bio.h (41354B)
1 // Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef OPENSSL_HEADER_BIO_H 16 #define OPENSSL_HEADER_BIO_H 17 18 #include <openssl/base.h> // IWYU pragma: export 19 20 #include <stdio.h> // For FILE 21 22 #include <openssl/buffer.h> 23 #include <openssl/err.h> // for ERR_print_errors_fp 24 #include <openssl/ex_data.h> 25 #include <openssl/stack.h> 26 27 #if defined(__cplusplus) 28 extern "C" { 29 #endif 30 31 32 // BIO abstracts over a file-descriptor like interface. 33 34 35 // Allocation and freeing. 36 37 DEFINE_STACK_OF(BIO) 38 39 // BIO_new creates a new BIO with the given method and a reference count of one. 40 // It returns the fresh |BIO|, or NULL on error. 41 OPENSSL_EXPORT BIO *BIO_new(const BIO_METHOD *method); 42 43 // BIO_free decrements the reference count of |bio|. If the reference count 44 // drops to zero, it calls the destroy callback, if present, on the method and 45 // frees |bio| itself. It then repeats that for the next BIO in the chain, if 46 // any. 47 // 48 // It returns one on success or zero otherwise. 49 OPENSSL_EXPORT int BIO_free(BIO *bio); 50 51 // BIO_vfree performs the same actions as |BIO_free|, but has a void return 52 // value. This is provided for API-compat. 53 // 54 // TODO(fork): remove. 55 OPENSSL_EXPORT void BIO_vfree(BIO *bio); 56 57 // BIO_up_ref increments the reference count of |bio| and returns one. 58 OPENSSL_EXPORT int BIO_up_ref(BIO *bio); 59 60 61 // Basic I/O. 62 63 // BIO_read attempts to read |len| bytes into |data|. It returns the number of 64 // bytes read, zero on EOF, or a negative number on error. 65 OPENSSL_EXPORT int BIO_read(BIO *bio, void *data, int len); 66 67 // BIO_gets reads a line from |bio| and writes at most |size| bytes into |buf|. 68 // It returns the number of bytes read or a negative number on error. This 69 // function's output always includes a trailing NUL byte, so it will read at 70 // most |size - 1| bytes. 71 // 72 // If the function read a complete line, the output will include the newline 73 // character, '\n'. If no newline was found before |size - 1| bytes or EOF, it 74 // outputs the bytes which were available. 75 OPENSSL_EXPORT int BIO_gets(BIO *bio, char *buf, int size); 76 77 // BIO_write writes |len| bytes from |data| to |bio|. It returns the number of 78 // bytes written or a negative number on error. 79 OPENSSL_EXPORT int BIO_write(BIO *bio, const void *data, int len); 80 81 // BIO_write_all writes |len| bytes from |data| to |bio|, looping as necessary. 82 // It returns one if all bytes were successfully written and zero on error. 83 OPENSSL_EXPORT int BIO_write_all(BIO *bio, const void *data, size_t len); 84 85 // BIO_puts writes a NUL terminated string from |buf| to |bio|. It returns the 86 // number of bytes written or a negative number on error. 87 OPENSSL_EXPORT int BIO_puts(BIO *bio, const char *buf); 88 89 // BIO_flush flushes any buffered output. It returns one on success and zero 90 // otherwise. 91 OPENSSL_EXPORT int BIO_flush(BIO *bio); 92 93 94 // Low-level control functions. 95 // 96 // These are generic functions for sending control requests to a BIO. In 97 // general one should use the wrapper functions like |BIO_get_close|. 98 99 // BIO_ctrl sends the control request |cmd| to |bio|. The |cmd| argument should 100 // be one of the |BIO_C_*| values. 101 OPENSSL_EXPORT long BIO_ctrl(BIO *bio, int cmd, long larg, void *parg); 102 103 // BIO_ptr_ctrl acts like |BIO_ctrl| but passes the address of a |void*| 104 // pointer as |parg| and returns the value that is written to it, or NULL if 105 // the control request returns <= 0. 106 OPENSSL_EXPORT char *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); 107 108 // BIO_int_ctrl acts like |BIO_ctrl| but passes the address of a copy of |iarg| 109 // as |parg|. 110 OPENSSL_EXPORT long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); 111 112 // BIO_reset resets |bio| to its initial state, the precise meaning of which 113 // depends on the concrete type of |bio|. It returns one on success and zero 114 // otherwise. 115 OPENSSL_EXPORT int BIO_reset(BIO *bio); 116 117 // BIO_eof returns non-zero when |bio| has reached end-of-file. The precise 118 // meaning of which depends on the concrete type of |bio|. Note that in the 119 // case of BIO_pair this always returns non-zero. 120 OPENSSL_EXPORT int BIO_eof(BIO *bio); 121 122 // BIO_set_flags ORs |flags| with |bio->flags|. 123 OPENSSL_EXPORT void BIO_set_flags(BIO *bio, int flags); 124 125 // BIO_clear_flags ANDs |bio->flags| with the bitwise-complement of |flags|. 126 OPENSSL_EXPORT void BIO_clear_flags(BIO *bio, int flags); 127 128 // BIO_test_flags returns |bio->flags| AND |flags|. 129 OPENSSL_EXPORT int BIO_test_flags(const BIO *bio, int flags); 130 131 // BIO_should_read returns non-zero if |bio| encountered a temporary error 132 // while reading (i.e. EAGAIN), indicating that the caller should retry the 133 // read. 134 OPENSSL_EXPORT int BIO_should_read(const BIO *bio); 135 136 // BIO_should_write returns non-zero if |bio| encountered a temporary error 137 // while writing (i.e. EAGAIN), indicating that the caller should retry the 138 // write. 139 OPENSSL_EXPORT int BIO_should_write(const BIO *bio); 140 141 // BIO_should_retry returns non-zero if the reason that caused a failed I/O 142 // operation is temporary and thus the operation should be retried. Otherwise, 143 // it was a permanent error and it returns zero. 144 OPENSSL_EXPORT int BIO_should_retry(const BIO *bio); 145 146 // BIO_should_io_special returns non-zero if |bio| encountered a temporary 147 // error while performing a special I/O operation, indicating that the caller 148 // should retry. The operation that caused the error is returned by 149 // |BIO_get_retry_reason|. 150 OPENSSL_EXPORT int BIO_should_io_special(const BIO *bio); 151 152 // BIO_RR_CONNECT indicates that a connect would have blocked 153 #define BIO_RR_CONNECT 0x02 154 155 // BIO_RR_ACCEPT indicates that an accept would have blocked 156 #define BIO_RR_ACCEPT 0x03 157 158 // BIO_get_retry_reason returns the special I/O operation that needs to be 159 // retried. The return value is one of the |BIO_RR_*| values. 160 OPENSSL_EXPORT int BIO_get_retry_reason(const BIO *bio); 161 162 // BIO_set_retry_reason sets the special I/O operation that needs to be retried 163 // to |reason|, which should be one of the |BIO_RR_*| values. 164 OPENSSL_EXPORT void BIO_set_retry_reason(BIO *bio, int reason); 165 166 // BIO_set_retry_read sets the |BIO_FLAGS_READ| and |BIO_FLAGS_SHOULD_RETRY| 167 // flags on |bio|. 168 OPENSSL_EXPORT void BIO_set_retry_read(BIO *bio); 169 170 // BIO_set_retry_write sets the |BIO_FLAGS_WRITE| and |BIO_FLAGS_SHOULD_RETRY| 171 // flags on |bio|. 172 OPENSSL_EXPORT void BIO_set_retry_write(BIO *bio); 173 174 // BIO_get_retry_flags gets the |BIO_FLAGS_READ|, |BIO_FLAGS_WRITE|, 175 // |BIO_FLAGS_IO_SPECIAL| and |BIO_FLAGS_SHOULD_RETRY| flags from |bio|. 176 OPENSSL_EXPORT int BIO_get_retry_flags(BIO *bio); 177 178 // BIO_clear_retry_flags clears the |BIO_FLAGS_READ|, |BIO_FLAGS_WRITE|, 179 // |BIO_FLAGS_IO_SPECIAL| and |BIO_FLAGS_SHOULD_RETRY| flags from |bio|. 180 OPENSSL_EXPORT void BIO_clear_retry_flags(BIO *bio); 181 182 // BIO_method_type returns the type of |bio|, which is one of the |BIO_TYPE_*| 183 // values. 184 OPENSSL_EXPORT int BIO_method_type(const BIO *bio); 185 186 typedef int BIO_info_cb(BIO *, int, int); 187 188 // BIO_callback_ctrl allows the callback function to be manipulated. The |cmd| 189 // arg will generally be |BIO_CTRL_SET_CALLBACK| but arbitrary command values 190 // can be interpreted by the |BIO|. 191 OPENSSL_EXPORT long BIO_callback_ctrl(BIO *bio, int cmd, BIO_info_cb *fp); 192 193 // BIO_pending returns the number of bytes pending to be read. 194 OPENSSL_EXPORT size_t BIO_pending(const BIO *bio); 195 196 // BIO_ctrl_pending calls |BIO_pending| and exists only for compatibility with 197 // OpenSSL. 198 OPENSSL_EXPORT size_t BIO_ctrl_pending(const BIO *bio); 199 200 // BIO_wpending returns the number of bytes pending to be written. 201 OPENSSL_EXPORT size_t BIO_wpending(const BIO *bio); 202 203 // BIO_set_close sets the close flag for |bio|. The meaning of which depends on 204 // the type of |bio| but, for example, a memory BIO interprets the close flag 205 // as meaning that it owns its buffer. It returns one on success and zero 206 // otherwise. 207 OPENSSL_EXPORT int BIO_set_close(BIO *bio, int close_flag); 208 209 // BIO_number_read returns the number of bytes that have been read from 210 // |bio|. 211 OPENSSL_EXPORT uint64_t BIO_number_read(const BIO *bio); 212 213 // BIO_number_written returns the number of bytes that have been written to 214 // |bio|. 215 OPENSSL_EXPORT uint64_t BIO_number_written(const BIO *bio); 216 217 218 // Managing chains of BIOs. 219 // 220 // BIOs can be put into chains where the output of one is used as the input of 221 // the next etc. The most common case is a buffering BIO, which accepts and 222 // buffers writes until flushed into the next BIO in the chain. 223 224 // BIO_push adds |appended_bio| to the end of the chain with |bio| at the head. 225 // It returns |bio|. Note that |appended_bio| may be the head of a chain itself 226 // and thus this function can be used to join two chains. 227 // 228 // BIO_push takes ownership of the caller's reference to |appended_bio|. 229 OPENSSL_EXPORT BIO *BIO_push(BIO *bio, BIO *appended_bio); 230 231 // BIO_pop removes |bio| from the head of a chain and returns the next BIO in 232 // the chain, or NULL if there is no next BIO. 233 // 234 // The caller takes ownership of the chain's reference to |bio|. 235 OPENSSL_EXPORT BIO *BIO_pop(BIO *bio); 236 237 // BIO_next returns the next BIO in the chain after |bio|, or NULL if there is 238 // no such BIO. 239 OPENSSL_EXPORT BIO *BIO_next(BIO *bio); 240 241 // BIO_free_all calls |BIO_free|. 242 // 243 // TODO(fork): update callers and remove. 244 OPENSSL_EXPORT void BIO_free_all(BIO *bio); 245 246 // BIO_find_type walks a chain of BIOs and returns the first that matches 247 // |type|, which is one of the |BIO_TYPE_*| values. 248 OPENSSL_EXPORT BIO *BIO_find_type(BIO *bio, int type); 249 250 // BIO_copy_next_retry sets the retry flags and |retry_reason| of |bio| from 251 // the next BIO in the chain. 252 OPENSSL_EXPORT void BIO_copy_next_retry(BIO *bio); 253 254 255 // Printf functions. 256 257 // BIO_printf behaves like |printf| but outputs to |bio| rather than a |FILE|. 258 // It returns the number of bytes written or a negative number on error. 259 OPENSSL_EXPORT int BIO_printf(BIO *bio, const char *format, ...) 260 OPENSSL_PRINTF_FORMAT_FUNC(2, 3); 261 262 263 // Utility functions. 264 265 // BIO_indent prints min(|indent|, |max_indent|) spaces. It returns one on 266 // success and zero otherwise. 267 OPENSSL_EXPORT int BIO_indent(BIO *bio, unsigned indent, unsigned max_indent); 268 269 // BIO_hexdump writes a hex dump of |data| to |bio|. Each line will be indented 270 // by |indent| spaces. It returns one on success and zero otherwise. 271 OPENSSL_EXPORT int BIO_hexdump(BIO *bio, const uint8_t *data, size_t len, 272 unsigned indent); 273 274 // ERR_print_errors prints the current contents of the error stack to |bio| 275 // using human readable strings where possible. 276 OPENSSL_EXPORT void ERR_print_errors(BIO *bio); 277 278 // BIO_read_asn1 reads a single ASN.1 object from |bio|. If successful it sets 279 // |*out| to be an allocated buffer (that should be freed with |OPENSSL_free|), 280 // |*out_size| to the length, in bytes, of that buffer and returns one. 281 // Otherwise it returns zero. 282 // 283 // If the length of the object is greater than |max_len| or 2^32 then the 284 // function will fail. Long-form tags are not supported. If the length of the 285 // object is indefinite the full contents of |bio| are read, unless it would be 286 // greater than |max_len|, in which case the function fails. 287 // 288 // If the function fails then some unknown amount of data may have been read 289 // from |bio|. 290 OPENSSL_EXPORT int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, 291 size_t max_len); 292 293 294 // Memory BIOs. 295 // 296 // Memory BIOs can be used as a read-only source (with |BIO_new_mem_buf|) or a 297 // writable sink (with |BIO_new|, |BIO_s_mem| and |BIO_mem_contents|). Data 298 // written to a writable, memory BIO can be recalled by reading from it. 299 // 300 // Calling |BIO_reset| on a read-only BIO resets it to the original contents. 301 // On a writable BIO, it clears any data. 302 // 303 // If the close flag is set to |BIO_NOCLOSE| (not the default) then the 304 // underlying |BUF_MEM| will not be freed when the |BIO| is freed. 305 // 306 // Memory BIOs support |BIO_gets| and |BIO_puts|. 307 // 308 // |BIO_ctrl_pending| returns the number of bytes currently stored. 309 310 // BIO_NOCLOSE and |BIO_CLOSE| can be used as symbolic arguments when a "close 311 // flag" is passed to a BIO function. 312 #define BIO_NOCLOSE 0 313 #define BIO_CLOSE 1 314 315 // BIO_s_mem returns a |BIO_METHOD| that uses a in-memory buffer. 316 OPENSSL_EXPORT const BIO_METHOD *BIO_s_mem(void); 317 318 // BIO_new_mem_buf creates read-only BIO that reads from |len| bytes at |buf|. 319 // It returns the BIO or NULL on error. This function does not copy or take 320 // ownership of |buf|. The caller must ensure the memory pointed to by |buf| 321 // outlives the |BIO|. 322 // 323 // If |len| is negative, then |buf| is treated as a NUL-terminated string, but 324 // don't depend on this in new code. 325 OPENSSL_EXPORT BIO *BIO_new_mem_buf(const void *buf, ossl_ssize_t len); 326 327 // BIO_mem_contents sets |*out_contents| to point to the current contents of 328 // |bio| and |*out_len| to contain the length of that data. It returns one on 329 // success and zero otherwise. 330 OPENSSL_EXPORT int BIO_mem_contents(const BIO *bio, 331 const uint8_t **out_contents, 332 size_t *out_len); 333 334 // BIO_get_mem_data sets |*contents| to point to the current contents of |bio| 335 // and returns the length of the data. 336 // 337 // WARNING: don't use this, use |BIO_mem_contents|. A return value of zero from 338 // this function can mean either that it failed or that the memory buffer is 339 // empty. 340 OPENSSL_EXPORT long BIO_get_mem_data(BIO *bio, char **contents); 341 342 // BIO_get_mem_ptr sets |*out| to a BUF_MEM containing the current contents of 343 // |bio|. It returns one on success or zero on error. 344 OPENSSL_EXPORT int BIO_get_mem_ptr(BIO *bio, BUF_MEM **out); 345 346 // BIO_set_mem_buf sets |b| as the contents of |bio|. If |take_ownership| is 347 // non-zero, then |b| will be freed when |bio| is closed. Returns one on 348 // success or zero otherwise. 349 OPENSSL_EXPORT int BIO_set_mem_buf(BIO *bio, BUF_MEM *b, int take_ownership); 350 351 // BIO_set_mem_eof_return sets the value that will be returned from reading 352 // |bio| when empty. If |eof_value| is zero then an empty memory BIO will 353 // return EOF (that is it will return zero and |BIO_should_retry| will be 354 // false). If |eof_value| is non zero then it will return |eof_value| when it 355 // is empty and it will set the read retry flag (that is |BIO_read_retry| is 356 // true). To avoid ambiguity with a normal positive return value, |eof_value| 357 // should be set to a negative value, typically -1. 358 // 359 // For a read-only BIO, the default is zero (EOF). For a writable BIO, the 360 // default is -1 so that additional data can be written once exhausted. 361 OPENSSL_EXPORT int BIO_set_mem_eof_return(BIO *bio, int eof_value); 362 363 364 // File descriptor BIOs. 365 // 366 // File descriptor BIOs are wrappers around the system's |read| and |write| 367 // functions. If the close flag is set then then |close| is called on the 368 // underlying file descriptor when the BIO is freed. 369 // 370 // |BIO_reset| attempts to seek the file pointer to the start of file using 371 // |lseek|. 372 373 #if !defined(OPENSSL_NO_POSIX_IO) 374 // BIO_s_fd returns a |BIO_METHOD| for file descriptor fds. 375 OPENSSL_EXPORT const BIO_METHOD *BIO_s_fd(void); 376 377 // BIO_new_fd creates a new file descriptor BIO wrapping |fd|. If |close_flag| 378 // is non-zero, then |fd| will be closed when the BIO is. 379 OPENSSL_EXPORT BIO *BIO_new_fd(int fd, int close_flag); 380 #endif 381 382 // BIO_set_fd sets the file descriptor of |bio| to |fd|. If |close_flag| is 383 // non-zero then |fd| will be closed when |bio| is. It returns one on success 384 // or zero on error. 385 // 386 // This function may also be used with socket BIOs (see |BIO_s_socket| and 387 // |BIO_new_socket|). 388 OPENSSL_EXPORT int BIO_set_fd(BIO *bio, int fd, int close_flag); 389 390 // BIO_get_fd returns the file descriptor currently in use by |bio| or -1 if 391 // |bio| does not wrap a file descriptor. If there is a file descriptor and 392 // |out_fd| is not NULL, it also sets |*out_fd| to the file descriptor. 393 // 394 // This function may also be used with socket BIOs (see |BIO_s_socket| and 395 // |BIO_new_socket|). 396 OPENSSL_EXPORT int BIO_get_fd(BIO *bio, int *out_fd); 397 398 399 // File BIOs. 400 // 401 // File BIOs are wrappers around a C |FILE| object. 402 // 403 // |BIO_flush| on a file BIO calls |fflush| on the wrapped stream. 404 // 405 // |BIO_reset| attempts to seek the file pointer to the start of file using 406 // |fseek|. 407 // 408 // Setting the close flag causes |fclose| to be called on the stream when the 409 // BIO is freed. 410 411 // BIO_s_file returns a BIO_METHOD that wraps a |FILE|. 412 OPENSSL_EXPORT const BIO_METHOD *BIO_s_file(void); 413 414 // BIO_new_file creates a file BIO by opening |filename| with the given mode. 415 // See the |fopen| manual page for details of the mode argument. On Windows, 416 // files may be opened in either binary or text mode so, as in |fopen|, callers 417 // must specify the desired option in |mode|. 418 OPENSSL_EXPORT BIO *BIO_new_file(const char *filename, const char *mode); 419 420 // BIO_FP_TEXT indicates the |FILE| should be switched to text mode on Windows. 421 // It has no effect on non-Windows platforms. 422 #define BIO_FP_TEXT 0x10 423 424 // BIO_new_fp creates a new file BIO that wraps |file|. If |flags| contains 425 // |BIO_CLOSE|, then |fclose| will be called on |file| when the BIO is closed. 426 // 427 // On Windows, if |flags| contains |BIO_FP_TEXT|, this function will 428 // additionally switch |file| to text mode. This is not recommended, but may be 429 // required for OpenSSL compatibility. If |file| was not already in text mode, 430 // mode changes can cause unflushed data in |file| to be written in unexpected 431 // ways. See |_setmode| in Windows documentation for details. 432 // 433 // Unlike OpenSSL, if |flags| does not contain |BIO_FP_TEXT|, the translation 434 // mode of |file| is left as-is. In OpenSSL, |file| will be set to binary, with 435 // the same pitfalls as above. BoringSSL does not do this so that wrapping a 436 // |FILE| in a |BIO| will not inadvertently change its state. 437 // 438 // To avoid these pitfalls, callers should set the desired translation mode when 439 // opening the file. If targeting just BoringSSL, this is sufficient. If 440 // targeting both OpenSSL and BoringSSL, callers should set |BIO_FP_TEXT| to 441 // match the desired state of the file. 442 OPENSSL_EXPORT BIO *BIO_new_fp(FILE *file, int flags); 443 444 // BIO_get_fp sets |*out_file| to the current |FILE| for |bio|. It returns one 445 // on success and zero otherwise. 446 OPENSSL_EXPORT int BIO_get_fp(BIO *bio, FILE **out_file); 447 448 // BIO_set_fp sets the |FILE| for |bio|. If |flags| contains |BIO_CLOSE| then 449 // |fclose| will be called on |file| when |bio| is closed. It returns one on 450 // success and zero otherwise. 451 // 452 // On Windows, if |flags| contains |BIO_FP_TEXT|, this function will 453 // additionally switch |file| to text mode. This is not recommended, but may be 454 // required for OpenSSL compatibility. If |file| was not already in text mode, 455 // mode changes can cause unflushed data in |file| to be written in unexpected 456 // ways. See |_setmode| in Windows documentation for details. 457 // 458 // Unlike OpenSSL, if |flags| does not contain |BIO_FP_TEXT|, the translation 459 // mode of |file| is left as-is. In OpenSSL, |file| will be set to binary, with 460 // the same pitfalls as above. BoringSSL does not do this so that wrapping a 461 // |FILE| in a |BIO| will not inadvertently change its state. 462 // 463 // To avoid these pitfalls, callers should set the desired translation mode when 464 // opening the file. If targeting just BoringSSL, this is sufficient. If 465 // targeting both OpenSSL and BoringSSL, callers should set |BIO_FP_TEXT| to 466 // match the desired state of the file. 467 OPENSSL_EXPORT int BIO_set_fp(BIO *bio, FILE *file, int flags); 468 469 // BIO_read_filename opens |filename| for reading and sets the result as the 470 // |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| 471 // will be closed when |bio| is freed. On Windows, the file is opened in binary 472 // mode. 473 OPENSSL_EXPORT int BIO_read_filename(BIO *bio, const char *filename); 474 475 // BIO_write_filename opens |filename| for writing and sets the result as the 476 // |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| 477 // will be closed when |bio| is freed. On Windows, the file is opened in binary 478 // mode. 479 OPENSSL_EXPORT int BIO_write_filename(BIO *bio, const char *filename); 480 481 // BIO_append_filename opens |filename| for appending and sets the result as 482 // the |FILE| for |bio|. It returns one on success and zero otherwise. The 483 // |FILE| will be closed when |bio| is freed. On Windows, the file is opened in 484 // binary mode. 485 OPENSSL_EXPORT int BIO_append_filename(BIO *bio, const char *filename); 486 487 // BIO_rw_filename opens |filename| for reading and writing and sets the result 488 // as the |FILE| for |bio|. It returns one on success and zero otherwise. The 489 // |FILE| will be closed when |bio| is freed. On Windows, the file is opened in 490 // binary mode. 491 OPENSSL_EXPORT int BIO_rw_filename(BIO *bio, const char *filename); 492 493 // BIO_tell returns the file offset of |bio|, or a negative number on error or 494 // if |bio| does not support the operation. 495 // 496 // TODO(https://crbug.com/boringssl/465): On platforms where |long| is 32-bit, 497 // this function cannot report 64-bit offsets. 498 OPENSSL_EXPORT long BIO_tell(BIO *bio); 499 500 // BIO_seek sets the file offset of |bio| to |offset|. It returns a non-negative 501 // number on success and a negative number on error. If |bio| is a file 502 // descriptor |BIO|, it returns the resulting file offset on success. If |bio| 503 // is a file |BIO|, it returns zero on success. 504 // 505 // WARNING: This function's return value conventions differs from most functions 506 // in this library. 507 // 508 // TODO(https://crbug.com/boringssl/465): On platforms where |long| is 32-bit, 509 // this function cannot handle 64-bit offsets. 510 OPENSSL_EXPORT long BIO_seek(BIO *bio, long offset); 511 512 513 // Socket BIOs. 514 // 515 // Socket BIOs behave like file descriptor BIOs but, on Windows systems, wrap 516 // the system's |recv| and |send| functions instead of |read| and |write|. On 517 // Windows, file descriptors are provided by C runtime and are not 518 // interchangeable with sockets. 519 // 520 // Socket BIOs may be used with |BIO_set_fd| and |BIO_get_fd|. 521 // 522 // TODO(davidben): Add separate APIs and fix the internals to use |SOCKET|s 523 // around rather than rely on int casts. 524 525 #if !defined(OPENSSL_NO_SOCK) 526 OPENSSL_EXPORT const BIO_METHOD *BIO_s_socket(void); 527 528 // BIO_new_socket allocates and initialises a fresh BIO which will read and 529 // write to the socket |fd|. If |close_flag| is |BIO_CLOSE| then closing the 530 // BIO will close |fd|. It returns the fresh |BIO| or NULL on error. 531 OPENSSL_EXPORT BIO *BIO_new_socket(int fd, int close_flag); 532 #endif // !OPENSSL_NO_SOCK 533 534 535 // Connect BIOs. 536 // 537 // A connection BIO creates a network connection and transfers data over the 538 // resulting socket. 539 540 #if !defined(OPENSSL_NO_SOCK) 541 OPENSSL_EXPORT const BIO_METHOD *BIO_s_connect(void); 542 543 // BIO_new_connect returns a BIO that connects to the given hostname and port. 544 // The |host_and_optional_port| argument should be of the form 545 // "www.example.com" or "www.example.com:443". If the port is omitted, it must 546 // be provided with |BIO_set_conn_port|. 547 // 548 // It returns the new BIO on success, or NULL on error. 549 OPENSSL_EXPORT BIO *BIO_new_connect(const char *host_and_optional_port); 550 551 // BIO_set_conn_hostname sets |host_and_optional_port| as the hostname and 552 // optional port that |bio| will connect to. If the port is omitted, it must be 553 // provided with |BIO_set_conn_port|. 554 // 555 // It returns one on success and zero otherwise. 556 OPENSSL_EXPORT int BIO_set_conn_hostname(BIO *bio, 557 const char *host_and_optional_port); 558 559 // BIO_set_conn_port sets |port_str| as the port or service name that |bio| 560 // will connect to. It returns one on success and zero otherwise. 561 OPENSSL_EXPORT int BIO_set_conn_port(BIO *bio, const char *port_str); 562 563 // BIO_set_conn_int_port sets |*port| as the port that |bio| will connect to. 564 // It returns one on success and zero otherwise. 565 OPENSSL_EXPORT int BIO_set_conn_int_port(BIO *bio, const int *port); 566 567 // BIO_set_nbio sets whether |bio| will use non-blocking I/O operations. It 568 // returns one on success and zero otherwise. This only works for connect BIOs 569 // and must be called before |bio| is connected to take effect. 570 // 571 // For socket and fd BIOs, callers must configure blocking vs. non-blocking I/O 572 // using the underlying platform APIs. 573 OPENSSL_EXPORT int BIO_set_nbio(BIO *bio, int on); 574 575 // BIO_do_connect connects |bio| if it has not been connected yet. It returns 576 // one on success and <= 0 otherwise. 577 OPENSSL_EXPORT int BIO_do_connect(BIO *bio); 578 #endif // !OPENSSL_NO_SOCK 579 580 581 // Datagram BIOs. 582 // 583 // TODO(fork): not implemented. 584 585 #define BIO_CTRL_DGRAM_QUERY_MTU 40 // as kernel for current MTU 586 587 #define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for MTU. want to use 588 this if asking the kernel fails */ 589 590 #define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU was exceed in 591 the previous write operation. */ 592 593 // BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT is unsupported as it is unused by consumers 594 // and depends on |timeval|, which is not 2038-clean on all platforms. 595 596 #define BIO_CTRL_DGRAM_GET_PEER 46 597 598 #define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 599 600 601 // BIO Pairs. 602 // 603 // BIO pairs provide a "loopback" like system: a pair of BIOs where data 604 // written to one can be read from the other and vice versa. 605 606 // BIO_new_bio_pair sets |*out1| and |*out2| to two freshly created BIOs where 607 // data written to one can be read from the other and vice versa. The 608 // |writebuf1| argument gives the size of the buffer used in |*out1| and 609 // |writebuf2| for |*out2|. It returns one on success and zero on error. 610 OPENSSL_EXPORT int BIO_new_bio_pair(BIO **out1, size_t writebuf1, BIO **out2, 611 size_t writebuf2); 612 613 // BIO_ctrl_get_read_request returns the number of bytes that the other side of 614 // |bio| tried (unsuccessfully) to read. 615 OPENSSL_EXPORT size_t BIO_ctrl_get_read_request(BIO *bio); 616 617 // BIO_ctrl_get_write_guarantee returns the number of bytes that |bio| (which 618 // must have been returned by |BIO_new_bio_pair|) will accept on the next 619 // |BIO_write| call. 620 OPENSSL_EXPORT size_t BIO_ctrl_get_write_guarantee(BIO *bio); 621 622 // BIO_shutdown_wr marks |bio| as closed, from the point of view of the other 623 // side of the pair. Future |BIO_write| calls on |bio| will fail. It returns 624 // one on success and zero otherwise. 625 OPENSSL_EXPORT int BIO_shutdown_wr(BIO *bio); 626 627 628 // Custom BIOs. 629 // 630 // Consumers can create custom |BIO|s by filling in a |BIO_METHOD| and using 631 // low-level control functions to set state. 632 633 // BIO_get_new_index returns a new "type" value for a custom |BIO|. 634 OPENSSL_EXPORT int BIO_get_new_index(void); 635 636 // BIO_meth_new returns a newly-allocated |BIO_METHOD| or NULL on allocation 637 // error. The |type| specifies the type that will be returned by 638 // |BIO_method_type|. If this is unnecessary, this value may be zero. The |name| 639 // parameter is vestigial and may be NULL. 640 // 641 // Use the |BIO_meth_set_*| functions below to initialize the |BIO_METHOD|. The 642 // function implementations may use |BIO_set_data| and |BIO_get_data| to add 643 // method-specific state to associated |BIO|s. Additionally, |BIO_set_init| must 644 // be called after an associated |BIO| is fully initialized. State set via 645 // |BIO_set_data| may be released by configuring a destructor with 646 // |BIO_meth_set_destroy|. 647 OPENSSL_EXPORT BIO_METHOD *BIO_meth_new(int type, const char *name); 648 649 // BIO_meth_free releases memory associated with |method|. 650 OPENSSL_EXPORT void BIO_meth_free(BIO_METHOD *method); 651 652 // BIO_meth_set_create sets a function to be called on |BIO_new| for |method| 653 // and returns one. The function should return one on success and zero on 654 // error. 655 OPENSSL_EXPORT int BIO_meth_set_create(BIO_METHOD *method, 656 int (*create_func)(BIO *)); 657 658 // BIO_meth_set_destroy sets a function to release data associated with a |BIO| 659 // and returns one. The function's return value is ignored. 660 // 661 // As the |BIO| is about to be destroyed, it is not necessary for |destroy_func| 662 // to clear the BIO's state with |BIO_set_data| or |BIO_set_init|. There is no 663 // harm in clearing them, but the |BIO| will not be passed to |BIO| operations, 664 // unless |destroy_func| itself does so. 665 OPENSSL_EXPORT int BIO_meth_set_destroy(BIO_METHOD *method, 666 int (*destroy_func)(BIO *)); 667 668 // BIO_meth_set_write sets the implementation of |BIO_write| for |method| and 669 // returns one. |BIO_METHOD|s which implement |BIO_write| should also implement 670 // |BIO_CTRL_FLUSH|. (See |BIO_meth_set_ctrl|.) 671 OPENSSL_EXPORT int BIO_meth_set_write(BIO_METHOD *method, 672 int (*write_func)(BIO *, const char *, 673 int)); 674 675 // BIO_meth_set_read sets the implementation of |BIO_read| for |method| and 676 // returns one. 677 OPENSSL_EXPORT int BIO_meth_set_read(BIO_METHOD *method, 678 int (*read_func)(BIO *, char *, int)); 679 680 // BIO_meth_set_gets sets the implementation of |BIO_gets| for |method| and 681 // returns one. 682 OPENSSL_EXPORT int BIO_meth_set_gets(BIO_METHOD *method, 683 int (*gets_func)(BIO *, char *, int)); 684 685 // BIO_meth_set_ctrl sets the implementation of |BIO_ctrl| for |method| and 686 // returns one. 687 OPENSSL_EXPORT int BIO_meth_set_ctrl(BIO_METHOD *method, 688 long (*ctrl_func)(BIO *, int, long, 689 void *)); 690 691 // BIO_meth_set_callback_ctrl sets the implementation of |BIO_callback_ctrl| for 692 // |method| and returns one. 693 OPENSSL_EXPORT int BIO_meth_set_callback_ctrl( 694 BIO_METHOD *method, long (*callback_ctrl_func)(BIO *, int, BIO_info_cb *)); 695 696 // BIO_set_data sets custom data on |bio|. It may be retried with 697 // |BIO_get_data|. 698 // 699 // This function should only be called by the implementation of a custom |BIO|. 700 // In particular, the data pointer of a built-in |BIO| is private to the 701 // library. For other uses, see |BIO_set_ex_data| and |BIO_set_app_data|. 702 OPENSSL_EXPORT void BIO_set_data(BIO *bio, void *ptr); 703 704 // BIO_get_data returns custom data on |bio| set by |BIO_get_data|. 705 // 706 // This function should only be called by the implementation of a custom |BIO|. 707 // In particular, the data pointer of a built-in |BIO| is private to the 708 // library. For other uses, see |BIO_get_ex_data| and |BIO_get_app_data|. 709 OPENSSL_EXPORT void *BIO_get_data(BIO *bio); 710 711 // BIO_set_init sets whether |bio| has been fully initialized. Until fully 712 // initialized, |BIO_read| and |BIO_write| will fail. 713 OPENSSL_EXPORT void BIO_set_init(BIO *bio, int init); 714 715 // BIO_get_init returns whether |bio| has been fully initialized. 716 OPENSSL_EXPORT int BIO_get_init(BIO *bio); 717 718 // These are values of the |cmd| argument to |BIO_ctrl|. 719 720 // BIO_CTRL_RESET implements |BIO_reset|. The arguments are unused. 721 #define BIO_CTRL_RESET 1 722 723 // BIO_CTRL_EOF implements |BIO_eof|. The arguments are unused. 724 #define BIO_CTRL_EOF 2 725 726 // BIO_CTRL_INFO is a legacy command that returns information specific to the 727 // type of |BIO|. It is not safe to call generically and should not be 728 // implemented in new |BIO| types. 729 #define BIO_CTRL_INFO 3 730 731 // BIO_CTRL_GET_CLOSE returns the close flag set by |BIO_CTRL_SET_CLOSE|. The 732 // arguments are unused. 733 #define BIO_CTRL_GET_CLOSE 8 734 735 // BIO_CTRL_SET_CLOSE implements |BIO_set_close|. The |larg| argument is the 736 // close flag. 737 #define BIO_CTRL_SET_CLOSE 9 738 739 // BIO_CTRL_PENDING implements |BIO_pending|. The arguments are unused. 740 #define BIO_CTRL_PENDING 10 741 742 // BIO_CTRL_FLUSH implements |BIO_flush|. The arguments are unused. 743 #define BIO_CTRL_FLUSH 11 744 745 // BIO_CTRL_WPENDING implements |BIO_wpending|. The arguments are unused. 746 #define BIO_CTRL_WPENDING 13 747 748 // BIO_CTRL_SET_CALLBACK sets an informational callback of type 749 // int cb(BIO *bio, int state, int ret) 750 #define BIO_CTRL_SET_CALLBACK 14 751 752 // BIO_CTRL_GET_CALLBACK returns the callback set by |BIO_CTRL_SET_CALLBACK|. 753 #define BIO_CTRL_GET_CALLBACK 15 754 755 // The following are never used, but are defined to aid porting existing code. 756 #define BIO_CTRL_SET 4 757 #define BIO_CTRL_GET 5 758 #define BIO_CTRL_PUSH 6 759 #define BIO_CTRL_POP 7 760 #define BIO_CTRL_DUP 12 761 #define BIO_CTRL_SET_FILENAME 30 762 763 764 // ex_data functions. 765 // 766 // See |ex_data.h| for details. 767 768 OPENSSL_EXPORT int BIO_get_ex_new_index(long argl, void *argp, 769 CRYPTO_EX_unused *unused, 770 CRYPTO_EX_dup *dup_unused, 771 CRYPTO_EX_free *free_func); 772 OPENSSL_EXPORT int BIO_set_ex_data(BIO *bio, int idx, void *arg); 773 OPENSSL_EXPORT void *BIO_get_ex_data(const BIO *bio, int idx); 774 775 #define BIO_set_app_data(bio, arg) (BIO_set_ex_data(bio, 0, (char *)(arg))) 776 #define BIO_get_app_data(bio) (BIO_get_ex_data(bio, 0)) 777 778 779 // Deprecated functions. 780 781 typedef BIO_info_cb bio_info_cb; 782 783 // BIO_f_base64 returns a filter |BIO| that base64-encodes data written into 784 // it, and decodes data read from it. |BIO_gets| is not supported. Call 785 // |BIO_flush| when done writing, to signal that no more data are to be 786 // encoded. The flag |BIO_FLAGS_BASE64_NO_NL| may be set to encode all the data 787 // on one line. 788 // 789 // Use |EVP_EncodeBlock| and |EVP_DecodeBase64| instead. 790 OPENSSL_EXPORT const BIO_METHOD *BIO_f_base64(void); 791 792 OPENSSL_EXPORT void BIO_set_retry_special(BIO *bio); 793 794 // BIO_set_write_buffer_size returns zero. 795 OPENSSL_EXPORT int BIO_set_write_buffer_size(BIO *bio, int buffer_size); 796 797 // BIO_set_shutdown sets a method-specific "shutdown" bit on |bio|. 798 OPENSSL_EXPORT void BIO_set_shutdown(BIO *bio, int shutdown); 799 800 // BIO_get_shutdown returns the method-specific "shutdown" bit. 801 OPENSSL_EXPORT int BIO_get_shutdown(BIO *bio); 802 803 // BIO_meth_set_puts returns one. |BIO_puts| is implemented with |BIO_write| in 804 // BoringSSL. 805 OPENSSL_EXPORT int BIO_meth_set_puts(BIO_METHOD *method, 806 int (*puts)(BIO *, const char *)); 807 808 #if !defined(OPENSSL_NO_SOCK) 809 // The following functions return function pointers, possibly NULL, which are 810 // compatible with the corresponding |BIO_meth_set_*| function. |method| must be 811 // |BIO_s_socket| or the program will abort. 812 // 813 // Using these functions is inherently unsafe and fragile. It is not possible to 814 // use them in a future-proof way. See 815 // https://github.com/openssl/openssl/issues/26047 for details. BoringSSL 816 // implements them solely for compatibility with Folly and older versions of 817 // PostgreSQL. To work around the future-proofing problems, the return values 818 // may diverge from the true implementation of |BIO_s_socket|. 819 // 820 // Caller should not use these functions. They are not necessary to define 821 // custom |BIO_METHOD|s. Instead, callers should either: 822 // 823 // - Define a custom |BIO_METHOD| that owns a socket |BIO| somewhere in the 824 // custom data. See |BIO_set_data|. 825 // 826 // - Define a custom |BIO_METHOD| that wraps a socket |BIO| as a filter. See 827 // |BIO_push| and |BIO_next|. 828 // 829 // - Define a custom |BIO_METHOD| without |BIO_s_socket| at all. If not using 830 // the built-in read or write functions, |BIO_s_socket| only provides a no-op 831 // |BIO_CTRL_FLUSH| implementation. This can be implemented by the caller. 832 OPENSSL_EXPORT int (*BIO_meth_get_write(const BIO_METHOD *method))(BIO *, 833 const char *, 834 int); 835 OPENSSL_EXPORT int (*BIO_meth_get_read(const BIO_METHOD *method))(BIO *, char *, 836 int); 837 OPENSSL_EXPORT int (*BIO_meth_get_gets(const BIO_METHOD *method))(BIO *, char *, 838 int); 839 OPENSSL_EXPORT int (*BIO_meth_get_puts(const BIO_METHOD *method))(BIO *, 840 const char *); 841 OPENSSL_EXPORT long (*BIO_meth_get_ctrl(const BIO_METHOD *method))(BIO *, int, 842 long, 843 void *); 844 OPENSSL_EXPORT int (*BIO_meth_get_create(const BIO_METHOD *method))(BIO *); 845 OPENSSL_EXPORT int (*BIO_meth_get_destroy(const BIO_METHOD *method))(BIO *); 846 OPENSSL_EXPORT long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *method))( 847 BIO *, int, BIO_info_cb *); 848 #endif // !OPENSSL_NO_SOCK 849 850 851 // Private functions 852 853 #define BIO_FLAGS_READ 0x01 854 #define BIO_FLAGS_WRITE 0x02 855 #define BIO_FLAGS_IO_SPECIAL 0x04 856 #define BIO_FLAGS_RWS (BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL) 857 #define BIO_FLAGS_SHOULD_RETRY 0x08 858 #define BIO_FLAGS_BASE64_NO_NL 0x100 859 // BIO_FLAGS_MEM_RDONLY is used with memory BIOs. It means we shouldn't free up 860 // or change the data in any way. 861 #define BIO_FLAGS_MEM_RDONLY 0x200 862 863 // BIO_TYPE_DESCRIPTOR denotes that the |BIO| responds to the |BIO_C_SET_FD| 864 // (|BIO_set_fd|) and |BIO_C_GET_FD| (|BIO_get_fd|) control hooks. 865 #define BIO_TYPE_DESCRIPTOR 0x0100 // socket, fd, connect or accept 866 #define BIO_TYPE_FILTER 0x0200 867 #define BIO_TYPE_SOURCE_SINK 0x0400 868 869 // These are the 'types' of BIOs 870 #define BIO_TYPE_NONE 0 871 #define BIO_TYPE_MEM (1 | BIO_TYPE_SOURCE_SINK) 872 #define BIO_TYPE_FILE (2 | BIO_TYPE_SOURCE_SINK) 873 #define BIO_TYPE_FD (4 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 874 #define BIO_TYPE_SOCKET (5 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 875 #define BIO_TYPE_NULL (6 | BIO_TYPE_SOURCE_SINK) 876 #define BIO_TYPE_SSL (7 | BIO_TYPE_FILTER) 877 #define BIO_TYPE_MD (8 | BIO_TYPE_FILTER) 878 #define BIO_TYPE_BUFFER (9 | BIO_TYPE_FILTER) 879 #define BIO_TYPE_CIPHER (10 | BIO_TYPE_FILTER) 880 #define BIO_TYPE_BASE64 (11 | BIO_TYPE_FILTER) 881 #define BIO_TYPE_CONNECT (12 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 882 #define BIO_TYPE_ACCEPT (13 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 883 #define BIO_TYPE_PROXY_CLIENT (14 | BIO_TYPE_FILTER) 884 #define BIO_TYPE_PROXY_SERVER (15 | BIO_TYPE_FILTER) 885 #define BIO_TYPE_NBIO_TEST (16 | BIO_TYPE_FILTER) 886 #define BIO_TYPE_NULL_FILTER (17 | BIO_TYPE_FILTER) 887 #define BIO_TYPE_BER (18 | BIO_TYPE_FILTER) // BER -> bin filter 888 #define BIO_TYPE_BIO (19 | BIO_TYPE_SOURCE_SINK) // (half a) BIO pair 889 #define BIO_TYPE_LINEBUFFER (20 | BIO_TYPE_FILTER) 890 #define BIO_TYPE_DGRAM (21 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) 891 #define BIO_TYPE_ASN1 (22 | BIO_TYPE_FILTER) 892 #define BIO_TYPE_COMP (23 | BIO_TYPE_FILTER) 893 894 // BIO_TYPE_START is the first user-allocated |BIO| type. No pre-defined type, 895 // flag bits aside, may exceed this value. 896 #define BIO_TYPE_START 128 897 898 #define BIO_C_SET_CONNECT 100 899 #define BIO_C_DO_STATE_MACHINE 101 900 #define BIO_C_SET_NBIO 102 901 #define BIO_C_SET_PROXY_PARAM 103 902 #define BIO_C_SET_FD 104 903 #define BIO_C_GET_FD 105 904 #define BIO_C_SET_FILE_PTR 106 905 #define BIO_C_GET_FILE_PTR 107 906 #define BIO_C_SET_FILENAME 108 907 #define BIO_C_SET_SSL 109 908 #define BIO_C_SET_MD 111 909 #define BIO_C_GET_MD 112 910 #define BIO_C_GET_CIPHER_STATUS 113 911 #define BIO_C_SET_BUF_MEM 114 912 #define BIO_C_GET_BUF_MEM_PTR 115 913 #define BIO_C_GET_BUFF_NUM_LINES 116 914 #define BIO_C_SET_BUFF_SIZE 117 915 #define BIO_C_SET_ACCEPT 118 916 #define BIO_C_SSL_MODE 119 917 #define BIO_C_GET_MD_CTX 120 918 #define BIO_C_GET_PROXY_PARAM 121 919 #define BIO_C_SET_BUFF_READ_DATA 122 // data to read first 920 #define BIO_C_GET_ACCEPT 124 921 #define BIO_C_FILE_SEEK 128 922 #define BIO_C_GET_CIPHER_CTX 129 923 #define BIO_C_SET_BUF_MEM_EOF_RETURN 130 // return end of input value 924 #define BIO_C_SET_BIND_MODE 131 925 #define BIO_C_GET_BIND_MODE 132 926 #define BIO_C_FILE_TELL 133 927 #define BIO_C_GET_SOCKS 134 928 #define BIO_C_SET_SOCKS 135 929 930 #define BIO_C_SET_WRITE_BUF_SIZE 136 // for BIO_s_bio 931 #define BIO_C_GET_WRITE_BUF_SIZE 137 932 #define BIO_C_GET_WRITE_GUARANTEE 140 933 #define BIO_C_GET_READ_REQUEST 141 934 #define BIO_C_SHUTDOWN_WR 142 935 #define BIO_C_NREAD0 143 936 #define BIO_C_NREAD 144 937 #define BIO_C_NWRITE0 145 938 #define BIO_C_NWRITE 146 939 #define BIO_C_RESET_READ_REQUEST 147 940 #define BIO_C_SET_MD_CTX 148 941 942 #define BIO_C_SET_PREFIX 149 943 #define BIO_C_GET_PREFIX 150 944 #define BIO_C_SET_SUFFIX 151 945 #define BIO_C_GET_SUFFIX 152 946 947 #define BIO_C_SET_EX_ARG 153 948 #define BIO_C_GET_EX_ARG 154 949 950 951 #if defined(__cplusplus) 952 } // extern C 953 954 extern "C++" { 955 956 BSSL_NAMESPACE_BEGIN 957 958 BORINGSSL_MAKE_DELETER(BIO, BIO_free) 959 BORINGSSL_MAKE_UP_REF(BIO, BIO_up_ref) 960 BORINGSSL_MAKE_DELETER(BIO_METHOD, BIO_meth_free) 961 962 BSSL_NAMESPACE_END 963 964 } // extern C++ 965 966 #endif 967 968 #define BIO_R_BAD_FOPEN_MODE 100 969 #define BIO_R_BROKEN_PIPE 101 970 #define BIO_R_CONNECT_ERROR 102 971 #define BIO_R_ERROR_SETTING_NBIO 103 972 #define BIO_R_INVALID_ARGUMENT 104 973 #define BIO_R_IN_USE 105 974 #define BIO_R_KEEPALIVE 106 975 #define BIO_R_NBIO_CONNECT_ERROR 107 976 #define BIO_R_NO_HOSTNAME_SPECIFIED 108 977 #define BIO_R_NO_PORT_SPECIFIED 109 978 #define BIO_R_NO_SUCH_FILE 110 979 #define BIO_R_NULL_PARAMETER 111 980 #define BIO_R_SYS_LIB 112 981 #define BIO_R_UNABLE_TO_CREATE_SOCKET 113 982 #define BIO_R_UNINITIALIZED 114 983 #define BIO_R_UNSUPPORTED_METHOD 115 984 #define BIO_R_WRITE_TO_READ_ONLY_BIO 116 985 986 #endif // OPENSSL_HEADER_BIO_H