Changes to allow it to compile in FreeBSD and fix a few issues that were picked up by clang 10.
This commit is contained in:
@@ -49,7 +49,16 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#ifdef COMPILE_FOR_LINUX
|
||||
#include <netpacket/packet.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPILE_FOR_FREEBSD
|
||||
#include <netinet/in.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_dl.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPILE_FOR_OSX
|
||||
#include <CoreServices/CoreServices.h>
|
||||
@@ -1954,6 +1963,7 @@ int get_device_id(uint8_t *id, int int_length) {
|
||||
t = id;
|
||||
int found = 0;
|
||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
#ifdef AF_PACKET
|
||||
if ((ifa->ifa_addr) && (ifa->ifa_addr->sa_family == AF_PACKET)) {
|
||||
struct sockaddr_ll *s = (struct sockaddr_ll *)ifa->ifa_addr;
|
||||
if ((strcmp(ifa->ifa_name, "lo") != 0) && (found == 0)) {
|
||||
@@ -1963,8 +1973,25 @@ int get_device_id(uint8_t *id, int int_length) {
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#ifdef AF_LINK
|
||||
struct sockaddr_dl * sdl = (struct sockaddr_dl *) ifa->ifa_addr;
|
||||
if ((sdl) && (sdl->sdl_family == AF_LINK)) {
|
||||
if (sdl->sdl_type == IFT_ETHER) {
|
||||
char *s = LLADDR(sdl);
|
||||
for (i = 0; i < sdl->sdl_alen; i++) {
|
||||
debug(1,"char %d: \"%c\".", i, *s);
|
||||
*t++ = (uint8_t)*s++;
|
||||
}
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
freeifaddrs(ifaddr);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-4
@@ -25,7 +25,7 @@ fi
|
||||
with_os=`echo ${with_os} | tr '[[:upper:]]' '[[:lower:]]' `
|
||||
|
||||
if test "x${with_os}" != xlinux && "x${with_os}" != xfreebsd && "x${with_os}" != xdarwin ; then
|
||||
AC_MSG_ERROR(--with-os=<arg> argument must linux, freebsd, openbsd or darwin)
|
||||
AC_MSG_ERROR(--with-os=<arg> argument must linux freebsd openbsd or darwin)
|
||||
fi
|
||||
|
||||
# Checks for programs.
|
||||
@@ -44,11 +44,11 @@ if test "x${with_os}" = xopenbsd ; then
|
||||
AC_CHECK_LIB([c],[clock_gettime], , AC_MSG_ERROR(libc needed))
|
||||
fi
|
||||
|
||||
# Pass the conditionals to automake
|
||||
AM_CONDITIONAL([BUILD_FOR_LINUX], [test "x${with_os}" = xlinux ])
|
||||
AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "x${with_os}" = xfreebsd ])
|
||||
AM_CONDITIONAL([BUILD_FOR_OPENBSD], [test "x${with_os}" = xopenbsd ])
|
||||
|
||||
|
||||
##### Some build systems are not fully using pkg-config, so we can use the flag ${with_pkg_config} on a case-by-case basis
|
||||
##### to control how to deal with them
|
||||
##### Note -- this flag is sometimes ignored, especially for newer packages
|
||||
@@ -383,8 +383,14 @@ AC_ARG_WITH(airplay-2, [AS_HELP_STRING([--with-airplay-2],[Build for AirPlay 2])
|
||||
if test "x$with_airplay_2" = "xyes" ; then
|
||||
AC_DEFINE([CONFIG_AIRPLAY_2], 1, [Build for AirPlay 2])
|
||||
AC_MSG_RESULT(>>Include libraries required for AirPlay 2)
|
||||
PKG_CHECK_MODULES([plist], [libplist >= 2.0.0],[CFLAGS="${plist_CFLAGS} ${CFLAGS}" LIBS="${plist_LIBS} ${LIBS}"],[AC_MSG_ERROR(AirPlay 2 support requires libplist 2.0.0 or later -- libplist-dev suggested!)])
|
||||
AC_CHECK_LIB([sodium], [sodium_init], ,[AC_MSG_ERROR([AirPlay 2 support requires libsodium -- libsodium-dev suggested])])
|
||||
if test "x${with_os}" = xlinux ; then
|
||||
PKG_CHECK_MODULES([libplist], [libplist >= 2.0.0],[CFLAGS="${libplist_CFLAGS} ${CFLAGS}" LIBS="${libplist_LIBS} ${LIBS}"],[AC_MSG_ERROR(AirPlay 2 support requires libplist 2.0.0 or later -- libplist-dev suggested!)])
|
||||
fi
|
||||
if test "x${with_os}" = xfreebsd ; then
|
||||
PKG_CHECK_MODULES([libplist], [libplist-2.0 >= 2.0.0],[CFLAGS="${libplist_CFLAGS} ${CFLAGS}" LIBS="${libplist_LIBS} ${LIBS}"],[AC_MSG_ERROR(AirPlay 2 support requires libplist 2.0.0 or later -- search for pkg libplist-2.2.0 or later!)])
|
||||
fi
|
||||
PKG_CHECK_MODULES([libsodium], [libsodium],[CFLAGS="${libsodium_CFLAGS} ${CFLAGS}" LIBS="${libsodium_LIBS} ${LIBS}"],[AC_MSG_ERROR(AirPlay 2 support requires libsodium -- libsodium-dev suggested)])
|
||||
# AC_CHECK_LIB([sodium], [sodium_init], ,[AC_MSG_ERROR([AirPlay 2 support requires libsodium -- libsodium-dev suggested])])
|
||||
AC_CHECK_LIB([avutil],[av_malloc], [], [AC_MSG_ERROR([Airplay 2 support requires libavutil -- libavutil-dev suggested])])
|
||||
AC_CHECK_LIB([avcodec],[avcodec_find_encoder], [], [AC_MSG_ERROR([AirPlay 2 support requires libavcodec -- libavcodec-dev suggested])])
|
||||
AC_CHECK_LIB([avformat],[avformat_new_stream], [], [AC_MSG_ERROR([AirPlay 2 support requires libavformat -- libavformat-dev suggested])])
|
||||
|
||||
@@ -465,7 +465,7 @@ void dacp_monitor_port_update_callback(char *dacp_id, uint16_t port) {
|
||||
"dacp_monitor_port_update_callback with Remote ID \"%s\", target ID \"%s\" and port "
|
||||
"number %d.",
|
||||
dacp_id, dacp_server.dacp_id, port);
|
||||
if ((dacp_id == NULL) || (dacp_server.dacp_id == NULL)) {
|
||||
if ((dacp_id == NULL) || (dacp_server.dacp_id[0] == '\0')) {
|
||||
warn("dacp_id or dacp_server.dacp_id NULL detected");
|
||||
} else {
|
||||
if (strcmp(dacp_id, dacp_server.dacp_id) == 0) {
|
||||
|
||||
+12
-5
@@ -1,14 +1,9 @@
|
||||
#ifndef _DEFINITIONS_H
|
||||
#define _DEFINITIONS_H
|
||||
|
||||
//#include <libconfig.h>
|
||||
//#include <signal.h>
|
||||
//#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
//#include "audio.h"
|
||||
#include "config.h"
|
||||
//#include "mdns.h"
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* Apple OSX and iOS (Darwin). ------------------------------ */
|
||||
@@ -23,6 +18,18 @@
|
||||
#define COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD 1
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#define COMPILE_FOR_LINUX 1
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#define COMPILE_FOR_BSD 1
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define COMPILE_FOR_FREEBSD 1
|
||||
#endif
|
||||
|
||||
// struct sockaddr_in6 is bigger than struct sockaddr. derp
|
||||
#ifdef AF_INET6
|
||||
#define SOCKADDR struct sockaddr_storage
|
||||
|
||||
+1
-1
Submodule pair_ap updated: 6d5933a2aa...d955c447da
@@ -24,6 +24,7 @@
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "definitions.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -31,6 +32,10 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#ifdef COMPILE_FOR_FREEBSD
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "common.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
@@ -1498,7 +1498,8 @@ void *rtp_event_receiver(void *arg) {
|
||||
socklen_t addr_size = sizeof(remote_addr);
|
||||
|
||||
int fd = accept(conn->event_socket, (struct sockaddr *)&remote_addr, &addr_size);
|
||||
pthread_cleanup_push(socket_cleanup, (void *)fd);
|
||||
intptr_t pfd = fd;
|
||||
pthread_cleanup_push(socket_cleanup, (void *)pfd);
|
||||
int finished = 0;
|
||||
do {
|
||||
nread = recv(fd, packet, sizeof(packet), 0);
|
||||
@@ -1792,11 +1793,11 @@ void *rtp_realtime_audio_receiver(void *arg) {
|
||||
}
|
||||
|
||||
ssize_t buffered_read(buffered_tcp_desc *descriptor, void *buf, size_t count) {
|
||||
ssize_t response;
|
||||
ssize_t response = -1;
|
||||
if (pthread_mutex_lock(&descriptor->mutex) != 0)
|
||||
debug(1, "problem with mutex");
|
||||
pthread_cleanup_push(mutex_unlock, (void *)&descriptor->mutex);
|
||||
if ((descriptor->closed == 0)) {
|
||||
if (descriptor->closed == 0) {
|
||||
while ((descriptor->buffer_occupancy == 0) && (descriptor->error_code == 0)) {
|
||||
if (pthread_cond_wait(&descriptor->not_empty_cv, &descriptor->mutex))
|
||||
debug(1, "Error waiting for buffered read");
|
||||
@@ -1848,7 +1849,8 @@ void *buffered_tcp_reader(void *arg) {
|
||||
socklen_t addr_size = sizeof(remote_addr);
|
||||
int finished = 0;
|
||||
int fd = accept(descriptor->sock_fd, (struct sockaddr *)&remote_addr, &addr_size);
|
||||
pthread_cleanup_push(socket_cleanup, (void *)fd);
|
||||
intptr_t pfd = fd;
|
||||
pthread_cleanup_push(socket_cleanup, (void *)pfd);
|
||||
|
||||
do {
|
||||
if (pthread_mutex_lock(&descriptor->mutex) != 0)
|
||||
|
||||
@@ -115,6 +115,10 @@ pid_t pid;
|
||||
int this_is_the_daemon_process = 0;
|
||||
#endif
|
||||
|
||||
#ifndef UUID_STR_LEN
|
||||
#define UUID_STR_LEN 36
|
||||
#endif
|
||||
|
||||
pthread_t rtsp_listener_thread;
|
||||
|
||||
int killOption = 0;
|
||||
@@ -1616,6 +1620,7 @@ int main(int argc, char **argv) {
|
||||
// with thanks
|
||||
uuid_t binuuid;
|
||||
uuid_generate_random(binuuid);
|
||||
|
||||
char *uuid = malloc(UUID_STR_LEN);
|
||||
/* Produces a UUID string at uuid consisting of lower-case letters. */
|
||||
uuid_unparse_lower(binuuid, uuid);
|
||||
|
||||
Reference in New Issue
Block a user