---
name: "libressl-BIO_find_type"
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_find_type"
---

# libressl-BIO\_find\_type(3)

BIO chain traversal

## NAME

**BIO\_find\_type**, **BIO\_next**, **BIO\_method\_type**, **BIO\_method\_name** – BIO chain traversal

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*BIO* *\**\

**BIO\_find\_type**(*BIO \*bio*, *int type*);

*BIO* *\**\

**BIO\_next**(*BIO \*bio*);

*int*\

**BIO\_method\_type**(*const BIO \*bio*);

*const* *char* *\**\

**BIO\_method\_name**(*const BIO \*bio*);

**#define BIO\_TYPE\_NONE 0**

**#define BIO\_TYPE\_START 128**

## DESCRIPTION

**BIO\_find\_type**() searches for a BIO matching the given *type* in the chain starting at *bio*. If the least significant byte of the *type* argument is non-zero, only exact matches of the *type* are accepted. Otherwise, a match only requires that any of the bits set in the *type* argument is also set in the candidate BIO.

Types with a least significant byte in the range from 0 to BIO\_TYPE\_START, inclusive, are reserved for BIO types built into the library. Types with a least significant byte greater than BIO\_TYPE\_START are available for user-defined BIO types; see BIO\_get\_new\_index(3) for details.

**BIO\_next**() returns the next BIO in the chain after *bio*. This function can be used to traverse all BIOs in a chain or in conjunction with **BIO\_find\_type**() to find all BIOs of a certain type.

**BIO\_method\_type**() returns the type of the given *bio*.

**BIO\_method\_name**() returns an ASCII string representing the type of the *bio*.

The following are the built-in source/sink BIO types that operate on file descriptors. They all have both of the bits BIO\_TYPE\_SOURCE\_SINK and BIO\_TYPE\_DESCRIPTOR but not the bit BIO\_TYPE\_FILTER set in their type constant.

| | | |
| --- | --- | --- |
| *type* constant | *name* string | *BIO\_METHOD* |
| BIO\_TYPE\_ACCEPT | socket accept | BIO\_s\_accept(3) |
| BIO\_TYPE\_CONNECT | socket connect | BIO\_s\_connect(3) |
| BIO\_TYPE\_DGRAM | datagram socket | BIO\_s\_datagram(3) |
| BIO\_TYPE\_FD | file descriptor | BIO\_s\_fd(3) |
| BIO\_TYPE\_SOCKET | socket | BIO\_s\_socket(3) |

The following are the built-in source/sink BIO types that do not directly operate on file descriptors. They all have the bit BIO\_TYPE\_SOURCE\_SINK but not the bits BIO\_TYPE\_DESCRIPTOR and BIO\_TYPE\_FILTER set in their type constant.

| | | |
| --- | --- | --- |
| *type* constant | *name* string | *BIO\_METHOD* |
| BIO\_TYPE\_BIO | BIO pair | BIO\_s\_bio(3) |
| BIO\_TYPE\_FILE | FILE pointer | BIO\_s\_file(3) |
| BIO\_TYPE\_MEM | memory buffer | BIO\_s\_mem(3) |
| BIO\_TYPE\_NULL | NULL | BIO\_s\_null(3) |

The following are the built-in filter BIO types. They all have the bit BIO\_TYPE\_FILTER but not the bits BIO\_TYPE\_SOURCE\_SINK and BIO\_TYPE\_DESCRIPTOR set in their type constant.

| | | |
| --- | --- | --- |
| *type* constant | *name* string | *BIO\_METHOD* |
| BIO\_TYPE\_BASE64 | base64 encoding | BIO\_f\_base64(3) |
| BIO\_TYPE\_BUFFER | buffer | BIO\_f\_buffer(3) |
| BIO\_TYPE\_CIPHER | cipher | BIO\_f\_cipher(3) |
| BIO\_TYPE\_MD | message digest | BIO\_f\_md(3) |
| BIO\_TYPE\_NULL\_FILTER | NULL filter | BIO\_f\_null(3) |
| BIO\_TYPE\_SSL | ssl | BIO\_f\_ssl(3) |

The constants BIO\_TYPE\_BER, BIO\_TYPE\_PROXY\_CLIENT, and BIO\_TYPE\_PROXY\_SERVER do not correspond to any BIO types implemented by the library and are not intended to be used for application-defined types, either. The constants BIO\_TYPE\_COMP, BIO\_TYPE\_LINEBUFFER, and BIO\_TYPE\_NBIO\_TEST corresponds to a deprecated BIO types that are intentionally undocumented.

If a variable in an application program is intended to store a BIO type but temporarily does not refer to any BIO or refers to a BIO of an unknown type, setting the variable to BIO\_TYPE\_NONE is recommended.

## RETURN VALUES

**BIO\_find\_type**() returns the next matching BIO or NULL if *bio* is a NULL pointer or if no matching BIO is found.

**BIO\_next**() returns the next BIO or NULL if *bio* is a NULL pointer or points to the last BIO in a chain.

**BIO\_method\_type**() returns one of the BIO\_TYPE\_\* constants.

**BIO\_method\_name**() returns an internal pointer to a string.

## EXAMPLES

Traverse a chain looking for digest BIOs:

```
BIO *btmp;
btmp = in_bio;	/* in_bio is the chain to search through */
while (btmp != NULL) {
	btmp = BIO_find_type(btmp, BIO_TYPE_MD);
	if (btmp == NULL)
		break;	/* Not found */
	/* btmp is a digest BIO, do something with it ... */
	...
	btmp = BIO_next(btmp);
}
```

## SEE ALSO

BIO\_meth\_new(3), BIO\_new(3)

## HISTORY

**BIO\_method\_type**() and **BIO\_method\_name**() first appeared in SSLeay 0.6.0. **BIO\_find\_type**() first appeared in SSLeay 0.6.6. These functions have been available since OpenBSD 2.4.

**BIO\_next**() first appeared in OpenSSL 0.9.6 and has been available since OpenBSD 2.9.
