const char* vm_soc_inet_ntop( int af, const void* src, char* dst, unsigned int size );
const char* vm_soc_inet_ntop( int af, const void* src, char* dst, unsigned int size );
Converts an IPv4 or IPv6 address in its numeric binary form in network byte order into its standard text representation form. The format of 'x:x:x:x:x:x:d.d.d.d' is not supported.
|
Parameters |
Description |
|
int af |
[IN] Specifies the protocol family, 0 for IPv4 and 1 for IPv6. |
|
const void* src |
[IN] IP address in numeric binary form in network byte order For IPv4, it is a kal_uint8 array with size of at least 4 bytes. For IPv6, it is an ipv6_addr_t variable or compatible kal_uint8 array with size of at least 16 bytes. And src should obey 4-byte alignment. |
|
char* dst |
[OUT] IP address in standard text presentation form ends with '0'. The size of the dst buffer should be big enough to accommodate the whole IP address. Otherwise, conversion will fail. For IPv4, the safe size is 16 bytes. For IPv6, the safe size is 40 bytes. |
|
unsigned int size |
[IN] The size of dst buffer in bytes. |
The converted IP address in standard text representation, if the conversion is
successful. If the conversion failed, the NULL is returned.
// IPv4 VMUINT8 ipv4[] = {192, 168, 0, 1}; VMCHAR ipv4_addr[16] = {0}, *addr = NULL; addr = vm_soc_inet_ntop(0, ipv4, ipv4_addr, 16); if (addr) { // successfully } // IPv6 VMUINT8 ipv6[] = {0xff, 0xee, 0xdd, 0xcc, 0xaa, 99, 88, 77, 66, 55, 44, 33, 22, 11, 00, 00}; VMCHAR ipv6_addr[16] = {0}; const VMCHAR *addr = NULL; addr = vm_soc_inet_ntop(1, ipv6, ipv6_addr, 40); if (addr) { // successfully }
vmsock.h
Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at
support@toolsfactory.com.