Merged revisions 99643 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 22 Jan 2008 20:42:47 +0000 (20:42 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 22 Jan 2008 20:42:47 +0000 (20:42 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r99643 | tilghman | 2008-01-22 14:34:55 -0600 (Tue, 22 Jan 2008) | 2 lines

Fix the defines for OS X (and Solaris, too)

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@99646 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/acl.c

index 7df1501..810ec80 100644 (file)
@@ -29,11 +29,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/network.h"
 
 
 #include "asterisk/network.h"
 
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__Darwin__)
+#include <fcntl.h>
+#include <net/route.h>
+#endif
+
 #if defined(SOLARIS)
 #include <sys/sockio.h>
 #endif
 
 #if defined(SOLARIS)
 #include <sys/sockio.h>
 #endif
 
-#if defined(__linux__)
+#if defined(__Darwin__) || defined(__linux__)
 #include <ifaddrs.h>
 #endif
 
 #include <ifaddrs.h>
 #endif
 
@@ -103,23 +108,23 @@ static void score_address(const struct sockaddr_in *sin, struct in_addr *best_ad
 static int get_local_address(struct in_addr *ourip)
 {
        int s, res = -1;
 static int get_local_address(struct in_addr *ourip)
 {
        int s, res = -1;
-#ifdef _SOLARIS
+#ifdef SOLARIS
        struct lifreq *ifr = NULL;
        struct lifnum ifn;
        struct lifconf ifc;
        struct sockaddr_in *sa;
        char *buf = NULL;
        int bufsz, x;
        struct lifreq *ifr = NULL;
        struct lifnum ifn;
        struct lifconf ifc;
        struct sockaddr_in *sa;
        char *buf = NULL;
        int bufsz, x;
-#endif /* _SOLARIS */
-#if defined(_BSD) || defined(__linux__)
+#endif /* SOLARIS */
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__)
        struct ifaddrs *ifap, *ifaphead;
        int rtnerr;
        const struct sockaddr_in *sin;
        struct ifaddrs *ifap, *ifaphead;
        int rtnerr;
        const struct sockaddr_in *sin;
-#endif /* defined(_BSD) || defined(_LINUX) */
+#endif /* BSD_OR_LINUX */
        struct in_addr best_addr = { 0, };
        int best_score = -100;
 
        struct in_addr best_addr = { 0, };
        int best_score = -100;
 
-#if defined(_BSD) || defined(__linux__)
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__)
        rtnerr = getifaddrs(&ifaphead);
        if (rtnerr) {
                perror(NULL);
        rtnerr = getifaddrs(&ifaphead);
        if (rtnerr) {
                perror(NULL);
@@ -130,7 +135,7 @@ static int get_local_address(struct in_addr *ourip)
        s = socket(AF_INET, SOCK_STREAM, 0);
 
        if (s > 0) {
        s = socket(AF_INET, SOCK_STREAM, 0);
 
        if (s > 0) {
-#if defined(_BSD) || defined(__linux__)
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__)
                for (ifap = ifaphead; ifap; ifap = ifap->ifa_next) {
 
                        if (ifap->ifa_addr->sa_family == AF_INET) {
                for (ifap = ifaphead; ifap; ifap = ifap->ifa_next) {
 
                        if (ifap->ifa_addr->sa_family == AF_INET) {
@@ -142,10 +147,10 @@ static int get_local_address(struct in_addr *ourip)
                                        break;
                        }
                }
                                        break;
                        }
                }
-#endif /* _BSD */
+#endif /* BSD_OR_LINUX */
 
                /* There is no reason whatsoever that this shouldn't work on Linux or BSD also. */
 
                /* There is no reason whatsoever that this shouldn't work on Linux or BSD also. */
-#ifdef _SOLARIS
+#ifdef SOLARIS
                /* Get a count of interfaces on the machine */
                ifn.lifn_family = AF_INET;
                ifn.lifn_flags = 0;
                /* Get a count of interfaces on the machine */
                ifn.lifn_family = AF_INET;
                ifn.lifn_flags = 0;
@@ -183,13 +188,13 @@ static int get_local_address(struct in_addr *ourip)
                }
 
                free(buf);
                }
 
                free(buf);
-#endif /* _SOLARIS */
+#endif /* SOLARIS */
                
                close(s);
        }
                
                close(s);
        }
-#if defined(_BSD) || defined(__linux__)
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__)
        freeifaddrs(ifaphead);
        freeifaddrs(ifaphead);
-#endif
+#endif /* BSD_OR_LINUX */
 
        if (res == 0 && ourip)
                memcpy(ourip, &best_addr, sizeof(*ourip));
 
        if (res == 0 && ourip)
                memcpy(ourip, &best_addr, sizeof(*ourip));