trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1232675 - in /trafficserver/traffic/trunk: CHANGES configure.ac lib/ts/ink_inet.h
Date Wed, 18 Jan 2012 00:50:50 GMT
Author: zwoop
Date: Wed Jan 18 00:50:50 2012
New Revision: 1232675

URL: http://svn.apache.org/viewvc?rev=1232675&view=rev
Log:
TS-1041 Populate sockaddr length. Author: James Peach.

Modified:
    trafficserver/traffic/trunk/CHANGES
    trafficserver/traffic/trunk/configure.ac
    trafficserver/traffic/trunk/lib/ts/ink_inet.h

Modified: trafficserver/traffic/trunk/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/CHANGES?rev=1232675&r1=1232674&r2=1232675&view=diff
==============================================================================
--- trafficserver/traffic/trunk/CHANGES (original)
+++ trafficserver/traffic/trunk/CHANGES Wed Jan 18 00:50:50 2012
@@ -1,5 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 3.1.2
+  *) [TS-1041] Populate sockaddr length. Author: James Peach.
+
   *) [TS-1081] Eliminate an additional copy of the pristine URL string.
 
   *) [TS-1038] SHttpTxnErrorBodySet() can leak memory.

Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=1232675&r1=1232674&r2=1232675&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Wed Jan 18 00:50:50 2012
@@ -1134,6 +1134,27 @@ TS_FLAG_HEADERS([netinet/ip_icmp.h], [],
 AC_SUBST(netinet_iph)
 AC_SUBST(netinet_ip_icmph)
 
+# BSD-derived systems populate the socket length in the structure itself. It's
+# redundant to check all of these, but hey, I need the typing practice.
+AC_CHECK_MEMBER([struct sockaddr.sa_len], [], [], [#include <netinet/in.h>])
+AC_CHECK_MEMBER([struct sockaddr_in.sin_len], [], [], [#include <netinet/in.h>])
+AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len], [], [], [#include <netinet/in.h>])
+
+if test "x${ac_cv_member_sockaddr_sa_len}" = xyes; then
+    AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1,
+	    [Whether struct sockaddr_in has the sa_len member])
+fi
+
+if test "x${ac_cv_member_sockaddr_in_sin_len}" = xyes ; then
+AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN, 1,
+	    [Whether struct sockaddr_in has the sin_len member])
+fi
+
+if test "x${ac_cv_member_sockaddr_in6_sin6_len}" = xyes; then
+    AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN, 1,
+	    [Whether struct sockaddr_in6 has the sin6_len member])
+fi
+
 if test "x${with_profiler}" = "xyes"; then
 TS_FLAG_HEADERS([google/profiler.h \
                   ], [], [])

Modified: trafficserver/traffic/trunk/lib/ts/ink_inet.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_inet.h?rev=1232675&r1=1232674&r2=1232675&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_inet.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_inet.h Wed Jan 18 00:50:50 2012
@@ -505,8 +505,14 @@ inline bool ink_inet_copy(
     case AF_INET6: n = sizeof(sockaddr_in6); break;
     }
   }
-  if (n) memcpy(dst, src, n);
-  else ink_inet_invalidate(dst);
+  if (n) {
+    memcpy(dst, src, n);
+#if HAVE_STRUCT_SOCKADDR_SA_LEN
+    dst->sa_len = n;
+#endif
+  } else {
+    ink_inet_invalidate(dst);
+  }
   return n != 0;
 }
 
@@ -658,6 +664,9 @@ inline sockaddr* ink_inet_ip4_set(
   uint16_t port = 0 ///< port, network order.
 ) {
   memset(dst, 0, sizeof(*dst));
+#if HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+  dst->sin_len = sizeof(sockaddr_in);
+#endif
   dst->sin_family = AF_INET;
   dst->sin_addr.s_addr = addr;
   dst->sin_port = port;
@@ -696,6 +705,9 @@ inline sockaddr* ink_inet_ip6_set(
   uint16_t port = 0 ///< Port, network order.
 ) {
   memset(dst, 0, sizeof(*dst));
+#if HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
+  dst->sin6_len = sizeof(sockaddr_in6);
+#endif
   dst->sin6_family = AF_INET6;
   memcpy(&dst->sin6_addr, &addr, sizeof addr);
   dst->sin6_port = port;



Mime
View raw message