Debian Codegraph @

upstream/debian-unstable/man3/BIO_set_callback.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "BIO_SET_CALLBACK 3SSL"
58 .TH BIO_SET_CALLBACK 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 BIO_set_callback_ex, BIO_get_callback_ex, BIO_set_callback, BIO_get_callback,
65 BIO_set_callback_arg, BIO_get_callback_arg, BIO_debug_callback,
66 BIO_debug_callback_ex, BIO_callback_fn_ex, BIO_callback_fn
67 \&\- BIO callback functions
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& #include <openssl/bio.h>
72 \&
73 \& typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,
74 \& size_t len, int argi,
75 \& long argl, int ret, size_t *processed);
76 \&
77 \& void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);
78 \& BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);
79 \&
80 \& void BIO_set_callback_arg(BIO *b, char *arg);
81 \& char *BIO_get_callback_arg(const BIO *b);
82 \&
83 \& long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len,
84 \& int argi, long argl, int ret, size_t *processed);
85 .Ve
86 .PP
87 The following functions have been deprecated since OpenSSL 3.0, and can be
88 hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
89 see \fBopenssl_user_macros\fR\|(7):
90 .PP
91 .Vb 6
92 \& typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
93 \& long argl, long ret);
94 \& void BIO_set_callback(BIO *b, BIO_callback_fn cb);
95 \& BIO_callback_fn BIO_get_callback(const BIO *b);
96 \& long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
97 \& long argl, long ret);
98 \&
99 \& typedef struct bio_mmsg_cb_args_st {
100 \& BIO_MSG *msg;
101 \& size_t stride, num_msg;
102 \& uint64_t flags;
103 \& size_t *msgs_processed;
104 \& } BIO_MMSG_CB_ARGS;
105 .Ve
106 .SH DESCRIPTION
107 .IX Header "DESCRIPTION"
108 \&\fBBIO_set_callback_ex()\fR and \fBBIO_get_callback_ex()\fR set and retrieve the BIO
109 callback. The callback is called during most high-level BIO operations. It can
110 be used for debugging purposes to trace operations on a BIO or to modify its
111 operation.
112 .PP
113 \&\fBBIO_set_callback()\fR and \fBBIO_get_callback()\fR set and retrieve the old format BIO
114 callback. New code should not use these functions, but they are retained for
115 backwards compatibility. Any callback set via \fBBIO_set_callback_ex()\fR will get
116 called in preference to any set by \fBBIO_set_callback()\fR.
117 .PP
118 \&\fBBIO_set_callback_arg()\fR and \fBBIO_get_callback_arg()\fR are macros which can be
119 used to set and retrieve an argument for use in the callback.
120 .PP
121 \&\fBBIO_debug_callback_ex()\fR is a standard debugging callback which prints
122 out information relating to each BIO operation. If the callback
123 argument is set it is interpreted as a BIO to send the information
124 to, otherwise stderr is used. The \fBBIO_debug_callback()\fR function is the
125 deprecated version of the same callback for use with the old callback
126 format \fBBIO_set_callback()\fR function.
127 .PP
128 BIO_callback_fn_ex is the type of the callback function and BIO_callback_fn
129 is the type of the old format callback function. The meaning of each argument
130 is described below:
131 .IP \fBb\fR 4
132 .IX Item "b"
133 The BIO the callback is attached to is passed in \fBb\fR.
134 .IP \fBoper\fR 4
135 .IX Item "oper"
136 \&\fBoper\fR is set to the operation being performed. For some operations
137 the callback is called twice, once before and once after the actual
138 operation, the latter case has \fBoper\fR or'ed with BIO_CB_RETURN.
139 .IP \fBlen\fR 4
140 .IX Item "len"
141 The length of the data requested to be read or written. This is only useful if
142 \&\fBoper\fR is BIO_CB_READ, BIO_CB_WRITE or BIO_CB_GETS.
143 .IP "\fBargp\fR \fBargi\fR \fBargl\fR" 4
144 .IX Item "argp argi argl"
145 The meaning of the arguments \fBargp\fR, \fBargi\fR and \fBargl\fR depends on
146 the value of \fBoper\fR, that is the operation being performed.
147 .IP \fBprocessed\fR 4
148 .IX Item "processed"
149 \&\fBprocessed\fR is a pointer to a location which will be updated with the amount of
150 data that was actually read or written. Only used for BIO_CB_READ, BIO_CB_WRITE,
151 BIO_CB_GETS and BIO_CB_PUTS.
152 .IP \fBret\fR 4
153 .IX Item "ret"
154 \&\fBret\fR is the return value that would be returned to the
155 application if no callback were present. The actual value returned
156 is the return value of the callback itself. In the case of callbacks
157 called before the actual BIO operation 1 is placed in \fBret\fR, if
158 the return value is not positive it will be immediately returned to
159 the application and the BIO operation will not be performed.
160 .PP
161 The callback should normally simply return \fBret\fR when it has
162 finished processing, unless it specifically wishes to modify the
163 value returned to the application.
164 .SH "CALLBACK OPERATIONS"
165 .IX Header "CALLBACK OPERATIONS"
166 In the notes below, \fBcallback\fR defers to the actual callback
167 function that is called.
168 .IP \fBBIO_free(b)\fR 4
169 .IX Item "BIO_free(b)"
170 .Vb 1
171 \& callback_ex(b, BIO_CB_FREE, NULL, 0, 0, 0L, 1L, NULL)
172 .Ve
173 .Sp
174 or
175 .Sp
176 .Vb 1
177 \& callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L)
178 .Ve
179 .Sp
180 is called before the free operation.
181 .IP "\fBBIO_read_ex(b, data, dlen, readbytes)\fR" 4
182 .IX Item "BIO_read_ex(b, data, dlen, readbytes)"
183 .Vb 1
184 \& callback_ex(b, BIO_CB_READ, data, dlen, 0, 0L, 1L, NULL)
185 .Ve
186 .Sp
187 or
188 .Sp
189 .Vb 1
190 \& callback(b, BIO_CB_READ, data, dlen, 0L, 1L)
191 .Ve
192 .Sp
193 is called before the read and
194 .Sp
195 .Vb 2
196 \& callback_ex(b, BIO_CB_READ | BIO_CB_RETURN, data, dlen, 0, 0L, retvalue,
197 \& &readbytes)
198 .Ve
199 .Sp
200 or
201 .Sp
202 .Vb 1
203 \& callback(b, BIO_CB_READ|BIO_CB_RETURN, data, dlen, 0L, retvalue)
204 .Ve
205 .Sp
206 after.
207 .IP "\fBBIO_write(b, data, dlen, written)\fR" 4
208 .IX Item "BIO_write(b, data, dlen, written)"
209 .Vb 1
210 \& callback_ex(b, BIO_CB_WRITE, data, dlen, 0, 0L, 1L, NULL)
211 .Ve
212 .Sp
213 or
214 .Sp
215 .Vb 1
216 \& callback(b, BIO_CB_WRITE, datat, dlen, 0L, 1L)
217 .Ve
218 .Sp
219 is called before the write and
220 .Sp
221 .Vb 2
222 \& callback_ex(b, BIO_CB_WRITE | BIO_CB_RETURN, data, dlen, 0, 0L, retvalue,
223 \& &written)
224 .Ve
225 .Sp
226 or
227 .Sp
228 .Vb 1
229 \& callback(b, BIO_CB_WRITE|BIO_CB_RETURN, data, dlen, 0L, retvalue)
230 .Ve
231 .Sp
232 after.
233 .IP "\fBBIO_gets(b, buf, size)\fR" 4
234 .IX Item "BIO_gets(b, buf, size)"
235 .Vb 1
236 \& callback_ex(b, BIO_CB_GETS, buf, size, 0, 0L, 1, NULL, NULL)
237 .Ve
238 .Sp
239 or
240 .Sp
241 .Vb 1
242 \& callback(b, BIO_CB_GETS, buf, size, 0L, 1L)
243 .Ve
244 .Sp
245 is called before the operation and
246 .Sp
247 .Vb 2
248 \& callback_ex(b, BIO_CB_GETS | BIO_CB_RETURN, buf, size, 0, 0L, retvalue,
249 \& &readbytes)
250 .Ve
251 .Sp
252 or
253 .Sp
254 .Vb 1
255 \& callback(b, BIO_CB_GETS|BIO_CB_RETURN, buf, size, 0L, retvalue)
256 .Ve
257 .Sp
258 after.
259 .IP "\fBBIO_puts(b, buf)\fR" 4
260 .IX Item "BIO_puts(b, buf)"
261 .Vb 1
262 \& callback_ex(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);
263 .Ve
264 .Sp
265 or
266 .Sp
267 .Vb 1
268 \& callback(b, BIO_CB_PUTS, buf, 0, 0L, 1L)
269 .Ve
270 .Sp
271 is called before the operation and
272 .Sp
273 .Vb 1
274 \& callback_ex(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0, 0L, retvalue, &written)
275 .Ve
276 .Sp
277 or
278 .Sp
279 .Vb 1
280 \& callback(b, BIO_CB_PUTS|BIO_CB_RETURN, buf, 0, 0L, retvalue)
281 .Ve
282 .Sp
283 after.
284 .IP "\fBBIO_ctrl(BIO *b, int cmd, long larg, void *parg)\fR" 4
285 .IX Item "BIO_ctrl(BIO *b, int cmd, long larg, void *parg)"
286 .Vb 1
287 \& callback_ex(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL)
288 .Ve
289 .Sp
290 or
291 .Sp
292 .Vb 1
293 \& callback(b, BIO_CB_CTRL, parg, cmd, larg, 1L)
294 .Ve
295 .Sp
296 is called before the call and
297 .Sp
298 .Vb 1
299 \& callback_ex(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd, larg, ret, NULL)
300 .Ve
301 .Sp
302 or
303 .Sp
304 .Vb 1
305 \& callback(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, cmd, larg, ret)
306 .Ve
307 .Sp
308 after.
309 .Sp
310 Note: \fBcmd\fR == \fBBIO_CTRL_SET_CALLBACK\fR is special, because \fBparg\fR is not the
311 argument of type \fBBIO_info_cb\fR itself. In this case \fBparg\fR is a pointer to
312 the actual call parameter, see \fBBIO_callback_ctrl\fR.
313 .IP "\fBBIO_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, size_t *msgs_processed)\fR" 4
314 .IX Item "BIO_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, size_t *msgs_processed)"
315 .Vb 1
316 \& callback_ex(b, BIO_CB_SENDMMSG, args, 0, 0, 0, 1, NULL)
317 .Ve
318 .Sp
319 or
320 .Sp
321 .Vb 1
322 \& callback(b, BIO_CB_SENDMMSG, args, 0, 0, 1)
323 .Ve
324 .Sp
325 is called before the call and
326 .Sp
327 .Vb 1
328 \& callback_ex(b, BIO_CB_SENDMMSG | BIO_CB_RETURN, args, ret, 0, 0, ret, NULL)
329 .Ve
330 .Sp
331 or
332 .Sp
333 .Vb 1
334 \& callback(b, BIO_CB_SENDMMSG | BIO_CB_RETURN, args, ret, 0, 0, ret)
335 .Ve
336 .Sp
337 after.
338 .Sp
339 \&\fBargs\fR is a pointer to a \fBBIO_MMSG_CB_ARGS\fR structure containing the arguments
340 passed to \fBBIO_sendmmsg()\fR. \fBret\fR is the return value of the \fBBIO_sendmmsg()\fR call.
341 The return value of \fBBIO_sendmmsg()\fR is altered to the value returned by the
342 \&\fBBIO_CB_SENDMMSG | BIO_CB_RETURN\fR call.
343 .IP "\fBBIO_recvmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, size_t *msgs_processed)\fR" 4
344 .IX Item "BIO_recvmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, size_t *msgs_processed)"
345 See the documentation for \fBBIO_sendmmsg()\fR. \fBBIO_recvmmsg()\fR works identically
346 except that \fBBIO_CB_RECVMMSG\fR is used instead of \fBBIO_CB_SENDMMSG\fR.
347 .SH "RETURN VALUES"
348 .IX Header "RETURN VALUES"
349 \&\fBBIO_get_callback_ex()\fR and \fBBIO_get_callback()\fR return the callback function
350 previously set by a call to \fBBIO_set_callback_ex()\fR and \fBBIO_set_callback()\fR
351 respectively.
352 .PP
353 \&\fBBIO_get_callback_arg()\fR returns a \fBchar\fR pointer to the value previously set
354 via a call to \fBBIO_set_callback_arg()\fR.
355 .PP
356 \&\fBBIO_debug_callback()\fR returns 1 or \fBret\fR if it's called after specific BIO
357 operations.
358 .SH EXAMPLES
359 .IX Header "EXAMPLES"
360 The \fBBIO_debug_callback_ex()\fR function is an example, its source is
361 in crypto/bio/bio_cb.c
362 .SH HISTORY
363 .IX Header "HISTORY"
364 The \fBBIO_debug_callback_ex()\fR function was added in OpenSSL 3.0.
365 .PP
366 \&\fBBIO_set_callback()\fR, \fBBIO_get_callback()\fR, and \fBBIO_debug_callback()\fR were
367 deprecated in OpenSSL 3.0. Use the non-deprecated _ex functions instead.
368 .SH COPYRIGHT
369 .IX Header "COPYRIGHT"
370 Copyright 2000\-2021 The OpenSSL Project Authors. All Rights Reserved.
371 .PP
372 Licensed under the Apache License 2.0 (the "License"). You may not use
373 this file except in compliance with the License. You can obtain a copy
374 in the file LICENSE in the source distribution or at
375 <https://www.openssl.org/source/license.html>.