trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1126862 [1/4] - in /trafficserver/traffic/branches/ssc: iocore/aio/ iocore/cache/ iocore/cluster/ iocore/dns/ iocore/eventsystem/ iocore/hostdb/ iocore/hostdb/include/ iocore/net/ iocore/utils/ lib/records/ lib/ts/ lib/wccp/ mgmt/ mgmt/api...
Date Tue, 24 May 2011 04:11:39 GMT
Author: amc
Date: Tue May 24 04:11:36 2011
New Revision: 1126862

URL: http://svn.apache.org/viewvc?rev=1126862&view=rev
Log:
Checkpoint and available to other team members

Added:
    trafficserver/traffic/branches/ssc/lib/ts/IpMap.cc
    trafficserver/traffic/branches/ssc/lib/ts/IpMap.h
    trafficserver/traffic/branches/ssc/lib/ts/IpMapConf.cc
    trafficserver/traffic/branches/ssc/lib/ts/IpMapConf.h
Modified:
    trafficserver/traffic/branches/ssc/iocore/aio/I_AIO.h
    trafficserver/traffic/branches/ssc/iocore/aio/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/cache/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/cache/P_Cache.h
    trafficserver/traffic/branches/ssc/iocore/cluster/ClusterAPI.cc
    trafficserver/traffic/branches/ssc/iocore/cluster/ClusterConfig.cc
    trafficserver/traffic/branches/ssc/iocore/cluster/ClusterHandlerBase.cc
    trafficserver/traffic/branches/ssc/iocore/cluster/ClusterMachine.cc
    trafficserver/traffic/branches/ssc/iocore/cluster/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/cluster/P_Cluster.h
    trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterCache.h
    trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterHandler.h
    trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterMachine.h
    trafficserver/traffic/branches/ssc/iocore/dns/DNS.cc
    trafficserver/traffic/branches/ssc/iocore/dns/DNSConnection.cc
    trafficserver/traffic/branches/ssc/iocore/dns/I_DNSProcessor.h
    trafficserver/traffic/branches/ssc/iocore/dns/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/dns/P_DNSConnection.h
    trafficserver/traffic/branches/ssc/iocore/dns/P_DNSProcessor.h
    trafficserver/traffic/branches/ssc/iocore/dns/P_SplitDNSProcessor.h
    trafficserver/traffic/branches/ssc/iocore/dns/SplitDNS.cc
    trafficserver/traffic/branches/ssc/iocore/eventsystem/I_EventSystem.h
    trafficserver/traffic/branches/ssc/iocore/eventsystem/I_SocketManager.h
    trafficserver/traffic/branches/ssc/iocore/eventsystem/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/eventsystem/P_UnixSocketManager.h
    trafficserver/traffic/branches/ssc/iocore/eventsystem/SocketManager.cc
    trafficserver/traffic/branches/ssc/iocore/hostdb/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/hostdb/include/Machine.h
    trafficserver/traffic/branches/ssc/iocore/net/Connection.cc
    trafficserver/traffic/branches/ssc/iocore/net/I_NetProcessor.h
    trafficserver/traffic/branches/ssc/iocore/net/I_NetVConnection.h
    trafficserver/traffic/branches/ssc/iocore/net/I_UDPConnection.h
    trafficserver/traffic/branches/ssc/iocore/net/I_UDPNet.h
    trafficserver/traffic/branches/ssc/iocore/net/I_UDPPacket.h
    trafficserver/traffic/branches/ssc/iocore/net/Makefile.am
    trafficserver/traffic/branches/ssc/iocore/net/P_Connection.h
    trafficserver/traffic/branches/ssc/iocore/net/P_NetVConnection.h
    trafficserver/traffic/branches/ssc/iocore/net/P_Socks.h
    trafficserver/traffic/branches/ssc/iocore/net/P_UDPConnection.h
    trafficserver/traffic/branches/ssc/iocore/net/P_UDPNet.h
    trafficserver/traffic/branches/ssc/iocore/net/P_UDPPacket.h
    trafficserver/traffic/branches/ssc/iocore/net/P_UnixNetProcessor.h
    trafficserver/traffic/branches/ssc/iocore/net/P_UnixNetVConnection.h
    trafficserver/traffic/branches/ssc/iocore/net/SSLNetVConnection.cc
    trafficserver/traffic/branches/ssc/iocore/net/Socks.cc
    trafficserver/traffic/branches/ssc/iocore/net/UnixConnection.cc
    trafficserver/traffic/branches/ssc/iocore/net/UnixNetAccept.cc
    trafficserver/traffic/branches/ssc/iocore/net/UnixNetPages.cc
    trafficserver/traffic/branches/ssc/iocore/net/UnixNetProcessor.cc
    trafficserver/traffic/branches/ssc/iocore/net/UnixNetVConnection.cc
    trafficserver/traffic/branches/ssc/iocore/net/UnixUDPNet.cc
    trafficserver/traffic/branches/ssc/iocore/utils/Makefile.am
    trafficserver/traffic/branches/ssc/lib/records/RecCompatibility.cc
    trafficserver/traffic/branches/ssc/lib/ts/Makefile.am
    trafficserver/traffic/branches/ssc/lib/ts/Vec.h
    trafficserver/traffic/branches/ssc/lib/ts/ink_inet.cc
    trafficserver/traffic/branches/ssc/lib/ts/ink_inet.h
    trafficserver/traffic/branches/ssc/lib/ts/ink_res_init.cc
    trafficserver/traffic/branches/ssc/lib/ts/ink_resolver.h
    trafficserver/traffic/branches/ssc/lib/ts/ink_sock.cc
    trafficserver/traffic/branches/ssc/lib/ts/ink_sock.h
    trafficserver/traffic/branches/ssc/lib/wccp/WccpEndPoint.cc
    trafficserver/traffic/branches/ssc/mgmt/LocalManager.cc
    trafficserver/traffic/branches/ssc/mgmt/ProcessManager.cc
    trafficserver/traffic/branches/ssc/mgmt/RecordsConfig.cc
    trafficserver/traffic/branches/ssc/mgmt/api/CoreAPIShared.cc
    trafficserver/traffic/branches/ssc/mgmt/api/EventControlMain.cc
    trafficserver/traffic/branches/ssc/mgmt/api/EventControlMain.h
    trafficserver/traffic/branches/ssc/mgmt/api/TSControlMain.cc
    trafficserver/traffic/branches/ssc/mgmt/api/TSControlMain.h
    trafficserver/traffic/branches/ssc/mgmt/api/remote/NetworkUtilsRemote.cc
    trafficserver/traffic/branches/ssc/mgmt/cluster/ClusterCom.cc
    trafficserver/traffic/branches/ssc/mgmt/cluster/ClusterCom.h
    trafficserver/traffic/branches/ssc/mgmt/cluster/VMap.cc
    trafficserver/traffic/branches/ssc/mgmt/preparse/Makefile.am
    trafficserver/traffic/branches/ssc/mgmt/utils/Makefile.am
    trafficserver/traffic/branches/ssc/mgmt/utils/MgmtSocket.h
    trafficserver/traffic/branches/ssc/mgmt/utils/MgmtUtils.cc
    trafficserver/traffic/branches/ssc/mgmt/utils/MgmtUtils.h
    trafficserver/traffic/branches/ssc/mgmt/web2/WebGlobals.h
    trafficserver/traffic/branches/ssc/mgmt/web2/WebIntrMain.cc
    trafficserver/traffic/branches/ssc/proxy/ControlMatcher.h
    trafficserver/traffic/branches/ssc/proxy/ICP.cc
    trafficserver/traffic/branches/ssc/proxy/ICP.h
    trafficserver/traffic/branches/ssc/proxy/ICPConfig.cc
    trafficserver/traffic/branches/ssc/proxy/ICPProcessor.h
    trafficserver/traffic/branches/ssc/proxy/InkAPI.cc
    trafficserver/traffic/branches/ssc/proxy/MuxVC.cc
    trafficserver/traffic/branches/ssc/proxy/MuxVC.h
    trafficserver/traffic/branches/ssc/proxy/ParentSelection.h
    trafficserver/traffic/branches/ssc/proxy/PluginVC.cc
    trafficserver/traffic/branches/ssc/proxy/PluginVC.h
    trafficserver/traffic/branches/ssc/proxy/Prefetch.cc
    trafficserver/traffic/branches/ssc/proxy/Socks.h
    trafficserver/traffic/branches/ssc/proxy/StufferUdpReceiver.cc
    trafficserver/traffic/branches/ssc/proxy/congest/CongestionStats.h
    trafficserver/traffic/branches/ssc/proxy/http/HttpConfig.cc
    trafficserver/traffic/branches/ssc/proxy/http/HttpConfig.h
    trafficserver/traffic/branches/ssc/proxy/http/HttpSM.cc
    trafficserver/traffic/branches/ssc/proxy/http/HttpTransact.cc
    trafficserver/traffic/branches/ssc/proxy/http/HttpTransact.h
    trafficserver/traffic/branches/ssc/proxy/http/test_socket_close.cc
    trafficserver/traffic/branches/ssc/proxy/logging/LogAccessHttp.cc
    trafficserver/traffic/branches/ssc/proxy/logging/LogSock.cc
    trafficserver/traffic/branches/ssc/test/SDKtest/client/DoTest.cc
    trafficserver/traffic/branches/ssc/test/SDKtest/client/DoTest.h
    trafficserver/traffic/branches/ssc/test/SDKtest/client/LoadGenerator.cc
    trafficserver/traffic/branches/ssc/test/SDKtest/client/LoadGenerator.h
    trafficserver/traffic/branches/ssc/test/SDKtest/client/Main.cc
    trafficserver/traffic/branches/ssc/test/SDKtest/synth_server/synth_server.c
    trafficserver/traffic/branches/ssc/test/deft/sio_loop.cc
    trafficserver/traffic/branches/ssc/tools/apichecker.pl

Modified: trafficserver/traffic/branches/ssc/iocore/aio/I_AIO.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/aio/I_AIO.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/aio/I_AIO.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/aio/I_AIO.h Tue May 24 04:11:36 2011
@@ -37,7 +37,7 @@
 
 #include "libts.h"
 #include "I_EventSystem.h"
-#include "I_RecProcess.h"
+#include <records/I_RecProcess.h>
 
 #define AIO_MODULE_MAJOR_VERSION 1
 #define AIO_MODULE_MINOR_VERSION 0

Modified: trafficserver/traffic/branches/ssc/iocore/aio/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/aio/Makefile.am?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/aio/Makefile.am (original)
+++ trafficserver/traffic/branches/ssc/iocore/aio/Makefile.am Tue May 24 04:11:36 2011
@@ -18,7 +18,7 @@
 
 AM_CPPFLAGS = \
   -I$(top_srcdir)/iocore/eventsystem \
-  -I$(top_srcdir)/lib/records
+  -I$(top_srcdir)/lib
 
 DEFS += @IOCORE_MODULARIZED_DEFS@
 

Modified: trafficserver/traffic/branches/ssc/iocore/cache/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cache/Makefile.am?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cache/Makefile.am (original)
+++ trafficserver/traffic/branches/ssc/iocore/cache/Makefile.am Tue May 24 04:11:36 2011
@@ -19,13 +19,13 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records
+  -I$(top_srcdir)/lib
 
 ADD_SRC =
 else
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/proxy/hdrs \
   -I$(top_srcdir)/proxy/http \

Modified: trafficserver/traffic/branches/ssc/iocore/cache/P_Cache.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cache/P_Cache.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cache/P_Cache.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/cache/P_Cache.h Tue May 24 04:11:36 2011
@@ -33,7 +33,7 @@
 #include "libts.h"
 #include "P_EventSystem.h"
 #include "P_AIO.h"
-#include "I_RecProcess.h"
+#include <records/I_RecProcess.h>
 
 #ifdef HTTP_CACHE
 #include "HTTP.h"

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/ClusterAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/ClusterAPI.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/ClusterAPI.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/ClusterAPI.cc Tue May 24 04:11:36 2011
@@ -154,7 +154,7 @@ MachineStatusSM::MachineStatusSMEvent(Ev
         MUTEX_TRY_LOCK(lock, status_callouts[n].mutex, et);
         if (lock) {
           int mi;
-          unsigned int my_ipaddr = (this_cluster_machine())->ip;
+          sockaddr_storage const* my_ipaddr = &this_cluster_machine()->ip;
           ClusterConfiguration *cc;
 
           TSNodeHandle_t nh;
@@ -162,12 +162,16 @@ MachineStatusSM::MachineStatusSMEvent(Ev
           cc = this_cluster()->current_configuration();
           if (cc) {
             for (mi = 0; mi < cc->n_machines; ++mi) {
-              if (cc->machines[mi]->ip != my_ipaddr) {
+              if (0 != ink_inet_cmp(&cc->machines[mi]->ip, my_ipaddr)) {
+                char buff[INET6_ADDRSTRLEN];
                 nh = IP_TO_NODE_HANDLE(cc->machines[mi]->ip);
                 status_callouts[n].func(&nh, NODE_ONLINE);
 
                 Debug("cluster_api",
-                      "initial callout: n %d ([%u.%u.%u.%u], %d)", n, DOT_SEPARATED(cc->machines[mi]->ip), NODE_ONLINE);
+                      "initial callout: n %d ([%s], %d)", n,
+                  ink_inet_ntop(&cc->machines[mi]->ip, buff, sizeof buff),
+                  NODE_ONLINE
+                );
               }
             }
           }

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/ClusterConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/ClusterConfig.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/ClusterConfig.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/ClusterConfig.cc Tue May 24 04:11:36 2011
@@ -106,11 +106,8 @@ ClusterAccept::ClusterAcceptEvent(int ev
 	opt.recv_bufsize = socket_recv_bufsize;
 	opt.send_bufsize = socket_send_bufsize;
 	opt.etype = ET_CLUSTER;
-	opt.port = cluster_port;
 	opt.domain = AF_INET;
-        accept_action = netProcessor.main_accept(this, NO_FD,
-                                                 NULL, NULL,
-                                                 false, false, opt);
+        accept_action = netProcessor.main_accept(this, NO_FD, cluster_port, opt);
         if (!accept_action) {
           Warning("Unable to accept cluster connections on port: %d", cluster_port);
         } else {
@@ -135,20 +132,22 @@ ClusterAccept::ClusterAcceptEvent(int ev
 int
 ClusterAccept::ClusterAcceptMachine(NetVConnection * NetVC)
 {
+  char buff[INET6_ADDRSTRLEN];
   // Validate remote IP address.
-  unsigned int remote_ip = NetVC->get_remote_ip();
+  sockaddr_storage const* remote_ip = NetVC->get_remote_addr();
+//  unsigned int remote_ip = NetVC->get_remote_ip();
   MachineList *mc = the_cluster_machines_config();
 
-  if (mc && !mc->find(remote_ip)) {
+  if (mc && !mc->findByAddr(remote_ip)) {
     Note("Illegal cluster connection from %u.%u.%u.%u", DOT_SEPARATED(remote_ip));
     NetVC->do_io(VIO::CLOSE);
     return 0;
   }
 
-  Debug(CL_NOTE, "Accepting machine %u.%u.%u.%u", DOT_SEPARATED(remote_ip));
+  Debug(CL_NOTE, "Accepting machine %s", ink_inet_ntop(remote_ip, buff, sizeof buff));
   ClusterHandler *ch = NEW(new ClusterHandler);
   ch->machine = NEW(new ClusterMachine(NULL, remote_ip));
-  ch->ip = remote_ip;
+  ch->ip = ch->;
   ch->net_vc = NetVC;
   eventProcessor.schedule_imm(ch, ET_CLUSTER);
   return 1;

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/ClusterHandlerBase.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/ClusterHandlerBase.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/ClusterHandlerBase.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/ClusterHandlerBase.cc Tue May 24 04:11:36 2011
@@ -1384,7 +1384,7 @@ ClusterHandler::dump_write_msg(int res)
   // Debug support for inter cluster message trace
   unsigned char x[4];
   memset(x, 0, sizeof(x));
-  *(uint32_t *) & x = (uint32_t) ((struct sockaddr_in *)&(net_vc->get_remote_addr()))->sin_addr.s_addr;
+  *(uint32_t *) & x = (uint32_t) ((sockaddr_storage *)&(net_vc->get_remote_addr()))->sin_addr.s_addr;
 
   fprintf(stderr,
           "[W] %hhu.%hhu.%hhu.%hhu SeqNo=%u, Cnt=%d, CntlCnt=%d Todo=%d, Res=%d\n",
@@ -1403,7 +1403,7 @@ ClusterHandler::dump_read_msg()
   // Debug support for inter cluster message trace
   unsigned char x[4];
   memset(x, 0, sizeof(x));
-  *(uint32_t *) & x = (uint32_t) ((struct sockaddr_in *)&(net_vc->get_remote_addr()))->sin_addr.s_addr;
+  *(uint32_t *) & x = (uint32_t) ((sockaddr_storage *)&(net_vc->get_remote_addr()))->sin_addr.s_addr;
 
   fprintf(stderr, "[R] %hhu.%hhu.%hhu.%hhu  SeqNo=%u, Cnt=%d, CntlCnt=%d\n",
           x[0], x[1], x[2], x[3], read.sequence_number, read.msg.count, read.msg.control_bytes);

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/ClusterMachine.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/ClusterMachine.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/ClusterMachine.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/ClusterMachine.cc Tue May 24 04:11:36 2011
@@ -63,21 +63,26 @@ create_this_cluster_machine()
   cluster_machine = NEW(new ClusterMachine);
 }
 
-ClusterMachine::ClusterMachine(char *ahostname, unsigned int aip, int aport):
+ClusterMachine::ClusterMachine(char *ahostname,
+//  unsigned int aip, int aport
+  sockaddr_storage const* aip
+):
 dead(false),
 hostname(ahostname),
-ip(aip),
-cluster_port(aport),
+//ip(aip),
+//cluster_port(aport),
 msg_proto_major(0),
 msg_proto_minor(0),
 clusterHandler(0)
 {
   EThread *thread = this_ethread();
   ProxyMutex *mutex = thread->mutex;
+
+  ink_inet_copy(&ip, aip);
 #ifndef INK_NO_CLUSTER
   CLUSTER_INCREMENT_DYN_STAT(CLUSTER_MACHINES_ALLOCATED_STAT);
 #endif
-  if (!aip) {
+  if (!ink_inet_is_ip(aip)) {
     char localhost[1024];
     if (!ahostname) {
       ink_release_assert(!gethostname(localhost, 1023));
@@ -89,7 +94,8 @@ clusterHandler(0)
     //   clustering from the manager, so the manager can control what
     //   interface we cluster over.  Otherwise figure it out ourselves
 #ifdef LOCAL_CLUSTER_TEST_MODE
-    ip = inet_addr("127.0.0.1");
+//    ip = inet_addr("127.0.0.1");
+    ink_inet_ip4_set(ip, INADDR_LOOPBACK);
 #else
 #ifdef CLUSTER_TEST
     int clustering_enabled = true;
@@ -99,43 +105,42 @@ clusterHandler(0)
     if (clustering_enabled) {
       char *clusterIP = getenv("PROXY_CLUSTER_ADDR");
       Debug("cluster_note", "[Machine::Machine] Cluster IP addr: %s\n", clusterIP);
-      ip = inet_addr(clusterIP);
+//      ip = inet_addr(clusterIP);
+      ink_inet_pton(&ip, clusterIP);
     } else {
-
       ink_gethostbyname_r_data data;
       struct hostent *r = ink_gethostbyname_r(ahostname, &data);
       if (!r) {
         Warning("unable to DNS %s: %d", ahostname, data.herrno);
-        ip = 0;
+        ink_inet_invalidate(ip);
       } else {
-
         // lowest IP address
-
-        ip = (unsigned int) -1; // 0xFFFFFFFF
+        uint32_t xip = (unsigned int) -1; // 0xFFFFFFFF
         for (int i = 0; r->h_addr_list[i]; i++)
-          if (ip > *(unsigned int *) r->h_addr_list[i])
-            ip = *(unsigned int *) r->h_addr_list[i];
-        if (ip == (unsigned int) -1)
-          ip = 0;
+          if (xip > *(unsigned int *) r->h_addr_list[i])
+            xip = *(unsigned int *) r->h_addr_list[i];
+        if (xip == (unsigned int) -1)
+          ink_inet_invalidate(ip);
+        else
+          ink_inet_ip4_set(ip, xip);
       }
       //ip = htonl(ip); for the alpha!
     }
 #endif // LOCAL_CLUSTER_TEST_MODE
   } else {
-
-    ip = aip;
-
-    ink_gethostbyaddr_r_data data;
-    struct hostent *r = ink_gethostbyaddr_r((char *) &ip, sizeof(int),
-                                            AF_INET, &data);
-
-    if (r == NULL) {
-      unsigned char x[4];
-      memset(x, 0, sizeof(x));
-      *(uint32_t *) & x = (uint32_t) ip;
-      Debug("machine_debug", "unable to reverse DNS %u.%u.%u.%u: %d", x[0], x[1], x[2], x[3], data.herrno);
+    addrinfo* ai = 0;
+    char buff[1024];
+    ink_inet_copy(ip, aip);
+//    ip = aip;
+   
+    int z = getnameinfo(&ip, sizeof(ip), buff, sizeof(buff), 0, 0, NI_NAMEREQD); 
+    if (0 != z) {
+      Debug("machine_debug", "unable to reverse DNS %s: %d",
+        ink_inet_ntop(&ip, buff, sizeof buff),
+        z
+      );
     } else
-      hostname = xstrdup(r->h_name);
+      hostname = xstrdup(buff);
   }
   if (hostname)
     hostname_len = strlen(hostname);

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/Makefile.am?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/Makefile.am (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/Makefile.am Tue May 24 04:11:36 2011
@@ -18,7 +18,7 @@
 
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/proxy/http \
   -I$(top_srcdir)/proxy/hdrs \
   -I$(top_srcdir)/proxy \

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/P_Cluster.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/P_Cluster.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/P_Cluster.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/P_Cluster.h Tue May 24 04:11:36 2011
@@ -31,7 +31,7 @@
 
 #include "libts.h"
 #include "P_EventSystem.h"
-#include "I_RecProcess.h"
+#include <records/I_RecProcess.h>
 #include "P_Net.h"
 #include "P_Cache.h"
 

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterCache.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterCache.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterCache.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterCache.h Tue May 24 04:11:36 2011
@@ -161,9 +161,12 @@ struct ClusterConfiguration
     return machines[hash_table[hash_value % CLUSTER_HASH_TABLE_SIZE]];
   }
 
-  ClusterMachine *find(unsigned int ip, int port = 0) {
+  ClusterMachine *findByAddr(
+//    unsigned int ip, int port = 0
+    sockaddr_storage const* ip
+  ) {
     for (int i = 0; i < n_machines; i++)
-      if (ip == machines[i]->ip && (!port || !machines[i]->cluster_port || machines[i]->cluster_port == port))
+      if (0 == ink_inet_cmp(ip, &machines[i]->ip))
         return machines[i];
     return NULL;
   }

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterHandler.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterHandler.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterHandler.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterHandler.h Tue May 24 04:11:36 2011
@@ -425,8 +425,9 @@ struct ClusterHandler:public ClusterHand
 #endif
   NetVConnection *net_vc;
   EThread *thread;
-  unsigned int ip;
-  int port;
+  sockaddr_storage ip;
+//  unsigned int ip;
+//  int port;
   char *hostname;
   ClusterMachine *machine;
   int ifd;

Modified: trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterMachine.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterMachine.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterMachine.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/cluster/P_ClusterMachine.h Tue May 24 04:11:36 2011
@@ -64,13 +64,17 @@ struct ClusterMachine: public Server
   // The network address of the current machine,
   // stored in network byte order
   //
-  unsigned int ip;
-  int cluster_port;
+//  unsigned int ip;
+//  int cluster_port;
+  sockaddr_storage ip;
 
     Link<ClusterMachine> link;
 
   // default for localhost
-    ClusterMachine(char *hostname = NULL, unsigned int ip = 0, int acluster_port = 0);
+    ClusterMachine(char *hostname = NULL,
+//      unsigned int ip = 0, int acluster_port = 0
+      sockaddr_storage const* ip = 0
+    );
    ~ClusterMachine();
 
   // Cluster message protocol version
@@ -84,19 +88,31 @@ struct ClusterMachine: public Server
 
 struct MachineListElement
 {
-  unsigned int ip;
-  int port;
+  sockaddr_storage ip;
+//  unsigned int ip;
+//  int port;
 };
 struct MachineList
 {
   int n;
   MachineListElement machine[1];
+/*
   MachineListElement *find(unsigned int ip, int port = 0) {
     for (int i = 0; i < n; i++)
       if (machine[i].ip == ip && (!port || machine[i].port == port))
         return &machine[i];
     return NULL;
   }
+*/
+  MachineListElement* findByAddr(sockaddr_storage const* addr) {
+    MachineListElement* elt = machine;
+    MachineListElement* limit = machine + n;
+    for ( ; elt < limit ; ++elt) {
+      if (0 == ink_inet_cmp(addr, &elt->ip))
+        return elt;
+    }
+    return 0;
+  }
 };
 
 MachineList *read_MachineList(char *filename, int test_fd = -1);

Modified: trafficserver/traffic/branches/ssc/iocore/dns/DNS.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/DNS.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/DNS.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/DNS.cc Tue May 24 04:11:36 2011
@@ -22,6 +22,7 @@
  */
 
 #include "P_DNS.h" /* MAGIC_EDITING_TAG */
+#include <ts/ink_inet.h>
 
 #ifdef SPLIT_DNS
 #include "I_SplitDNS.h"
@@ -52,6 +53,14 @@ int dns_ns_rr_init_down = 1;
 char *dns_ns_list = NULL;
 char *dns_resolv_conf = NULL;
 int dns_thread = 0;
+int dns_prefer_ipv6 = 0;
+namespace {
+  inline bool prefer_ipv6_p() { return 1 == dns_prefer_ipv6; }
+  // Currently only used for A and AAAA.
+  inline char const* QtypeName(int qtype) {
+    return T_AAAA == qtype ? "AAAA" : T_A == qtype ? "A" : "*";
+  }
+}
 
 DNSProcessor dnsProcessor;
 ClassAllocator<DNSEntry> dnsEntryAllocator("dnsEntryAllocator");
@@ -96,7 +105,60 @@ void HostEnt::free() {
   dnsBufAllocator.free(this);
 }
 
-//
+inline bool IsAddrReply(int qtype) {
+  return qtype == T_A || qtype == T_AAAA;
+}
+
+void
+make_ipv4_ptr(const char *addr, char *buffer)
+{
+    char *p = buffer;
+    unsigned char *u = (unsigned char *) addr;
+
+    if (u[3] > 99)
+      *p++ = (u[3] / 100) + '0';
+    if (u[3] > 9)
+      *p++ = ((u[3] / 10) % 10) + '0';
+    *p++ = u[3] % 10 + '0';
+    *p++ = '.';
+    if (u[2] > 99)
+      *p++ = (u[2] / 100) + '0';
+    if (u[2] > 9)
+      *p++ = ((u[2] / 10) % 10) + '0';
+    *p++ = u[2] % 10 + '0';
+    *p++ = '.';
+    if (u[1] > 99)
+      *p++ = (u[1] / 100) + '0';
+    if (u[1] > 9)
+      *p++ = ((u[1] / 10) % 10) + '0';
+    *p++ = u[1] % 10 + '0';
+    *p++ = '.';
+    if (u[0] > 99)
+      *p++ = (u[0] / 100) + '0';
+    if (u[0] > 9)
+      *p++ = ((u[0] / 10) % 10) + '0';
+    *p++ = u[0] % 10 + '0';
+    *p++ = '.';
+    ink_strncpy(p, "in-addr.arpa", MAXDNAME - (p - buffer + 1));    
+}
+
+void
+make_ipv6_ptr(const char *addr, char *buffer)
+{
+    const char hex_digit[] = "0123456789abcdef";
+    char *p = buffer;
+    int i;
+
+    for (i = 15; i >= 0; i--) {
+        *p++ = hex_digit[(unsigned char) addr[i] & 0x0f];
+        *p++ = '.';
+        *p++ = hex_digit[(unsigned char) addr[i] >> 4];
+        *p++ = '.';
+    }
+
+    ink_strncpy(p, "ip6.arpa", MAXDNAME - (p - buffer + 1));
+}
+
 //  Public functions
 //
 //  See documentation is header files and Memos
@@ -117,6 +179,7 @@ DNSProcessor::start(int) {
   IOCORE_ReadConfigStringAlloc(dns_ns_list, "proxy.config.dns.nameservers");
   IOCORE_ReadConfigStringAlloc(dns_resolv_conf, "proxy.config.dns.resolv_conf");
   IOCORE_EstablishStaticConfigInt32(dns_thread, "proxy.config.dns.dedicated_thread");
+  IOCORE_EstablishStaticConfigInt32(dns_prefer_ipv6, "proxy.config.dns.prefer_ipv6");
 
   if (dns_thread > 0) {
     ET_DNS = eventProcessor.spawn_event_threads(1, "ET_DNS"); // TODO: Hmmm, should we just get a single thread some other way?
@@ -142,15 +205,19 @@ DNSProcessor::start(int) {
 }
 
 void
-DNSProcessor::open(unsigned int aip, int aport, int aoptions)
+DNSProcessor::open(sockaddr_storage const* target, int aoptions)
 {
   DNSHandler *h = NEW(new DNSHandler);
 
   h->options = aoptions;
   h->mutex = thread->mutex;
   h->m_res = &l_res;
-  h->ip = aip;
-  h->port = aport;
+  if (target)
+    ink_inet_copy(&h->addr, target);
+  else
+    ink_inet_invalidate(h->addr);
+//  h->ip = aip;
+//  h->port = aport;
 
   if (!dns_handler_initialized)
     handler = h;
@@ -171,14 +238,14 @@ DNSProcessor::dns_init()
 
   if (dns_ns_list) {
     Debug("dns", "Nameserver list specified \"%s\"\n", dns_ns_list);
-    uint32_t nameserver_ip[MAX_NAMED];
-    int nameserver_port[MAX_NAMED];
+    sockaddr_storage nameserver[MAX_NAMED];
     int i, j;
     char *last, *ndx;
     char *ns_list = xstrdup(dns_ns_list);
     char *ns = (char *) ink_strtok_r(ns_list, " ,;\t\r", &last);
 
     for (i = 0, j = 0; (i < MAX_NAMED) && ns; i++) {
+      sockaddr_storage* ss = nameserver + j;
       Debug("dns", "Nameserver list - parsing \"%s\"\n", ns);
       int err = 0;
       int prt = DOMAIN_SERVICE_PORT;
@@ -191,30 +258,33 @@ DNSProcessor::dns_init()
           err = 1;
         }
       }
-      nameserver_ip[j] = ink_inet_addr(ns);
-      nameserver_port[j] = prt;
-      if ((int) nameserver_ip[j] == -1) {
+      if (!ink_inet_is_valid(ss)) {
         Debug("dns", "Invalid IP address given for nameserver '%s', discarding", ns);
         Warning("Invalid IP address given for nameserver '%s', discarding", ns);
         err = 1;
       }
-
       if (!err) {
-        Debug("dns", "Adding nameserver %d.%d.%d.%d:%d to nameserver list",
-              DOT_SEPARATED(nameserver_ip[j]), nameserver_port[j]);
+        char buff[INET6_ADDRPORTSTRLEN];
+
+        ink_inet_init(*ss);
+        ink_inet_pton(ns, ss);
+        ink_inet_port_cast(ss) = prt;
+
+        Debug("dns", "Adding nameserver %s to nameserver list",
+          ink_inet_nptop(ss, buff, sizeof(buff))
+        );
         ++j;
-      } else
-        nameserver_ip[j] = 0;
+      }
 
       ns = (char *) ink_strtok_r(NULL, " ,;\t\r", &last);
     }
     xfree(ns_list);
     // Terminate the list for ink_res_init
-    nameserver_ip[j] = 0;
+    ink_inet_invalidate(nameserver[j]);
 
     // The default domain (4th param) and search list (5th param) will
     // come from /etc/resolv.conf.
-    if (ink_res_init(&l_res, &nameserver_ip[0], &nameserver_port[0], NULL, NULL, dns_resolv_conf) < 0)
+    if (ink_res_init(&l_res, nameserver, NULL, NULL, dns_resolv_conf) < 0)
       Warning("Failed to build DNS res records for the servers (%s).  Using resolv.conf.", dns_ns_list);
   } else {
     if (ink_res_init(&l_res, NULL, NULL, NULL, NULL, dns_resolv_conf) < 0)
@@ -266,7 +336,7 @@ DNSEntry::init(const char *x, int len, i
 
   mutex = dnsH->mutex;
 
-  if (qtype == T_A || qtype == T_SRV) {
+  if (IsAddrReply(qtype) || qtype == T_SRV) {
     if (len) {
       len = len > (MAXDNAME - 1) ? (MAXDNAME - 1) : len;
       memcpy(qname, x, len);
@@ -278,34 +348,8 @@ DNSEntry::init(const char *x, int len, i
       qname_len = strlen(qname);
     }
   } else {                    //T_PTR
-    char *p = qname;
-    unsigned char *u = (unsigned char *) x;
-
-    if (u[3] > 99)
-      *p++ = (u[3] / 100) + '0';
-    if (u[3] > 9)
-      *p++ = ((u[3] / 10) % 10) + '0';
-    *p++ = u[3] % 10 + '0';
-    *p++ = '.';
-    if (u[2] > 99)
-      *p++ = (u[2] / 100) + '0';
-    if (u[2] > 9)
-      *p++ = ((u[2] / 10) % 10) + '0';
-    *p++ = u[2] % 10 + '0';
-    *p++ = '.';
-    if (u[1] > 99)
-      *p++ = (u[1] / 100) + '0';
-    if (u[1] > 9)
-      *p++ = ((u[1] / 10) % 10) + '0';
-    *p++ = u[1] % 10 + '0';
-    *p++ = '.';
-    if (u[0] > 99)
-      *p++ = (u[0] / 100) + '0';
-    if (u[0] > 9)
-      *p++ = ((u[0] / 10) % 10) + '0';
-    *p++ = u[0] % 10 + '0';
-    *p++ = '.';
-    ink_strncpy(p, "in-addr.arpa", MAXDNAME - (p - qname + 1));
+      if (static_cast<int>(INK_IP6_SIZE) == len) make_ipv6_ptr(x, qname);
+      else make_ipv4_ptr(x, qname);
   }
 
   SET_HANDLER((DNSEntryHandler) & DNSEntry::mainEvent);
@@ -317,15 +361,17 @@ DNSEntry::init(const char *x, int len, i
 
 */
 void
-DNSHandler::open_con(unsigned int aip, int aport, bool failed, int icon)
+DNSHandler::open_con(sockaddr_storage const* target, bool failed, int icon)
 {
+  char addr_buff[INET6_ADDRPORTSTRLEN];
   PollDescriptor *pd = get_PollDescriptor(dnsProcessor.thread);
 
-  Debug("dns", "open_con: opening connection %d.%d.%d.%d:%d", DOT_SEPARATED(aip), aport);
+  Debug("dns", "open_con: opening connection %s", ink_inet_nptop(target, addr_buff, sizeof(addr_buff)));
 
   if (!icon) {
-    ip = aip;
-    port = aport;
+//    ip = aip;
+//    port = aport;
+    ink_inet_copy(&addr, target);
   }
 
   if (con[icon].fd != NO_FD) {  // Remove old FD from epoll fd
@@ -333,8 +379,8 @@ DNSHandler::open_con(unsigned int aip, i
     con[icon].close();
   }
 
-  if (con[icon].connect(aip, aport, NON_BLOCKING_CONNECT, CONNECT_WITH_UDP, NON_BLOCKING, BIND_RANDOM_PORT) < 0) {
-    Debug("dns", "opening connection %d.%d.%d.%d:%d FAILED for %d", DOT_SEPARATED(aip), aport, icon);
+  if (con[icon].connect(target, NON_BLOCKING_CONNECT, CONNECT_WITH_UDP, NON_BLOCKING, BIND_RANDOM_PORT) < 0) {
+    Debug("dns", "opening connection %s FAILED for %d", addr_buff, icon);
     if (!failed) {
       if (dns_ns_rr)
         rr_failure(icon);
@@ -348,7 +394,7 @@ DNSHandler::open_con(unsigned int aip, i
       Error("[iocore_dns] open_con: Failed to add %d server to epoll list\n", icon);
     } else {
       con[icon].num = icon;
-      Debug("dns", "opening connection %d.%d.%d.%d:%d SUCCEEDED for %d", DOT_SEPARATED(aip), aport, icon);
+      Debug("dns", "opening connection %s SUCCEEDED for %d", addr_buff, icon);
     }
   }
 }
@@ -364,17 +410,16 @@ DNSHandler::startEvent(int event, Event 
   NOWARN_UNUSED(event);
   //
   // If this is for the default server, get it
-  //
+  // AMC: I love this cut and paste re-use...sigh.
   Debug("dns", "DNSHandler::startEvent: on thread %d\n", e->ethread->id);
-  if (ip == DEFAULT_DOMAIN_NAME_SERVER) {
+  if (!ink_inet_is_valid(addr)) {
     // seems that res_init always sets m_res.nscount to at least 1!
     if (!m_res->nscount)
       Warning("bad configurations: no nameservers given");
-    struct sockaddr_in *sa = &m_res->nsaddr_list[0].sin;
-    ip = sa->sin_addr.s_addr;
-    if (!ip)
-      ip = ink_inet_addr("127.0.0.1");
-    port = ntohs(sa->sin_port);
+    if (!ink_inet_copy(addr, m_res->nsaddr_list[0])) {
+      ink_inet_init(addr);
+      ink_inet_ip4_set(addr, INADDR_LOOPBACK, DOMAIN_SERVICE_PORT);
+    }
   }
 
   if (!dns_handler_initialized) {
@@ -390,18 +435,20 @@ DNSHandler::startEvent(int event, Event 
         max_nscount = MAX_NAMED;
       n_con = 0;
       for (int i = 0; i < max_nscount; i++) {
-        struct sockaddr_in *sa = &m_res->nsaddr_list[i].sin;
-        ip = sa->sin_addr.s_addr;
-        if (ip) {
-          port = ntohs(sa->sin_port);
-          open_con(ip, port, false, n_con);
+        char buff[INET6_ADDRPORTSTRLEN];
+        sockaddr_storage *sa = &m_res->nsaddr_list[i];
+        if (ink_inet_is_valid(sa)) {
+          open_con(sa, false, n_con);
           ++n_con;
-          Debug("dns_pas", "opened connection to %d.%d.%d.%d:%d, n_con = %d", DOT_SEPARATED(ip), port, n_con);
+          Debug("dns_pas", "opened connection to %s, n_con = %d",
+            ink_inet_nptop(sa, buff, sizeof(buff)),
+            n_con
+          );
         }
       }
       dns_ns_rr_init_down = 0;
     } else {
-      open_con(ip, port);
+      open_con(&addr);
       n_con = 1;
     }
     e->ethread->schedule_every(this, DNS_PERIOD);
@@ -423,19 +470,19 @@ DNSHandler::startEvent_sdns(int event, E
   NOWARN_UNUSED(event);
   Debug("dns", "DNSHandler::startEvent_sdns: on thread %d\n", e->ethread->id);
 
-  if (ip == DEFAULT_DOMAIN_NAME_SERVER) {
+  if (!ink_inet_is_valid(addr)) { // use default
     // seems that res_init always sets m_res.nscount to at least 1!
     if (!m_res->nscount)
       Warning("bad nameserver config, fallback to 127.0.0.1");
-    struct sockaddr_in *sa = &m_res->nsaddr_list[0].sin;
-    ip = sa->sin_addr.s_addr;
-    if (!ip)
-      ip = ink_inet_addr("127.0.0.1");
-    port = ntohs(sa->sin_port);
+    sockaddr_storage addr;
+    if (!ink_inet_copy(addr, m_res->nsaddr_list[0])) {
+      ink_inet_init(addr);
+      ink_inet_ip4_set(addr, INADDR_LOOPBACK, DOMAIN_SERVICE_PORT);
+    }
   }
 
   SET_HANDLER(&DNSHandler::mainEvent);
-  open_con(ip, port, false, n_con);
+  open_con(&addr, false, n_con);
   ++n_con;                      // TODO should n_con be zeroed?
 
   e->schedule_every(DNS_PERIOD);
@@ -454,7 +501,8 @@ _ink_res_mkquery(ink_res_state res, char
 void
 DNSHandler::recover()
 {
-  Warning("connection to DNS server %d.%d.%d.%d restored", DOT_SEPARATED(ip));
+  char buff[INET6_ADDRSTRLEN];
+  Warning("connection to DNS server %s restored", ink_inet_ntop(&addr, buff, sizeof(buff)));
   name_server = 0;
   switch_named(name_server);
 }
@@ -466,17 +514,18 @@ DNSHandler::retry_named(int ndx, ink_hrt
     Debug("dns", "retry_named: reopening DNS connection for index %d", ndx);
     last_primary_reopen = t;
     con[ndx].close();
-    struct sockaddr_in *sa;
-    sa = &m_res->nsaddr_list[ndx].sin;
-    ip = sa->sin_addr.s_addr;
-    port = ntohs(sa->sin_port);
+    open_con(&m_res->nsaddr_list[ndx], true, ndx);
+//    sockaddr_storage *sa;
+//    sa = &m_res->nsaddr_list[ndx];
+//    ip = sa->sin_addr.s_addr;
+//    port = ntohs(sa->sin_port);
 
-    open_con(ip, port, true, ndx);
+//    open_con(ip, port, true, ndx);
   }
 
   char buffer[MAX_DNS_PACKET_LEN];
   Debug("dns", "trying to resolve '%s' from DNS connection, ndx %d", try_server_names[try_servers], ndx);
-  int r = _ink_res_mkquery(m_res, try_server_names[try_servers], T_A, buffer);
+  int r = _ink_res_mkquery(m_res, try_server_names[try_servers], prefer_ipv6_p() ? T_AAAA : T_A, buffer);
   try_servers = (try_servers + 1) % SIZE(try_server_names);
   ink_assert(r >= 0);
   if (r >= 0) {                 // looking for a bounce
@@ -492,14 +541,14 @@ DNSHandler::try_primary_named(bool reope
   if (reopen && ((t - last_primary_reopen) > DNS_PRIMARY_REOPEN_PERIOD)) {
     Debug("dns", "try_primary_named: reopening primary DNS connection");
     last_primary_reopen = t;
-    open_con(ip, port, true, 0);
+    open_con(&addr, true, 0);
   }
   if ((t - last_primary_retry) > DNS_PRIMARY_RETRY_PERIOD) {
     char buffer[MAX_DNS_PACKET_LEN];
 
     last_primary_retry = t;
     Debug("dns", "trying to resolve '%s' from primary DNS connection", try_server_names[try_servers]);
-    int r = _ink_res_mkquery(m_res, try_server_names[try_servers], T_A, buffer);
+    int r = _ink_res_mkquery(m_res, try_server_names[try_servers], prefer_ipv6_p() ? T_AAAA : T_A, buffer);
     // if try_server_names[] is not full, round-robin within the
     // filled entries.
     if (local_num_entries < DEFAULT_NUM_TRY_SERVER)
@@ -534,29 +583,37 @@ DNSHandler::failover()
   Debug("dns", "failover: initiating failover attempt, current name_server=%d", name_server);
   // no hope, if we have only one server
   if (m_res->nscount > 1) {
+    char buff1[INET6_ADDRSTRLEN], buff2[INET6_ADDRSTRLEN];
     int max_nscount = m_res->nscount;
 
     if (max_nscount > MAX_NAMED)
       max_nscount = MAX_NAMED;
-    unsigned int old_ip = m_res->nsaddr_list[name_server].sin.sin_addr.s_addr;
+    sockaddr_storage const* old_addr = &m_res->nsaddr_list[name_server];
     name_server = (name_server + 1) % max_nscount;
     Debug("dns", "failover: failing over to name_server=%d", name_server);
 
-    struct sockaddr_in *sa = &m_res->nsaddr_list[name_server].sin;
-
-    Warning("failover: connection to DNS server %d.%d.%d.%d lost, move to %d.%d.%d.%d",
-            DOT_SEPARATED(old_ip), DOT_SEPARATED(sa->sin_addr.s_addr));
-
-    unsigned int tip = sa->sin_addr.s_addr;
+    sockaddr_storage target;
+    ink_inet_copy(target, m_res->nsaddr_list[name_server]);
 
-    if (!tip)
-      tip = ink_inet_addr("127.0.0.1");
-    open_con(tip, ntohs(sa->sin_port), true, name_server);
+    Warning("failover: connection to DNS server %s lost, move to %s",
+      ink_inet_ntop(old_addr, buff1, sizeof(buff1)),
+      ink_inet_ntop(&target, buff2, sizeof(buff2))
+    );
+
+    if (!ink_inet_is_valid(target)) {
+      ink_inet_init(target);
+      ink_inet_ip4_set(target, INADDR_LOOPBACK, DOMAIN_SERVICE_PORT);
+    }
+    open_con(&target, true, name_server);
     if (n_con <= name_server)
       n_con = name_server + 1;
     switch_named(name_server);
-  } else
-    Warning("failover: connection to DNS server %d.%d.%d.%d lost, retrying", DOT_SEPARATED(ip));
+  } else {
+    char buff[INET6_ADDRSTRLEN];
+    Warning("failover: connection to DNS server %s lost, retrying",
+      ink_inet_ntop(&addr, buff, sizeof(buff))
+    );
+  }
 }
 
 /** Mark one of the nameservers as down. */
@@ -565,13 +622,13 @@ DNSHandler::rr_failure(int ndx)
 {
   // no hope, if we have only one server
   if (!ns_down[ndx]) {
+    char buff[INET6_ADDRSTRLEN];
     // mark this nameserver as down
     Debug("dns", "rr_failure: Marking nameserver %d as down", ndx);
     ns_down[ndx] = 1;
-
-    struct sockaddr_in *sa = &m_res->nsaddr_list[ndx].sin;
-    unsigned int tip = sa->sin_addr.s_addr;
-    Warning("connection to DNS server %d.%d.%d.%d lost, marking as down", DOT_SEPARATED(tip));
+    Warning("connection to DNS server %s lost, marking as down",
+      ink_inet_ntop(&m_res->nsaddr_list[ndx], buff, sizeof(buff))
+    );
   }
 
   int nscount = m_res->nscount;
@@ -633,17 +690,18 @@ DNSHandler::recv_dns(int event, Event *e
   NOWARN_UNUSED(event);
   NOWARN_UNUSED(e);
   DNSConnection *dnsc = NULL;
+  char buff[INET6_ADDRSTRLEN];
 
   while ((dnsc = (DNSConnection *) triggered.dequeue())) {
     while (1) {
-      struct sockaddr_in sa_from;
-      socklen_t sa_length = sizeof(sa_from); // TODO: I'm guessing when we support IPv6,this will have to change.
+      sockaddr_storage from;
+      socklen_t from_length = sizeof(from);
 
       if (!hostent_cache)
         hostent_cache = dnsBufAllocator.alloc();
       HostEnt *buf = hostent_cache;
 
-      int res = socketManager.recvfrom(dnsc->fd, buf->buf, MAX_DNS_PACKET_LEN, 0, (struct sockaddr *) &sa_from, &sa_length);
+      int res = socketManager.recvfrom(dnsc->fd, buf->buf, MAX_DNS_PACKET_LEN, 0, &from, &from_length);
 
       if (res == -EAGAIN)
         break;
@@ -657,8 +715,10 @@ DNSHandler::recv_dns(int event, Event *e
       }
 
       // verify that this response came from the correct server
-      if (dnsc->sa.sin_addr.s_addr != sa_from.sin_addr.s_addr) {
-        Warning("received DNS response from unexpected named %d.%d.%d.%d", DOT_SEPARATED(sa_from.sin_addr.s_addr));
+      if (0 != ink_inet_cmp(dnsc->sa, from)) {
+        Warning("received DNS response from unexpected named %s",
+          ink_inet_ntop(&from, buff, sizeof(buff))
+        );
         continue;
       }
       hostent_cache = 0;
@@ -669,9 +729,9 @@ DNSHandler::recv_dns(int event, Event *e
         if (good_rcode(buf->buf)) {
           received_one(dnsc->num);
           if (ns_down[dnsc->num]) {
-            struct sockaddr_in *sa = &m_res->nsaddr_list[dnsc->num].sin;
-
-            Warning("connection to DNS server %d.%d.%d.%d restored", DOT_SEPARATED(sa->sin_addr.s_addr));
+            Warning("connection to DNS server %s restored",
+              ink_inet_ntop(&m_res->nsaddr_list[dnsc->num], buff, sizeof(buff))
+            );
             ns_down[dnsc->num] = 0;
           }
         }
@@ -766,10 +826,10 @@ get_entry(DNSHandler *h, char *qname, in
 {
   for (DNSEntry *e = h->entries.head; e; e = (DNSEntry *) e->link.next) {
     if (e->qtype == qtype) {
-      if (qtype == T_A) {
+      if (IsAddrReply(qtype)) {
         if (!strcmp(qname, e->qname))
           return e;
-      } else if (*(unsigned int *) qname == *(unsigned int *) e->qname)
+      } else if (0 == memcmp(qname, e->qname, e->qname_len))
         return e;
     }
   }
@@ -871,7 +931,7 @@ write_dns_event(DNSHandler *h, DNSEntry 
     h->release_query_id(e->id[dns_retries - e->retries]);
   }
   e->id[dns_retries - e->retries] = i;
-  Debug("dns", "send query for %s to fd %d", e->qname, h->con[h->name_server].fd);
+  Debug("dns", "send query (qtype=%d) for %s to fd %d", e->qtype, e->qname, h->con[h->name_server].fd);
 
   int s = socketManager.send(h->con[h->name_server].fd, buffer, r, 0);
   if (s != r) {
@@ -1013,6 +1073,18 @@ dns_result(DNSHandler *h, DNSEntry *e, H
       --(e->retries);
       write_dns(h);
       return;
+    } else if (prefer_ipv6_p() && e->qtype == T_AAAA) {
+      Debug("dns", "Trying A after AAAA failure for %s", e->qname);
+      e->retries = dns_retries;
+      e->qtype = T_A;
+      write_dns(h);
+      return;
+    } else if (!prefer_ipv6_p() && e->qtype == T_A) {
+      Debug("dns", "Trying AAAA after A failure for %s", e->qname);
+      e->retries = dns_retries;
+      e->qtype = T_AAAA;
+      write_dns(h);
+      return;
     } else if (e->domains && *e->domains) {
       do {
         Debug("dns", "domain extending %s", e->qname);
@@ -1071,10 +1143,12 @@ dns_result(DNSHandler *h, DNSEntry *e, H
   }
   h->entries.remove(e);
 
-  if (e->qtype == T_A) {
-    unsigned int tip = ent != NULL ? *(unsigned int *) ent->ent.h_addr_list[0] : 0;
-    Debug("dns", "%s result for %s = %d.%d.%d.%d retry %d",
-          ent ? "SUCCESS" : "FAIL", e->qname, DOT_SEPARATED(tip), retry);
+  if (IsAddrReply(e->qtype)) {
+    char buff[INET6_ADDRSTRLEN];
+    char const* ptr = "<none>";
+    if (ent) ptr = inet_ntop(e->qtype == T_AAAA ? AF_INET6 : AF_INET, ent->ent.h_addr_list[0], buff, sizeof(buff));
+    Debug("dns", "%s result for %s = %s retry %d",
+      ent ? "SUCCESS" : "FAIL", e->qname, ptr, retry);
   } else {
     Debug("dns", "%s result for %s = %s retry %d",
           ent ? "SUCCESS" : "FAIL", e->qname, (ent != NULL ? ent->ent.h_name : "<not found>"), retry);
@@ -1249,7 +1323,7 @@ dns_process(DNSHandler *handler, HostEnt
     }
 
     cp += n + QFIXEDSZ;
-    if (e->qtype == T_A) {
+    if (IsAddrReply(e->qtype)) {
       if (-1 == rname_len)
         n = strlen((char *)bp) + 1;
       else
@@ -1324,7 +1398,7 @@ dns_process(DNSHandler *handler, HostEnt
       //
       // Decode cname
       //
-      if (e->qtype == T_A && type == T_CNAME) {
+      if (IsAddrReply(e->qtype) && type == T_CNAME) {
         if (ap >= &buf->host_aliases[DNS_MAX_ALIASES - 1])
           continue;
         n = ink_dn_expand((u_char *) h, eom, cp, tbuf, sizeof(tbuf));
@@ -1402,7 +1476,7 @@ dns_process(DNSHandler *handler, HostEnt
 
         buf->srv_hosts.insert(s);
         ++num_srv;
-      } else if (type == T_A) {
+      } else if (IsAddrReply(type)) {
         if (answer) {
           if (n != buf->ent.h_length) {
             cp += n;
@@ -1414,7 +1488,7 @@ dns_process(DNSHandler *handler, HostEnt
           buf->ent.h_addrtype = C_IN;
           buf->ent.h_name = (char *) bp;
           nn = strlen((char *) bp) + 1;
-          Debug("dns", "received A name = %s", bp);
+          Debug("dns", "received %s name = %s", QtypeName(type), bp);
           bp += nn;
           buflen -= nn;
         }
@@ -1423,13 +1497,16 @@ dns_process(DNSHandler *handler, HostEnt
           *hap++ = cp;
           cp += n;
         } else {
+          char ip_string[INET6_ADDRSTRLEN];
           bp = (unsigned char *) align_pointer_forward(bp, sizeof(int));
           if (bp + n >= buf->hostbuf + DNS_HOSTBUF_SIZE) {
             ++error;
             break;
           }
           memcpy((*hap++ = bp), cp, n);
-          Debug("dns", "received A = %d.%d.%d.%d", DOT_SEPARATED(*(unsigned int *) bp));
+          Debug("dns", "received %s = %s", QtypeName(type),
+            inet_ntop(T_AAAA == type ? AF_INET6 : AF_INET, bp, ip_string, sizeof(ip_string))
+          );
           bp += n;
           cp += n;
         }

Modified: trafficserver/traffic/branches/ssc/iocore/dns/DNSConnection.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/DNSConnection.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/DNSConnection.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/DNSConnection.cc Tue May 24 04:11:36 2011
@@ -50,7 +50,7 @@
 DNSConnection::DNSConnection():
   fd(NO_FD), num(0), generator((uint32_t)((uintptr_t)time(NULL) ^ (uintptr_t) this)), handler(NULL)
 {
-  memset(&sa, 0, sizeof(struct sockaddr_in));
+  memset(&sa, 0, sizeof(sockaddr_storage));
 }
 
 DNSConnection::~DNSConnection()
@@ -79,21 +79,22 @@ DNSConnection::trigger()
 }
 
 int
-DNSConnection::connect(unsigned int ip, int port,
+DNSConnection::connect(sockaddr_storage const* target,
                        bool non_blocking_connect, bool use_tcp, bool non_blocking, bool bind_random_port)
 {
   ink_assert(fd == NO_FD);
 
   int res = 0;
   short Proto;
+  uint8_t family = target->ss_family;
 
   if (use_tcp) {
     Proto = IPPROTO_TCP;
-    if ((res = socketManager.socket(AF_INET, SOCK_STREAM, 0)) < 0)
+    if ((res = socketManager.socket(family, SOCK_STREAM, 0)) < 0)
       goto Lerror;
   } else {
     Proto = IPPROTO_UDP;
-    if ((res = socketManager.socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+    if ((res = socketManager.socket(family, SOCK_DGRAM, 0)) < 0)
       goto Lerror;
   }
 
@@ -102,15 +103,17 @@ DNSConnection::connect(unsigned int ip, 
   if (bind_random_port) {
     int retries = 0;
     while (retries++ < 10000) {
-      struct sockaddr_in bind_sa;
-      memset(&sa, 0, sizeof(bind_sa));
-      bind_sa.sin_family = AF_INET;
-      bind_sa.sin_addr.s_addr = INADDR_ANY;
+      sockaddr_storage bind_sa;
+      ink_inet_init(bind_sa);
+      if (ink_inet_is_ip6(target))
+        ink_inet_ip6_addr_cast(&bind_sa) = in6addr_any;
+      else
+        ink_inet_ip4_set(&bind_sa, INADDR_ANY);
       uint32_t p = generator.random();
-      p = (uint16_t)((p % (LAST_RANDOM_PORT - FIRST_RANDOM_PORT)) + FIRST_RANDOM_PORT);
-      bind_sa.sin_port = htons(p);
+      p = static_cast<uint16_t>((p % (LAST_RANDOM_PORT - FIRST_RANDOM_PORT)) + FIRST_RANDOM_PORT);
+      ink_inet_port_cast(bind_sa) = htons(p);
       Debug("dns", "random port = %u\n", p);
-      if ((res = socketManager.ink_bind(fd, (struct sockaddr *) &bind_sa, sizeof(bind_sa), Proto)) < 0) {
+      if ((res = socketManager.ink_bind(fd, &bind_sa, sizeof(bind_sa), Proto)) < 0) {
         continue;
       }
       goto Lok;
@@ -119,11 +122,6 @@ DNSConnection::connect(unsigned int ip, 
   Lok:;
   }
 
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons(port);
-  sa.sin_addr.s_addr = ip;
-  memset(&sa.sin_zero, 0, 8);
-
   if (non_blocking_connect)
     if ((res = safe_nonblocking(fd)) < 0)
       goto Lerror;
@@ -143,7 +141,7 @@ DNSConnection::connect(unsigned int ip, 
     goto Lerror;
 #endif
 
-  res =::connect(fd, (struct sockaddr *) &sa, sizeof(struct sockaddr_in));
+  res =::connect(fd, ink_inet_sa_cast(target), sizeof(*target));
 
   if (!res || ((res < 0) && (errno == EINPROGRESS || errno == EWOULDBLOCK))) {
     if (!non_blocking_connect && non_blocking)

Modified: trafficserver/traffic/branches/ssc/iocore/dns/I_DNSProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/I_DNSProcessor.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/I_DNSProcessor.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/I_DNSProcessor.h Tue May 24 04:11:36 2011
@@ -31,8 +31,7 @@
 #define  DNS_MAX_ADDRS                35
 #define  DNS_HOSTBUF_SIZE           8192
 #define  DOMAIN_SERVICE_PORT          53
-#define  DEFAULT_DOMAIN_NAME_SERVER    0        // use the default server
-
+#define  DEFAULT_DOMAIN_NAME_SERVER    0
 
 /**
   All buffering required to handle a DNS receipt. For asynchronous DNS,
@@ -88,7 +87,12 @@ struct DNSProcessor: public Processor
 
   // Open/close a link to a 'named' (done in start())
   //
-  void open(unsigned int ip = DEFAULT_DOMAIN_NAME_SERVER, int port = DOMAIN_SERVICE_PORT, int options = _res.options);
+  void open(
+    sockaddr_storage const* target = 0, // 0 -> use default
+//    unsigned int ip = DEFAULT_DOMAIN_NAME_SERVER,
+//    int port = DOMAIN_SERVICE_PORT,
+    int options = _res.options
+  );
 
   DNSProcessor();
 

Modified: trafficserver/traffic/branches/ssc/iocore/dns/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/Makefile.am?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/Makefile.am (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/Makefile.am Tue May 24 04:11:36 2011
@@ -19,11 +19,11 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records
+  -I$(top_srcdir)/lib
 else
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/proxy/http \
   -I$(top_srcdir)/proxy/hdrs \

Modified: trafficserver/traffic/branches/ssc/iocore/dns/P_DNSConnection.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/P_DNSConnection.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/P_DNSConnection.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/P_DNSConnection.h Tue May 24 04:11:36 2011
@@ -60,14 +60,14 @@ struct DNSHandler;
 struct DNSConnection
 {
   int fd;
-  struct sockaddr_in sa;
+  sockaddr_storage sa;
   int num;
   LINK(DNSConnection, link);
   EventIO eio;
   InkRand generator;
   DNSHandler* handler;
 
-  int connect(unsigned int ip, int port,
+  int connect(sockaddr_storage const* target,
               bool non_blocking_connect = NON_BLOCKING_CONNECT,
               bool use_tcp = CONNECT_WITH_TCP, bool non_blocking = NON_BLOCKING, bool bind_random_port = BIND_ANY_PORT);
   int close();

Modified: trafficserver/traffic/branches/ssc/iocore/dns/P_DNSProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/P_DNSProcessor.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/P_DNSProcessor.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/P_DNSProcessor.h Tue May 24 04:11:36 2011
@@ -198,8 +198,9 @@ struct DNSEntry;
 */
 struct DNSHandler: public Continuation
 {
-  unsigned int ip;
-  int port;
+//  unsigned int ip;
+//  int port;
+  sockaddr_storage addr;
   int ifd[MAX_NAMED];
   int n_con;
   DNSConnection con[MAX_NAMED];
@@ -225,7 +226,6 @@ struct DNSHandler: public Continuation
   // bitmap of query ids in use
   uint64_t qid_in_flight[(USHRT_MAX+1)/64];
 
-
   void received_one(int i)
   {
     failover_number[i] = failover_soon_number[i] = crossed_failover_number[i] = 0;
@@ -261,7 +261,7 @@ struct DNSHandler: public Continuation
   int startEvent_sdns(int event, Event *e);
   int mainEvent(int event, Event *e);
 
-  void open_con(unsigned int aip, int aport, bool failed = false, int icon = 0);
+  void open_con(sockaddr_storage const* target, bool failed = false, int icon = 0);
   void failover();
   void rr_failure(int ndx);
   void recover();
@@ -287,10 +287,13 @@ struct DNSHandler: public Continuation
 
 
 TS_INLINE DNSHandler::DNSHandler()
- : Continuation(NULL), ip(0), port(0), n_con(0), options(0), in_flight(0), name_server(0), in_write_dns(0),
+ : Continuation(NULL),
+   //  ip(0), port(0),
+  n_con(0), options(0), in_flight(0), name_server(0), in_write_dns(0),
   hostent_cache(0), last_primary_retry(0), last_primary_reopen(0),
   m_res(0), txn_lookup_timeout(0), generator((uint32_t)((uintptr_t)time(NULL) ^ (uintptr_t)this))
 {
+  ink_inet_init(addr);
   for (int i = 0; i < MAX_NAMED; i++) {
     ifd[i] = -1;
     failover_number[i] = 0;
@@ -304,8 +307,5 @@ TS_INLINE DNSHandler::DNSHandler()
   Debug("net_epoll", "inline DNSHandler::DNSHandler()");
 }
 
-#define DOT_SEPARATED(_x)                                   \
-  ((unsigned char*)&(_x))[0], ((unsigned char*)&(_x))[1],   \
-    ((unsigned char*)&(_x))[2], ((unsigned char*)&(_x))[3]
+# endif
 
-#endif

Modified: trafficserver/traffic/branches/ssc/iocore/dns/P_SplitDNSProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/P_SplitDNSProcessor.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/P_SplitDNSProcessor.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/P_SplitDNSProcessor.h Tue May 24 04:11:36 2011
@@ -162,7 +162,7 @@ TS_INLINE bool SplitDNSConfig::isSplitDN
    -------------------------------------------------------------- */
 struct DNSServer
 {
-  unsigned int x_server_ip[MAXNS];
+  sockaddr_storage x_server_ip[MAXNS];
   char x_dns_ip_line[MAXDNAME * 2];
 
   char x_def_domain[MAXDNAME];

Modified: trafficserver/traffic/branches/ssc/iocore/dns/SplitDNS.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/dns/SplitDNS.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/dns/SplitDNS.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/dns/SplitDNS.cc Tue May 24 04:11:36 2011
@@ -364,14 +364,9 @@ SplitDNSRecord::ProcessDNSHosts(char *va
       *tmp = 0;
     }
 
-    unsigned int addr = inet_addr(current);
-
-    if (((uint32_t)-1) == htonl(addr)) {
+    if (0 != ink_inet_pton(current, m_servers.x_server_ip + i))
       return "invalid IP address given for a DNS server";
-    }
-
-    m_servers.x_server_ip[i] = addr;
-    m_servers.x_dns_server_port[i] = port ? port : NAMESERVER_PORT;
+    ink_inet_port_cast(m_servers.x_server_ip) = (port ? port : NAMESERVER_PORT);
 
     if ((MAXDNAME * 2 - 1) > totsz) {
       sz = strlen(current);
@@ -506,27 +501,27 @@ SplitDNSRecord::Init(matcher_line * line
     }
   }
 
-  if (this->m_servers.x_server_ip[0] == 0) {
+  if (!ink_inet_is_valid(this->m_servers.x_server_ip[0])) {
     snprintf(errBuf, errBufLen, "%s No server specified in splitdns.config at line %d", modulePrefix, line_num);
     return errBuf;
   }
 
   DNSHandler *dnsH = new DNSHandler;
   ink_res_state res = new __ink_res_state;
+  char ip_string[INET6_ADDRPORTSTRLEN];
 
   memset(res, 0, sizeof(__ink_res_state));
   if ((-1 == ink_res_init(res, m_servers.x_server_ip, m_servers.x_dns_server_port,
                           m_servers.x_def_domain, m_servers.x_domain_srch_list, NULL))) {
-    snprintf(errBuf, errBufLen, "Failed to build res record for the servers %u ... on port %d",
-             m_servers.x_server_ip[0], m_servers.x_dns_server_port[0]);
+    snprintf(errBuf, errBufLen, "Failed to build res record for the servers %s",
+      ink_inet_nptop(m_servers.x_server_ip, ip_string, sizeof ip_string));
     return errBuf;
   }
 
   dnsH->m_res = res;
   dnsH->mutex = SplitDNSConfig::dnsHandler_mutex;
   dnsH->options = res->options;
-  dnsH->ip = DEFAULT_DOMAIN_NAME_SERVER;
-  dnsH->port = DOMAIN_SERVICE_PORT;
+  ink_inet_invalidate(dnsH->addr);
 
   m_servers.x_dnsH = dnsH;
 
@@ -575,13 +570,10 @@ SplitDNSRecord::UpdateMatch(SplitDNSResu
 void
 SplitDNSRecord::Print()
 {
-  struct in_addr address;
+  char s[INET6_ADDRPORTSTRLEN];
 
   for (int i = 0; i < m_dnsSrvr_cnt; i++) {
-    address.s_addr = m_servers.x_server_ip[i];
-    char *pAdr = inet_ntoa(address);
-
-    Debug("splitdns_config", " %s:%d ", pAdr, m_servers.x_dns_server_port[i]);
+    Debug("splitdns_config", " %s ", ink_inet_nptop(m_servers.x_server_ip, s, sizeof(s)));
   }
 }
 

Modified: trafficserver/traffic/branches/ssc/iocore/eventsystem/I_EventSystem.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/eventsystem/I_EventSystem.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/eventsystem/I_EventSystem.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/eventsystem/I_EventSystem.h Tue May 24 04:11:36 2011
@@ -46,7 +46,7 @@
 #include "I_Thread.h"
 #include "I_VIO.h"
 #include "I_VConnection.h"
-#include "I_RecProcess.h"
+#include <records/I_RecProcess.h>
 #include "I_SocketManager.h"
 
 #define EVENT_SYSTEM_MODULE_MAJOR_VERSION 1

Modified: trafficserver/traffic/branches/ssc/iocore/eventsystem/I_SocketManager.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/eventsystem/I_SocketManager.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/eventsystem/I_SocketManager.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/eventsystem/I_SocketManager.h Tue May 24 04:11:36 2011
@@ -64,7 +64,7 @@ struct SocketManager
   int64_t pread(int fd, void *buf, int len, off_t offset, char *tag = NULL);
 
   int recv(int s, void *buf, int len, int flags);
-  int recvfrom(int fd, void *buf, int size, int flags, struct sockaddr *addr, socklen_t *addrlen);
+  int recvfrom(int fd, void *buf, int size, int flags, sockaddr_storage *addr, socklen_t *addrlen);
 
   int64_t write(int fd, void *buf, int len, void *pOLP = NULL);
   int64_t writev(int fd, struct iovec *vector, size_t count);
@@ -72,7 +72,7 @@ struct SocketManager
   int64_t pwrite(int fd, void *buf, int len, off_t offset, char *tag = NULL);
 
   int send(int fd, void *buf, int len, int flags);
-  int sendto(int fd, void *buf, int len, int flags, struct sockaddr *to, int tolen);
+  int sendto(int fd, void *buf, int len, int flags, sockaddr_storage *to, int tolen);
   int sendmsg(int fd, struct msghdr *m, int flags, void *pOLP = 0);
   int64_t lseek(int fd, off_t offset, int whence);
   int fstat(int fd, struct stat *);
@@ -105,7 +105,7 @@ struct SocketManager
   int dup(int s);
 
   // result is the fd or -errno
-  int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+  int accept(int s, sockaddr_storage* addr, socklen_t *addrlen);
 
   // manipulate socket buffers
   int get_sndbuf_size(int s);
@@ -113,13 +113,13 @@ struct SocketManager
   int set_sndbuf_size(int s, int size);
   int set_rcvbuf_size(int s, int size);
 
-  int getsockname(int s, struct sockaddr *, socklen_t *);
+  int getsockname(int s, sockaddr_storage *, socklen_t *);
 
   /** Close the socket.
       @return 0 if successful, -errno on error.
    */
   int close(int sock);
-  int ink_bind(int s, struct sockaddr *name, int namelen, short protocol = 0);
+  int ink_bind(int s, sockaddr_storage const* name, int namelen, short protocol = 0);
 
   int pagesize;
 

Modified: trafficserver/traffic/branches/ssc/iocore/eventsystem/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/eventsystem/Makefile.am?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/eventsystem/Makefile.am (original)
+++ trafficserver/traffic/branches/ssc/iocore/eventsystem/Makefile.am Tue May 24 04:11:36 2011
@@ -17,7 +17,7 @@
 #  limitations under the License.
 
 AM_CPPFLAGS = \
-  -I$(top_srcdir)/lib/records
+  -I$(top_srcdir)/lib
 
 DEFS += @IOCORE_MODULARIZED_DEFS@
 

Modified: trafficserver/traffic/branches/ssc/iocore/eventsystem/P_UnixSocketManager.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/eventsystem/P_UnixSocketManager.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/eventsystem/P_UnixSocketManager.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/eventsystem/P_UnixSocketManager.h Tue May 24 04:11:36 2011
@@ -60,11 +60,11 @@ transient_error()
 // Timing done in the connectionManager
 //
 TS_INLINE int
-SocketManager::accept(int s, struct sockaddr *addr, socklen_t *addrlen)
+SocketManager::accept(int s, sockaddr_storage* addr, socklen_t *addrlen)
 {
   int r;
   do {
-    r =::accept(s, addr, addrlen);
+    r =::accept(s, ink_inet_sa_cast(addr), addrlen);
     if (likely(r >= 0))
       break;
     r = -errno;
@@ -187,11 +187,11 @@ SocketManager::recv(int fd, void *buf, i
 }
 
 TS_INLINE int
-SocketManager::recvfrom(int fd, void *buf, int size, int flags, struct sockaddr *addr, socklen_t *addrlen)
+SocketManager::recvfrom(int fd, void *buf, int size, int flags, sockaddr_storage *addr, socklen_t *addrlen)
 {
   int r;
   do {
-    r =::recvfrom(fd, (char *) buf, size, flags, addr, addrlen);
+    r =::recvfrom(fd, (char *) buf, size, flags, ink_inet_sa_cast(addr), addrlen);
     if (unlikely(r < 0))
       r = -errno;
   } while (r == -EINTR);
@@ -254,11 +254,11 @@ SocketManager::send(int fd, void *buf, i
 }
 
 TS_INLINE int
-SocketManager::sendto(int fd, void *buf, int len, int flags, struct sockaddr *to, int tolen)
+SocketManager::sendto(int fd, void *buf, int len, int flags, sockaddr_storage *to, int tolen)
 {
   int r;
   do {
-    if (unlikely((r =::sendto(fd, (char *) buf, len, flags, to, tolen)) < 0))
+    if (unlikely((r =::sendto(fd, (char *) buf, len, flags, ink_inet_sa_cast(to), tolen)) < 0))
       r = -errno;
   } while (r == -EINTR);
   return r;
@@ -502,9 +502,9 @@ SocketManager::set_rcvbuf_size(int s, in
 }
 
 TS_INLINE int
-SocketManager::getsockname(int s, struct sockaddr *sa, socklen_t *sz)
+SocketManager::getsockname(int s, sockaddr_storage *sa, socklen_t *sz)
 {
-  return::getsockname(s, sa, sz);
+  return::getsockname(s, ink_inet_sa_cast(sa), sz);
 }
 
 TS_INLINE int

Modified: trafficserver/traffic/branches/ssc/iocore/eventsystem/SocketManager.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/eventsystem/SocketManager.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/eventsystem/SocketManager.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/eventsystem/SocketManager.cc Tue May 24 04:11:36 2011
@@ -112,7 +112,7 @@ safe_mlock(caddr_t addr, size_t len, cad
 }
 
 int
-SocketManager::ink_bind(int s, struct sockaddr *name, int namelen, short Proto)
+SocketManager::ink_bind(int s, sockaddr_storage const* name, int namelen, short Proto)
 {
   (void) Proto;
   return safe_bind(s, name, namelen);

Modified: trafficserver/traffic/branches/ssc/iocore/hostdb/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/hostdb/Makefile.am?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/hostdb/Makefile.am (original)
+++ trafficserver/traffic/branches/ssc/iocore/hostdb/Makefile.am Tue May 24 04:11:36 2011
@@ -19,11 +19,11 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records
+  -I$(top_srcdir)/lib
 else
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib/records \
+  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/proxy/hdrs \
   -I$(top_srcdir)/proxy/http \

Modified: trafficserver/traffic/branches/ssc/iocore/hostdb/include/Machine.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/hostdb/include/Machine.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/hostdb/include/Machine.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/hostdb/include/Machine.h Tue May 24 04:11:36 2011
@@ -88,19 +88,31 @@ struct Machine:Server
 
 struct MachineListElement
 {
-  unsigned int ip;
-  int port;
+  sockaddr_storage ip;
+//  unsigned int ip;
+//  int port;
 };
 struct MachineList
 {
   int n;
   MachineListElement machine[1];
+/*
   MachineListElement *find(unsigned int ip, int port = 0) {
     for (int i = 0; i < n; i++)
       if (machine[i].ip == ip && (!port || machine[i].port == port))
         return &machine[i];
     return NULL;
   }
+*/
+  MachineListElement* findByAddr(sockaddr_storage const* addr) {
+    MachineListElement* elt = machine;
+    MachineListElement* limit = machine + n;
+    for ( ; elt < limit ; ++elt) {
+      if (0 == ink_inet_cmp(addr, &elt->ip))
+        return elt;
+    }
+    return 0;
+  }
 };
 
 MachineList *read_MachineList(char *filename, int test_fd = -1);

Modified: trafficserver/traffic/branches/ssc/iocore/net/Connection.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/net/Connection.cc?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/net/Connection.cc (original)
+++ trafficserver/traffic/branches/ssc/iocore/net/Connection.cc Tue May 24 04:11:36 2011
@@ -69,7 +69,7 @@ Connection::Connection()
   , is_bound(false)
   , is_connected(false)
 {
-  memset(&sa, 0, sizeof(struct sockaddr_storage));
+  ink_inet_invalidate(addr);
 }
 
 
@@ -83,9 +83,9 @@ int
 Server::accept(Connection * c)
 {
   int res = 0;
-  socklen_t sz = sizeof(c->sa);
+  socklen_t sz = sizeof(c->addr);
 
-  res = socketManager.accept(fd, (struct sockaddr *)&c->sa, &sz);
+  res = socketManager.accept(fd, &c->addr, &sz);
   if (res < 0)
     return res;
   c->fd = res;
@@ -208,8 +208,8 @@ Server::setup_fd_for_listen(bool non_blo
     if ((res = safe_nonblocking(fd)) < 0)
       goto Lerror;
   {
-    int namelen = sizeof(sa);
-    if ((res = safe_getsockname(fd, (struct sockaddr *) &sa, &namelen)))
+    int namelen = sizeof(addr);
+    if ((res = safe_getsockname(fd, &addr, &namelen)))
       goto Lerror;
   }
   return 0;
@@ -223,38 +223,16 @@ Lerror:
 
 
 int
-Server::listen(int port_number, int domain, bool non_blocking, int recv_bufsize, int send_bufsize)
+Server::listen(bool non_blocking, int recv_bufsize, int send_bufsize)
 {
   ink_assert(fd == NO_FD);
   int res = 0;
-  int gai_errno = 0;
+  int namelen;
 
-  char port[6] = {'\0'};
-  struct addrinfo hints;
-  struct addrinfo *ai_res = NULL;
-  struct addrinfo *ai = NULL;
-  socklen_t addrlen = 0;  // keep track of length of socket address info
-  snprintf(port, sizeof(port), "%d", port_number);
-
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = domain;
-  hints.ai_socktype = SOCK_STREAM;
-  hints.ai_flags = AI_PASSIVE|AI_NUMERICHOST|AI_ADDRCONFIG;
-  gai_errno = getaddrinfo(accept_ip_str, port, &hints, &ai_res);
-  if(0 != gai_errno) {
-    Error("getaddrinfo error %i: %s", gai_errno, gai_strerror(gai_errno));
-    return -1;
-  }
-
-  ai = ai_res;
-
-  res = socketManager.socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
-
-  memset(&sa, 0, sizeof(sa));
-  addrlen = ai->ai_addrlen;  // save value for later since ai will be freed asap
-  memcpy(&sa, ai->ai_addr, ai->ai_addrlen);
+  if (!ink_inet_is_ip(accept_addr))
+    ink_inet_ip4_set(&accept_addr, INADDR_ANY,0);
 
-  freeaddrinfo(ai_res);
+  res = socketManager.socket(accept_addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
 
   if (res < 0)
     return res;
@@ -316,13 +294,13 @@ Server::listen(int port_number, int doma
   }
 #endif
 
-  if (domain == AF_INET6 && (res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, ON, sizeof(int))) < 0)
+  if (ink_inet_is_ip6(accept_addr) && (res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, ON, sizeof(int))) < 0)
     goto Lerror;
 
   if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, ON, sizeof(int))) < 0)
     goto Lerror;
 
-  if ((res = socketManager.ink_bind(fd, (struct sockaddr *) &sa, addrlen, IPPROTO_TCP)) < 0) {
+  if ((res = socketManager.ink_bind(fd, &addr, sizeof(addr), IPPROTO_TCP)) < 0) {
     goto Lerror;
   }
 #ifdef SET_TCP_NO_DELAY
@@ -346,16 +324,15 @@ Server::listen(int port_number, int doma
   if (non_blocking)
     if ((res = safe_nonblocking(fd)) < 0)
       goto Lerror;
-  if (!port_number) {
-    int namelen = sizeof(sa);
-    if ((res = safe_getsockname(fd, (struct sockaddr *) &sa, &namelen)))
-      goto Lerror;
-  }
+  // Original just did this on port == 0.
+  namelen = sizeof(addr);
+  if ((res = safe_getsockname(fd, &addr, &namelen)))
+    goto Lerror;
   return 0;
 
 Lerror:
   if (fd != NO_FD)
     close();
-  Error("Could not bind or listen to port %d (error: %d)", port_number, res);
+  Error("Could not bind or listen to port %d (error: %d)", ink_inet_get_port(accept_addr), res);
   return res;
 }

Modified: trafficserver/traffic/branches/ssc/iocore/net/I_NetProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/net/I_NetProcessor.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/net/I_NetProcessor.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/net/I_NetProcessor.h Tue May 24 04:11:36 2011
@@ -46,12 +46,11 @@ public:
   struct AcceptOptions {
     typedef AcceptOptions self; ///< Self reference type.
 
-    /// Port on which to listen.
-    /// 0 => don't care, which is useful if the socket is already bound.
-    int port;
     /// Should we use accept threads? If so, how many?
     int accept_threads;
     /// Communication domain (default: AF_INET)
+    /// @note Ignored if an explicit incoming address is set in the
+    /// the configuration (@c incoming_ip_to_bind).
     int domain;
     /// Event type to generate on accept.
     EventType etype;
@@ -60,6 +59,13 @@ public:
 	or @c NET_EVENT_ACCEPT_FAILED on success and failure resp.
     */
     bool f_callback_on_open;
+    /** Accept only on the loopback address.
+        Default: @c false.
+     */
+    bool localhost_only;
+    /// Are frequent accepts expected?
+    /// Default: @c false.
+    bool frequent_accept;
 
     /// Socket receive buffer size.
     /// 0 => OS default.
@@ -115,7 +121,6 @@ public:
     @param callback_on_open if true, cont is called back with
       NET_EVENT_ACCEPT_SUCCEED, or NET_EVENT_ACCEPT_FAILED on success
       and failure resp.
-    @param listen_socket_in if passed, used for listening.
     @param accept_pool_size NT specific, better left unspecified.
     @param accept_only can be used to customize accept, accept a
       connection only if there is some data to be read. This works
@@ -132,17 +137,27 @@ public:
       port becomes free immediately.
 
   */
-  inkcoreapi virtual Action * accept(Continuation * cont, int port, int domain = AF_INET, int accept_threads = -1,
-                                     bool frequent_accept = false,
-                                     // not used
-                                     unsigned int accept_ip = INADDR_ANY, char *accept_ip_str = NULL, bool callback_on_open = false,
-                                     SOCKET listen_socket_in = NO_FD,   // NT only
-                                     int accept_pool_size = ACCEPTEX_POOL_SIZE, // NT only
-                                     bool accept_only = false,
-                                     sockaddr * bound_sockaddr = 0,
-                                     int *bound_sockaddr_size = 0,
-                                     int recv_bufsize = 0,
-                                     int send_bufsize = 0, uint32_t sockopt_flag = 0, EventType etype = ET_NET);
+  inkcoreapi virtual Action * accept(
+    Continuation * cont,
+    sockaddr_storage const* addr,
+//    int port,
+    AcceptOptions const& opt = DEFAULT_ACCEPT_OPTIONS
+//    int domain = AF_INET,
+//    int accept_threads = -1,
+//    bool frequent_accept = false,
+    // not used
+//    unsigned int accept_ip = INADDR_ANY,
+//    char *accept_ip_str = NULL,
+//    bool callback_on_open = false,
+//    int accept_pool_size = ACCEPTEX_POOL_SIZE, // NT only
+//    bool accept_only = false,
+//    sockaddr * bound_sockaddr = 0,
+//    int *bound_sockaddr_size = 0,
+//    int recv_bufsize = 0,
+//    int send_bufsize = 0,
+//    uint32_t sockopt_flag = 0,
+//    EventType etype = ET_NET
+  );
 
   /**
     Accepts incoming connections on port. Accept connections on port.
@@ -182,9 +197,16 @@ public:
       port becomes free immediately.
 
   */
-  virtual Action *main_accept(Continuation * cont, SOCKET listen_socket_in, sockaddr * bound_sockaddr = NULL,
-                              int *bound_sockaddr_size = NULL, bool accept_only = false, bool localhost_only = false,
-                              AcceptOptions const& opt = DEFAULT_ACCEPT_OPTIONS);
+  virtual Action *main_accept(
+    Continuation * cont,
+    SOCKET listen_socket_in,
+    uint16_t port,
+//    sockaddr * bound_sockaddr = NULL,
+//    int *bound_sockaddr_size = NULL,
+//    bool accept_only = false,
+//    bool localhost_only = false,
+    AcceptOptions const& opt = DEFAULT_ACCEPT_OPTIONS
+  );
 
   /**
     Open a NetVConnection for connection oriented I/O. Connects
@@ -208,8 +230,11 @@ public:
 
   */
 
-  inkcoreapi Action *connect_re(Continuation * cont,
-                                unsigned int ip, int port, NetVCOptions * options = NULL);
+  inkcoreapi Action *connect_re(
+    Continuation * cont,
+    sockaddr_storage const* addr,
+    NetVCOptions * options = NULL
+  );
 
   /**
     Open a NetVConnection for connection oriented I/O. This call
@@ -221,8 +246,7 @@ public:
     asynchronous type connect is desired use connect_re().
 
     @param cont Continuation to be called back with events.
-    @param ip machine to connect to.
-    @param port port to connect to.
+    @param addr Address to which to connect (includes port).
     @param timeout for connect, the cont will get NET_EVENT_OPEN_FAILED
       if connection could not be established for timeout msecs. The
       default is 30 secs.
@@ -231,10 +255,12 @@ public:
     @see connect_re()
 
   */
-  Action *connect_s(Continuation * cont,
-                    unsigned int ip,
-                    int port,
-                    int timeout = NET_CONNECT_TIMEOUT, NetVCOptions * opts = NULL);
+  Action *connect_s(
+    Continuation * cont,
+    sockaddr_storage const* addr,
+    int timeout = NET_CONNECT_TIMEOUT,
+    NetVCOptions * opts = NULL
+  );
 
   /**
     Starts the Netprocessor. This has to be called before doing any

Modified: trafficserver/traffic/branches/ssc/iocore/net/I_NetVConnection.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/net/I_NetVConnection.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/net/I_NetVConnection.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/net/I_NetVConnection.h Tue May 24 04:11:36 2011
@@ -48,10 +48,18 @@ enum NetDataType
     This class holds various options a user can specify for
     NetVConnection. Various clients need many slightly different
     features. This is an attempt to prevent out of control growth of
-    the connection method signatures.
+    the connection method signatures. Only options of interest need to
+    be explicitly set -- the rest get sensible default values.
 
-    Only options of interest need to be explicitly set --
-    the rest get sensible default values.
+    @note Binding addresses is a bit complex. It is not currently
+    possible to bind indiscriminately across protocols, which means
+    any connection must commit to IPv4 or IPv6. For this reason the
+    connection logic will look at the address family of @a local_addr
+    even if @a addr_binding is @c ANY_ADDR and bind to any address in
+    that protocol. If it's not an IP protocol, IPv4 will be used.
+
+    @note Port values are encoded in the address. Use a port value
+    of 0 to indicate "don't care".
 */
 struct NetVCOptions {
   typedef NetVCOptions self; ///< Self reference type.
@@ -67,6 +75,9 @@ struct NetVCOptions {
 
   /** The set of ways in which the local address should be bound.
 
+      The protocol is set by the contents of @a local_addr regardless
+      of this value. @c ANY_ADDR will override only the address.
+
       @note The difference between @c INTF_ADDR and @c FOREIGN_ADDR is
       whether transparency is enabled on the socket. It is the
       client's responsibility to set this correctly based on whether the
@@ -83,23 +94,10 @@ struct NetVCOptions {
     FOREIGN_ADDR ///< Bind to foreign address in @a local_addr.
   };
 
-  /// The set of ways in which the local port should be bound.
-  enum port_bind_style {
-    ANY_PORT, ///< Bind to any available local port (don't care, default).
-    FIXED_PORT ///< Bind to the port in @a local_port.
-  };
-
-  /// Port to use for local side of connection.
-  /// @note Ignored if @a port_binding is @c ANY_PORT.
-  /// @see port_binding
-  uint16_t local_port;
-  /// How to bind local port.
-  /// @note Default is @c ANY_PORT.
-  port_bind_style port_binding;
   /// Address to use for local side of connection.
   /// @note Ignored if @a addr_binding is @c ANY_ADDR.
   /// @see addr_binding
-  uint32_t local_addr;
+  sockaddr_storage local_addr;
   /// How to bind the local address.
   /// @note Default is @c ANY_ADDR.
   addr_bind_style addr_binding;
@@ -369,22 +367,22 @@ public:
   virtual ink_hrtime get_inactivity_timeout() = 0;
 
   /** Returns local sockaddr storage. */
-  const struct sockaddr_storage &get_local_addr();
+  sockaddr_storage const* get_local_addr();
 
   /** Returns local ip. */
-  unsigned int get_local_ip();
+//  unsigned int get_local_ip();
 
   /** Returns local port. */
-  int get_local_port();
+  uint16_t get_local_port();
 
   /** Returns remote sockaddr storage. */
-  const struct sockaddr_storage &get_remote_addr();
+  sockaddr_storage const* get_remote_addr();
 
   /** Returns remote ip. */
-  unsigned int get_remote_ip();
+//  unsigned int get_remote_ip();
 
   /** Returns remote port. */
-  int get_remote_port();
+  uint16_t get_remote_port();
 
   /** Structure holding user options. */
   NetVCOptions options;
@@ -458,11 +456,11 @@ private:
   NetVConnection & operator =(const NetVConnection &);
 
 protected:
-  struct sockaddr_storage local_addr;
-  struct sockaddr_storage remote_addr;
+  sockaddr_storage local_addr;
+  sockaddr_storage remote_addr;
 
-  int got_local_addr;
-  int got_remote_addr;
+  bool got_local_addr;
+  bool got_remote_addr;
 
   bool is_internal_request;
   /// Set if this connection is transparent.

Modified: trafficserver/traffic/branches/ssc/iocore/net/I_UDPConnection.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/net/I_UDPConnection.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/net/I_UDPConnection.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/net/I_UDPConnection.h Tue May 24 04:11:36 2011
@@ -50,8 +50,8 @@ public:
   };
 
   SOCKET getFd();
-  void setBinding(struct sockaddr_in *);
-  inkcoreapi int getBinding(struct sockaddr_in *);
+  void setBinding(sockaddr_storage *);
+  inkcoreapi int getBinding(sockaddr_storage *);
 
   void destroy();
   int shouldDestroy();

Modified: trafficserver/traffic/branches/ssc/iocore/net/I_UDPNet.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/net/I_UDPNet.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/net/I_UDPNet.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/net/I_UDPNet.h Tue May 24 04:11:36 2011
@@ -47,9 +47,13 @@ public:
 
   //this function was interanal intially.. this is required for public and
   //interface probably should change.
-  bool CreateUDPSocket(int *resfd, struct sockaddr_in *addr,
-                       Action ** status,
-                       int my_port, unsigned int my_ip = 0, int send_bufsize = 0, int recv_bufsize = 0);
+  bool CreateUDPSocket(
+    int *resfd,
+    sockaddr_storage const* remote_addr,
+    sockaddr_storage* local_addr,
+    Action ** status,
+    int send_bufsize = 0, int recv_bufsize = 0
+  );
 
   /**
      create UDPConnection
@@ -63,8 +67,7 @@ public:
 
      @param c Continuation that is called back with newly created
      socket.
-     @param my_port Local port to be bound (required)
-     @param my_ip Local IP to be bound (optional).  Defaults to '0' (INADDR_ANY)
+     @param addr Address to bind (includes port)
      @param send_bufsize (optional) Socket buffer size for sending.
      Limits how much outstanding data to OS before it is able to send
      to the NIC.
@@ -73,17 +76,20 @@ public:
      @return Action* Always returns ACTION_RESULT_DONE if socket was
      created successfuly, or ACTION_IO_ERROR if not.
   */
-  inkcoreapi Action *UDPBind(Continuation * c, int my_port, int my_ip = 0, int send_bufsize = 0, int recv_bufsize = 0);
+  inkcoreapi Action *UDPBind(Continuation * c, sockaddr_storage const* addr, int send_bufsize = 0, int recv_bufsize = 0);
 
   // The mess again: the complier won't let me stick UDPConnection here.
-  void UDPClassifyConnection(Continuation * udpConn, int destIP);
+  void UDPClassifyConnection(Continuation * udpConn, InkInetAddr const& addr);
 
   // create pairs of UDPConnections in which the first connection is
   // on a even-#'ed port and the second connection is on the next
   // odd-#'ed port.  Create "nPairs" of such connections.
   Action *UDPCreatePortPairs(Continuation *, int nPairs,
-                             unsigned int myIP = 0,
-                             unsigned int destIP = 0, int send_bufsize = 0, int recv_bufsize = 0);
+    sockaddr_storage const* local_addr,
+    sockaddr_storage const* remote_addr,
+//                             unsigned int myIP = 0,
+//                             unsigned int destIP = 0,
+    int send_bufsize = 0, int recv_bufsize = 0);
 
   // Regarding sendto_re, sendmsg_re, recvfrom_re:
   // * You may be called back on 'c' with completion or error status.
@@ -105,13 +111,13 @@ public:
   // * You can get other info about the completed operation through use
   //   of the completionUtil class.
   Action *sendto_re(Continuation * c, void *token, int fd,
-                    struct sockaddr *toaddr, int toaddrlen, IOBufferBlock * buf, int len);
+                    sockaddr_storage *toaddr, int toaddrlen, IOBufferBlock * buf, int len);
   // I/O buffers referenced by msg must be pinned by the caller until
   // continuation is called back.
   Action *sendmsg_re(Continuation * c, void *token, int fd, struct msghdr *msg);
 
   Action *recvfrom_re(Continuation * c, void *token, int fd,
-                      struct sockaddr *fromaddr, socklen_t *fromaddrlen,
+                      sockaddr_storage *fromaddr, socklen_t *fromaddrlen,
                       IOBufferBlock * buf, int len, bool useReadCont = true, int timeout = 0);
   // Continuation is really a UDPConnection; due to the include mess, we stick in the
   // base-class of UDPConnection.

Modified: trafficserver/traffic/branches/ssc/iocore/net/I_UDPPacket.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ssc/iocore/net/I_UDPPacket.h?rev=1126862&r1=1126861&r2=1126862&view=diff
==============================================================================
--- trafficserver/traffic/branches/ssc/iocore/net/I_UDPPacket.h (original)
+++ trafficserver/traffic/branches/ssc/iocore/net/I_UDPPacket.h Tue May 24 04:11:36 2011
@@ -65,8 +65,8 @@ public:
   inkcoreapi void append_block(IOBufferBlock * block);
   virtual void UDPPacket_is_abstract() = 0;
 
-  struct sockaddr_in from;    // what address came from
-  struct sockaddr_in to;      // what address to send to
+  sockaddr_storage from;    // what address came from
+  sockaddr_storage to;      // what address to send to
 
   int from_size;
 
@@ -83,7 +83,7 @@ public:
    @param buf if !NULL, then len bytes copied from buf and made into packet.
    @param len # of bytes to copy from buf
  */
-TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr_in *to, ink_hrtime when = 0, char *buf = NULL, int len = 0);
+TS_INLINE UDPPacket *new_UDPPacket(sockaddr_storage *to, ink_hrtime when = 0, char *buf = NULL, int len = 0);
 /**
    Create a new packet to be sent over UDPConnection. This clones and
    makes a reference to an existing IOBufferBlock chain.
@@ -95,7 +95,7 @@ TS_INLINE UDPPacket *new_UDPPacket(struc
    for packet
    @param len # of bytes to reference from block
  */
-TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr_in *to,
+TS_INLINE UDPPacket *new_UDPPacket(sockaddr_storage *to,
                                     ink_hrtime when = 0, IOBufferBlock * block = NULL, int len = 0);
 /**
    Create a new packet to be sent over UDPConnection.  Packet has no
@@ -107,7 +107,7 @@ TS_INLINE UDPPacket *new_UDPPacket();
    Create a new packet to be delivered to application.
    Internal function only
 */
-TS_INLINE UDPPacket *new_incoming_UDPPacket(struct sockaddr_in *from, char *buf, int len);
+TS_INLINE UDPPacket *new_incoming_UDPPacket(sockaddr_storage *from, char *buf, int len);
 
 //@}
 #endif //__I_UDPPACKET_H_



Mime
View raw message