]> git.ipfire.org Git - thirdparty/strongswan.git/blame - linux/lib/libfreeswan/initsubnet.3
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / linux / lib / libfreeswan / initsubnet.3
CommitLineData
997358a6
MW
1.TH IPSEC_INITSUBNET 3 "12 March 2002"
2.\" RCSID $Id: initsubnet.3,v 1.1 2004/03/15 20:35:26 as Exp $
3.SH NAME
4ipsec initsubnet \- initialize an ip_subnet
5.br
6ipsec addrtosubnet \- initialize a singleton ip_subnet
7.br
8ipsec subnettypeof \- get address type of an ip_subnet
9.br
10ipsec masktocount \- convert subnet mask to bit count
11.br
12ipsec networkof \- get base address of an ip_subnet
13.br
14ipsec maskof \- get subnet mask of an ip_subnet
15.SH SYNOPSIS
16.B "#include <freeswan.h>"
17.sp
18.B "const char *initsubnet(const ip_address *addr,"
19.ti +1c
20.B "int maskbits, int clash, ip_subnet *dst);"
21.br
22.B "const char *addrtosubnet(const ip_address *addr,"
23.ti +1c
24.B "ip_subnet *dst);"
25.sp
26.B "int subnettypeof(const ip_subnet *src);"
27.br
28.B "int masktocount(const ip_address *src);"
29.br
30.B "void networkof(const ip_subnet *src, ip_address *dst);"
31.br
32.B "void maskof(const ip_subnet *src, ip_address *dst);"
33.SH DESCRIPTION
34The
35.B <freeswan.h>
36library uses an internal type
37.I ip_subnet
38to contain a description of an IP subnet
39(base address plus mask).
40These functions provide basic tools for creating and examining this type.
41.PP
42.I Initsubnet
43initializes a variable
44.I *dst
45of type
46.I ip_subnet
47from a base address and
48a count of mask bits.
49The
50.I clash
51parameter specifies what to do if the base address includes
52.B 1
53bits outside the prefix specified by the mask
54(that is, in the ``host number'' part of the address):
55.RS
56.IP '0' 5
57zero out host-number bits
58.IP 'x'
59non-zero host-number bits are an error
60.RE
61.PP
62.I Initsubnet
63returns
64.B NULL
65for success and
66a pointer to a string-literal error message for failure;
67see DIAGNOSTICS.
68.PP
69.I Addrtosubnet
70initializes an
71.I ip_subnet
72variable
73.I *dst
74to a ``singleton subnet'' containing the single address
75.IR *addr .
76It returns
77.B NULL
78for success and
79a pointer to a string-literal error message for failure.
80.PP
81.I Subnettypeof
82returns the address type of a subnet,
83normally
84.B AF_INET
85or
86.BR AF_INET6 .
87(The
88.B <freeswan.h>
89header file arranges to include the necessary headers for these
90names to be known.)
91.PP
92.I Masktocount
93converts a subnet mask, expressed as an address, to a bit count
94suitable for use with
95.IR initsubnet .
96It returns
97.B \-1
98for error; see DIAGNOSTICS.
99.PP
100.I Networkof
101fills in
102.I *dst
103with the base address of subnet
104.IR src .
105.PP
106.I Maskof
107fills in
108.I *dst
109with the subnet mask of subnet
110.IR src ,
111expressed as an address.
112.SH SEE ALSO
113inet(3), ipsec_ttosubnet(3), ipsec_rangetosubnet(3)
114.SH DIAGNOSTICS
115Fatal errors in
116.I initsubnet
117are:
118unknown address family;
119unknown
120.I clash
121value;
122impossible mask bit count;
123non-zero host-number bits and
124.I clash
125is
126.BR 'x' .
127Fatal errors in
128.I addrtosubnet
129are:
130unknown address family.
131Fatal errors in
132.I masktocount
133are:
134unknown address family;
135mask bits not contiguous.
136.SH HISTORY
137Written for the FreeS/WAN project by Henry Spencer.