ipsec_rangetosubnet (3) - Linux Manuals
ipsec_rangetosubnet: convert address range to subnet
Command to display ipsec_rangetosubnet
manual in Linux: $ man 3 ipsec_rangetosubnet
NAME
ipsec_rangetosubnet - convert address range to subnet
SYNOPSIS
#include <freeswan.h>
-
const char *rangetosubnet(const ip_address * start, const ip_address * stop, ip_subnet * dst);
DESCRIPTION
Rangetosubnet
accepts two IP addresses which define an address range, from
start
to
stop
inclusive, and converts this to a subnet if possible. The addresses must both be IPv4 or both be IPv6, and the address family of the resulting subnet is the same.
Rangetosubnet
returns NULL for success and a pointer to a string-literal error message for failure; see DIAGNOSTICS.
DIAGNOSTICS
Fatal errors in
rangetosubnet
are: mixed address families; unknown address family;
start
and
stop
do not define a subnet.
HISTORY
Written for the FreeS/WAN project by Henry Spencer.
BUGS
The restriction of error reports to literal strings (so that callers don't need to worry about freeing them or copying them) does limit the precision of error reporting.
The error-reporting convention lends itself to slightly obscure code, because many readers will not think of NULL as signifying success. A good way to make it clearer is to write something like:
-
const char *error;
error = rangetosubnet( /* ... */ );
if (error != NULL) {
/* something went wrong */
Pages related to ipsec_rangetosubnet
- ipsec_anyaddr (3) - get and test for addresses of type "any", "unspecified" and loopback
- ipsec_atoaddr (3) - convert Internet addresses and Subnet masks to and from ASCII
- ipsec_atoasr (3) - convert ASCII to Internet address, subnet, or range, convert Internet address range to ASCII
- ipsec_atoul (3) - convert unsigned-long numbers to and from ASCII
- ipsec_goodmask (3) - check if Internet subnet mask is valid, convert Internet subnet mask to bit count, convert bit count to Internet subnet mask
- ipsec_initaddr (3) - initialize an ip_address, get address type of an ip_address, get length of address within an ip_address, get copy of address within an ip_address, get pointer to address within an ip_address
- ipsec_initsubnet (3) - initialize an ip_subnet, initialize a singleton ip_subnet, get address type of an ip_subnet, convert subnet mask to bit count, get base address of an ip_subnet, get subnet mask of an ip_subnet
- ipsec_portof (3) - get port field of an ip_address, set port field of an ip_address, get pointer to internal sockaddr of an ip_address, get length of internal sockaddr of an ip_address
- ipsec_sameaddr (3) - do comparisons for addresses, subnets, SA IDs and address families
- ipsec_subnetof (3) - given Internet address and subnet mask return subnet number, host part, broadcast address