BIO_ctrl.3ossl 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  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_CTRL 3ossl"
  58. .TH BIO_CTRL 3ossl 2025-01-17 3.4.0 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_ctrl, BIO_callback_ctrl, BIO_ptr_ctrl, BIO_int_ctrl, BIO_reset,
  65. BIO_seek, BIO_tell, BIO_flush, BIO_eof, BIO_set_close, BIO_get_close,
  66. BIO_pending, BIO_wpending, BIO_ctrl_pending, BIO_ctrl_wpending,
  67. BIO_get_info_callback, BIO_set_info_callback, BIO_info_cb, BIO_get_ktls_send,
  68. BIO_get_ktls_recv, BIO_set_conn_mode, BIO_get_conn_mode, BIO_set_tfo
  69. \&\- BIO control operations
  70. .SH SYNOPSIS
  71. .IX Header "SYNOPSIS"
  72. .Vb 1
  73. \& #include <openssl/bio.h>
  74. \&
  75. \& typedef int BIO_info_cb(BIO *b, int state, int res);
  76. \&
  77. \& long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
  78. \& long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *cb);
  79. \& void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
  80. \& long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
  81. \&
  82. \& int BIO_reset(BIO *b);
  83. \& int BIO_seek(BIO *b, int ofs);
  84. \& int BIO_tell(BIO *b);
  85. \& int BIO_flush(BIO *b);
  86. \& int BIO_eof(BIO *b);
  87. \& int BIO_set_close(BIO *b, long flag);
  88. \& int BIO_get_close(BIO *b);
  89. \& int BIO_pending(BIO *b);
  90. \& int BIO_wpending(BIO *b);
  91. \& size_t BIO_ctrl_pending(BIO *b);
  92. \& size_t BIO_ctrl_wpending(BIO *b);
  93. \&
  94. \& int BIO_get_info_callback(BIO *b, BIO_info_cb **cbp);
  95. \& int BIO_set_info_callback(BIO *b, BIO_info_cb *cb);
  96. \&
  97. \& int BIO_get_ktls_send(BIO *b);
  98. \& int BIO_get_ktls_recv(BIO *b);
  99. \&
  100. \& int BIO_set_conn_mode(BIO *b, int mode);
  101. \& int BIO_get_conn_mode(BIO *b);
  102. \&
  103. \& int BIO_set_tfo(BIO *b, int onoff);
  104. .Ve
  105. .SH DESCRIPTION
  106. .IX Header "DESCRIPTION"
  107. \&\fBBIO_ctrl()\fR, \fBBIO_callback_ctrl()\fR, \fBBIO_ptr_ctrl()\fR and \fBBIO_int_ctrl()\fR
  108. are BIO "control" operations taking arguments of various types.
  109. These functions are not normally called directly, various macros
  110. are used instead. The standard macros are described below, macros
  111. specific to a particular type of BIO are described in the specific
  112. BIOs manual page as well as any special features of the standard
  113. calls.
  114. .PP
  115. \&\fBBIO_reset()\fR typically resets a BIO to some initial state, in the case
  116. of file related BIOs for example it rewinds the file pointer to the
  117. start of the file.
  118. .PP
  119. \&\fBBIO_seek()\fR resets a file related BIO's (that is file descriptor and
  120. FILE BIOs) file position pointer to \fBofs\fR bytes from start of file.
  121. .PP
  122. \&\fBBIO_tell()\fR returns the current file position of a file related BIO.
  123. .PP
  124. \&\fBBIO_flush()\fR normally writes out any internally buffered data, in some
  125. cases it is used to signal EOF and that no more data will be written.
  126. .PP
  127. \&\fBBIO_eof()\fR returns 1 if the BIO has read EOF, the precise meaning of
  128. "EOF" varies according to the BIO type.
  129. .PP
  130. \&\fBBIO_set_close()\fR sets the BIO \fBb\fR close flag to \fBflag\fR. \fBflag\fR can
  131. take the value BIO_CLOSE or BIO_NOCLOSE. Typically BIO_CLOSE is used
  132. in a source/sink BIO to indicate that the underlying I/O stream should
  133. be closed when the BIO is freed.
  134. .PP
  135. \&\fBBIO_get_close()\fR returns the BIOs close flag.
  136. .PP
  137. \&\fBBIO_pending()\fR, \fBBIO_ctrl_pending()\fR, \fBBIO_wpending()\fR and \fBBIO_ctrl_wpending()\fR
  138. return the number of pending characters in the BIOs read and write buffers.
  139. Not all BIOs support these calls. \fBBIO_ctrl_pending()\fR and \fBBIO_ctrl_wpending()\fR
  140. return a size_t type and are functions, \fBBIO_pending()\fR and \fBBIO_wpending()\fR are
  141. macros which call \fBBIO_ctrl()\fR.
  142. .PP
  143. \&\fBBIO_get_ktls_send()\fR returns 1 if the BIO is using the Kernel TLS data-path for
  144. sending. Otherwise, it returns zero.
  145. \&\fBBIO_get_ktls_recv()\fR returns 1 if the BIO is using the Kernel TLS data-path for
  146. receiving. Otherwise, it returns zero.
  147. .PP
  148. \&\fBBIO_get_conn_mode()\fR returns the BIO connection mode. \fBBIO_set_conn_mode()\fR sets
  149. the BIO connection mode.
  150. .PP
  151. \&\fBBIO_set_tfo()\fR disables TCP Fast Open when \fBonoff\fR is 0, and enables TCP Fast
  152. Open when \fBonoff\fR is nonzero. Setting the value to 1 is equivalent to setting
  153. \&\fBBIO_SOCK_TFO\fR in \fBBIO_set_conn_mode()\fR.
  154. .SH "RETURN VALUES"
  155. .IX Header "RETURN VALUES"
  156. \&\fBBIO_reset()\fR normally returns 1 for success and <=0 for failure. File
  157. BIOs are an exception, they return 0 for success and \-1 for failure.
  158. .PP
  159. \&\fBBIO_seek()\fR and \fBBIO_tell()\fR both return the current file position on success
  160. and \-1 for failure, except file BIOs which for \fBBIO_seek()\fR always return 0
  161. for success and \-1 for failure.
  162. .PP
  163. \&\fBBIO_flush()\fR returns 1 for success and <=0 for failure.
  164. .PP
  165. \&\fBBIO_eof()\fR returns 1 if EOF has been reached, 0 if not, or negative values for failure.
  166. .PP
  167. \&\fBBIO_set_close()\fR returns 1 on success or <=0 for failure.
  168. .PP
  169. \&\fBBIO_get_close()\fR returns the close flag value: BIO_CLOSE or BIO_NOCLOSE. It also
  170. returns other negative values if an error occurs.
  171. .PP
  172. \&\fBBIO_pending()\fR, \fBBIO_ctrl_pending()\fR, \fBBIO_wpending()\fR and \fBBIO_ctrl_wpending()\fR
  173. return the amount of pending data. \fBBIO_pending()\fR and \fBBIO_wpending()\fR return
  174. negative value or 0 on error. \fBBIO_ctrl_pending()\fR and \fBBIO_ctrl_wpending()\fR return
  175. 0 on error.
  176. .PP
  177. \&\fBBIO_get_ktls_send()\fR returns 1 if the BIO is using the Kernel TLS data-path for
  178. sending. Otherwise, it returns zero.
  179. \&\fBBIO_get_ktls_recv()\fR returns 1 if the BIO is using the Kernel TLS data-path for
  180. receiving. Otherwise, it returns zero.
  181. .PP
  182. \&\fBBIO_set_conn_mode()\fR returns 1 for success and 0 for failure. \fBBIO_get_conn_mode()\fR
  183. returns the current connection mode. Which may contain the bitwise-or of the
  184. following flags:
  185. .PP
  186. .Vb 6
  187. \& BIO_SOCK_REUSEADDR
  188. \& BIO_SOCK_V6_ONLY
  189. \& BIO_SOCK_KEEPALIVE
  190. \& BIO_SOCK_NONBLOCK
  191. \& BIO_SOCK_NODELAY
  192. \& BIO_SOCK_TFO
  193. .Ve
  194. .PP
  195. \&\fBBIO_set_tfo()\fR returns 1 for success, and 0 for failure.
  196. .SH NOTES
  197. .IX Header "NOTES"
  198. \&\fBBIO_flush()\fR, because it can write data may return 0 or \-1 indicating
  199. that the call should be retried later in a similar manner to \fBBIO_write_ex()\fR.
  200. The \fBBIO_should_retry()\fR call should be used and appropriate action taken
  201. is the call fails.
  202. .PP
  203. The return values of \fBBIO_pending()\fR and \fBBIO_wpending()\fR may not reliably
  204. determine the amount of pending data in all cases. For example in the
  205. case of a file BIO some data may be available in the FILE structures
  206. internal buffers but it is not possible to determine this in a
  207. portably way. For other types of BIO they may not be supported.
  208. .PP
  209. Filter BIOs if they do not internally handle a particular \fBBIO_ctrl()\fR
  210. operation usually pass the operation to the next BIO in the chain.
  211. This often means there is no need to locate the required BIO for
  212. a particular operation, it can be called on a chain and it will
  213. be automatically passed to the relevant BIO. However, this can cause
  214. unexpected results: for example no current filter BIOs implement
  215. \&\fBBIO_seek()\fR, but this may still succeed if the chain ends in a FILE
  216. or file descriptor BIO.
  217. .PP
  218. Source/sink BIOs return an 0 if they do not recognize the \fBBIO_ctrl()\fR
  219. operation.
  220. .SH BUGS
  221. .IX Header "BUGS"
  222. Some of the return values are ambiguous and care should be taken. In
  223. particular a return value of 0 can be returned if an operation is not
  224. supported, if an error occurred, if EOF has not been reached and in
  225. the case of \fBBIO_seek()\fR on a file BIO for a successful operation.
  226. .PP
  227. In older versions of OpenSSL the \fBBIO_ctrl_pending()\fR and
  228. \&\fBBIO_ctrl_wpending()\fR could return values greater than INT_MAX on error.
  229. .SH HISTORY
  230. .IX Header "HISTORY"
  231. The \fBBIO_get_ktls_send()\fR and \fBBIO_get_ktls_recv()\fR macros were added in
  232. OpenSSL 3.0. They were modified to never return \-1 in OpenSSL 3.0.4.
  233. .PP
  234. The \fBBIO_get_conn_mode()\fR, \fBBIO_set_conn_mode()\fR and \fBBIO_set_tfo()\fR functions
  235. were added in OpenSSL 3.2.
  236. .SH COPYRIGHT
  237. .IX Header "COPYRIGHT"
  238. Copyright 2000\-2022 The OpenSSL Project Authors. All Rights Reserved.
  239. .PP
  240. Licensed under the Apache License 2.0 (the "License"). You may not use
  241. this file except in compliance with the License. You can obtain a copy
  242. in the file LICENSE in the source distribution or at
  243. <https://www.openssl.org/source/license.html>.