You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2011/07/08 17:08:13 UTC

svn commit: r1144353 [2/2] - in /trafficserver/traffic/trunk: cop/ iocore/aio/ iocore/cache/ iocore/cluster/ iocore/dns/ iocore/eventsystem/ iocore/hostdb/ iocore/net/ iocore/utils/ lib/ts/ mgmt/api/remote/ mgmt/cli/ mgmt/preparse/ mgmt/tools/ proxy/ p...

Modified: trafficserver/traffic/trunk/lib/ts/ink_inet.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_inet.h?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_inet.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_inet.h Fri Jul  8 15:08:11 2011
@@ -28,6 +28,7 @@
 #include "ink_platform.h"
 #include "ink_port.h"
 #include "ink_apidefs.h"
+#include <ts/ink_assert.h>
 
 #define INK_GETHOSTBYNAME_R_DATA_SIZE 1024
 #define INK_GETHOSTBYADDR_R_DATA_SIZE 1024
@@ -91,182 +92,417 @@ inkcoreapi uint32_t ink_inet_addr(const 
 const char *ink_inet_ntop(const struct sockaddr *addr, char *dst, size_t size);
 uint16_t ink_inet_port(const struct sockaddr *addr);
 
+// --
+/// Size in bytes of an IPv6 address.
+size_t const INK_IP6_SIZE = sizeof(in6_addr);
+
+/** Write a null terminated string for @a addr to @a dst.
+    A buffer of size INET6_ADDRSTRLEN suffices, including a terminating nul.
+ */
+char const* ink_inet_ntop(
+  const sockaddr *addr, ///< Address.
+  char *dst, ///< Output buffer.
+  size_t size ///< Length of buffer.
+);
+
+static size_t const INET6_ADDRPORTSTRLEN = INET6_ADDRSTRLEN + 6;
+
+/** Write a null terminated string for @a addr to @a dst with port.
+    A buffer of size INET6_ADDRPORTSTRLEN suffices, including a terminating nul.
+ */
+char const* ink_inet_nptop(
+  const sockaddr *addr, ///< Address.
+  char *dst, ///< Output buffer.
+  size_t size ///< Length of buffer.
+);
+
+/** Convert @a text to an IP address and write it to @a addr.
+
+    @a text is expected to be an explicit address, not a hostname.  No
+    hostname resolution is done.
+
+    @note This uses @c getaddrinfo internally and so involves memory
+    allocation.
+
+    @return 0 on success, non-zero on failure.
+*/
+int ink_inet_pton(
+  char const* text, ///< [in] text.
+  sockaddr* addr ///< [out] address
+);
+
 /// Reset an address to invalid.
-/// Convenience overload.
 /// @note Useful for marking a member as not yet set.
-inline void ink_inet_invalidate(sockaddr_storage* addr) {
-  addr->ss_family = AF_UNSPEC;
+inline void ink_inet_invalidate(sockaddr* addr) {
+  addr->sa_family = AF_UNSPEC;
 }
 
-/// Set to all zero.
-inline void ink_inet_init(sockaddr_storage* addr) {
-  memset(addr, 0, sizeof(addr));
-  ink_inet_invalidate(addr);
+/// Test for IP protocol.
+/// @return @c true if the address is IP, @c false otherwise.
+inline bool ink_inet_is_ip(sockaddr const* addr) {
+  return AF_INET == addr->sa_family || AF_INET6 == addr->sa_family;
 }
-
-/// @return @a a cast to @c sockaddr_storage*.
-inline sockaddr_storage* ink_inet_ss_cast(sockaddr* a) {
-  return static_cast<sockaddr_storage*>(static_cast<void*>(a));
+/// Test for IPv4 protocol.
+/// @return @c true if the address is IPv4, @c false otherwise.
+inline bool ink_inet_is_ip4(sockaddr const* addr) {
+  return AF_INET == addr->sa_family;
 }
-/// @return @a a cast to @c sockaddr_storage const*.
-inline sockaddr_storage const* ink_inet_ss_cast(sockaddr const* a) {
-  return static_cast<sockaddr_storage const*>(static_cast<void const*>(a));
+/// Test for IPv6 protocol.
+/// @return @c true if the address is IPv6, @c false otherwise.
+inline bool ink_inet_is_ip6(sockaddr const* addr) {
+  return AF_INET6 == addr->sa_family;
 }
-/// @return @a a cast to @c sockaddr_storage const*.
-inline sockaddr_storage* ink_inet_ss_cast(sockaddr_in6* a) {
-  return reinterpret_cast<sockaddr_storage*>(a);
-}
-/// @return @a a cast to @c sockaddr_storage const*.
-inline sockaddr_storage const* ink_inet_ss_cast(sockaddr_in6 const* a) {
-  return reinterpret_cast<sockaddr_storage const*>(a);
+/// @return @c true if the address families are compatible.
+inline bool ink_inet_are_compatible(
+  sockaddr const* lhs, ///< Address to test.
+  sockaddr const* rhs  ///< Address to test.
+) {
+  return lhs->sa_family == rhs->sa_family;
 }
-/// @return @a a cast to @c sockaddr*.
+
+// IP address casting.
+// sa_cast to cast to sockaddr*.
+// ss_cast to cast to sockaddr_storage*.
+// ip4_cast converts to sockaddr_in (because that's effectively an IPv4 addr).
+// ip6_cast converts to sockaddr_in6
+
 inline sockaddr* ink_inet_sa_cast(sockaddr_storage* a) {
-  return reinterpret_cast<sockaddr*>(a);
+  return static_cast<sockaddr*>(static_cast<void*>(a));
 }
-/// @return @a a cast to sockaddr const*.
 inline sockaddr const* ink_inet_sa_cast(sockaddr_storage const* a) {
-  return reinterpret_cast<sockaddr const*>(a);
+  return static_cast<sockaddr const*>(static_cast<void const*>(a));
+}
+
+inline sockaddr* ink_inet_sa_cast(sockaddr_in* a) {
+  return static_cast<sockaddr*>(static_cast<void*>(a));
+}
+inline sockaddr_storage const* ink_inet_sa_cast(sockaddr_in const* a) {
+  return static_cast<sockaddr_storage const*>(static_cast<void const*>(a));
+}
+
+inline sockaddr* ink_inet_sa_cast(sockaddr_in6* a) {
+  return static_cast<sockaddr*>(static_cast<void*>(a));
 }
-/// @return @a a cast to sockaddr const*.
 inline sockaddr const* ink_inet_sa_cast(sockaddr_in6 const* a) {
-  return reinterpret_cast<sockaddr const*>(a);
+  return static_cast<sockaddr const*>(static_cast<void const*>(a));
 }
 
-/// Test for IPv4 protocol.
-/// @return @c true if the address is IPv4, @c false otherwise.
-inline bool ink_inet_is_ip4(sockaddr_storage const* addr) {
-  return AF_INET == addr->ss_family;
+inline sockaddr_storage* ink_inet_ss_cast(sockaddr* a) {
+  return static_cast<sockaddr_storage*>(static_cast<void*>(a));
 }
-/// Test for IPv4 protocol.
-/// @return @c true if the address is IPv4, @c false otherwise.
-inline bool ink_inet_is_ip4(sockaddr const* addr) {
-  return AF_INET == addr->sa_family;
+inline sockaddr_storage const* ink_inet_ss_cast(sockaddr const* a) {
+  return static_cast<sockaddr_storage const*>(static_cast<void const*>(a));
 }
-/// Test for IPv6 protocol.
-/// Convenience overload.
-/// @return @c true if the address is IPv6, @c false otherwise.
-inline bool ink_inet_is_ip6(sockaddr_storage const* addr) {
-  return AF_INET6 == addr->ss_family;
+
+inline sockaddr_in* ink_inet_ip4_cast(sockaddr* a) {
+  return static_cast<sockaddr_in*>(static_cast<void*>(a));
+}
+inline sockaddr_in const* ink_inet_ip4_cast(sockaddr const* a) {
+  return static_cast<sockaddr_in const*>(static_cast<void const*>(a));
 }
 
-/// IPv4 cast.
-/// @return @a a cast to a @c sockaddr_in*
-inline sockaddr_in* ink_inet_ip4_cast(
-  sockaddr_storage* a ///< Address structure.
-) {
+inline sockaddr_in& ink_inet_ip4_cast(sockaddr& a) {
+  return *static_cast<sockaddr_in*>(static_cast<void*>(&a));
+}
+inline sockaddr_in const& ink_inet_ip4_cast(sockaddr const& a) {
+  return *static_cast<sockaddr_in const*>(static_cast<void const*>(&a));
+}
+
+inline sockaddr_in* ink_inet_ip4_cast(sockaddr_in6* a) {
   return static_cast<sockaddr_in*>(static_cast<void*>(a));
 }
-/// IPv4 cast.
-/// @return @a a cast to a @c sockaddr_in*
-inline sockaddr_in const* ink_inet_ip4_cast(
-  sockaddr_storage const* a ///< Address structure.
-) {
+inline sockaddr_in const* ink_inet_ip4_cast(sockaddr_in6 const* a) {
   return static_cast<sockaddr_in const*>(static_cast<void const*>(a));
 }
-/// IPv4 cast.
-/// @return @a a cast to a @c sockaddr_in*
-inline sockaddr_in const* ink_inet_ip4_cast(
-  sockaddr const* a ///< Address structure.
-) {
-  return reinterpret_cast<sockaddr_in const*>(a);
-}
-/// IPv6 cast.
-/// @return @a a cast to a @c sockaddr_in6*
-inline sockaddr_in6* ink_inet_ip6_cast(sockaddr_storage* a) {
+
+inline sockaddr_in6* ink_inet_ip6_cast(sockaddr* a) {
   return static_cast<sockaddr_in6*>(static_cast<void*>(a));
 }
-/// IPv6 cast.
-/// @return @a a cast to a @c sockaddr_in6*
-inline sockaddr_in6 const* ink_inet_ip6_cast(sockaddr_storage const* a) {
+inline sockaddr_in6 const* ink_inet_ip6_cast(sockaddr const* a) {
   return static_cast<sockaddr_in6 const*>(static_cast<void const*>(a));
 }
-
+inline sockaddr_in6& ink_inet_ip6_cast(sockaddr& a) {
+  return *static_cast<sockaddr_in6*>(static_cast<void*>(&a));
+}
+inline sockaddr_in6 const& ink_inet_ip6_cast(sockaddr const& a) {
+  return *static_cast<sockaddr_in6 const*>(static_cast<void const*>(&a));
+}
 /** Get a reference to the port in an address.
     @note Because this is direct access, the port value is in network order.
-    @see ink_inet_get_port for host order copy.
+    @see ink_inet_get_port.
     @return A reference to the port value in an IPv4 or IPv6 address.
     @internal This is primarily for internal use but it might be handy for
     clients so it is exposed.
 */
-inline uint16_t& ink_inet_port_cast(sockaddr_storage* ss) {
+inline uint16_t& ink_inet_port_cast(sockaddr* sa) {
   static uint16_t dummy = 0;
-  return AF_INET == ss->ss_family
-    ? ink_inet_ip4_cast(ss)->sin_port
-    : AF_INET6 == ss->ss_family
-      ? ink_inet_ip6_cast(ss)->sin6_port
+  return ink_inet_is_ip4(sa)
+    ? ink_inet_ip4_cast(sa)->sin_port
+    : ink_inet_is_ip6(sa)
+      ? ink_inet_ip6_cast(sa)->sin6_port
       : (dummy = 0)
     ;
 }
 /** Get a reference to the port in an address.
     @note Because this is direct access, the port value is in network order.
-    @see ink_inet_get_port for host order copy.
-    @return A reference to the port value in an IPv4 or IPv6 address.
-    @internal This is primarily for internal use but it might be handy for
-    clients so it is exposed.
-*/
-inline uint16_t const& ink_inet_port_cast(sockaddr_storage const* ss) {
-    return ink_inet_port_cast(const_cast<sockaddr_storage*>(ss));
-}
-/** Get a reference to the port in an address.
-    @note Because this is direct access, the port value is in network order.
-    @see ink_inet_get_port for host order copy.
+    @see ink_inet_get_port.
     @return A reference to the port value in an IPv4 or IPv6 address.
     @internal This is primarily for internal use but it might be handy for
     clients so it is exposed.
 */
 inline uint16_t const& ink_inet_port_cast(sockaddr const* sa) {
-    return ink_inet_port_cast(ink_inet_ss_cast(sa));
+  return ink_inet_port_cast(const_cast<sockaddr*>(sa));
 }
 
 /** Access the IPv4 address.
 
-    If @a addr is not IPv4 the results are indeterminate.
-    
+    If this is not an IPv4 address a zero valued address is returned.
     @note This is direct access to the address so it will be in
     network order.
 
     @return A reference to the IPv4 address in @a addr.
 */
-inline in_addr_t& ink_inet_ip4_addr_cast(sockaddr_storage* addr) {
-    return ink_inet_ip4_cast(addr)->sin_addr.s_addr;
+inline in_addr_t& ink_inet_ip4_addr_cast(sockaddr* addr) {
+  static in_addr_t dummy = 0;
+  return ink_inet_is_ip4(addr)
+    ? ink_inet_ip4_cast(addr)->sin_addr.s_addr
+    : (dummy = 0)
+    ;
 }
 /** Access the IPv4 address.
 
-    If @a addr is not IPv4 the results are indeterminate.
-    
+    If this is not an IPv4 address a zero valued address is returned.
     @note This is direct access to the address so it will be in
     network order.
 
     @return A reference to the IPv4 address in @a addr.
 */
-inline in_addr_t const& ink_inet_ip4_addr_cast(sockaddr_storage const* addr) {
-    return ink_inet_ip4_cast(addr)->sin_addr.s_addr;
+inline in_addr_t const& ink_inet_ip4_addr_cast(sockaddr const* addr) {
+  static in_addr_t dummy = 0;
+  return ink_inet_is_ip4(addr)
+    ? ink_inet_ip4_cast(addr)->sin_addr.s_addr
+    : static_cast<in_addr_t const&>(dummy = 0)
+    ;
 }
-/** Access the IPv4 address.
+/** Access the IPv6 address.
 
-    If @a addr is not IPv4 the results are indeterminate.
-    
+    If this is not an IPv6 address a zero valued address is returned.
     @note This is direct access to the address so it will be in
     network order.
 
-    @return A reference to the IPv4 address in @a addr.
+    @return A reference to the IPv6 address in @a addr.
 */
-inline in_addr_t const& ink_inet_ip4_addr_cast(sockaddr const* addr) {
-    return ink_inet_ip4_cast(addr)->sin_addr.s_addr;
+inline in6_addr& ink_inet_ip6_addr_cast(sockaddr* addr) {
+  return ink_inet_ip6_cast(addr)->sin6_addr;
+}
+  
+
+/// @name Address operators
+//@{
+
+/** Copy the address from @a src to @a dst if it's IP.
+    This attempts to do a minimal copy based on the type of @a src.
+    If @a src is not an IP address type it is @b not copied.
+    @return @c true if @a src was an IP address, @c false otherwise.
+*/
+inline bool ink_inet_copy(
+  sockaddr* dst, ///< Destination object.
+  sockaddr const* src ///< Source object.
+) {
+  size_t n = 0;
+  switch (src->sa_family) {
+  case AF_INET: n = sizeof(sockaddr_in); break;
+  case AF_INET6: n = sizeof(sockaddr_in6); break;
+  }
+  if (n) memcpy(dst, src, n);
+  else ink_inet_invalidate(dst);
+  return n != 0;
+}
+
+/** Compare two addresses.
+    This is valid for IPv4, IPv6, and the unspecified address type.
+    If the addresses are of different types they are ordered
+    UNSPEC < IPv4 < IPv6
+    Otherwise
+     - all UNSPEC addresses are the same.
+     - IPv4 addresses are compared numerically (host order)
+     - IPv6 addresses are compared byte wise from left to right.
+
+    @return
+      - -1 if @a lhs is less than @a rhs.
+      - 0 if @a lhs is identical to @a rhs.
+      - 1 if @a lhs is greater than @a rhs.
+    @internal This looks like a lot of code for an inline but I think it
+    should compile down quite a bit.
+*/
+inline int ink_inet_cmp(
+  sockaddr const* lhs, ///< Left hand operand.
+  sockaddr const* rhs ///< Right hand operand.
+) {
+  int zret = 0;
+  uint16_t rtype = rhs->sa_family;
+  uint16_t ltype = lhs->sa_family;
+
+  // Handle the UNSPEC cases on both sides to make the
+  // other logic simpler.
+  if (AF_UNSPEC == ltype) {
+    ink_assert(AF_INET == rtype || AF_INET6 == rtype);
+    return AF_UNSPEC == rtype ? 0 : -1;
+  } else if (AF_UNSPEC == rtype) {
+    ink_assert(AF_INET == ltype || AF_INET6 == ltype);
+    return 1; // because lhs is not UNSPEC.
+  } else if (AF_INET == ltype) {
+    if (AF_INET == rtype) {
+      in_addr_t la = ntohl(ink_inet_ip4_cast(lhs)->sin_addr.s_addr);
+      in_addr_t ra = ntohl(ink_inet_ip4_cast(rhs)->sin_addr.s_addr);
+      if (la < ra) zret = -1;
+      else if (la > ra) zret = 1;
+      else zret = 0;
+    } else {
+      ink_assert(AF_INET6 == rtype);
+      zret = -1; // IPv4 addresses are before IPv6
+    }
+  } else if (AF_INET6 == ltype) {
+    if (AF_INET6 == rtype) {
+      zret = memcmp(
+        &ink_inet_ip6_cast(lhs)->sin6_addr,
+        &ink_inet_ip6_cast(rhs)->sin6_addr,
+        sizeof(sockaddr_in6::sin6_addr)
+      );
+    } else {
+      ink_assert(AF_INET == rtype);
+      zret = 1; // IPv6 always greater than IPv4
+    }
+  } else {
+    ink_assert(false && "Only IP addresses can be compared");
+  }
+
+  return zret;
+}
+
+//@}
+
+/// Get IP TCP/UDP port.
+/// @return The port in host order for an IPv4 or IPv6 address,
+/// or zero if neither.
+inline uint16_t ink_inet_get_port(
+  sockaddr const* addr ///< Address with port.
+) {
+  // We can discard the const because this function returns
+  // by value.
+  return ntohs(ink_inet_port_cast(const_cast<sockaddr*>(addr)));
+}
+
+/** Extract the IPv4 address.
+    @return Host order IPv4 address.
+*/
+inline in_addr_t ink_inet_get_ip4_addr(
+  sockaddr const* addr ///< Address object.
+) {
+  return ntohl(ink_inet_ip4_addr_cast(const_cast<sockaddr*>(addr)));
+}
+
+/// Write IPv4 data to storage @a dst.
+inline void ink_inet_ip4_set(
+  sockaddr_in* dst, ///< Destination storage.
+  in_addr_t addr, ///< address, IPv4 network order.
+  uint16_t port = 0 ///< port, network order.
+) {
+  memset(dst, 0, sizeof(*dst));
+  dst->sin_family = AF_INET;
+  dst->sin_addr.s_addr = addr;
+  dst->sin_port = port;
+}
+
+/** Write IPv4 data to @a dst.
+    @note Convenience overload.
+*/
+inline void ink_inet_ip4_set(
+  sockaddr_in6* dst, ///< Destination storage.
+  in_addr_t ip4, ///< address, IPv4 network order.
+  uint16_t port = 0 ///< port, network order.
+) {
+  ink_inet_ip4_set(ink_inet_ip4_cast(dst), ip4, port);
 }
 
-/// Write IPv4 data to a @c sockaddr_storage.
+/** Write IPv4 data to storage @a dst.
+
+    This is the generic overload. Caller must verify that @a dst is at
+    least @c sizeof(sockaddr_in) bytes.
+*/
 inline void ink_inet_ip4_set(
-  sockaddr_storage* ss, ///< Destination storage.
+  sockaddr* dst, ///< Destination storage.
   in_addr_t ip4, ///< address, IPv4 network order.
   uint16_t port = 0 ///< port, network order.
 ) {
-  sockaddr_in* sin = ink_inet_ip4_cast(ss);
-  memset(sin, 0, sizeof(*sin));
-  sin->sin_family = AF_INET;
-  memcpy(&(sin->sin_addr), &ip4, sizeof(ip4));
-  sin->sin_port = port;
+  ink_inet_ip4_set(ink_inet_ip4_cast(dst), ip4, port);
 }
 
+/** Storage for an IP address.
+    In some cases we want to store just the address and not the
+    ancillary information (such as port, or flow data) in
+    @c sockaddr_storage. There are a couple of cases where this
+    makes sense.
+    @note This is not easily used as an address for system calls.
+*/
+struct InkIpAddr {
+  typedef InkIpAddr self; ///< Self reference type.
+
+  /// Default construct (invalid address).
+  InkIpAddr() : _family(AF_UNSPEC) {}
+  /// Construct as IPv4 @a addr.
+  explicit InkIpAddr(
+    in_addr_t addr ///< Address to assign.
+  ) : _family(AF_INET) {
+    _addr._ip4 = addr;
+  }
+  /// Construct from @c sockaddr_storage.
+  explicit InkIpAddr(sockaddr const& addr) { this->assign(&addr); }
+  /// Construct from @c sockaddr_storage.
+  explicit InkIpAddr(sockaddr const* addr) { this->assign(addr); }
+
+  /// Assign sockaddr storage.
+  self& assign(sockaddr const* addr) {
+    _family = addr->sa_family;
+    if (ink_inet_is_ip4(addr)) {
+      _addr._ip4 = ink_inet_ip4_addr_cast(addr);
+    } else if (ink_inet_is_ip6(addr)) {
+      memcpy(&_addr._ip6, &ink_inet_ip6_cast(addr)->sin6_addr, INK_IP6_SIZE);
+    } else {
+      _family = AF_UNSPEC;
+    }
+    return *this;
+  }
+
+  /// Equality.
+  bool operator==(self const& that) {
+    return _family == AF_INET
+      ? (that._family == AF_INET && _addr._ip4 == that._addr._ip4)
+      : _family == AF_INET6
+        ? (that._family == AF_INET6
+          && 0 == memcmp(&_addr._ip6, &that._addr._ip6, INK_IP6_SIZE)
+          )
+        : (_family = AF_UNSPEC && that._family == AF_UNSPEC)
+    ;
+  }
+
+  /// Inequality.
+  bool operator!=(self const& that) {
+    return ! (*this == that);
+  }
+
+  /// Test for validity.
+  bool isValid() const { return _family == AF_INET || _family == AF_INET6; }
+
+  uint8_t _family; ///< Protocol family.
+  uint8_t _pad[3]; ///< Pad it out.
+  /// Address data.
+  union {
+    in_addr_t _ip4; ///< IPv4 address storage.
+    in6_addr  _ip6; ///< IPv6 address storage.
+  } _addr;
+};
+
+// --
+
 #endif // _ink_inet.h

Modified: trafficserver/traffic/trunk/mgmt/api/remote/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/api/remote/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/api/remote/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/api/remote/Makefile.am Fri Jul  8 15:08:11 2011
@@ -16,6 +16,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/mgmt \
   -I$(top_srcdir)/mgmt/utils \
   -I$(top_srcdir)/mgmt/api \

Modified: trafficserver/traffic/trunk/mgmt/cli/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/cli/Makefile.am Fri Jul  8 15:08:11 2011
@@ -21,6 +21,7 @@ SUFFIXES = .java .class .jar .my .def .s
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/mgmt/api/include \
   -I$(top_srcdir)/mgmt/tools
 

Modified: trafficserver/traffic/trunk/mgmt/preparse/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/preparse/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/preparse/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/preparse/Makefile.am Fri Jul  8 15:08:11 2011
@@ -15,6 +15,7 @@
 #  limitations under the License.
 
 AM_CPPFLAGS = \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/proxy/hdrs
 
 MGMT_DEFS = @MGMT_DEFS@

Modified: trafficserver/traffic/trunk/mgmt/tools/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/tools/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/tools/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/tools/Makefile.am Fri Jul  8 15:08:11 2011
@@ -19,6 +19,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/mgmt/utils \
   -I$(top_srcdir)/mgmt/api \
   -I$(top_srcdir)/mgmt/api/include \

Modified: trafficserver/traffic/trunk/proxy/FetchSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/FetchSM.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/FetchSM.cc (original)
+++ trafficserver/traffic/trunk/proxy/FetchSM.cc Fri Jul  8 15:08:11 2011
@@ -52,7 +52,7 @@ void
 FetchSM::httpConnect()
 {
   Debug(DEBUG_TAG, "[%s] calling httpconnect write", __FUNCTION__);
-  sockaddr_storage addr;
+  sockaddr_in addr;
   ink_inet_ip4_set(&addr, _ip, _port);
   http_vc = TSHttpConnect(ink_inet_sa_cast(&addr));
 

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Fri Jul  8 15:08:11 2011
@@ -5111,7 +5111,7 @@ TSHttpTxnClientAddrGet(TSHttpTxn txnp)
   NetVConnection *vc = cs->get_netvc();
   if (vc == NULL) return 0;
 
-  return ink_inet_sa_cast(vc->get_remote_addr());
+  return vc->get_remote_addr();
 }
 
 unsigned int
@@ -5135,7 +5135,7 @@ TSHttpTxnIncomingAddrGet(TSHttpTxn txnp)
   NetVConnection *vc = cs->get_netvc();
   if (vc == NULL) return 0;
 
-  return ink_inet_sa_cast(vc->get_local_addr());
+  return vc->get_local_addr();
 }
 
 int
@@ -5153,7 +5153,8 @@ TSHttpTxnServerAddrGet(TSHttpTxn txnp)
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
 
   HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
-  ink_inet_ip4_set(&sm->t_state.server_info.addr,
+  ink_inet_ip4_set(
+    ink_inet_sa_cast(&sm->t_state.server_info.addr),
     sm->t_state.server_info.ip,
     sm->t_state.server_info.port
   );
@@ -6147,7 +6148,7 @@ sockaddr const*
 TSNetVConnLocalAddrGet(TSVConn connp) {
   sdk_assert(sdk_sanity_check_iocore_structure(connp) == TS_SUCCESS);
   NetVConnection* vc = reinterpret_cast<NetVConnection*>(connp);
-  return ink_inet_sa_cast(vc->get_local_addr());
+  return vc->get_local_addr();
 }
 
 
@@ -6155,7 +6156,7 @@ sockaddr const*
 TSNetVConnRemoteAddrGet(TSVConn connp) {
   sdk_assert(sdk_sanity_check_iocore_structure(connp) == TS_SUCCESS);
   NetVConnection* vc = reinterpret_cast<NetVConnection*>(connp);
-  return ink_inet_sa_cast(vc->get_remote_addr());
+  return vc->get_remote_addr();
 }
 
 
@@ -6231,7 +6232,7 @@ TSHostLookupResultAddrGet(TSHostLookupRe
 {
   sdk_assert(sdk_sanity_check_hostlookup_structure(lookup_result) == TS_SUCCESS);
   HostDBInfo* di = reinterpret_cast<HostDBInfo*>(lookup_result);
-  ink_inet_ip4_set(ink_inet_ss_cast(&di->ip6), di->ip());
+  ink_inet_ip4_set(ink_inet_sa_cast(&di->ip6), di->ip());
   return ink_inet_sa_cast(&di->ip6);
 }
 
@@ -7138,8 +7139,9 @@ TSFetchPages(TSFetchUrlParams_t *params)
 
   while (myparams != NULL) {
     FetchSM *fetch_sm =  FetchSMAllocator.alloc();
-    in_addr_t ip = ink_inet_ip4_addr_cast(&myparams->ip);
-    uint16_t port = ink_inet_port_cast(&myparams->ip);
+    sockaddr* addr = ink_inet_sa_cast(&myparams->ip);
+    in_addr_t ip = ink_inet_ip4_addr_cast(addr);
+    uint16_t port = ink_inet_port_cast(addr);
 
     fetch_sm->init((Continuation*)myparams->contp, myparams->options,myparams->events, myparams->request, myparams->request_len, ip, port);
     fetch_sm->httpConnect();

Modified: trafficserver/traffic/trunk/proxy/InkAPITest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITest.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITest.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITest.cc Fri Jul  8 15:08:11 2011
@@ -336,7 +336,7 @@ REGRESSION_TEST(SDK_API_TSNetVConn) (Reg
 
   TSNetAccept(server_cont, server_port, -1, 0);
 
-  sockaddr_storage addr;
+  sockaddr_in addr;
   ink_inet_ip4_set(&addr, INADDR_LOOPBACK, server_port);
   TSNetConnect(client_cont, ink_inet_sa_cast(&addr));
 }
@@ -7430,7 +7430,7 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_TSHttp
   /* Now send a request to the OS via TS using TSHttpConnect */
 
   /* ip and log do not matter as it is used for logging only */
-  sockaddr_storage addr;
+  sockaddr_in addr;
   ink_inet_ip4_set(&addr, 1, 1);
   data->vc = TSHttpConnect(ink_inet_sa_cast(&addr));
   synclient_txn_send_request_to_vc(data->browser, data->request, data->vc);
@@ -7470,7 +7470,7 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_TSHttp
   /* Now send a request to the OS via TS using TSHttpConnect */
 
   /* ip and log do not matter as it is used for logging only */
-  sockaddr_storage addr;
+  sockaddr_in addr;
   ink_inet_ip4_set(&addr, 2, 2);
   data->vc = TSHttpConnect(ink_inet_sa_cast(&addr));
 

Modified: trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITestTool.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITestTool.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITestTool.cc Fri Jul  8 15:08:11 2011
@@ -493,7 +493,7 @@ static int
 synclient_txn_send_request(ClientTxn * txn, char *request)
 {
   TSCont cont;
-  sockaddr_storage addr;
+  sockaddr_in addr;
 
   TSAssert(txn->magic == MAGIC_ALIVE);
   txn->request = xstrdup(request);

Modified: trafficserver/traffic/trunk/proxy/PluginVC.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/PluginVC.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/PluginVC.cc (original)
+++ trafficserver/traffic/trunk/proxy/PluginVC.cc Fri Jul  8 15:08:11 2011
@@ -865,9 +865,17 @@ void
 PluginVC::set_local_addr()
 {
   if (vc_type == PLUGIN_VC_ACTIVE) {
-    local_addr = core_obj->active_addr_struct;
+    ink_inet_copy(
+      ink_inet_sa_cast(&local_addr),
+      ink_inet_sa_cast(&core_obj->active_addr_struct)
+    );
+//    local_addr = core_obj->active_addr_struct;
   } else {
-    local_addr = core_obj->passive_addr_struct;
+    ink_inet_copy(
+      ink_inet_sa_cast(&local_addr),
+      ink_inet_sa_cast(&core_obj->passive_addr_struct)
+    );
+//    local_addr = core_obj->passive_addr_struct;
   }
 }
 
@@ -875,9 +883,17 @@ void
 PluginVC::set_remote_addr()
 {
   if (vc_type == PLUGIN_VC_ACTIVE) {
-    remote_addr = core_obj->passive_addr_struct;
+    ink_inet_copy(
+      ink_inet_sa_cast(&remote_addr),
+      ink_inet_sa_cast(&core_obj->passive_addr_struct)
+    );
+//    remote_addr = core_obj->passive_addr_struct;
   } else {
-    remote_addr = core_obj->active_addr_struct;
+    ink_inet_copy(
+      ink_inet_sa_cast(&remote_addr),
+      ink_inet_sa_cast(&core_obj->active_addr_struct)
+    );
+//    remote_addr = core_obj->active_addr_struct;
   }
 }
 

Modified: trafficserver/traffic/trunk/proxy/congest/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/congest/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/congest/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/congest/Makefile.am Fri Jul  8 15:08:11 2011
@@ -18,6 +18,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/proxy/http \

Modified: trafficserver/traffic/trunk/proxy/hdrs/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/Makefile.am Fri Jul  8 15:08:11 2011
@@ -18,6 +18,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records
 
 noinst_LIBRARIES = libhdrs.a

Modified: trafficserver/traffic/trunk/proxy/http/HttpClientSession.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpClientSession.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpClientSession.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpClientSession.cc Fri Jul  8 15:08:11 2011
@@ -201,7 +201,7 @@ HttpClientSession::new_connection(NetVCo
   // check what type of socket address we just accepted
   // by looking at the address family value of sockaddr_storage
   // and logging to stat system
-  switch(new_vc->get_remote_addr()->ss_family) {
+  switch(new_vc->get_remote_addr()->sa_family) {
     case AF_INET:
       HTTP_INCREMENT_DYN_STAT(http_total_client_connections_ipv4_stat);
     break;

Modified: trafficserver/traffic/trunk/proxy/http/HttpSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpSM.cc?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpSM.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpSM.cc Fri Jul  8 15:08:11 2011
@@ -604,7 +604,11 @@ HttpSM::attach_client_session(HttpClient
   t_state.client_info.is_transparent = netvc->get_is_transparent();
   t_state.backdoor_request = client_vc->backdoor_connect;
   memset(&(t_state.client_info.addr), 0, sizeof(t_state.client_info.addr));
-  t_state.client_info.addr = *client_vc->get_netvc()->get_remote_addr();
+  ink_inet_copy(
+    ink_inet_sa_cast(&t_state.client_info.addr),
+    client_vc->get_netvc()->get_remote_addr()
+  );
+//  t_state.client_info.addr = ink_inet_ip6_cast(*client_vc->get_netvc()->get_remote_addr());
   t_state.client_info.port_attribute = (HttpPortTypes) netvc->attributes;
 
   HTTP_INCREMENT_DYN_STAT(http_current_client_transactions_stat);

Modified: trafficserver/traffic/trunk/proxy/http/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpTransact.h?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpTransact.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpTransact.h Fri Jul  8 15:08:11 2011
@@ -784,7 +784,7 @@ public:
     // components is a byte, so:
     // 0x25364758 = 0x25.0x36.0x47.0x58 = 37.54.71.88 in decimal.
     in_addr_t ip;
-    sockaddr_storage addr;
+    sockaddr_in6 addr;
 
     // port to connect to, except for client
     // connection where it is port on proxy
@@ -813,8 +813,7 @@ public:
         port_attribute(SERVER_PORT_DEFAULT),
         is_transparent(false)
     {
-      ink_inet_init(&addr);
-//      memset(&addr, 0, sizeof(addr));
+      memset(&addr, 0, sizeof(addr));
     }
   } ConnectionAttributes;
 

Modified: trafficserver/traffic/trunk/proxy/http/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/http/Makefile.am Fri Jul  8 15:08:11 2011
@@ -21,6 +21,7 @@ SUBDIRS = remap
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
   -I$(top_srcdir)/proxy \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/mgmt \
   -I$(top_srcdir)/mgmt/preparse \

Modified: trafficserver/traffic/trunk/proxy/http/remap/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/Makefile.am Fri Jul  8 15:08:11 2011
@@ -18,6 +18,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/mgmt \

Modified: trafficserver/traffic/trunk/proxy/logging/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/logging/Makefile.am Fri Jul  8 15:08:11 2011
@@ -20,6 +20,7 @@ DEFS += -DIOCORE_LOG_COLLATION
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/proxy/http \

Modified: trafficserver/traffic/trunk/proxy/stats/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/stats/Makefile.am?rev=1144353&r1=1144352&r2=1144353&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/stats/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/stats/Makefile.am Fri Jul  8 15:08:11 2011
@@ -18,6 +18,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/mgmt \