Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ipsec_rangetosubnet(3) [centos man page]

IPSEC_RANGETOSUBNET(3)						    8 Sept 2000 					    IPSEC_RANGETOSUBNET(3)

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. SEE ALSO
ipsec_initsubnet(3), ipsec_ttosubnet(3) 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 */ 8 Sept 2000 11/14/2008 IPSEC_RANGETOSUBNET(3)

Check Out this Related Man Page

IPSEC_INITSUBNET(3)					     Library Functions Manual					       IPSEC_INITSUBNET(3)

NAME
ipsec_initsubnet, ipsec_addrtosubnet, ipsec_subnettypeof, ipsec_masktocount, ipsec_networkof, ipsec_maskof - initialize an ip_subnet, ini- tialize 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 SYNOPSIS
#include <freeswan.h> const char *initsubnet(const ip_address *addr, int maskbits, int clash, ip_subnet *dst); const char *addrtosubnet(const ip_address *addr, ip_subnet *dst); int subnettypeof(const ip_subnet *src); int masktocount(const ip_address *src); void networkof(const ip_subnet *src, ip_address *dst); void maskof(const ip_subnet *src, ip_address *dst); DESCRIPTION
The <freeswan.h> library uses an internal type ip_subnet to contain a description of an IP subnet (base address plus mask). These func- tions provide basic tools for creating and examining this type. Initsubnet initializes a variable *dst of type ip_subnet from a base address and a count of mask bits. The clash parameter specifies what to do if the base address includes 1 bits outside the prefix specified by the mask (that is, in the ``host number'' part of the address): '0' zero out host-number bits 'x' non-zero host-number bits are an error Initsubnet returns NULL for success and a pointer to a string-literal error message for failure; see DIAGNOSTICS. Addrtosubnet initializes an ip_subnet variable *dst to a ``singleton subnet'' containing the single address *addr. It returns NULL for success and a pointer to a string-literal error message for failure. Subnettypeof returns the address type of a subnet, normally AF_INET or AF_INET6. (The <freeswan.h> header file arranges to include the necessary headers for these names to be known.) Masktocount converts a subnet mask, expressed as an address, to a bit count suitable for use with initsubnet. It returns -1 for error; see DIAGNOSTICS. Networkof fills in *dst with the base address of subnet src. Maskof fills in *dst with the subnet mask of subnet src, expressed as an address. SEE ALSO
inet(3), ipsec_ttosubnet(3), ipsec_rangetosubnet(3) DIAGNOSTICS
Fatal errors in initsubnet are: unknown address family; unknown clash value; impossible mask bit count; non-zero host-number bits and clash is 'x'. Fatal errors in addrtosubnet are: unknown address family. Fatal errors in masktocount are: unknown address family; mask bits not contiguous. HISTORY
Written for the FreeS/WAN project by Henry Spencer. 12 March 2002 IPSEC_INITSUBNET(3)
Man Page