1IPV6(7)                    Linux Programmer's Manual                   IPV6(7)
2
3
4

NAME

6       ipv6, AF_INET6 - Linux IPv6 protocol implementation
7

SYNOPSIS

9       #include <sys/socket.h>
10       #include <netinet/in.h>
11
12       tcp6_socket = socket(AF_INET6, SOCK_STREAM, 0);
13       raw6_socket = socket(AF_INET6, SOCK_RAW, protocol);
14       udp6_socket = socket(AF_INET6, SOCK_DGRAM, protocol);
15

DESCRIPTION

17       Linux 2.2 optionally implements the Internet Protocol, version 6.  This
18       man page contains a description of the IPv6 basic API as implemented by
19       the  Linux  kernel  and  glibc  2.1.  The interface is based on the BSD
20       sockets interface; see socket(7).
21
22       The IPv6 API aims to be  mostly  compatible  with  the  IPv4  API  (see
23       ip(7)).  Only differences are described in this man page.
24
25       To  bind an AF_INET6 socket to any process, the local address should be
26       copied from the in6addr_any  variable  which  has  in6_addr  type.   In
27       static  initializations,  IN6ADDR_ANY_INIT  may  also  be  used,  which
28       expands to a constant expression.  Both of them  are  in  network  byte
29       order.
30
31       The   IPv6   loopback   address   (::1)  is  available  in  the  global
32       in6addr_loopback variable.  For initializations,  IN6ADDR_LOOPBACK_INIT
33       should be used.
34
35       IPv4 connections can be handled with the v6 API by using the v4-mapped-
36       on-v6 address type; thus a program only needs to support this API  type
37       to  support  both  protocols.   This  is  handled  transparently by the
38       address handling functions in the C library.
39
40       IPv4 and IPv6 share the local port space.  When you get an IPv4 connec‐
41       tion  or  packet to a IPv6 socket, its source address will be mapped to
42       v6 and it will be mapped to v6.
43
44   Address Format
45           struct sockaddr_in6 {
46               sa_family_t     sin6_family;   /* AF_INET6 */
47               in_port_t       sin6_port;     /* port number */
48               uint32_t        sin6_flowinfo; /* IPv6 flow information */
49               struct in6_addr sin6_addr;     /* IPv6 address */
50               uint32_t        sin6_scope_id; /* Scope ID (new in 2.4) */
51           };
52
53           struct in6_addr {
54               unsigned char   s6_addr[16];   /* IPv6 address */
55           };
56
57       sin6_family is always set to AF_INET6; sin6_port is the  protocol  port
58       (see  sin_port  in  ip(7));  sin6_flowinfo is the IPv6 flow identifier;
59       sin6_addr is the 128-bit IPv6 address.  sin6_scope_id is an ID  depend‐
60       ing  on  the scope of the address.  It is new in Linux 2.4.  Linux only
61       supports it for link scope addresses, in that case  sin6_scope_id  con‐
62       tains the interface index (see netdevice(7))
63
64       IPv6  supports several address types: unicast to address a single host,
65       multicast to address a group of hosts, anycast to address  the  nearest
66       member  of a group of hosts (not implemented in Linux), IPv4-on-IPv6 to
67       address a IPv4 host, and other reserved address types.
68
69       The address notation for IPv6 is a group of 16 2-digit hexadecimal num‐
70       bers,  separated with a ':'.  "::" stands for a string of 0 bits.  Spe‐
71       cial addresses are ::1  for  loopback  and  ::FFFF:<IPv4  address>  for
72       IPv4-mapped-on-IPv6.
73
74       The port space of IPv6 is shared with IPv4.
75
76   Socket Options
77       IPv6  supports  some  protocol-specific  socket options that can be set
78       with setsockopt(2) and read  with  getsockopt(2).   The  socket  option
79       level for IPv6 is IPPROTO_IPV6.  A boolean integer flag is zero when it
80       is false, otherwise true.
81
82       IPV6_ADDRFORM
83              Turn an AF_INET6 socket into a socket  of  a  different  address
84              family.   Only  AF_INET  is currently supported for that.  It is
85              only allowed for IPv6 sockets that are connected and bound to  a
86              v4-mapped-on-v6  address.  The argument is a pointer to an inte‐
87              ger containing AF_INET.  This is useful to pass v4-mapped  sock‐
88              ets  as file descriptors to programs that don't know how to deal
89              with the IPv6 API.
90
91       IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
92              Control membership in multicast groups.  Argument is  a  pointer
93              to a struct ipv6_mreq structure.
94
95       IPV6_MTU
96              Set  the  MTU  to be used for the socket.  The MTU is limited by
97              the device MTU or the  path  mtu  when  path  mtu  discovery  is
98              enabled.  Argument is a pointer to integer.
99
100       IPV6_MTU_DISCOVER
101              Control  path  mtu discovery on the socket.  See IP_MTU_DISCOVER
102              in ip(7) for details.
103
104       IPV6_MULTICAST_HOPS
105              Set the multicast hop limit  for  the  socket.   Argument  is  a
106              pointer  to  an  integer.   -1  in the value means use the route
107              default, otherwise it should be between 0 and 255.
108
109       IPV6_MULTICAST_IF
110              Set the device for outgoing multicast  packets  on  the  socket.
111              This  is  only  allowed for SOCK_DGRAM and SOCK_RAW socket.  The
112              argument is a pointer to an interface index  (see  netdevice(7))
113              in an integer.
114
115       IPV6_MULTICAST_LOOP
116              Control  whether  the  socket sees multicast packets that it has
117              send itself.  Argument is a pointer to boolean.
118
119       IPV6_PKTINFO
120              Set delivery of the IPV6_PKTINFO  control  message  on  incoming
121              datagrams.   Only  allowed  for  SOCK_DGRAM or SOCK_RAW sockets.
122              Argument is a pointer to a boolean value in an integer.
123
124       IPV6_RTHDR,  IPV6_AUTHHDR,  IPV6_DSTOPS,  IPV6_HOPOPTS,  IPV6_FLOWINFO,
125       IPV6_HOPLIMIT
126              Set delivery of control messages for incoming datagrams contain‐
127              ing extension headers from the received packet.  IPV6_RTHDR  de‐
128              livers the routing header, IPV6_AUTHHDR delivers the authentica‐
129              tion header,  IPV6_DSTOPTS  delivers  the  destination  options,
130              IPV6_HOPOPTS delivers the hop options, IPV6_FLOWINFO delivers an
131              integer containing the flow ID, IPV6_HOPLIMIT delivers an  inte‐
132              ger  containing  the  hop count of the packet.  The control mes‐
133              sages have the same type as the socket option.  All these header
134              options  can also be set for outgoing packets by putting the ap‐
135              propriate control message into the control buffer of sendmsg(2).
136              Only  allowed for SOCK_DGRAM or SOCK_RAW sockets.  Argument is a
137              pointer to a boolean value.
138
139       IPV6_RECVERR
140              Control receiving of asynchronous error options.  See IP_RECVERR
141              in ip(7) for details.  Argument is a pointer to boolean.
142
143       IPV6_ROUTER_ALERT
144              Pass  forwarded packets containing a router alert hop-by-hop op‐
145              tion to this socket.  Only allowed for  SOCK_RAW  sockets.   The
146              tapped packets are not forwarded by the kernel, it is the user's
147              responsibility to send them out again.  Argument is a pointer to
148              an  integer.  A positive integer indicates a router alert option
149              value to intercept.  Packets carrying a router alert option with
150              a  value  field containing this integer will be delivered to the
151              socket.  A negative integer disables delivery  of  packets  with
152              router alert options to this socket.
153
154       IPV6_UNICAST_HOPS
155              Set the unicast hop limit for the socket.  Argument is a pointer
156              to an integer.  -1 in the value means  use  the  route  default,
157              otherwise it should be between 0 and 255.
158
159       IPV6_V6ONLY (since Linux 2.4.21 and 2.6)
160              If  this  flag  is set to true (nonzero), then the socket is re‐
161              stricted to sending and receiving IPv6 packets  only.   In  this
162              case,  an IPv4 and an IPv6 application can bind to a single port
163              at the same time.
164
165              If this flag is set to false (zero), then the socket can be used
166              to  send  and  receive packets to and from an IPv6 address or an
167              IPv4-mapped IPv6 address.
168
169              The argument is a pointer to a boolean value in an integer.
170
171              The default value for this flag is defined by  the  contents  of
172              the  file  /proc/sys/net/ipv6/bindv6only.  The default value for
173              that file is 0 (false).
174

VERSIONS

176       The older libinet6 libc5 based IPv6 API implementation for Linux is not
177       described here and may vary in details.
178
179       Linux  2.4  will  break  binary  compatibility for the sockaddr_in6 for
180       64-bit hosts by changing the alignment of in6_addr and adding an  addi‐
181       tional sin6_scope_id field.  The kernel interfaces stay compatible, but
182       a program including sockaddr_in6 or in6_addr into other structures  may
183       not be.  This is not a problem for 32-bit hosts like i386.
184
185       The  sin6_flowinfo  field  is  new  in  Linux 2.4.  It is transparently
186       passed/read by the kernel when the passed address length  contains  it.
187       Some programs that pass a longer address buffer and then check the out‐
188       going address length may break.
189

NOTES

191       The sockaddr_in6 structure is bigger than the generic  sockaddr.   Pro‐
192       grams  that  assume  that  all  address types can be stored safely in a
193       struct sockaddr need to be changed to use struct  sockaddr_storage  for
194       that instead.
195

BUGS

197       The  IPv6  extended  API as in RFC 2292 is currently only partly imple‐
198       mented; although the 2.2 kernel has near complete support for receiving
199       options,  the  macros  for generating IPv6 options are missing in glibc
200       2.1.
201
202       IPSec support for EH and AH headers is missing.
203
204       Flow label management is not complete and not documented here.
205
206       This man page is not complete.
207

SEE ALSO

209       cmsg(3), ip(7)
210
211       RFC 2553: IPv6 BASIC API.  Linux tries to be compliant to this.
212
213       RFC 2460: IPv6 specification.
214

COLOPHON

216       This page is part of release 3.25 of the Linux  man-pages  project.   A
217       description  of  the project, and information about reporting bugs, can
218       be found at http://www.kernel.org/doc/man-pages/.
219
220
221
222Linux                             2009-02-28                           IPV6(7)
Impressum