]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man4/icmp6.4
xnu-3789.70.16.tar.gz
[apple/xnu.git] / bsd / man / man4 / icmp6.4
CommitLineData
91447636
A
1.\" $NetBSD: icmp6.4,v 1.13 2005/01/11 06:01:41 itojun Exp $
2.\" $KAME: icmp6.4,v 1.6 2004/12/27 05:30:56 itojun Exp $
3.\" $OpenBSD: icmp6.4,v 1.19 2004/12/23 20:33:03 jaredy Exp $
9bccf70c
A
4.\"
5.\" Copyright (c) 1986, 1991, 1993
91447636 6.\" The Regents of the University of California. All rights reserved.
9bccf70c
A
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
91447636 16.\" 3. Neither the name of the University nor the names of its contributors
9bccf70c
A
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
91447636 31.Dd December 20, 2004
9bccf70c
A
32.Dt ICMP6 4
33.Os
9bccf70c
A
34.Sh NAME
35.Nm icmp6
36.Nd Internet Control Message Protocol for IPv6
9bccf70c 37.Sh SYNOPSIS
9bccf70c
A
38.In sys/socket.h
39.In netinet/in.h
40.In netinet/icmp6.h
41.Ft int
91447636 42.Fn socket AF_INET6 SOCK_RAW IPPROTO_ICMPV6
9bccf70c 43.Sh DESCRIPTION
91447636
A
44ICMPv6 is the error and control message protocol used by IPv6 and the
45IPv6 protocol family (see
46.Xr ip6 4
47and
48.Xr inet6 4 ) .
9bccf70c
A
49It may be accessed through a
50.Dq raw socket
51for network monitoring and diagnostic functions.
91447636 52.Pp
9bccf70c
A
53The
54.Fa proto
91447636
A
55parameter to the
56.Xr socket 2
57call to create an ICMPv6 socket may be obtained from
58.Xr getprotobyname 3 .
59ICMPv6 sockets are connectionless, and are normally used with the
9bccf70c
A
60.Xr sendto 2
61and
62.Xr recvfrom 2
63calls, though the
64.Xr connect 2
65call may also be used to fix the destination for future packets
91447636 66(in which case
9bccf70c
A
67.Xr read 2
68or
69.Xr recv 2
70and
71.Xr write 2
72or
73.Xr send 2
74system calls may be used).
75.Pp
91447636 76Outgoing packets automatically have an IPv6 header prepended to them
9bccf70c 77(based on the destination address).
91447636
A
78Incoming packets on the socket are received with the IPv6 header and any
79extension headers removed.
80.Ss Types
81ICMPv6 messages are classified according to the type and code fields
82present in the ICMPv6 header.
83The abbreviations for the types and codes may be used in rules in
84.Xr pf.conf 5 .
85The following types are defined:
86.Bl -column x xxxxxxxxxxxx -offset indent
87.It Sy Num Ta Sy Abbrev. Ta Sy Description
88.It 1 Ta unreach Ta "Destination unreachable"
89.It 2 Ta toobig Ta "Packet too big"
90.It 3 Ta timex Ta "Time exceeded"
91.It 4 Ta paramprob Ta "Invalid IPv6 header"
92.It 128 Ta echoreq Ta "Echo service request"
93.It 129 Ta echorep Ta "Echo service reply"
94.It 130 Ta groupqry Ta "Group membership query"
95.It 130 Ta listqry Ta "Multicast listener query"
96.It 131 Ta grouprep Ta "Group membership report"
97.It 131 Ta listenrep Ta "Multicast listener report"
98.It 132 Ta groupterm Ta "Group membership termination"
99.It 132 Ta listendone Ta "Multicast listerner done"
100.It 133 Ta routersol Ta "Router solicitation"
101.It 134 Ta routeradv Ta "Router advertisement"
102.It 135 Ta neighbrsol Ta "Neighbor solicitation"
103.It 136 Ta neighbradv Ta "Neighbor advertisement"
104.It 137 Ta redir Ta "Shorter route exists"
105.It 138 Ta routrrenum Ta "Route renumbering"
106.It 139 Ta fqdnreq Ta "FQDN query"
107.It 139 Ta niqry Ta "Node information query"
108.It 139 Ta wrureq Ta "Who-are-you request"
109.It 140 Ta fqdnrep Ta "FQDN reply"
110.It 140 Ta nirep Ta "Node information reply"
111.It 140 Ta wrurep Ta "Who-are-you reply"
112.It 200 Ta mtraceresp Ta "mtrace response"
113.It 201 Ta mtrace Ta "mtrace messages"
114.El
115.Pp
116The following codes are defined:
117.Bl -column x xxxxxxxxxxxx xxxxxxxx -offset indent
118.It Sy Num Ta Sy Abbrev. Ta Sy Type Ta
119.Sy Description
120.It 0 Ta noroute-unr Ta unreach Ta "No route to destination"
121.It 1 Ta admin-unr Ta unreach Ta "Administratively prohibited"
122.It 2 Ta beyond-unr Ta unreach Ta "Beyond scope of source address"
123.It 2 Ta notnbr-unr Ta unreach Ta "Not a neighbor (obselete)"
124.It 3 Ta addr-unr Ta unreach Ta "Address unreachable"
125.It 4 Ta port-unr Ta unreach Ta "Port unreachable"
126.It 0 Ta transit Ta timex Ta "Time exceeded in transit"
127.It 1 Ta reassemb Ta timex Ta "Time exceeded in reassembly"
128.It 0 Ta badhead Ta paramprob Ta "Erroneous header field"
129.It 1 Ta nxthdr Ta paramprob Ta "Unrecognized next header"
130.It 2 Ta "" Ta redir Ta "Unrecognized option"
131.It 0 Ta redironlink Ta redir Ta "Redirection to on-link node"
132.It 1 Ta redirrouter Ta redir Ta "Redirection to better router"
133.El
134.Ss Headers
135All ICMPv6 messages are prefixed with an ICMPv6 header.
136This header corresponds to the
137.Vt icmp6_hdr
138structure and has the following definition:
139.Bd -literal -offset indent
140struct icmp6_hdr {
141 u_int8_t icmp6_type; /* type field */
142 u_int8_t icmp6_code; /* code field */
143 u_int16_t icmp6_cksum; /* checksum field */
144 union {
145 u_int32_t icmp6_un_data32[1]; /* type-specific */
146 u_int16_t icmp6_un_data16[2]; /* type-specific */
147 u_int8_t icmp6_un_data8[4]; /* type-specific */
148 } icmp6_dataun;
149} __packed;
150
151#define icmp6_data32 icmp6_dataun.icmp6_un_data32
152#define icmp6_data16 icmp6_dataun.icmp6_un_data16
153#define icmp6_data8 icmp6_dataun.icmp6_un_data8
154#define icmp6_pptr icmp6_data32[0] /* parameter prob */
155#define icmp6_mtu icmp6_data32[0] /* packet too big */
156#define icmp6_id icmp6_data16[0] /* echo request/reply */
157#define icmp6_seq icmp6_data16[1] /* echo request/reply */
158#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership*/
159.Ed
9bccf70c 160.Pp
91447636
A
161.Va icmp6_type
162describes the type of the message.
163Suitable values are defined in
164.Aq Pa netinet/icmp6.h .
165.Va icmp6_code
166describes the sub-type of the message and depends on
167.Va icmp6_type .
168.Va icmp6_cksum
169contains the checksum for the message and is filled in by the
170kernel on outgoing messages.
171The other fields are used for type-specific purposes.
172.Ss Filters
173Because of the extra functionality of ICMPv6 in comparison to ICMPv4,
174a larger number of messages may be potentially received on an ICMPv6
175socket.
176Input filters may therefore be used to restrict input to a subset of the
177incoming ICMPv6 messages so only interesting messages are returned by the
178.Xr recv 2
179family of calls to an application.
9bccf70c 180.Pp
91447636
A
181The
182.Vt icmp6_filter
183structure may be used to refine the input message set according to the
184ICMPv6 type.
185By default, all messages types are allowed on newly created raw ICMPv6
186sockets.
187The following macros may be used to refine the input set:
188.Bl -tag -width Ds
189.It Fn "void ICMP6_FILTER_SETPASSALL" "struct icmp6_filter *filterp"
190Allow all incoming messages.
191.Va filterp
192is modified to allow all message types.
193.It Fn "void ICMP6_FILTER_SETBLOCKALL" "struct icmp6_filter *filterp"
194Ignore all incoming messages.
195.Va filterp
196is modified to ignore all message types.
197.It Fn "void ICMP6_FILTER_SETPASS" "int type" \
198 "struct icmp6_filter *filterp"
199Allow ICMPv6 messages with the given
200.Fa type .
201.Va filterp
202is modified to allow such messages.
203.It Fn "void ICMP6_FILTER_SETBLOCK" "int type" \
204 "struct icmp6_filter *filterp"
205Ignore ICMPv6 messages with the given
206.Fa type .
207.Va filterp
208is modified to ignore such messages.
209.It Fn "int ICMP6_FILTER_WILLPASS" "int type" \
210 "const struct icmp6_filter *filterp"
211Determine if the given filter will allow an ICMPv6 message of the given
212type.
213.It Fn "int ICMP6_FILTER_WILLBLOCK" "int type" \
214 "const struct icmp6_filter *filterp"
215Determine if the given filter will ignore an ICMPv6 message of the given
216type.
217.El
9bccf70c 218.Pp
91447636 219The
9bccf70c
A
220.Xr getsockopt 2
221and
222.Xr setsockopt 2
91447636
A
223calls may be used to obtain and install the filter on ICMPv6 sockets at
224option level
9bccf70c 225.Dv IPPROTO_ICMPV6
91447636
A
226and name
227.Dv ICMPV6_FILTER
228with a pointer to the
229.Vt icmp6_filter
230structure as the option value.
2d21ac55
A
231.Ss "Non-privileged ICMPv6"
232.Pp
233.Tn ICMPv6
234sockets can be opened with the
235.Dv SOCK_DGRAM
236socket type without requiring root privileges. The synopsis is the following:
237.Pp
6d2010ae 238.Fn socket AF_INET6 SOCK_DGRAM IPPROTO_ICMPV6
2d21ac55
A
239.Pp
240This can only be used to send
241.Tn ICMPv6
242echo requests to gauge the quality of the connectivity to a host, to receive
243destination unreachable message for path MTU discovery, or to receveive
244time exceeded message for traceroute.
245.Pp
246A socket opened with superuser privileges can send any kind of
247.Tn ICMPv6
248message and can also use the
249.Xr ip6 4
250options that require superuser privileges.
9bccf70c 251.Sh SEE ALSO
91447636 252.Xr getsockopt 2 ,
9bccf70c
A
253.Xr recv 2 ,
254.Xr send 2 ,
91447636
A
255.Xr setsockopt 2 ,
256.Xr socket 2 ,
257.Xr getprotobyname 3 ,
9bccf70c 258.Xr inet6 4 ,
91447636
A
259.Xr ip6 4 ,
260.Xr netintro 4
9bccf70c
A
261.Rs
262.%A W. Stevens
263.%A M. Thomas
91447636
A
264.%T Advanced Sockets API for IPv6
265.%N RFC 2292
9bccf70c 266.%D February 1998
9bccf70c
A
267.Re
268.Rs
269.%A A. Conta
270.%A S. Deering
91447636
A
271.%T "Internet Control Message Protocol (ICMPv6) for the Internet" \
272 "Protocol Version 6 (IPv6) Specification"
273.%N RFC 2463
9bccf70c 274.%D December 1998
9bccf70c 275.Re