BIO_METH_NEW(3)
π
BIO_METH_NEW(3) β custom BIO_METHOD era π
okay bestie, this is the BIO_METH_NEW(3) page from the Library Functions Manual, and itβs genuinely iconic: weβre manipulating BIO_METHOD structures, aka the little function-pointer tables that give a BIO its whole personality. custom-BIO main character energy, no cap π¦β¨
π 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 β¨
the synopsis says library βlibcryptoβ and #include <openssl/bio.h>, so thatβs your include + lib situation, bestie. the signatures go exactly like this:
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 that implement a BIO type. if you want the whole lore on BIO objects, see BIO_new(3) π
BIO_meth_new()β creates a newBIO_METHODstructure. it needs a unique integertype, and you useBIO_get_new_index()to get that value fortype. currently, the user can only create up to 127 differentBIOtypes, andtypeis limited to the range 129β255. thenamepointer is stored in the structure and will not be freed byBIO_meth_free()β so donβt expect it to clean that up for you, bestie π«Ά- the standard
BIOtypes are listed in<openssl/bio.h>. some examples includeBIO_TYPE_BUFFERandBIO_TYPE_CIPHER. thetypeof filterBIOs should have theBIO_TYPE_FILTERbit set. source/sinkBIOs should have theBIO_TYPE_SOURCE_SINKbit set. file descriptor basedBIOs (e.g. socket, fd, connect, accept etc.) should additionally have theBIO_TYPE_DESCRIPTORbit set. seeBIO_find_type(3)for more information π BIO_meth_free()β is an alias forfree(3). literally that. πBIO_meth_get_write(),BIO_meth_set_write(),BIO_meth_get_read(), andBIO_meth_set_read()β get and set the functionswriteandreadused for writing and reading arbitrary length data to and from theBIO. these functions are called fromBIO_write(3)andBIO_read(3), respectively. the parameters and return values ofwriteandreadhave the same meaning as forBIO_write(3)andBIO_read(3)β¨BIO_meth_get_puts()andBIO_meth_set_puts()β get and set the functionputsused for writing a NUL-terminated string to theBIO. this function is called fromBIO_puts(3). the parameters and the return value ofputshave the same meaning as forBIO_puts(3)πBIO_meth_get_gets()andBIO_meth_set_gets()β get and set the functiongetsused for reading a line of data from theBIO. this function is called fromBIO_gets(3). the parameters and the return value ofgetshave the same meaning as forBIO_gets(3)πΈBIO_meth_get_ctrl()andBIO_meth_set_ctrl()β get and set the functionctrlused for processing control messages in theBIO. this function is called fromBIO_ctrl(3). the parameters and return value ofctrlhave the same meaning as forBIO_ctrl(3)π₯BIO_meth_get_create()andBIO_meth_set_create()β get and set a functioncreateused while initializing a new instance of theBIO. this function is called fromBIO_new(3).BIO_new(3)allocates the memory for the newBIO, and a pointer to this newly allocated structure is passed as the parameter tocreateπBIO_meth_get_destroy()andBIO_meth_set_destroy()β get and set a functiondestroyused while destroying an instance of aBIO. this function is called fromBIO_free(3). a pointer to theBIOto be destroyed is passed as the parameter. thedestroyfunction is intended to perform clean-up specific to theBIOtype. the memory for theBIOitself must not be freed by this function β donβt do it, bestie, thatβs not your moment πBIO_meth_get_callback_ctrl()andBIO_meth_set_callback_ctrl()β get and set the functioncallback_ctrlused for processing callback control messages in theBIO. this function is called fromBIO_callback_ctrl(3). the parameters and return value ofcallback_ctrlhave the same meaning as forBIO_callback_ctrl(3)π
π RETURN VALUES π
BIO_get_new_index()β returns the newBIOtype value or -1 if an error occurs.BIO_meth_new()β returns the newBIO_METHODstructure orNULLif an error occurs.BIO_meth_set_*()β return 1 on success or 0 on error. currently, they cannot fail. slay, no notes πBIO_meth_get_*()β 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. periodt π
mwah π β this cutie is from the Debian source, dated June 8, 2025, and the manual page is BIO_METH_NEW(3) πβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2016 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms