[Asterisk-cvs] asterisk/pbx pbx_dundi.c,1.3,1.4

markster at lists.digium.com markster at lists.digium.com
Sat Oct 23 17:37:33 CDT 2004


Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv3033/pbx

Modified Files:
	pbx_dundi.c 
Log Message:
Fix for FreeBSD (netbsd too?) (bug #2702)


Index: pbx_dundi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_dundi.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pbx_dundi.c	22 Oct 2004 14:19:11 -0000	1.3
+++ pbx_dundi.c	23 Oct 2004 21:41:17 -0000	1.4
@@ -39,13 +39,18 @@
 #include <sys/socket.h>
 #include <string.h>
 #include <errno.h>
-#if defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+#include <sys/types.h>
 #include <netinet/in_systm.h>
 #endif
 #include <netinet/ip.h>
 #include <sys/ioctl.h>
 #include <netinet/in.h>
 #include <net/if.h>
+#if defined(__FreeBSD__)
+#include <net/if_dl.h>
+#include <ifaddrs.h>
+#endif
 #include <zlib.h>
 
 #define MAX_RESULTS	64
@@ -354,7 +359,7 @@
 
 static void reset_global_eid(void)
 {
-#if !defined(__NetBSD__)
+#if defined(SIOCGIFHWADDR)
 	int x,s;
 	char eid_str[20];
 	struct ifreq ifr;
@@ -372,6 +377,27 @@
 			}
         }
 	}
+#else
+#if defined(ifa_broadaddr)
+	char eid_str[20];
+	struct ifaddrs *ifap;
+	
+	if (getifaddrs(&ifap) == 0) {
+		struct ifaddrs *p;
+		for (p = ifap; p; p = p->ifa_next) {
+			if (p->ifa_addr->sa_family == AF_LINK) {
+				struct sockaddr_dl* sdp = (struct sockaddr_dl*) p->ifa_addr;
+				memcpy(
+					&(global_eid.eid),
+					sdp->sdl_data + sdp->sdl_nlen, 6);
+				ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name);
+				freeifaddrs(ifap);
+				return;
+			}
+		}
+		freeifaddrs(ifap);
+	}
+#endif
 #endif
 	ast_log(LOG_NOTICE, "No ethernet interface found for seeding global EID  You will have to set it manually.\n");
 }




More information about the svn-commits mailing list