xref: /freebsd/crypto/openssl/doc/man3/BIO_ADDR.pod (revision 58f351825a371d1a3dd693d6f64a1245ea851a51)
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().
41e71b7053SJung-uk Kim
42e71b7053SJung-uk KimBIO_ADDR_clear() clears any data held within the provided B<BIO_ADDR> and sets
43e71b7053SJung-uk Kimit back to an uninitialised state.
44e71b7053SJung-uk Kim
45*58f35182SJung-uk KimBIO_ADDR_rawmake() takes a protocol B<family>, a byte array of
46e71b7053SJung-uk Kimsize B<wherelen> with an address in network byte order pointed at
47e71b7053SJung-uk Kimby B<where> and a port number in network byte order in B<port> (except
48e71b7053SJung-uk Kimfor the B<AF_UNIX> protocol family, where B<port> is meaningless and
49e71b7053SJung-uk Kimtherefore ignored) and populates the given B<BIO_ADDR> with them.
50e71b7053SJung-uk KimIn case this creates a B<AF_UNIX> B<BIO_ADDR>, B<wherelen> is expected
51e71b7053SJung-uk Kimto be the length of the path string (not including the terminating
52e71b7053SJung-uk KimNUL, such as the result of a call to strlen()).
53e71b7053SJung-uk KimI<Read on about the addresses in L</RAW ADDRESSES> below>.
54e71b7053SJung-uk Kim
55e71b7053SJung-uk KimBIO_ADDR_family() returns the protocol family of the given
56e71b7053SJung-uk KimB<BIO_ADDR>.  The possible non-error results are one of the
57e71b7053SJung-uk Kimconstants AF_INET, AF_INET6 and AF_UNIX. It will also return AF_UNSPEC if the
58e71b7053SJung-uk KimBIO_ADDR has not been initialised.
59e71b7053SJung-uk Kim
60e71b7053SJung-uk KimBIO_ADDR_rawaddress() will write the raw address of the given
61e71b7053SJung-uk KimB<BIO_ADDR> in the area pointed at by B<p> if B<p> is non-NULL,
62e71b7053SJung-uk Kimand will set B<*l> to be the amount of bytes the raw address
63e71b7053SJung-uk Kimtakes up if B<l> is non-NULL.
64e71b7053SJung-uk KimA technique to only find out the size of the address is a call
65e71b7053SJung-uk Kimwith B<p> set to B<NULL>.  The raw address will be in network byte
66e71b7053SJung-uk Kimorder, most significant byte first.
67e71b7053SJung-uk KimIn case this is a B<AF_UNIX> B<BIO_ADDR>, B<l> gets the length of the
68e71b7053SJung-uk Kimpath string (not including the terminating NUL, such as the result of
69e71b7053SJung-uk Kima call to strlen()).
70e71b7053SJung-uk KimI<Read on about the addresses in L</RAW ADDRESSES> below>.
71e71b7053SJung-uk Kim
72e71b7053SJung-uk KimBIO_ADDR_rawport() returns the raw port of the given B<BIO_ADDR>.
73e71b7053SJung-uk KimThe raw port will be in network byte order.
74e71b7053SJung-uk Kim
75e71b7053SJung-uk KimBIO_ADDR_hostname_string() returns a character string with the
76e71b7053SJung-uk Kimhostname of the given B<BIO_ADDR>.  If B<numeric> is 1, the string
77e71b7053SJung-uk Kimwill contain the numerical form of the address.  This only works for
78e71b7053SJung-uk KimB<BIO_ADDR> of the protocol families AF_INET and AF_INET6.  The
79e71b7053SJung-uk Kimreturned string has been allocated on the heap and must be freed
80e71b7053SJung-uk Kimwith OPENSSL_free().
81e71b7053SJung-uk Kim
82e71b7053SJung-uk KimBIO_ADDR_service_string() returns a character string with the
83e71b7053SJung-uk Kimservice name of the port of the given B<BIO_ADDR>.  If B<numeric>
84e71b7053SJung-uk Kimis 1, the string will contain the port number.  This only works
85e71b7053SJung-uk Kimfor B<BIO_ADDR> of the protocol families AF_INET and AF_INET6.  The
86e71b7053SJung-uk Kimreturned string has been allocated on the heap and must be freed
87e71b7053SJung-uk Kimwith OPENSSL_free().
88e71b7053SJung-uk Kim
89e71b7053SJung-uk KimBIO_ADDR_path_string() returns a character string with the path
90e71b7053SJung-uk Kimof the given B<BIO_ADDR>.  This only works for B<BIO_ADDR> of the
91e71b7053SJung-uk Kimprotocol family AF_UNIX.  The returned string has been allocated
92e71b7053SJung-uk Kimon the heap and must be freed with OPENSSL_free().
93e71b7053SJung-uk Kim
94e71b7053SJung-uk Kim=head1 RAW ADDRESSES
95e71b7053SJung-uk Kim
96e71b7053SJung-uk KimBoth BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a
97e71b7053SJung-uk Kimnetwork byte order address of a specific site.  Internally, those are
98e71b7053SJung-uk Kimtreated as a pointer to B<struct in_addr> (for B<AF_INET>), B<struct
99e71b7053SJung-uk Kimin6_addr> (for B<AF_INET6>) or B<char *> (for B<AF_UNIX>), all
100e71b7053SJung-uk Kimdepending on the protocol family the address is for.
101e71b7053SJung-uk Kim
102e71b7053SJung-uk Kim=head1 RETURN VALUES
103e71b7053SJung-uk Kim
104e71b7053SJung-uk KimThe string producing functions BIO_ADDR_hostname_string(),
105e71b7053SJung-uk KimBIO_ADDR_service_string() and BIO_ADDR_path_string() will
106e71b7053SJung-uk Kimreturn B<NULL> on error and leave an error indication on the
107e71b7053SJung-uk KimOpenSSL error stack.
108e71b7053SJung-uk Kim
109e71b7053SJung-uk KimAll other functions described here return 0 or B<NULL> when the
110e71b7053SJung-uk Kiminformation they should return isn't available.
111e71b7053SJung-uk Kim
112e71b7053SJung-uk Kim=head1 SEE ALSO
113e71b7053SJung-uk Kim
114e71b7053SJung-uk KimL<BIO_connect(3)>, L<BIO_s_connect(3)>
115e71b7053SJung-uk Kim
116e71b7053SJung-uk Kim=head1 COPYRIGHT
117e71b7053SJung-uk Kim
118*58f35182SJung-uk KimCopyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
119e71b7053SJung-uk Kim
120e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
121e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
122e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
123e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
124e71b7053SJung-uk Kim
125e71b7053SJung-uk Kim=cut
126