---
name: "libressl-BIO_get_data"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-BIO_get_data"
---

# libressl-BIO\_get\_data(3)

manage BIO state information

## NAME

**BIO\_set\_data**, **BIO\_get\_data**, **BIO\_set\_flags**, **BIO\_clear\_flags**, **BIO\_test\_flags**, **BIO\_get\_flags**, **BIO\_set\_retry\_read**, **BIO\_set\_retry\_write**, **BIO\_set\_retry\_special**, **BIO\_clear\_retry\_flags**, **BIO\_get\_retry\_flags**, **BIO\_copy\_next\_retry**, **BIO\_set\_init**, **BIO\_get\_init**, **BIO\_set\_shutdown**, **BIO\_get\_shutdown** – manage BIO state information

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/bio.h\>**

*void*\

**BIO\_set\_data**(*BIO \*a*, *void \*ptr*);

*void* *\**\

**BIO\_get\_data**(*BIO \*a*);

*void*\

**BIO\_set\_flags**(*BIO \*a*, *int flags*);

*void*\

**BIO\_clear\_flags**(*BIO \*a*, *int flags*);

*int*\

**BIO\_test\_flags**(*const BIO \*a*, *int flags*);

*int*\

**BIO\_get\_flags**(*const BIO \*a*);

*void*\

**BIO\_set\_retry\_read**(*BIO \*a*);

*void*\

**BIO\_set\_retry\_write**(*BIO \*a*);

*void*\

**BIO\_set\_retry\_special**(*BIO \*a*);

*void*\

**BIO\_clear\_retry\_flags**(*BIO \*a*);

*int*\

**BIO\_get\_retry\_flags**(*BIO \*a*);

*void*\

**BIO\_copy\_next\_retry**(*BIO \*a*);

*void*\

**BIO\_set\_init**(*BIO \*a*, *int init*);

*int*\

**BIO\_get\_init**(*BIO \*a*);

*void*\

**BIO\_set\_shutdown**(*BIO \*a*, *int shutdown*);

*int*\

**BIO\_get\_shutdown**(*BIO \*a*);

## DESCRIPTION

These functions are mainly useful when implementing a custom BIO.

The **BIO\_set\_data**() function associates the custom data pointed to by *ptr* with the *BIO a*. This data can subsequently be retrieved via a call to **BIO\_get\_data**(). This can be used by custom BIOs for storing implementation specific information.

**BIO\_set\_flags**() sets all the bits contained in the *flags* argument in the flags stored in *a*. The value of a flag neither changes when it is already set in *a* nor when it is unset in the *flags* argument.

**BIO\_clear\_flags**() clears all the bits contained in the *flags* argument from the flags stored in *a*. The value of a flag neither changes when it is already unset in *a* nor when it is unset in the *flags* argument.

**BIO\_test\_flags**() checks whether any of the bits contained in the *flags* argument are set in the flags stored in *a*. Application programs usually call macros like those documented in BIO\_should\_retry(3) rather than calling **BIO\_test\_flags**() directly. Flag bits correspond to accessor macros as follows:

- BIO\_FLAGS\_READ

  BIO\_should\_read(3)

- BIO\_FLAGS\_WRITE

  BIO\_should\_write(3)

- BIO\_FLAGS\_IO\_SPECIAL

  BIO\_should\_io\_special(3)

- BIO\_FLAGS\_RWS

  BIO\_retry\_type(3)

- BIO\_FLAGS\_SHOULD\_RETRY

  BIO\_should\_retry(3)

- BIO\_FLAGS\_BASE64\_NO\_NL

  see BIO\_f\_base64(3)

- BIO\_FLAGS\_MEM\_RDONLY

  see BIO\_s\_mem(3)

In particular, BIO\_FLAGS\_RWS is the bitwise OR of BIO\_FLAGS\_READ, BIO\_FLAGS\_WRITE, and BIO\_FLAGS\_IO\_SPECIAL.

**BIO\_set\_retry\_read**(), **BIO\_set\_retry\_write**(), and **BIO\_set\_retry\_special**() set the BIO\_FLAGS\_READ, BIO\_FLAGS\_WRITE, and BIO\_FLAGS\_IO\_SPECIAL flag bit in *a*, respectively. They all set the BIO\_FLAGS\_SHOULD\_RETRY flag bit, too.

**BIO\_clear\_retry\_flags**() clears the flag bits BIO\_FLAGS\_READ, BIO\_FLAGS\_WRITE, BIO\_FLAGS\_IO\_SPECIAL, and BIO\_FLAGS\_SHOULD\_RETRY in *a*.

**BIO\_copy\_next\_retry**() copies retry-related state data from the BIO that follows *a* in its chain to *a*, that is, the data accessible with **BIO\_get\_retry\_flags**() and BIO\_get\_retry\_reason(3). Flags which are already set in *a* are not cleared. Before calling **BIO\_copy\_next\_retry**(), making sure that *a* is not the last BIO in its chain is the responsibility of the caller, for example by checking that BIO\_next(3) does not return NULL.

The **BIO\_set\_init**() function sets the *init* flag in *a* to the specified value. A non-zero value indicates that initialisation is complete, whilst zero indicates that it is not. Often initialisation will complete during initial construction of the BIO. For some BIOs however, initialisation may not be complete until additional steps have been taken, for example through calling custom ctrls.

The **BIO\_set\_shutdown**() and **BIO\_get\_shutdown**() functions are low-level interfaces to forcefully set and get the *shutdown* flag of *a*, circumventing type-dependent sanity checks, exclusively intended for implementing a new BIO type. The *shutdown* argument must be either BIO\_CLOSE or BIO\_NOCLOSE. When merely using a *BIO* object, call BIO\_set\_close(3) and BIO\_get\_close(3) instead.

**BIO\_get\_flags**(), **BIO\_set\_retry\_read**(), **BIO\_set\_retry\_write**(), **BIO\_set\_retry\_special**(), **BIO\_clear\_retry\_flags**(), and **BIO\_get\_retry\_flags**() are implemented as macros.

## RETURN VALUES

**BIO\_get\_data**() returns a pointer to the implementation specific custom data associated with *a*, or NULL if none is set.

**BIO\_test\_flags**() returns the bitwise AND of the *flags* argument and the flags stored in *a*. Consequently, it returns a non-zero value if and only if at least one of the requested *flags* is set.

**BIO\_get\_flags**() returns all the flags currently stored in *a*.

**BIO\_get\_retry\_flags**() returns the bitwise AND of (BIO\_FLAGS\_RWS \| BIO\_FLAGS\_SHOULD\_RETRY) and the flags stored in *a*.

**BIO\_get\_init**() returns the value of the init flag of *a*.

**BIO\_get\_shutdown**() returns the value previously set with **BIO\_set\_shutdown**() or with BIO\_set\_close(3).

## SEE ALSO

BIO\_meth\_new(3), BIO\_new(3), BIO\_set\_close(3), BIO\_should\_retry(3)

## HISTORY

**BIO\_set\_flags**(), **BIO\_clear\_flags**(), **BIO\_set\_retry\_read**(), **BIO\_set\_retry\_write**(), **BIO\_set\_retry\_special**(), **BIO\_clear\_retry\_flags**(), and **BIO\_get\_retry\_flags**() first appeared in SSLeay 0.8.0, **BIO\_copy\_next\_retry**() in SSLeay 0.8.1, and **BIO\_get\_flags**() in SSLeay 0.9.0. These functions have been available since OpenBSD 2.4.

**BIO\_test\_flags**() first appeared in OpenSSL 0.9.8e and has been available since OpenBSD 4.5.

**BIO\_set\_data**(), **BIO\_get\_data**(), **BIO\_set\_init**(), **BIO\_set\_shutdown**(), and **BIO\_get\_shutdown**() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.

**BIO\_get\_init**() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 7.1.
