diff --git a/doc/developer-guide/api/functions/TSVConnFdGet.en.rst b/doc/developer-guide/api/functions/TSVConnFdGet.en.rst new file mode 100644 index 00000000000..7e5a808115f --- /dev/null +++ b/doc/developer-guide/api/functions/TSVConnFdGet.en.rst @@ -0,0 +1,34 @@ +.. Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright + ownership. The ASF licenses this file to you under the Apache + License, Version 2.0 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of + the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + +TSVConnFdGet +============ + +Synopsis +-------- + +.. code-block:: cpp + + #include + +.. c:function:: int TSVConnFdGet(TSVConn vconnp) + + +Description +----------- +Returns the file descriptor associated with the network connection :arg:`sslp`. +It returns -1 on error. diff --git a/include/ts/ts.h b/include/ts/ts.h index 3191f236173..6d94342a2d6 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -1315,6 +1315,8 @@ namespace c TSReturnCode TSVConnTunnel(TSVConn sslp); /* Return the SSL object associated with the connection */ TSSslConnection TSVConnSslConnectionGet(TSVConn sslp); + /* Return the file descriptoer associated with the connection */ + int TSVConnFdGet(TSVConn sslp); /* Return the intermediate X509StoreCTX object that references the certificate being validated */ TSSslVerifyCTX TSVConnSslVerifyCTXGet(TSVConn sslp); /* Fetch a SSL context from the global lookup table */ diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index 035aaa64823..a4ab9709fba 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -9132,6 +9132,14 @@ tsapi::c::TSVConnSslConnectionGet(TSVConn sslp) return ssl; } +int +tsapi::c::TSVConnFdGet(TSVConn vconnp) +{ + sdk_assert(sdk_sanity_check_null_ptr(vconnp) == TS_SUCCESS); + NetVConnection *vc = reinterpret_cast(vconnp); + return vc->get_socket(); +} + const char * tsapi::c::TSVConnSslSniGet(TSVConn sslp, int *length) {