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:
46 The BIO the callback is attached to is passed in B<b>.
50 B<oper> is set to the operation being performed. For some operations
51 the callback is called twice, once before and once after the actual
52 operation, the latter case has B<oper> or'ed with BIO_CB_RETURN.
54 =item B<argp> B<argi> B<argl>
56 The meaning of the arguments B<argp>, B<argi> and B<argl> depends on
57 the value of B<oper>, that is the operation being performed.
61 B<ret> is the return value that would be returned to the
62 application if no callback were present. The actual value returned
63 is the return value of the callback itself. In the case of callbacks
64 called before the actual BIO operation 1 is placed in B<ret>, if
65 the return value is not positive it will be immediately returned to
66 the application and the BIO operation will not be performed.
70 The callback should normally simply return B<ret> when it has
71 finished processing, unless it specifically wishes to modify the
72 value returned to the application.
74 =head1 CALLBACK OPERATIONS
76 In the notes below, B<callback> defers to the actual callback
77 function that is called.
83 callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L) is called before the
86 =item B<BIO_read(b, out, outl)>
88 callback(b, BIO_CB_READ, out, outl, 0L, 1L) is called before
89 the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue)
92 =item B<BIO_write(b, in, inl)>
94 callback(b, BIO_CB_WRITE, in, inl, 0L, 1L) is called before
95 the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue)
98 =item B<BIO_gets(b, out, outl)>
100 callback(b, BIO_CB_GETS, out, outl, 0L, 1L) is called before
101 the operation and callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue)
104 =item B<BIO_puts(b, in)>
106 callback(b, BIO_CB_WRITE, in, 0, 0L, 1L) is called before
107 the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue)
110 =item B<BIO_ctrl(BIO *b, int cmd, long larg, void *parg)>
112 callback(b, BIO_CB_CTRL, parg, cmd, larg, 1L) is called before the call and
113 callback(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, cmd, larg, ret) after.
119 The BIO_debug_callback() function is a good example, its source is
120 in crypto/bio/bio_cb.c
124 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
126 Licensed under the OpenSSL license (the "License"). You may not use
127 this file except in compliance with the License. You can obtain a copy
128 in the file LICENSE in the source distribution or at
129 L<https://www.openssl.org/source/license.html>.