[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

inet_pton Subroutine

Purpose

Converts between text and binary address formats.

Library

Library (libc.a)

Syntax

char *inet_net_ntop 
int af;
const char *src;
void *dst;

Description

This function converts an address in its standard text format into its numeric binary form. The argument af specifies the family of the address. Note, AF_INET and AF_INET6 address families are currently supported.

The argument src points to the string being passed in. The argument dst points to a buffer into which the function stores the numeric address. The address is returned in network byte order.

Return Values

If successful, 1 (one) is returned. If unseccessful, 0 (zero) is returned if the input is not a valid IPv4 dotted-decimal string or a valid IPv6 address string; or a -1 (negative one) with errno set to EAFNOSUPPORT if the af argument is unknown. The calling application must ensure that the buffer referred to by dst is large enough to hold the numeric address (4 bytes for AF_INET or 16 bytes for AF_INET6).

If the af argument is AF_INET, the function accepts a string in the standard IPv4 dotted-decimal form:

ddd.ddd.ddd.ddd

where ddd is a one to three digit decimal number between 0 and 255. Note that many implementations of the existing inet_addr and inet_aton functions accept nonstandard input: octal numbers, hexadecimal numbers, and fewer than four numbers. inet_pton does not accept these formats.

If the af argument is AF_INET6, then the function acdepts a string in one of the standard IPv6 text forms defined the addressing architecture specification.

.

Related Information

The inet_net_ntop subroutine, inet_net_pton subroutine, and inet_ntop subroutine.

Subroutines Overview in AIX Version 4 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]