1 .\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (c) 1998,1999 by Internet Software Consortium
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 .\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\" Id: inet_cidr.man3,v 1.2 2009/01/21 00:12:34 each Exp
24 .Nd network translation routines
26 .Fd #include <sys/types.h>
27 .Fd #include <sys/socket.h>
28 .Fd #include <netinet/in.h>
29 .Fd #include <arpa/inet.h>
30 .Fn inet_cidr_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size"
31 .Fn inet_cidr_pton "int af" "const char *src" "void *dst" "int *bits"
33 These routines are used for converting addresses to and from network and
34 presentation forms with CIDR (Classless Inter-Domain Routing) representation,
40 .\" ::ffff:130.155.16.1/116
43 converts an address from network to presentation format.
46 describes the type of address that is being passed in
48 .\"Currently defined types are AF_INET and AF_INET6.
49 Currently only AF_INET is supported.
52 is an address in network byte order, its length is determined from
56 specifies the number of bits in the netmask unless it is -1 in which case
57 the CIDR representation is omitted.
60 is a caller supplied buffer of at least
68 Check errno for reason.
71 converts and address from presentation format, with optional CIDR
72 reperesentation, to network format.
73 The resulting address is zero filled if there were insufficint bits in
77 describes the type of address that is being passed in via
79 and determines the size of
83 is an address in presentation format.
86 returns the number of bits in the netmask or -1 if a CIDR representation was
90 returns 0 on succces or -1 on error.
91 Check errno for reason.
92 ENOENT indicates an invalid netmask.