137 lines
2.7 KiB
Groff
137 lines
2.7 KiB
Groff
.TH IPSEC_INITSUBNET 3 "12 March 2002"
|
|
.SH NAME
|
|
ipsec initsubnet \- initialize an ip_subnet
|
|
.br
|
|
ipsec addrtosubnet \- initialize a singleton ip_subnet
|
|
.br
|
|
ipsec subnettypeof \- get address type of an ip_subnet
|
|
.br
|
|
ipsec masktocount \- convert subnet mask to bit count
|
|
.br
|
|
ipsec networkof \- get base address of an ip_subnet
|
|
.br
|
|
ipsec maskof \- get subnet mask of an ip_subnet
|
|
.SH SYNOPSIS
|
|
.B "#include <freeswan.h>"
|
|
.sp
|
|
.B "const char *initsubnet(const ip_address *addr,"
|
|
.ti +1c
|
|
.B "int maskbits, int clash, ip_subnet *dst);"
|
|
.br
|
|
.B "const char *addrtosubnet(const ip_address *addr,"
|
|
.ti +1c
|
|
.B "ip_subnet *dst);"
|
|
.sp
|
|
.B "int subnettypeof(const ip_subnet *src);"
|
|
.br
|
|
.B "int masktocount(const ip_address *src);"
|
|
.br
|
|
.B "void networkof(const ip_subnet *src, ip_address *dst);"
|
|
.br
|
|
.B "void maskof(const ip_subnet *src, ip_address *dst);"
|
|
.SH DESCRIPTION
|
|
The
|
|
.B <freeswan.h>
|
|
library uses an internal type
|
|
.I 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.
|
|
.PP
|
|
.I Initsubnet
|
|
initializes a variable
|
|
.I *dst
|
|
of type
|
|
.I ip_subnet
|
|
from a base address and
|
|
a count of mask bits.
|
|
The
|
|
.I clash
|
|
parameter specifies what to do if the base address includes
|
|
.B 1
|
|
bits outside the prefix specified by the mask
|
|
(that is, in the ``host number'' part of the address):
|
|
.RS
|
|
.IP '0' 5
|
|
zero out host-number bits
|
|
.IP 'x'
|
|
non-zero host-number bits are an error
|
|
.RE
|
|
.PP
|
|
.I Initsubnet
|
|
returns
|
|
.B NULL
|
|
for success and
|
|
a pointer to a string-literal error message for failure;
|
|
see DIAGNOSTICS.
|
|
.PP
|
|
.I Addrtosubnet
|
|
initializes an
|
|
.I ip_subnet
|
|
variable
|
|
.I *dst
|
|
to a ``singleton subnet'' containing the single address
|
|
.IR *addr .
|
|
It returns
|
|
.B NULL
|
|
for success and
|
|
a pointer to a string-literal error message for failure.
|
|
.PP
|
|
.I Subnettypeof
|
|
returns the address type of a subnet,
|
|
normally
|
|
.B AF_INET
|
|
or
|
|
.BR AF_INET6 .
|
|
(The
|
|
.B <freeswan.h>
|
|
header file arranges to include the necessary headers for these
|
|
names to be known.)
|
|
.PP
|
|
.I Masktocount
|
|
converts a subnet mask, expressed as an address, to a bit count
|
|
suitable for use with
|
|
.IR initsubnet .
|
|
It returns
|
|
.B \-1
|
|
for error; see DIAGNOSTICS.
|
|
.PP
|
|
.I Networkof
|
|
fills in
|
|
.I *dst
|
|
with the base address of subnet
|
|
.IR src .
|
|
.PP
|
|
.I Maskof
|
|
fills in
|
|
.I *dst
|
|
with the subnet mask of subnet
|
|
.IR src ,
|
|
expressed as an address.
|
|
.SH SEE ALSO
|
|
inet(3), ipsec_ttosubnet(3), ipsec_rangetosubnet(3)
|
|
.SH DIAGNOSTICS
|
|
Fatal errors in
|
|
.I initsubnet
|
|
are:
|
|
unknown address family;
|
|
unknown
|
|
.I clash
|
|
value;
|
|
impossible mask bit count;
|
|
non-zero host-number bits and
|
|
.I clash
|
|
is
|
|
.BR 'x' .
|
|
Fatal errors in
|
|
.I addrtosubnet
|
|
are:
|
|
unknown address family.
|
|
Fatal errors in
|
|
.I masktocount
|
|
are:
|
|
unknown address family;
|
|
mask bits not contiguous.
|
|
.SH HISTORY
|
|
Written for the FreeS/WAN project by Henry Spencer.
|