1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimBIO_ADDR, BIO_ADDR_new, BIO_ADDR_clear, BIO_ADDR_free, BIO_ADDR_rawmake, 6e71b7053SJung-uk KimBIO_ADDR_family, BIO_ADDR_rawaddress, BIO_ADDR_rawport, 7e71b7053SJung-uk KimBIO_ADDR_hostname_string, BIO_ADDR_service_string, 8e71b7053SJung-uk KimBIO_ADDR_path_string - BIO_ADDR routines 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim=head1 SYNOPSIS 11e71b7053SJung-uk Kim 12e71b7053SJung-uk Kim #include <sys/types.h> 13e71b7053SJung-uk Kim #include <openssl/bio.h> 14e71b7053SJung-uk Kim 15e71b7053SJung-uk Kim typedef union bio_addr_st BIO_ADDR; 16e71b7053SJung-uk Kim 17e71b7053SJung-uk Kim BIO_ADDR *BIO_ADDR_new(void); 18e71b7053SJung-uk Kim void BIO_ADDR_free(BIO_ADDR *); 19e71b7053SJung-uk Kim void BIO_ADDR_clear(BIO_ADDR *ap); 20e71b7053SJung-uk Kim int BIO_ADDR_rawmake(BIO_ADDR *ap, int family, 21e71b7053SJung-uk Kim const void *where, size_t wherelen, unsigned short port); 22e71b7053SJung-uk Kim int BIO_ADDR_family(const BIO_ADDR *ap); 23e71b7053SJung-uk Kim int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l); 24e71b7053SJung-uk Kim unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap); 25e71b7053SJung-uk Kim char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric); 26e71b7053SJung-uk Kim char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric); 27e71b7053SJung-uk Kim char *BIO_ADDR_path_string(const BIO_ADDR *ap); 28e71b7053SJung-uk Kim 29e71b7053SJung-uk Kim=head1 DESCRIPTION 30e71b7053SJung-uk Kim 31e71b7053SJung-uk KimThe B<BIO_ADDR> type is a wrapper around all types of socket 32e71b7053SJung-uk Kimaddresses that OpenSSL deals with, currently transparently 33e71b7053SJung-uk Kimsupporting AF_INET, AF_INET6 and AF_UNIX according to what's 34e71b7053SJung-uk Kimavailable on the platform at hand. 35e71b7053SJung-uk Kim 36e71b7053SJung-uk KimBIO_ADDR_new() creates a new unfilled B<BIO_ADDR>, to be used 37e71b7053SJung-uk Kimwith routines that will fill it with information, such as 38e71b7053SJung-uk KimBIO_accept_ex(). 39e71b7053SJung-uk Kim 40e71b7053SJung-uk KimBIO_ADDR_free() frees a B<BIO_ADDR> created with BIO_ADDR_new(). 41*a7148ab3SEnji CooperIf the argument is NULL, nothing is done. 42e71b7053SJung-uk Kim 43e71b7053SJung-uk KimBIO_ADDR_clear() clears any data held within the provided B<BIO_ADDR> and sets 44e71b7053SJung-uk Kimit back to an uninitialised state. 45e71b7053SJung-uk Kim 4658f35182SJung-uk KimBIO_ADDR_rawmake() takes a protocol B<family>, a byte array of 47e71b7053SJung-uk Kimsize B<wherelen> with an address in network byte order pointed at 48e71b7053SJung-uk Kimby B<where> and a port number in network byte order in B<port> (except 49e71b7053SJung-uk Kimfor the B<AF_UNIX> protocol family, where B<port> is meaningless and 50e71b7053SJung-uk Kimtherefore ignored) and populates the given B<BIO_ADDR> with them. 51e71b7053SJung-uk KimIn case this creates a B<AF_UNIX> B<BIO_ADDR>, B<wherelen> is expected 52e71b7053SJung-uk Kimto be the length of the path string (not including the terminating 53e71b7053SJung-uk KimNUL, such as the result of a call to strlen()). 54b077aed3SPierre ProncheryRead on about the addresses in L</RAW ADDRESSES> below. 55e71b7053SJung-uk Kim 56e71b7053SJung-uk KimBIO_ADDR_family() returns the protocol family of the given 57e71b7053SJung-uk KimB<BIO_ADDR>. The possible non-error results are one of the 58e71b7053SJung-uk Kimconstants AF_INET, AF_INET6 and AF_UNIX. It will also return AF_UNSPEC if the 59e71b7053SJung-uk KimBIO_ADDR has not been initialised. 60e71b7053SJung-uk Kim 61e71b7053SJung-uk KimBIO_ADDR_rawaddress() will write the raw address of the given 62e71b7053SJung-uk KimB<BIO_ADDR> in the area pointed at by B<p> if B<p> is non-NULL, 63e71b7053SJung-uk Kimand will set B<*l> to be the amount of bytes the raw address 64e71b7053SJung-uk Kimtakes up if B<l> is non-NULL. 65e71b7053SJung-uk KimA technique to only find out the size of the address is a call 66e71b7053SJung-uk Kimwith B<p> set to B<NULL>. The raw address will be in network byte 67e71b7053SJung-uk Kimorder, most significant byte first. 68e71b7053SJung-uk KimIn case this is a B<AF_UNIX> B<BIO_ADDR>, B<l> gets the length of the 69e71b7053SJung-uk Kimpath string (not including the terminating NUL, such as the result of 70e71b7053SJung-uk Kima call to strlen()). 71b077aed3SPierre ProncheryRead on about the addresses in L</RAW ADDRESSES> below. 72e71b7053SJung-uk Kim 73e71b7053SJung-uk KimBIO_ADDR_rawport() returns the raw port of the given B<BIO_ADDR>. 74e71b7053SJung-uk KimThe raw port will be in network byte order. 75e71b7053SJung-uk Kim 76e71b7053SJung-uk KimBIO_ADDR_hostname_string() returns a character string with the 77e71b7053SJung-uk Kimhostname of the given B<BIO_ADDR>. If B<numeric> is 1, the string 78e71b7053SJung-uk Kimwill contain the numerical form of the address. This only works for 79e71b7053SJung-uk KimB<BIO_ADDR> of the protocol families AF_INET and AF_INET6. The 80e71b7053SJung-uk Kimreturned string has been allocated on the heap and must be freed 81e71b7053SJung-uk Kimwith OPENSSL_free(). 82e71b7053SJung-uk Kim 83e71b7053SJung-uk KimBIO_ADDR_service_string() returns a character string with the 84e71b7053SJung-uk Kimservice name of the port of the given B<BIO_ADDR>. If B<numeric> 85e71b7053SJung-uk Kimis 1, the string will contain the port number. This only works 86e71b7053SJung-uk Kimfor B<BIO_ADDR> of the protocol families AF_INET and AF_INET6. The 87e71b7053SJung-uk Kimreturned string has been allocated on the heap and must be freed 88e71b7053SJung-uk Kimwith OPENSSL_free(). 89e71b7053SJung-uk Kim 90e71b7053SJung-uk KimBIO_ADDR_path_string() returns a character string with the path 91e71b7053SJung-uk Kimof the given B<BIO_ADDR>. This only works for B<BIO_ADDR> of the 92e71b7053SJung-uk Kimprotocol family AF_UNIX. The returned string has been allocated 93e71b7053SJung-uk Kimon the heap and must be freed with OPENSSL_free(). 94e71b7053SJung-uk Kim 95e71b7053SJung-uk Kim=head1 RAW ADDRESSES 96e71b7053SJung-uk Kim 97e71b7053SJung-uk KimBoth BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a 98e71b7053SJung-uk Kimnetwork byte order address of a specific site. Internally, those are 99e71b7053SJung-uk Kimtreated as a pointer to B<struct in_addr> (for B<AF_INET>), B<struct 100e71b7053SJung-uk Kimin6_addr> (for B<AF_INET6>) or B<char *> (for B<AF_UNIX>), all 101e71b7053SJung-uk Kimdepending on the protocol family the address is for. 102e71b7053SJung-uk Kim 103e71b7053SJung-uk Kim=head1 RETURN VALUES 104e71b7053SJung-uk Kim 105e71b7053SJung-uk KimThe string producing functions BIO_ADDR_hostname_string(), 106e71b7053SJung-uk KimBIO_ADDR_service_string() and BIO_ADDR_path_string() will 107e71b7053SJung-uk Kimreturn B<NULL> on error and leave an error indication on the 108e71b7053SJung-uk KimOpenSSL error stack. 109e71b7053SJung-uk Kim 110e71b7053SJung-uk KimAll other functions described here return 0 or B<NULL> when the 111e71b7053SJung-uk Kiminformation they should return isn't available. 112e71b7053SJung-uk Kim 113e71b7053SJung-uk Kim=head1 SEE ALSO 114e71b7053SJung-uk Kim 115e71b7053SJung-uk KimL<BIO_connect(3)>, L<BIO_s_connect(3)> 116e71b7053SJung-uk Kim 117e71b7053SJung-uk Kim=head1 COPYRIGHT 118e71b7053SJung-uk Kim 119*a7148ab3SEnji CooperCopyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved. 120e71b7053SJung-uk Kim 121b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 122e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 123e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 124e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 125e71b7053SJung-uk Kim 126e71b7053SJung-uk Kim=cut 127