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

NAME

6       ipv6, PF_INET6 - Linux IPv6 protocol implementation
7

SYNOPSIS

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

DESCRIPTION

18       Linux 2.2 optionally implements the Internet Protocol, version 6.  This
19       man page contains a description of the IPv6 basic API as implemented by
20       the Linux kernel and glibc 2.1. The interface is based on the BSD sock‐
21       ets interface; see socket(7).
22
23       The IPv6 API aims to be mostly compatible with the ip(7) v4  API.  Only
24       differences are described in this man page.
25
26       To  bind  an AF_INET6 socket to any process the local address should be
27       copied from the in6addr_any  variable  which  has  in6_addr  type.   In
28       static initializations IN6ADDR_ANY_INIT may also be used, which expands
29       to a constant expression.  Both of them are in network 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 only to support this API
37       type to support both protocols.  This is handled transparently  by  the
38       address handling functions in libc.
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 v6
42       and it'll be mapped to v6.
43

ADDRESS FORMAT

45              struct sockaddr_in6 {
46                  u_int16_t       sin6_family;/* AF_INET6 */
47                  u_int16_t       sin6_port;/* port number */
48                  u_int32_t       sin6_flowinfo;/* IPv6 flow information */
49                  struct in6_addr sin6_addr;/* IPv6 address */
50                  u_int32_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  128bit  IPv6  address.   sin6_scope_id  is an ID of
60       depending of on the scope of the address.  It  is  new  in  Linux  2.4.
61       Linux  only  supports  it  for  link  scope  addresses,  in  that  case
62       sin6_scope_id contains 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

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 only
85              allowed  for  IPv6  sockets  that  are  connected and bound to a
86              v4-mapped-on-v6 address. The argument is a pointer to a  integer
87              containing AF_INET.  This is useful to pass v4-mapped sockets as
88              file descriptors to programs that don't know how  to  deal  with
89              the IPv6 API.
90
91       IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP
92              Control membership in multicast groups. Argument is a pointer to
93              a struct ipv6_mreq structure.
94
95       IPV6_MTU
96              Set the MTU to be used for the socket. The MTU is limited by the
97              device  MTU  or the path mtu when path mtu discovery is enabled.
98              Argument is a pointer to integer.
99
100       IPV6_MTU_DISCOVER
101              Control path mtu discovery on the socket. See IP_MTU_DISCOVER in
102              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 an 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 all forwarded packets containing an router alert option  to
145              this  socket.   Only  allowed for datagram sockets and for root.
146              Argument is a pointer to boolean.
147
148       IPV6_UNICAST_HOPS
149              Set the unicast hop limit for the socket. Argument is an pointer
150              to an integer. -1 in the value means use the route default, oth‐
151              erwise it should be between 0 and 255.
152

VERSIONS

154       The older libinet6 libc5 based IPv6 API implementation for Linux is not
155       described here and may vary in details.
156
157       Linux  2.4  will  break  binary  compatibility for the sockaddr_in6 for
158       64bit hosts by changing the alignment of in6_addr and adding  an  addi‐
159       tional  sin6_scope_id field. The kernel interfaces stay compatible, but
160       a program including sockaddr_in6 or in6_addr into other structures  may
161       not be. This is not a problem for 32bit hosts like i386.
162
163       The  sin6_flowinfo  field  is  new  in  Linux  2.4. It is transparently
164       passed/read by the kernel when the passed address length  contains  it.
165       Some programs that pass a longer address buffer and then check the out‐
166       going address length may break.
167

PORTING NOTES

169       The sockaddr_in6 structure is bigger than the generic  sockaddr.   Pro‐
170       grams  that  assume  that  all  address types can be stored safely in a
171       struct sockaddr need to be changed to use struct  sockaddr_storage  for
172       that instead.
173

BUGS

175       The  IPv6  extended  API as in RFC 2292 is currently only partly imple‐
176       mented; although the 2.2 kernel has near complete support for receiving
177       options,  the  macros  for generating IPv6 options are missing in glibc
178       2.1.
179
180       IPSec support for EH and AH headers is missing.
181
182       Flow label management is not complete and not documented here.
183
184       This man page is not complete.
185

SEE ALSO

187       cmsg(3), ip(7)
188
189       RFC 2553: IPv6 BASIC API. Linux tries to be compliant to this.
190
191       RFC 2460: IPv6 specification.
192
193
194
195Linux Man Page                    1999-06-29                           IPV6(7)
Impressum