xref: /freebsd/crypto/openssl/doc/man3/BIO_ADDRINFO.pod (revision a7148ab39c03abd4d1a84997c70bf96f15dd2a09)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimBIO_lookup_type,
6e71b7053SJung-uk KimBIO_ADDRINFO, BIO_ADDRINFO_next, BIO_ADDRINFO_free,
7e71b7053SJung-uk KimBIO_ADDRINFO_family, BIO_ADDRINFO_socktype, BIO_ADDRINFO_protocol,
8e71b7053SJung-uk KimBIO_ADDRINFO_address,
9e71b7053SJung-uk KimBIO_lookup_ex,
10e71b7053SJung-uk KimBIO_lookup
11e71b7053SJung-uk Kim- BIO_ADDRINFO type and routines
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim=head1 SYNOPSIS
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim #include <sys/types.h>
16e71b7053SJung-uk Kim #include <openssl/bio.h>
17e71b7053SJung-uk Kim
18e71b7053SJung-uk Kim typedef union bio_addrinfo_st BIO_ADDRINFO;
19e71b7053SJung-uk Kim
20e71b7053SJung-uk Kim enum BIO_lookup_type {
21e71b7053SJung-uk Kim     BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
22e71b7053SJung-uk Kim };
23e71b7053SJung-uk Kim
24e71b7053SJung-uk Kim int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
25e71b7053SJung-uk Kim                   int family, int socktype, int protocol, BIO_ADDRINFO **res);
26b077aed3SPierre Pronchery int BIO_lookup(const char *host, const char *service,
27e71b7053SJung-uk Kim                enum BIO_lookup_type lookup_type,
28e71b7053SJung-uk Kim                int family, int socktype, BIO_ADDRINFO **res);
29e71b7053SJung-uk Kim
30e71b7053SJung-uk Kim const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
31e71b7053SJung-uk Kim int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
32e71b7053SJung-uk Kim int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
33e71b7053SJung-uk Kim int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
34e71b7053SJung-uk Kim const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
35e71b7053SJung-uk Kim void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
36e71b7053SJung-uk Kim
37e71b7053SJung-uk Kim=head1 DESCRIPTION
38e71b7053SJung-uk Kim
39e71b7053SJung-uk KimThe B<BIO_ADDRINFO> type is a wrapper for address information
40e71b7053SJung-uk Kimtypes provided on your platform.
41e71b7053SJung-uk Kim
42e71b7053SJung-uk KimB<BIO_ADDRINFO> normally forms a chain of several that can be
43e71b7053SJung-uk Kimpicked at one by one.
44e71b7053SJung-uk Kim
45e71b7053SJung-uk KimBIO_lookup_ex() looks up a specified B<host> and B<service>, and
46e71b7053SJung-uk Kimuses B<lookup_type> to determine what the default address should
47e71b7053SJung-uk Kimbe if B<host> is B<NULL>. B<family>, B<socktype> and B<protocol> are used to
48e71b7053SJung-uk Kimdetermine what protocol family, socket type and protocol should be used for
49e71b7053SJung-uk Kimthe lookup.  B<family> can be any of AF_INET, AF_INET6, AF_UNIX and
50e71b7053SJung-uk KimAF_UNSPEC. B<socktype> can be SOCK_STREAM, SOCK_DGRAM or 0. Specifying 0
51e71b7053SJung-uk Kimindicates that any type can be used. B<protocol> specifies a protocol such as
52e71b7053SJung-uk KimIPPROTO_TCP, IPPROTO_UDP or IPPORTO_SCTP. If set to 0 than any protocol can be
53e71b7053SJung-uk Kimused. B<res> points at a pointer to hold the start of a B<BIO_ADDRINFO>
54e71b7053SJung-uk Kimchain.
55e71b7053SJung-uk Kim
56e71b7053SJung-uk KimFor the family B<AF_UNIX>, BIO_lookup_ex() will ignore the B<service>
57b077aed3SPierre Proncheryparameter and expects the B<host> parameter to hold the path to the socket file.
58e71b7053SJung-uk Kim
59e71b7053SJung-uk KimBIO_lookup() does the same as BIO_lookup_ex() but does not provide the ability
60e71b7053SJung-uk Kimto select based on the protocol (any protocol may be returned).
61e71b7053SJung-uk Kim
62e71b7053SJung-uk KimBIO_ADDRINFO_family() returns the family of the given
63e71b7053SJung-uk KimB<BIO_ADDRINFO>.  The result will be one of the constants
64e71b7053SJung-uk KimAF_INET, AF_INET6 and AF_UNIX.
65e71b7053SJung-uk Kim
66e71b7053SJung-uk KimBIO_ADDRINFO_socktype() returns the socket type of the given
67e71b7053SJung-uk KimB<BIO_ADDRINFO>.  The result will be one of the constants
68e71b7053SJung-uk KimSOCK_STREAM and SOCK_DGRAM.
69e71b7053SJung-uk Kim
70e71b7053SJung-uk KimBIO_ADDRINFO_protocol() returns the protocol id of the given
71e71b7053SJung-uk KimB<BIO_ADDRINFO>.  The result will be one of the constants
72e71b7053SJung-uk KimIPPROTO_TCP and IPPROTO_UDP.
73e71b7053SJung-uk Kim
74e71b7053SJung-uk KimBIO_ADDRINFO_address() returns the underlying B<BIO_ADDR>
75e71b7053SJung-uk Kimof the given B<BIO_ADDRINFO>.
76e71b7053SJung-uk Kim
77e71b7053SJung-uk KimBIO_ADDRINFO_next() returns the next B<BIO_ADDRINFO> in the chain
78e71b7053SJung-uk Kimfrom the given one.
79e71b7053SJung-uk Kim
80e71b7053SJung-uk KimBIO_ADDRINFO_free() frees the chain of B<BIO_ADDRINFO> starting
81*a7148ab3SEnji Cooperwith the given one. If the argument is NULL, nothing is done.
82e71b7053SJung-uk Kim
83e71b7053SJung-uk Kim=head1 RETURN VALUES
84e71b7053SJung-uk Kim
85e71b7053SJung-uk KimBIO_lookup_ex() and BIO_lookup() return 1 on success and 0 when an error
86e71b7053SJung-uk Kimoccurred, and will leave an error indication on the OpenSSL error stack in that
87e71b7053SJung-uk Kimcase.
88e71b7053SJung-uk Kim
89e71b7053SJung-uk KimAll other functions described here return 0 or B<NULL> when the
90e71b7053SJung-uk Kiminformation they should return isn't available.
91e71b7053SJung-uk Kim
92e71b7053SJung-uk Kim=head1 NOTES
93e71b7053SJung-uk Kim
94e71b7053SJung-uk KimThe BIO_lookup_ex() implementation uses the platform provided getaddrinfo()
95e71b7053SJung-uk Kimfunction. On Linux it is known that specifying 0 for the protocol will not
9658f35182SJung-uk Kimreturn any SCTP based addresses when calling getaddrinfo(). Therefore, if an SCTP
97e71b7053SJung-uk Kimaddress is required then the B<protocol> parameter to BIO_lookup_ex() should be
98e71b7053SJung-uk Kimexplicitly set to IPPROTO_SCTP. The same may be true on other platforms.
99e71b7053SJung-uk Kim
100e71b7053SJung-uk Kim=head1 HISTORY
101e71b7053SJung-uk Kim
102e71b7053SJung-uk KimThe BIO_lookup_ex() function was added in OpenSSL 1.1.1.
103e71b7053SJung-uk Kim
104e71b7053SJung-uk Kim=head1 COPYRIGHT
105e71b7053SJung-uk Kim
106*a7148ab3SEnji CooperCopyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
107e71b7053SJung-uk Kim
108b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
109e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
110e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
111e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
112e71b7053SJung-uk Kim
113e71b7053SJung-uk Kim=cut
114