cec7dddd7e3547cb91a5d874035f36dfcbbcf6c5
[openssl.git] / doc / crypto / BIO_ADDR.pod
1 =pod
2
3 =head1 NAME
4
5 BIO_ADDR, BIO_ADDR_new, BIO_ADDR_free, BIO_ADDR_rawmake,
6 BIO_ADDR_family, BIO_ADDR_rawaddress, BIO_ADDR_rawport,
7 BIO_ADDR_hostname_string, BIO_ADDR_service_string,
8 BIO_ADDR_path_string - BIO_ADDR routines
9
10 =head1 SYNOPSIS
11
12  #include <sys/types.h>
13  #include <openssl/bio.h>
14
15  typedef union bio_addr_st BIO_ADDR;
16
17  BIO_ADDR *BIO_ADDR_new(void);
18  void BIO_ADDR_free(BIO_ADDR *);
19  int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
20                       const void *where, size_t wherelen, unsigned short port);
21  int BIO_ADDR_family(const BIO_ADDR *ap);
22  int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
23  unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
24  char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
25  char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
26  char *BIO_ADDR_path_string(const BIO_ADDR *ap);
27
28 =head1 DESCRIPTION
29
30 The B<BIO_ADDR> type is a wrapper around all types of socket
31 addresses that OpenSSL deals with, currently transparently
32 supporting AF_INET, AF_INET6 and AF_UNIX according to what's
33 available on the platform at hand.
34
35 BIO_ADDR_new() creates a new unfilled B<BIO_ADDR>, to be used
36 with routines that will fill it with information, such as
37 BIO_accept_ex().
38
39 BIO_ADDR_free() frees a B<BIO_ADDR> created with BIO_ADDR_new().
40
41 BIO_ADDR_rawmake() takes a protocol B<family>, an 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 I<Read on about the addresses in L</RAW ADDRESSES> below>.
50
51 BIO_ADDR_family() returns the protocol family of the given
52 B<BIO_ADDR>.  The possible non-error results are one of the
53 constants AF_INET, AF_INET6 and AF_UNIX.
54
55 BIO_ADDR_rawaddress() will write the raw address of the given
56 B<BIO_ADDR> in the area pointed at by B<p> if B<p> is non-NULL,
57 and will set B<*l> to be the amount of bytes the raw address
58 takes up if B<l> is non-NULL.
59 A technique to only find out the size of the address is a call
60 with B<p> set to B<NULL>.  The raw address will be in network byte
61 order, most significant byte first.
62 In case this is a B<AF_UNIX> B<BIO_ADDR>, B<l> gets the length of the
63 path string (not including the terminating NUL, such as the result of
64 a call to strlen()).
65 I<Read on about the addresses in L</RAW ADDRESSES> below>.
66
67 BIO_ADDR_rawport() returns the raw port of the given B<BIO_ADDR>.
68 The raw port will be in network byte order.
69
70 BIO_ADDR_hostname_string() returns a character string with the
71 hostname of the given B<BIO_ADDR>.  If B<numeric> is 1, the string
72 will contain the numerical form of the address.  This only works for
73 B<BIO_ADDR> of the protocol families AF_INET and AF_INET6.  The
74 returned string has been allocated on the heap and must be freed
75 with OPENSSL_free().
76
77 BIO_ADDR_service_string() returns a character string with the
78 service name of the port of the given B<BIO_ADDR>.  If B<numeric>
79 is 1, the string will contain the port number.  This only works
80 for B<BIO_ADDR> of the protocol families AF_INET and AF_INET6.  The
81 returned string has been allocated on the heap and must be freed
82 with OPENSSL_free().
83
84 BIO_ADDR_path_string() returns a character string with the path
85 of the given B<BIO_ADDR>.  This only works for B<BIO_ADDR> of the
86 protocol family AF_UNIX.  The returned string has been allocated
87 on the heap and must be freed with OPENSSL_free().
88
89 =head1 RAW ADDRESSES
90
91 Both BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a
92 network byte order address of a specific site.  Internally, those are
93 treated as a pointer to B<struct in_addr> (for B<AF_INET>), B<struct
94 in6_addr> (for B<AF_INET6>) or B<char *> (for B<AF_UNIX>), all
95 depending on the protocol family the address is for.
96
97 =head1 RETURN VALUES
98
99 The string producing functions BIO_ADDR_hostname_string(),
100 BIO_ADDR_service_string() and BIO_ADDR_path_string() will
101 return B<NULL> on error and leave an error indication on the
102 OpenSSL error stack.
103
104 All other functions described here return 0 or B<NULL> when the
105 information they should return isn't available.
106
107 =head1 SEE ALSO
108
109 L<BIO_connect(3)>, L<BIO_s_connect(3)>