]> ruderich.org/simon Gitweb - socket2unix/socket2unix.git/blobdiff - src/socket2unix.c
Fix compile on FreeBSD.
[socket2unix/socket2unix.git] / src / socket2unix.c
index 848a40bf68745eecf0fd9dd2bf3416d65ace8e61..c90c864ebecf79b805e96a29add3412efcb7596e 100644 (file)
 /* Necessary for RTLD_NEXT. */
 #define _GNU_SOURCE
 
+#include <config.h>
+
 #include <assert.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <netinet/in.h>
-#include <netinet/ip.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -197,7 +198,11 @@ static const char *get_socket_path(void) {
 static int get_log_level(void) {
     const char *level = getenv("SOCKET2UNIX_DEBUG");
     if (!level) {
+#ifdef DEBUG
+        return LOG_LEVEL_DEBUG;
+#else
         return LOG_LEVEL_WARNING;
+#endif
     }
     int number = atoi(level);
     if (number <= 0 || number > LOG_LEVEL_DEBUG) {
@@ -217,18 +222,28 @@ static const char *af_to_name(int af) {
         return "AF_INET6";
     } else if (af == AF_IPX) {
         return "AF_IPX";
+#ifdef AF_NETLINK
     } else if (af == AF_NETLINK) {
         return "AF_NETLINK";
+#endif
+#ifdef AF_X25
     } else if (af == AF_X25) {
         return "AF_X25";
+#endif
+#ifdef AF_AX25
     } else if (af == AF_AX25) {
         return "AF_AX25";
+#endif
+#ifdef AF_ATMPVC
     } else if (af == AF_ATMPVC) {
         return "AF_ATMPVC";
+#endif
     } else if (af == AF_APPLETALK) {
         return "AF_APPLETALK";
+#ifdef AF_PACKET
     } else if (af == AF_PACKET) {
         return "AF_PACKET";
+#endif
     } else {
         return "AF_UNKNOWN";
     }
@@ -244,8 +259,10 @@ static const char *sock_to_name(int sock) {
         return "SOCK_RAW";
     } else if (sock & SOCK_RDM) {
         return "SOCK_RDM";
+#ifdef SOCK_PACKET
     } else if (sock & SOCK_PACKET) {
         return "SOCK_PACKET";
+#endif
     } else {
         return "SOCK_UNKNOWN";
     }
@@ -254,10 +271,14 @@ static const char *sock_to_name(int sock) {
 static const char *level_to_name(int level) {
     if (level == SOL_SOCKET) {
         return "SOL_SOCKET";
+#ifdef SOL_IP
     } else if (level == SOL_IP) {
         return "SOL_IP";
+#endif
+#ifdef SOL_IPV6
     } else if (level == SOL_IPV6) {
         return "SOL_IPV6";
+#endif
     } else if (level == IPPROTO_TCP) {
         return "IPPROTO_TCP";
     } else if (level == IPPROTO_UDP) {