2
0

BIO_parse_hostserv.pod 2.3 KB

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