.\" Man page generated from reStructuredText. . .TH "TSCLIENTPROTOCOLSTACK" "3ts" "Mar 08, 2019" "7.1" "Apache Traffic Server" .SH NAME TSClientProtocolStack \- TSClientProtocolStack API function . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp \fI#include \fP .INDENT 0.0 .TP .B TSReturnCode TSHttpTxnClientProtocolStackGet(TSHttpTxn\fI\ txnp\fP, int\fI\ n\fP, char const**\fI\ result\fP, int*\fI\ actual\fP) .UNINDENT .INDENT 0.0 .TP .B TSReturnCode TSHttpSsnClientProtocolStackGet(TSHttpSsn\fI\ ssnp\fP, int\fI\ n\fP, char const**\fI\ result\fP, int*\fI\ actual\fP) .UNINDENT .INDENT 0.0 .TP .B char const* TSHttpTxnClientProtocolStackContains(TSHttpTxn\fI\ txnp\fP) .UNINDENT .INDENT 0.0 .TP .B char const* TSHttpSsnClientProtocolStackContains(TSHttpSsn\fI\ ssnp\fP) .UNINDENT .INDENT 0.0 .TP .B char const* TSNormalizedProtocolTag(char const*\fI\ tag\fP) .UNINDENT .INDENT 0.0 .TP .B char const* TSRegisterProtocolTag(char const*\fI\ tag\fP) .UNINDENT .SH DESCRIPTION .sp These functions are used to explore the protocol stack of the client (user agent) connection to Traffic Server\&. The functions \fI\%TSHttpTxnClientProtocolStackGet()\fP and \fI\%TSHttpSsnClientProtocolStackGet()\fP can be used to retrieve the entire protocol stack for the user agent connection. \fI\%TSHttpTxnClientProtocolStackContains()\fP and \fI\%TSHttpSsnClientProtocolStackContains()\fP will check for a specific protocol \fItag\fP being present in the stack. .sp Each protocol is represented by tag which is a null terminated string. A particular tag will always be returned as the same character pointer and so protocols can be reliably checked with pointer comparisons. \fI\%TSNormalizedProtocolTag()\fP will return this character pointer for a specific \fItag\fP\&. A return value of \fBNULL\fP indicates the provided \fItag\fP is not registered as a known protocol tag. \fI\%TSRegisterProtocolTag()\fP registers the \fItag\fP and then returns its normalized value. This is useful for plugins that provide custom protocols for user agents. .sp The protocols are ordered from higher level protocols to the lower level ones on which the higher operate. For instance a stack might look like "http/1.1,tls/1.2,tcp,ipv4". For \fI\%TSHttpTxnClientProtocolStackGet()\fP and \fI\%TSHttpSsnClientProtocolStackGet()\fP these values are placed in the array \fIresult\fP\&. \fIcount\fP is the maximum number of elements of \fIresult\fP that may be modified by the function call. If \fIactual\fP is not \fBNULL\fP then the actual number of elements in the protocol stack will be returned. If this is equal or less than \fIcount\fP then all elements were returned. If it is larger then some layers were omitted from \fIresult\fP\&. If the full stack is required \fIactual\fP can be used to resize \fIresult\fP to be sufficient to hold all of the elements and the function called again with updated \fIcount\fP and \fIresult\fP\&. In practice the maximum number of elements will is almost certain to be less than 10 which therefore should suffice. These functions return \fBTS_SUCCESS\fP on success and \fBTS_ERROR\fP on failure which should only occurr if \fItxnp\fP or \fIssnp\fP are invalid. .sp The \fI\%TSHttpTxnClientProtocolStackContains()\fP and \fI\%TSHttpSsnClientProtocolStackContains()\fP functions are provided for the convenience when only the presence of a protocol is of interest, not its location or the presence of other protocols. These functions return NULL if the protocol \fItag\fP is not present, and a pointer to the normalized tag if it is present. The strings are matched with an anchor prefix search, as with debug tags. For instance if \fItag\fP is "tls" then it will match "tls/1.2" or "tls/1.3". This makes checking for TLS or IP more convenient. If more precision is required the entire protocol stack can be retrieved and processed more thoroughly. .sp The protocol tags defined by Traffic Server\&. .TS center; |l|l|. _ T{ Protocol T} T{ Tag T} _ T{ HTTP/1.1 T} T{ http/1.1 T} _ T{ HTTP/1.0 T} T{ http/1.0 T} _ T{ HTTP/2 T} T{ h2 T} _ T{ WebSocket T} T{ ws T} _ T{ TLS 1.3 T} T{ tls/1.3 T} _ T{ TLS 1.2 T} T{ tls/1.2 T} _ T{ TLS 1.1 T} T{ tls/1.1 T} _ T{ TLS 1.0 T} T{ tls/1.0 T} _ T{ TCP T} T{ tcp T} _ T{ UDP T} T{ udp T} _ T{ IPv4 T} T{ ipv4 T} _ T{ IPv6 T} T{ ipv6 T} _ T{ QUIC T} T{ quic T} _ .TE .SS Examples .sp The example below is excerpted from \fIexample/protocol\-stack/protocol\-stack.cc\fP in the Traffic Server source distribution. It demonstrates how to use \fI\%TSHttpTxnClientProtocolStackGet()\fP and \fI\%TSHttpTxnClientProtocolStackContains()\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C static int proto_stack_cb(TSCont contp ATS_UNUSED, TSEvent event, void *edata) { TSHttpTxn txnp = (TSHttpTxn)edata; const char *results[10]; int count = 0; TSDebug(DEBUG_TAG, "Protocols:"); TSHttpTxnClientProtocolStackGet(txnp, 10, results, &count); for (int i = 0; i < count; i++) { TSDebug(DEBUG_TAG, "\et%d: %s", i, results[i]); } const char *ret_tag = TSHttpTxnClientProtocolStackContains(txnp, "h2"); TSDebug(DEBUG_TAG, "Stack %s HTTP/2", ret_tag != nullptr ? "contains" : "does not contain"); TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); return 0; } .ft P .fi .UNINDENT .UNINDENT .SH COPYRIGHT 2019, dev@trafficserver.apache.org .\" Generated by docutils manpage writer. .