HP HP-UX IPv6 User's Guide

HP-UX IPv6 Porting Guide
HP-UX 11i v3
Manufacturing Part Number : B2355-91069
E0207
United States
© Copyright 2007 Hewlett-Packard Company L.P. All rights reserved.
Legal Notices
Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.
The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.
Warranty
A copy of the specific warranty terms applicable to your Hewlett- Packard product and replacement parts can be obtained from your local Sales and Service Office.
U.S. Government License
Proprietary computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.
Copyright Notice
Copyright © 2007 Hewlett-Packard Development Company L.P. All rights reserved. Reproduction, adaptation, or translation of this document without prior written permission is prohibited, except as allowed under the copyright laws.
Trademark Notices
®
UNIX
Intel
Microsoft, Windows, and Windows NT are U.S. registered trademarks of Microsoft Corporation.
Printed in the US.
ii
is a registered trademark of The Open Group.
®
and Itanium® are registered trademarks of Intel Corporation.

About This Document

This document is intended to help HP-UX BSD Sockets Application Programmers port IPv4 network applications to IPv6.
The document printing date and part number indicate the document’s current edition. The printing date will change when a new edition is printed. Minor changes may be made at reprint without changing the printing date. The document part number will change when extensive changes are made.
Document updates may be issued between editions to correct errors or document product changes. To ensure that you receive the updated or new editions, you should subscribe to the appropriate product support service. See your HP sales representative for details.
The latest version of this document can be found on line at: docs.hp.com/hpux/netcom/index.html#IPv6.
Intended Audience
This document is intended for HP-UX BSD Sockets Application Programmers porting IPv4 network applications to IPv6.
This document is not a tutorial.
iii
What’s In This Docuent
The guide is organized as follows:
1Introduction
2 IPv6 Addressing
3 Data Structure Changes
4 Migrating Applications from IPv4 to IPv6
5 Overview of IPv6 and IPv4 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
Appendix A IPv4 to IPv6 Quick-Reference Guide
HP-UX Release Names and Release Identifiers
Each HP-UX 11i release has an associated release name and release identifier. The uname (1) command with the -r option returns the release identifier. This table shows the releases available for HP-UX 11i.
Table 1 HP-UX 11i Releases
Release
Identifier
B.11.31 HP-UX 11i v3 Intel
B.11.23 HP-UX 11i v2 Intel® Itanium
iv
Release Name
Supported Processor
Architecture
®
Itanium
®
®
Table 1 HP-UX 11i Releases (Continued)
Release
Identifier
B.11.22 HP-UX 11i v1.6 Intel® Itanium
B.11.20 HP-UX 11i v1.5 Intel® Itanium
B.11.11 HP-UX 11i v1 PA-RISC
Release Name
Supported Processor
Architecture
®
®
Related Documents
HP Documentation
Additional information about HP-UX IPv6 transport can be found within docs.hp.com in the networking and communications collection under IPv6 at:
http://www.docs.hp.com/hpux/netcom/index.html#IPv6
Other documents in this collection (besides this guide) include:
HP-UX IPv6 Transport Administrator’s Guide (TOUR 1.0)
HP-UX IPv6 Transport Administrator’s Guide (HP-UX 11i v2)
Other Documentation
For more information, refer to RFC 2533 “Basic Socket Interface Extensions for IPv6”. The IETF (Internet Engineering Task Force) RFCs can be located at: http://www.ietf.org/rfc.html.
v
HP Welcomes Your Comments
HP welcomes your comments concerning this document. HP is committed to providing documentation that meets your needs.
Please send comments to: netinfo_feedback@cup.hp.com
Please include document title, manufacturing part number, and any comment, error found, or suggestion for improvement you have concerning this document. Also, please tell us what you like, so we can incorporate it into other documents.
vi

1 Introduction

This chapter provides a brief introduction, including comments about existing IPv4 applications, transitioning to IPv6, and some general terminology.
Chapter 1 1
Introduction

Why IPv6 Now?

Why IPv6 Now?
In the last five years, the Internet has transformed the way people live. The Internet’s tremendous growth rate greatly exceeded any futurist’s predictions, including the Internet Protocol (IP) architect’s plans from twenty years ago. IP version 4 (IPv4) provided ample addresses for network growth throughout the 1980s, but the address-supply is now low outside the United States. If current Internet growth rates continue, the prediction is that the supply of unassigned IPv4 addresses will be depleted within ten years. Internet Protocol Version 6 (IPv6) overcomes many limitations of IPv4.
For additional information on using HP-UX IPv6 transport, refer to the following documentation as needed:
HP-UX IPv6 Transport Administrator’s Guide (HP-UX 11i v3)

Who Should Read This Guide

HP-UX BSD Sockets Application Programmers porting IPv4 network applications to IPv6.

Do Existing IPv4 Applications Require Changes?

No. Current IPv4 applications can remain unchanged. Modify applications only to take advantage of new IPv6 features.
Chapter 12
Introduction

Does implementing IPv6 require a complete transition from IPv4?

Does implementing IPv6 require a complete transition from IPv4?
No. Networks can migrate to IPv6 gradually, using transition mechanisms defined by IPv6 Protocol Specifications. IPv4 and IPv6 will coexist for a long time. IPv6 Protocol Specifications provide two major transition mechanisms:
Dual Stack: Dual-stack hosts have both IPv4 and IPv6 interfaces configured and can communicate with both IPv4 and IPv6 hosts.
Tunneling: Tunneling is a mechanism that has been defined to allow IPv6 packets to be encapsulated in IPv4 packets. A Dual-Stack host can send IPv6 packets through an IPv4
tunnel to a remote IPv6 host, without requiring an IPv6 infrastructure.
Chapter 1 3
Introduction

Terminology

Terminology
This section provides brief definitions of some common general IP and IPv6 terms.

General IP Terminology

Node: A device that implements IP (either IPv4 or IPv6 or both).
Router: A node that forwards IP packets not explicitly addressed to itself.
Host: Any node that is not a router.
Link: A logical connection between two nodes. Here, a link is the layer below IP such as Ethernet, PPP, or ATM networks. A link also includes IPv6 traffic encapsulated within IPv4 packets, also known as tunneling.
Name Service: A database that maps host names to IP addresses. Common Name Services are Domain Name System (DNS) or the /etc/hosts file.
Site: An organization’s Intranet, perhaps geographically disbursed.

IPv6 Terminology

IPv4 Address: A 32-bit IPv4 address
IPv6 Address: An 128-bit IPv6 address
IPv4-only node: A node that implements only IPv4. An IPv4-only node does not understand IPv6.
IPv6-only node: A node configured for IPv6 only. An IPv6-only node does not understand IPv4.
IPv4/IPv6 node: A node that implements both IPv4 and IPv6.
IPv6 node: A node that implements IPv6. IPv4/IPv6 and IPv6-only nodes are both IPv6 nodes.
IPv4 node: A host that implements IPv4. IPv4/IPv6 and IPv4-only nodes are both IPv4 nodes.
Chapter 14

2 IPv6 Addressing

This chapter describes basic IPv6 addressing information.
Chapter 2 5
IPv6 Addressing

Types of IPv6 addresses

Types of IPv6 addresses
IPv6 supports both single-destination (unicast) and multiple-destination (multicast) addresses. Addresses comprise three different scopes.

IPv6 Address scope

Link-local: An IPv6 address used over one local link; assigned during autoconfiguration.
Global: An IPv6 address used throughout the Internet.
An IPv6 node always has a link-local address. It may have one or more global addresses.

IPv4 to IPv6 Transition Addresses

To ease the transition from IPv4 to IPv6, the IPv6 Protocol Specifications define two global IPv6 addresses containing unique IPv4 address in the low-order 32-bits of the IPv6 address.

IPv4-Mapped Address

An IPv4-mapped IPv6 address enables an IPv6 application on an IPv4/IPv6 host to communicate with an IPv4-only node. IPv4-mapped IPv6 addresses are created internally by the Name Service resolver when an IPv6 application requests the host name for a node with an IPv4 address only.
The IPv6 module encodes the IPv4 address in the low-order 32 bits of the IPv6 address.
Figure 2-1 IPv4-Mapped Address
Chapter 26
IPv6 Addressing

Comparing IPv4 and IPv6 Addresses

Comparing IPv4 and IPv6 Addresses
IPv4 addresses are 32-bit addresses represented as four dotted-decimal octets
Example: 10.1.3.7
IPv6 Addresses are 128-bit records represented as eight fields of up to four hexadecimal digits. A colon separates each field (:).
Example: 8888:7777:6666:5555:4444:3333:2222:1111

Leading Zeros Suppressed

Example: 0008:0007:0006:0005:0004:0003:0002:0001
Is also valid in the format:
8:7:6:5:4:3:2:1

Contiguous Fields Containing only the Digits Zero can be collapsed

Example: 0008:0000:0000:0000:0000:0003:0002:0001
Is also valid in the format:
8::3:2:1
NOTE Only one set of contiguous fields of zeros per IP address can be collapsed.

IPv4-Mapped IPv6 Addresses can display IPv4 Addresses in Dotted-Decimal Format

IPv4-mapped addresses contain the IPv4 address in the low-order 32-bits. Mixing hexadecimal format and dotted-decimal format is valid. For example, the IPv4 mapped IPv6 address ::ffff:10.9.8.7 is valid in the following formats:
Table 2-1
0::ffff:0a09:0807 IPv4 mapped IPv6 address
::ffff:0a09:0807 First zero removed
Chapter 2 7
IPv6 Addressing
Comparing IPv4 and IPv6 Addresses
Table 2-1 (Continued)
::ffff:10.9.8.7 Combined hex and decimal format
IPv6 addresses are classless, using Classless Internet Domain Registry CIDR format. The prefix follows the IPv6 address (<IPv6 addr>”/”<prefix>) and denotes the size of a subnet.
Example: 8:7:6:5:4:3:2:1/16
Chapter 28

IPv6 Address Types

Unicast Address

Figure 2-2 Unicast Address
Unicast addresses usually comprise a 64-bit prefix and a 64-bit interface ID.
Figure 2-3 Unicast Prefix
IPv6 Addressing
IPv6 Address Types
The 64-bit interface ID must be unique on the link. An interface ID often includes the interface Link-Layer Address.

IPv6 Loopback Address

The loopback interface uses the IPv6 loopback address for self-testing, by sending IP datagrams to itself. The IPv6 loopback address is: 0:0:0:0:0:0:0:1 (or more simply, ::1).
Chapter 2 9
IPv6 Addressing
IPv6 Address Types

Link-local Unicast Address

The LAN segment is the scope of a Link-local Address, and is used for address autoconfiguration and neighbor discovery.
Figure 2-4 Link-Local Unicast Address

IPv6 Multicast Addresses

IPv6 multicast addresses resemble IPv4 multicast addresses, but have an explicit field for address-scope.
Chapter 210
Figure 2-5 Multicast Address Format
IPv6 Addressing
IPv6 Address Types

Some Well-know Multicast Addresses

FF02::1 All nodes (link-local)
FF02::2 All routers (link-local)
FF02::9 All Routing Information Protocol next generation (RIPng) routers (link-local)

IPv6 Wildcard Addresses

In IPv4, an application can let the system choose which source IP address to bind to a socket by specifying a wildcard address: the symbolic constant INADDR_ANY in the bind() function call. In IPv6, because the IPv6 address type is a structure (struct in6_addr), a symbolic constant can initialize an IPv6 address structure variable, but cannot assign an IPv6 structure variable. Therefore, an IPv6 wildcard address requires two forms:
For initialization, use the symbolic constant IN6ADDR_ANY_INIT of the type struct
in6_addr. For example, struct in6_addr anyaddr = IN6ADDR_ANY_INIT;
Chapter 2 11
IPv6 Addressing
IPv6 Address Types
NOTE Only use the constant during initialization.
For assignment, use the global variable named in6addr_any, of the type in6_addr structure. For example:
Header file
<netinet/in.h> <netinet/in6.h>
extern const struct in6_addr in6addr_any;
struct sockaddr_in6 sin6; … sin6.sin6_addr = in6addr_any; /* structure assignment */ … if (bind(s, (struct sockaddr *) &sin6, sizeof(sin6)) == -1)

IPv6 Loopback Addresses

The IPv4 loopback address is an integer type INADDR_LOOPBACK. The IPv6 loopback address is an in6_addr structure defined in <netinet/in.h>. For example:
Header file
<netinet/in.h> <netinet/in6.h>
sin6.sin6_addr = in6addr_loopback; /* structure assignment */
The symbolic constant named IN6ADDR_LOOPBACK_INIT is defined in <netinet/in.h>. Use it only when declaring a sockaddr_in6 struct. For example:
struct in6_addr loopbackaddr = IN6ADDR_LOOPBACK_INIT
NOTE IPv4 defines INADDR_* constants in IPv4 host byte order. However, IPv6
defines IN6ADDR_* and in6addr* constants in network byte order.
Chapter 212

3 Data Structure Changes

Chapter 3 13
Data Structure Changes

IP Address Structure

IP Address Structure

Header file

<netinet/in.h>

IPv4 Structure

struct in_addr { unsigned int s_addr ; /* 32-bit IPv4*/ };

IPv6 Structure

struct in6_addr { uint8_t s6_addr[16]; } /* array of 16 8-bit elements = one 128-bit IPv6 address */
Chapter 314
Data Structure Changes

Socket Address structure for 4.3BSD-based HP-UX

Socket Address structure for 4.3BSD-based HP-UX

Header file

<netinet/in.h>

IPv4 Structure

struct sockaddr_in { short sin_family; /*AF_INET */ u_short sin_port; /* transport layer port number */ struct in_addr sin_addr; /* IPv4 */ char sin_zero[8]; /* Unused */ };

IPv6 Structure

struct sockaddr_in6 {
sa_family_t sin6_family; /*AF_INET6 */ in_port_t sin6_port; /* transport layer port number.* / uint32_t sin6_flowinfo; /* traffic class */ struct in6_addr sin6_addr; /* IPv6*/ uint32_t sin6_scope_id;/* Address scope */
}:
Chapter 3 15
Data Structure Changes

Generic Socket Address Structure

Generic Socket Address Structure

Header file

<netinet/in.h>
struct sockaddr_storage
The sockaddr_storage data structure simplifies writing portable code across multiple address families and platforms. This data structure provides the following flexibility and consistency.
One simple addition to the sockets API that can help application writers is the struct sockaddr_storage structure. The structure is large enough to accommodate all supported protocol-specific address structures.
sockaddr_storage aligns at an appropriate boundary so that pointers to it - can be cast as pointers to protocol specific address structures and used to access the fields of those
structures without alignment problems.
Chapter 316
4 Migrating Applications from IPv4 to
IPv6
HP-UX supports two standard IPv4/IPv6 interoperability methods:
Chapter 4 17
Loading...
+ 53 hidden pages