xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/doc/man3/BIO_parse_hostserv.pod (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos=pod
2*4724848cSchristos
3*4724848cSchristos=head1 NAME
4*4724848cSchristos
5*4724848cSchristosBIO_hostserv_priorities,
6*4724848cSchristosBIO_parse_hostserv
7*4724848cSchristos- utility routines to parse a standard host and service string
8*4724848cSchristos
9*4724848cSchristos=head1 SYNOPSIS
10*4724848cSchristos
11*4724848cSchristos #include <openssl/bio.h>
12*4724848cSchristos
13*4724848cSchristos enum BIO_hostserv_priorities {
14*4724848cSchristos     BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
15*4724848cSchristos };
16*4724848cSchristos int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
17*4724848cSchristos                        enum BIO_hostserv_priorities hostserv_prio);
18*4724848cSchristos
19*4724848cSchristos=head1 DESCRIPTION
20*4724848cSchristos
21*4724848cSchristosBIO_parse_hostserv() will parse the information given in B<hostserv>,
22*4724848cSchristoscreate strings with the hostname and service name and give those
23*4724848cSchristosback via B<host> and B<service>.  Those will need to be freed after
24*4724848cSchristosthey are used.  B<hostserv_prio> helps determine if B<hostserv> shall
25*4724848cSchristosbe interpreted primarily as a hostname or a service name in ambiguous
26*4724848cSchristoscases.
27*4724848cSchristos
28*4724848cSchristosThe syntax the BIO_parse_hostserv() recognises is:
29*4724848cSchristos
30*4724848cSchristos host + ':' + service
31*4724848cSchristos host + ':' + '*'
32*4724848cSchristos host + ':'
33*4724848cSchristos        ':' + service
34*4724848cSchristos '*'  + ':' + service
35*4724848cSchristos host
36*4724848cSchristos service
37*4724848cSchristos
38*4724848cSchristosThe host part can be a name or an IP address.  If it's a IPv6
39*4724848cSchristosaddress, it MUST be enclosed in brackets, such as '[::1]'.
40*4724848cSchristos
41*4724848cSchristosThe service part can  be a service name or its port number.
42*4724848cSchristos
43*4724848cSchristosThe returned values will depend on the given B<hostserv> string
44*4724848cSchristosand B<hostserv_prio>, as follows:
45*4724848cSchristos
46*4724848cSchristos host + ':' + service  => *host = "host", *service = "service"
47*4724848cSchristos host + ':' + '*'      => *host = "host", *service = NULL
48*4724848cSchristos host + ':'            => *host = "host", *service = NULL
49*4724848cSchristos        ':' + service  => *host = NULL, *service = "service"
50*4724848cSchristos  '*' + ':' + service  => *host = NULL, *service = "service"
51*4724848cSchristos
52*4724848cSchristos in case no ':' is present in the string, the result depends on
53*4724848cSchristos hostserv_prio, as follows:
54*4724848cSchristos
55*4724848cSchristos when hostserv_prio == BIO_PARSE_PRIO_HOST
56*4724848cSchristos host                 => *host = "host", *service untouched
57*4724848cSchristos
58*4724848cSchristos when hostserv_prio == BIO_PARSE_PRIO_SERV
59*4724848cSchristos service              => *host untouched, *service = "service"
60*4724848cSchristos
61*4724848cSchristos=head1 RETURN VALUES
62*4724848cSchristos
63*4724848cSchristosBIO_parse_hostserv() returns 1 on success or 0 on error.
64*4724848cSchristos
65*4724848cSchristos=head1 SEE ALSO
66*4724848cSchristos
67*4724848cSchristosL<BIO_ADDRINFO(3)>
68*4724848cSchristos
69*4724848cSchristos=head1 COPYRIGHT
70*4724848cSchristos
71*4724848cSchristosCopyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
72*4724848cSchristos
73*4724848cSchristosLicensed under the OpenSSL license (the "License").  You may not use
74*4724848cSchristosthis file except in compliance with the License.  You can obtain a copy
75*4724848cSchristosin the file LICENSE in the source distribution or at
76*4724848cSchristosL<https://www.openssl.org/source/license.html>.
77*4724848cSchristos
78*4724848cSchristos=cut
79