5 BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg,
6 BIO_debug_callback - BIO callback functions
10 #include <openssl/bio.h>
13 typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
16 void BIO_set_callback(BIO *b, BIO_callack_fn cb);
17 BIO_callack_fn BIO_get_callback(BIO *b);
18 void BIO_set_callback_arg(BIO *b, char *arg);
19 char *BIO_get_callback_arg(const BIO *b);
21 long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
26 BIO_set_callback() and BIO_get_callback() set and retrieve the BIO callback,
27 they are both macros. The callback is called during most high level BIO
28 operations. It can be used for debugging purposes to trace operations on
29 a BIO or to modify its operation.
31 BIO_set_callback_arg() and BIO_get_callback_arg() are macros which can be
32 used to set and retrieve an argument for use in the callback.
34 BIO_debug_callback() is a standard debugging callback which prints
35 out information relating to each BIO operation. If the callback
36 argument is set it is interpreted as a BIO to send the information
37 to, otherwise stderr is used.
39 BIO_callback_fn() is the type of the callback function. The meaning of each
40 argument is described below:
43 The BIO the callback is attached to is passed in B<b>.
45 B<oper> is set to the operation being performed. For some operations
46 the callback is called twice, once before and once after the actual
47 operation, the latter case has B<oper> or'ed with BIO_CB_RETURN.
49 The meaning of the arguments B<argp>, B<argi> and B<argl> depends on
50 the value of B<oper>, that is the operation being performed.
52 B<ret> is the return value that would be returned to the
53 application if no callback were present. The actual value returned
54 is the return value of the callback itself. In the case of callbacks
55 called before the actual BIO operation 1 is placed in B<ret>, if
56 the return value is not positive it will be immediately returned to
57 the application and the BIO operation will not be performed.
61 The callback should normally simply return B<ret> when it has
62 finished processing, unless it specifically wishes to modify the
63 value returned to the application.
65 =head1 CALLBACK OPERATIONS
67 In the notes below, B<callback> defers to the actual callback
68 function that is called.
74 callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L) is called before the
77 =item B<BIO_read(b, out, outl)>
79 callback(b, BIO_CB_READ, out, outl, 0L, 1L) is called before
80 the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue)
83 =item B<BIO_write(b, in, inl)>
85 callback(b, BIO_CB_WRITE, in, inl, 0L, 1L) is called before
86 the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue)
89 =item B<BIO_gets(b, out, outl)>
91 callback(b, BIO_CB_GETS, out, outl, 0L, 1L) is called before
92 the operation and callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue)
95 =item B<BIO_puts(b, in)>
97 callback(b, BIO_CB_WRITE, in, 0, 0L, 1L) is called before
98 the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue)
101 =item B<BIO_ctrl(BIO *b, int cmd, long larg, void *parg)>
103 callback(b,BIO_CB_CTRL,parg,cmd,larg,1L) is called before the call and
104 callback(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd, larg,ret) after.
110 The BIO_debug_callback() function is a good example, its source is
111 in crypto/bio/bio_cb.c
115 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
117 Licensed under the OpenSSL license (the "License"). You may not use
118 this file except in compliance with the License. You can obtain a copy
119 in the file LICENSE in the source distribution or at
120 L<https://www.openssl.org/source/license.html>.