BIO_meth_new.3ossl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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_METH_NEW 3ossl"
  58. .TH BIO_METH_NEW 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_get_new_index,
  65. BIO_meth_new, BIO_meth_free, BIO_meth_get_read_ex, BIO_meth_set_read_ex,
  66. BIO_meth_get_write_ex, BIO_meth_set_write_ex, BIO_meth_get_write,
  67. BIO_meth_set_write, BIO_meth_get_read, BIO_meth_set_read, BIO_meth_get_puts,
  68. BIO_meth_set_puts, BIO_meth_get_gets, BIO_meth_set_gets, BIO_meth_get_ctrl,
  69. BIO_meth_set_ctrl, BIO_meth_get_create, BIO_meth_set_create,
  70. BIO_meth_get_destroy, BIO_meth_set_destroy, BIO_meth_get_callback_ctrl,
  71. BIO_meth_set_callback_ctrl, BIO_meth_set_sendmmsg, BIO_meth_get_sendmmsg,
  72. BIO_meth_set_recvmmsg, BIO_meth_get_recvmmsg \- Routines to build up BIO methods
  73. .SH SYNOPSIS
  74. .IX Header "SYNOPSIS"
  75. .Vb 1
  76. \& #include <openssl/bio.h>
  77. \&
  78. \& int BIO_get_new_index(void);
  79. \&
  80. \& BIO_METHOD *BIO_meth_new(int type, const char *name);
  81. \&
  82. \& void BIO_meth_free(BIO_METHOD *biom);
  83. \&
  84. \& int (*BIO_meth_get_write_ex(const BIO_METHOD *biom))(BIO *, const char *, size_t,
  85. \& size_t *);
  86. \& int (*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int);
  87. \& int BIO_meth_set_write_ex(BIO_METHOD *biom,
  88. \& int (*bwrite)(BIO *, const char *, size_t, size_t *));
  89. \& int BIO_meth_set_write(BIO_METHOD *biom,
  90. \& int (*write)(BIO *, const char *, int));
  91. \&
  92. \& int (*BIO_meth_get_read_ex(const BIO_METHOD *biom))(BIO *, char *, size_t, size_t *);
  93. \& int (*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int);
  94. \& int BIO_meth_set_read_ex(BIO_METHOD *biom,
  95. \& int (*bread)(BIO *, char *, size_t, size_t *));
  96. \& int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int));
  97. \&
  98. \& int (*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *);
  99. \& int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *));
  100. \&
  101. \& int (*BIO_meth_get_gets(const BIO_METHOD *biom))(BIO *, char *, int);
  102. \& int BIO_meth_set_gets(BIO_METHOD *biom,
  103. \& int (*gets)(BIO *, char *, int));
  104. \&
  105. \& long (*BIO_meth_get_ctrl(const BIO_METHOD *biom))(BIO *, int, long, void *);
  106. \& int BIO_meth_set_ctrl(BIO_METHOD *biom,
  107. \& long (*ctrl)(BIO *, int, long, void *));
  108. \&
  109. \& int (*BIO_meth_get_create(const BIO_METHOD *bion))(BIO *);
  110. \& int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *));
  111. \&
  112. \& int (*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *);
  113. \& int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *));
  114. \&
  115. \& long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *);
  116. \& int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
  117. \& long (*callback_ctrl)(BIO *, int, BIO_info_cb *));
  118. \&
  119. \& ossl_ssize_t (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *,
  120. \& BIO_MSG *,
  121. \& size_t,
  122. \& size_t,
  123. \& uint64_t);
  124. \& int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
  125. \& ossl_ssize_t (*f) (BIO *, BIO_MSG *, size_t,
  126. \& size_t, uint64_t));
  127. \&
  128. \& ossl_ssize_t (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *,
  129. \& BIO_MSG *,
  130. \& size_t,
  131. \& size_t,
  132. \& uint64_t);
  133. \& int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
  134. \& ossl_ssize_t (*f) (BIO *, BIO_MSG *, size_t,
  135. \& size_t, uint64_t));
  136. .Ve
  137. .SH DESCRIPTION
  138. .IX Header "DESCRIPTION"
  139. The \fBBIO_METHOD\fR type is a structure used for the implementation of new BIO
  140. types. It provides a set of functions used by OpenSSL for the implementation
  141. of the various BIO capabilities. See the \fBbio\fR\|(7) page for more information.
  142. .PP
  143. \&\fBBIO_meth_new()\fR creates a new \fBBIO_METHOD\fR structure that contains a type
  144. identifier \fItype\fR and a string that represents its \fBname\fR.
  145. \&\fBtype\fR can be set to either \fBBIO_TYPE_NONE\fR or via \fBBIO_get_new_index()\fR if
  146. a unique type is required for searching (See \fBBIO_find_type\fR\|(3))
  147. .PP
  148. Note that \fBBIO_get_new_index()\fR can only be used 127 times before it returns an
  149. error.
  150. .PP
  151. The set of
  152. standard OpenSSL provided BIO types is provided in \fI<openssl/bio.h>\fR.
  153. Some examples include \fBBIO_TYPE_BUFFER\fR and \fBBIO_TYPE_CIPHER\fR. Filter BIOs
  154. should have a type which have the "filter" bit set (\fBBIO_TYPE_FILTER\fR).
  155. Source/sink BIOs should have the "source/sink" bit set (\fBBIO_TYPE_SOURCE_SINK\fR).
  156. File descriptor based BIOs (e.g. socket, fd, connect, accept etc) should
  157. additionally have the "descriptor" bit set (\fBBIO_TYPE_DESCRIPTOR\fR). See the
  158. \&\fBBIO_find_type\fR\|(3) page for more information.
  159. .PP
  160. \&\fBBIO_meth_free()\fR destroys a \fBBIO_METHOD\fR structure and frees up any memory
  161. associated with it. If the argument is NULL, nothing is done.
  162. .PP
  163. \&\fBBIO_meth_get_write_ex()\fR and \fBBIO_meth_set_write_ex()\fR get and set the function
  164. used for writing arbitrary length data to the BIO respectively. This function
  165. will be called in response to the application calling \fBBIO_write_ex()\fR or
  166. \&\fBBIO_write()\fR. The parameters for the function have the same meaning as for
  167. \&\fBBIO_write_ex()\fR. Older code may call \fBBIO_meth_get_write()\fR and
  168. \&\fBBIO_meth_set_write()\fR instead. Applications should not call both
  169. \&\fBBIO_meth_set_write_ex()\fR and \fBBIO_meth_set_write()\fR or call \fBBIO_meth_get_write()\fR
  170. when the function was set with \fBBIO_meth_set_write_ex()\fR.
  171. .PP
  172. \&\fBBIO_meth_get_read_ex()\fR and \fBBIO_meth_set_read_ex()\fR get and set the function used
  173. for reading arbitrary length data from the BIO respectively. This function will
  174. be called in response to the application calling \fBBIO_read_ex()\fR or \fBBIO_read()\fR.
  175. The parameters for the function have the same meaning as for \fBBIO_read_ex()\fR.
  176. Older code may call \fBBIO_meth_get_read()\fR and \fBBIO_meth_set_read()\fR instead.
  177. Applications should not call both \fBBIO_meth_set_read_ex()\fR and \fBBIO_meth_set_read()\fR
  178. or call \fBBIO_meth_get_read()\fR when the function was set with
  179. \&\fBBIO_meth_set_read_ex()\fR.
  180. .PP
  181. \&\fBBIO_meth_get_puts()\fR and \fBBIO_meth_set_puts()\fR get and set the function used for
  182. writing a NULL terminated string to the BIO respectively. This function will be
  183. called in response to the application calling \fBBIO_puts()\fR. The parameters for
  184. the function have the same meaning as for \fBBIO_puts()\fR.
  185. .PP
  186. \&\fBBIO_meth_get_gets()\fR and \fBBIO_meth_set_gets()\fR get and set the function typically
  187. used for reading a line of data from the BIO respectively (see the \fBBIO_gets\fR\|(3)
  188. page for more information). This function will be called in response to the
  189. application calling \fBBIO_gets()\fR. The parameters for the function have the same
  190. meaning as for \fBBIO_gets()\fR.
  191. .PP
  192. \&\fBBIO_meth_get_ctrl()\fR and \fBBIO_meth_set_ctrl()\fR get and set the function used for
  193. processing ctrl messages in the BIO respectively. See the \fBBIO_ctrl\fR\|(3) page for
  194. more information. This function will be called in response to the application
  195. calling \fBBIO_ctrl()\fR. The parameters for the function have the same meaning as for
  196. \&\fBBIO_ctrl()\fR.
  197. .PP
  198. \&\fBBIO_meth_get_create()\fR and \fBBIO_meth_set_create()\fR get and set the function used
  199. for creating a new instance of the BIO respectively. This function will be
  200. called in response to the application calling \fBBIO_new()\fR and passing
  201. in a pointer to the current BIO_METHOD. The \fBBIO_new()\fR function will allocate the
  202. memory for the new BIO, and a pointer to this newly allocated structure will
  203. be passed as a parameter to the function. If a create function is set,
  204. \&\fBBIO_new()\fR will not mark the BIO as initialised on allocation.
  205. \&\fBBIO_set_init\fR\|(3) must then be called either by the create function, or later,
  206. by a BIO ctrl function, once BIO initialisation is complete.
  207. .PP
  208. \&\fBBIO_meth_get_destroy()\fR and \fBBIO_meth_set_destroy()\fR get and set the function used
  209. for destroying an instance of a BIO respectively. This function will be
  210. called in response to the application calling \fBBIO_free()\fR. A pointer to the BIO
  211. to be destroyed is passed as a parameter. The destroy function should be used
  212. for BIO specific clean up. The memory for the BIO itself should not be freed by
  213. this function.
  214. .PP
  215. \&\fBBIO_meth_get_callback_ctrl()\fR and \fBBIO_meth_set_callback_ctrl()\fR get and set the
  216. function used for processing callback ctrl messages in the BIO respectively. See
  217. the \fBBIO_callback_ctrl\fR\|(3) page for more information. This function will be called
  218. in response to the application calling \fBBIO_callback_ctrl()\fR. The parameters for
  219. the function have the same meaning as for \fBBIO_callback_ctrl()\fR.
  220. .PP
  221. \&\fBBIO_meth_get_sendmmsg()\fR, \fBBIO_meth_set_sendmmsg()\fR, \fBBIO_meth_get_recvmmsg()\fR and
  222. \&\fBBIO_meth_set_recvmmsg()\fR get and set the functions used for handling
  223. \&\fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR calls respectively. See \fBBIO_sendmmsg\fR\|(3) for
  224. more information.
  225. .SH "RETURN VALUES"
  226. .IX Header "RETURN VALUES"
  227. \&\fBBIO_get_new_index()\fR returns the new BIO type value or \-1 if an error occurred.
  228. .PP
  229. BIO_meth_new(int type, const char *name) returns a valid \fBBIO_METHOD\fR or NULL
  230. if an error occurred.
  231. .PP
  232. The \fBBIO_meth_set\fR functions return 1 on success or 0 on error.
  233. .PP
  234. The \fBBIO_meth_get\fR functions return the corresponding function pointers.
  235. .SH "SEE ALSO"
  236. .IX Header "SEE ALSO"
  237. \&\fBbio\fR\|(7), \fBBIO_find_type\fR\|(3), \fBBIO_ctrl\fR\|(3), \fBBIO_read_ex\fR\|(3), \fBBIO_new\fR\|(3)
  238. .SH HISTORY
  239. .IX Header "HISTORY"
  240. The functions described here were added in OpenSSL 1.1.0.
  241. .SH COPYRIGHT
  242. .IX Header "COPYRIGHT"
  243. Copyright 2016\-2024 The OpenSSL Project Authors. All Rights Reserved.
  244. .PP
  245. Licensed under the Apache License 2.0 (the "License"). You may not use
  246. this file except in compliance with the License. You can obtain a copy
  247. in the file LICENSE in the source distribution or at
  248. <https://www.openssl.org/source/license.html>.