[Freeswitch-svn] [commit] r11819 - freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su

FreeSWITCH SVN mikej at freeswitch.org
Wed Feb 11 08:57:55 PST 2009


Author: mikej
Date: Wed Feb 11 10:57:55 2009
New Revision: 11819

Log:
Tue Jan 13 16:20:06 CST 2009  Pekka Pessi <first.last at nokia.com>
  * su_localinfo.c: using SU_LOCALINFO_TEST



Modified:
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c	Wed Feb 11 10:57:55 2009
@@ -67,7 +67,11 @@
 #include <net/if_types.h>
 #endif
 
-#if HAVE_GETIFADDRS
+#if SU_LOCALINFO_TEST
+
+#undef USE_LOCALINFO0
+
+#elif HAVE_GETIFADDRS
 
 #define USE_LOCALINFO0 1
 #define localinfo0 bsd_localinfo
@@ -81,6 +85,7 @@
 static int win_localinfo(su_localinfo_t const *, su_localinfo_t **);
 
 #else
+/* No localinfo0(), use localinfo4() and localinfo6() */
 
 #undef USE_LOCALINFO0
 static int localinfo4(su_localinfo_t const *, su_localinfo_t **);
@@ -90,9 +95,13 @@
 
 #endif
 
+static int li_scope4(uint32_t ip4);
+static int li_scope6(struct in6_addr const *ip6);
+
+#if !SU_LOCALINFO_TEST
+
 static int li_name(su_localinfo_t const*, int, su_sockaddr_t const*, char **);
 static void li_sort(su_localinfo_t *i, su_localinfo_t **rresult);
-static int li_scope4(uint32_t ip4);
 
 /** @brief Request local address information.
  *
@@ -196,8 +205,13 @@
     *hh = *hints;
     if (hh->li_canonname)
       hh->li_flags |= LI_CANONNAME;
+#if 0
+    /* hints->li_ifname is used to select by interface,
+       li_ifname is returned with LI_IFNAME flag
+    */
     if ((hh->li_flags & LI_IFNAME) && hh->li_ifname == NULL)
       return ELI_BADHINTS;
+#endif
   }
 
   switch (hh->li_family) {
@@ -255,6 +269,8 @@
   return error;
 }
 
+#endif
+
 /** Free local address information.
  *
  * Free a list of su_localinfo_t structures obtained with su_getlocalinfo()
@@ -415,16 +431,17 @@
 extern int su_get_local_ip_addr(su_sockaddr_t *su);
 #endif
 
-#if USE_LOCALINFO0
+#if SU_LOCALINFO_TEST
 
+#elif USE_LOCALINFO0
+/* no localinfo4 */
 #elif HAVE_IFCONF
 #if __APPLE_CC__
 /** Build a list of local IPv4 addresses and append it to *rresult. */
 static
 int localinfo4(su_localinfo_t const *hints, su_localinfo_t **rresult)
 {
-  su_localinfo_t *tbf = NULL, **lli = &tbf;
-  su_localinfo_t *li = NULL, *li_first = NULL;
+  su_localinfo_t *li = NULL;
   su_sockaddr_t *su;
   int error = ELI_NOADDRESS;
   char *canonname = NULL;
@@ -453,8 +470,8 @@
   }
 
 
-  li = calloc(1, sizeof(su_localinfo_t));
-  sa = calloc(1, sizeof(su_sockaddr_t));
+  li = calloc(1, (sizeof *li) + (sizeof *sa));
+  sa = (void *)(li + 1);
 
   error = getsockname(s, (struct sockaddr *) sa, &salen);
   if (error < 0 && errno == SOCKET_ERROR) {
@@ -511,8 +528,7 @@
 
 err:
   if (canonname) free(canonname);
-  if (li_first) free(li_first);
-  su_freelocalinfo(tbf);
+  if (li) free(li);
   su_close(s);
 
   return error;
@@ -772,8 +788,7 @@
     li->li_addrlen = su_sockaddr_size(su);
     li->li_addr = su;
     li->li_canonname = canonname;
-    if (hints->li_flags & LI_IFNAME)
-      li->li_ifname = if_name;
+    li->li_ifname = if_name;
 
     canonname = NULL;
     li_first = NULL;
@@ -917,8 +932,8 @@
 
 #endif
 
-#if USE_LOCALINFO0 || !SU_HAVE_IN6
-
+#if USE_LOCALINFO0 || !SU_HAVE_IN6 || SU_LOCALINFO_TEST
+/* No localinfo6() */
 #elif HAVE_PROC_NET_IF_INET6
 /** Build a list of local IPv6 addresses and append it to *return_result. */
 static
@@ -1128,8 +1143,9 @@
 }
 #endif
 
-
-#if HAVE_GETIFADDRS
+#if !USE_LOCALINFO0
+/* no localinfo0() or bsd_localinfo() */
+#elif HAVE_GETIFADDRS
 
 #include <ifaddrs.h>
 
@@ -1455,6 +1471,7 @@
 }
 
 #elif HAVE_SIO_ADDRESS_LIST_QUERY
+
 static
 int localinfo0(su_localinfo_t const *hints, su_localinfo_t **rresult)
 {
@@ -1572,6 +1589,8 @@
 }
 #endif
 
+#if !SU_LOCALINFO_TEST
+
 static
 int li_name(su_localinfo_t const *hints,
 	    int gni_flags,
@@ -1639,6 +1658,8 @@
   }
 }
 
+#endif
+
 /**Get local IP address.
  *
  * @deprecated



More information about the Freeswitch-svn mailing list