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