Blame doc/man3/BIO_ADDR.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
BIO_ADDR, BIO_ADDR_new, BIO_ADDR_clear, BIO_ADDR_free, BIO_ADDR_rawmake,
Packit c4476c
BIO_ADDR_family, BIO_ADDR_rawaddress, BIO_ADDR_rawport,
Packit c4476c
BIO_ADDR_hostname_string, BIO_ADDR_service_string,
Packit c4476c
BIO_ADDR_path_string - BIO_ADDR routines
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <sys/types.h>
Packit c4476c
 #include <openssl/bio.h>
Packit c4476c
Packit c4476c
 typedef union bio_addr_st BIO_ADDR;
Packit c4476c
Packit c4476c
 BIO_ADDR *BIO_ADDR_new(void);
Packit c4476c
 void BIO_ADDR_free(BIO_ADDR *);
Packit c4476c
 void BIO_ADDR_clear(BIO_ADDR *ap);
Packit c4476c
 int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
Packit c4476c
                      const void *where, size_t wherelen, unsigned short port);
Packit c4476c
 int BIO_ADDR_family(const BIO_ADDR *ap);
Packit c4476c
 int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
Packit c4476c
 unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
Packit c4476c
 char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
Packit c4476c
 char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
Packit c4476c
 char *BIO_ADDR_path_string(const BIO_ADDR *ap);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
The B<BIO_ADDR> type is a wrapper around all types of socket
Packit c4476c
addresses that OpenSSL deals with, currently transparently
Packit c4476c
supporting AF_INET, AF_INET6 and AF_UNIX according to what's
Packit c4476c
available on the platform at hand.
Packit c4476c
Packit c4476c
BIO_ADDR_new() creates a new unfilled B<BIO_ADDR>, to be used
Packit c4476c
with routines that will fill it with information, such as
Packit c4476c
BIO_accept_ex().
Packit c4476c
Packit c4476c
BIO_ADDR_free() frees a B<BIO_ADDR> created with BIO_ADDR_new().
Packit c4476c
Packit c4476c
BIO_ADDR_clear() clears any data held within the provided B<BIO_ADDR> and sets
Packit c4476c
it back to an uninitialised state.
Packit c4476c
Packit c4476c
BIO_ADDR_rawmake() takes a protocol B<family>, an byte array of
Packit c4476c
size B<wherelen> with an address in network byte order pointed at
Packit c4476c
by B<where> and a port number in network byte order in B<port> (except
Packit c4476c
for the B<AF_UNIX> protocol family, where B<port> is meaningless and
Packit c4476c
therefore ignored) and populates the given B<BIO_ADDR> with them.
Packit c4476c
In case this creates a B<AF_UNIX> B<BIO_ADDR>, B<wherelen> is expected
Packit c4476c
to be the length of the path string (not including the terminating
Packit c4476c
NUL, such as the result of a call to strlen()).
Packit c4476c
I<Read on about the addresses in L</RAW ADDRESSES> below>.
Packit c4476c
Packit c4476c
BIO_ADDR_family() returns the protocol family of the given
Packit c4476c
B<BIO_ADDR>.  The possible non-error results are one of the
Packit c4476c
constants AF_INET, AF_INET6 and AF_UNIX. It will also return AF_UNSPEC if the
Packit c4476c
BIO_ADDR has not been initialised.
Packit c4476c
Packit c4476c
BIO_ADDR_rawaddress() will write the raw address of the given
Packit c4476c
B<BIO_ADDR> in the area pointed at by B

if B

is non-NULL,

Packit c4476c
and will set B<*l> to be the amount of bytes the raw address
Packit c4476c
takes up if B<l> is non-NULL.
Packit c4476c
A technique to only find out the size of the address is a call
Packit c4476c
with B

set to B<NULL>. The raw address will be in network byte

Packit c4476c
order, most significant byte first.
Packit c4476c
In case this is a B<AF_UNIX> B<BIO_ADDR>, B<l> gets the length of the
Packit c4476c
path string (not including the terminating NUL, such as the result of
Packit c4476c
a call to strlen()).
Packit c4476c
I<Read on about the addresses in L</RAW ADDRESSES> below>.
Packit c4476c
Packit c4476c
BIO_ADDR_rawport() returns the raw port of the given B<BIO_ADDR>.
Packit c4476c
The raw port will be in network byte order.
Packit c4476c
Packit c4476c
BIO_ADDR_hostname_string() returns a character string with the
Packit c4476c
hostname of the given B<BIO_ADDR>.  If B<numeric> is 1, the string
Packit c4476c
will contain the numerical form of the address.  This only works for
Packit c4476c
B<BIO_ADDR> of the protocol families AF_INET and AF_INET6.  The
Packit c4476c
returned string has been allocated on the heap and must be freed
Packit c4476c
with OPENSSL_free().
Packit c4476c
Packit c4476c
BIO_ADDR_service_string() returns a character string with the
Packit c4476c
service name of the port of the given B<BIO_ADDR>.  If B<numeric>
Packit c4476c
is 1, the string will contain the port number.  This only works
Packit c4476c
for B<BIO_ADDR> of the protocol families AF_INET and AF_INET6.  The
Packit c4476c
returned string has been allocated on the heap and must be freed
Packit c4476c
with OPENSSL_free().
Packit c4476c
Packit c4476c
BIO_ADDR_path_string() returns a character string with the path
Packit c4476c
of the given B<BIO_ADDR>.  This only works for B<BIO_ADDR> of the
Packit c4476c
protocol family AF_UNIX.  The returned string has been allocated
Packit c4476c
on the heap and must be freed with OPENSSL_free().
Packit c4476c
Packit c4476c
=head1 RAW ADDRESSES
Packit c4476c
Packit c4476c
Both BIO_ADDR_rawmake() and BIO_ADDR_rawaddress() take a pointer to a
Packit c4476c
network byte order address of a specific site.  Internally, those are
Packit c4476c
treated as a pointer to B<struct in_addr> (for B<AF_INET>), B
Packit c4476c
in6_addr> (for B<AF_INET6>) or B<char *> (for B<AF_UNIX>), all
Packit c4476c
depending on the protocol family the address is for.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
The string producing functions BIO_ADDR_hostname_string(),
Packit c4476c
BIO_ADDR_service_string() and BIO_ADDR_path_string() will
Packit c4476c
return B<NULL> on error and leave an error indication on the
Packit c4476c
OpenSSL error stack.
Packit c4476c
Packit c4476c
All other functions described here return 0 or B<NULL> when the
Packit c4476c
information they should return isn't available.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<BIO_connect(3)>, L<BIO_s_connect(3)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut