HP-UX IPv6 Porting Guide (September 2004)
Table Of Contents
- About This Document
- 1 Introduction
- 2 IPv6 Addressing
- 3 Data Structure Changes
- 4 Migrating Applications from IPv4 to IPv6
- 5 Overview of IPv4 and IPv6 Call Set-up
- 6 Function Calls Converting Names to Addresses
- 7 Function Calls Converting IP addresses to Names
- 8 Reading Error Messages
- 9 Freeing Memory
- 10 Converting Binary and Text Addresses
- 11 Testing for Scope and Type of IPv6 addresses using Macros
- 12 Identifying Local Interface Names and Indexes
- 13 Configuring or Querying an Interface using IPv6 ioctl() Function Calls
- 14 Verifying IPv6 Installation
- 15 Sample Client/Server Programs
- A IPv4 to IPv6 Quick Reference Guide

Function Calls Converting Names to Addresses
getaddrinfo(3N)
Chapter 6 33
getaddrinfo(3N)
getaddrinfo() is a nodename-to-address and servicename-to-port-number function call. The
protocol-independent function call complies with POSIX 1003.1g Draft 6.6 (1997). For more
information refer to the getaddrinfo(3N) man page.
Syntax
getaddrinfo(const char *nodename, const char *servname, const struct
addrinfo *hints, struct addrinfo **res);
Parameters
*nodename
: A pointer to a node name or numeric string, such as an IPv4 dotted-decimal
address or an IPv6 hexadecimal address.
nodename
can also point to a NULL string.
servname
: A pointer to a service name (such as ftp) or port number (such as 21).
*servname
can also point to a NULL string. Either
*nodename
or
*servname
must point to a name or
numeric string.
*hints
: A pointer to an addrinfo structure containing filters for socket-type, address family,
or protocol-type.
hints
can also point to a NULL string. addrinfo and
hints
are described
below.
**res
: A pointer to a linked list of addrinfo structures each containing a socket address and
information regarding the socket.
addrinfo Data Structure pointed-to by hints
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST,
* See RFC 2533 for more details*/
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for nodename */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};