BIO_set_callback.3ossl 14 KB

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