Deleted Added
full compact
ip6.4 (162797) ip6.4 (176470)
1.\" $KAME: ip6.4,v 1.23 2005/01/11 05:56:25 itojun Exp $
2.\" $OpenBSD: ip6.4,v 1.21 2005/01/06 03:50:46 itojun Exp $
3.\"
4.\" Copyright (c) 1983, 1991, 1993
5.\" The Regents of the University of California. 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 University 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 REGENTS 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 REGENTS 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.\"
1.\" $KAME: ip6.4,v 1.23 2005/01/11 05:56:25 itojun Exp $
2.\" $OpenBSD: ip6.4,v 1.21 2005/01/06 03:50:46 itojun Exp $
3.\"
4.\" Copyright (c) 1983, 1991, 1993
5.\" The Regents of the University of California. 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 University 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 REGENTS 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 REGENTS 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.\" $FreeBSD: head/share/man/man4/ip6.4 162797 2006-09-29 16:16:41Z bms $
31.\" $FreeBSD: head/share/man/man4/ip6.4 176470 2008-02-22 21:02:36Z bms $
32.\"
32.\"
33.Dd September 29, 2006
33.Dd February 21, 2008
34.Dt IP6 4
35.Os
36.Sh NAME
37.Nm ip6
38.Nd Internet Protocol version 6 (IPv6) network layer
39.Sh SYNOPSIS
40.In sys/socket.h
41.In netinet/in.h
42.Ft int
43.Fn socket AF_INET6 SOCK_RAW proto
44.Sh DESCRIPTION
45The IPv6 network layer is used by the IPv6 protocol family for
46transporting data.
47IPv6 packets contain an IPv6 header that is not provided as part of the
48payload contents when passed to an application.
49IPv6 header options affect the behavior of this protocol and may be used
50by high-level protocols (such as the
51.Xr tcp 4
52and
53.Xr udp 4
54protocols) as well as directly by
55.Dq raw sockets ,
56which process IPv6 messages at a lower-level and may be useful for
57developing new protocols and special-purpose applications.
58.Ss Header
59All IPv6 packets begin with an IPv6 header.
60When data received by the kernel are passed to the application, this
61header is not included in buffer, even when raw sockets are being used.
62Likewise, when data are sent to the kernel for transmit from the
63application, the buffer is not examined for an IPv6 header:
64the kernel always constructs the header.
65To directly access IPv6 headers from received packets and specify them
66as part of the buffer passed to the kernel, link-level access
67.Po
68.Xr bpf 4 ,
69for example
70.Pc
71must instead be utilized.
72.Pp
73The header has the following definition:
74.Bd -literal -offset indent
75struct ip6_hdr {
76 union {
77 struct ip6_hdrctl {
78 u_int32_t ip6_un1_flow; /* 20 bits of flow ID */
79 u_int16_t ip6_un1_plen; /* payload length */
80 u_int8_t ip6_un1_nxt; /* next header */
81 u_int8_t ip6_un1_hlim; /* hop limit */
82 } ip6_un1;
83 u_int8_t ip6_un2_vfc; /* version and class */
84 } ip6_ctlun;
85 struct in6_addr ip6_src; /* source address */
86 struct in6_addr ip6_dst; /* destination address */
87} __packed;
88
89#define ip6_vfc ip6_ctlun.ip6_un2_vfc
90#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
91#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
92#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
93#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
94#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
95.Ed
96.Pp
97All fields are in network-byte order.
98Any options specified (see
99.Sx Options
100below) must also be specified in network-byte order.
101.Pp
102.Va ip6_flow
103specifies the flow ID.
104.Va ip6_plen
105specifies the payload length.
106.Va ip6_nxt
107specifies the type of the next header.
108.Va ip6_hlim
109specifies the hop limit.
110.Pp
111The top 4 bits of
112.Va ip6_vfc
113specify the class and the bottom 4 bits specify the version.
114.Pp
115.Va ip6_src
116and
117.Va ip6_dst
118specify the source and destination addresses.
119.Pp
120The IPv6 header may be followed by any number of extension headers that start
121with the following generic definition:
122.Bd -literal -offset indent
123struct ip6_ext {
124 u_int8_t ip6e_nxt;
125 u_int8_t ip6e_len;
126} __packed;
127.Ed
128.Ss Options
129IPv6 allows header options on packets to manipulate the behavior of the
130protocol.
131These options and other control requests are accessed with the
132.Xr getsockopt 2
133and
134.Xr setsockopt 2
135system calls at level
136.Dv IPPROTO_IPV6
137and by using ancillary data in
138.Xr recvmsg 2
139and
140.Xr sendmsg 2 .
141They can be used to access most of the fields in the IPv6 header and
142extension headers.
143.Pp
144The following socket options are supported:
145.Bl -tag -width Ds
146.\" .It Dv IPV6_OPTIONS
147.It Dv IPV6_UNICAST_HOPS Fa "int *"
148Get or set the default hop limit header field for outgoing unicast
149datagrams sent on this socket.
34.Dt IP6 4
35.Os
36.Sh NAME
37.Nm ip6
38.Nd Internet Protocol version 6 (IPv6) network layer
39.Sh SYNOPSIS
40.In sys/socket.h
41.In netinet/in.h
42.Ft int
43.Fn socket AF_INET6 SOCK_RAW proto
44.Sh DESCRIPTION
45The IPv6 network layer is used by the IPv6 protocol family for
46transporting data.
47IPv6 packets contain an IPv6 header that is not provided as part of the
48payload contents when passed to an application.
49IPv6 header options affect the behavior of this protocol and may be used
50by high-level protocols (such as the
51.Xr tcp 4
52and
53.Xr udp 4
54protocols) as well as directly by
55.Dq raw sockets ,
56which process IPv6 messages at a lower-level and may be useful for
57developing new protocols and special-purpose applications.
58.Ss Header
59All IPv6 packets begin with an IPv6 header.
60When data received by the kernel are passed to the application, this
61header is not included in buffer, even when raw sockets are being used.
62Likewise, when data are sent to the kernel for transmit from the
63application, the buffer is not examined for an IPv6 header:
64the kernel always constructs the header.
65To directly access IPv6 headers from received packets and specify them
66as part of the buffer passed to the kernel, link-level access
67.Po
68.Xr bpf 4 ,
69for example
70.Pc
71must instead be utilized.
72.Pp
73The header has the following definition:
74.Bd -literal -offset indent
75struct ip6_hdr {
76 union {
77 struct ip6_hdrctl {
78 u_int32_t ip6_un1_flow; /* 20 bits of flow ID */
79 u_int16_t ip6_un1_plen; /* payload length */
80 u_int8_t ip6_un1_nxt; /* next header */
81 u_int8_t ip6_un1_hlim; /* hop limit */
82 } ip6_un1;
83 u_int8_t ip6_un2_vfc; /* version and class */
84 } ip6_ctlun;
85 struct in6_addr ip6_src; /* source address */
86 struct in6_addr ip6_dst; /* destination address */
87} __packed;
88
89#define ip6_vfc ip6_ctlun.ip6_un2_vfc
90#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
91#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
92#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
93#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
94#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
95.Ed
96.Pp
97All fields are in network-byte order.
98Any options specified (see
99.Sx Options
100below) must also be specified in network-byte order.
101.Pp
102.Va ip6_flow
103specifies the flow ID.
104.Va ip6_plen
105specifies the payload length.
106.Va ip6_nxt
107specifies the type of the next header.
108.Va ip6_hlim
109specifies the hop limit.
110.Pp
111The top 4 bits of
112.Va ip6_vfc
113specify the class and the bottom 4 bits specify the version.
114.Pp
115.Va ip6_src
116and
117.Va ip6_dst
118specify the source and destination addresses.
119.Pp
120The IPv6 header may be followed by any number of extension headers that start
121with the following generic definition:
122.Bd -literal -offset indent
123struct ip6_ext {
124 u_int8_t ip6e_nxt;
125 u_int8_t ip6e_len;
126} __packed;
127.Ed
128.Ss Options
129IPv6 allows header options on packets to manipulate the behavior of the
130protocol.
131These options and other control requests are accessed with the
132.Xr getsockopt 2
133and
134.Xr setsockopt 2
135system calls at level
136.Dv IPPROTO_IPV6
137and by using ancillary data in
138.Xr recvmsg 2
139and
140.Xr sendmsg 2 .
141They can be used to access most of the fields in the IPv6 header and
142extension headers.
143.Pp
144The following socket options are supported:
145.Bl -tag -width Ds
146.\" .It Dv IPV6_OPTIONS
147.It Dv IPV6_UNICAST_HOPS Fa "int *"
148Get or set the default hop limit header field for outgoing unicast
149datagrams sent on this socket.
150A value of \-1 resets to the default value.
151.\" .It Dv IPV6_RECVOPTS Fa "int *"
152.\" Get or set the status of whether all header options will be
153.\" delivered along with the datagram when it is received.
154.\" .It Dv IPV6_RECVRETOPTS Fa "int *"
155.\" Get or set the status of whether header options will be delivered
156.\" for reply.
157.\" .It Dv IPV6_RECVDSTADDR Fa "int *"
158.\" Get or set the status of whether datagrams are received with
159.\" destination addresses.
160.\" .It Dv IPV6_RETOPTS
161.\" Get or set IPv6 options.
162.It Dv IPV6_MULTICAST_IF Fa "u_int *"
163Get or set the interface from which multicast packets will be sent.
164For hosts with multiple interfaces, each multicast transmission is sent
165from the primary network interface.
166The interface is specified as its index as provided by
167.Xr if_nametoindex 3 .
168A value of zero specifies the default interface.
169.It Dv IPV6_MULTICAST_HOPS Fa "int *"
170Get or set the default hop limit header field for outgoing multicast
171datagrams sent on this socket.
172This option controls the scope of multicast datagram transmissions.
173.Pp
174Datagrams with a hop limit of 1 are not forwarded beyond the local
175network.
176Multicast datagrams with a hop limit of zero will not be transmitted on
177any network but may be delivered locally if the sending host belongs to
178the destination group and if multicast loopback (see below) has not been
179disabled on the sending socket.
180Multicast datagrams with a hop limit greater than 1 may be forwarded to
181the other networks if a multicast router (such as
182.Xr mrouted 8 Pq Pa ports/net/mrouted )
183is attached to the local network.
184.It Dv IPV6_MULTICAST_LOOP Fa "u_int *"
185Get or set the status of whether multicast datagrams will be looped back
186for local delivery when a multicast datagram is sent to a group to which
187the sending host belongs.
188.Pp
189This option improves performance for applications that may have no more
190than one instance on a single host (such as a router daemon) by
191eliminating the overhead of receiving their own transmissions.
192It should generally not be used by applications for which there may be
193more than one instance on a single host (such as a conferencing program)
194or for which the sender does not belong to the destination group
195(such as a time-querying program).
196.Pp
197A multicast datagram sent with an initial hop limit greater than 1 may
198be delivered to the sending host on a different interface from that on
199which it was sent if the host belongs to the destination group on that
200other interface.
201The multicast loopback control option has no effect on such delivery.
202.It Dv IPV6_JOIN_GROUP Fa "struct ipv6_mreq *"
203Join a multicast group.
204A host must become a member of a multicast group before it can receive
205datagrams sent to the group.
206.Bd -literal
207struct ipv6_mreq {
208 struct in6_addr ipv6mr_multiaddr;
209 unsigned int ipv6mr_interface;
210};
211.Ed
212.Pp
213.Va ipv6mr_interface
214may be set to zeroes to choose the default multicast interface or to the
215index of a particular multicast-capable interface if the host is
216multihomed.
217Membership is associated with a single interface; programs running on
218multihomed hosts may need to join the same group on more than one
219interface.
220.Pp
221If the multicast address is unspecified (i.e., all zeroes), messages
222from all multicast addresses will be accepted by this group.
223Note that setting to this value requires superuser privileges.
224.It Dv IPV6_LEAVE_GROUP Fa "struct ipv6_mreq *"
225Drop membership from the associated multicast group.
226Memberships are automatically dropped when the socket is closed or when
227the process exits.
228.It Dv IPV6_PORTRANGE Fa "int *"
229Get or set the allocation policy of ephemeral ports for when the kernel
230automatically binds a local address to this socket.
231The following values are available:
232.Pp
233.Bl -tag -width IPV6_PORTRANGE_DEFAULT -compact
234.It Dv IPV6_PORTRANGE_DEFAULT
235Use the regular range of non-reserved ports (varies, see
236.Xr sysctl 8 ) .
237.It Dv IPV6_PORTRANGE_HIGH
238Use a high range (varies, see
239.Xr sysctl 8 ) .
240.It Dv IPV6_PORTRANGE_LOW
241Use a low, reserved range (600\-1023).
242.El
243.It Dv IPV6_PKTINFO Fa "int *"
244Get or set whether additional information about subsequent packets will
245be provided as ancillary data along with the payload in subsequent
246.Xr recvmsg 2
247calls.
248The information is stored in the following structure in the ancillary
249data returned:
250.Bd -literal
251struct in6_pktinfo {
252 struct in6_addr ipi6_addr; /* src/dst IPv6 address */
253 unsigned int ipi6_ifindex; /* send/recv if index */
254};
255.Ed
256.It Dv IPV6_HOPLIMIT Fa "int *"
257Get or set whether the hop limit header field from subsequent packets
258will be provided as ancillary data along with the payload in subsequent
259.Xr recvmsg 2
260calls.
261The value is stored as an
262.Vt int
263in the ancillary data returned.
264.\" .It Dv IPV6_NEXTHOP Fa "int *"
265.\" Get or set whether the address of the next hop for subsequent
266.\" packets will be provided as ancillary data along with the payload in
267.\" subsequent
268.\" .Xr recvmsg 2
269.\" calls.
270.\" The option is stored as a
271.\" .Vt sockaddr
272.\" structure in the ancillary data returned.
273.\" .Pp
274.\" This option requires superuser privileges.
275.It Dv IPV6_HOPOPTS Fa "int *"
276Get or set whether the hop-by-hop options from subsequent packets will be
277provided as ancillary data along with the payload in subsequent
278.Xr recvmsg 2
279calls.
280The option is stored in the following structure in the ancillary data
281returned:
282.Bd -literal
283struct ip6_hbh {
284 u_int8_t ip6h_nxt; /* next header */
285 u_int8_t ip6h_len; /* length in units of 8 octets */
286/* followed by options */
287} __packed;
288.Ed
289.Pp
290The
291.Fn inet6_option_space
292routine and family of routines may be used to manipulate this data.
293.Pp
294This option requires superuser privileges.
295.It Dv IPV6_DSTOPTS Fa "int *"
296Get or set whether the destination options from subsequent packets will
297be provided as ancillary data along with the payload in subsequent
298.Xr recvmsg 2
299calls.
300The option is stored in the following structure in the ancillary data
301returned:
302.Bd -literal
303struct ip6_dest {
304 u_int8_t ip6d_nxt; /* next header */
305 u_int8_t ip6d_len; /* length in units of 8 octets */
306/* followed by options */
307} __packed;
308.Ed
309.Pp
310The
311.Fn inet6_option_space
312routine and family of routines may be used to manipulate this data.
313.Pp
314This option requires superuser privileges.
150.\" .It Dv IPV6_RECVOPTS Fa "int *"
151.\" Get or set the status of whether all header options will be
152.\" delivered along with the datagram when it is received.
153.\" .It Dv IPV6_RECVRETOPTS Fa "int *"
154.\" Get or set the status of whether header options will be delivered
155.\" for reply.
156.\" .It Dv IPV6_RECVDSTADDR Fa "int *"
157.\" Get or set the status of whether datagrams are received with
158.\" destination addresses.
159.\" .It Dv IPV6_RETOPTS
160.\" Get or set IPv6 options.
161.It Dv IPV6_MULTICAST_IF Fa "u_int *"
162Get or set the interface from which multicast packets will be sent.
163For hosts with multiple interfaces, each multicast transmission is sent
164from the primary network interface.
165The interface is specified as its index as provided by
166.Xr if_nametoindex 3 .
167A value of zero specifies the default interface.
168.It Dv IPV6_MULTICAST_HOPS Fa "int *"
169Get or set the default hop limit header field for outgoing multicast
170datagrams sent on this socket.
171This option controls the scope of multicast datagram transmissions.
172.Pp
173Datagrams with a hop limit of 1 are not forwarded beyond the local
174network.
175Multicast datagrams with a hop limit of zero will not be transmitted on
176any network but may be delivered locally if the sending host belongs to
177the destination group and if multicast loopback (see below) has not been
178disabled on the sending socket.
179Multicast datagrams with a hop limit greater than 1 may be forwarded to
180the other networks if a multicast router (such as
181.Xr mrouted 8 Pq Pa ports/net/mrouted )
182is attached to the local network.
183.It Dv IPV6_MULTICAST_LOOP Fa "u_int *"
184Get or set the status of whether multicast datagrams will be looped back
185for local delivery when a multicast datagram is sent to a group to which
186the sending host belongs.
187.Pp
188This option improves performance for applications that may have no more
189than one instance on a single host (such as a router daemon) by
190eliminating the overhead of receiving their own transmissions.
191It should generally not be used by applications for which there may be
192more than one instance on a single host (such as a conferencing program)
193or for which the sender does not belong to the destination group
194(such as a time-querying program).
195.Pp
196A multicast datagram sent with an initial hop limit greater than 1 may
197be delivered to the sending host on a different interface from that on
198which it was sent if the host belongs to the destination group on that
199other interface.
200The multicast loopback control option has no effect on such delivery.
201.It Dv IPV6_JOIN_GROUP Fa "struct ipv6_mreq *"
202Join a multicast group.
203A host must become a member of a multicast group before it can receive
204datagrams sent to the group.
205.Bd -literal
206struct ipv6_mreq {
207 struct in6_addr ipv6mr_multiaddr;
208 unsigned int ipv6mr_interface;
209};
210.Ed
211.Pp
212.Va ipv6mr_interface
213may be set to zeroes to choose the default multicast interface or to the
214index of a particular multicast-capable interface if the host is
215multihomed.
216Membership is associated with a single interface; programs running on
217multihomed hosts may need to join the same group on more than one
218interface.
219.Pp
220If the multicast address is unspecified (i.e., all zeroes), messages
221from all multicast addresses will be accepted by this group.
222Note that setting to this value requires superuser privileges.
223.It Dv IPV6_LEAVE_GROUP Fa "struct ipv6_mreq *"
224Drop membership from the associated multicast group.
225Memberships are automatically dropped when the socket is closed or when
226the process exits.
227.It Dv IPV6_PORTRANGE Fa "int *"
228Get or set the allocation policy of ephemeral ports for when the kernel
229automatically binds a local address to this socket.
230The following values are available:
231.Pp
232.Bl -tag -width IPV6_PORTRANGE_DEFAULT -compact
233.It Dv IPV6_PORTRANGE_DEFAULT
234Use the regular range of non-reserved ports (varies, see
235.Xr sysctl 8 ) .
236.It Dv IPV6_PORTRANGE_HIGH
237Use a high range (varies, see
238.Xr sysctl 8 ) .
239.It Dv IPV6_PORTRANGE_LOW
240Use a low, reserved range (600\-1023).
241.El
242.It Dv IPV6_PKTINFO Fa "int *"
243Get or set whether additional information about subsequent packets will
244be provided as ancillary data along with the payload in subsequent
245.Xr recvmsg 2
246calls.
247The information is stored in the following structure in the ancillary
248data returned:
249.Bd -literal
250struct in6_pktinfo {
251 struct in6_addr ipi6_addr; /* src/dst IPv6 address */
252 unsigned int ipi6_ifindex; /* send/recv if index */
253};
254.Ed
255.It Dv IPV6_HOPLIMIT Fa "int *"
256Get or set whether the hop limit header field from subsequent packets
257will be provided as ancillary data along with the payload in subsequent
258.Xr recvmsg 2
259calls.
260The value is stored as an
261.Vt int
262in the ancillary data returned.
263.\" .It Dv IPV6_NEXTHOP Fa "int *"
264.\" Get or set whether the address of the next hop for subsequent
265.\" packets will be provided as ancillary data along with the payload in
266.\" subsequent
267.\" .Xr recvmsg 2
268.\" calls.
269.\" The option is stored as a
270.\" .Vt sockaddr
271.\" structure in the ancillary data returned.
272.\" .Pp
273.\" This option requires superuser privileges.
274.It Dv IPV6_HOPOPTS Fa "int *"
275Get or set whether the hop-by-hop options from subsequent packets will be
276provided as ancillary data along with the payload in subsequent
277.Xr recvmsg 2
278calls.
279The option is stored in the following structure in the ancillary data
280returned:
281.Bd -literal
282struct ip6_hbh {
283 u_int8_t ip6h_nxt; /* next header */
284 u_int8_t ip6h_len; /* length in units of 8 octets */
285/* followed by options */
286} __packed;
287.Ed
288.Pp
289The
290.Fn inet6_option_space
291routine and family of routines may be used to manipulate this data.
292.Pp
293This option requires superuser privileges.
294.It Dv IPV6_DSTOPTS Fa "int *"
295Get or set whether the destination options from subsequent packets will
296be provided as ancillary data along with the payload in subsequent
297.Xr recvmsg 2
298calls.
299The option is stored in the following structure in the ancillary data
300returned:
301.Bd -literal
302struct ip6_dest {
303 u_int8_t ip6d_nxt; /* next header */
304 u_int8_t ip6d_len; /* length in units of 8 octets */
305/* followed by options */
306} __packed;
307.Ed
308.Pp
309The
310.Fn inet6_option_space
311routine and family of routines may be used to manipulate this data.
312.Pp
313This option requires superuser privileges.
314.It Dv IPV6_TCLASS Fa "int *"
315Get or set the value of the traffic class field used for outgoing datagrams
316on this socket.
317The value must be between \-1 and 255.
318A value of \-1 resets to the default value.
319.It Dv IPV6_RECVTCLASS Fa "int *"
320Get or set the status of whether the traffic class header field will be
321provided as ancillary data along with the payload in subsequent
322.Xr recvmsg 2
323calls.
324The header field is stored as a single value of type
325.Vt int .
315.It Dv IPV6_RTHDR Fa "int *"
316Get or set whether the routing header from subsequent packets will be
317provided as ancillary data along with the payload in subsequent
318.Xr recvmsg 2
319calls.
320The header is stored in the following structure in the ancillary data
321returned:
322.Bd -literal
323struct ip6_rthdr {
324 u_int8_t ip6r_nxt; /* next header */
325 u_int8_t ip6r_len; /* length in units of 8 octets */
326 u_int8_t ip6r_type; /* routing type */
327 u_int8_t ip6r_segleft; /* segments left */
328/* followed by routing-type-specific data */
329} __packed;
330.Ed
331.Pp
332The
333.Fn inet6_option_space
334routine and family of routines may be used to manipulate this data.
335.Pp
336This option requires superuser privileges.
337.It Dv IPV6_PKTOPTIONS Fa "struct cmsghdr *"
338Get or set all header options and extension headers at one time on the
339last packet sent or received on the socket.
340All options must fit within the size of an mbuf (see
341.Xr mbuf 9 ) .
342Options are specified as a series of
343.Vt cmsghdr
344structures followed by corresponding values.
345.Va cmsg_level
346is set to
347.Dv IPPROTO_IPV6 ,
348.Va cmsg_type
349to one of the other values in this list, and trailing data to the option
350value.
351When setting options, if the length
352.Va optlen
353to
354.Xr setsockopt 2
355is zero, all header options will be reset to their default values.
356Otherwise, the length should specify the size the series of control
357messages consumes.
358.Pp
359Instead of using
360.Xr sendmsg 2
361to specify option values, the ancillary data used in these calls that
362correspond to the desired header options may be directly specified as
363the control message in the series of control messages provided as the
364argument to
365.Xr setsockopt 2 .
366.It Dv IPV6_CHECKSUM Fa "int *"
367Get or set the byte offset into a packet where the 16-bit checksum is
368located.
369When set, this byte offset is where incoming packets will be expected
370to have checksums of their data stored and where outgoing packets will
371have checksums of their data computed and stored by the kernel.
372A value of \-1 specifies that no checksums will be checked on incoming
373packets and that no checksums will be computed or stored on outgoing
374packets.
375The offset of the checksum for ICMPv6 sockets cannot be relocated or
376turned off.
377.It Dv IPV6_V6ONLY Fa "int *"
378Get or set whether only IPv6 connections can be made to this socket.
379For wildcard sockets, this can restrict connections to IPv6 only.
380.\"With
381.\".Ox
382.\"IPv6 sockets are always IPv6-only, so the socket option is read-only
383.\"(not modifiable).
384.It Dv IPV6_FAITH Fa "int *"
385Get or set the status of whether
386.Xr faith 4
387connections can be made to this socket.
388.It Dv IPV6_USE_MIN_MTU Fa "int *"
389Get or set whether the minimal IPv6 maximum transmission unit (MTU) size
390will be used to avoid fragmentation from occurring for subsequent
391outgoing datagrams.
392.It Dv IPV6_AUTH_LEVEL Fa "int *"
393Get or set the
394.Xr ipsec 4
395authentication level.
396.It Dv IPV6_ESP_TRANS_LEVEL Fa "int *"
397Get or set the ESP transport level.
398.It Dv IPV6_ESP_NETWORK_LEVEL Fa "int *"
399Get or set the ESP encapsulation level.
400.It Dv IPV6_IPCOMP_LEVEL Fa "int *"
401Get or set the
402.Xr ipcomp 4
403level.
404.El
405.Pp
406The
407.Dv IPV6_PKTINFO ,
408.\" .Dv IPV6_NEXTHOP ,
409.Dv IPV6_HOPLIMIT ,
410.Dv IPV6_HOPOPTS ,
411.Dv IPV6_DSTOPTS ,
412and
413.Dv IPV6_RTHDR
414options will return ancillary data along with payload contents in subsequent
415.Xr recvmsg 2
416calls with
417.Va cmsg_level
418set to
419.Dv IPPROTO_IPV6
420and
421.Va cmsg_type
422set to respective option name value (e.g.,
423.Dv IPV6_HOPTLIMIT ) .
424These options may also be used directly as ancillary
425.Va cmsg_type
426values in
427.Xr sendmsg 2
428to set options on the packet being transmitted by the call.
429The
430.Va cmsg_level
431value must be
432.Dv IPPROTO_IPV6 .
433For these options, the ancillary data object value format is the same
434as the value returned as explained for each when received with
435.Xr recvmsg 2 .
436.Pp
437Note that using
438.Xr sendmsg 2
439to specify options on particular packets works only on UDP and raw sockets.
440To manipulate header options for packets on TCP sockets, only the socket
441options may be used.
442.Pp
443In some cases, there are multiple APIs defined for manipulating an IPv6
444header field.
445A good example is the outgoing interface for multicast datagrams, which
446can be set by the
447.Dv IPV6_MULTICAST_IF
448socket option, through the
449.Dv IPV6_PKTINFO
450option, and through the
451.Va sin6_scope_id
452field of the socket address passed to the
453.Xr sendto 2
454system call.
455.Pp
456Resolving these conflicts is implementation dependent.
457This implementation determines the value in the following way:
458options specified by using ancillary data (i.e.,
459.Xr sendmsg 2 )
460are considered first,
461options specified by using
462.Dv IPV6_PKTOPTIONS
463to set
464.Dq sticky
465options are considered second,
466options specified by using the individual, basic, and direct socket
467options (e.g.,
468.Dv IPV6_UNICAST_HOPS )
469are considered third,
470and options specified in the socket address supplied to
471.Xr sendto 2
472are the last choice.
473.Ss Multicasting
474IPv6 multicasting is supported only on
475.Dv AF_INET6
476sockets of type
477.Dv SOCK_DGRAM
478and
479.Dv SOCK_RAW ,
480and only on networks where the interface driver supports
481multicasting.
482Socket options (see above) that manipulate membership of
483multicast groups and other multicast options include
484.Dv IPV6_MULTICAST_IF ,
485.Dv IPV6_MULTICAST_HOPS ,
486.Dv IPV6_MULTICAST_LOOP ,
487.Dv IPV6_LEAVE_GROUP ,
488and
489.Dv IPV6_JOIN_GROUP .
490.Ss Raw Sockets
491Raw IPv6 sockets are connectionless and are normally used with the
492.Xr sendto 2
493and
494.Xr recvfrom 2
495calls, although the
496.Xr connect 2
497call may be used to fix the destination address for future outgoing
498packets so that
499.Xr send 2
500may instead be used and the
501.Xr bind 2
502call may be used to fix the source address for future outgoing
503packets instead of having the kernel choose a source address.
504.Pp
505By using
506.Xr connect 2
507or
508.Xr bind 2 ,
509raw socket input is constrained to only packets with their
510source address matching the socket destination address if
511.Xr connect 2
512was used and to packets with their destination address
513matching the socket source address if
514.Xr bind 2
515was used.
516.Pp
517If the
518.Ar proto
519argument to
520.Xr socket 2
521is zero, the default protocol
522.Pq Dv IPPROTO_RAW
523is used for outgoing packets.
524For incoming packets, protocols recognized by kernel are
525.Sy not
526passed to the application socket (e.g.,
527.Xr tcp 4
528and
529.Xr udp 4 )
530except for some ICMPv6 messages.
531The ICMPv6 messages not passed to raw sockets include echo, timestamp,
532and address mask requests.
533If
534.Ar proto
535is non-zero, only packets with this protocol will be passed to the
536socket.
537.Pp
538IPv6 fragments are also not passed to application sockets until
539they have been reassembled.
540If reception of all packets is desired, link-level access (such as
541.Xr bpf 4 )
542must be used instead.
543.Pp
544Outgoing packets automatically have an IPv6 header prepended to them
545(based on the destination address and the protocol number the socket
546was created with).
547Incoming packets are received by an application without the IPv6 header
548or any extension headers.
549.Pp
550Outgoing packets will be fragmented automatically by the kernel if they
551are too large.
552Incoming packets will be reassembled before being sent to the raw socket,
553so packet fragments or fragment headers will never be seen on a raw socket.
554.Sh EXAMPLES
555The following determines the hop limit on the next packet received:
556.Bd -literal
557struct iovec iov[2];
558u_char buf[BUFSIZ];
559struct cmsghdr *cm;
560struct msghdr m;
561int found, optval;
562u_char data[2048];
563
564/* Create socket. */
565
566(void)memset(&m, 0, sizeof(m));
567(void)memset(&iov, 0, sizeof(iov));
568
569iov[0].iov_base = data; /* buffer for packet payload */
570iov[0].iov_len = sizeof(data); /* expected packet length */
571
572m.msg_name = &from; /* sockaddr_in6 of peer */
573m.msg_namelen = sizeof(from);
574m.msg_iov = iov;
575m.msg_iovlen = 1;
576m.msg_control = (caddr_t)buf; /* buffer for control messages */
577m.msg_controllen = sizeof(buf);
578
579/*
580 * Enable the hop limit value from received packets to be
581 * returned along with the payload.
582 */
583optval = 1;
584if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &optval,
585 sizeof(optval)) == -1)
586 err(1, "setsockopt");
587
588found = 0;
589while (!found) {
590 if (recvmsg(s, &m, 0) == -1)
591 err(1, "recvmsg");
592 for (cm = CMSG_FIRSTHDR(&m); cm != NULL;
593 cm = CMSG_NXTHDR(&m, cm)) {
594 if (cm->cmsg_level == IPPROTO_IPV6 &&
595 cm->cmsg_type == IPV6_HOPLIMIT &&
596 cm->cmsg_len == CMSG_LEN(sizeof(int))) {
597 found = 1;
598 (void)printf("hop limit: %d\en",
599 *(int *)CMSG_DATA(cm));
600 break;
601 }
602 }
603}
604.Ed
605.Sh DIAGNOSTICS
606A socket operation may fail with one of the following errors returned:
607.Bl -tag -width EADDRNOTAVAILxx
608.It Bq Er EISCONN
609when trying to establish a connection on a socket which
610already has one or when trying to send a datagram with the destination
611address specified and the socket is already connected.
612.It Bq Er ENOTCONN
613when trying to send a datagram, but
614no destination address is specified, and the socket has not been
615connected.
616.It Bq Er ENOBUFS
617when the system runs out of memory for
618an internal data structure.
619.It Bq Er EADDRNOTAVAIL
620when an attempt is made to create a
621socket with a network address for which no network interface
622exists.
623.It Bq Er EACCES
624when an attempt is made to create
625a raw IPv6 socket by a non-privileged process.
626.El
627.Pp
628The following errors specific to IPv6 may occur when setting or getting
629header options:
630.Bl -tag -width EADDRNOTAVAILxx
631.It Bq Er EINVAL
632An unknown socket option name was given.
633.It Bq Er EINVAL
634An ancillary data object was improperly formed.
635.El
636.Sh SEE ALSO
637.Xr getsockopt 2 ,
638.Xr recv 2 ,
639.Xr send 2 ,
640.Xr setsockopt 2 ,
641.Xr socket 2 ,
642.\" .Xr inet6_option_space 3 ,
643.\" .Xr inet6_rthdr_space 3 ,
644.Xr if_nametoindex 3 ,
645.Xr bpf 4 ,
646.Xr icmp6 4 ,
647.Xr inet6 4 ,
648.Xr netintro 4 ,
649.Xr tcp 4 ,
650.Xr udp 4
651.Rs
652.%A W. Stevens
653.%A M. Thomas
654.%T Advanced Sockets API for IPv6
655.%R RFC 2292
656.%D February 1998
657.Re
658.Rs
659.%A S. Deering
660.%A R. Hinden
661.%T Internet Protocol, Version 6 (IPv6) Specification
662.%R RFC 2460
663.%D December 1998
664.Re
665.Rs
666.%A R. Gilligan
667.%A S. Thomson
668.%A J. Bound
669.%A W. Stevens
670.%T Basic Socket Interface Extensions for IPv6
671.%R RFC 2553
672.%D March 1999
673.Re
674.Rs
675.%A W. Stevens
676.%A B. Fenner
677.%A A. Rudoff
678.%T UNIX Network Programming, third edition
679.Re
680.Sh STANDARDS
681Most of the socket options are defined in RFC 2292 or RFC 2553.
682The
683.Dv IPV6_V6ONLY
684socket option is defined in RFC 3542.
685The
686.Dv IPV6_PORTRANGE
687socket option and the conflict resolution rule are not defined in the
688RFCs and should be considered implementation dependent.
326.It Dv IPV6_RTHDR Fa "int *"
327Get or set whether the routing header from subsequent packets will be
328provided as ancillary data along with the payload in subsequent
329.Xr recvmsg 2
330calls.
331The header is stored in the following structure in the ancillary data
332returned:
333.Bd -literal
334struct ip6_rthdr {
335 u_int8_t ip6r_nxt; /* next header */
336 u_int8_t ip6r_len; /* length in units of 8 octets */
337 u_int8_t ip6r_type; /* routing type */
338 u_int8_t ip6r_segleft; /* segments left */
339/* followed by routing-type-specific data */
340} __packed;
341.Ed
342.Pp
343The
344.Fn inet6_option_space
345routine and family of routines may be used to manipulate this data.
346.Pp
347This option requires superuser privileges.
348.It Dv IPV6_PKTOPTIONS Fa "struct cmsghdr *"
349Get or set all header options and extension headers at one time on the
350last packet sent or received on the socket.
351All options must fit within the size of an mbuf (see
352.Xr mbuf 9 ) .
353Options are specified as a series of
354.Vt cmsghdr
355structures followed by corresponding values.
356.Va cmsg_level
357is set to
358.Dv IPPROTO_IPV6 ,
359.Va cmsg_type
360to one of the other values in this list, and trailing data to the option
361value.
362When setting options, if the length
363.Va optlen
364to
365.Xr setsockopt 2
366is zero, all header options will be reset to their default values.
367Otherwise, the length should specify the size the series of control
368messages consumes.
369.Pp
370Instead of using
371.Xr sendmsg 2
372to specify option values, the ancillary data used in these calls that
373correspond to the desired header options may be directly specified as
374the control message in the series of control messages provided as the
375argument to
376.Xr setsockopt 2 .
377.It Dv IPV6_CHECKSUM Fa "int *"
378Get or set the byte offset into a packet where the 16-bit checksum is
379located.
380When set, this byte offset is where incoming packets will be expected
381to have checksums of their data stored and where outgoing packets will
382have checksums of their data computed and stored by the kernel.
383A value of \-1 specifies that no checksums will be checked on incoming
384packets and that no checksums will be computed or stored on outgoing
385packets.
386The offset of the checksum for ICMPv6 sockets cannot be relocated or
387turned off.
388.It Dv IPV6_V6ONLY Fa "int *"
389Get or set whether only IPv6 connections can be made to this socket.
390For wildcard sockets, this can restrict connections to IPv6 only.
391.\"With
392.\".Ox
393.\"IPv6 sockets are always IPv6-only, so the socket option is read-only
394.\"(not modifiable).
395.It Dv IPV6_FAITH Fa "int *"
396Get or set the status of whether
397.Xr faith 4
398connections can be made to this socket.
399.It Dv IPV6_USE_MIN_MTU Fa "int *"
400Get or set whether the minimal IPv6 maximum transmission unit (MTU) size
401will be used to avoid fragmentation from occurring for subsequent
402outgoing datagrams.
403.It Dv IPV6_AUTH_LEVEL Fa "int *"
404Get or set the
405.Xr ipsec 4
406authentication level.
407.It Dv IPV6_ESP_TRANS_LEVEL Fa "int *"
408Get or set the ESP transport level.
409.It Dv IPV6_ESP_NETWORK_LEVEL Fa "int *"
410Get or set the ESP encapsulation level.
411.It Dv IPV6_IPCOMP_LEVEL Fa "int *"
412Get or set the
413.Xr ipcomp 4
414level.
415.El
416.Pp
417The
418.Dv IPV6_PKTINFO ,
419.\" .Dv IPV6_NEXTHOP ,
420.Dv IPV6_HOPLIMIT ,
421.Dv IPV6_HOPOPTS ,
422.Dv IPV6_DSTOPTS ,
423and
424.Dv IPV6_RTHDR
425options will return ancillary data along with payload contents in subsequent
426.Xr recvmsg 2
427calls with
428.Va cmsg_level
429set to
430.Dv IPPROTO_IPV6
431and
432.Va cmsg_type
433set to respective option name value (e.g.,
434.Dv IPV6_HOPTLIMIT ) .
435These options may also be used directly as ancillary
436.Va cmsg_type
437values in
438.Xr sendmsg 2
439to set options on the packet being transmitted by the call.
440The
441.Va cmsg_level
442value must be
443.Dv IPPROTO_IPV6 .
444For these options, the ancillary data object value format is the same
445as the value returned as explained for each when received with
446.Xr recvmsg 2 .
447.Pp
448Note that using
449.Xr sendmsg 2
450to specify options on particular packets works only on UDP and raw sockets.
451To manipulate header options for packets on TCP sockets, only the socket
452options may be used.
453.Pp
454In some cases, there are multiple APIs defined for manipulating an IPv6
455header field.
456A good example is the outgoing interface for multicast datagrams, which
457can be set by the
458.Dv IPV6_MULTICAST_IF
459socket option, through the
460.Dv IPV6_PKTINFO
461option, and through the
462.Va sin6_scope_id
463field of the socket address passed to the
464.Xr sendto 2
465system call.
466.Pp
467Resolving these conflicts is implementation dependent.
468This implementation determines the value in the following way:
469options specified by using ancillary data (i.e.,
470.Xr sendmsg 2 )
471are considered first,
472options specified by using
473.Dv IPV6_PKTOPTIONS
474to set
475.Dq sticky
476options are considered second,
477options specified by using the individual, basic, and direct socket
478options (e.g.,
479.Dv IPV6_UNICAST_HOPS )
480are considered third,
481and options specified in the socket address supplied to
482.Xr sendto 2
483are the last choice.
484.Ss Multicasting
485IPv6 multicasting is supported only on
486.Dv AF_INET6
487sockets of type
488.Dv SOCK_DGRAM
489and
490.Dv SOCK_RAW ,
491and only on networks where the interface driver supports
492multicasting.
493Socket options (see above) that manipulate membership of
494multicast groups and other multicast options include
495.Dv IPV6_MULTICAST_IF ,
496.Dv IPV6_MULTICAST_HOPS ,
497.Dv IPV6_MULTICAST_LOOP ,
498.Dv IPV6_LEAVE_GROUP ,
499and
500.Dv IPV6_JOIN_GROUP .
501.Ss Raw Sockets
502Raw IPv6 sockets are connectionless and are normally used with the
503.Xr sendto 2
504and
505.Xr recvfrom 2
506calls, although the
507.Xr connect 2
508call may be used to fix the destination address for future outgoing
509packets so that
510.Xr send 2
511may instead be used and the
512.Xr bind 2
513call may be used to fix the source address for future outgoing
514packets instead of having the kernel choose a source address.
515.Pp
516By using
517.Xr connect 2
518or
519.Xr bind 2 ,
520raw socket input is constrained to only packets with their
521source address matching the socket destination address if
522.Xr connect 2
523was used and to packets with their destination address
524matching the socket source address if
525.Xr bind 2
526was used.
527.Pp
528If the
529.Ar proto
530argument to
531.Xr socket 2
532is zero, the default protocol
533.Pq Dv IPPROTO_RAW
534is used for outgoing packets.
535For incoming packets, protocols recognized by kernel are
536.Sy not
537passed to the application socket (e.g.,
538.Xr tcp 4
539and
540.Xr udp 4 )
541except for some ICMPv6 messages.
542The ICMPv6 messages not passed to raw sockets include echo, timestamp,
543and address mask requests.
544If
545.Ar proto
546is non-zero, only packets with this protocol will be passed to the
547socket.
548.Pp
549IPv6 fragments are also not passed to application sockets until
550they have been reassembled.
551If reception of all packets is desired, link-level access (such as
552.Xr bpf 4 )
553must be used instead.
554.Pp
555Outgoing packets automatically have an IPv6 header prepended to them
556(based on the destination address and the protocol number the socket
557was created with).
558Incoming packets are received by an application without the IPv6 header
559or any extension headers.
560.Pp
561Outgoing packets will be fragmented automatically by the kernel if they
562are too large.
563Incoming packets will be reassembled before being sent to the raw socket,
564so packet fragments or fragment headers will never be seen on a raw socket.
565.Sh EXAMPLES
566The following determines the hop limit on the next packet received:
567.Bd -literal
568struct iovec iov[2];
569u_char buf[BUFSIZ];
570struct cmsghdr *cm;
571struct msghdr m;
572int found, optval;
573u_char data[2048];
574
575/* Create socket. */
576
577(void)memset(&m, 0, sizeof(m));
578(void)memset(&iov, 0, sizeof(iov));
579
580iov[0].iov_base = data; /* buffer for packet payload */
581iov[0].iov_len = sizeof(data); /* expected packet length */
582
583m.msg_name = &from; /* sockaddr_in6 of peer */
584m.msg_namelen = sizeof(from);
585m.msg_iov = iov;
586m.msg_iovlen = 1;
587m.msg_control = (caddr_t)buf; /* buffer for control messages */
588m.msg_controllen = sizeof(buf);
589
590/*
591 * Enable the hop limit value from received packets to be
592 * returned along with the payload.
593 */
594optval = 1;
595if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &optval,
596 sizeof(optval)) == -1)
597 err(1, "setsockopt");
598
599found = 0;
600while (!found) {
601 if (recvmsg(s, &m, 0) == -1)
602 err(1, "recvmsg");
603 for (cm = CMSG_FIRSTHDR(&m); cm != NULL;
604 cm = CMSG_NXTHDR(&m, cm)) {
605 if (cm->cmsg_level == IPPROTO_IPV6 &&
606 cm->cmsg_type == IPV6_HOPLIMIT &&
607 cm->cmsg_len == CMSG_LEN(sizeof(int))) {
608 found = 1;
609 (void)printf("hop limit: %d\en",
610 *(int *)CMSG_DATA(cm));
611 break;
612 }
613 }
614}
615.Ed
616.Sh DIAGNOSTICS
617A socket operation may fail with one of the following errors returned:
618.Bl -tag -width EADDRNOTAVAILxx
619.It Bq Er EISCONN
620when trying to establish a connection on a socket which
621already has one or when trying to send a datagram with the destination
622address specified and the socket is already connected.
623.It Bq Er ENOTCONN
624when trying to send a datagram, but
625no destination address is specified, and the socket has not been
626connected.
627.It Bq Er ENOBUFS
628when the system runs out of memory for
629an internal data structure.
630.It Bq Er EADDRNOTAVAIL
631when an attempt is made to create a
632socket with a network address for which no network interface
633exists.
634.It Bq Er EACCES
635when an attempt is made to create
636a raw IPv6 socket by a non-privileged process.
637.El
638.Pp
639The following errors specific to IPv6 may occur when setting or getting
640header options:
641.Bl -tag -width EADDRNOTAVAILxx
642.It Bq Er EINVAL
643An unknown socket option name was given.
644.It Bq Er EINVAL
645An ancillary data object was improperly formed.
646.El
647.Sh SEE ALSO
648.Xr getsockopt 2 ,
649.Xr recv 2 ,
650.Xr send 2 ,
651.Xr setsockopt 2 ,
652.Xr socket 2 ,
653.\" .Xr inet6_option_space 3 ,
654.\" .Xr inet6_rthdr_space 3 ,
655.Xr if_nametoindex 3 ,
656.Xr bpf 4 ,
657.Xr icmp6 4 ,
658.Xr inet6 4 ,
659.Xr netintro 4 ,
660.Xr tcp 4 ,
661.Xr udp 4
662.Rs
663.%A W. Stevens
664.%A M. Thomas
665.%T Advanced Sockets API for IPv6
666.%R RFC 2292
667.%D February 1998
668.Re
669.Rs
670.%A S. Deering
671.%A R. Hinden
672.%T Internet Protocol, Version 6 (IPv6) Specification
673.%R RFC 2460
674.%D December 1998
675.Re
676.Rs
677.%A R. Gilligan
678.%A S. Thomson
679.%A J. Bound
680.%A W. Stevens
681.%T Basic Socket Interface Extensions for IPv6
682.%R RFC 2553
683.%D March 1999
684.Re
685.Rs
686.%A W. Stevens
687.%A B. Fenner
688.%A A. Rudoff
689.%T UNIX Network Programming, third edition
690.Re
691.Sh STANDARDS
692Most of the socket options are defined in RFC 2292 or RFC 2553.
693The
694.Dv IPV6_V6ONLY
695socket option is defined in RFC 3542.
696The
697.Dv IPV6_PORTRANGE
698socket option and the conflict resolution rule are not defined in the
699RFCs and should be considered implementation dependent.