ipsec_initsubnet (3) - Linux Manuals
ipsec_initsubnet: 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
NAMEipsec_initsubnet, ipsec_addrtosubnet, ipsec_subnettypeof, ipsec_masktocount, ipsec_networkof, ipsec_maskof - 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
const char *initsubnet(const ip_address *addr,
const char *addrtosubnet(const ip_address *addr,
DESCRIPTIONThe <libreswan.h> library uses an internal type ip_subnet to contain a description of an IP subnet (base address plus mask). These functions 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):
- zero out host-number bits
- 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 <libreswan.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.
DIAGNOSTICSFatal 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.
HISTORYWritten for the FreeS/WAN project by Henry Spencer.