BIO_ADDRINFO(3ossl)
π BIO_ADDRINFO π
okay bestie, welcome to BIO_ADDRINFO(3ossl) β yes that's the whole manual name, we're in the OpenSSL corner of the universe now. this page is literally a whole friend group of functions that handle address info, so grab a snack π and let's get into it.
β¨ NAME β¨
BIO_lookup_type, BIO_ADDRINFO, BIO_ADDRINFO_next, BIO_ADDRINFO_free, BIO_ADDRINFO_family, BIO_ADDRINFO_socktype, BIO_ADDRINFO_protocol, BIO_ADDRINFO_address, BIO_lookup_ex, BIO_lookup β all of these are the BIO_ADDRINFO type and its lil routines π
π¦ SYNOPSIS π¦
#include <sys/types.h>
#include <openssl/bio.h>
typedef union bio_addrinfo_st BIO_ADDRINFO;
enum BIO_lookup_type {
BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
};
int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
int family, int socktype, int protocol, BIO_ADDRINFO **res);
int BIO_lookup(const char *host, const char *service,
enum BIO_lookup_type lookup_type,
int family, int socktype, BIO_ADDRINFO **res);
const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
πΈ DESCRIPTION πΈ
so. the BIO_ADDRINFO type is a wrapper for the address information types that your platform gives you. basically a cute lil envelope for whatever your OS hands over π«Ά
and BIO_ADDRINFO normally forms a chain of several of them β so you can pick them off one by one, like a playlist you're working through. iconic behaviour honestly.
BIO_lookup_ex() looks up a specified host and service, and uses lookup_type to decide what the default address should be when host is NULL. the family, socktype and protocol args are what determine which protocol family, socket type and protocol get used for the lookup:
- family can be any of
AF_INET,AF_INET6,AF_UNIXandAF_UNSPEC. - socktype can be
SOCK_STREAM,SOCK_DGRAMor0. setting it to0means any type can be used, no gatekeeping π - protocol specifies a protocol like
IPPROTO_TCP,IPPROTO_UDPorIPPORTO_SCTP(and yup, that's spelled exactly like that on the page β iykyk π). if it's set to0then any protocol can be used. - res points at a pointer that holds the start of a
BIO_ADDRINFOchain.
the AF_UNIX tea β: for the family AF_UNIX, BIO_lookup_ex() will ignore the service parameter and expects the host parameter to hold the path to the socket file. periodt.
BIO_lookup() does the same thing as BIO_lookup_ex(), BUT it doesn't give you the ability to select based on protocol β any protocol may be returned. lowkey the chill version.
<charonqua>now the little getter besties, each one doing exactly one job π</charonqua>
BIO_ADDRINFO_family()β returns the family of the givenBIO_ADDRINFO. the result will be one of the constantsAF_INET,AF_INET6andAF_UNIX.BIO_ADDRINFO_socktype()β returns the socket type of the givenBIO_ADDRINFO. the result will be one of the constantsSOCK_STREAMandSOCK_DGRAM.BIO_ADDRINFO_protocol()β returns the protocol id of the givenBIO_ADDRINFO. the result will be one of the constantsIPPROTO_TCPandIPPROTO_UDP.BIO_ADDRINFO_address()β returns the underlyingBIO_ADDRof the givenBIO_ADDRINFO.BIO_ADDRINFO_next()β returns the nextBIO_ADDRINFOin the chain from the given one. main character energy: always pointing at the next thing β¨BIO_ADDRINFO_free()β frees the chain ofBIO_ADDRINFOstarting with the given one. and if the argument isNULL, nothing is done. no crash, no drama, we love a graceful no-op π
π RETURN VALUES π
BIO_lookup_ex()andBIO_lookup()return1on success and0when an error occurred β and in that error case they'll leave an error indication on the OpenSSL error stack, so go check it π- all the other functions described here return
0orNULLwhen the information they should return isn't available. that's it, that's the vibe check.
π₯ NOTES π₯
real talk: the BIO_lookup_ex() implementation uses the platform provided getaddrinfo() function. on Linux it is known that specifying 0 for the protocol will not return any SCTP based addresses when calling getaddrinfo(). so if you need an SCTP address, you gotta explicitly set the protocol parameter to BIO_lookup_ex() to IPPROTO_SCTP. ngl, the same may be true on other platforms too β so don't @ me.
π okay but seriously bestie, that SCTP thing is a real gotcha. explicitly set IPPROTO_SCTP or you will simply not get your address. no cap.
π HISTORY π
BIO_lookup_ex() was added in OpenSSL 1.1.1. a true icon of that era π
π 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 π«Ά this was OpenSSL 3.5.6, dated 2026-04-07, and you read it in BIO_ADDRINFO(3ossl) β go forth and look up some addresses, slay π
β¨πΈ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms