3 .\" Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
5 .\" Permission to use, copy, modify, and/or distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 .\" PERFORMANCE OF THIS SOFTWARE.
17 .\" Id: inet_cidr.3,v 1.3 2009/01/22 23:49:23 tbox Exp
20 .Dt INET_CIDR @LIB_NETWORK_EXT_U@
25 .Nd network translation routines
27 .Fd #include <sys/types.h>
28 .Fd #include <sys/socket.h>
29 .Fd #include <netinet/in.h>
30 .Fd #include <arpa/inet.h>
31 .Fn inet_cidr_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size"
32 .Fn inet_cidr_pton "int af" "const char *src" "void *dst" "int *bits"
34 These routines are used for converting addresses to and from network and
35 presentation forms with CIDR (Classless Inter-Domain Routing) representation,
41 .\" ::ffff:130.155.16.1/116
44 converts an address from network to presentation format.
47 describes the type of address that is being passed in
49 .\"Currently defined types are AF_INET and AF_INET6.
50 Currently only AF_INET is supported.
53 is an address in network byte order, its length is determined from
57 specifies the number of bits in the netmask unless it is -1 in which case
58 the CIDR representation is omitted.
61 is a caller supplied buffer of at least
69 Check errno for reason.
72 converts and address from presentation format, with optional CIDR
73 reperesentation, to network format.
74 The resulting address is zero filled if there were insufficint bits in
78 describes the type of address that is being passed in via
80 and determines the size of
84 is an address in presentation format.
87 returns the number of bits in the netmask or -1 if a CIDR representation was
91 returns 0 on succces or -1 on error.
92 Check errno for reason.
93 ENOENT indicates an invalid netmask.