Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5      1.1  christos BIO_hostserv_priorities,
      6      1.1  christos BIO_parse_hostserv
      7      1.1  christos - utility routines to parse a standard host and service string
      8      1.1  christos 
      9      1.1  christos =head1 SYNOPSIS
     10      1.1  christos 
     11      1.1  christos  #include <openssl/bio.h>
     12      1.1  christos 
     13      1.1  christos  enum BIO_hostserv_priorities {
     14      1.1  christos      BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
     15      1.1  christos  };
     16      1.1  christos  int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
     17      1.1  christos                         enum BIO_hostserv_priorities hostserv_prio);
     18      1.1  christos 
     19      1.1  christos =head1 DESCRIPTION
     20      1.1  christos 
     21      1.1  christos BIO_parse_hostserv() will parse the information given in B<hostserv>,
     22  1.1.1.2  christos create strings with the hostname and service name and give those
     23      1.1  christos back via B<host> and B<service>.  Those will need to be freed after
     24      1.1  christos they are used.  B<hostserv_prio> helps determine if B<hostserv> shall
     25  1.1.1.2  christos be interpreted primarily as a hostname or a service name in ambiguous
     26      1.1  christos cases.
     27      1.1  christos 
     28      1.1  christos The syntax the BIO_parse_hostserv() recognises is:
     29      1.1  christos 
     30      1.1  christos  host + ':' + service
     31      1.1  christos  host + ':' + '*'
     32      1.1  christos  host + ':'
     33      1.1  christos         ':' + service
     34      1.1  christos  '*'  + ':' + service
     35      1.1  christos  host
     36      1.1  christos  service
     37      1.1  christos 
     38      1.1  christos The host part can be a name or an IP address.  If it's a IPv6
     39      1.1  christos address, it MUST be enclosed in brackets, such as '[::1]'.
     40      1.1  christos 
     41  1.1.1.3  christos The service part can be a service name or its port number.  A service name
     42  1.1.1.3  christos will be mapped to a port number using the system function getservbyname().
     43      1.1  christos 
     44      1.1  christos The returned values will depend on the given B<hostserv> string
     45      1.1  christos and B<hostserv_prio>, as follows:
     46      1.1  christos 
     47      1.1  christos  host + ':' + service  => *host = "host", *service = "service"
     48      1.1  christos  host + ':' + '*'      => *host = "host", *service = NULL
     49      1.1  christos  host + ':'            => *host = "host", *service = NULL
     50      1.1  christos         ':' + service  => *host = NULL, *service = "service"
     51      1.1  christos   '*' + ':' + service  => *host = NULL, *service = "service"
     52      1.1  christos 
     53      1.1  christos  in case no ':' is present in the string, the result depends on
     54      1.1  christos  hostserv_prio, as follows:
     55      1.1  christos 
     56      1.1  christos  when hostserv_prio == BIO_PARSE_PRIO_HOST
     57      1.1  christos  host                 => *host = "host", *service untouched
     58      1.1  christos 
     59      1.1  christos  when hostserv_prio == BIO_PARSE_PRIO_SERV
     60      1.1  christos  service              => *host untouched, *service = "service"
     61      1.1  christos 
     62      1.1  christos =head1 RETURN VALUES
     63      1.1  christos 
     64      1.1  christos BIO_parse_hostserv() returns 1 on success or 0 on error.
     65      1.1  christos 
     66      1.1  christos =head1 SEE ALSO
     67      1.1  christos 
     68      1.1  christos L<BIO_ADDRINFO(3)>
     69      1.1  christos 
     70      1.1  christos =head1 COPYRIGHT
     71      1.1  christos 
     72  1.1.1.3  christos Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
     73      1.1  christos 
     74  1.1.1.3  christos Licensed under the Apache License 2.0 (the "License").  You may not use
     75      1.1  christos this file except in compliance with the License.  You can obtain a copy
     76      1.1  christos in the file LICENSE in the source distribution or at
     77      1.1  christos L<https://www.openssl.org/source/license.html>.
     78      1.1  christos 
     79      1.1  christos =cut
     80