trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1236915 - in /trafficserver/traffic/trunk: CHANGES proxy/InkAPI.cc proxy/PluginVC.cc proxy/PluginVC.h proxy/api/ts/ts.h.in proxy/http/HttpProxyServerMain.cc
Date Fri, 27 Jan 2012 22:54:45 GMT
Author: amc
Date: Fri Jan 27 22:54:44 2012
New Revision: 1236915

URL: http://svn.apache.org/viewvc?rev=1236915&view=rev
Log:
TS-1089: Added API for creating transparent connections (via PluginVC).

Modified:
    trafficserver/traffic/trunk/CHANGES
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/PluginVC.cc
    trafficserver/traffic/trunk/proxy/PluginVC.h
    trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
    trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc

Modified: trafficserver/traffic/trunk/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/CHANGES?rev=1236915&r1=1236914&r2=1236915&view=diff
==============================================================================
--- trafficserver/traffic/trunk/CHANGES (original)
+++ trafficserver/traffic/trunk/CHANGES Fri Jan 27 22:54:44 2012
@@ -4,6 +4,8 @@ Changes with Apache Traffic Server 3.1.2
    parameter (int *bytes) from the prototype in <ts/ts.h>.
    Author: Alistair Stevenson
 
+  *) [TS-1089] Added TSHttpConnectTransparent.
+
   *) [TS-1088] Added TSHttpTxnOutgoingTransparencySet to API to
    control outbound transparency.
 

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1236915&r1=1236914&r2=1236915&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Fri Jan 27 22:54:44 2012
@@ -5988,22 +5988,20 @@ TSHttpAltInfoQualitySet(TSHttpAltInfo in
 }
 
 extern HttpAccept *plugin_http_accept;
+extern HttpAccept *plugin_http_transparent_accept;
 
 TSVConn
 TSHttpConnect(sockaddr const* addr)
 {
   sdk_assert(addr);
 
-  in_addr_t ip = ink_inet_ip4_addr_cast(addr);
-  uint16_t port = ink_inet_get_port(addr);
-
-  sdk_assert(ip);
-  sdk_assert(port);
+  sdk_assert(ink_inet_is_ip(addr));
+  sdk_assert(ink_inet_port_cast(addr));
 
   if (plugin_http_accept) {
     PluginVCCore *new_pvc = PluginVCCore::alloc();
 
-    new_pvc->set_active_addr(ip, port);
+    new_pvc->set_active_addr(addr);
     new_pvc->set_accept_cont(plugin_http_accept);
 
     PluginVC *return_vc = new_pvc->connect();
@@ -6022,6 +6020,42 @@ TSHttpConnect(sockaddr const* addr)
   return NULL;
 }
 
+TSVConn
+TSHttpConnectTransparent(sockaddr const* client_addr, sockaddr const* server_addr)
+{
+  sdk_assert(ink_inet_is_ip(client_addr));
+  sdk_assert(ink_inet_is_ip(server_addr));
+  sdk_assert(!ink_inet_is_any(client_addr));
+  sdk_assert(ink_inet_port_cast(client_addr));
+  sdk_assert(!ink_inet_is_any(server_addr));
+  sdk_assert(ink_inet_port_cast(server_addr));
+
+  if (plugin_http_transparent_accept) {
+    PluginVCCore *new_pvc = PluginVCCore::alloc();
+
+    // set active address expects host ordering and the above casts do not
+    // swap when it is required
+    new_pvc->set_active_addr(client_addr);
+    new_pvc->set_passive_addr(server_addr);
+    new_pvc->set_transparent(true, true);
+    new_pvc->set_accept_cont(plugin_http_transparent_accept);
+
+    PluginVC *return_vc = new_pvc->connect();
+
+    if (return_vc != NULL) {
+      PluginVC* other_side = return_vc->get_other_side();
+
+      if(other_side != NULL) {
+        other_side->set_is_internal_request(true);
+      }
+    }
+
+    return reinterpret_cast<TSVConn>(return_vc);
+  }
+
+  return NULL;
+}
+
 /* Actions */
 void
 TSActionCancel(TSAction actionp)

Modified: trafficserver/traffic/trunk/proxy/PluginVC.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/PluginVC.cc?rev=1236915&r1=1236914&r2=1236915&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/PluginVC.cc (original)
+++ trafficserver/traffic/trunk/proxy/PluginVC.cc Fri Jan 27 22:54:44 2012
@@ -1151,12 +1151,24 @@ PluginVCCore::set_passive_addr(in_addr_t
 }
 
 void
+PluginVCCore::set_passive_addr(sockaddr const* ip)
+{
+  passive_addr_struct.assign(ip);
+}
+
+void
 PluginVCCore::set_active_addr(in_addr_t ip, int port)
 {
   ink_inet_ip4_set(&active_addr_struct, htonl(ip), htons(port));
 }
 
 void
+PluginVCCore::set_active_addr(sockaddr const* ip)
+{
+  active_addr_struct.assign(ip);
+}
+
+void
 PluginVCCore::set_passive_data(void *data)
 {
   passive_data = data;
@@ -1168,6 +1180,14 @@ PluginVCCore::set_active_data(void *data
   active_data = data;
 }
 
+void
+PluginVCCore::set_transparent(bool passive_side, bool active_side)
+{
+  passive_vc.set_is_transparent(passive_side);
+  active_vc.set_is_transparent(active_side);
+}
+
+
 /*************************************************************
  *
  *   REGRESSION TEST STUFF

Modified: trafficserver/traffic/trunk/proxy/PluginVC.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/PluginVC.h?rev=1236915&r1=1236914&r2=1236915&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/PluginVC.h (original)
+++ trafficserver/traffic/trunk/proxy/PluginVC.h Fri Jan 27 22:54:44 2012
@@ -179,18 +179,28 @@ public:
 
   /// Set the active address.
   void set_active_addr(
-    in_addr_t ip, ///< IPv4 address in host order.
-    int port ///< IP Port in host order.
-  );
+                       in_addr_t ip, ///< IPv4 address in host order.
+                       int port ///< IP Port in host order.
+                       );
+  /// Set the active address and port.
+  void set_active_addr(
+                       sockaddr const *ip ///< Address and port used.
+                       );
+  /// Set the passive address.
+  void set_passive_addr(
+                        in_addr_t ip, ///< IPv4 address in host order.
+                        int port ///< IP port in host order.
+                        );
   /// Set the passive address.
   void set_passive_addr(
-    in_addr_t ip, ///< IPv4 address in host order.
-    int port ///< IP port in host order.
-  );
+                        sockaddr const* ip ///< Address and port.
+                        );
 
   void set_active_data(void *data);
   void set_passive_data(void *data);
 
+  void set_transparent(bool passive_side, bool active_side);
+
 private:
 
   void destroy();

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h.in?rev=1236915&r1=1236914&r2=1236915&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h.in (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h.in Fri Jan 27 22:54:44 2012
@@ -2421,6 +2421,23 @@ extern "C"
 
    */
   tsapi TSVConn TSHttpConnect(struct sockaddr const* addr);
+  
+    /* --------------------------------------------------------------------------
+     Initiate Transparent Http Connection */
+  /**
+      Allows the plugin to initiate a transparent http connection. This operates
+      identically to TSHttpConnect except that it is treated as an intercepted
+      transparent connection by the session and transaction state machines.
+
+      @param client_addr the address that the resulting connection will be seen as
+      	coming from
+      @param server_addr the address that the resulting connection will be seen as
+      	attempting to connect to when intercepted
+      @param vc will be set to point to the new TSVConn on success.
+      
+   */
+  tsapi TSVConn TSHttpConnectTransparent(struct sockaddr const* client_addr, struct sockaddr
const * server_addr);
+  
   tsapi void TSFetchUrl(const char* request,int request_len, struct sockaddr const* addr,
TSCont contp, TSFetchWakeUpOptions callback_options,TSFetchEvent event);
   tsapi void TSFetchPages(TSFetchUrlParams_t* params);
 

Modified: trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc?rev=1236915&r1=1236914&r2=1236915&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpProxyServerMain.cc Fri Jan 27 22:54:44 2012
@@ -74,6 +74,7 @@ struct DumpStats: public Continuation
 };
 
 HttpAccept *plugin_http_accept = NULL;
+HttpAccept *plugin_http_transparent_accept = 0;
 
 /////////////////////////////////////////////////////////////////
 //
@@ -105,6 +106,13 @@ init_HttpProxyServer(void)
     plugin_http_accept = NEW(new HttpAccept);
     plugin_http_accept->mutex = new_ProxyMutex();
   }
+  // Same as plugin_http_accept except outbound transparent.
+  if (! plugin_http_transparent_accept) {
+    HttpAccept::Options ha_opt;
+    ha_opt.setOutboundTransparent(true);
+    plugin_http_transparent_accept = NEW(new HttpAccept(ha_opt));
+    plugin_http_transparent_accept->mutex = new_ProxyMutex();
+  }
 #endif
 }
 



Mime
View raw message