HPlogo HP-UX IPv6 Porting Guide: HP-UX 11i v2 September 2004 > Chapter 7  Function Calls Converting IP addresses to Names

getipnodebyaddr(3N)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

The IPv6 getipnodebyaddr() function call improves upon the IPv4 gethostbyaddr() by adding an error number parameter.

NOTE: Starting with the HP-UX 11i v2 release, the getipnodebyaddr() function is entering OBSOLESCENCE, and will be OBSOLETED in a future HP-UX release. Therefore, it is recommended the getaddrinfo() function be used instead.

Header Files

#include <sys/socket.h>#include <netdb.h>

Syntax

name_ptr =getipnodebyaddr(const void *src, size_t len,int af, int *error_num);

Parameters

*src: A pointer to the structure containing the IP address searched.

len: The length of the IP address: four octets for AF_INET or sixteen octets for AF_INET6.

af: Address family AF_INET or AF_INET6.

*error_num: *error_num is a pointer to the integer containing an error code, if any.

name_ptr: A pointer to the struct hostent returned by the function, containing the host name.

Data Structures

struct hostent {
char *h_name; /* Canonical name of host name such as grace.hp.com*/
char **h_alias; /* Pointer to an array of pointers to alias names */
int h_addrtype; /* AF_INET (for IPv4 addresses)AF_INET6 (for IPv6)*/
int h_length; /* 4 octets (IPv6) or 16 octets (IPv6) */
char **h_addr_list[0]; /* Pointer to an array of pointers to IPv4 */
} /* addresses or IPv6 addresses */

How getipnodebyaddr() processes IPv4-compatible IPv6 addresses

If af is AF_INET6, len equals 16, and the IPv6 address is an IPv4-mapped or an IPv4-compatible IPv6 address, then:

  1. skip the first 12 bytes of the IPv6 address.

  2. set af to AF_INET.

  3. set len to 4.

If af is AF_INET, lookup the name for the given IPv4 address; that is, query for a PTR record in the in-addr.arpa domain.

If af is AF_INET6, lookup the name for the given IPv6 address; that is, query for a PTR record in the ip6.int domain.

A successful function call copies *src and af into the returned hostent name_ptr structure. An unsuccessful function returns a nonzero error_num.

© 2004 Hewlett-Packard Development Company, L.P.