summaryrefslogtreecommitdiff
path: root/static/netbsd/man4/inet6.4 3.html
blob: 722c4155a10ca4fcad5147040230748a51289c91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<table class="head">
  <tr>
    <td class="head-ltitle">INET6(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">INET6(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">inet6</code> &#x2014; <span class="Nd">Internet
    protocol version 6 family</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/types.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">netinet/in.h</a>&gt;</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The <code class="Nm">inet6</code> family is an updated version of
    <a class="Xr">inet(4)</a> family. While <a class="Xr">inet(4)</a> implements
    Internet Protocol version 4, <code class="Nm">inet6</code> implements
    Internet Protocol version 6.</p>
<p class="Pp" id="Internet"><code class="Nm">inet6</code> is a collection of
    protocols layered atop the
    <a class="permalink" href="#Internet"><i class="Em">Internet Protocol
    version 6</i></a> (IPv6) transport layer, and using the IPv6 address format.
    The <code class="Nm">inet6</code> family provides protocol support for the
    <code class="Dv">SOCK_STREAM</code>, <code class="Dv">SOCK_DGRAM</code>, and
    <code class="Dv">SOCK_RAW</code> socket types; the
    <code class="Dv">SOCK_RAW</code> interface provides access to the IPv6
    protocol.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="ADDRESSING"><a class="permalink" href="#ADDRESSING">ADDRESSING</a></h1>
<p class="Pp">IPv6 addresses are 16 byte quantities, stored in network standard
    byteorder. The include file
    <code class="In">&lt;<a class="In">netinet/in.h</a>&gt;</code> defines this
    address as a discriminated union.</p>
<p class="Pp">Sockets bound to the <code class="Nm">inet6</code> family use the
    following addressing structure:</p>
<div class="Bd Pp Bd-indent Li">
<pre>struct sockaddr_in6 {
	uint8_t		sin6_len;
	sa_family_t	sin6_family;
	in_port_t	sin6_port;
	uint32_t	sin6_flowinfo;
	struct in6_addr	sin6_addr;
	uint32_t	sin6_scope_id;
};</pre>
</div>
<p class="Pp">Sockets may be created with the local address
    &#x201C;<code class="Dv">::</code>&#x201D; (which is equal to IPv6 address
    <code class="Dv">0:0:0:0:0:0:0:0</code>) to effect &#x201C;wildcard&#x201D;
    matching on incoming messages.</p>
<p class="Pp">The IPv6 specification defines scoped addresses, like link-local
    or site-local addresses. A scoped address is ambiguous to the kernel, if it
    is specified without a scope identifier. To manipulate scoped addresses
    properly from the userland, programs must use the advanced API defined in
    RFC 2292. A compact description of the advanced API is available in
    <a class="Xr">ip6(4)</a>. If a scoped address is specified without an
    explicit scope, the kernel may raise an error. Note that scoped addresses
    are not for daily use at this moment, both from a specification and an
    implementation point of view.</p>
<p class="Pp">The KAME implementation supports an extended numeric IPv6 address
    notation for link-local addresses, like
    &#x201C;<code class="Li">fe80::1%de0</code>&#x201D; to specify
    &#x201C;<code class="Li">fe80::1</code> on <code class="Li">de0</code>
    interface&#x201D;. This notation is supported by
    <a class="Xr">getaddrinfo(3)</a> and <a class="Xr">getnameinfo(3)</a>. Some
    of normal userland programs, such as <a class="Xr">telnet(1)</a> or
    <a class="Xr">ftp(1)</a>, are able to use this notation. With special
    programs like <a class="Xr">ping6(8)</a>, you can specify the outgoing
    interface by an extra command line option to disambiguate scoped
  addresses.</p>
<p class="Pp">Scoped addresses are handled specially in the kernel. In kernel
    structures like routing tables or interface structures, a scoped address
    will have its interface index embedded into the address. Therefore, the
    address in some kernel structures is not the same as that on the wire. The
    embedded index will become visible through a
    <code class="Dv">PF_ROUTE</code> socket, kernel memory accesses via
    <a class="Xr">kvm(3)</a> and on some other occasions. HOWEVER, users should
    never use the embedded form. For details please consult
    <a class="Lk" href="http://www.kame.net/dev/cvsweb2.cgi/kame/IMPLEMENTATION">http://www.kame.net/dev/cvsweb2.cgi/kame/IMPLEMENTATION</a>.
    Note that the above URL describes the situation with the latest KAME tree,
    not the <span class="Ux">NetBSD</span> tree.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="PROTOCOLS"><a class="permalink" href="#PROTOCOLS">PROTOCOLS</a></h1>
<p class="Pp">The <code class="Nm">inet6</code> family comprises the IPv6
    network protocol, Internet Control Message Protocol version 6 (ICMPv6),
    Transmission Control Protocol (TCP), and User Datagram Protocol (UDP). TCP
    is used to support the <code class="Dv">SOCK_STREAM</code> abstraction while
    UDP is used to support the <code class="Dv">SOCK_DGRAM</code> abstraction.
    Note that TCP and UDP are common to <a class="Xr">inet(4)</a> and
    <code class="Nm">inet6</code>. A raw interface to IPv6 is available by
    creating an Internet socket of type <code class="Dv">SOCK_RAW</code>. The
    ICMPv6 message protocol is accessible from a raw socket.</p>
<section class="Ss">
<h2 class="Ss" id="Interaction_between_IPv4/v6_sockets"><a class="permalink" href="#Interaction_between_IPv4/v6_sockets">Interaction
  between IPv4/v6 sockets</a></h2>
<p class="Pp">By default, <span class="Ux">NetBSD</span> does not route IPv4
    traffic to <code class="Dv">AF_INET6</code> sockets. The default behavior
    intentionally violates RFC 2553 for security reasons. Listen to two sockets
    if you want to accept both IPv4 and IPv6 traffic. IPv4 traffic may be routed
    with certain per-socket/per-node configuration, however, it is not
    recommended to do so. Consult <a class="Xr">ip6(4)</a> for details.</p>
<p class="Pp">The behavior of <code class="Dv">AF_INET6</code> TCP/UDP socket is
    documented in RFC 2553. Basically, it says this:</p>
<ul class="Bl-bullet Bl-compact">
  <li>A specific bind on an <code class="Dv">AF_INET6</code> socket
      (<a class="Xr">bind(2)</a> with an address specified) should accept IPv6
      traffic to that address only.</li>
  <li>If you perform a wildcard bind on an <code class="Dv">AF_INET6</code>
      socket (<a class="Xr">bind(2)</a> to IPv6 address
      <code class="Li">::</code>), and there is no wildcard bind
      <code class="Dv">AF_INET</code> socket on that TCP/UDP port, IPv6 traffic
      as well as IPv4 traffic should be routed to that
      <code class="Dv">AF_INET6</code> socket. IPv4 traffic should be seen as if
      it came from an IPv6 address like <code class="Li">::ffff:10.1.1.1</code>.
      This is called an IPv4 mapped address.</li>
  <li>If there are both a wildcard bind <code class="Dv">AF_INET</code> socket
      and a wildcard bind <code class="Dv">AF_INET6</code> socket on one TCP/UDP
      port, they should behave separately. IPv4 traffic should be routed to the
      <code class="Dv">AF_INET</code> socket and IPv6 should be routed to the
      <code class="Dv">AF_INET6</code> socket.</li>
</ul>
<p class="Pp">However, RFC 2553 does not define the ordering constraint between
    calls to <a class="Xr">bind(2)</a>, nor how IPv4 TCP/UDP port numbers and
    IPv6 TCP/UDP port numbers relate to each other (should they be integrated or
    separated). Implemented behavior is very different from kernel to kernel.
    Therefore, it is unwise to rely too much upon the behavior of
    <code class="Dv">AF_INET6</code> wildcard bind sockets. It is recommended to
    listen to two sockets, one for <code class="Dv">AF_INET</code> and another
    for <code class="Dv">AF_INET6</code>, when you would like to accept both
    IPv4 and IPv6 traffic.</p>
<p class="Pp">It should also be noted that malicious parties can take advantage
    of the complexity presented above, and are able to bypass access control, if
    the target node routes IPv4 traffic to <code class="Dv">AF_INET6</code>
    socket. Users are advised to take care handling connections from IPv4 mapped
    address to <code class="Dv">AF_INET6</code> sockets.</p>
</section>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">ioctl(2)</a>, <a class="Xr">socket(2)</a>,
    <a class="Xr">sysctl(3)</a>, <a class="Xr">icmp6(4)</a>,
    <a class="Xr">intro(4)</a>, <a class="Xr">ip6(4)</a>,
    <a class="Xr">tcp(4)</a>, <a class="Xr">udp(4)</a></p>
<p class="Pp"><cite class="Rs"><span class="RsA">Qing Li</span>,
    <span class="RsA">Tatuya Jinmei</span>, and <span class="RsA">Keiichi
    Shima</span>, <i class="RsB">IPv6 Core Protocols Implementation</i>,
    <i class="RsI">Morgan Kaufmann</i>,
  <span class="RsD">2006</span>.</cite></p>
<p class="Pp"><cite class="Rs"><span class="RsA">Qing Li</span>,
    <span class="RsA">Tatuya Jinmei</span>, and <span class="RsA">Keiichi
    Shima</span>, <i class="RsB">IPv6 Advanced Protocols Implementation</i>,
    <i class="RsI">Morgan Kaufmann</i>,
  <span class="RsD">2007</span>.</cite></p>
</section>
<section class="Sh">
<h1 class="Sh" id="STANDARDS"><a class="permalink" href="#STANDARDS">STANDARDS</a></h1>
<p class="Pp"><cite class="Rs"><span class="RsA">Tatuya Jinmei</span> and
    <span class="RsA">Atsushi Onoe</span>, <span class="RsT">An Extension of
    Format for IPv6 Scoped Addresses</span>, <span class="RsR">internet
    draft</span>,
    <span class="RsN">draft-ietf-ipngwg-scopedaddr-format-02.txt</span>,
    <span class="RsD">June 2000</span>, <span class="RsO">work in progress
    material</span>.</cite></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <code class="Nm">inet6</code> protocol interfaces are defined
    in RFC 2553 and RFC 2292. The implementation described herein appeared in
    the WIDE/KAME project.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
<p class="Pp">The IPv6 support is subject to change as the Internet protocols
    develop. Users should not depend on details of the current implementation,
    but rather the services exported.</p>
<p class="Pp">Users are suggested to implement &#x201C;version
    independent&#x201D; code as much as possible, as you will need to support
    both <a class="Xr">inet(4)</a> and <code class="Nm">inet6</code>.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">March 10, 2010</td>
    <td class="foot-os">NetBSD 10.1</td>
  </tr>
</table>