ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzab6_5.4.0.1/uafinet6.htm

142 lines
9.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Use AF_INET6 address family" />
<meta name="abstract" content="AF_INET6 sockets provide support for Internet Protocol version 6 (IPv6) 128 bit (16 byte) address structures. Programmers can write applications using AF_INET6 address family to accept client requests for either IPv4 or IPv6 nodes or from IPv6 nodes only." />
<meta name="description" content="AF_INET6 sockets provide support for Internet Protocol version 6 (IPv6) 128 bit (16 byte) address structures. Programmers can write applications using AF_INET6 address family to accept client requests for either IPv4 or IPv6 nodes or from IPv6 nodes only." />
<meta name="DC.Relation" scheme="URI" content="uaddrfam.htm" />
<meta name="DC.Relation" scheme="URI" content="prerequisites.htm" />
<meta name="DC.Relation" scheme="URI" content="ip6scen.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzai2/rzai2compipv4ipv6.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/recvfr.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/accept.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/gpeern.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/sendto.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/connec.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/bind.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/ghostnm.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/getaddrinfo.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/ghosta.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/getnameinfo.htm" />
<meta name="DC.Relation" scheme="URI" content="ip6scen.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2001, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2001, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="uafinet6" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Use AF_INET6 address family</title>
</head>
<body id="uafinet6"><a name="uafinet6"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use AF_INET6 address family</h1>
<div><p>AF_INET6 sockets provide support for Internet Protocol version
6 (IPv6) 128 bit (16 byte) address structures. Programmers can write applications
using AF_INET6 address family to accept client requests for either IPv4 or
IPv6 nodes or from IPv6 nodes only.</p>
<div class="section"><p>Like AF_INET sockets, AF_INET6 sockets can be
either connection-oriented (type SOCK_STREAM) or they can be connectionless
(type SOCK_DGRAM). Connection-oriented AF_INET6 sockets use TCP as the transport
protocol. Connectionless AF_INET6 sockets use User Datagram Protocol (UDP)
as the transport protocol. When you create an AF_INET6 domain socket, you
specify AF_INET6 for the address family in the socket program. AF_INET6 sockets
can also use a type of SOCK_RAW. If this type is set, the application connects
directly to the IP layer and does not use either the TCP or UDP transport.</p>
</div>
<div class="section"><h4 class="sectiontitle">IPv6 applications compatibility with IPv4 applications</h4><p>Socket
applications written with AF_INET6 address family allow Internet Protocol
version 6 (IPv6) applications to work with Internet Protocol version 4 (IPv4)
applications (those applications that use AF_INET address family). This feature
allows socket programmers to use an IPv4-mapped IPv6 address format. This
address format represents the IPv4 address of an IPv4 node to be represented
as an IPv6 address. The IPv4 address is encoded into the low-order 32 bits
of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF.
For example, an IPv4- mapped address can look like this: </p>
<pre> ::FFFF:192.1.1.1</pre>
</div>
<div class="section"><p>These addresses can be generated automatically by the <span class="apiname">getaddrinfo()</span> function,
when the specified host has only IPv4 addresses. </p>
</div>
<div class="section"><p>You can create applications that use AF_INET6 sockets to open
TCP connections to IPv4 nodes. To accomplish this task, you can encode the
destination's IPv4 address as an IPv4mapped IPv6 address and pass that address
within a sockaddr_in6 structure in the <span class="apiname">connect()</span> or <span class="apiname">sendto()</span> call.
When applications use AF_INET6 sockets to accept TCP connections from IPv4
nodes, or receive UDP packets from IPv4 nodes, the system returns the peer's
address to the application in the <span class="apiname">accept()</span>, <span class="apiname">recvfrom()</span>,
or <span class="apiname">getpeername()</span> calls using a sockaddr_in6 structure encoded
this way. </p>
</div>
<div class="section"><p>While the <span class="apiname">bind()</span> function allows applications
to select the source IP address of UDP packets and TCP connections, applications
often want the system to select the source address for them. Applications
use in6addr_any similarly to the way they use the INADDR_ANY macro in IPv4
for this purpose. An additional feature of binding in this way is that it
allows an AF_INET6 socket to communicate with both IPv4 and IPv6 nodes. For
example, an application issuing an <span class="apiname">accept()</span> on a listening
socket bound to in6addr_any accepts connections from either IPv4 or IPv6 nodes.
This behavior can be modified through the use of the IPPROTO_IPV6 level socket
option IPV6_V6ONLY. Few applications need to know which type of node with
which they are interoperating. However, for those applications that do need
to know, the IN6_IS_ADDR_V4MAPPED() macro defined in &lt;netinet/in.h&gt;
is provided.</p>
</div>
<div class="section"><h4 class="sectiontitle">IPv6 restrictions</h4><div class="p">Currently, i5/OS™ support
of IPv6 is limited in some functions. The following table lists
these restrictions and their implications to socket programmers.
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 1. IPv6 restrictions and implications</caption><thead align="left"><tr><th valign="top" id="d0e77">Restriction</th>
<th valign="top" id="d0e79">Implication</th>
</tr>
</thead>
<tbody><tr><td valign="top" headers="d0e77 ">iSeries™ host table does not support IPv6 addresses.</td>
<td valign="top" headers="d0e79 ">The <span class="apiname">getaddrinfo()</span> and <span class="apiname">getnameinfo()</span> APIs
are not able to locate IPv6 addresses in the host table. These APIs find addresses
in the Domain Name System (DNS) only.</td>
</tr>
<tr><td valign="top" headers="d0e77 ">The <span class="apiname">gethostbyname()</span> and <span class="apiname">gethostbyaddr()</span> APIs
only support IPv4 address resolution.</td>
<td valign="top" headers="d0e79 ">Use <span class="apiname">getaddrinfo()</span> and <span class="apiname">getnameinfo()</span> APIs
if IPv6 address resolution is required.</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="uaddrfam.htm" title="This topic includes sample programs that illustrate each of the socket address families.">Design applications with address families</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="prerequisites.htm" title="Before writing socket applications, you must first complete these steps.">Prerequisites for socket programming</a></div>
<div><a href="ip6scen.htm" title="This topic describes a typical situation in which you might want to use the AF_INET6 address family.">Socket scenario: Create an application to accept IPv4 and IPv6 clients</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../rzai2/rzai2compipv4ipv6.htm">Compare IPv4 to IPv6</a></div>
<div><a href="../apis/recvfr.htm">recvfrom()</a></div>
<div><a href="../apis/accept.htm">accept()</a></div>
<div><a href="../apis/gpeern.htm">getpeername()</a></div>
<div><a href="../apis/sendto.htm">sendto()</a></div>
<div><a href="../apis/connec.htm">connect()</a></div>
<div><a href="../apis/bind.htm">bind()</a></div>
<div><a href="../apis/ghostnm.htm">gethostbyname()</a></div>
<div><a href="../apis/getaddrinfo.htm">getaddrinfo()</a></div>
<div><a href="../apis/ghosta.htm">gethostbyaddr()</a></div>
<div><a href="../apis/getnameinfo.htm">getnameinfo()</a></div>
</div>
</div>
</body>
</html>