Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2017-03-11 17:48:32 +00:00
|
|
|
BIO_hostserv_priorities,
|
|
|
|
BIO_parse_hostserv
|
|
|
|
- utility routines to parse a standard host and service string
|
Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
#include <openssl/bio.h>
|
|
|
|
|
|
|
|
enum BIO_hostserv_priorities {
|
|
|
|
BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
|
|
|
|
};
|
|
|
|
int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
|
|
|
|
enum BIO_hostserv_priorities hostserv_prio);
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
BIO_parse_hostserv() will parse the information given in B<hostserv>,
|
|
|
|
create strings with the host name and service name and give those
|
|
|
|
back via B<host> and B<service>. Those will need to be freed after
|
|
|
|
they are used. B<hostserv_prio> helps determine if B<hostserv> shall
|
2016-03-20 15:51:06 +00:00
|
|
|
be interpreted primarily as a host name or a service name in ambiguous
|
Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
cases.
|
|
|
|
|
|
|
|
The syntax the BIO_parse_hostserv() recognises is:
|
|
|
|
|
|
|
|
host + ':' + service
|
|
|
|
host + ':' + '*'
|
|
|
|
host + ':'
|
|
|
|
':' + service
|
|
|
|
'*' + ':' + service
|
|
|
|
host
|
|
|
|
service
|
|
|
|
|
|
|
|
The host part can be a name or an IP address. If it's a IPv6
|
|
|
|
address, it MUST be enclosed in brackets, such as '[::1]'.
|
|
|
|
|
|
|
|
The service part can be a service name or its port number.
|
|
|
|
|
|
|
|
The returned values will depend on the given B<hostserv> string
|
|
|
|
and B<hostserv_prio>, as follows:
|
|
|
|
|
|
|
|
host + ':' + service => *host = "host", *service = "service"
|
|
|
|
host + ':' + '*' => *host = "host", *service = NULL
|
|
|
|
host + ':' => *host = "host", *service = NULL
|
|
|
|
':' + service => *host = NULL, *service = "service"
|
|
|
|
'*' + ':' + service => *host = NULL, *service = "service"
|
2016-05-20 12:11:46 +00:00
|
|
|
|
Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
in case no ':' is present in the string, the result depends on
|
|
|
|
hostserv_prio, as follows:
|
2016-05-20 12:11:46 +00:00
|
|
|
|
Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
when hostserv_prio == BIO_PARSE_PRIO_HOST
|
|
|
|
host => *host = "host", *service untouched
|
2016-05-20 12:11:46 +00:00
|
|
|
|
Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
when hostserv_prio == BIO_PARSE_PRIO_SERV
|
|
|
|
service => *host untouched, *service = "service"
|
|
|
|
|
2017-12-25 09:50:39 +00:00
|
|
|
=head1 RETURN VALUES
|
|
|
|
|
|
|
|
BIO_parse_hostserv() returns 1 on success or 0 on error.
|
|
|
|
|
Refactoring BIO: add wrappers around sockaddr et al
Because different platforms have different levels of support for IPv6,
different kinds of sockaddr variants, and some have getaddrinfo et al
while others don't, we could end up with a mess if ifdefs, duplicate
code and other maintainance nightmares.
Instead, we're introducing wrappers around the common form for socket
communication:
BIO_ADDR, closely related to struct sockaddr and some of its variants.
BIO_ADDRINFO, closely related to struct addrinfo.
With that comes support routines, both convenient creators and
accessors, plus a few utility functions:
BIO_parse_hostserv, takes a string of the form host:service and
splits it into host and service. It checks for * in both parts, and
converts any [ipv6-address] syntax to ust the IPv6 address.
BIO_lookup, looks up information on a host.
All routines handle IPv4 (AF_INET) and IPv6 (AF_INET6) addresses, and
there is support for local sockets (AF_UNIX) as well.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-02 14:54:57 +00:00
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
L<BIO_ADDRINFO(3)>
|
2016-05-18 14:16:40 +00:00
|
|
|
|
2016-05-18 15:44:05 +00:00
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
2018-01-15 17:01:46 +00:00
|
|
|
Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2016-05-18 15:44:05 +00:00
|
|
|
|
2018-12-06 13:04:44 +00:00
|
|
|
Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 15:44:05 +00:00
|
|
|
this file except in compliance with the License. You can obtain a copy
|
|
|
|
in the file LICENSE in the source distribution or at
|
|
|
|
L<https://www.openssl.org/source/license.html>.
|
|
|
|
|
|
|
|
=cut
|