You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by us...@apache.org on 2013/07/09 00:17:54 UTC

git commit: TS-2007 Add TSNetConnectTransparent API for transparent net connections

Updated Branches:
  refs/heads/master d0333c576 -> 667cca193


TS-2007 Add TSNetConnectTransparent API for transparent net connections


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/667cca19
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/667cca19
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/667cca19

Branch: refs/heads/master
Commit: 667cca19347c4009767f94edbaac788b3cb2851d
Parents: d0333c5
Author: Uri Shachar <us...@apache.org>
Authored: Tue Jul 9 01:15:50 2013 +0300
Committer: Uri Shachar <us...@apache.org>
Committed: Tue Jul 9 01:15:50 2013 +0300

----------------------------------------------------------------------
 CHANGES                     |  2 ++
 proxy/InkAPI.cc             | 19 +++++++++++++++++++
 proxy/api/ts/experimental.h | 28 ++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/667cca19/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6249fe7..52a2d08 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache Traffic Server 3.3.5
 
 
+  *) [TS-2007] Add TSNetConnectTransparent API for transparent net connections
+
   *) [TS-1991] clang complaint: logical not is only applied to the left hand
    side of this comparison.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/667cca19/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index f598b47..209dd0b 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -6484,6 +6484,25 @@ TSNetConnect(TSCont contp, sockaddr const* addr)
 }
 
 TSAction
+TSNetConnectTransparent(TSCont contp, sockaddr const* client_addr, sockaddr const* server_addr)
+{
+  sdk_assert(sdk_sanity_check_continuation(contp) == TS_SUCCESS);
+  sdk_assert(ats_is_ip(server_addr));
+  sdk_assert(ats_ip_are_compatible(client_addr, server_addr));
+
+  NetVCOptions opt;
+  opt.addr_binding = NetVCOptions::FOREIGN_ADDR;
+  opt.local_ip.assign(client_addr);
+  opt.local_port = ats_ip_port_host_order(client_addr);
+
+  FORCE_PLUGIN_MUTEX(contp);
+
+  return reinterpret_cast<TSAction>(
+    netProcessor.connect_re(reinterpret_cast<INKContInternal*>(contp), server_addr, &opt)
+  );
+}
+
+TSAction
 TSNetAccept(TSCont contp, int port, int domain, int accept_threads)
 {
   NetProcessor::AcceptOptions opt;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/667cca19/proxy/api/ts/experimental.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/experimental.h b/proxy/api/ts/experimental.h
index c8945c1..08537ae 100644
--- a/proxy/api/ts/experimental.h
+++ b/proxy/api/ts/experimental.h
@@ -215,6 +215,34 @@ extern "C"
   tsapi int TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp);
 
 
+  /**
+      Opens a network connection to the host specified by the 'to' sockaddr
+      spoofing the client addr to equal the 'from' sockaddr.
+      If the connection is successfully opened, contp
+      is called back with the event TS_EVENT_NET_CONNECT and the new
+      network vconnection will be passed in the event data parameter.
+      If the connection is not successful, contp is called back with
+      the event TS_EVENT_NET_CONNECT_FAILED.
+
+      Note: It is possible to receive TS_EVENT_NET_CONNECT
+      even if the connection failed, because of the implementation of
+      network sockets in the underlying operating system. There is an
+      exception: if a plugin tries to open a connection to a port on
+      its own host machine, then TS_EVENT_NET_CONNECT is sent only
+      if the connection is successfully opened. In general, however,
+      your plugin needs to look for an TS_EVENT_VCONN_WRITE_READY to
+      be sure that the connection is successfully opened.
+
+      @return TSAction which allows you to check if the connection is complete,
+        or cancel the attempt to connect.
+
+   */
+  tsapi TSAction TSNetConnectTransparent(TSCont contp, /**< continuation that is called back when the attempted net connection either succeeds or fails. */
+                                         struct sockaddr const* from, /**< Address to spoof as connection origin */
+                                         struct sockaddr const* to /**< Address to which to connect. */
+  );
+
+
   /* =====  Matcher Utils =====  */
 #define               TS_MATCHER_LINE_INVALID 0
   typedef struct tsapi_matcheline* TSMatcherLine;