This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Convert an Internet network number to CIDR format
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> char * inet_net_ntop( int af, const void * src, int bits, char * dst, size_t size );
libsocket
Use the -l socket option to qcc to link against this library.
The inet_net_ntop() function converts an Internet network number from network format (usually a struct in_addr or some other binary form, in network byte order) to CIDR (Classless Internet Domain Routing) presentation format that's suitable for external display purposes.
With CIDR, a single IP address can be used to designate many unique IP addresses. A CIDR IP address looks like a normal IP address, except that it ends with a slash (/) followed by a number, called the IP prefix. For example:
172.200.0.0/16
The IP prefix specifies how many addresses are covered by the CIDR address, with lower numbers covering more addresses.
You can specify Internet addresses in the "dotted quad" notation, or Internet network numbers, using one of the following forms:
All numbers supplied as "parts" in a dot notation may be decimal, octal, or hexadecimal, as specified in the C language. That is, a number is interpreted as decimal unless it has a leading 0 (octal), or a leading 0x or 0X (hex).
A pointer to the destination string (dst), or NULL if a system error occurs (errno is set).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |