1IPSEC_INITSUBNET(3) Library Functions Manual IPSEC_INITSUBNET(3)
2
3
4
6 ipsec initsubnet - initialize an ip_subnet
7 ipsec addrtosubnet - initialize a singleton ip_subnet
8 ipsec subnettypeof - get address type of an ip_subnet
9 ipsec masktocount - convert subnet mask to bit count
10 ipsec networkof - get base address of an ip_subnet
11 ipsec maskof - get subnet mask of an ip_subnet
12
14 #include <freeswan.h>
15
16 const char *initsubnet(const ip_address *addr,
17 int maskbits, int clash, ip_subnet *dst);
18 const char *addrtosubnet(const ip_address *addr,
19 ip_subnet *dst);
20
21 int subnettypeof(const ip_subnet *src);
22 int masktocount(const ip_address *src);
23 void networkof(const ip_subnet *src, ip_address *dst);
24 void maskof(const ip_subnet *src, ip_address *dst);
25
27 The <freeswan.h> library uses an internal type ip_subnet to contain a
28 description of an IP subnet (base address plus mask). These functions
29 provide basic tools for creating and examining this type.
30
31 Initsubnet initializes a variable *dst of type ip_subnet from a base
32 address and a count of mask bits. The clash parameter specifies what
33 to do if the base address includes 1 bits outside the prefix specified
34 by the mask (that is, in the ``host number'' part of the address):
35
36 '0' zero out host-number bits
37
38 'x' non-zero host-number bits are an error
39
40 Initsubnet returns NULL for success and a pointer to a string-literal
41 error message for failure; see DIAGNOSTICS.
42
43 Addrtosubnet initializes an ip_subnet variable *dst to a ``singleton
44 subnet'' containing the single address *addr. It returns NULL for suc‐
45 cess and a pointer to a string-literal error message for failure.
46
47 Subnettypeof returns the address type of a subnet, normally AF_INET or
48 AF_INET6. (The <freeswan.h> header file arranges to include the neces‐
49 sary headers for these names to be known.)
50
51 Masktocount converts a subnet mask, expressed as an address, to a bit
52 count suitable for use with initsubnet. It returns -1 for error; see
53 DIAGNOSTICS.
54
55 Networkof fills in *dst with the base address of subnet src.
56
57 Maskof fills in *dst with the subnet mask of subnet src, expressed as
58 an address.
59
61 inet(3), ipsec_ttosubnet(3), ipsec_rangetosubnet(3)
62
64 Fatal errors in initsubnet are: unknown address family; unknown clash
65 value; impossible mask bit count; non-zero host-number bits and clash
66 is 'x'. Fatal errors in addrtosubnet are: unknown address family.
67 Fatal errors in masktocount are: unknown address family; mask bits not
68 contiguous.
69
71 Written for the FreeS/WAN project by Henry Spencer.
72
73
74
75 12 March 2002 IPSEC_INITSUBNET(3)