OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / lib / goodmask.3
1 .TH IPSEC_GOODMASK 3 "11 June 2001"
2 .\" RCSID $Id: goodmask.3,v 1.5 2001/06/11 23:08:00 henry Exp $
3 .SH NAME
4 ipsec goodmask \- is this Internet subnet mask a valid one?
5 .br
6 ipsec masktobits \- convert Internet subnet mask to bit count
7 .br
8 ipsec bitstomask \- convert bit count to Internet subnet mask
9 .SH SYNOPSIS
10 .B "#include <freeswan.h>
11 .sp
12 .B "int goodmask(struct in_addr mask);"
13 .br
14 .B "int masktobits(struct in_addr mask);"
15 .br
16 .B "struct in_addr bitstomask(int n);"
17 .SH DESCRIPTION
18 These functions are obsolete;
19 see
20 .IR ipsec_masktocount (3)
21 for a partial replacement.
22 .PP
23 .I Goodmask
24 reports whether the subnet
25 .I mask
26 is a valid one,
27 i.e. consists of a (possibly empty) sequence of
28 .BR 1 s
29 followed by a (possibly empty) sequence of
30 .BR 0 s.
31 .I Masktobits
32 takes a (valid) subnet mask and returns the number of
33 .B 1
34 bits in it.
35 .I Bitstomask
36 reverses this,
37 returning the subnet mask corresponding to bit count
38 .IR n .
39 .PP
40 All masks are in network byte order.
41 .SH SEE ALSO
42 inet(3), ipsec_atosubnet(3)
43 .SH DIAGNOSTICS
44 .I Masktobits
45 returns
46 .B \-1
47 for an invalid mask.
48 .I Bitstomask
49 returns an all-zeros mask for a negative or out-of-range
50 .IR n .
51 .SH HISTORY
52 Written for the FreeS/WAN project by Henry Spencer.
53 .SH BUGS
54 The error-reporting convention of
55 .I bitstomask
56 is less than ideal;
57 zero is sometimes a legitimate mask.