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