inet_net_pton()

Updated: April 19, 2023

Convert an Internet network number from CIDR format to network format

Synopsis:

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int inet_net_pton( int af,
                   const char * src,
                   void * dst,
                   size_t size );

Arguments:

af
The address family. Currently, only AF_INET is supported.
src
A pointer to the presentation-format (CIDR) address. The format of the address is interpreted according to af.
dst
A pointer to the buffer where the function can store the converted address.
size
The size of the buffer pointed to by dst, in bytes.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The inet_net_pton() function converts an Internet network number from presentation format—a printable form as held in a character string, such as Internet standard dot notation or Classless Internet Domain Routing (CIDR)—to network format (usually a struct in_addr or some other internal binary representation, in network byte order).

For more information on Internet addresses, see inet_net_ntop().

Returns:

The number of bits that specify the network number (computed based on the class, or specified with /CIDR), or -1 if an error occurred (errno is set).

Errors:

ENOENT
Invalid argument af.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes