---
name: "libressl-BIO_meth_new"
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_meth_new"
---

# libressl-BIO\_meth\_new(3)

manipulate BIO\_METHOD structures

## NAME

**BIO\_get\_new\_index**, **BIO\_meth\_new**, **BIO\_meth\_free**, **BIO\_meth\_get\_write**, **BIO\_meth\_set\_write**, **BIO\_meth\_get\_read**, **BIO\_meth\_set\_read**, **BIO\_meth\_get\_puts**, **BIO\_meth\_set\_puts**, **BIO\_meth\_get\_gets**, **BIO\_meth\_set\_gets**, **BIO\_meth\_get\_ctrl**, **BIO\_meth\_set\_ctrl**, **BIO\_meth\_get\_create**, **BIO\_meth\_set\_create**, **BIO\_meth\_get\_destroy**, **BIO\_meth\_set\_destroy**, **BIO\_meth\_get\_callback\_ctrl**, **BIO\_meth\_set\_callback\_ctrl** – manipulate BIO\_METHOD structures

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*int*\

**BIO\_get\_new\_index**(*void*);

*BIO\_METHOD* *\**\

**BIO\_meth\_new**(*int type*, *const char \*name*);

*void*\

**BIO\_meth\_free**(*BIO\_METHOD \*biom*);

*int*\

**(\*BIO\_meth\_get\_write(const BIO\_METHOD \*biom))**(*BIO \**, *const char \**, *int*);

*int*\

**BIO\_meth\_set\_write**(*BIO\_METHOD \*biom*, *int (\*write)(BIO \*, const char \*, int)*);

*int*\

**(\*BIO\_meth\_get\_read(const BIO\_METHOD \*biom))**(*BIO \**, *char \**, *int*);

*int*\

**BIO\_meth\_set\_read**(*BIO\_METHOD \*biom*, *int (\*read)(BIO \*, char \*, int)*);

*int*\

**(\*BIO\_meth\_get\_puts(const BIO\_METHOD \*biom))**(*BIO \**, *const char \**);

*int*\

**BIO\_meth\_set\_puts**(*BIO\_METHOD \*biom*, *int (\*puts)(BIO \*, const char \*)*);

*int*\

**(\*BIO\_meth\_get\_gets(const BIO\_METHOD \*biom))**(*BIO \**, *char \**, *int*);

*int*\

**BIO\_meth\_set\_gets**(*BIO\_METHOD \*biom*, *int (\*gets)(BIO \*, char \*, int)*);

*long*\

**(\*BIO\_meth\_get\_ctrl(const BIO\_METHOD \*biom))**(*BIO \**, *int*, *long*, *void \**);

*int*\

**BIO\_meth\_set\_ctrl**(*BIO\_METHOD \*biom*, *long (\*ctrl)(BIO \*, int, long, void \*)*);

*int*\

**(\*BIO\_meth\_get\_create(const BIO\_METHOD \*biom))**(*BIO \**);

*int*\

**BIO\_meth\_set\_create**(*BIO\_METHOD \*biom*, *int (\*create)(BIO \*)*);

*int*\

**(\*BIO\_meth\_get\_destroy(const BIO\_METHOD \*biom))**(*BIO \**);

*int*\

**BIO\_meth\_set\_destroy**(*BIO\_METHOD \*biom*, *int (\*destroy)(BIO \*)*);

*long*\

**(\*BIO\_meth\_get\_callback\_ctrl(const BIO\_METHOD \*biom))**(*BIO \**, *int*, *BIO\_info\_cb \**);

*int*\

**BIO\_meth\_set\_callback\_ctrl**(*BIO\_METHOD \*biom*, *long (\*callback\_ctrl)(BIO \*, int, BIO\_info\_cb \*)*);

## DESCRIPTION

The *BIO\_METHOD* structure stores function pointers implementing a *BIO* type. See BIO\_new(3) for more information about *BIO* objects.

**BIO\_meth\_new**() creates a new *BIO\_METHOD* structure. It requires a unique integer *type*; use **BIO\_get\_new\_index**() to get the value for *type*. Currently, the user can only create up to 127 different BIO types, and *type* is limited to the range 129–255. The *name* pointer is stored in the structure and will not be freed by **BIO\_meth\_free**().

The standard BIO types are listed in ⟨openssl/bio.h⟩. Some examples include BIO\_TYPE\_BUFFER and BIO\_TYPE\_CIPHER. The *type* of filter BIOs should have the BIO\_TYPE\_FILTER bit set. Source/sink BIOs should have the BIO\_TYPE\_SOURCE\_SINK bit set. File descriptor based BIOs (e.g. socket, fd, connect, accept etc.) should additionally have the BIO\_TYPE\_DESCRIPTOR bit set. See BIO\_find\_type(3) for more information.

**BIO\_meth\_free**() is an alias for [free(3)](/free/3.md).

**BIO\_meth\_get\_write**(), **BIO\_meth\_set\_write**(), **BIO\_meth\_get\_read**(), and **BIO\_meth\_set\_read**() get and set the functions *write* and *read* used for writing and reading arbitrary length data to and from the *BIO*. These functions are called from BIO\_write(3) and BIO\_read(3), respectively. The parameters and return values of *write* and *read* have the same meaning as for BIO\_write(3) and BIO\_read(3).

**BIO\_meth\_get\_puts**() and **BIO\_meth\_set\_puts**() get and set the function *puts* used for writing a NUL-terminated string to the *BIO*. This function is called from BIO\_puts(3). The parameters and the return value of *puts* have the same meaning as for BIO\_puts(3).

**BIO\_meth\_get\_gets**() and **BIO\_meth\_set\_gets**() get and set the function *gets* used for reading a line of data from the *BIO*. This function is called from BIO\_gets(3). The parameters and the return value of *gets* have the same meaning as for BIO\_gets(3).

**BIO\_meth\_get\_ctrl**() and **BIO\_meth\_set\_ctrl**() get and set the function *ctrl* used for processing control messages in the *BIO*. This function is called from BIO\_ctrl(3). The parameters and return value of *ctrl* have the same meaning as for BIO\_ctrl(3).

**BIO\_meth\_get\_create**() and **BIO\_meth\_set\_create**() get and set a function *create* used while initializing a new instance of the *BIO*. This function is called from BIO\_new(3). The BIO\_new(3) function allocates the memory for the new *BIO*, and a pointer to this newly allocated structure is passed as the parameter to *create*.

**BIO\_meth\_get\_destroy**() and **BIO\_meth\_set\_destroy**() get and set a function *destroy* used while destroying an instance of a *BIO*. This function is called from BIO\_free(3). A pointer to the *BIO* to be destroyed is passed as the parameter. The *destroy* function is intended to perform clean-up specific to the *BIO* *type*. The memory for the *BIO* itself must not be freed by this function.

**BIO\_meth\_get\_callback\_ctrl**() and **BIO\_meth\_set\_callback\_ctrl**() get and set the function *callback\_ctrl* used for processing callback control messages in the *BIO*. This function is called from BIO\_callback\_ctrl(3). The parameters and return value of *callback\_ctrl* have the same meaning as for BIO\_callback\_ctrl(3).

## RETURN VALUES

**BIO\_get\_new\_index**() returns the new BIO type value or -1 if an error occurs.

**BIO\_meth\_new**() returns the new *BIO\_METHOD* structure or NULL if an error occurs.

The **BIO\_meth\_set\_\***() functions return 1 on success or 0 on error. Currently, they cannot fail.

The **BIO\_meth\_get\_\***() functions return function pointers.

## SEE ALSO

BIO\_ctrl(3), BIO\_find\_type(3), BIO\_new(3), BIO\_read(3)

## HISTORY

These functions first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.
