1INET_CIDR(3)             BSD Library Functions Manual             INET_CIDR(3)
2

NAME

4     inet_cidr_ntop, inet_cidr_pton — network translation routines
5

SYNOPSIS

7     #include <sys/types.h>
8     #include <sys/socket.h>
9     #include <netinet/in.h>
10     #include <arpa/inet.h>
11
12     inet_cidr_ntop(int af, const void *src, int bits, char *dst,
13         size_t size);
14
15     inet_cidr_pton(int af, const char *src, void *dst, int *bits);
16

DESCRIPTION

18     These routines are used for converting addresses to and from network and
19     presentation forms with CIDR (Classless Inter-Domain Routing) representa‐
20     tion, embedded net mask.
21
22                     130.155.16.1/20
23
24     inet_cidr_ntop() converts an address from network to presentation format.
25
26     af describes the type of address that is being passed in src.  Currently
27     only AF_INET is supported.
28
29     src is an address in network byte order, its length is determined from
30     af.
31
32     bits specifies the number of bits in the netmask unless it is -1 in which
33     case the CIDR representation is omitted.
34
35     dst is a caller supplied buffer of at least size bytes.
36
37     inet_cidr_ntop() returns dst on success or NULL.  Check errno for reason.
38
39     inet_cidr_pton() converts and address from presentation format, with
40     optional CIDR reperesentation, to network format.  The resulting address
41     is zero filled if there were insufficint bits in src.
42
43     af describes the type of address that is being passed in via src and
44     determines the size of dst.
45
46     src is an address in presentation format.
47
48     bits returns the number of bits in the netmask or -1 if a CIDR represen‐
49     tation was not supplied.
50
51     inet_cidr_pton() returns 0 on succces or -1 on error.  Check errno for
52     reason.  ENOENT indicates an invalid netmask.
53

SEE ALSO

55     intro(2)
56
574th Berkeley Distribution      October 19, 1998      4th Berkeley Distribution
Impressum