inet_ntop

inet_ntop converts an IPv4 or IPv6 Internet network address into a string in Internet standard format. This is the ANSI version of the Windows function InetNtop.

Syntax

Copy
PCTSTR WSAAPI inet_ntop(
    INT  Family,
    PVOID pAddr,
    PSTR pStringBuf,
    size_t StringBufSize
);

Parameters

[in] Family

The address family: AF_INET or AF_INET6.

[in] pAddr

A pointer to the IP address in network byte order. It points to an IN_ADDR structure with IPv4 address when Family is AF_INET. It points to IN6_ADDR structure with IPv6 address when Family is AF_IN6.

[out] pStringBuf

A pointer to a buffer to store the null-terminated string representation of the IP address.

For IPv4, this buffer should be large enough to hold at least 16 characters.

For IPv6, this buffer should be large enough to hold at least 46 characters.

[in] StringBufSize

The length, in characters, of the buffer pointed to by the pStringBuf parameter.

For IPv4, this buffer should be large enough to hold at least 16 characters.

For IPv6, this buffer should be large enough to hold at least 46 characters.

Return Value

A valid pointer is returned if the function succeeds. It points to a buffer containing the string representation of IP address.

If the function fails, a null value is returned. A specific error code can be retrieved by calling WSAGetLastError.

Possible error codes returned by WSAGetLastError are:

Error Code Meaning

WSAEAFNOSUPPORT

The address family is not supported.

WSAEFAULT

An invalid parameter was passed to the function.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

WS2Tcpip.h, Winsock2.h RtTcpipApi.lib