Standard preamble:
========================================================================
..
.... Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.
If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.
Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================
Title "OSSL_TRACE_SET_CHANNEL 3ossl"
way too many mistakes in technical documents.
The trace output is divided into categories which can be enabled individually. Every category can be enabled individually by attaching a so called \fItrace channel to it, which in the simplest case is just a \s-1BIO\s0 object to which the application can write the tracing output for this category. Alternatively, the application can provide a tracer callback in order to get more finegrained trace information. This callback will be wrapped internally by a dedicated \s-1BIO\s0 object.
For the tracing code, both trace channel types are indistinguishable. These are called a simple trace channel and a callback trace channel, respectively.
\fBOSSL_trace_set_prefix() and OSSL_trace_set_suffix() can be used to add an extra line for each channel, to be output before and after group of tracing output. What constitutes an output group is decided by the code that produces the output. The lines given here are considered immutable; for more dynamic tracing prefixes, consider setting a callback with \fBOSSL_trace_set_callback() instead.
\fBOSSL_trace_set_callback() is used to enable the given trace \fIcategory by giving it the tracer callback cb with the associated data data, which will simply be passed through to cb whenever it's called. The callback function is internally wrapped by a dedicated \s-1BIO\s0 object, the so called callback trace channel. This should be used when it's desirable to do form the trace output to something suitable for application needs where a prefix and suffix line aren't enough.
\fBOSSL_trace_set_channel() and OSSL_trace_set_callback() are mutually exclusive, calling one of them will clear whatever was set by the previous call.
Calling OSSL_trace_set_channel() with \s-1NULL\s0 for channel or \fBOSSL_trace_set_callback() with \s-1NULL\s0 for cb disables tracing for the given category.
The possible control numbers are:
There is also \s-1OSSL_TRACE_CATEGORY_ALL\s0, which works as a fallback and can be used to get all trace output.
Note, however, that in this case all trace output will effectively be associated with the '\s-1ALL\s0' category, which is undesirable if the application intends to include the category name in the trace output. In this case it is better to register separate channels for each trace category instead.
.Vb 3 int foo = 42; const char bar[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; \& OSSL_TRACE_BEGIN(TLS) { BIO_puts(trc_out, "foo: "); BIO_printf(trc_out, "%d\en", foo); BIO_dump(trc_out, bar, sizeof(bar)); } OSSL_TRACE_END(TLS); .Ve
.Vb 6 int main(int argc, char *argv[]) { BIO *err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); OSSL_trace_set_channel(OSSL_TRACE_CATEGORY_SSL, err); OSSL_trace_set_prefix(OSSL_TRACE_CATEGORY_SSL, "BEGIN TRACE[TLS]"); OSSL_trace_set_suffix(OSSL_TRACE_CATEGORY_SSL, "END TRACE[TLS]"); \& /* ... work ... */ } .Ve
When the trace producing code above is performed, this will be output on standard error:
.Vb 4 BEGIN TRACE[TLS] foo: 42 0000 - 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................ END TRACE[TLS] .Ve
.Vb 5 static size_t cb(const char *buf, size_t cnt, int category, int cmd, void *vdata) { BIO *bio = vdata; const char *label = NULL; \& switch (cmd) { case OSSL_TRACE_CTRL_BEGIN: label = "BEGIN"; break; case OSSL_TRACE_CTRL_END: label = "END"; break; } \& if (label != NULL) { union { pthread_t tid; unsigned long ltid; } tid; \& tid.tid = pthread_self(); BIO_printf(bio, "%s TRACE[%s]:%lx\en", label, OSSL_trace_get_category_name(category), tid.ltid); } return (size_t)BIO_puts(bio, buf); } \& int main(int argc, char *argv[]) { BIO *err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); OSSL_trace_set_callback(OSSL_TRACE_CATEGORY_SSL, cb, err); \& /* ... work ... */ } .Ve
The output is almost the same as for the simple example above.
.Vb 4 BEGIN TRACE[TLS]:7f9eb0193b80 foo: 42 0000 - 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................ END TRACE[TLS]:7f9eb0193b80 .Ve
When the library is built with tracing disabled, the macro \fB\s-1OPENSSL_NO_TRACE\s0 is defined in <openssl/opensslconf.h> and all functions described here are inoperational, i.e. will do nothing.
Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.