trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1236470 [2/3] - in /trafficserver/traffic/trunk: ./ iocore/cluster/ iocore/net/ lib/records/ lib/ts/ mgmt/ mgmt/cli/ mgmt/utils/ proxy/ proxy/config/ proxy/http/ proxy/logging/
Date Fri, 27 Jan 2012 00:33:33 GMT
Modified: trafficserver/traffic/trunk/lib/ts/ink_inet.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_inet.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_inet.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_inet.h Fri Jan 27 00:33:31 2012
@@ -25,8 +25,12 @@
 #if !defined (_ink_inet_h_)
 #define _ink_inet_h_
 
+#include <netinet/in.h>
+#include <netdb.h>
+#include <ink_memory.h>
 #include <sys/socket.h>
 #include <ts/ink_apidefs.h>
+#include <ts/TsBuffer.h>
 
 #define INK_GETHOSTBYNAME_R_DATA_SIZE 1024
 #define INK_GETHOSTBYADDR_R_DATA_SIZE 1024
@@ -64,8 +68,28 @@ union ts_ip_endpoint {
     uint16_t port = 0 ///< Port (network order).
   );
 
-  /// Access to port.
+  /// Access to port in network order.
   uint16_t& port();
+
+  /// Test if a valid IP address.
+  bool isValid() const;
+  /// Test for IPv4.
+  bool isIp4() const;
+  /// Test for IPv6.
+  bool isIp6() const;
+
+  /// Set to be any address for family @a family.
+  /// @a family must be @c AF_INET or @c AF_INET6.
+  /// @return This object.
+  self& setToAnyAddr(
+    int family ///< Address family.
+  );
+  /// Set to be loopback for family @a family.
+  /// @a family must be @c AF_INET or @c AF_INET6.
+  /// @return This object.
+  self& setToLoopback(
+    int family ///< Address family.
+  );
 };
 
 struct ink_gethostbyname_r_data
@@ -143,6 +167,12 @@ inline void ink_inet_invalidate(ts_ip_en
   ip->sa.sa_family = AF_UNSPEC;
 }
 
+/** Get a string name for an IP address family.
+    @return The string name (never @c NULL).
+*/
+char const*
+ink_inet_family_name(int family);
+
 /// Test for IP protocol.
 /// @return @c true if the address is IP, @c false otherwise.
 inline bool ink_inet_is_ip(sockaddr const* addr) {
@@ -154,6 +184,11 @@ inline bool ink_inet_is_ip(ts_ip_endpoin
   return addr
     && (AF_INET == addr->sa.sa_family || AF_INET6 == addr->sa.sa_family);
 }
+/// Test for IP protocol.
+/// @return @c true if the value is an IP address family, @c false otherwise.
+inline bool ink_inet_is_ip(int family) {
+  return AF_INET == family || AF_INET6 == family;
+}
 /// Test for IPv4 protocol.
 /// @return @c true if the address is IPv4, @c false otherwise.
 inline bool ink_inet_is_ip4(sockaddr const* addr) {
@@ -184,6 +219,27 @@ inline bool ink_inet_are_compatible(
 ) {
   return lhs->sa_family == rhs->sa_family;
 }
+/// @return @c true if the address families are compatible.
+inline bool ink_inet_are_compatible(
+  ts_ip_endpoint const* lhs, ///< Address to test.
+  ts_ip_endpoint const* rhs  ///< Address to test.
+) {
+  return ink_inet_are_compatible(&lhs->sa, &rhs->sa);
+}
+/// @return @c true if the address families are compatible.
+inline bool ink_inet_are_compatible(
+  int lhs, ///< Address family to test.
+  sockaddr const* rhs  ///< Address to test.
+) {
+  return lhs == rhs->sa_family;
+}
+/// @return @c true if the address families are compatible.
+inline bool ink_inet_are_compatible(
+  sockaddr const* lhs, ///< Address to test.
+  int rhs  ///< Family to test.
+) {
+  return lhs->sa_family == rhs;
+}
 
 // IP address casting.
 // sa_cast to cast to sockaddr*.
@@ -443,20 +499,25 @@ inline uint8_t const* ink_inet_addr8_cas
   return ink_inet_addr8_cast(&ip->sa);
 }
 
+/// Check for loopback.
 /// @return @c true if this is an IP loopback address, @c false otherwise.
 inline bool ink_inet_is_loopback(sockaddr const* ip) {
   return ip
     && (
-      (AF_INET == ip->sa_family && htonl(INADDR_LOOPBACK) == ink_inet_ip4_addr_cast(ip))
+      (AF_INET == ip->sa_family && 0x7F == ink_inet_addr8_cast(ip)[0])
       ||
       (AF_INET6 == ip->sa_family && IN6_IS_ADDR_LOOPBACK(&ink_inet_ip6_addr_cast(ip)))
     );
 }
 
+/// Check for loopback.
+/// @return @c true if this is an IP loopback address, @c false otherwise.
 inline bool ink_inet_is_loopback(ts_ip_endpoint const* ip) {
   return ink_inet_is_loopback(&ip->sa);
 }
 
+/// Check for multicast.
+/// @return @true if @a ip is multicast.
 inline bool ink_inet_is_multicast(sockaddr const* ip) {
   return ip
     && (
@@ -465,10 +526,14 @@ inline bool ink_inet_is_multicast(sockad
       (AF_INET6 == ip->sa_family && IN6_IS_ADDR_MULTICAST(&ink_inet_ip6_addr_cast(ip)))
     );
 }
+/// Check for multicast.
+/// @return @true if @a ip is multicast.
 inline bool ink_inet_is_multicast(ts_ip_endpoint const* ip) {
   return ink_inet_is_multicast(&ip->sa);
 }
 
+/// Check for non-routable address.
+/// @return @c true if @a ip is a non-routable.
 inline bool ink_inet_is_nonroutable(sockaddr const* ip) {
   bool zret = false;
   if (ink_inet_is_ip4(ip)) {
@@ -481,9 +546,19 @@ inline bool ink_inet_is_nonroutable(sock
   return zret;
 }
 
+/// Check for non-routable address.
+/// @return @c true if @a ip is a non-routable.
 inline bool ink_inet_is_nonroutable(ts_ip_endpoint const* ip) {
   return ink_inet_is_nonroutable(&ip->sa);
 }
+
+/// Check for being "any" address.
+/// @return @c true if @a ip is the any / unspecified address.
+inline bool ink_inet_is_any(sockaddr const* ip) {
+  return (ink_inet_is_ip4(ip) && INADDR_ANY == ink_inet_ip4_cast(ip)) ||
+    (ink_inet_is_ip6(ip) && IN6_IS_ADDR_UNSPECIFIED(ink_inet_ip6_cast(ip)))
+    ;
+}
   
 /// @name Address operators
 //@{
@@ -663,7 +738,7 @@ inline sockaddr* ink_inet_ip4_set(
   in_addr_t addr, ///< address, IPv4 network order.
   uint16_t port = 0 ///< port, network order.
 ) {
-  memset(dst, 0, sizeof(*dst));
+  ink_zero(*dst);
 #if HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
   dst->sin_len = sizeof(sockaddr_in);
 #endif
@@ -704,7 +779,7 @@ inline sockaddr* ink_inet_ip6_set(
   in6_addr const& addr, ///< address in network order.
   uint16_t port = 0 ///< Port, network order.
 ) {
-  memset(dst, 0, sizeof(*dst));
+  ink_zero(*dst);
 #if HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
   dst->sin6_len = sizeof(sockaddr_in6);
 #endif
@@ -822,6 +897,38 @@ inline int ink_inet_pton(
   return ink_inet_pton(text, &addr->sa);
 }
 
+/** Get the best address info for @a name.
+
+    @name is passed to @c getaddrinfo which does a host lookup if @a
+    name is not in IP address format. The results are examined for the
+    "best" addresses. This is only significant for the host name case
+    (for IP address data, there is at most one result). The preference is
+    Global > Non-Routable > Multicast > Loopback.
+
+    IPv4 and IPv4 results are handled independently and stored in @a
+    ip4 and @a ip6 respectively. If @a name is known to be a numeric
+    IP address @c ink_inet_pton is a better choice. Use this function
+    if the type of @a name is not known. If you want to look at the
+    addresses and not just get the "best", use @c getaddrinfo
+    directly.
+
+    @a ip4 or @a ip6 can be @c NULL and the result for that family is
+    discarded. It is legal for both to be @c NULL in which case this
+    is just a format check.
+
+    @return 0 if an address was found, non-zero otherwise.
+
+    @see ink_inet_pton
+    @see getaddrinfo
+ */
+
+int
+ink_inet_getbestaddrinfo(
+  char const* name, ///< [in] Address name (IPv4, IPv6, or host name)
+  ts_ip_endpoint* ip4, ///< [out] Storage for IPv4 address.
+  ts_ip_endpoint* ip6 ///< [out] Storage for IPv6 address
+);
+
 /** Generic IP address hash function.
 */    
 uint32_t ink_inet_hash(sockaddr const* addr);
@@ -871,7 +978,7 @@ struct InkInetAddr {
   /// Construct from @c ts_ip_endpoint.
   explicit InkInetAddr(ts_ip_endpoint const* addr) { this->assign(&addr->sa); }
 
-  /// Assign sockaddr storage.
+  /// Assign from sockaddr storage.
   self& assign(sockaddr const* addr) {
     _family = addr->sa_family;
     if (ink_inet_is_ip4(addr)) {
@@ -887,6 +994,10 @@ struct InkInetAddr {
   self& operator = (ts_ip_endpoint const& ip) {
     return this->assign(&ip.sa);
   }
+  /// Assign from IPv4 raw address.
+  self& operator = (
+    in_addr_t ip ///< Network order IPv4 address.
+  );
 
   /** Load from string.
       The address is copied to this object if the conversion is successful,
@@ -921,11 +1032,24 @@ struct InkInetAddr {
     return ! (*this == that);
   }
 
+  /// Test for same address family.
+  /// @c return @c true if @a that is the same address family as @a this.
+  bool isCompatibleWith(self const& that);
+
+  /// Get the address family.
+  /// @return The address family.
+  uint16_t family() const;
+  /// Test for IPv4.
+  bool isIp4() const;
+  /// Test for IPv6.
+  bool isIp6() const;
+
   /// Test for validity.
   bool isValid() const { return _family == AF_INET || _family == AF_INET6; }
   /// Make invalid.
   self& invalidate() { _family = AF_UNSPEC; return *this; }
-  /// Test for multicast
+  /// Test for multicast.
+  /// @return @c true if this is an IP multicast address.
   bool isMulticast() const;
 
   uint16_t _family; ///< Protocol family.
@@ -937,6 +1061,23 @@ struct InkInetAddr {
   } _addr;
 };
 
+inline InkInetAddr&
+InkInetAddr::operator = (in_addr_t ip) {
+  _family = AF_INET;
+  _addr._ip4 = ip;
+  return *this;
+}
+
+inline uint16_t InkInetAddr::family() const { return _family; }
+
+inline bool
+InkInetAddr::isCompatibleWith(self const& that) {
+  return this->isValid() && _family == that._family;
+}
+
+inline bool InkInetAddr::isIp4() const { return AF_INET == _family; }
+inline bool InkInetAddr::isIp6() const { return AF_INET6 == _family; }
+
 // Associated operators.
 bool operator == (InkInetAddr const& lhs, sockaddr const* rhs);
 inline bool operator == (sockaddr const* lhs, InkInetAddr const& rhs) {
@@ -997,4 +1138,28 @@ ts_ip_endpoint::port() {
   return ink_inet_port_cast(&sa);
 }
 
+inline bool
+ts_ip_endpoint::isValid() const {
+  return ink_inet_is_ip(this);
+}
+
+inline bool ts_ip_endpoint::isIp4() const { return AF_INET == sa.sa_family; }
+inline bool ts_ip_endpoint::isIp6() const { return AF_INET6 == sa.sa_family; }
+
+inline ts_ip_endpoint&
+ts_ip_endpoint::setToAnyAddr(int family) {
+  sa.sa_family = family;
+  if (AF_INET == family) ink_inet_ip4_addr_cast(this) = INADDR_ANY;
+  else if (AF_INET6 == family) ink_inet_ip6_addr_cast(this) = in6addr_any;
+  return *this;
+}
+
+inline ts_ip_endpoint&
+ts_ip_endpoint::setToLoopback(int family) {
+  sa.sa_family = family;
+  if (AF_INET == family) ink_inet_ip4_addr_cast(this) = htonl(INADDR_LOOPBACK);
+  else if (AF_INET6 == family) ink_inet_ip6_addr_cast(this) = in6addr_loopback;
+  return *this;
+}
+
 #endif // _ink_inet.h

Modified: trafficserver/traffic/trunk/mgmt/LocalManager.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/LocalManager.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/LocalManager.cc (original)
+++ trafficserver/traffic/trunk/mgmt/LocalManager.cc Fri Jan 27 00:33:31 2012
@@ -35,8 +35,6 @@
 #include <sys/capability.h>
 #endif
 
-int bindProxyPort(int, char*, int, bool, int);
-
 bool
 LocalManager::SetForDup(void *hIOCPort, long lTProcId, void *hTh)
 {
@@ -229,79 +227,16 @@ LocalManager::LocalManager(char *mpath, 
 
   virt_map = NULL;
 
-
-  for (int i = 0; i < MAX_PROXY_SERVER_PORTS; i++) {
-    proxy_server_port[i] = proxy_server_fd[i] = -1;
-    memset((void *) proxy_server_port_attributes[i], 0, MAX_ATTR_LEN);
-  }
-
-  int pnum = 0;
   RecInt http_enabled = REC_readInteger("proxy.config.http.enabled", &found);
   ink_debug_assert(found);
   if (http_enabled && found) {
-    int port = (int) REC_readInteger("proxy.config.http.server_port", &found);
-    if (found) {
-      proxy_server_port[pnum] = port;
-      char *main_server_port_attributes = (char *) REC_readString("proxy.config.http.server_port_attr", &found);
-      ink_strlcpy((char *) proxy_server_port_attributes[pnum],
-                  main_server_port_attributes, sizeof(proxy_server_port_attributes[pnum]));
-      ats_free(main_server_port_attributes);
-      pnum++;
-    }
+    HttpProxyPort::loadConfig(m_proxy_ports);
   }
+  HttpProxyPort::loadDefaultIfEmpty(m_proxy_ports);
 
-  // Check to see if we are running SSL term
-  RecInt ssl_term_enabled = REC_readInteger("proxy.config.ssl.enabled", &found);
-  ink_assert(found);
-  if (found && ssl_term_enabled) {
-    // Get the SSL port
-    RecInt ssl_term_port = REC_readInteger("proxy.config.ssl.server_port", &found);
-    ink_assert(found);
-    if (found) {
-      proxy_server_port[pnum] = ssl_term_port;
-      ink_strlcpy((char *) proxy_server_port_attributes[pnum], "S", sizeof(proxy_server_port_attributes[pnum]));
-      pnum++;
-    }
-  }
-
-  // Read other ports to be listened on
-  char *proxy_server_other_ports = REC_readString("proxy.config.http.server_other_ports", &found);
-  if (proxy_server_other_ports) {
-    char *last, *cport;
-
-    cport = ink_strtok_r(proxy_server_other_ports, " ", &last);
-    for (; pnum < MAX_PROXY_SERVER_PORTS && cport; pnum++) {
-      const char *attr = "X";
-
-      for (int j = 0; cport[j]; j++) {
-        if (cport[j] == ':') {
-          cport[j] = '\0';
-          attr = &cport[j + 1];
-        }
-      }
-
-      int port_no = atoi(cport);
-
-      proxy_server_port[pnum] = port_no;
-      ink_strlcpy((char *) proxy_server_port_attributes[pnum], attr, sizeof(proxy_server_port_attributes[pnum]));
+  // Get the default IP binding values.
+  RecHttpLoadIp("proxy.local.incoming_ip_to_bind", m_inbound_ip4, m_inbound_ip6);
 
-      Debug("lm", "[LocalManager::LocalManager] Adding port (%s, %d, '%s')\n", cport, port_no, attr);
-      cport = ink_strtok_r(NULL, " ", &last);
-    }
-
-    if (pnum == MAX_PROXY_SERVER_PORTS && cport) {
-      Debug("lm", "[LocalManager::LocalManager] Unable to listen on all other ports,"
-            " max number of other ports exceeded(max == %d)\n", MAX_PROXY_SERVER_PORTS);
-    }
-    ats_free(proxy_server_other_ports);
-  }
-  // Bind proxy ports to incoming_ip_to_bind
-  char *incoming_ip_to_bind_str = REC_readString("proxy.local.incoming_ip_to_bind", &found);
-  if (found && incoming_ip_to_bind_str != NULL) {
-    proxy_server_incoming_ip_to_bind_str = incoming_ip_to_bind_str;
-  } else {
-    proxy_server_incoming_ip_to_bind_str = NULL;
-  }
   config_path = REC_readString("proxy.config.config_dir", &found);
   char *absolute_config_path = Layout::get()->relative(config_path);
   ats_free(config_path);
@@ -824,12 +759,7 @@ LocalManager::sendMgmtMsgToProcesses(Mgm
       if (lmgmt->virt_map) {
         lmgmt->virt_map->downAddrs();   /* Down all known addrs to be safe */
       }
-      for (int i = 0; i < MAX_PROXY_SERVER_PORTS; i++) {
-        if (proxy_server_fd[i] != -1) { // Close the socket
-          close_socket(proxy_server_fd[i]);
-          proxy_server_fd[i] = -1;
-        }
-      }
+      this->closeProxyPorts();
       break;
     }
   case MGMT_EVENT_RESTART:
@@ -1072,28 +1002,29 @@ LocalManager::startProxy()
   } else {
     int res, i = 0, n;
     char real_proxy_options[2048], *options[32], *last, *tok;
+    bool open_ports_p = false;
 
     snprintf(real_proxy_options, sizeof(real_proxy_options), "%s", proxy_options);
     n = strlen(real_proxy_options);
 
     // Check if we need to pass down port/fd information to
-    // traffic_server
-    if (proxy_server_fd[0] != -1) {
-      snprintf(&real_proxy_options[n], sizeof(real_proxy_options) - n, " -A");
+    // traffic_server by seeing if there are any open ports.
+    for ( int i = 0, limit = m_proxy_ports.length()
+            ; !open_ports_p && i < limit
+            ; ++i
+    )
+      if (ts::NO_FD != m_proxy_ports[i].m_fd) open_ports_p = true;
+
+    if (open_ports_p) {
+      bool need_comma_p = false;
+      snprintf(&real_proxy_options[n], sizeof(real_proxy_options) - n, " --httpport ");
       n = strlen(real_proxy_options);
-      // Handle some syntax issues
-      if (proxy_server_fd[0] != -1) {
-        snprintf(&real_proxy_options[n], sizeof(real_proxy_options) - n, ",");
-        n = strlen(real_proxy_options);
-      }
-      // Fill in the rest of the fd's
-      if (proxy_server_fd[0] != -1) {
-        snprintf(&real_proxy_options[n], sizeof(real_proxy_options) - n,
-                 "%d:%s", proxy_server_fd[0], (char*)proxy_server_port_attributes[0]);
-        n = strlen(real_proxy_options);
-        for (i = 1; i<MAX_PROXY_SERVER_PORTS && proxy_server_fd[i]> 0; i++) {
-          snprintf(&real_proxy_options[n], sizeof(real_proxy_options) - n,
-                   ",%d:%s", proxy_server_fd[i], (char*)proxy_server_port_attributes[i]);
+      for ( int i = 0, limit = m_proxy_ports.length() ; i < limit ; ++i ) {
+        HttpProxyPort& p = m_proxy_ports[i];
+        if (ts::NO_FD != p.m_fd) {
+          if (need_comma_p) real_proxy_options[n++] = ',';
+          need_comma_p = true;
+          p.print(real_proxy_options+n, sizeof(real_proxy_options)-n);
           n = strlen(real_proxy_options);
         }
       }
@@ -1102,13 +1033,13 @@ LocalManager::startProxy()
     Debug("lm", "[LocalManager::startProxy] Launching %s with options '%s'\n",
           absolute_proxy_binary, real_proxy_options);
 
-    for (i = 0; i < 32; i++)
-      options[i] = NULL;
+    ink_zero(options);
     options[0] = absolute_proxy_binary;
     i = 1;
     tok = ink_strtok_r(real_proxy_options, " ", &last);
     options[i++] = tok;
     while (i < 32 && (tok = ink_strtok_r(NULL, " ", &last))) {
+      Debug("lm", "opt %d = '%s'\n", i, tok);
       options[i++] = tok;
     }
 
@@ -1123,7 +1054,18 @@ LocalManager::startProxy()
   return true;
 }
 
-
+/** Close all open ports.
+ */
+void
+LocalManager::closeProxyPorts() {
+  for ( int i = 0, n = lmgmt->m_proxy_ports.length() ; i < n ; ++i ) {
+    HttpProxyPort& p = lmgmt->m_proxy_ports[i];
+    if (ts::NO_FD != p.m_fd) {
+      close_socket(p.m_fd);
+      p.m_fd = ts::NO_FD;
+    }
+  }
+}
 /*
  * listenForProxy()
  *  Function listens on the accept port of the proxy, so users aren't dropped.
@@ -1135,46 +1077,15 @@ LocalManager::listenForProxy()
     return;
 
   // We are not already bound, bind the port
-  for (int i = 0; i < MAX_PROXY_SERVER_PORTS; i++) {
-    if (proxy_server_port[i] != -1) {
-      if (proxy_server_fd[i] < 0) {
-        int domain = AF_INET;
-        int type = SOCK_STREAM;
-        bool transparent = false;
-
-        switch (*proxy_server_port_attributes[i]) {
-        case 'D':
-          // D is for DNS proxy, udp only
-          type = SOCK_DGRAM;
-          break;
-        case '>': // in-bound (client side) transparent
-        case '=': // fully transparent
-          transparent = true;
-          break;
-        default:
-          type = SOCK_STREAM;
-        }
-
-        switch (*(proxy_server_port_attributes[i] + 1)) {
-        case '6':
-          domain = AF_INET6;
-          break;
-        default:
-          domain = AF_INET;
-        }
-
-        proxy_server_fd[i] = bindProxyPort(proxy_server_port[i], proxy_server_incoming_ip_to_bind_str, domain, transparent, type);
-      }
-
-      if (*proxy_server_port_attributes[i] != 'D') {
-        if ((listen(proxy_server_fd[i], 1024)) < 0) {
-          mgmt_fatal(stderr, "[LocalManager::listenForProxy] Unable to listen on socket: %d\n", proxy_server_port[i]);
-        }
-        mgmt_log(stderr, "[LocalManager::listenForProxy] Listening on port: %d\n", proxy_server_port[i]);
-      } else {
-        break;
-      }
+  for ( int i = 0, n = lmgmt->m_proxy_ports.length() ; i < n ; ++i ) {
+    HttpProxyPort& p = lmgmt->m_proxy_ports[i];
+    if (ts::NO_FD == p.m_fd) {
+      this->bindProxyPort(p);
     }
+    if ((listen(p.m_fd, 1024)) < 0) {
+      mgmt_fatal(stderr, "[LocalManager::listenForProxy] Unable to listen on socket: %d\n", p.m_port);
+    }
+    mgmt_log(stderr, "[LocalManager::listenForProxy] Listening on port: %d\n", p.m_port);
   }
   return;
 }
@@ -1249,27 +1160,21 @@ restoreRootPriv(uid_t *old_euid)
 /*
  * bindProxyPort()
  *  Function binds the accept port of the proxy
- *  Also, type specifies udp or tcp
  */
-int
-bindProxyPort(int proxy_port, char *incoming_ip_to_bind_str, int domain, bool transparent, int type)
+void
+LocalManager::bindProxyPort(HttpProxyPort& port)
 {
   int one = 1;
-  int proxy_port_fd = -1;
-  struct addrinfo hints;
-  struct addrinfo *result = NULL;
-  char proxy_port_str[8] = {'\0'};
-  int err = 0;
 
 #if !TS_USE_POSIX_CAP
   bool privBoost = false;
   uid_t euid = geteuid();
   uid_t saved_euid = 0;
 
-  if (proxy_port < 1024 && euid != 0) {
+  if (port.m_port < 1024 && euid != 0) {
     if (restoreRootPriv(&saved_euid) == false) {
       mgmt_elog(stderr, "[bindProxyPort] Unable to get root priviledges to bind port %d. euid is %d.  Exiting\n",
-                proxy_port, euid);
+                port.m_port, euid);
       _exit(0);
     } else {
       privBoost = true;
@@ -1278,25 +1183,24 @@ bindProxyPort(int proxy_port, char *inco
 #endif
 
   /* Setup reliable connection, for large config changes */
-  if ((proxy_port_fd = socket(domain, type, 0)) < 0) {
+  if ((port.m_fd = socket(port.m_family, SOCK_STREAM, 0)) < 0) {
     mgmt_elog(stderr, "[bindProxyPort] Unable to create socket : %s\n", strerror(errno));
     _exit(1);
   }
-  if (domain == AF_INET6) {
-    if (setsockopt(proxy_port_fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int)) < 0) {
-      mgmt_elog(stderr, "[bindProxyPort] Unable to set socket options: %d : %s\n", proxy_port, strerror(errno));
+  if (port.m_family == AF_INET6) {
+    if (setsockopt(port.m_fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int)) < 0) {
+      mgmt_elog(stderr, "[bindProxyPort] Unable to set socket options: %d : %s\n", port.m_port, strerror(errno));
     }
   }
-  if (setsockopt(proxy_port_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
-    mgmt_elog(stderr, "[bindProxyPort] Unable to set socket options: %d : %s\n", proxy_port, strerror(errno));
+  if (setsockopt(port.m_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
+    mgmt_elog(stderr, "[bindProxyPort] Unable to set socket options: %d : %s\n", port.m_port, strerror(errno));
     _exit(1);
   }
 
-  if (transparent) {
+  if (port.m_inbound_transparent_p) {
 #if TS_USE_TPROXY
-    int transparent_value = 1;
-    Debug("http_tproxy", "Listen port %d inbound transparency enabled.\n", proxy_port);
-    if (setsockopt(proxy_port_fd, SOL_IP, TS_IP_TRANSPARENT, &transparent_value, sizeof(transparent_value)) == -1) {
+    Debug("http_tproxy", "Listen port %d inbound transparency enabled.\n", port.m_port);
+    if (setsockopt(port.m_fd, SOL_IP, TS_IP_TRANSPARENT, &one, sizeof(one)) == -1) {
       mgmt_elog(stderr, "[bindProxyPort] Unable to set transparent socket option [%d] %s\n", errno, strerror(errno));
       _exit(1);
     }
@@ -1305,29 +1209,29 @@ bindProxyPort(int proxy_port, char *inco
 #endif
   }
 
-  snprintf(proxy_port_str, sizeof(proxy_port_str), "%d", proxy_port);
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = domain;
-  hints.ai_socktype = type;
-  hints.ai_flags = AI_PASSIVE;
-
-  err = getaddrinfo(incoming_ip_to_bind_str, proxy_port_str, &hints, &result);
-  if (err != 0) {
-    mgmt_elog(stderr, "[bindProxyPort] Unable to get address info: %s : %s\n", incoming_ip_to_bind_str, gai_strerror(err));
+  ts_ip_endpoint ip;
+  if (port.m_inbound_ip.isValid()) {
+    ip.assign(port.m_inbound_ip);
+  } else if (AF_INET6 == port.m_family) {
+    if (m_inbound_ip6.isValid()) ip.assign(m_inbound_ip6);
+    else ip.setToAnyAddr(AF_INET6);
+  } else if (AF_INET == port.m_family) {
+    if (m_inbound_ip4.isValid()) ip.assign(m_inbound_ip4);
+    else ip.setToAnyAddr(AF_INET);
+  } else {
+    mgmt_elog(stderr, "[bindProxyPort] Proxy port with invalid address type %d\n", port.m_family);
     _exit(1);
   }
-
-  if((bind(proxy_port_fd, result->ai_addr, result->ai_addrlen)) < 0) {
-    mgmt_elog(stderr, "[bindProxyPort] Unable to bind socket: %d : %s\n", proxy_port, strerror(errno));
+  ip.port() = htons(port.m_port);
+  if (bind(port.m_fd, &ip.sa, ink_inet_ip_size(&ip)) < 0) {
+    mgmt_elog(stderr, "[bindProxyPort] Unable to bind socket: %d : %s\n", port.m_port, strerror(errno));
     _exit(1);
   }
 
-  freeaddrinfo(result);
-
-  Debug("lm", "[bindProxyPort] Successfully bound proxy port %d\n", proxy_port);
+  Debug("lm", "[bindProxyPort] Successfully bound proxy port %d\n", port.m_port);
 
 #if !TS_USE_POSIX_CAP
-  if (proxy_port < 1024 && euid != 0) {
+  if (port.m_port < 1024 && euid != 0) {
     if (privBoost == true) {
       if (removeRootPriv(saved_euid) == false) {
         mgmt_elog(stderr, "[bindProxyPort] Unable to reset permissions to euid %d.  Exiting...\n", getuid());
@@ -1336,7 +1240,6 @@ bindProxyPort(int proxy_port, char *inco
     }
   }
 #endif
-  return proxy_port_fd;
 }
 
 void

Modified: trafficserver/traffic/trunk/mgmt/LocalManager.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/LocalManager.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/LocalManager.h (original)
+++ trafficserver/traffic/trunk/mgmt/LocalManager.h Fri Jan 27 00:33:31 2012
@@ -39,6 +39,7 @@
 #include "BaseManager.h"
 #include "ClusterCom.h"
 #include "VMap.h"
+#include <records/I_RecHttp.h>
 #if TS_HAS_WCCP
 #include <wccp/Wccp.h>
 #endif
@@ -84,6 +85,8 @@ public:
   void processEventQueue();
   bool startProxy();
   void listenForProxy();
+  void bindProxyPort(HttpProxyPort&);
+  void closeProxyPorts();
 
   void mgmtCleanup();
   void mgmtShutdown(int status, bool mainThread = false);
@@ -115,11 +118,10 @@ public:
   volatile bool proxy_launch_outstanding;
   volatile bool mgmt_shutdown_outstanding;
   volatile int proxy_running;
-  volatile int proxy_server_port[MAX_PROXY_SERVER_PORTS];
-  volatile char proxy_server_port_attributes[MAX_PROXY_SERVER_PORTS][MAX_ATTR_LEN];
-  volatile int proxy_server_fd[MAX_PROXY_SERVER_PORTS];
-  in_addr_t proxy_server_incoming_ip_to_bind;
-  char *proxy_server_incoming_ip_to_bind_str;
+  HttpProxyPort::Group m_proxy_ports;
+  // Local inbound addresses to bind, if set.
+  InkInetAddr m_inbound_ip4;
+  InkInetAddr m_inbound_ip6;
 
   int process_server_timeout_secs;
   int process_server_timeout_msecs;

Modified: trafficserver/traffic/trunk/mgmt/Main.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/Main.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/Main.cc (original)
+++ trafficserver/traffic/trunk/mgmt/Main.cc Fri Jan 27 00:33:31 2012
@@ -417,7 +417,8 @@ main(int argc, char **argv)
   int cluster_port = -1, cluster_server_port = -1;
   // TODO: This seems completely incomplete, disabled for now
   //  int dump_config = 0, dump_process = 0, dump_node = 0, dump_cluster = 0, dump_local = 0;
-  int proxy_port = -1, proxy_backdoor = -1;
+  char* proxy_port = 0;
+  int proxy_backdoor = -1;
   char *envVar = NULL, *group_addr = NULL, *tsArgs = NULL;
   bool log_to_syslog = true;
   char userToRunAs[80];
@@ -537,7 +538,7 @@ main(int argc, char **argv)
             }
           } else if (strcmp(argv[i], "-proxyPort") == 0) {
             ++i;
-            proxy_port = atoi(argv[i]);
+            proxy_port = argv[i];
           } else if (strcmp(argv[i], "-proxyBackDoor") == 0) {
             ++i;
             proxy_backdoor = atoi(argv[i]);
@@ -703,9 +704,8 @@ main(int argc, char **argv)
     lmgmt->proxy_options = tsArgs;
     mgmt_log(stderr, "[main] Traffic Server Args: '%s'\n", lmgmt->proxy_options);
   }
-  if (proxy_port != -1) {
-    lmgmt->proxy_server_port[0] = proxy_port;
-    mgmt_log(stderr, "[main] Traffic Server Port: '%d'\n", lmgmt->proxy_server_port[0]);
+  if (proxy_port) {
+    HttpProxyPort::loadValue(lmgmt->m_proxy_ports, proxy_port);
   }
 
   if (proxy_backdoor != -1) {

Modified: trafficserver/traffic/trunk/mgmt/RecordsConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/RecordsConfig.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/RecordsConfig.cc (original)
+++ trafficserver/traffic/trunk/mgmt/RecordsConfig.cc Fri Jan 27 00:33:31 2012
@@ -404,7 +404,9 @@ RecordElement RecordsConfig[] = {
   //       #
   {RECT_CONFIG, "proxy.config.http.enabled", RECD_INT, "1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.http.server_port", RECD_INT, "8080", RECU_RESTART_TM, RR_REQUIRED, RECC_INT, "[0-65535]", RECA_NULL}
+  {RECT_CONFIG, "proxy.config.http.server_ports", RECD_STRING, NULL, RECU_RESTART_TM, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  ,
+  {RECT_CONFIG, "proxy.config.http.server_port", RECD_INT, "-1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-65535]", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.http.server_port_attr", RECD_STRING, "X", RECU_RESTART_TM, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
@@ -1318,7 +1320,7 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.ssl.server.honor_cipher_order", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.ssl.server_port", RECD_INT, "443", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-65535]", RECA_NULL}
+  {RECT_CONFIG, "proxy.config.ssl.server_port", RECD_INT, "-1", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-65535]", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.ssl.client.certification_level", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
   ,

Modified: trafficserver/traffic/trunk/mgmt/cli/ShowCmd.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli/ShowCmd.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli/ShowCmd.cc (original)
+++ trafficserver/traffic/trunk/mgmt/cli/ShowCmd.cc Fri Jan 27 00:33:31 2012
@@ -1215,8 +1215,7 @@ ShowVersion()
 int
 ShowPorts()
 {
-  TSInt http_server = -1;
-  TSString http_other = NULL;
+  TSString http_ports = NULL;
   TSInt cluster = -1;
   TSInt cluster_rs = -1;
   TSInt cluster_mc = -1;
@@ -1226,8 +1225,7 @@ ShowPorts()
 
   // retrieve values
 
-  Cli_RecordGetInt("proxy.config.http.server_port", &http_server);
-  Cli_RecordGetString("proxy.config.http.server_other_ports", &http_other);
+  Cli_RecordGetString("proxy.config.http.server_ports", &http_ports);
   Cli_RecordGetInt("proxy.config.cluster.cluster_port", &cluster);
   Cli_RecordGetInt("proxy.config.cluster.rsport", &cluster_rs);
   Cli_RecordGetInt("proxy.config.cluster.mcport", &cluster_mc);
@@ -1237,8 +1235,7 @@ ShowPorts()
 
   // display results
   Cli_Printf("\n");
-  Cli_Printf("HTTP Server Port ------- %d\n", http_server);
-  Cli_Printf("HTTP Other Ports ------- %s\n", (http_other != NULL) ? http_other : "none");
+  Cli_Printf("HTTP Ports ------------- %s\n", (http_ports != NULL) ? http_ports : "none");
   Cli_Printf("Cluster Port ----------- %d\n", cluster);
   Cli_Printf("Cluster RS Port -------- %d\n", cluster_rs);
   Cli_Printf("Cluster MC Port -------- %d\n", cluster_mc);

Modified: trafficserver/traffic/trunk/mgmt/utils/WebMgmtUtils.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/utils/WebMgmtUtils.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/utils/WebMgmtUtils.cc (original)
+++ trafficserver/traffic/trunk/mgmt/utils/WebMgmtUtils.cc Fri Jan 27 00:33:31 2012
@@ -1270,9 +1270,8 @@ processSpawn(const char *args[],
 
   } else if (pid == 0) {        // child process
     // close all the listening port in child process
-    for (int i = 0; i < MAX_PROXY_SERVER_PORTS && lmgmt->proxy_server_fd[i] >= 0; i++) {
-      close_socket(lmgmt->proxy_server_fd[i]);
-    }
+    lmgmt->closeProxyPorts();
+
 #if TS_USE_POSIX_CAP
     /* There is no point in saving the current euid in order to
        restore it because at this point the process will either exec

Modified: trafficserver/traffic/trunk/proxy/IPAllow.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/IPAllow.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/IPAllow.h (original)
+++ trafficserver/traffic/trunk/proxy/IPAllow.h Fri Jan 27 00:33:31 2012
@@ -67,7 +67,9 @@ public:
    ~IpAllow();
   int BuildTable();
   void Print();
-  bool match(in_addr_t addr);
+  bool match(in_addr_t addr) const;
+  bool match(ts_ip_endpoint const* ip) const;
+  bool match(sockaddr const* ip) const;
 
   /// @return The global instance.
   static self* instance();
@@ -82,6 +84,7 @@ private:
   const char *action;
   bool _allow_all;
   IpMap _map;
+  // Can't use Vec<> because it requires a default constructor for AclRecord.
   std::vector<AclRecord> _acls;
 
   static self* _instance;
@@ -90,7 +93,7 @@ private:
 inline IpAllow* IpAllow::instance() { return _instance; }
 
 inline bool
-IpAllow::match(in_addr_t addr) {
+IpAllow::match(in_addr_t addr) const {
   bool zret = _allow_all;
   if (!zret) {
     void* raw;
@@ -102,4 +105,22 @@ IpAllow::match(in_addr_t addr) {
   return zret;
 }
 
+inline bool
+IpAllow::match(ts_ip_endpoint const* ip) const {
+  return this->match(&ip->sa);
+}
+
+inline bool
+IpAllow::match(sockaddr const* ip) const {
+  bool zret = _allow_all;
+  if (!zret) {
+    void* raw;
+    if (_map.contains(ip, &raw)) {
+      AclRecord* acl = static_cast<AclRecord*>(raw);
+      zret = acl && ACL_OP_ALLOW == acl->_op;
+    }
+  }
+  return zret;
+}
+
 #endif

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Fri Jan 27 00:33:31 2012
@@ -5320,18 +5320,24 @@ TSHttpTxnServerIPGet(TSHttpTxn txnp)
   return ink_inet_ip4_addr_cast(&sm->t_state.server_info.addr.sa);
 }
 
-// This API does currently not use or honor the port specified in the sockaddr.
-// This could change in a future version, but for now, leave it at 0 (or undef).
+// [amc] This might use the port. The code path should do that but it
+// hasn't been tested.
 TSReturnCode
 TSHttpTxnOutgoingAddrSet(TSHttpTxn txnp, const struct sockaddr *addr, socklen_t addrlen)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
   HttpSM *sm = (HttpSM *) txnp;
 
-  sm->t_state.setup_per_txn_configs(); // Make sure the txn_conf struct is setup
-  ink_inet_copy(&sm->t_state.txn_conf->outgoing_ip_to_bind_saddr.sa, addr);
-  ink_inet_port_cast(&sm->t_state.txn_conf->outgoing_ip_to_bind_saddr) = 0;
+  sm->ua_session->outbound_port = ink_inet_get_port(addr);
 
+  if (ink_inet_is_ip4(addr)) {
+    sm->ua_session->outbound_ip4.assign(addr);
+  } else if (ink_inet_is_ip6(addr)) {
+    sm->ua_session->outbound_ip6.assign(addr);
+  } else {
+    sm->ua_session->outbound_ip4.invalidate();
+    sm->ua_session->outbound_ip6.invalidate();
+  }
   return TS_ERROR;
 }
 
@@ -6335,6 +6341,8 @@ TSNetConnect(TSCont contp, sockaddr cons
 TSAction
 TSNetAccept(TSCont contp, int port, int domain, int accept_threads)
 {
+  NetProcessor::AcceptOptions opt;
+
   sdk_assert(sdk_sanity_check_continuation(contp) == TS_SUCCESS);
   sdk_assert(port > 0);
   sdk_assert(accept_threads >= -1);
@@ -6343,11 +6351,14 @@ TSNetAccept(TSCont contp, int port, int 
   // doing an accept at any time?
   FORCE_PLUGIN_MUTEX(contp);
 
-  if (domain < 0)
-    domain = AF_INET;
+  // If it's not IPv6, force to IPv4.
+  opt.ip_family = domain == AF_INET6 ? AF_INET6 : AF_INET;
+  opt.accept_threads = accept_threads;
+  opt.local_port = port;
+  opt.frequent_accept = false;
 
   INKContInternal *i = (INKContInternal *) contp;
-  return (TSAction)netProcessor.accept(i, port, domain, accept_threads);
+  return (TSAction)netProcessor.accept(i, opt);
 }
 
 /* DNS Lookups */

Modified: trafficserver/traffic/trunk/proxy/InkAPITest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITest.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITest.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITest.cc Fri Jan 27 00:33:31 2012
@@ -2243,10 +2243,16 @@ static int
 checkHttpTxnClientIncomingPortGet(SocketTest * test, void *data)
 {
   uint16_t port;
-  TSMgmtInt port_from_config_file = -1;
+  HttpProxyPort* proxy_port = HttpProxyPort::findHttp(AF_INET);
   TSHttpTxn txnp = (TSHttpTxn) data;
   sockaddr const* ptr = TSHttpTxnIncomingAddrGet(txnp);
 
+  if (0 == proxy_port) {
+    SDK_RPRINT(test->regtest, "TSHttpTxnIncomingPortGet", "TestCase1", TC_FAIL,
+               "TSHttpTxnClientIncomingPortGet failed to find configured HTTP port.");
+    test->test_client_incoming_port_get = false;
+    return TS_EVENT_CONTINUE;
+  }
   if (0 == ptr) {
     SDK_RPRINT(test->regtest, "TSHttpTxnIncomingPortGet", "TestCase1", TC_FAIL,
                "TSHttpTxnClientIncomingPortGet returns 0 pointer");
@@ -2255,18 +2261,14 @@ checkHttpTxnClientIncomingPortGet(Socket
   }
   port = ink_inet_get_port(ptr);
 
-  if (TSMgmtIntGet("proxy.config.http.server_port", &port_from_config_file) != TS_SUCCESS) {
-    port_from_config_file = 8080;
-  }
-
-  TSDebug(UTDBG_TAG, "TS HTTP port = %x, Txn incoming client port %x", (int) port_from_config_file, port);
+  TSDebug(UTDBG_TAG, "TS HTTP port = %x, Txn incoming client port %x", proxy_port->m_port, port);
 
-  if (port == static_cast<uint16_t>(port_from_config_file)) {
+  if (port == proxy_port->m_port) {
     SDK_RPRINT(test->regtest, "TSHttpTxnClientIncomingPortGet", "TestCase1", TC_PASS, "ok");
     test->test_client_incoming_port_get = true;
   } else {
     SDK_RPRINT(test->regtest, "TSHttpTxnClientIncomingPortGet", "TestCase1", TC_FAIL,
-               "Value's Mismatch. From Funtion: %d  Expected value: %d", port, port_from_config_file);
+               "Value's Mismatch. From Funtion: %d  Expected value: %d", port, proxy_port->m_port);
     test->test_client_incoming_port_get = false;
   }
   return TS_EVENT_CONTINUE;
@@ -6371,12 +6373,13 @@ cache_hook_handler(TSCont contp, TSEvent
       /* If this is the first time, then the response is in cache and we should make */
       /* another request to get cache hit */
       if (data->first_time == true) {
-        data->first_time = false;
+	data->first_time = false;
         /* Kill the origin server */
         synserver_delete(data->os);
+
         /* Send another similar client request */
         synclient_txn_send_request(data->browser2, data->request);
-        TSfree(data->request);
+        ink_assert(REQUEST_INPROGRESS == data->browser2->status);
         TSContSchedule(contp, 25, TS_THREAD_POOL_DEFAULT);
         return 0;
       }
@@ -6396,6 +6399,7 @@ cache_hook_handler(TSCont contp, TSEvent
       synclient_txn_delete(data->browser2);
 
       data->magic = MAGIC_DEAD;
+      TSfree(data->request);
       TSfree(data);
       TSContDataSet(contp, NULL);
     }

Modified: trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITestTool.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITestTool.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITestTool.cc Fri Jan 27 00:33:31 2012
@@ -26,6 +26,7 @@
 
 #include <arpa/inet.h>          /* For htonl */
 #include "P_Net.h"
+#include <records/I_RecHttp.h>
 
 #define SDBG_TAG "SockServer"
 #define CDBG_TAG "SockClient"
@@ -428,13 +429,14 @@ get_request_id(TSHttpTxn txnp)
 static ClientTxn *
 synclient_txn_create(void)
 {
-  TSMgmtInt proxy_port;
-
+  HttpProxyPort* proxy_port;
+  
   ClientTxn *txn = (ClientTxn *) TSmalloc(sizeof(ClientTxn));
-  if (TSMgmtIntGet(PROXY_CONFIG_NAME_HTTP_PORT, &proxy_port) != TS_SUCCESS) {
-    proxy_port = PROXY_HTTP_DEFAULT_PORT;
-  }
-  txn->connect_port = (int) proxy_port;
+  if (0 == (proxy_port = HttpProxyPort::findHttp(AF_INET)))
+    txn->connect_port = PROXY_HTTP_DEFAULT_PORT;
+  else
+    txn->connect_port = proxy_port->m_port;
+
   txn->local_port = (int) 0;
   txn->connect_ip = IP(127, 0, 0, 1);
   txn->status = REQUEST_INPROGRESS;
@@ -447,7 +449,7 @@ synclient_txn_create(void)
   txn->magic = MAGIC_ALIVE;
   txn->connect_action = NULL;
 
-  TSDebug(CDBG_TAG, "Connecting to proxy 127.0.0.1 on port %d", (int) proxy_port);
+  TSDebug(CDBG_TAG, "Connecting to proxy 127.0.0.1 on port %d", txn->connect_port);
   return txn;
 }
 

Modified: trafficserver/traffic/trunk/proxy/Main.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Main.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Main.cc (original)
+++ trafficserver/traffic/trunk/proxy/Main.cc Fri Jan 27 00:33:31 2012
@@ -134,7 +134,7 @@ int num_of_udp_threads = DEFAULT_NUMBER_
 int num_accept_threads  = DEFAULT_NUM_ACCEPT_THREADS;
 int num_task_threads = DEFAULT_NUM_TASK_THREADS;
 int run_test_hook = 0;
-int http_accept_port_number = DEFAULT_HTTP_ACCEPT_PORT_NUMBER;
+char http_accept_port_descriptor[1023] = "";
 int http_accept_file_descriptor = NO_FD;
 int ssl_accept_file_descriptor = NO_FD;
 char accept_fd_list[1024] = "";
@@ -175,13 +175,11 @@ int diags_init = 0;             // used 
 
 char vingid_flag[255] = "";
 
-
 static int accept_mss = 0;
 static int cmd_line_dprintf_level = 0;  // default debug output level fro ink_dprintf function
 
 AppVersionInfo appVersionInfo;  // Build info for this application
 
-
 #if TS_HAS_TESTS
 extern int run_TestHook();
 // TODO: Maybe review and "fix" this test at some point?
@@ -210,10 +208,8 @@ ArgumentDescription argument_description
    "PROXY_ACCEPT_THREAD", NULL},
   {"accept_till_done", 'b', "Accept Till Done", "T", &accept_till_done,
    "PROXY_ACCEPT_TILL_DONE", NULL},
-  {"httpport", 'p', "Port Number for HTTP Accept", "I",
-   &http_accept_port_number, "PROXY_HTTP_ACCEPT_PORT", NULL},
-  {"acceptfds", 'A', "File Descriptor List for Accept", "S1023",
-   accept_fd_list, "PROXY_ACCEPT_DESCRIPTOR_LIST", NULL},
+  {"httpport", 'p', "Port descriptor for HTTP Accept", "S1023",
+   http_accept_port_descriptor, "PROXY_HTTP_ACCEPT_PORT", NULL},
   {"cluster_port", 'P', "Cluster Port Number", "I", &cluster_port_number,
    "PROXY_CLUSTER_PORT", NULL},
   {"dprintf_level", 'o', "Debug output level", "I", &cmd_line_dprintf_level,
@@ -846,91 +842,6 @@ check_for_root_uid()
 }
 #endif
 
-// static void print_accept_fd(HttpPortEntry* e)
-//
-static void
-print_accept_fd(HttpEntryPoint * e)
-{
-  if (e) {
-    printf("Accept FDs: ");
-    while (e->fd != NO_FD) {
-      printf("%d:%d ", e->fd, e->type);
-      e++;
-    }
-    printf("\n");
-  }
-}
-
-extern void get_connection_attributes(const char *attr, HttpEntryPoint *result);
-
-// static HttpEntryPoint* parse_accept_fd_list()
-//
-// Parses the list of FD's and types sent in by the manager
-//   with the -A flag
-//
-// If the NTTP Accept fd is in the list, sets global
-//   nttp_accept_fd
-//
-// If the SSL Accept fd is in the list, sets global
-//   ssl_accept_fd
-//
-// If there is no -A arg, returns NULL
-//
-//  Otherwise returns an array of HttpEntryPoint which
-//   is terminated with a HttpEntryPoint with the fd
-//   field set to NO_FD
-//
-static HttpEntryPoint *
-parse_accept_fd_list()
-{
-  HttpEntryPoint *accept_array;
-  int accept_index = 0;
-  int list_entries;
-  int fd = ts::NO_FD;
-  Tokenizer listTok(",");
-
-  if (!accept_fd_list[0]
-    || (list_entries = listTok.Initialize(accept_fd_list, SHARE_TOKS)) <= 0
-  )
-    return 0;
-
-  // Add one because we use NO_FD as an array termination mark later.
-  accept_array = new HttpEntryPoint[list_entries + 1];
-
-  for (int i = 0; i < list_entries; ++i) {
-    HttpEntryPoint* pent = accept_array + accept_index;
-    char const* cur_entry = listTok[i];
-    char* next;
-
-    // Check to see if there is a port attribute
-    char const* attr_str = strchr(cur_entry, ':');
-    if (attr_str != NULL) {
-      attr_str = attr_str + 1;
-    }
-    // Handle the file descriptor
-    fd = strtoul(cur_entry, &next, 10);
-    if (next == cur_entry) {
-      Warning("Failed to parse file descriptor '%s'", cur_entry);
-      continue; // number parsing failure
-    }
-
-    // Handle reading the attribute
-    get_connection_attributes(attr_str, pent);
-    if (SERVER_PORT_SSL == pent->type) {
-      ink_assert(ssl_accept_file_descriptor == NO_FD);
-      ssl_accept_file_descriptor = fd;
-      continue;
-    }
-    accept_array[accept_index++].fd = fd;
-  }
-
-  ink_assert(accept_index < list_entries + 1);
-
-  accept_array[accept_index].fd = NO_FD;
-
-  return accept_array;
-}
-
 static int
 set_core_size(const char *name, RecDataT data_type, RecData data, void *opaque_token)
 {
@@ -1322,11 +1233,9 @@ chdir_root()
 int
 getNumSSLThreads(void)
 {
-  int ssl_enabled = 0;
+  bool ssl_enabled = HttpProxyPort::hasSSL();
   int num_of_ssl_threads = 0;
 
-  TS_ReadConfigInteger(ssl_enabled, "proxy.config.ssl.enabled");
-
   // Set number of ssl threads equal to num of processors if
   // SSL is enabled so it will scale properly. If SSL is not
   // enabled, leave num of ssl threads one, incase a remap rule
@@ -1571,9 +1480,7 @@ main(int argc, char **argv)
   admin_user_p = 
     (REC_ERR_OKAY ==
       TS_ReadConfigString(user, "proxy.config.admin.user_id", max_login)
-    )
-    && user[0] != '\0'
-    && 0 != strcmp(user, "#-1")
+    ) && user[0] != '\0' && 0 != strcmp(user, "#-1")
     ;
 
 # if TS_USE_POSIX_CAP
@@ -1613,7 +1520,8 @@ main(int argc, char **argv)
   if (is_debug_tag_set("diags"))
     diags->dump();
 # if TS_USE_POSIX_CAP
-  DebugCapabilities("server"); // Can do this now, logging is up.
+  if (is_debug_tag_set("server"))
+    DebugCapabilities("server"); // Can do this now, logging is up.
 # endif
 
   // Check if we should do mlockall()
@@ -1643,13 +1551,17 @@ main(int argc, char **argv)
   /* Set up the machine with the outbound address if that's set,
      or the inbound address if set, otherwise let it default.
   */
-  sockaddr const* machine_addr = 0;
-  if (ink_inet_is_ip(&HttpConfig::m_master.oride.outgoing_ip_to_bind_saddr)) {
-    machine_addr = &HttpConfig::m_master.oride.outgoing_ip_to_bind_saddr.sa;
-  } else if (ink_inet_is_ip(&HttpConfig::m_master.incoming_ip_to_bind_saddr)) {
-    machine_addr = &HttpConfig::m_master.incoming_ip_to_bind_saddr.sa;
-  }
-  Machine::init(0, machine_addr);
+  ts_ip_endpoint machine_addr;
+  ink_zero(machine_addr);
+  if (HttpConfig::m_master.outbound_ip4.isValid())
+    machine_addr.assign(HttpConfig::m_master.outbound_ip4);
+  else if (HttpConfig::m_master.outbound_ip6.isValid())
+    machine_addr.assign(HttpConfig::m_master.outbound_ip6);
+  else if (HttpConfig::m_master.inbound_ip4.isValid())
+    machine_addr.assign(HttpConfig::m_master.inbound_ip4);
+  else if (HttpConfig::m_master.inbound_ip6.isValid())
+    machine_addr.assign(HttpConfig::m_master.inbound_ip6);
+  Machine::init(0, &machine_addr.sa);
 
   // pmgmt->start() must occur after initialization of Diags but
   // before calling RecProcessInit()
@@ -1678,13 +1590,6 @@ main(int argc, char **argv)
   // Init HTTP Accept-Encoding/User-Agent filter
   init_http_aeua_filter();
 
-  // Parse the accept port list from the manager
-  http_open_port_array = parse_accept_fd_list();
-
-  if (is_debug_tag_set("accept_fd"))
-    print_accept_fd(http_open_port_array);
-
-
   // Sanity checks
   //  if (!lock_process) check_for_root_uid();
   check_fd_limit();
@@ -1797,6 +1702,11 @@ main(int argc, char **argv)
     clusterProcessor.init();
 #endif
 
+    // Load HTTP port data. getNumSSLThreads depends on this.
+    if (!HttpProxyPort::loadValue(http_accept_port_descriptor))
+      HttpProxyPort::loadConfig();
+    HttpProxyPort::loadDefaultIfEmpty();
+
     cacheProcessor.start();
     udpNet.start(num_of_udp_threads);   // XXX : broken for __WIN32
     sslNetProcessor.start(getNumSSLThreads());
@@ -1865,15 +1775,6 @@ main(int argc, char **argv)
 #endif
 
     init_HttpProxyServer();
-    if (!http_accept_port_number) {
-      TS_ReadConfigInteger(http_accept_port_number, "proxy.config.http.server_port");
-    }
-    if ((unsigned int) http_accept_port_number >= 0xFFFF) {
-      ProcessFatal("\ncannot listen on port %d.\naccept port cannot be larger that 65535.\n"
-                   "please check your Traffic Server configurations", http_accept_port_number);
-      return (1);
-    }
-
     int http_enabled = 1;
     TS_ReadConfigInteger(http_enabled, "proxy.config.http.enabled");
 
@@ -1882,7 +1783,7 @@ main(int argc, char **argv)
       int icp_enabled = 0;
       TS_ReadConfigInteger(icp_enabled, "proxy.config.icp.enabled");
 #endif
-      start_HttpProxyServer(http_accept_file_descriptor, http_accept_port_number, ssl_accept_file_descriptor, num_accept_threads);
+      start_HttpProxyServer(num_accept_threads);
 #ifndef INK_NO_ICP
       if (icp_enabled)
         icpProcessor.start();

Modified: trafficserver/traffic/trunk/proxy/Main.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Main.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Main.h (original)
+++ trafficserver/traffic/trunk/proxy/Main.h Fri Jan 27 00:33:31 2012
@@ -45,9 +45,6 @@
 //
 // Global Configuration
 extern int accept_till_done;
-//extern int ssl_accept_port_number;
-//extern int ssl_enabled;
-extern int http_accept_port_number;
 extern int http_accept_file_descriptor;
 extern int command_flag;
 extern int auto_clear_hostdb_flag;
@@ -88,39 +85,6 @@ maintainance_mode()
 
 void syslog_thr_init();
 
-enum HttpPortTypes
-{
-  SERVER_PORT_DEFAULT = 0,
-  SERVER_PORT_COMPRESSED,
-  SERVER_PORT_BLIND_TUNNEL,
-  SERVER_PORT_SSL
-};
-
-struct HttpEntryPoint {
-  int fd; ///< Pre-opened file descriptor if present.
-  HttpPortTypes type; ///< Type of connection.
-  int port; ///< Port on which to listent.
-  unsigned int domain; ///< Networking domain.
-  /// Set if inbound connects (from client) are/were transparent.
-  bool f_inbound_transparent;
-  /// Set if outbound connections (to origin servers) are transparent.
-  bool f_outbound_transparent;
-
-  HttpEntryPoint()
-    : fd(ts::NO_FD)
-    , type(SERVER_PORT_DEFAULT)
-    , port(-1)
-    , domain(AF_INET)
-    , f_inbound_transparent(false)
-    , f_outbound_transparent(false)
-  { }
-};
-
-/// Ports that are already open (passed via -A from manager).
-extern HttpEntryPoint *http_open_port_array;
-/// Ports to open in this process.
-extern HttpEntryPoint *http_other_port_array;
-
 extern Version version;
 extern AppVersionInfo appVersionInfo;
 

Modified: trafficserver/traffic/trunk/proxy/Prefetch.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Prefetch.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Prefetch.cc (original)
+++ trafficserver/traffic/trunk/proxy/Prefetch.cc Fri Jan 27 00:33:31 2012
@@ -27,6 +27,7 @@
 #include "HdrUtils.h"
 #include "HttpCompat.h"
 #include "I_Layout.h"
+#include <records/I_RecHttp.h>
 #include <ts/IpMapConf.h>
 
 #ifdef PREFETCH
@@ -1499,9 +1500,12 @@ PrefetchBlaster::httpClient(int event, v
   switch (event) {
 
   case EVENT_IMMEDIATE:{
-      netProcessor.connect_re(this, htonl((127 << 24) | 1), prefetch_config.local_http_server_port);
-      break;
-    }
+    ts_ip_endpoint target;
+    target.setToLoopback(AF_INET);
+    target.port() = prefetch_config.local_http_server_port;
+    netProcessor.connect_re(this, &target.sa);
+    break;
+  }
 
   case NET_EVENT_OPEN:{
       serverVC = (VConnection *) data;
@@ -1823,7 +1827,7 @@ PrefetchConfiguration::readConfiguration
     return 0;
   }
 
-  TS_ReadConfigInteger(local_http_server_port, "proxy.config.http.server_port");
+  local_http_server_port = HttpProxyPort::findHttp(AF_INET)->m_port;
   TS_ReadConfigInteger(stuffer_port, "proxy.config.prefetch.child_port");
   TS_ReadConfigInteger(url_buffer_size, "proxy.config.prefetch.url_buffer_size");
   TS_ReadConfigInteger(url_buffer_timeout, "proxy.config.prefetch.url_buffer_timeout");

Modified: trafficserver/traffic/trunk/proxy/SocksProxy.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/SocksProxy.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/SocksProxy.cc (original)
+++ trafficserver/traffic/trunk/proxy/SocksProxy.cc Fri Jan 27 00:33:31 2012
@@ -145,15 +145,17 @@ SocksProxy::mainEvent(int event, void *d
 
     switch (state) {
     case HTTP_REQ:{
-        //This is a WRITE_COMPLETE. vio->nbytes == vio->ndone is true
+      HttpAccept::Options ha_opt;
+      //This is a WRITE_COMPLETE. vio->nbytes == vio->ndone is true
 
-        SOCKSPROXY_INC_STAT(socksproxy_http_connections_stat);
-        Debug("SocksProxy", "Handing over the HTTP request\n");
+      SOCKSPROXY_INC_STAT(socksproxy_http_connections_stat);
+      Debug("SocksProxy", "Handing over the HTTP request\n");
 
-        HttpAccept http_accept(clientVC->attributes);
-        http_accept.mainEvent(NET_EVENT_ACCEPT, clientVC);
-        state = ALL_DONE;
-        break;
+      ha_opt.transport_type = clientVC->attributes;
+      HttpAccept http_accept(ha_opt);
+      http_accept.mainEvent(NET_EVENT_ACCEPT, clientVC);
+      state = ALL_DONE;
+      break;
       }
 
     case RESP_TO_CLIENT:
@@ -522,8 +524,8 @@ start_SocksProxy(int port)
 {
   Debug("SocksProxy", "Accepting SocksProxy connections on port %d\n", port);
   NetProcessor::AcceptOptions opt;
-  opt.port = port;
-  netProcessor.main_accept(NEW(new SocksAccepter), NO_FD, 0, 0, false, false, opt);
+  opt.local_port = port;
+  netProcessor.main_accept(NEW(new SocksAccepter), NO_FD, opt);
 
   socksproxy_stat_block = RecAllocateRawStatBlock(socksproxy_stat_count);
 

Modified: trafficserver/traffic/trunk/proxy/TestHook.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/TestHook.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/TestHook.cc (original)
+++ trafficserver/traffic/trunk/proxy/TestHook.cc Fri Jan 27 00:33:31 2012
@@ -497,8 +497,16 @@ run_TestHook()
 
   printf("*** BRIOCORE Server Running ***\n");
   for (i = 1; i <= G.accept_count; i++) {
+    NetProcessor::AcceptOptions opt;
     c = new AcceptContinuation();
-    (void) netProcessor.accept(c, G.accept_port, G.accept_spawn);
+    opt.local_port = G.accept_port;
+    // [amc] I have absolutely no idea what accept_spawn is supposed
+    // to control.  I am just guessing it's accept_threads. Code
+    // tracing indicated it ended up as the value for the address
+    // family and then ignored. It's declared as an int but assigned a
+    // bool value so I'm not even sure what type it's intended to be.
+    opt.accept_threads = G.accept_spawn;
+    (void) netProcessor.accept(c, opt);
   }
   return (0);
 }

Modified: trafficserver/traffic/trunk/proxy/UglyLogStubs.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/UglyLogStubs.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/UglyLogStubs.cc (original)
+++ trafficserver/traffic/trunk/proxy/UglyLogStubs.cc Fri Jan 27 00:33:31 2012
@@ -157,15 +157,14 @@ NetProcessor::AcceptOptions const NetPro
 NetProcessor::AcceptOptions&
 NetProcessor::AcceptOptions::reset()
 {
-  port = 0;
+  local_port = 0;
   accept_threads = 0;
-  domain = AF_INET;
+  ip_family = AF_INET;
   etype = ET_NET;
   f_callback_on_open = false;
   recv_bufsize = 0;
   send_bufsize = 0;
   sockopt_flags = 0;
-  f_outbound_transparent = false;
   f_inbound_transparent = false;
   return *this;
 }

Modified: trafficserver/traffic/trunk/proxy/Update.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Update.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Update.cc (original)
+++ trafficserver/traffic/trunk/proxy/Update.cc Fri Jan 27 00:33:31 2012
@@ -31,6 +31,7 @@
 #include "HttpDebugNames.h"
 #include "URL.h"
 #include "HdrUtils.h"
+#include <records/I_RecHttp.h>
 //#include "MixtAPIInternal.h"
 
 RecRawStatBlock *update_rsb;
@@ -716,15 +717,11 @@ UpdateConfigManager::~UpdateConfigManage
 {
 }
 
-static RecInt local_http_server_port = 0;
-
 int
 UpdateConfigManager::init()
 {
   update_rsb = RecAllocateRawStatBlock((int) update_stat_count);
 
-  UpdateEstablishStaticConfigInteger(local_http_server_port, "proxy.config.http.server_port");
-
   _CP_actual = NEW(new UpdateConfigParams);
 
   // Setup update handlers for each global configuration parameter
@@ -2566,12 +2563,15 @@ ObjectReloadCont::ObjectReloadEvent(int 
   switch (_state) {
   case START:
     {
+      ts_ip_endpoint target;
       // Schedule connect to localhost:<proxy port>
       Debug("update-reload", "Connect start id=%d", _request_id);
       _state = ObjectReloadCont::ATTEMPT_CONNECT;
       MUTEX_TRY_LOCK(lock, this->mutex, this_ethread());
       ink_release_assert(lock);
-      _cur_action = netProcessor.connect_re(this, inet_addr("127.0.0.1"), local_http_server_port);
+      target.setToLoopback(AF_INET);
+      target.port() = htons(HttpProxyPort::findHttp(AF_INET)->m_port);
+      _cur_action = netProcessor.connect_re(this, &target.sa);
       return EVENT_DONE;
     }
   case ATTEMPT_CONNECT:

Modified: trafficserver/traffic/trunk/proxy/config/records.config.default.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/config/records.config.default.in?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/config/records.config.default.in (original)
+++ trafficserver/traffic/trunk/proxy/config/records.config.default.in Fri Jan 27 00:33:31 2012
@@ -57,10 +57,12 @@ CONFIG proxy.config.process_manager.mgmt
 ##############################################################################
 #
 # In order to only bind a specific IP, use the following config, as in
-# the example below. Note
+# the example below. Note - this can contain two addresses, one for IPv4
+# sockets and one for IPv6 sockets.
 #
 ##############################################################################
 #LOCAL proxy.local.incoming_ip_to_bind STRING 192.168.101.17
+#LOCAL proxy.local.incoming_ip_to_bind STRING 192.168.101.17 fc07:192:168:101::17
 ##############################################################################
 #
 # Alarm Configuration
@@ -77,15 +79,28 @@ CONFIG proxy.config.alarm.abs_path STRIN
    ##########
    # basics #
    ##########
-   # The main server_port is listed here, other server ports is a
-   # string of ports, separated by whitespace.  The port attributes
-   # should be set to X(default behavior). For example...
-   # server_other_ports STRING 1234:X 12345:X
-CONFIG proxy.config.http.server_port INT 8080
-CONFIG proxy.config.http.server_port_attr STRING X
-# to enable IPv6 listening on port 8080:
-# CONFIG proxy.config.http.server_other_ports STRING 8080:X6
-CONFIG proxy.config.http.server_other_ports STRING NULL
+   # The server ports are listed here. These are separated by spaces or commas.
+   # Each port is a colon separated list of values, which must include a
+   # port number. Other options are
+   # ipv4 - Use IPv4 (default)
+   # ipv6 - Use IPv6
+   # tr-in - Transparent inbound.
+   # tr-out - Transparent outbound.
+   # tr-full - Fully transparent (inbound and outbound).
+   # ssl - SSL terminated port.
+   # blind - Blind tunnel port.
+   # ip-in=[addr] - Bind inbound IP address (listen for client).
+   # ip-out=[addr] - Bind outbound IP address (connect to origin server).
+   #
+   # note - address types must agree with each other and the ipv4/ipv6
+   # option if specified. IPv6 addresses must be enclosed in brackets.
+   # ip-out can be repeated as long as each address is a different family.
+   # The '=' is optional.
+   #
+   # Example: Port 8080 IPv6 inbound transparent, and port 80 IPv4
+   # "8080:ipv6:tr-in 80"
+CONFIG proxy.config.http.server_ports STRING 8080
+   # Ports on the origin server to which a blind tunnel may connect.
 CONFIG proxy.config.http.connect_ports STRING 443 563
    # The via settings have three values
    #  0 - Do not modify / set this via header
@@ -476,7 +491,9 @@ CONFIG proxy.config.url_remap.pristine_h
    # proxy.config.ssl.enabled should be:
    #   0 - none
    #   1 - SSL enabled
-CONFIG proxy.config.ssl.enabled INT 0
+   # Deprecated. SSL is enabled automatically if an SSL port is configured
+   # in config.proxy.http.server_ports.
+#CONFIG proxy.config.ssl.enabled INT 0
    # The number of SSL threads is a multiplier of number of CPUs and
    # proxy.config.exec_thread.autoconfig.scale by default. You can
    # override that here (set it to a non-zero value).
@@ -495,8 +512,9 @@ CONFIG proxy.config.ssl.server.cipher_su
 CONFIG proxy.config.ssl.server.honor_cipher_order INT 0
    # Control if SSL should perform content compression or not
 CONFIG proxy.config.ssl.compression INT 1
-   # SSL port (unfortunately, only one at this time)
-CONFIG proxy.config.ssl.server_port INT 443
+   # Deprecated.
+   # SSL ports should now be configured via proxy.config.http.server_ports
+#CONFIG proxy.config.ssl.server_port INT 443
    # Client certification level should be:
    # 0 no client certificates
    # 1 client certificates optional

Modified: trafficserver/traffic/trunk/proxy/http/HttpAccept.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpAccept.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpAccept.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpAccept.cc Fri Jan 27 00:33:31 2012
@@ -26,6 +26,7 @@
 #include "HttpClientSession.h"
 #include "I_Machine.h"
 
+HttpAccept::Options const HttpAccept::DEFAULT_OPTIONS;
 
 int
 HttpAccept::mainEvent(int event, void *data)
@@ -37,28 +38,34 @@ HttpAccept::mainEvent(int event, void *d
     ////////////////////////////////////////////////////
     // if client address forbidden, close immediately //
     ////////////////////////////////////////////////////
-    NetVConnection *netvc = (NetVConnection *) data;
-    in_addr_t client_ip = netvc->get_remote_ip();
+    NetVConnection *netvc = static_cast<NetVConnection *>(data);
+    sockaddr const* client_ip = netvc->get_remote_addr();
+    ip_port_text_buffer ipb;
 
     // The backdoor port is now only bound to "localhost", so reason to
     // check for if it's incoming from "localhost" or not.
     if (!backdoor && IpAllow::instance() && (!IpAllow::instance()->match(client_ip))) {
-      char ip_string[32];
-      unsigned char *p = (unsigned char *) &(client_ip);
-
-      snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
-      Warning("connect by disallowed client %s, closing", ip_string);
+      Warning("connect by disallowed client %s, closing", ink_inet_ntop(client_ip, ipb, sizeof(ipb)));
       netvc->do_io_close();
 
       return VC_EVENT_CONT;
     }
 
-    netvc->attributes = attr;
+    netvc->attributes = transport_type;
+
+    if (is_debug_tag_set("http_seq"))
+      Debug("http_seq", "[HttpAccept:mainEvent %lx] accepted connection from %s transport type = %d.\n", netvc, ink_inet_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
 
-    Debug("http_seq", "HttpAccept:mainEvent] accepted connection");
     HttpClientSession *new_session = THREAD_ALLOC_INIT(httpClientSessionAllocator, netvc->thread);
 
+   // copy over session related data.
+    new_session->f_outbound_transparent = f_outbound_transparent;
+    new_session->outbound_ip4 = outbound_ip4;
+    new_session->outbound_ip6 = outbound_ip6;
+    new_session->outbound_port = outbound_port;
+
     new_session->new_connection(netvc, backdoor);
+
     return EVENT_CONT;
   }
 

Modified: trafficserver/traffic/trunk/proxy/http/HttpAccept.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpAccept.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpAccept.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpAccept.h Fri Jan 27 00:33:31 2012
@@ -29,19 +29,126 @@
 #include "HttpConfig.h"
 #include "HTTP.h"
 
-/**
-   The continuation mutex is NULL to allow parellel accepts in NT. The
-   only state used by the handler is attr and backdoor which is setup
-   at the beginning of time and never changed. No state is recorded by
-   the handler. So a NULL mutex is safe.
+namespace detail {
+  /** Options for @c HttpAccept.
+
+      @internal This is done as a separate class for two reasons.
+
+      The first is that in current usage many instances are created
+      with the same options so (for the client) this is easier and
+      more efficient than passing options directly to the @c
+      HttpAccept or calling setters.
+
+      The second is that @c HttpAccept is not provided with any thread
+      safety because it is intended as an immutable object. Putting
+      the setters here and not there makes that clearer.
+
+      We don't do this directly as nested class because we want to
+      inherit the data members rather than duplicate the declarations
+      and initializations.
+   */
+  class HttpAcceptOptions {
+  private:
+    typedef HttpAcceptOptions self; ///< Self reference type.
+  public:
+    HttpAcceptOptions();
+
+    // Connection type (HttpProxyPort::TransportType)
+    int transport_type;
+    /// Set the transport type.
+    self& setTransportType(int);
+    /// Local address to bind for outbound connections.
+    InkInetAddr outbound_ip4;
+    /// Local address to bind for outbound connections.
+    InkInetAddr outbound_ip6;
+    /// Set the outbound IP address.
+    self& setOutboundIp(InkInetAddr& ip);
+    self& setOutboundIp(ts_ip_endpoint* ip);
+    /// Local port for outbound connection.
+    uint16_t outbound_port;
+    /// Set outbound port.
+    self& setOutboundPort(uint16_t);
+    /// Outbound transparent.
+    bool f_outbound_transparent;
+    /// Set outbound transparency.
+    self& setOutboundTransparent(bool);
+    /// Accepting backdoor connections.
+    bool backdoor;
+    /// Set backdoor accept.
+    self& setBackdoor(bool);
+  };
+
+  inline HttpAcceptOptions::HttpAcceptOptions()
+    : transport_type(0)
+    , outbound_port(0)
+    , f_outbound_transparent(false)
+    , backdoor(false)
+  {
+  }
+
+  inline HttpAcceptOptions&
+  HttpAcceptOptions::setTransportType(int type) {
+    transport_type =  type;
+    return *this;
+  }
+
+  inline HttpAcceptOptions&
+  HttpAcceptOptions::setOutboundIp(InkInetAddr& ip) {
+    if (ip.isIp4()) outbound_ip4 = ip;
+    else if (ip.isIp6()) outbound_ip6 = ip;
+    return *this;
+  }
+
+  inline HttpAcceptOptions&
+  HttpAcceptOptions::setOutboundIp(ts_ip_endpoint* ip) {
+    if (ip->isIp4()) outbound_ip4 = *ip;
+    else if (ip->isIp6()) outbound_ip6 = *ip;
+    return *this;
+  }
 
+  inline HttpAcceptOptions&
+  HttpAcceptOptions::setOutboundPort(uint16_t port) {
+    outbound_port = port;
+    return *this;
+  }
+
+  inline HttpAcceptOptions&
+  HttpAcceptOptions::setOutboundTransparent(bool flag) {
+    f_outbound_transparent = flag;
+    return *this;
+  }
+
+  inline HttpAcceptOptions&
+  HttpAcceptOptions::setBackdoor(bool flag) {
+    backdoor = flag;
+    return *this;
+  }
+}
+
+/**
+   The continuation mutex is NULL to allow parellel accepts in NT. No
+   state is recorded by the handler and values are required to be set
+   during construction via the @c Options struct and never changed. So
+   a NULL mutex is safe.
+
+   Most of the state is simply passed on to the @c ClientSession after
+   an accept. It is done here because this is the least bad pathway
+   from the top level configuration to the HTTP session.
 */
 
-class HttpAccept: public Continuation
+class HttpAccept: public Continuation, private detail::HttpAcceptOptions
 {
+private:
+  typedef HttpAccept self; ///< Self reference type.
 public:
- HttpAccept(int aattr, bool abackdoor = false)
-   : Continuation(NULL), backdoor(abackdoor), attr(aattr)
+  /** Construction options.
+      Provide an easier to remember typedef for clients.
+  */
+  typedef detail::HttpAcceptOptions Options;
+
+  HttpAccept(Options const& opt = DEFAULT_OPTIONS)
+    : Continuation(0)
+    , detail::HttpAcceptOptions(opt) // copy these.
   {
     SET_HANDLER(&HttpAccept::mainEvent);
     return;
@@ -54,12 +161,12 @@ public:
 
   int mainEvent(int event, void *netvc);
 
+  /// Container for default options.
+  static Options const DEFAULT_OPTIONS;
+
 private:
-    bool backdoor;
-  int attr;
     HttpAccept(const HttpAccept &);
     HttpAccept & operator =(const HttpAccept &);
 };
 
-
 #endif

Modified: trafficserver/traffic/trunk/proxy/http/HttpClientSession.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpClientSession.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpClientSession.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpClientSession.h Fri Jan 27 00:33:31 2012
@@ -143,6 +143,14 @@ private:
 public:
   bool backdoor_connect;
   int hooks_set;
+  /// Local address for outbound connection.
+  InkInetAddr outbound_ip4;
+  /// Local address for outbound connection.
+  InkInetAddr outbound_ip6;
+  /// Local port for outbound connection.
+  uint16_t outbound_port;
+  /// Set outbound connection to transparent.
+  bool f_outbound_transparent;
 
   // for DI. An active connection is one that a request has
   // been successfully parsed (PARSE_DONE) and it remains to

Modified: trafficserver/traffic/trunk/proxy/http/HttpConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpConfig.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpConfig.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpConfig.cc Fri Jan 27 00:33:31 2012
@@ -31,6 +31,7 @@
 #include "ICPProcessor.h"
 #include "P_Net.h"
 #include "P_RecUtils.h"
+#include <records/I_RecHttp.h>
 
 #ifndef min
 #define         min(a,b)        ((a) < (b) ? (a) : (b))
@@ -1131,21 +1132,8 @@ HttpConfig::startup()
     c.proxy_hostname[0] = '\0';
   }
 
-  RecGetRecordString_Xmalloc("proxy.local.incoming_ip_to_bind", &(c.incoming_ip_to_bind));
-
-  if (c.incoming_ip_to_bind) {
-    Debug("ip_binding", "incoming_ip_to_bind: %s", c.incoming_ip_to_bind);
-    if (0 != ink_inet_pton(c.incoming_ip_to_bind, &c.incoming_ip_to_bind_saddr.sa))
-      Warning("Invalid address '%s' for 'proxy.local.incoming_ip_to_bind'", c.incoming_ip_to_bind);
-  }
-
-  RecGetRecordString_Xmalloc("proxy.local.outgoing_ip_to_bind", &(c.outgoing_ip_to_bind));
-
-  if (c.outgoing_ip_to_bind) {
-    Debug("ip_binding", "outgoing_ip_to_bind: %s", c.outgoing_ip_to_bind);
-    if (0 != ink_inet_pton(c.outgoing_ip_to_bind, &c.oride.outgoing_ip_to_bind_saddr))
-      Warning("Invalid address '%s' for 'proxy.local.outgoing_ip_to_bind'", c.outgoing_ip_to_bind);
-  }
+  RecHttpLoadIp("proxy.local.incoming_ip_to_bind", c.inbound_ip4, c.inbound_ip6);
+  RecHttpLoadIp("proxy.local.outgoing_ip_to_bind", c.outbound_ip4, c.outbound_ip6);
 
   HttpEstablishStaticConfigLongLong(c.server_max_connections, "proxy.config.http.server_max_connections");
   HttpEstablishStaticConfigLongLong(c.oride.server_tcp_init_cwnd, "proxy.config.http.server_tcp_init_cwnd");
@@ -1414,8 +1402,12 @@ HttpConfig::reconfigure()
 
   params = NEW(new HttpConfigParams);
 
-  params->incoming_ip_to_bind_saddr = m_master.incoming_ip_to_bind_saddr;
-  ink_inet_copy(&params->oride.outgoing_ip_to_bind_saddr, &m_master.oride.outgoing_ip_to_bind_saddr);
+  params->inbound_ip4 = m_master.inbound_ip4;
+  params->inbound_ip6 = m_master.inbound_ip6;
+
+  params->outbound_ip4 = m_master.outbound_ip4;
+  params->outbound_ip6 = m_master.outbound_ip6;
+
   params->proxy_hostname = ats_strdup(m_master.proxy_hostname);
   params->proxy_hostname_len = (params->proxy_hostname) ? strlen(params->proxy_hostname) : 0;
   params->no_dns_forward_to_parent = INT_TO_BOOL(m_master.no_dns_forward_to_parent);

Modified: trafficserver/traffic/trunk/proxy/http/HttpConfig.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpConfig.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpConfig.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpConfig.h Fri Jan 27 00:33:31 2012
@@ -432,7 +432,6 @@ struct OverridableHttpConfigParams {
        proxy_response_server_string(NULL), proxy_response_server_string_len(0),
        cache_heuristic_lm_factor(0.0), freshness_fuzz_prob(0.0)
   { 
-    ink_zero(outgoing_ip_to_bind_saddr);
   }
 
   // IMPORTANT: All MgmtInt configs should come before any other string / float
@@ -560,11 +559,6 @@ struct OverridableHttpConfigParams {
 
   float cache_heuristic_lm_factor;
   float freshness_fuzz_prob;
-
-  ////////////////////////
-  //  Source IP         //
-  ////////////////////////
-  ts_ip_endpoint outgoing_ip_to_bind_saddr; // This is kinda ugly for now, whatever ...
 };
 
 
@@ -600,10 +594,8 @@ public:
   char *proxy_hostname;
   int proxy_hostname_len;
 
-  char *incoming_ip_to_bind;
-  ts_ip_endpoint incoming_ip_to_bind_saddr;
-
-  char *outgoing_ip_to_bind;
+  InkInetAddr inbound_ip4, inbound_ip6;
+  InkInetAddr outbound_ip4, outbound_ip6;
 
   MgmtInt server_max_connections;
   MgmtInt origin_min_keep_alive_connections; // TODO: This one really ought to be overridable, but difficult right now.
@@ -895,8 +887,6 @@ inline
 HttpConfigParams::HttpConfigParams()
   : proxy_hostname(0),
     proxy_hostname_len(0),
-    incoming_ip_to_bind(0),
-    outgoing_ip_to_bind(0),
     server_max_connections(0),
     origin_min_keep_alive_connections(0),
     parent_proxy_routing_enable(0),
@@ -973,7 +963,6 @@ HttpConfigParams::HttpConfigParams()
     ignore_accept_charset_mismatch(0),
     normalize_ae_gzip(1)
 {
-  ink_zero(incoming_ip_to_bind_saddr);
 }
 
 inline

Modified: trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc Fri Jan 27 00:33:31 2012
@@ -35,9 +35,6 @@
 #include "HttpTunnel.h"
 #include "Tokenizer.h"
 
-HttpEntryPoint *http_open_port_array = NULL;
-HttpEntryPoint *http_other_port_array = NULL;
-
 #ifdef DEBUG
 extern "C"
 {
@@ -76,108 +73,6 @@ struct DumpStats: public Continuation
   }
 };
 
-// Does not modify result->port
-void get_connection_attributes(const char *attr, HttpEntryPoint *result) {
-  int attr_len;
-
-  result->type = SERVER_PORT_DEFAULT;
-  result->domain = AF_INET;
-
-  if (!attr ) return;
-
-  attr_len = strlen(attr);
-
-  if (attr_len > 2) {
-    Warning("too many port attributes: '%s'", attr);
-    return;
-  } else if (attr_len <= 0) {
-    return;
-  }
-
-  switch (*attr) {
-  case 'S' : result->type = SERVER_PORT_SSL; break;
-  case 'C': result->type = SERVER_PORT_COMPRESSED; break;
-  case '<':
-    result->f_outbound_transparent = true;
-    result->type = SERVER_PORT_DEFAULT;
-    break;
-  case '=':
-    result->f_outbound_transparent = true;
-    result->f_inbound_transparent = true;
-    result->type = SERVER_PORT_DEFAULT;
-    break;
-  case '>':
-    result->f_inbound_transparent = true;
-    result->type = SERVER_PORT_DEFAULT;
-    break;
-  case 'X': result->type = SERVER_PORT_DEFAULT; break;
-  case 'T': result->type = SERVER_PORT_BLIND_TUNNEL; break;
-  default: Warning("unknown port attribute '%s'", attr); break;
-  }
-
-  if (attr_len >= 2) {
-    switch (*(attr + 1)) {
-    case '6': result->domain = AF_INET6; break;
-    default: result->domain = AF_INET;
-    }
-  }
-}
-
-
-static HttpEntryPoint *
-parse_http_server_other_ports()
-{
-  int list_entries;
-  int accept_index = 0;
-  int port = 0;
-  char *other_ports_str = NULL;
-  Tokenizer listTok(", ");
-  HttpEntryPoint *additional_ports_array;
-
-  other_ports_str = HTTP_ConfigReadString("proxy.config.http.server_other_ports");
-
-  if (!other_ports_str || *other_ports_str == '\0') {
-    return NULL;
-  }
-
-  list_entries = listTok.Initialize(other_ports_str, SHARE_TOKS);
-
-  if (list_entries <= 0) return 0;
-
-  // Add one so last entry is marked with @a fd of @c NO_FD
-  additional_ports_array = new HttpEntryPoint[list_entries + 1];
-
-  for (int i = 0; i < list_entries; ++i) {
-    HttpEntryPoint* pent = additional_ports_array + accept_index;
-    char const* cur_entry = listTok[i];
-    char* next;
-
-    // Check to see if there is a port attribute
-    char const* attr_str = strchr(cur_entry, ':');
-    if (attr_str != NULL) attr_str = attr_str + 1;
-
-    // Port value
-    port = strtoul(cur_entry, &next, 10);
-    if (next == cur_entry) {
-      Warning("failed to read accept port '%s', discarding", cur_entry);
-      continue;
-    } else if (!(1 <= port || port <= 65535)) {
-      Warning("Port value '%s' out of range, discarding", cur_entry);
-      continue;
-    }
-
-    pent->port = port;
-    get_connection_attributes(attr_str, pent);
-    ++accept_index;
-  }
-
-  ink_assert(accept_index < list_entries + 1);
-
-  additional_ports_array[accept_index].port = -1;
-
-  return additional_ports_array;
-}
-
 HttpAccept *plugin_http_accept = NULL;
 
 /////////////////////////////////////////////////////////////////
@@ -207,7 +102,7 @@ init_HttpProxyServer(void)
   //   port but without going through the operating system
   //
   if (plugin_http_accept == NULL) {
-    plugin_http_accept = NEW(new HttpAccept(SERVER_PORT_DEFAULT, false));
+    plugin_http_accept = NEW(new HttpAccept);
     plugin_http_accept->mutex = new_ProxyMutex();
   }
 #endif
@@ -215,23 +110,12 @@ init_HttpProxyServer(void)
 
 
 void
-start_HttpProxyServer(int fd, int port, int ssl_fd, int accept_threads)
+start_HttpProxyServer(int accept_threads)
 {
   char *dump_every_str = 0;
   static bool called_once = false;
   NetProcessor::AcceptOptions opt;
 
-  ////////////////////////////////
-  // check if accept port is in //
-  // network safe range.        //
-  ////////////////////////////////
-  if ((port<1) || (port> 65535)) {
-
-    ProcessFatal("accept port %d is not between 1 and 65535 ", "please check configuration", port);
-    return;
-  }
-
-
   if ((dump_every_str = getenv("PROXY_DUMP_STATS")) != 0) {
     int dump_every_sec = atoi(dump_every_str);
     eventProcessor.schedule_every(NEW(new DumpStats), HRTIME_SECONDS(dump_every_sec), ET_CALL);
@@ -244,74 +128,47 @@ start_HttpProxyServer(int fd, int port, 
   ink_assert(!called_once);
 
   opt.accept_threads = accept_threads;
-
-  // If ports are already open, just listen on those and ignore other
-  // configuration.
-  if (http_open_port_array) {
-    for ( HttpEntryPoint* pent = http_open_port_array
-        ; ts::NO_FD != pent->fd
-        ; ++pent
-    ) {
-      opt.f_outbound_transparent = pent->f_outbound_transparent;
-      opt.f_inbound_transparent = pent->f_inbound_transparent;
-      netProcessor.main_accept(NEW(new HttpAccept(pent->type)), pent->fd, NULL, NULL, false, false, opt);
-    }
-  } else {
-    static HttpPortTypes type = SERVER_PORT_DEFAULT;
-    char *attr_string = 0;
-    opt.port = port;
-
-    // function can be called several times : do memory allocation once
-    
-    REC_ReadConfigStringAlloc(attr_string, "proxy.config.http.server_port_attr");
-    REC_ReadConfigInteger(opt.recv_bufsize, "proxy.config.net.sock_recv_buffer_size_in");
-    REC_ReadConfigInteger(opt.send_bufsize, "proxy.config.net.sock_send_buffer_size_in");
-    REC_ReadConfigInteger(opt.sockopt_flags, "proxy.config.net.sock_option_flag_in");
-
-    if (attr_string) {
-      HttpEntryPoint attr;
-      get_connection_attributes(attr_string, &attr);
-      type = attr.type;
-      opt.domain = attr.domain;
-      Debug("http_tproxy", "Primary listen socket transparency is %s\n",
-        attr.f_inbound_transparent &&  attr.f_outbound_transparent ? "bidirectional"
-        : attr.f_inbound_transparent ? "inbound"
-        : attr.f_outbound_transparent ? "outbound"
-        : "off"
-      );
-      opt.f_outbound_transparent = attr.f_outbound_transparent;
-      opt.f_inbound_transparent = attr.f_inbound_transparent;
-      ats_free(attr_string);
-    }
-
-    netProcessor.main_accept(NEW(new HttpAccept(type)), fd,  NULL, NULL, false, false, opt);
-
-    http_other_port_array = parse_http_server_other_ports();
-    if (http_other_port_array) {
-      for (int i = 0; http_other_port_array[i].port != -1; i++) {
-        HttpEntryPoint & e = http_other_port_array[i];
-        if ((e.port<1) || (e.port> 65535))
-          Warning("additional port out of range ignored: %d", e.port);
-        else {
-          opt.port = e.port;
-          opt.domain = e.domain;
-          opt.f_outbound_transparent = e.f_outbound_transparent;
-          opt.f_inbound_transparent = e.f_inbound_transparent;
-          netProcessor.main_accept(NEW(new HttpAccept(e.type)), e.fd, NULL, NULL, false, false, opt);
-        }
+  REC_ReadConfigInteger(opt.recv_bufsize, "proxy.config.net.sock_recv_buffer_size_in");
+  REC_ReadConfigInteger(opt.send_bufsize, "proxy.config.net.sock_send_buffer_size_in");
+  SslConfigParams *sslParam = sslTerminationConfig.acquire();
+  
+  for ( int i = 0 , n = HttpProxyPort::global().length() ; i < n ; ++i ) {
+    HttpProxyPort& p = HttpProxyPort::global()[i];
+    HttpAccept::Options ha_opt;
+
+    opt.f_inbound_transparent = p.m_inbound_transparent_p;
+    opt.ip_family = p.m_family;
+    opt.local_port = p.m_port;
+
+    ha_opt.f_outbound_transparent = p.m_outbound_transparent_p;
+    ha_opt.transport_type = p.m_type;
+
+    if (p.m_inbound_ip.isValid())
+      opt.local_ip = p.m_inbound_ip;
+    else if (AF_INET6 == p.m_family && HttpConfig::m_master.inbound_ip6.isIp6())
+      opt.local_ip = HttpConfig::m_master.inbound_ip6;
+    else if (AF_INET == p.m_family && HttpConfig::m_master.inbound_ip4.isIp4())
+      opt.local_ip = HttpConfig::m_master.inbound_ip4;
+
+    if (p.m_outbound_ip4.isValid())
+      ha_opt.outbound_ip4 = p.m_outbound_ip4;
+    else if (HttpConfig::m_master.outbound_ip4.isValid())
+      ha_opt.outbound_ip4 = HttpConfig::m_master.outbound_ip4;
+
+    if (p.m_outbound_ip6.isValid())
+      ha_opt.outbound_ip6 = p.m_outbound_ip6;
+    else if (HttpConfig::m_master.outbound_ip6.isValid())
+      ha_opt.outbound_ip6 = HttpConfig::m_master.outbound_ip6;
+
+    if (HttpProxyPort::TRANSPORT_SSL == p.m_type) {
+      if (sslParam->getTerminationMode() & sslParam->SSL_TERM_MODE_CLIENT) {
+        sslNetProcessor.main_accept(NEW(new HttpAccept(ha_opt)), p.m_fd, opt);
       }
+    } else {
+      netProcessor.main_accept(NEW(new HttpAccept(ha_opt)), p.m_fd, opt);
     }
   }
 
-  SslConfigParams *sslParam = sslTerminationConfig.acquire();
-
-  if (sslParam->getTerminationMode() & sslParam->SSL_TERM_MODE_CLIENT) {
-    opt.reset();
-    opt.port = sslParam->getAcceptPort();
-    opt.accept_threads = accept_threads;
-    sslNetProcessor.main_accept(NEW(new HttpAccept(SERVER_PORT_SSL)), ssl_fd, 0, 0, false, false, opt);
-  }
-
   sslTerminationConfig.release(sslParam);
 
 #ifdef DEBUG
@@ -330,10 +187,13 @@ void
 start_HttpProxyServerBackDoor(int port, int accept_threads)
 {
   NetProcessor::AcceptOptions opt;
+  HttpAccept::Options ha_opt;
 
-  opt.port = port;
+  opt.local_port = port;
   opt.accept_threads = accept_threads;
+  opt.localhost_only = true;
+  ha_opt.backdoor = true;
   
   // The backdoor only binds the loopback interface
-  netProcessor.main_accept(NEW(new HttpAccept(SERVER_PORT_DEFAULT, true)), NO_FD, 0, 0, false, true, opt);
+  netProcessor.main_accept(NEW(new HttpAccept(ha_opt)), NO_FD, opt);
 }

Modified: trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.h?rev=1236470&r1=1236469&r2=1236470&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.h Fri Jan 27 00:33:31 2012
@@ -23,12 +23,9 @@
 
 void init_HttpProxyServer(void);
 
-/**
-  fd is either a file descriptor which has already been opened for
-  the purpose of accepting proxy connections, or NO_FD (-1) if a file
-  descriptor should be opened.
-
+/** Start the proxy server. 
+    The ports are contained in the HttpProxyPort global data.
 */
-void start_HttpProxyServer(int fd, int port, int ssl_fd, int accept_threads = 0);
+void start_HttpProxyServer(int accept_threads = 0);
 
 void start_HttpProxyServerBackDoor(int port, int accept_threads = 0);



Mime
View raw message