Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions doc/developer-guide/api/functions/TSVConnFdGet.en.rst
Original file line number Diff line number Diff line change
@@ -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 <ts/ts.h>

.. c:function:: int TSVConnFdGet(TSVConn vconnp)


Description
-----------
Returns the file descriptor associated with the network connection :arg:`sslp`.
It returns -1 on error.
2 changes: 2 additions & 0 deletions include/ts/ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 8 additions & 0 deletions src/traffic_server/InkAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9132,6 +9132,14 @@ tsapi::c::TSVConnSslConnectionGet(TSVConn sslp)
return ssl;
}

int
tsapi::c::TSVConnFdGet(TSVConn vconnp)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kinda feels that we should do the normal assertion on the vconnp here, rather than checking the nullptr after the casting. Like the common pattern is

sdk_assert(sdk_sanity_check_null_ptr((void *)vconnp) == TS_SUCCESS);

I guess I'm fine checking the vconnp explicitly as well, but probably should be done before the cast.

sdk_assert(sdk_sanity_check_null_ptr(vconnp) == TS_SUCCESS);
NetVConnection *vc = reinterpret_cast<NetVConnection *>(vconnp);
return vc->get_socket();
}

const char *
tsapi::c::TSVConnSslSniGet(TSVConn sslp, int *length)
{
Expand Down