1.\" $OpenBSD: inet6.4,v 1.34 2015/09/10 17:55:21 schwarze Exp $ 2.\" $KAME: inet6.4,v 1.19 2000/11/24 10:13:18 itojun Exp $ 3.\" 4.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the project nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.Dd $Mdocdate: September 10 2015 $ 32.Dt INET6 4 33.Os 34.Sh NAME 35.Nm inet6 36.Nd Internet protocol version 6 family 37.Sh SYNOPSIS 38.In sys/types.h 39.In netinet/in.h 40.Sh DESCRIPTION 41The 42.Nm 43family is an updated version of the 44.Xr inet 4 45family. 46While 47.Xr inet 4 48implements Internet Protocol version 4, 49.Nm 50implements Internet Protocol version 6. 51.Pp 52The 53.Nm 54family is comprised of the 55Internet Protocol version 6 56.Pq Tn IPv6 57network protocol, Internet Control 58Message Protocol version 6 59.Pq Tn ICMPv6 , 60Transmission Control Protocol 61.Pq Tn TCP , 62and User Datagram Protocol 63.Pq Tn UDP . 64.Tn TCP 65is used to support the 66.Dv SOCK_STREAM 67abstraction while 68.Tn UDP 69is used to support the 70.Dv SOCK_DGRAM 71abstraction. 72Note that 73.Tn TCP 74and 75.Tn UDP 76are common to 77.Xr inet 4 78and 79.Nm inet6 . 80A raw interface to 81.Tn IPv6 82is available 83by creating an Internet socket of type 84.Dv SOCK_RAW . 85The 86.Tn ICMPv6 87message protocol is accessible from a raw socket. 88.\" .Pp 89.\" The 128-bit IPv6 address contains both network and host parts. 90.\" However, direct examination of addresses is discouraged. 91.\" For those programs which absolutely need to break addresses 92.\" into their component parts, the following 93.\" .Xr ioctl 2 94.\" commands are provided for a datagram socket in the 95.\" .Nm 96.\" domain; they have the same form as the 97.\" .Dv SIOCIFADDR 98.\" command (see 99.\" .Xr intro 4 ) . 100.\" .Pp 101.\" .Bl -tag -width SIOCSIFNETMASK 102.\" .It Dv SIOCSIFNETMASK 103.\" Set interface network mask. 104.\" The network mask defines the network part of the address; 105.\" if it contains more of the address than the address type would indicate, 106.\" then subnets are in use. 107.\" .It Dv SIOCGIFNETMASK 108.\" Get interface network mask. 109.\" .El 110.Pp 111For security reasons, 112.Ox 113does not route IPv4 traffic to an 114.Dv AF_INET6 115socket, 116and does not support IPv4 mapped addresses, 117where IPv4 traffic is seen as if it comes from an IPv6 address like 118.Li ::ffff:10.1.1.1 . 119Where both IPv4 and IPv6 traffic need to be accepted, listen on two sockets. 120.Sh ADDRESSING 121IPv6 addresses are 16 byte quantities, stored in network standard byteorder. 122The include file 123.In netinet/in.h 124defines this address 125as a discriminated union. 126.Pp 127Sockets bound to the 128.Nm 129family utilize the following addressing structure: 130.Bd -literal -offset indent 131struct sockaddr_in6 { 132 u_int8_t sin6_len; 133 sa_family_t sin6_family; 134 in_port_t sin6_port; 135 u_int32_t sin6_flowinfo; 136 struct in6_addr sin6_addr; 137 u_int32_t sin6_scope_id; 138}; 139.Ed 140.Pp 141Sockets may be created with the local address 142.Dq Dv :: 143.Po 144which is equal to IPv6 address 145.Dv 0:0:0:0:0:0:0:0 146.Pc 147to effect 148.Dq wildcard 149matching on incoming messages. 150.Pp 151The IPv6 specification defines scoped address, 152like link-local or site-local address. 153A scoped address is ambiguous to the kernel, 154if it is specified without a scope identifier. 155To manipulate scoped addresses properly from userland, 156programs must use the advanced API defined in RFC 3542. 157A compact description of the advanced API is available in 158.Xr ip6 4 . 159If scoped addresses are specified without explicit scope, 160the kernel may raise an error. 161Note that scoped addresses are not for daily use at this moment, 162both from a specification and an implementation point of view. 163.Pp 164KAME implementation supports extended numeric IPv6 address notation 165for link-local addresses, 166like 167.Dq Li fe80::1%de0 168to specify 169.Do 170.Li fe80::1 171on 172.Li de0 173interface 174.Dc . 175The notation is supported by 176.Xr getaddrinfo 3 177and 178.Xr getnameinfo 3 . 179Some normal userland programs, such as 180.Xr telnet 1 181or 182.Xr ftp 1 , 183are able to use the notation. 184With special programs 185like 186.Xr ping6 8 , 187an outgoing interface can be specified with an extra command line option 188to disambiguate scoped addresses. 189.Pp 190Scoped addresses are handled specially in the kernel. 191In the kernel structures like routing tables or interface structure, 192scoped addresses will have their interface index embedded into the address. 193Therefore, 194the address on some of the kernel structure is not the same as that on the wire. 195The embedded index will become visible on 196.Dv PF_ROUTE 197socket, kernel memory accesses via 198.Xr kvm 3 199and some other occasions. 200HOWEVER, users should never use the embedded form. 201For details please consult 202.Lk http://www.kame.net/dev/cvsweb2.cgi/kame/IMPLEMENTATION . 203Note that the above URL describes the situation with the latest KAME tree, 204not the 205.Ox 206tree. 207.Sh SEE ALSO 208.Xr ioctl 2 , 209.Xr socket 2 , 210.Xr sysctl 3 , 211.Xr icmp6 4 , 212.Xr intro 4 , 213.Xr ip6 4 , 214.Xr tcp 4 , 215.Xr udp 4 216.Sh STANDARDS 217.Rs 218.%A Tatsuya Jinmei 219.%A Atsushi Onoe 220.%D June 2000 221.%N draft-ietf-ipngwg-scopedaddr-format-02.txt 222.%O work in progress material 223.%R internet draft 224.%T "An Extension of Format for IPv6 Scoped Addresses" 225.Re 226.Pp 227.Rs 228.%A R. Gilligan 229.%A S. Thomson 230.%A J. Bound 231.%A J. McCann 232.%A W. Stevens 233.%D February 2003 234.%R RFC 3493 235.%T Basic Socket Interface Extensions for Ipv6 236.Re 237.Pp 238.Rs 239.%A W. Stevens 240.%A M. Thomas 241.%A E. Nordmark 242.%A T. Jinmei 243.%D May 2003 244.%R RFC 3542 245.%T Advanced Sockets Application Programming Interface (API) for IPv6 246.Re 247.Sh HISTORY 248The implementation described herein appeared in WIDE/KAME project. 249.Sh BUGS 250The IPv6 support is subject to change as the Internet protocols develop. 251Users should not depend on details of the current implementation, 252but rather the services exported. 253.Pp 254.Dq Version independent 255code should be implemented as much as possible in order to support both 256.Xr inet 4 257and 258.Nm inet6 . 259