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