BIO_ADDR.pod 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. =pod
  2. =head1 NAME
  3. BIO_ADDR, BIO_ADDR_new, BIO_ADDR_copy, BIO_ADDR_dup, BIO_ADDR_clear,
  4. BIO_ADDR_free, BIO_ADDR_rawmake,
  5. BIO_ADDR_family, BIO_ADDR_rawaddress, BIO_ADDR_rawport,
  6. BIO_ADDR_hostname_string, BIO_ADDR_service_string,
  7. BIO_ADDR_path_string - BIO_ADDR routines
  8. =head1 SYNOPSIS
  9. #include <sys/types.h>
  10. #include <openssl/bio.h>
  11. typedef union bio_addr_st BIO_ADDR;
  12. BIO_ADDR *BIO_ADDR_new(void);
  13. int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src);
  14. BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap);
  15. void BIO_ADDR_free(BIO_ADDR *);
  16. void BIO_ADDR_clear(BIO_ADDR *ap);
  17. int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
  18. const void *where, size_t wherelen, unsigned short port);
  19. int BIO_ADDR_family(const BIO_ADDR *ap);
  20. int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
  21. unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
  22. char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
  23. char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
  24. char *BIO_ADDR_path_string(const BIO_ADDR *ap);
  25. =head1 DESCRIPTION
  26. The B<BIO_ADDR> type is a wrapper around all types of socket
  27. addresses that OpenSSL deals with, currently transparently
  28. supporting AF_INET, AF_INET6 and AF_UNIX according to what's
  29. available on the platform at hand.
  30. BIO_ADDR_new() creates a new unfilled B<BIO_ADDR>, to be used
  31. with routines that will fill it with information, such as
  32. BIO_accept_ex().
  33. BIO_ADDR_copy() copies the contents of B<src> into B<dst>. Neither B<src> or
  34. B<dst> can be NULL.
  35. BIO_ADDR_dup() creates a new B<BIO_ADDR>, with a copy of the
  36. address data in B<ap>.
  37. BIO_ADDR_free() frees a B<BIO_ADDR> created with BIO_ADDR_new()
  38. or BIO_ADDR_dup();
  39. BIO_ADDR_clear() clears any data held within the provided B<BIO_ADDR> and sets
  40. it back to an uninitialised state.
  41. BIO_ADDR_rawmake() takes a protocol B<family>, a byte array of
  42. size B<wherelen> with an address in network byte order pointed at
  43. by B<where> and a port number in network byte order in B<port> (except
  44. for the B<AF_UNIX> protocol family, where B<port> is meaningless and
  45. therefore ignored) and populates the given B<BIO_ADDR> with them.
  46. In case this creates a B<AF_UNIX> B<BIO_ADDR>, B<wherelen> is expected
  47. to be the length of the path string (not including the terminating
  48. NUL, such as the result of a call to strlen()).
  49. Read on about the addresses in L</RAW ADDRESSES> below.
  50. BIO_ADDR_family() returns the protocol family of the given
  51. B<BIO_ADDR>. The possible non-error results are one of the
  52. constants AF_INET, AF_INET6 and AF_UNIX. It will also return AF_UNSPEC if the
  53. BIO_ADDR has not been initialised.
  54. BIO_ADDR_rawaddress() will write the raw address of the given
  55. B<BIO_ADDR> in the area pointed at by B<p> if B<p> is non-NULL,
  56. and will set B<*l> to be the amount of bytes the raw address
  57. takes up if B<l> is non-NULL.
  58. A technique to only find out the size of the address is a call
  59. with B<p> set to B<NULL>. The raw address will be in network byte
  60. order, most significant byte first.
  61. In case this is a B<AF_UNIX> B<BIO_ADDR>, B<l> gets the length of the
  62. path string (not including the terminating NUL, such as the result of
  63. a call to strlen()).
  64. Read on about the addresses in L</RAW ADDRESSES> below.
  65. BIO_ADDR_rawport() returns the raw port of the given B<BIO_ADDR>.
  66. The raw port will be in network byte order.
  67. BIO_ADDR_hostname_string() returns a character string with the
  68. hostname of the given B<BIO_ADDR>. If B<numeric> is 1, the string
  69. will contain the numerical form of the address. This only works for
  70. B<BIO_ADDR> of the protocol families AF_INET and AF_INET6. The
  71. returned string has been allocated on the heap and must be freed
  72. with OPENSSL_free().
  73. BIO_ADDR_service_string() returns a character string with the
  74. service name of the port of the given B<BIO_ADDR>. If B<numeric>
  75. is 1, the string will contain the port number. This only works
  76. for B<BIO_ADDR> of the protocol families AF_INET and AF_INET6. The
  77. returned string has been allocated on the heap and must be freed
  78. with OPENSSL_free().
  79. BIO_ADDR_path_string() returns a character string with the path
  80. of the given B<BIO_ADDR>. This only works for B<BIO_ADDR> of the
  81. protocol family AF_UNIX. The returned string has been allocated
  82. on the heap and must be freed with OPENSSL_free().
  83. =head1 RAW ADDRESSES
  84. Both BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a
  85. network byte order address of a specific site. Internally, those are
  86. treated as a pointer to B<struct in_addr> (for B<AF_INET>), B<struct
  87. in6_addr> (for B<AF_INET6>) or B<char *> (for B<AF_UNIX>), all
  88. depending on the protocol family the address is for.
  89. =head1 RETURN VALUES
  90. The string producing functions BIO_ADDR_hostname_string(),
  91. BIO_ADDR_service_string() and BIO_ADDR_path_string() will
  92. return B<NULL> on error and leave an error indication on the
  93. OpenSSL error stack.
  94. BIO_ADDR_copy() returns 1 on success or 0 on error.
  95. All other functions described here return 0 or B<NULL> when the
  96. information they should return isn't available.
  97. =head1 SEE ALSO
  98. L<BIO_connect(3)>, L<BIO_s_connect(3)>
  99. =head1 HISTORY
  100. BIO_ADDR_copy() and BIO_ADDR_dup() were added in OpenSSL 3.2.
  101. =head1 COPYRIGHT
  102. Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
  103. Licensed under the Apache License 2.0 (the "License"). You may not use
  104. this file except in compliance with the License. You can obtain a copy
  105. in the file LICENSE in the source distribution or at
  106. L<https://www.openssl.org/source/license.html>.
  107. =cut