bio.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. /*
  2. * WARNING: do not edit!
  3. * Generated by Makefile from include/openssl/bio.h.in
  4. *
  5. * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  6. *
  7. * Licensed under the Apache License 2.0 (the "License"). You may not use
  8. * this file except in compliance with the License. You can obtain a copy
  9. * in the file LICENSE in the source distribution or at
  10. * https://www.openssl.org/source/license.html
  11. */
  12. #ifndef OPENSSL_BIO_H
  13. # define OPENSSL_BIO_H
  14. # pragma once
  15. # include <openssl/macros.h>
  16. # ifndef OPENSSL_NO_DEPRECATED_3_0
  17. # define HEADER_BIO_H
  18. # endif
  19. # include <openssl/e_os2.h>
  20. # ifndef OPENSSL_NO_STDIO
  21. # include <stdio.h>
  22. # endif
  23. # include <stdarg.h>
  24. # include <openssl/crypto.h>
  25. # include <openssl/bioerr.h>
  26. # include <openssl/core.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* There are the classes of BIOs */
  31. # define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
  32. # define BIO_TYPE_FILTER 0x0200
  33. # define BIO_TYPE_SOURCE_SINK 0x0400
  34. /* These are the 'types' of BIOs */
  35. # define BIO_TYPE_NONE 0
  36. # define BIO_TYPE_MEM ( 1|BIO_TYPE_SOURCE_SINK)
  37. # define BIO_TYPE_FILE ( 2|BIO_TYPE_SOURCE_SINK)
  38. # define BIO_TYPE_FD ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
  39. # define BIO_TYPE_SOCKET ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
  40. # define BIO_TYPE_NULL ( 6|BIO_TYPE_SOURCE_SINK)
  41. # define BIO_TYPE_SSL ( 7|BIO_TYPE_FILTER)
  42. # define BIO_TYPE_MD ( 8|BIO_TYPE_FILTER)
  43. # define BIO_TYPE_BUFFER ( 9|BIO_TYPE_FILTER)
  44. # define BIO_TYPE_CIPHER (10|BIO_TYPE_FILTER)
  45. # define BIO_TYPE_BASE64 (11|BIO_TYPE_FILTER)
  46. # define BIO_TYPE_CONNECT (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
  47. # define BIO_TYPE_ACCEPT (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
  48. # define BIO_TYPE_NBIO_TEST (16|BIO_TYPE_FILTER)/* server proxy BIO */
  49. # define BIO_TYPE_NULL_FILTER (17|BIO_TYPE_FILTER)
  50. # define BIO_TYPE_BIO (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */
  51. # define BIO_TYPE_LINEBUFFER (20|BIO_TYPE_FILTER)
  52. # define BIO_TYPE_DGRAM (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
  53. # define BIO_TYPE_ASN1 (22|BIO_TYPE_FILTER)
  54. # define BIO_TYPE_COMP (23|BIO_TYPE_FILTER)
  55. # ifndef OPENSSL_NO_SCTP
  56. # define BIO_TYPE_DGRAM_SCTP (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
  57. # endif
  58. # define BIO_TYPE_CORE_TO_PROV (25|BIO_TYPE_SOURCE_SINK)
  59. # define BIO_TYPE_DGRAM_PAIR (26|BIO_TYPE_SOURCE_SINK)
  60. # define BIO_TYPE_DGRAM_MEM (27|BIO_TYPE_SOURCE_SINK)
  61. /* Custom type starting index returned by BIO_get_new_index() */
  62. #define BIO_TYPE_START 128
  63. /* Custom type maximum index that can be returned by BIO_get_new_index() */
  64. #define BIO_TYPE_MASK 0xFF
  65. /*
  66. * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
  67. * BIO_set_fp(in,stdin,BIO_NOCLOSE);
  68. */
  69. # define BIO_NOCLOSE 0x00
  70. # define BIO_CLOSE 0x01
  71. /*
  72. * These are used in the following macros and are passed to BIO_ctrl()
  73. */
  74. # define BIO_CTRL_RESET 1/* opt - rewind/zero etc */
  75. # define BIO_CTRL_EOF 2/* opt - are we at the eof */
  76. # define BIO_CTRL_INFO 3/* opt - extra tit-bits */
  77. # define BIO_CTRL_SET 4/* man - set the 'IO' type */
  78. # define BIO_CTRL_GET 5/* man - get the 'IO' type */
  79. # define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */
  80. # define BIO_CTRL_POP 7/* opt - internal, used to signify change */
  81. # define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */
  82. # define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */
  83. # define BIO_CTRL_PENDING 10/* opt - is their more data buffered */
  84. # define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */
  85. # define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */
  86. # define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */
  87. # define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */
  88. # define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */
  89. # define BIO_CTRL_PEEK 29/* BIO_f_buffer special */
  90. # define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */
  91. /* dgram BIO stuff */
  92. # define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */
  93. # define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected
  94. * socket to be passed in */
  95. # define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */
  96. # define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */
  97. # define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */
  98. # define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */
  99. # define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */
  100. # define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation timed out */
  101. /* #ifdef IP_MTU_DISCOVER */
  102. # define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */
  103. /* #endif */
  104. # define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */
  105. # define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
  106. # define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */
  107. # define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU.
  108. * want to use this if asking
  109. * the kernel fails */
  110. # define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was
  111. * exceed in the previous write
  112. * operation */
  113. # define BIO_CTRL_DGRAM_GET_PEER 46
  114. # define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */
  115. # define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout
  116. * to adjust socket timeouts */
  117. # define BIO_CTRL_DGRAM_SET_DONT_FRAG 48
  118. # define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49
  119. /* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */
  120. # define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
  121. # ifndef OPENSSL_NO_SCTP
  122. /* SCTP stuff */
  123. # define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51
  124. # define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52
  125. # define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53
  126. # define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60
  127. # define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61
  128. # define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62
  129. # define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63
  130. # define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64
  131. # define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65
  132. # define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70
  133. # endif
  134. # define BIO_CTRL_DGRAM_SET_PEEK_MODE 71
  135. /*
  136. * internal BIO:
  137. * # define BIO_CTRL_SET_KTLS_SEND 72
  138. * # define BIO_CTRL_SET_KTLS_SEND_CTRL_MSG 74
  139. * # define BIO_CTRL_CLEAR_KTLS_CTRL_MSG 75
  140. */
  141. # define BIO_CTRL_GET_KTLS_SEND 73
  142. # define BIO_CTRL_GET_KTLS_RECV 76
  143. # define BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY 77
  144. # define BIO_CTRL_DGRAM_SCTP_MSG_WAITING 78
  145. /* BIO_f_prefix controls */
  146. # define BIO_CTRL_SET_PREFIX 79
  147. # define BIO_CTRL_SET_INDENT 80
  148. # define BIO_CTRL_GET_INDENT 81
  149. # define BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP 82
  150. # define BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE 83
  151. # define BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE 84
  152. # define BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS 85
  153. # define BIO_CTRL_DGRAM_GET_CAPS 86
  154. # define BIO_CTRL_DGRAM_SET_CAPS 87
  155. # define BIO_CTRL_DGRAM_GET_NO_TRUNC 88
  156. # define BIO_CTRL_DGRAM_SET_NO_TRUNC 89
  157. /*
  158. * internal BIO:
  159. * # define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90
  160. */
  161. # define BIO_CTRL_GET_RPOLL_DESCRIPTOR 91
  162. # define BIO_CTRL_GET_WPOLL_DESCRIPTOR 92
  163. # define BIO_CTRL_DGRAM_DETECT_PEER_ADDR 93
  164. # define BIO_DGRAM_CAP_NONE 0U
  165. # define BIO_DGRAM_CAP_HANDLES_SRC_ADDR (1U << 0)
  166. # define BIO_DGRAM_CAP_HANDLES_DST_ADDR (1U << 1)
  167. # define BIO_DGRAM_CAP_PROVIDES_SRC_ADDR (1U << 2)
  168. # define BIO_DGRAM_CAP_PROVIDES_DST_ADDR (1U << 3)
  169. # ifndef OPENSSL_NO_KTLS
  170. # define BIO_get_ktls_send(b) \
  171. (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0)
  172. # define BIO_get_ktls_recv(b) \
  173. (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0)
  174. # else
  175. # define BIO_get_ktls_send(b) (0)
  176. # define BIO_get_ktls_recv(b) (0)
  177. # endif
  178. /* modifiers */
  179. # define BIO_FP_READ 0x02
  180. # define BIO_FP_WRITE 0x04
  181. # define BIO_FP_APPEND 0x08
  182. # define BIO_FP_TEXT 0x10
  183. # define BIO_FLAGS_READ 0x01
  184. # define BIO_FLAGS_WRITE 0x02
  185. # define BIO_FLAGS_IO_SPECIAL 0x04
  186. # define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
  187. # define BIO_FLAGS_SHOULD_RETRY 0x08
  188. # ifndef OPENSSL_NO_DEPRECATED_3_0
  189. /* This #define was replaced by an internal constant and should not be used. */
  190. # define BIO_FLAGS_UPLINK 0
  191. # endif
  192. # define BIO_FLAGS_BASE64_NO_NL 0x100
  193. /*
  194. * This is used with memory BIOs:
  195. * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;
  196. * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.
  197. */
  198. # define BIO_FLAGS_MEM_RDONLY 0x200
  199. # define BIO_FLAGS_NONCLEAR_RST 0x400
  200. # define BIO_FLAGS_IN_EOF 0x800
  201. /* the BIO FLAGS values 0x1000 to 0x8000 are reserved for internal KTLS flags */
  202. typedef union bio_addr_st BIO_ADDR;
  203. typedef struct bio_addrinfo_st BIO_ADDRINFO;
  204. int BIO_get_new_index(void);
  205. void BIO_set_flags(BIO *b, int flags);
  206. int BIO_test_flags(const BIO *b, int flags);
  207. void BIO_clear_flags(BIO *b, int flags);
  208. # define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
  209. # define BIO_set_retry_special(b) \
  210. BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
  211. # define BIO_set_retry_read(b) \
  212. BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
  213. # define BIO_set_retry_write(b) \
  214. BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
  215. /* These are normally used internally in BIOs */
  216. # define BIO_clear_retry_flags(b) \
  217. BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
  218. # define BIO_get_retry_flags(b) \
  219. BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
  220. /* These should be used by the application to tell why we should retry */
  221. # define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ)
  222. # define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE)
  223. # define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
  224. # define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS)
  225. # define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
  226. /*
  227. * The next three are used in conjunction with the BIO_should_io_special()
  228. * condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int
  229. * *reason); will walk the BIO stack and return the 'reason' for the special
  230. * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return
  231. * the code.
  232. */
  233. /*
  234. * Returned from the SSL bio when the certificate retrieval code had an error
  235. */
  236. # define BIO_RR_SSL_X509_LOOKUP 0x01
  237. /* Returned from the connect BIO when a connect would have blocked */
  238. # define BIO_RR_CONNECT 0x02
  239. /* Returned from the accept BIO when an accept would have blocked */
  240. # define BIO_RR_ACCEPT 0x03
  241. /* These are passed by the BIO callback */
  242. # define BIO_CB_FREE 0x01
  243. # define BIO_CB_READ 0x02
  244. # define BIO_CB_WRITE 0x03
  245. # define BIO_CB_PUTS 0x04
  246. # define BIO_CB_GETS 0x05
  247. # define BIO_CB_CTRL 0x06
  248. # define BIO_CB_RECVMMSG 0x07
  249. # define BIO_CB_SENDMMSG 0x08
  250. /*
  251. * The callback is called before and after the underling operation, The
  252. * BIO_CB_RETURN flag indicates if it is after the call
  253. */
  254. # define BIO_CB_RETURN 0x80
  255. # define BIO_CB_return(a) ((a)|BIO_CB_RETURN)
  256. # define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
  257. # define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
  258. # ifndef OPENSSL_NO_DEPRECATED_3_0
  259. typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
  260. long argl, long ret);
  261. OSSL_DEPRECATEDIN_3_0 BIO_callback_fn BIO_get_callback(const BIO *b);
  262. OSSL_DEPRECATEDIN_3_0 void BIO_set_callback(BIO *b, BIO_callback_fn callback);
  263. OSSL_DEPRECATEDIN_3_0 long BIO_debug_callback(BIO *bio, int cmd,
  264. const char *argp, int argi,
  265. long argl, long ret);
  266. # endif
  267. typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,
  268. size_t len, int argi,
  269. long argl, int ret, size_t *processed);
  270. BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);
  271. void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);
  272. long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len,
  273. int argi, long argl, int ret, size_t *processed);
  274. char *BIO_get_callback_arg(const BIO *b);
  275. void BIO_set_callback_arg(BIO *b, char *arg);
  276. typedef struct bio_method_st BIO_METHOD;
  277. const char *BIO_method_name(const BIO *b);
  278. int BIO_method_type(const BIO *b);
  279. typedef int BIO_info_cb(BIO *, int, int);
  280. typedef BIO_info_cb bio_info_cb; /* backward compatibility */
  281. SKM_DEFINE_STACK_OF_INTERNAL(BIO, BIO, BIO)
  282. #define sk_BIO_num(sk) OPENSSL_sk_num(ossl_check_const_BIO_sk_type(sk))
  283. #define sk_BIO_value(sk, idx) ((BIO *)OPENSSL_sk_value(ossl_check_const_BIO_sk_type(sk), (idx)))
  284. #define sk_BIO_new(cmp) ((STACK_OF(BIO) *)OPENSSL_sk_new(ossl_check_BIO_compfunc_type(cmp)))
  285. #define sk_BIO_new_null() ((STACK_OF(BIO) *)OPENSSL_sk_new_null())
  286. #define sk_BIO_new_reserve(cmp, n) ((STACK_OF(BIO) *)OPENSSL_sk_new_reserve(ossl_check_BIO_compfunc_type(cmp), (n)))
  287. #define sk_BIO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_BIO_sk_type(sk), (n))
  288. #define sk_BIO_free(sk) OPENSSL_sk_free(ossl_check_BIO_sk_type(sk))
  289. #define sk_BIO_zero(sk) OPENSSL_sk_zero(ossl_check_BIO_sk_type(sk))
  290. #define sk_BIO_delete(sk, i) ((BIO *)OPENSSL_sk_delete(ossl_check_BIO_sk_type(sk), (i)))
  291. #define sk_BIO_delete_ptr(sk, ptr) ((BIO *)OPENSSL_sk_delete_ptr(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)))
  292. #define sk_BIO_push(sk, ptr) OPENSSL_sk_push(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
  293. #define sk_BIO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
  294. #define sk_BIO_pop(sk) ((BIO *)OPENSSL_sk_pop(ossl_check_BIO_sk_type(sk)))
  295. #define sk_BIO_shift(sk) ((BIO *)OPENSSL_sk_shift(ossl_check_BIO_sk_type(sk)))
  296. #define sk_BIO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_BIO_sk_type(sk),ossl_check_BIO_freefunc_type(freefunc))
  297. #define sk_BIO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), (idx))
  298. #define sk_BIO_set(sk, idx, ptr) ((BIO *)OPENSSL_sk_set(ossl_check_BIO_sk_type(sk), (idx), ossl_check_BIO_type(ptr)))
  299. #define sk_BIO_find(sk, ptr) OPENSSL_sk_find(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
  300. #define sk_BIO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
  301. #define sk_BIO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), pnum)
  302. #define sk_BIO_sort(sk) OPENSSL_sk_sort(ossl_check_BIO_sk_type(sk))
  303. #define sk_BIO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_BIO_sk_type(sk))
  304. #define sk_BIO_dup(sk) ((STACK_OF(BIO) *)OPENSSL_sk_dup(ossl_check_const_BIO_sk_type(sk)))
  305. #define sk_BIO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(BIO) *)OPENSSL_sk_deep_copy(ossl_check_const_BIO_sk_type(sk), ossl_check_BIO_copyfunc_type(copyfunc), ossl_check_BIO_freefunc_type(freefunc)))
  306. #define sk_BIO_set_cmp_func(sk, cmp) ((sk_BIO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_BIO_sk_type(sk), ossl_check_BIO_compfunc_type(cmp)))
  307. /* Prefix and suffix callback in ASN1 BIO */
  308. typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,
  309. void *parg);
  310. typedef void (*BIO_dgram_sctp_notification_handler_fn) (BIO *b,
  311. void *context,
  312. void *buf);
  313. # ifndef OPENSSL_NO_SCTP
  314. /* SCTP parameter structs */
  315. struct bio_dgram_sctp_sndinfo {
  316. uint16_t snd_sid;
  317. uint16_t snd_flags;
  318. uint32_t snd_ppid;
  319. uint32_t snd_context;
  320. };
  321. struct bio_dgram_sctp_rcvinfo {
  322. uint16_t rcv_sid;
  323. uint16_t rcv_ssn;
  324. uint16_t rcv_flags;
  325. uint32_t rcv_ppid;
  326. uint32_t rcv_tsn;
  327. uint32_t rcv_cumtsn;
  328. uint32_t rcv_context;
  329. };
  330. struct bio_dgram_sctp_prinfo {
  331. uint16_t pr_policy;
  332. uint32_t pr_value;
  333. };
  334. # endif
  335. /* BIO_sendmmsg/BIO_recvmmsg-related definitions */
  336. typedef struct bio_msg_st {
  337. void *data;
  338. size_t data_len;
  339. BIO_ADDR *peer, *local;
  340. uint64_t flags;
  341. } BIO_MSG;
  342. typedef struct bio_mmsg_cb_args_st {
  343. BIO_MSG *msg;
  344. size_t stride, num_msg;
  345. uint64_t flags;
  346. size_t *msgs_processed;
  347. } BIO_MMSG_CB_ARGS;
  348. #define BIO_POLL_DESCRIPTOR_TYPE_NONE 0
  349. #define BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD 1
  350. #define BIO_POLL_DESCRIPTOR_TYPE_SSL 2
  351. #define BIO_POLL_DESCRIPTOR_CUSTOM_START 8192
  352. typedef struct bio_poll_descriptor_st {
  353. uint32_t type;
  354. union {
  355. int fd;
  356. void *custom;
  357. uintptr_t custom_ui;
  358. SSL *ssl;
  359. } value;
  360. } BIO_POLL_DESCRIPTOR;
  361. /*
  362. * #define BIO_CONN_get_param_hostname BIO_ctrl
  363. */
  364. # define BIO_C_SET_CONNECT 100
  365. # define BIO_C_DO_STATE_MACHINE 101
  366. # define BIO_C_SET_NBIO 102
  367. /* # define BIO_C_SET_PROXY_PARAM 103 */
  368. # define BIO_C_SET_FD 104
  369. # define BIO_C_GET_FD 105
  370. # define BIO_C_SET_FILE_PTR 106
  371. # define BIO_C_GET_FILE_PTR 107
  372. # define BIO_C_SET_FILENAME 108
  373. # define BIO_C_SET_SSL 109
  374. # define BIO_C_GET_SSL 110
  375. # define BIO_C_SET_MD 111
  376. # define BIO_C_GET_MD 112
  377. # define BIO_C_GET_CIPHER_STATUS 113
  378. # define BIO_C_SET_BUF_MEM 114
  379. # define BIO_C_GET_BUF_MEM_PTR 115
  380. # define BIO_C_GET_BUFF_NUM_LINES 116
  381. # define BIO_C_SET_BUFF_SIZE 117
  382. # define BIO_C_SET_ACCEPT 118
  383. # define BIO_C_SSL_MODE 119
  384. # define BIO_C_GET_MD_CTX 120
  385. /* # define BIO_C_GET_PROXY_PARAM 121 */
  386. # define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */
  387. # define BIO_C_GET_CONNECT 123
  388. # define BIO_C_GET_ACCEPT 124
  389. # define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
  390. # define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
  391. # define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
  392. # define BIO_C_FILE_SEEK 128
  393. # define BIO_C_GET_CIPHER_CTX 129
  394. # define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input
  395. * value */
  396. # define BIO_C_SET_BIND_MODE 131
  397. # define BIO_C_GET_BIND_MODE 132
  398. # define BIO_C_FILE_TELL 133
  399. # define BIO_C_GET_SOCKS 134
  400. # define BIO_C_SET_SOCKS 135
  401. # define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */
  402. # define BIO_C_GET_WRITE_BUF_SIZE 137
  403. # define BIO_C_MAKE_BIO_PAIR 138
  404. # define BIO_C_DESTROY_BIO_PAIR 139
  405. # define BIO_C_GET_WRITE_GUARANTEE 140
  406. # define BIO_C_GET_READ_REQUEST 141
  407. # define BIO_C_SHUTDOWN_WR 142
  408. # define BIO_C_NREAD0 143
  409. # define BIO_C_NREAD 144
  410. # define BIO_C_NWRITE0 145
  411. # define BIO_C_NWRITE 146
  412. # define BIO_C_RESET_READ_REQUEST 147
  413. # define BIO_C_SET_MD_CTX 148
  414. # define BIO_C_SET_PREFIX 149
  415. # define BIO_C_GET_PREFIX 150
  416. # define BIO_C_SET_SUFFIX 151
  417. # define BIO_C_GET_SUFFIX 152
  418. # define BIO_C_SET_EX_ARG 153
  419. # define BIO_C_GET_EX_ARG 154
  420. # define BIO_C_SET_CONNECT_MODE 155
  421. # define BIO_C_SET_TFO 156 /* like BIO_C_SET_NBIO */
  422. # define BIO_C_SET_SOCK_TYPE 157
  423. # define BIO_C_GET_SOCK_TYPE 158
  424. # define BIO_C_GET_DGRAM_BIO 159
  425. # define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
  426. # define BIO_get_app_data(s) BIO_get_ex_data(s,0)
  427. # define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
  428. # define BIO_set_tfo(b,n) BIO_ctrl(b,BIO_C_SET_TFO,(n),NULL)
  429. # ifndef OPENSSL_NO_SOCK
  430. /* IP families we support, for BIO_s_connect() and BIO_s_accept() */
  431. /* Note: the underlying operating system may not support some of them */
  432. # define BIO_FAMILY_IPV4 4
  433. # define BIO_FAMILY_IPV6 6
  434. # define BIO_FAMILY_IPANY 256
  435. /* BIO_s_connect() */
  436. # define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \
  437. (char *)(name))
  438. # define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1, \
  439. (char *)(port))
  440. # define BIO_set_conn_address(b,addr) BIO_ctrl(b,BIO_C_SET_CONNECT,2, \
  441. (char *)(addr))
  442. # define BIO_set_conn_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)
  443. # define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))
  444. # define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))
  445. # define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))
  446. # define BIO_get_conn_ip_family(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
  447. # define BIO_get_conn_mode(b) BIO_ctrl(b,BIO_C_GET_CONNECT,4,NULL)
  448. # define BIO_set_conn_mode(b,n) BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)
  449. # define BIO_set_sock_type(b,t) BIO_ctrl(b,BIO_C_SET_SOCK_TYPE,(t),NULL)
  450. # define BIO_get_sock_type(b) BIO_ctrl(b,BIO_C_GET_SOCK_TYPE,0,NULL)
  451. # define BIO_get0_dgram_bio(b, p) BIO_ctrl(b,BIO_C_GET_DGRAM_BIO,0,(void *)(BIO **)(p))
  452. /* BIO_s_accept() */
  453. # define BIO_set_accept_name(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \
  454. (char *)(name))
  455. # define BIO_set_accept_port(b,port) BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \
  456. (char *)(port))
  457. # define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))
  458. # define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))
  459. # define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))
  460. # define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))
  461. /* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
  462. # define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL)
  463. # define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \
  464. (char *)(bio))
  465. # define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)
  466. # define BIO_get_accept_ip_family(b) BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)
  467. # define BIO_set_tfo_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,5,(n)?(void *)"a":NULL)
  468. /* Aliases kept for backward compatibility */
  469. # define BIO_BIND_NORMAL 0
  470. # define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR
  471. # define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR
  472. # define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
  473. # define BIO_get_bind_mode(b) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
  474. # endif /* OPENSSL_NO_SOCK */
  475. # define BIO_do_connect(b) BIO_do_handshake(b)
  476. # define BIO_do_accept(b) BIO_do_handshake(b)
  477. # define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
  478. /* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
  479. # define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
  480. # define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c))
  481. /* BIO_s_file() */
  482. # define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))
  483. # define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp))
  484. /* BIO_s_fd() and BIO_s_file() */
  485. # define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
  486. # define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
  487. /*
  488. * name is cast to lose const, but might be better to route through a
  489. * function so we can do it safely
  490. */
  491. # ifdef CONST_STRICT
  492. /*
  493. * If you are wondering why this isn't defined, its because CONST_STRICT is
  494. * purely a compile-time kludge to allow const to be checked.
  495. */
  496. int BIO_read_filename(BIO *b, const char *name);
  497. # else
  498. # define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
  499. BIO_CLOSE|BIO_FP_READ,(char *)(name))
  500. # endif
  501. # define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
  502. BIO_CLOSE|BIO_FP_WRITE,name)
  503. # define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
  504. BIO_CLOSE|BIO_FP_APPEND,name)
  505. # define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
  506. BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
  507. /*
  508. * WARNING WARNING, this ups the reference count on the read bio of the SSL
  509. * structure. This is because the ssl read BIO is now pointed to by the
  510. * next_bio field in the bio. So when you free the BIO, make sure you are
  511. * doing a BIO_free_all() to catch the underlying BIO.
  512. */
  513. # define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl))
  514. # define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp))
  515. # define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
  516. # define BIO_set_ssl_renegotiate_bytes(b,num) \
  517. BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
  518. # define BIO_get_num_renegotiates(b) \
  519. BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)
  520. # define BIO_set_ssl_renegotiate_timeout(b,seconds) \
  521. BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
  522. /* defined in evp.h */
  523. /* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */
  524. # define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp))
  525. # define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm))
  526. # define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \
  527. (char *)(pp))
  528. # define BIO_set_mem_eof_return(b,v) \
  529. BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
  530. /* For the BIO_f_buffer() type */
  531. # define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
  532. # define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
  533. # define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
  534. # define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
  535. # define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
  536. /* Don't use the next one unless you know what you are doing :-) */
  537. # define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
  538. # define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
  539. # define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
  540. # define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
  541. # define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
  542. # define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
  543. # define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
  544. /* ...pending macros have inappropriate return type */
  545. size_t BIO_ctrl_pending(BIO *b);
  546. size_t BIO_ctrl_wpending(BIO *b);
  547. # define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
  548. # define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
  549. cbp)
  550. # define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
  551. /* For the BIO_f_buffer() type */
  552. # define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
  553. # define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s))
  554. /* For BIO_s_bio() */
  555. # define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
  556. # define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
  557. # define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
  558. # define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
  559. # define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
  560. /* macros with inappropriate type -- but ...pending macros use int too: */
  561. # define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
  562. # define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
  563. size_t BIO_ctrl_get_write_guarantee(BIO *b);
  564. size_t BIO_ctrl_get_read_request(BIO *b);
  565. int BIO_ctrl_reset_read_request(BIO *b);
  566. /* ctrl macros for dgram */
  567. # define BIO_ctrl_dgram_connect(b,peer) \
  568. (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer))
  569. # define BIO_ctrl_set_connected(b,peer) \
  570. (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer))
  571. # define BIO_dgram_recv_timedout(b) \
  572. (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
  573. # define BIO_dgram_send_timedout(b) \
  574. (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
  575. # define BIO_dgram_get_peer(b,peer) \
  576. (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer))
  577. # define BIO_dgram_set_peer(b,peer) \
  578. (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer))
  579. # define BIO_dgram_detect_peer_addr(b,peer) \
  580. (int)BIO_ctrl(b, BIO_CTRL_DGRAM_DETECT_PEER_ADDR, 0, (char *)(peer))
  581. # define BIO_dgram_get_mtu_overhead(b) \
  582. (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
  583. # define BIO_dgram_get_local_addr_cap(b) \
  584. (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, NULL)
  585. # define BIO_dgram_get_local_addr_enable(b, penable) \
  586. (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, (char *)(penable))
  587. # define BIO_dgram_set_local_addr_enable(b, enable) \
  588. (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, (enable), NULL)
  589. # define BIO_dgram_get_effective_caps(b) \
  590. (uint32_t)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS, 0, NULL)
  591. # define BIO_dgram_get_caps(b) \
  592. (uint32_t)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_CAPS, 0, NULL)
  593. # define BIO_dgram_set_caps(b, caps) \
  594. (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_CAPS, (long)(caps), NULL)
  595. # define BIO_dgram_get_no_trunc(b) \
  596. (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, NULL)
  597. # define BIO_dgram_set_no_trunc(b, enable) \
  598. (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_NO_TRUNC, (enable), NULL)
  599. # define BIO_dgram_get_mtu(b) \
  600. (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU, 0, NULL)
  601. # define BIO_dgram_set_mtu(b, mtu) \
  602. (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_MTU, (mtu), NULL)
  603. /* ctrl macros for BIO_f_prefix */
  604. # define BIO_set_prefix(b,p) BIO_ctrl((b), BIO_CTRL_SET_PREFIX, 0, (void *)(p))
  605. # define BIO_set_indent(b,i) BIO_ctrl((b), BIO_CTRL_SET_INDENT, (i), NULL)
  606. # define BIO_get_indent(b) BIO_ctrl((b), BIO_CTRL_GET_INDENT, 0, NULL)
  607. #define BIO_get_ex_new_index(l, p, newf, dupf, freef) \
  608. CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)
  609. int BIO_set_ex_data(BIO *bio, int idx, void *data);
  610. void *BIO_get_ex_data(const BIO *bio, int idx);
  611. uint64_t BIO_number_read(BIO *bio);
  612. uint64_t BIO_number_written(BIO *bio);
  613. /* For BIO_f_asn1() */
  614. int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
  615. asn1_ps_func *prefix_free);
  616. int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
  617. asn1_ps_func **pprefix_free);
  618. int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
  619. asn1_ps_func *suffix_free);
  620. int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
  621. asn1_ps_func **psuffix_free);
  622. const BIO_METHOD *BIO_s_file(void);
  623. BIO *BIO_new_file(const char *filename, const char *mode);
  624. BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio);
  625. # ifndef OPENSSL_NO_STDIO
  626. BIO *BIO_new_fp(FILE *stream, int close_flag);
  627. # endif
  628. BIO *BIO_new_ex(OSSL_LIB_CTX *libctx, const BIO_METHOD *method);
  629. BIO *BIO_new(const BIO_METHOD *type);
  630. int BIO_free(BIO *a);
  631. void BIO_set_data(BIO *a, void *ptr);
  632. void *BIO_get_data(BIO *a);
  633. void BIO_set_init(BIO *a, int init);
  634. int BIO_get_init(BIO *a);
  635. void BIO_set_shutdown(BIO *a, int shut);
  636. int BIO_get_shutdown(BIO *a);
  637. void BIO_vfree(BIO *a);
  638. int BIO_up_ref(BIO *a);
  639. int BIO_read(BIO *b, void *data, int dlen);
  640. int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
  641. __owur int BIO_recvmmsg(BIO *b, BIO_MSG *msg,
  642. size_t stride, size_t num_msg, uint64_t flags,
  643. size_t *msgs_processed);
  644. int BIO_gets(BIO *bp, char *buf, int size);
  645. int BIO_get_line(BIO *bio, char *buf, int size);
  646. int BIO_write(BIO *b, const void *data, int dlen);
  647. int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
  648. __owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg,
  649. size_t stride, size_t num_msg, uint64_t flags,
  650. size_t *msgs_processed);
  651. __owur int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
  652. __owur int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
  653. int BIO_puts(BIO *bp, const char *buf);
  654. int BIO_indent(BIO *b, int indent, int max);
  655. long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
  656. long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
  657. void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
  658. long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
  659. BIO *BIO_push(BIO *b, BIO *append);
  660. BIO *BIO_pop(BIO *b);
  661. void BIO_free_all(BIO *a);
  662. BIO *BIO_find_type(BIO *b, int bio_type);
  663. BIO *BIO_next(BIO *b);
  664. void BIO_set_next(BIO *b, BIO *next);
  665. BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
  666. int BIO_get_retry_reason(BIO *bio);
  667. void BIO_set_retry_reason(BIO *bio, int reason);
  668. BIO *BIO_dup_chain(BIO *in);
  669. int BIO_nread0(BIO *bio, char **buf);
  670. int BIO_nread(BIO *bio, char **buf, int num);
  671. int BIO_nwrite0(BIO *bio, char **buf);
  672. int BIO_nwrite(BIO *bio, char **buf, int num);
  673. const BIO_METHOD *BIO_s_mem(void);
  674. # ifndef OPENSSL_NO_DGRAM
  675. const BIO_METHOD *BIO_s_dgram_mem(void);
  676. # endif
  677. const BIO_METHOD *BIO_s_secmem(void);
  678. BIO *BIO_new_mem_buf(const void *buf, int len);
  679. # ifndef OPENSSL_NO_SOCK
  680. const BIO_METHOD *BIO_s_socket(void);
  681. const BIO_METHOD *BIO_s_connect(void);
  682. const BIO_METHOD *BIO_s_accept(void);
  683. # endif
  684. const BIO_METHOD *BIO_s_fd(void);
  685. const BIO_METHOD *BIO_s_log(void);
  686. const BIO_METHOD *BIO_s_bio(void);
  687. const BIO_METHOD *BIO_s_null(void);
  688. const BIO_METHOD *BIO_f_null(void);
  689. const BIO_METHOD *BIO_f_buffer(void);
  690. const BIO_METHOD *BIO_f_readbuffer(void);
  691. const BIO_METHOD *BIO_f_linebuffer(void);
  692. const BIO_METHOD *BIO_f_nbio_test(void);
  693. const BIO_METHOD *BIO_f_prefix(void);
  694. const BIO_METHOD *BIO_s_core(void);
  695. # ifndef OPENSSL_NO_DGRAM
  696. const BIO_METHOD *BIO_s_dgram_pair(void);
  697. const BIO_METHOD *BIO_s_datagram(void);
  698. int BIO_dgram_non_fatal_error(int error);
  699. BIO *BIO_new_dgram(int fd, int close_flag);
  700. # ifndef OPENSSL_NO_SCTP
  701. const BIO_METHOD *BIO_s_datagram_sctp(void);
  702. BIO *BIO_new_dgram_sctp(int fd, int close_flag);
  703. int BIO_dgram_is_sctp(BIO *bio);
  704. int BIO_dgram_sctp_notification_cb(BIO *b,
  705. BIO_dgram_sctp_notification_handler_fn handle_notifications,
  706. void *context);
  707. int BIO_dgram_sctp_wait_for_dry(BIO *b);
  708. int BIO_dgram_sctp_msg_waiting(BIO *b);
  709. # endif
  710. # endif
  711. # ifndef OPENSSL_NO_SOCK
  712. int BIO_sock_should_retry(int i);
  713. int BIO_sock_non_fatal_error(int error);
  714. int BIO_err_is_non_fatal(unsigned int errcode);
  715. int BIO_socket_wait(int fd, int for_read, time_t max_time);
  716. # endif
  717. int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds);
  718. int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds);
  719. int BIO_fd_should_retry(int i);
  720. int BIO_fd_non_fatal_error(int error);
  721. int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
  722. void *u, const void *s, int len);
  723. int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
  724. void *u, const void *s, int len, int indent);
  725. int BIO_dump(BIO *b, const void *bytes, int len);
  726. int BIO_dump_indent(BIO *b, const void *bytes, int len, int indent);
  727. # ifndef OPENSSL_NO_STDIO
  728. int BIO_dump_fp(FILE *fp, const void *s, int len);
  729. int BIO_dump_indent_fp(FILE *fp, const void *s, int len, int indent);
  730. # endif
  731. int BIO_hex_string(BIO *out, int indent, int width, const void *data,
  732. int datalen);
  733. # ifndef OPENSSL_NO_SOCK
  734. BIO_ADDR *BIO_ADDR_new(void);
  735. int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src);
  736. BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap);
  737. int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
  738. const void *where, size_t wherelen, unsigned short port);
  739. void BIO_ADDR_free(BIO_ADDR *);
  740. void BIO_ADDR_clear(BIO_ADDR *ap);
  741. int BIO_ADDR_family(const BIO_ADDR *ap);
  742. int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
  743. unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
  744. char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
  745. char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
  746. char *BIO_ADDR_path_string(const BIO_ADDR *ap);
  747. const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
  748. int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
  749. int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
  750. int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
  751. const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
  752. void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
  753. enum BIO_hostserv_priorities {
  754. BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
  755. };
  756. int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
  757. enum BIO_hostserv_priorities hostserv_prio);
  758. enum BIO_lookup_type {
  759. BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
  760. };
  761. int BIO_lookup(const char *host, const char *service,
  762. enum BIO_lookup_type lookup_type,
  763. int family, int socktype, BIO_ADDRINFO **res);
  764. int BIO_lookup_ex(const char *host, const char *service,
  765. int lookup_type, int family, int socktype, int protocol,
  766. BIO_ADDRINFO **res);
  767. int BIO_sock_error(int sock);
  768. int BIO_socket_ioctl(int fd, long type, void *arg);
  769. int BIO_socket_nbio(int fd, int mode);
  770. int BIO_sock_init(void);
  771. # ifndef OPENSSL_NO_DEPRECATED_1_1_0
  772. # define BIO_sock_cleanup() while(0) continue
  773. # endif
  774. int BIO_set_tcp_ndelay(int sock, int turn_on);
  775. # ifndef OPENSSL_NO_DEPRECATED_1_1_0
  776. OSSL_DEPRECATEDIN_1_1_0 struct hostent *BIO_gethostbyname(const char *name);
  777. OSSL_DEPRECATEDIN_1_1_0 int BIO_get_port(const char *str, unsigned short *port_ptr);
  778. OSSL_DEPRECATEDIN_1_1_0 int BIO_get_host_ip(const char *str, unsigned char *ip);
  779. OSSL_DEPRECATEDIN_1_1_0 int BIO_get_accept_socket(char *host_port, int mode);
  780. OSSL_DEPRECATEDIN_1_1_0 int BIO_accept(int sock, char **ip_port);
  781. # endif
  782. union BIO_sock_info_u {
  783. BIO_ADDR *addr;
  784. };
  785. enum BIO_sock_info_type {
  786. BIO_SOCK_INFO_ADDRESS
  787. };
  788. int BIO_sock_info(int sock,
  789. enum BIO_sock_info_type type, union BIO_sock_info_u *info);
  790. # define BIO_SOCK_REUSEADDR 0x01
  791. # define BIO_SOCK_V6_ONLY 0x02
  792. # define BIO_SOCK_KEEPALIVE 0x04
  793. # define BIO_SOCK_NONBLOCK 0x08
  794. # define BIO_SOCK_NODELAY 0x10
  795. # define BIO_SOCK_TFO 0x20
  796. int BIO_socket(int domain, int socktype, int protocol, int options);
  797. int BIO_connect(int sock, const BIO_ADDR *addr, int options);
  798. int BIO_bind(int sock, const BIO_ADDR *addr, int options);
  799. int BIO_listen(int sock, const BIO_ADDR *addr, int options);
  800. int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);
  801. int BIO_closesocket(int sock);
  802. BIO *BIO_new_socket(int sock, int close_flag);
  803. BIO *BIO_new_connect(const char *host_port);
  804. BIO *BIO_new_accept(const char *host_port);
  805. # endif /* OPENSSL_NO_SOCK*/
  806. BIO *BIO_new_fd(int fd, int close_flag);
  807. int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
  808. BIO **bio2, size_t writebuf2);
  809. # ifndef OPENSSL_NO_DGRAM
  810. int BIO_new_bio_dgram_pair(BIO **bio1, size_t writebuf1,
  811. BIO **bio2, size_t writebuf2);
  812. # endif
  813. /*
  814. * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
  815. * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default
  816. * value.
  817. */
  818. void BIO_copy_next_retry(BIO *b);
  819. /*
  820. * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
  821. */
  822. # define ossl_bio__attr__(x)
  823. # if defined(__GNUC__) && defined(__STDC_VERSION__) \
  824. && !defined(__MINGW32__) && !defined(__MINGW64__) \
  825. && !defined(__APPLE__)
  826. /*
  827. * Because we support the 'z' modifier, which made its appearance in C99,
  828. * we can't use __attribute__ with pre C99 dialects.
  829. */
  830. # if __STDC_VERSION__ >= 199901L
  831. # undef ossl_bio__attr__
  832. # define ossl_bio__attr__ __attribute__
  833. # if __GNUC__*10 + __GNUC_MINOR__ >= 44
  834. # define ossl_bio__printf__ __gnu_printf__
  835. # else
  836. # define ossl_bio__printf__ __printf__
  837. # endif
  838. # endif
  839. # endif
  840. int BIO_printf(BIO *bio, const char *format, ...)
  841. ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));
  842. int BIO_vprintf(BIO *bio, const char *format, va_list args)
  843. ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));
  844. int BIO_snprintf(char *buf, size_t n, const char *format, ...)
  845. ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));
  846. int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
  847. ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));
  848. # undef ossl_bio__attr__
  849. # undef ossl_bio__printf__
  850. BIO_METHOD *BIO_meth_new(int type, const char *name);
  851. void BIO_meth_free(BIO_METHOD *biom);
  852. int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);
  853. int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,
  854. size_t *);
  855. int BIO_meth_set_write(BIO_METHOD *biom,
  856. int (*write) (BIO *, const char *, int));
  857. int BIO_meth_set_write_ex(BIO_METHOD *biom,
  858. int (*bwrite) (BIO *, const char *, size_t, size_t *));
  859. int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
  860. int (*f) (BIO *, BIO_MSG *, size_t, size_t,
  861. uint64_t, size_t *));
  862. int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
  863. size_t, size_t,
  864. uint64_t, size_t *);
  865. int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
  866. int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);
  867. int BIO_meth_set_read(BIO_METHOD *biom,
  868. int (*read) (BIO *, char *, int));
  869. int BIO_meth_set_read_ex(BIO_METHOD *biom,
  870. int (*bread) (BIO *, char *, size_t, size_t *));
  871. int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
  872. int (*f) (BIO *, BIO_MSG *, size_t, size_t,
  873. uint64_t, size_t *));
  874. int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
  875. size_t, size_t,
  876. uint64_t, size_t *);
  877. int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
  878. int BIO_meth_set_puts(BIO_METHOD *biom,
  879. int (*puts) (BIO *, const char *));
  880. int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
  881. int BIO_meth_set_gets(BIO_METHOD *biom,
  882. int (*ossl_gets) (BIO *, char *, int));
  883. long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
  884. int BIO_meth_set_ctrl(BIO_METHOD *biom,
  885. long (*ctrl) (BIO *, int, long, void *));
  886. int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
  887. int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
  888. int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
  889. int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
  890. long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))
  891. (BIO *, int, BIO_info_cb *);
  892. int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
  893. long (*callback_ctrl) (BIO *, int,
  894. BIO_info_cb *));
  895. # ifdef __cplusplus
  896. }
  897. # endif
  898. #endif