BIO_CTRL(3ossl)
π BIO_CTRL(3ossl) β BIO control operations: group-chat edition π
okay so bestie, welcome to the OpenSSL manual page BIO_CTRL(3ossl) β the one all about poking a BIO with control ops. Itβs giving βtiny remote control for your I/O streamβ energy, and the function list is long, but weβre gonna slay it together. πβ¨
β¨ NAME β¨
BIO_ctrl, BIO_callback_ctrl, BIO_ptr_ctrl, BIO_int_ctrl, BIO_reset, BIO_seek, BIO_tell, BIO_flush, BIO_eof, BIO_set_close, BIO_get_close, BIO_pending, BIO_wpending, BIO_ctrl_pending, BIO_ctrl_wpending, BIO_get_info_callback, BIO_set_info_callback, BIO_info_cb, BIO_get_ktls_send, BIO_get_ktls_recv, BIO_set_conn_mode, BIO_get_conn_mode, BIO_set_tfo β BIO control operations.
πΈ SYNOPSIS πΈ
#include <openssl/bio.h>
typedef int BIO_info_cb(BIO *b, int state, int res);
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *cb);
void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
int BIO_reset(BIO *b);
int BIO_seek(BIO *b, int ofs);
int BIO_tell(BIO *b);
int BIO_flush(BIO *b);
int BIO_eof(BIO *b);
int BIO_set_close(BIO *b, long flag);
int BIO_get_close(BIO *b);
int BIO_pending(BIO *b);
int BIO_wpending(BIO *b);
size_t BIO_ctrl_pending(BIO *b);
size_t BIO_ctrl_wpending(BIO *b);
int BIO_get_info_callback(BIO *b, BIO_info_cb **cbp);
int BIO_set_info_callback(BIO *b, BIO_info_cb *cb);
int BIO_get_ktls_send(BIO *b);
int BIO_get_ktls_recv(BIO *b);
int BIO_set_conn_mode(BIO *b, int mode);
int BIO_get_conn_mode(BIO *b);
int BIO_set_tfo(BIO *b, int onoff);
π¦ DESCRIPTION π¦
okay so hereβs the vibe check on each little control-ish thing:
BIO_ctrl(),BIO_callback_ctrl(),BIO_ptr_ctrl(),BIO_int_ctrl()β these are the BIO βcontrolβ operations, and they take arguments of various types. Ngl, you donβt normally call these directly; various macros are used instead. The standard macros are described below, and macros specific to a particular type of BIO are described in the specific BIOs manual page as well as any special features of the standard calls.BIO_reset()β typically resets a BIO to some initial state. For file-related BIOs, for example, it rewinds the file pointer to the start of the file. Rewind era. πBIO_seek()β resets a file-related BIOβs file position pointer (that is, file descriptor andFILEBIOs) toofsbytes from the start of the file.BIO_tell()β returns the current file position of a file-related BIO.BIO_flush()β normally writes out any internally buffered data. In some cases itβs used to signal EOF and that no more data will be written.BIO_eof()β returns1if the BIO has read EOF. The precise meaning of βEOFβ varies according to the BIO type, iykyk.BIO_set_close()β sets the BIObclose flag toflag.flagcan take the valueBIO_CLOSEorBIO_NOCLOSE. TypicallyBIO_CLOSEis used in a source/sink BIO to indicate that the underlying I/O stream should be closed when the BIO is freed.BIO_get_close()β returns the BIOβs close flag.BIO_pending(),BIO_ctrl_pending(),BIO_wpending(),BIO_ctrl_wpending()β return the number of pending characters in the BIOβs read and write buffers. Not all BIOs support these calls.BIO_ctrl_pending()andBIO_ctrl_wpending()return asize_ttype and are functions;BIO_pending()andBIO_wpending()are macros which callBIO_ctrl().BIO_get_ktls_send()β returns1if the BIO is using the Kernel TLS data-path for sending. Otherwise, it returns zero.BIO_get_ktls_recv()β returns1if the BIO is using the Kernel TLS data-path for receiving. Otherwise, it returns zero.BIO_get_conn_mode()β returns the BIO connection mode.BIO_set_conn_mode()β sets the BIO connection mode.BIO_set_tfo()β disables TCP Fast Open whenonoffis0, and enables TCP Fast Open whenonoffis nonzero. Setting the value to1is equivalent to settingBIO_SOCK_TFOinBIO_set_conn_mode().
π RETURN VALUES π
BIO_reset()β normally returns1for success and<=0for failure. File BIOs are an exception: they return0for success and-1for failure. Not me getting special-case energy from a file BIO πBIO_seek()andBIO_tell()β both return the current file position on success and-1for failure, except file BIOs which forBIO_seek()always return0for success and-1for failure.BIO_flush()β returns1for success and<=0for failure.BIO_eof()β returns1if EOF has been reached,0if not, or negative values for failure.BIO_set_close()β returns1on success or<=0for failure.BIO_get_close()β returns the close flag value:BIO_CLOSEorBIO_NOCLOSE. It also returns other negative values if an error occurs.BIO_pending(),BIO_ctrl_pending(),BIO_wpending(),BIO_ctrl_wpending()β return the amount of pending data.BIO_pending()andBIO_wpending()return negative value or0on error.BIO_ctrl_pending()andBIO_ctrl_wpending()return0on error.BIO_get_ktls_send()β returns1if the BIO is using the Kernel TLS data-path for sending. Otherwise, it returns zero.BIO_get_ktls_recv()β returns1if the BIO is using the Kernel TLS data-path for receiving. Otherwise, it returns zero.BIO_set_conn_mode()β returns1for success and0for failure.BIO_get_conn_mode()β returns the current connection mode. Which may contain the bitwise-or of the following flags:BIO_SOCK_REUSEADDRBIO_SOCK_V6_ONLYBIO_SOCK_KEEPALIVEBIO_SOCK_NONBLOCKBIO_SOCK_NODELAYBIO_SOCK_TFO
BIO_set_tfo()β returns1for success, and0for failure.
π NOTES π
BIO_flush(), because it can write data, may return 0 or -1 indicating that the call should be retried later in a similar manner to BIO_write_ex(). The BIO_should_retry() call should be used and appropriate action taken if the call fails. bestie please use the retry check, fr fr π«Ά
The return values of BIO_pending() and BIO_wpending() may not reliably determine the amount of pending data in all cases. For example, in the case of a file BIO, some data may be available in the FILE structureβs internal buffers but it is not possible to determine this in a portable way. For other types of BIO they may not be supported.
Filter BIOs, if they do not internally handle a particular BIO_ctrl() operation, usually pass the operation to the next BIO in the chain. This often means there is no need to locate the required BIO for a particular operation: it can be called on a chain and it will be automatically passed to the relevant BIO. However, this can cause unexpected results: for example, no current filter BIOs implement BIO_seek(), but this may still succeed if the chain ends in a FILE or file descriptor BIO.
Source/sink BIOs return an 0 if they do not recognize the BIO_ctrl() operation.
π BUGS π
Some of the return values are ambiguous and care should be taken. In particular, a return value of 0 can be returned if an operation is not supported, if an error occurred, if EOF has not been reached, and in the case of BIO_seek() on a file BIO for a successful operation. so yes, 0 is out here wearing many hats π
In older versions of OpenSSL the BIO_ctrl_pending() and BIO_ctrl_wpending() could return values greater than INT_MAX on error.
π HISTORY π
The BIO_get_ktls_send() and BIO_get_ktls_recv() macros were added in OpenSSL 3.0. They were modified to never return -1 in OpenSSL 3.0.4.
The BIO_get_conn_mode(), BIO_set_conn_mode() and BIO_set_tfo() functions were added in OpenSSL 3.2.
π§ COPYRIGHT π§
Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the βLicenseβ). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
okay bestie, thatβs the whole BIO_CTRL(3ossl) page. Cute sign-off time: itβs from OpenSSL source/version 3.5.6, dated 2026-04-07, and this page is BIO_CTRL(3ossl). Now go control those BIOs, you main character. π
β¨π¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms