inet_cidr_ntop(3RESOLV) Resolver Library Functions inet_cidr_ntop(3RESOLV)NAME
inet_cidr_ntop, inet_cidr_pton - network translation routines
SYNOPSIS
cc [ flag... ] file... -lresolv -lsocket -lnsl [ library...]
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
char *inet_cidr_ntop(int af, const void *src, int bits, char *dst,
size_t size);
int inet_cidr_pton(int af, const char *src, void *dst, int *bits);
DESCRIPTION
These routines are used for converting addresses to and from network
and presentation forms with CIDR (Classless Inter-Domain Routing) rep‐
resentation, embedded net mask.
The inet_cidr_ntop() function converts an address from network to pre‐
sentation format.
The af parameter describes the type of address that is being passed in
src. Currently only AF_INET is supported.
The src parameter is an address in network byte order, its length is
determined from af.
The bits parameter specifies the number of bits in the netmask unless
it is -1 in which case the CIDR representation is omitted.
The dst parameter is a caller supplied buffer of at least size bytes.
The inet_cidr_ntop() function returns dst on success or NULL. Check
errno for reason.
The inet_cidr_pton() function converts and address from presentation
format, with optional CIDR representation, to network format. The
resulting address is zero filled if there were insufficient bits in
src.
The af parameter describes the type of address that is being passed in
via src and determines the size of dst.
The src parameter is an address in presentation format.
The bits parameter returns the number of bits in the netmask or -1 if
a CIDR representation was not supplied.
The inet_cidr_pton() function returns 0 on success or -1 on error.
Check errno for reason. ENOENT indicates an invalid netmask.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Interface Stability │Committed │
├─────────────────────────────┼─────────────────────────────┤
│MT-Level │MT-Safe │
└─────────────────────────────┴─────────────────────────────┘
SEE ALSOIntro(2), attributes(5)SunOS 5.11 11 Nov 2009 inet_cidr_ntop(3RESOLV)