BIO_parse_hostserv.pod 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 host name 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 host name 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.
  31. The returned values will depend on the given B<hostserv> string
  32. and B<hostserv_prio>, as follows:
  33. host + ':' + service => *host = "host", *service = "service"
  34. host + ':' + '*' => *host = "host", *service = NULL
  35. host + ':' => *host = "host", *service = NULL
  36. ':' + service => *host = NULL, *service = "service"
  37. '*' + ':' + service => *host = NULL, *service = "service"
  38. in case no ':' is present in the string, the result depends on
  39. hostserv_prio, as follows:
  40. when hostserv_prio == BIO_PARSE_PRIO_HOST
  41. host => *host = "host", *service untouched
  42. when hostserv_prio == BIO_PARSE_PRIO_SERV
  43. service => *host untouched, *service = "service"
  44. =head1 RETURN VALUES
  45. BIO_parse_hostserv() returns 1 on success or 0 on error.
  46. =head1 SEE ALSO
  47. L<BIO_ADDRINFO(3)>
  48. =head1 COPYRIGHT
  49. Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
  50. Licensed under the OpenSSL license (the "License"). You may not use
  51. this file except in compliance with the License. You can obtain a copy
  52. in the file LICENSE in the source distribution or at
  53. L<https://www.openssl.org/source/license.html>.
  54. =cut