blob: c3866bf04d3a18015571f25ea97de3b4e1ccf5ae [file]
.. 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.
.. include:: ../../../common.defs
.. default-domain:: cpp
TSHttpTxnClientAddrGet
**********************
Synopsis
========
.. code-block:: cpp
#include <ts/ts.h>
.. function:: struct sockaddr const * TSHttpTxnClientAddrGet(TSHttpTxn txnp)
Description
===========
Return the socket address of the client that initiated the transaction
:arg:`txnp`. The returned pointer references storage owned by |TS| and is
only valid for the duration of the current callback; plugins that need to
keep the value across callbacks must copy it into their own storage.
The returned ``struct sockaddr`` is address-family agnostic. Inspect the
``sa_family`` field (or use the ``ats_ip_*`` helpers) to dispatch on IPv4
versus IPv6.
If the listener that accepted the connection has the ``pp-clnt`` flag set
and a PROXY Protocol header was successfully parsed, the returned address
is the PROXY-Protocol source address rather than the immediate TCP peer.
Without ``pp-clnt`` the returned address is the immediate TCP peer even
when PROXY Protocol is enabled. See :ref:`Proxy Protocol <proxy-protocol>`
for the full enumeration of surfaces gated by ``pp-clnt``.
Return Value
============
A pointer to the client address, or ``nullptr`` if :arg:`txnp` is invalid
or no client address is available.
See Also
========
:manpage:`TSAPI(3ts)`,
:func:`TSHttpSsnClientAddrGet`,
:func:`TSNetVConnClientAddrGet`