1.\" $KAME: icmp6.4,v 1.6 2004/12/27 05:30:56 itojun Exp $ 2.\" $OpenBSD: icmp6.4,v 1.19 2004/12/23 20:33:03 jaredy Exp $ 3.\" 4.\" Copyright (c) 1986, 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$ 32.\" 33.Dd November 7, 2012 34.Dt ICMP6 4 35.Os 36.Sh NAME 37.Nm icmp6 38.Nd Internet Control Message Protocol for IPv6 39.Sh SYNOPSIS 40.In sys/socket.h 41.In netinet/in.h 42.In netinet/icmp6.h 43.Ft int 44.Fn socket AF_INET6 SOCK_RAW IPPROTO_ICMPV6 45.Sh DESCRIPTION 46ICMPv6 is the error and control message protocol used by IPv6 and the 47IPv6 protocol family (see 48.Xr ip6 4 49and 50.Xr inet6 4 ) . 51It may be accessed through a 52.Dq raw socket 53for network monitoring and diagnostic functions. 54.Pp 55The 56.Fa proto 57parameter to the 58.Xr socket 2 59call to create an ICMPv6 socket may be obtained from 60.Xr getprotobyname 3 . 61ICMPv6 sockets are connectionless, and are normally used with the 62.Xr sendto 2 63and 64.Xr recvfrom 2 65calls, though the 66.Xr connect 2 67call may also be used to fix the destination for future packets 68(in which case 69.Xr read 2 70or 71.Xr recv 2 72and 73.Xr write 2 74or 75.Xr send 2 76system calls may be used). 77.Pp 78Outgoing packets automatically have an IPv6 header prepended to them 79(based on the destination address). 80Incoming packets on the socket are received with the IPv6 header and any 81extension headers removed. 82.Ss Types 83ICMPv6 messages are classified according to the type and code fields 84present in the ICMPv6 header. 85The abbreviations for the types and codes may be used in rules in 86.Xr pf.conf 5 . 87The following types are defined: 88.Bl -column x xxxxxxxxxxxx -offset indent 89.It Sy Num Ta Sy Abbrev. Ta Sy Description 90.It 1 Ta unreach Ta "Destination unreachable" 91.It 2 Ta toobig Ta "Packet too big" 92.It 3 Ta timex Ta "Time exceeded" 93.It 4 Ta paramprob Ta "Invalid IPv6 header" 94.It 128 Ta echoreq Ta "Echo service request" 95.It 129 Ta echorep Ta "Echo service reply" 96.It 130 Ta groupqry Ta "Group membership query" 97.It 130 Ta listqry Ta "Multicast listener query" 98.It 131 Ta grouprep Ta "Group membership report" 99.It 131 Ta listenrep Ta "Multicast listener report" 100.It 132 Ta groupterm Ta "Group membership termination" 101.It 132 Ta listendone Ta "Multicast listener done" 102.It 133 Ta routersol Ta "Router solicitation" 103.It 134 Ta routeradv Ta "Router advertisement" 104.It 135 Ta neighbrsol Ta "Neighbor solicitation" 105.It 136 Ta neighbradv Ta "Neighbor advertisement" 106.It 137 Ta redir Ta "Shorter route exists" 107.It 138 Ta routrrenum Ta "Route renumbering" 108.It 139 Ta fqdnreq Ta "FQDN query" 109.It 139 Ta niqry Ta "Node information query" 110.It 139 Ta wrureq Ta "Who-are-you request" 111.It 140 Ta fqdnrep Ta "FQDN reply" 112.It 140 Ta nirep Ta "Node information reply" 113.It 140 Ta wrurep Ta "Who-are-you reply" 114.It 200 Ta mtraceresp Ta "mtrace response" 115.It 201 Ta mtrace Ta "mtrace messages" 116.El 117.Pp 118The following codes are defined: 119.Bl -column x xxxxxxxxxxxx xxxxxxxx -offset indent 120.It Sy Num Ta Sy Abbrev. Ta Sy Type Ta 121.Sy Description 122.It 0 Ta noroute-unr Ta unreach Ta "No route to destination" 123.It 1 Ta admin-unr Ta unreach Ta "Administratively prohibited" 124.It 2 Ta beyond-unr Ta unreach Ta "Beyond scope of source address" 125.It 2 Ta notnbr-unr Ta unreach Ta "Not a neighbor (obsolete)" 126.It 3 Ta addr-unr Ta unreach Ta "Address unreachable" 127.It 4 Ta port-unr Ta unreach Ta "Port unreachable" 128.It 0 Ta transit Ta timex Ta "Time exceeded in transit" 129.It 1 Ta reassemb Ta timex Ta "Time exceeded in reassembly" 130.It 0 Ta badhead Ta paramprob Ta "Erroneous header field" 131.It 1 Ta nxthdr Ta paramprob Ta "Unrecognized next header" 132.It 2 Ta "" Ta redir Ta "Unrecognized option" 133.It 0 Ta redironlink Ta redir Ta "Redirection to on-link node" 134.It 1 Ta redirrouter Ta redir Ta "Redirection to better router" 135.El 136.Ss Headers 137All ICMPv6 messages are prefixed with an ICMPv6 header. 138This header corresponds to the 139.Vt icmp6_hdr 140structure and has the following definition: 141.Bd -literal -offset indent 142struct icmp6_hdr { 143 uint8_t icmp6_type; /* type field */ 144 uint8_t icmp6_code; /* code field */ 145 uint16_t icmp6_cksum; /* checksum field */ 146 union { 147 uint32_t icmp6_un_data32[1]; /* type-specific */ 148 uint16_t icmp6_un_data16[2]; /* type-specific */ 149 uint8_t icmp6_un_data8[4]; /* type-specific */ 150 } icmp6_dataun; 151} __packed; 152 153#define icmp6_data32 icmp6_dataun.icmp6_un_data32 154#define icmp6_data16 icmp6_dataun.icmp6_un_data16 155#define icmp6_data8 icmp6_dataun.icmp6_un_data8 156#define icmp6_pptr icmp6_data32[0] /* parameter prob */ 157#define icmp6_mtu icmp6_data32[0] /* packet too big */ 158#define icmp6_id icmp6_data16[0] /* echo request/reply */ 159#define icmp6_seq icmp6_data16[1] /* echo request/reply */ 160#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership*/ 161.Ed 162.Pp 163.Va icmp6_type 164describes the type of the message. 165Suitable values are defined in 166.Aq Pa netinet/icmp6.h . 167.Va icmp6_code 168describes the sub-type of the message and depends on 169.Va icmp6_type . 170.Va icmp6_cksum 171contains the checksum for the message and is filled in by the 172kernel on outgoing messages. 173The other fields are used for type-specific purposes. 174.Ss Filters 175Because of the extra functionality of ICMPv6 in comparison to ICMPv4, 176a larger number of messages may be potentially received on an ICMPv6 177socket. 178Input filters may therefore be used to restrict input to a subset of the 179incoming ICMPv6 messages so only interesting messages are returned by the 180.Xr recv 2 181family of calls to an application. 182.Pp 183The 184.Vt icmp6_filter 185structure may be used to refine the input message set according to the 186ICMPv6 type. 187By default, all messages types are allowed on newly created raw ICMPv6 188sockets. 189The following macros may be used to refine the input set: 190.Bl -tag -width Ds 191.It Fn "void ICMP6_FILTER_SETPASSALL" "struct icmp6_filter *filterp" 192Allow all incoming messages. 193.Va filterp 194is modified to allow all message types. 195.It Fn "void ICMP6_FILTER_SETBLOCKALL" "struct icmp6_filter *filterp" 196Ignore all incoming messages. 197.Va filterp 198is modified to ignore all message types. 199.It Xo 200.Ft void 201.Fn ICMP6_FILTER_SETPASS "int type" "struct icmp6_filter *filterp" 202.Xc 203Allow ICMPv6 messages with the given 204.Fa type . 205.Va filterp 206is modified to allow such messages. 207.It Xo 208.Ft void 209.Fn ICMP6_FILTER_SETBLOCK" "int type" "struct icmp6_filter *filterp" 210.Xc 211Ignore ICMPv6 messages with the given 212.Fa type . 213.Va filterp 214is modified to ignore such messages. 215.It Xo 216.Ft int 217.Fn ICMP6_FILTER_WILLPASS" "int type" "const struct icmp6_filter *filterp" 218.Xc 219Determine if the given filter will allow an ICMPv6 message of the given 220type. 221.It Xo 222.Ft int 223.Fn ICMP6_FILTER_WILLBLOCK" "int type" "const struct icmp6_filter *filterp" 224.Xc 225Determine if the given filter will ignore an ICMPv6 message of the given 226type. 227.El 228.Pp 229The 230.Xr getsockopt 2 231and 232.Xr setsockopt 2 233calls may be used to obtain and install the filter on ICMPv6 sockets at 234option level 235.Dv IPPROTO_ICMPV6 236and name 237.Dv ICMP6_FILTER 238with a pointer to the 239.Vt icmp6_filter 240structure as the option value. 241.Sh SEE ALSO 242.Xr getsockopt 2 , 243.Xr recv 2 , 244.Xr send 2 , 245.Xr setsockopt 2 , 246.Xr socket 2 , 247.Xr getprotobyname 3 , 248.Xr inet6 4 , 249.Xr ip6 4 , 250.Xr netintro 4 251.Rs 252.%A W. Stevens 253.%A M. Thomas 254.%T Advanced Sockets API for IPv6 255.%N RFC 2292 256.%D February 1998 257.Re 258.Rs 259.%A A. Conta 260.%A S. Deering 261.%T "Internet Control Message Protocol (ICMPv6) for the Internet" \ 262 "Protocol Version 6 (IPv6) Specification" 263.%N RFC 2463 264.%D December 1998 265.Re 266