#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>
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)) {
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;
-}
\ No newline at end of file
+}
+
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.
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
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])])
"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) {
#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). ------------------------------ */
#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
-Subproject commit 6d5933a2aa982fb8e7eb3f953ffa3bcf0e43a989
+Subproject commit d955c447dac0545803dee9c90312c9d42310e9b1
* OTHER DEALINGS IN THE SOFTWARE.
*/
+#include "definitions.h"
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#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>
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);
}
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");
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)
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;
// 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);