BIO_ADDR(3ossl)
π BIO_ADDR β the OpenSSL manual, but make it make sense β¨
okay bestie, welcome to BIO_ADDR(3ossl), one of the OpenSSL pages, and honestly? she's a baddie. this is the whole family of BIO_ADDR routines and we're gonna go through every single one of them together, no skips, no cap π
πΈ NAME πΈ
BIO_ADDR, BIO_ADDR_new, BIO_ADDR_copy, BIO_ADDR_dup, BIO_ADDR_clear, BIO_ADDR_free, BIO_ADDR_rawmake, BIO_ADDR_family, BIO_ADDR_rawaddress, BIO_ADDR_rawport, BIO_ADDR_hostname_string, BIO_ADDR_service_string, BIO_ADDR_path_string β all the BIO_ADDR routines, together at last π«Ά
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <openssl/bio.h>
typedef union bio_addr_st BIO_ADDR;
BIO_ADDR *BIO_ADDR_new(void);
int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src);
BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap);
void BIO_ADDR_free(BIO_ADDR *ap);
void BIO_ADDR_clear(BIO_ADDR *ap);
int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
const void *where, size_t wherelen, unsigned short port);
int BIO_ADDR_family(const BIO_ADDR *ap);
int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
char *BIO_ADDR_path_string(const BIO_ADDR *ap);
like, look at her. iconic. no notes π
π¦ DESCRIPTION π¦
The BIO_ADDR type is basically a little wrapper around all the types of socket addresses that OpenSSL deals with, and rn she transparently supports AF_INET, AF_INET6 and AF_UNIX β depending on what's actually available on the platform at hand, iykyk π
BIO_ADDR_new()β creates a brand new unfilledBIO_ADDR, ready to be used with routines that will fill it with information, likeBIO_accept_ex(). she's empty but she's got potential π«BIO_ADDR_copy()β copies the contents of src into dst. Neither src nor dst can beNULL, so don't even try it πBIO_ADDR_dup()β creates a newBIO_ADDR, with a copy of the address data in ap. a lil clone, we love her πBIO_ADDR_free()β frees aBIO_ADDRcreated withBIO_ADDR_new()orBIO_ADDR_dup(). If the argument isNULL, nothing is done. no drama, no crash, we respect that πBIO_ADDR_clear()β clears any data held within the providedBIO_ADDRand sets it back to an uninitialised state. factory reset energy β¨BIO_ADDR_rawmake()β takes a protocol family, a byte array of size wherelen with an address in network byte order pointed at by where, and a port number in network byte order in port, then populates the givenBIO_ADDRwith them. Except for theAF_UNIXprotocol family, where port is meaningless and therefore ignored (she's above that). In case this creates aAF_UNIXBIO_ADDR, wherelen is expected to be the length of the path string β not including the terminating NUL, such as the result of a call tostrlen(). Read on about the addresses in "RAW ADDRESSES" below πBIO_ADDR_family()β returns the protocol family of the givenBIO_ADDR. The possible non-error results are one of the constantsAF_INET,AF_INET6andAF_UNIX. It will also returnAF_UNSPECif theBIO_ADDRhas not been initialised. (uninitiated queen behavior π)BIO_ADDR_rawaddress()β will write the raw address of the givenBIO_ADDRin the area pointed at by p if p is non-NULL, and will set*lto be the amount of bytes the raw address takes up if l is non-NULL. A technique to only find out the size of the address is a call with p set toNULLβ sneaky but valid π₯ The raw address will be in network byte order, most significant byte first. In case this is aAF_UNIXBIO_ADDR, l gets the length of the path string β not including the terminating NUL, such as the result of a call tostrlen(). Again, "RAW ADDRESSES" below πBIO_ADDR_rawport()β returns the raw port of the givenBIO_ADDR. The raw port will be in network byte order. raw. unbothered. πBIO_ADDR_hostname_string()β returns a character string with the hostname of the givenBIO_ADDR. If numeric is1, the string will contain the numerical form of the address. This only works forBIO_ADDRof the protocol familiesAF_INETandAF_INET6. The returned string has been allocated on the heap and must be freed withOPENSSL_free(). do not forget this or she will haunt you πBIO_ADDR_service_string()β returns a character string with the service name of the port of the givenBIO_ADDR. If numeric is1, the string will contain the port number. This only works forBIO_ADDRof the protocol familiesAF_INETandAF_INET6. The returned string has been allocated on the heap and must be freed withOPENSSL_free(). same deal bestie, free your strings π§BIO_ADDR_path_string()β returns a character string with the path of the givenBIO_ADDR. This only works forBIO_ADDRof the protocol familyAF_UNIX. The returned string has been allocated on the heap and must be freed withOPENSSL_free(). yes. again. free it π
β RAW ADDRESSES β
Both BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a network byte order address of a specific site. Internally, those are treated as a pointer to struct in_addr (for AF_INET), struct in6_addr (for AF_INET6) or char * (for AF_UNIX) β all depending on the protocol family the address is for. it's giving shape-shifter, but in a c-struct way πΈ
π₯ RETURN VALUES π₯
The string producing functions BIO_ADDR_hostname_string(), BIO_ADDR_service_string() and BIO_ADDR_path_string() will return NULL on error and leave an error indication on the OpenSSL error stack.
BIO_ADDR_copy() returns 1 on success or 0 on error.
All other functions described here return 0 or NULL when the information they should return isn't available. (not me getting nothing back from a function, we've all been there π)
π SEE ALSO π
BIO_connect(3), BIO_s_connect(3)
π HISTORY π
BIO_ADDR_copy() and BIO_ADDR_dup() were added in OpenSSL 3.2. new girls on the block, and they ate π
π COPYRIGHT π
Copyright 2016-2024 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>.
and that's the whole page bestie, every flag, every return value, every AF_UNIX caveat, untouched and unbothered π«Ά this was OpenSSL 3.5.9, dated 2026-09-29, and yes that date is in the future, don't think about it too hard, just say thank you and go OPENSSL_free() your strings πβ¨π¦
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms