[Freeswitch-trunk] [commit] r6632 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua: bnf nta nth sresolv stun su su/sofia-sip tport

Freeswitch SVN mikej at freeswitch.org
Tue Dec 11 05:45:06 EST 2007


Author: mikej
Date: Tue Dec 11 05:45:05 2007
New Revision: 6632

Modified:
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_common.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_mini.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_ntop.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_pton.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c

Log:
prepend su_ to inet_ntop and inet_pton replacement functions to work around problematic msvc 9 headers

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c	Tue Dec 11 05:45:05 2007
@@ -849,7 +849,7 @@
     len = span_ip6_address(s);
 
   if (len) {
-    if (s[len] == '\0' && inet_pton(AF_INET6, s, addr) == 1) {
+    if (s[len] == '\0' && su_inet_pton(AF_INET6, s, addr) == 1) {
       if (SU_IN6_IS_ADDR_V4MAPPED(addr) ||
 	  SU_IN6_IS_ADDR_V4COMPAT(addr)) {
 	memcpy(addr, addr + 12, 4);
@@ -868,7 +868,7 @@
       s = memcpy(tmp, s, len + 1);
       scan_ip4_address(&tmp);      
     }
-    if (s[len] == '\0' && inet_pton(AF_INET, s, addr) == 1)
+    if (s[len] == '\0' && su_inet_pton(AF_INET, s, addr) == 1)
       return (void)(*return_addrlen = 4), len;
   }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	Tue Dec 11 05:45:05 2007
@@ -1795,7 +1795,7 @@
       int port;
 
       if (su) {
-	inet_ntop(su->su_family, SU_ADDR(su), host, sizeof host);
+	su_inet_ntop(su->su_family, SU_ADDR(su), host, sizeof host);
 	maddr = use_maddr && strcasecmp(canon, host) != 0;
 	port = ntohs(su->su_port);
       }
@@ -7524,7 +7524,7 @@
 	  orq->orq_method_name, orq->orq_cseq->cs_seq,
 	  todo, su_strerror(error), error, 
 	  tpn->tpn_proto, 
-	  inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
+	  su_inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
 	  htons(su->su_port));
 }
 
@@ -9582,7 +9582,7 @@
         aaaa->aaaa_record->r_type != sres_type_aaaa)
       continue;			      /* There was an error */
 
-    inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
+    su_inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
 
     if (j == 0)
       SU_DEBUG_5(("nta(%p): %s IN AAAA %s\n", (void *)orq, 
@@ -9665,7 +9665,7 @@
 	a->a_record->r_type != sres_type_a)
       continue;			      /* There was an error */
 
-    inet_ntop(AF_INET, &a->a_addr, addr, sizeof(addr));
+    su_inet_ntop(AF_INET, &a->a_addr, addr, sizeof(addr));
 
     if (j == 0)
       SU_DEBUG_5(("nta: %s IN A %s\n", a->a_record->r_name, addr));

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c	Tue Dec 11 05:45:05 2007
@@ -1075,7 +1075,7 @@
 	 hc->hc_method_name,
 	 errmsg, error,
 	 tpn->tpn_proto,
-	 inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
+	 su_inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
 	 htons(su->su_port));
 
   he->he_stats->st_tp_errors++;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	Tue Dec 11 05:45:05 2007
@@ -166,10 +166,14 @@
 #define SRES_TIME_MAX ((time_t)LONG_MAX)
 
 #if !HAVE_INET_PTON
-int inet_pton(int af, char const *src, void *dst);
+int su_inet_pton(int af, char const *src, void *dst);
+#else
+#define su_inet_pton inet_pton
 #endif
 #if !HAVE_INET_NTOP
-const char *inet_ntop(int af, void const *src, char *dst, size_t size);
+const char *su_inet_ntop(int af, void const *src, char *dst, size_t size);
+#else
+#define su_inet_ntop inet_ntop
 #endif
 
 #if defined(va_copy)
@@ -2374,14 +2378,14 @@
   if (strchr(server, ':')) {
     struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
     memset(sa, 0, ns->ns_addrlen = sizeof *sin6);
-    err = inet_pton(sa->sa_family = AF_INET6, server, &sin6->sin6_addr);
+    err = su_inet_pton(sa->sa_family = AF_INET6, server, &sin6->sin6_addr);
   } 
   else 
 #endif
     {
       struct sockaddr_in *sin = (struct sockaddr_in *)sa;
       memset(sa, 0, ns->ns_addrlen = sizeof *sin);
-      err = inet_pton(sa->sa_family = AF_INET, server, &sin->sin_addr);
+      err = su_inet_pton(sa->sa_family = AF_INET, server, &sin->sin_addr);
     }
 
   if (err <= 0) {
@@ -2469,7 +2473,7 @@
     dns->dns_socket = INVALID_SOCKET;
     ns = c->c_nameservers[i];
     memcpy(dns->dns_addr, ns->ns_addr, dns->dns_addrlen = ns->ns_addrlen);
-    inet_ntop(dns->dns_addr->ss_family, SS_ADDR(dns->dns_addr), 
+    su_inet_ntop(dns->dns_addr->ss_family, SS_ADDR(dns->dns_addr), 
 	      dns->dns_name, sizeof dns->dns_name);
     dns->dns_edns = c->c_opt.edns;
     servers[i] = dns++;
@@ -2554,12 +2558,12 @@
 
     if (family == AF_INET) {
       void *addr = &((struct sockaddr_in *)dns->dns_addr)->sin_addr;
-      inet_ntop(family, addr, ipaddr, sizeof ipaddr);
+      su_inet_ntop(family, addr, ipaddr, sizeof ipaddr);
     }
 #if HAVE_SIN6
     else if (family == AF_INET6) {
       void *addr = &((struct sockaddr_in6 *)dns->dns_addr)->sin6_addr;
-      inet_ntop(family, addr, ipaddr, sizeof ipaddr);
+      su_inet_ntop(family, addr, ipaddr, sizeof ipaddr);
       lb = "[", rb = "]";
     }
 #endif
@@ -3168,7 +3172,7 @@
 
 	snprintf(info + strlen(info), sizeof(info) - strlen(info), 
 		 " reported by ");
-	inet_ntop(from->ss_family, SS_ADDR(from), 
+	su_inet_ntop(from->ss_family, SS_ADDR(from), 
 		  info + strlen(info), sizeof(info) - strlen(info));
       }
 
@@ -3232,13 +3236,13 @@
     if (remote->ss_family == AF_INET) {
       struct sockaddr_in const *sin = (struct sockaddr_in *)remote;
       uint8_t const *in_addr = (uint8_t*)&sin->sin_addr;
-      inet_ntop(AF_INET, in_addr, buf, sizeof(buf));
+      su_inet_ntop(AF_INET, in_addr, buf, sizeof(buf));
     } 
 #if HAVE_SIN6
     else if (remote->ss_family == AF_INET6) {
       struct sockaddr_in6 const *sin6 = (struct sockaddr_in6 *)remote;
       uint8_t const *in_addr = (uint8_t*)&sin6->sin6_addr;
-      inet_ntop(AF_INET6, in_addr, buf, sizeof(buf));
+      su_inet_ntop(AF_INET6, in_addr, buf, sizeof(buf));
     }
 #endif
   }
@@ -3365,12 +3369,12 @@
       ;
     else if (from->ss_family == AF_INET) {
       struct sockaddr_in const *sin = (void *)from;
-      inet_ntop(AF_INET, &sin->sin_addr, host, sizeof host);
+      su_inet_ntop(AF_INET, &sin->sin_addr, host, sizeof host);
     } 
 #if HAVE_SIN6
     else if (from->ss_family == AF_INET6) {
       struct sockaddr_in6 const *sin6 = (void *)from;
-      inet_ntop(AF_INET6, &sin6->sin6_addr, host, sizeof host);
+      su_inet_ntop(AF_INET6, &sin6->sin6_addr, host, sizeof host);
     }
 #endif
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c	Tue Dec 11 05:45:05 2007
@@ -803,7 +803,7 @@
 
     if ((err = bind(s, &su->su_sa, sulen)) < 0) {
       SU_DEBUG_3(("%s: bind(%s:%u): %s\n",  __func__, 
-		  inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
+		  su_inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
 		  (unsigned) ntohs(su->su_port),
 		  su_strerror(su_errno())));
       return -1;
@@ -817,7 +817,7 @@
   memcpy(&sd->sd_bind_addr, su, sulen);
 
   SU_DEBUG_3(("%s: local socket is bound to %s:%u\n", __func__,
-	      inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
+	      su_inet_ntop(su->su_family, SU_ADDR(su), addr, sizeof(addr)),
 	      (unsigned) ntohs(su->su_port)));
 
   events = SU_WAIT_IN | SU_WAIT_ERR;
@@ -864,7 +864,7 @@
       memcpy(su, li->li_addr, *return_len = li->li_addrlen);
 
       SU_DEBUG_3(("%s: using local address %s\n", __func__, 
-		  inet_ntop(family, SU_ADDR(su), addr, sizeof(addr))));
+		  su_inet_ntop(family, SU_ADDR(su), addr, sizeof(addr))));
       break;
     }
 
@@ -1693,7 +1693,7 @@
 
   
   SU_DEBUG_5(("%s: response from server %s:%u\n", __func__,
-	      inet_ntop(recv.su_family, SU_ADDR(&recv), addr, sizeof(addr)),
+	      su_inet_ntop(recv.su_family, SU_ADDR(&recv), addr, sizeof(addr)),
 	      ntohs(recv.su_port)));
 
   debug_print(&binding_response.enc_buf);      
@@ -2014,7 +2014,7 @@
   char addr[SU_ADDRSIZE];
 
   SU_DEBUG_5(("%s: checking if %s is a local address.\n", __func__, 
-	      inet_ntop(AF_INET, SU_ADDR(su), addr, sizeof(addr))));
+	      su_inet_ntop(AF_INET, SU_ADDR(su), addr, sizeof(addr))));
 
   hints->li_family = af = su->su_family;
 
@@ -2032,7 +2032,7 @@
     }
 
     SU_DEBUG_9(("%s: skipping local address %s.\n", __func__, 
-		inet_ntop(af, SU_ADDR(li->li_addr), addr, sizeof(addr))));
+		su_inet_ntop(af, SU_ADDR(li->li_addr), addr, sizeof(addr))));
   }  
 
   su_freelocalinfo(res);
@@ -2758,7 +2758,7 @@
   }
 
   SU_DEBUG_3(("%s: socket y bound to %s:%u\n", __func__,
-	      inet_ntop(y_addr.su_family, SU_ADDR(&y_addr), addr, sizeof(addr)),
+	      su_inet_ntop(y_addr.su_family, SU_ADDR(&y_addr), addr, sizeof(addr)),
 	      (unsigned) ntohs(y_addr.su_port)));
 
   req->sr_from_y = -1;
@@ -2946,7 +2946,7 @@
   req = stun_request_create(sd);
 
   SU_DEBUG_3(("%s: Starting to send STUN keepalives to %s:%u\n", __func__, 
-	      inet_ntop(sa->su_family, SU_ADDR(sa), addr, sizeof(addr)),
+	      su_inet_ntop(sa->su_family, SU_ADDR(sa), addr, sizeof(addr)),
 	      (unsigned) ntohs(sa->su_port)));
   
   if (stun_make_binding_req(sh, req, req->sr_msg, 0, 0) < 0 ||

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_common.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_common.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_common.c	Tue Dec 11 05:45:05 2007
@@ -223,7 +223,7 @@
   memcpy(&addr->su_sin.sin_addr.s_addr, p + 4, 4);
 
   SU_DEBUG_5(("%s: address attribute: %s:%d\n", __func__,
-	      inet_ntop(addr->su_family, SU_ADDR(addr), ipaddr, sizeof(ipaddr)),
+	      su_inet_ntop(addr->su_family, SU_ADDR(addr), ipaddr, sizeof(ipaddr)),
 	      (unsigned) ntohs(addr->su_sin.sin_port)));
 
   attr->pattr = addr;
@@ -640,7 +640,7 @@
   }
 
   if (err > 0) {
-    inet_ntop(to_addr->su_family, SU_ADDR(to_addr), ipaddr, sizeof(ipaddr));
+    su_inet_ntop(to_addr->su_family, SU_ADDR(to_addr), ipaddr, sizeof(ipaddr));
     SU_DEBUG_5(("%s: message sent to %s:%u\n", __func__,
 		ipaddr, ntohs(to_addr->su_port)));
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_mini.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_mini.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun_mini.c	Tue Dec 11 05:45:05 2007
@@ -184,7 +184,7 @@
     struct sockaddr_in const *sin = from;
 
     if (sin->sin_family == AF_INET)
-      inet_ntop(sin->sin_family, &sin->sin_addr, buffer, sizeof buffer);
+      su_inet_ntop(sin->sin_family, &sin->sin_addr, buffer, sizeof buffer);
     else
       sprintf(buffer, "<af=%u>", (unsigned)sin->sin_family);
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_ntop.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_ntop.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_ntop.c	Tue Dec 11 05:45:05 2007
@@ -45,7 +45,7 @@
  *	Paul Vixie, 1996.
  */
 const char *
-inet_ntop(int af, void const *src, char *dst, size_t size)
+su_inet_ntop(int af, void const *src, char *dst, size_t size)
 {
 
 	switch (af) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_pton.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_pton.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/inet_pton.c	Tue Dec 11 05:45:05 2007
@@ -45,7 +45,7 @@
  *	Paul Vixie, 1996.
  */
 int
-inet_pton(int af, const char * src, void * dst)
+su_inet_pton(int af, const char * src, void * dst)
 {
 	switch (af) {
 	case AF_INET:

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su.h	Tue Dec 11 05:45:05 2007
@@ -321,8 +321,8 @@
 #endif
 
 #if SU_HAVE_WINSOCK
-SOFIAPUBFUN int inet_pton(int af, char const *src, void *dst);
-SOFIAPUBFUN const char *inet_ntop(int af, void const *src,
+SOFIAPUBFUN int su_inet_pton(int af, char const *src, void *dst);
+SOFIAPUBFUN const char *su_inet_ntop(int af, void const *src,
 				  char *dst, size_t size);
 SOFIAPUBFUN ssize_t 
   su_send(su_socket_t s, void *buffer, size_t length, int flags),
@@ -351,6 +351,8 @@
 #define htonl su_ntohl
 
 #else
+#define su_inet_pton inet_pton
+#define su_inet_ntop inet_ntop
 #define su_send(s,b,l,f) send((s),(b),(l),(f))
 #define su_sendto(s,b,l,f,a,L) sendto((s),(b),(l),(f),(void const*)(a),(L))
 #define su_recv(s,b,l,f) recv((s),(b),(l),(f))

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	Tue Dec 11 05:45:05 2007
@@ -1596,7 +1596,7 @@
       if ((flags & LI_NAMEREQD) == LI_NAMEREQD)
 	return 1;
       SU_DEBUG_7(("li_name: getnameinfo() failed\n"));
-      if (!inet_ntop(su->su_family, SU_ADDR(su), name, sizeof name))
+      if (!su_inet_ntop(su->su_family, SU_ADDR(su), name, sizeof name))
 	return ELI_RESOLVER;
     }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c	Tue Dec 11 05:45:05 2007
@@ -2954,14 +2954,14 @@
 #if SU_HAVE_IN6
     if (su->su_family == AF_INET6) {
       ipaddr[0] = '[';
-      inet_ntop(su->su_family, SU_ADDR(su), ipaddr + 1, sizeof(ipaddr) - 1);
+      su_inet_ntop(su->su_family, SU_ADDR(su), ipaddr + 1, sizeof(ipaddr) - 1);
       strcat(ipaddr, "]");
     }
     else {
-      inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr));
+      su_inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr));
     }
 #else
-    inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr));
+    su_inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr));
 #endif
 
     d->d_from->tpn_canon = ipaddr;
@@ -3949,7 +3949,7 @@
 #if SU_HAVE_IN6
   SU_DEBUG_9(("tport_resolve addrinfo = %s%s%s:%d\n", 
 	      su->su_family == AF_INET6 ? "[" : "",
-              inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr)),
+              su_inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr)),
 	      su->su_family == AF_INET6 ? "]" : "",
               htons(su->su_port)));
 #else
@@ -4433,7 +4433,7 @@
 
     su->su_port = htons(strtoul(port, NULL, 10));
     
-    if (inet_pton(su->su_family, host, SU_ADDR(su)) > 0) {
+    if (su_inet_pton(su->su_family, host, SU_ADDR(su)) > 0) {
       resolved = 1;
       next = NULL;
 
@@ -4710,7 +4710,7 @@
   }
 #endif
 
-  if (inet_ntop(su->su_family, SU_ADDR(su), b, bufsize) == NULL)
+  if (su_inet_ntop(su->su_family, SU_ADDR(su), b, bufsize) == NULL)
     return NULL;
   n = strlen(b); 
   if (bufsize < n + 2)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c	Tue Dec 11 05:45:05 2007
@@ -154,7 +154,7 @@
   if (msg_addrinfo(msg)->ai_flags & TP_AI_COMPRESSED)
     comp = ";comp=sigcomp";
 
-  inet_ntop(su->su_family, SU_ADDR(su), name, sizeof(name));
+  su_inet_ntop(su->su_family, SU_ADDR(su), name, sizeof(name));
 
   snprintf(stamp, 128,
 	   "%s "MOD_ZU" bytes %s %s/[%s]:%u%s%s at %02u:%02u:%02u.%06lu:\n",



More information about the Freeswitch-trunk mailing list