1IPSEC_GOODMASK(3) Library Functions Manual IPSEC_GOODMASK(3)
2
3
4
6 ipsec goodmask - is this Internet subnet mask a valid one?
7 ipsec masktobits - convert Internet subnet mask to bit count
8 ipsec bitstomask - convert bit count to Internet subnet mask
9
11 #include <freeswan.h>
12
13 int goodmask(struct in_addr mask);
14 int masktobits(struct in_addr mask);
15 struct in_addr bitstomask(int n);
16
18 These functions are obsolete; see ipsec_masktocount(3) for a partial
19 replacement.
20
21 Goodmask reports whether the subnet mask is a valid one, i.e. consists
22 of a (possibly empty) sequence of 1s followed by a (possibly empty)
23 sequence of 0s. Masktobits takes a (valid) subnet mask and returns the
24 number of 1 bits in it. Bitstomask reverses this, returning the subnet
25 mask corresponding to bit count n.
26
27 All masks are in network byte order.
28
30 inet(3), ipsec_atosubnet(3)
31
33 Masktobits returns -1 for an invalid mask. Bitstomask returns an all-
34 zeros mask for a negative or out-of-range n.
35
37 Written for the FreeS/WAN project by Henry Spencer.
38
40 The error-reporting convention of bitstomask is less than ideal; zero
41 is sometimes a legitimate mask.
42
43
44
45 11 June 2001 IPSEC_GOODMASK(3)