ICMPv6 is the error and control message protocol used by IPv6 and the
IPv6 protocol family (see
ip6(4)
and
inet6(4)).
It may be accessed through a
``raw socket''
for network monitoring and diagnostic functions.
The
Fa proto
parameter to the
socket(2)
call to create an ICMPv6 socket may be obtained from
getprotobyname(3).
ICMPv6 sockets are connectionless, and are normally used with the
sendto(2)
and
recvfrom(2)
calls, though the
connect(2)
call may also be used to fix the destination for future packets
(in which case
read(2)
or
recv(2)
and
write(2)
or
send(2)
system calls may be used).
Outgoing packets automatically have an IPv6 header prepended to them
(based on the destination address).
Incoming packets on the socket are received with the IPv6 header and any
extension headers removed.
Types
ICMPv6 messages are classified according to the type and code fields
present in the ICMPv6 header.
The abbreviations for the types and codes may be used in rules in
pf.conf5.
The following types are defined:
Num Ta Abbrev. Ta Description
1 Ta unreach Ta Destination unreachable
2 Ta toobig Ta Packet too big
3 Ta timex Ta Time exceeded
4 Ta paramprob Ta Invalid IPv6 header
128 Ta echoreq Ta Echo service request
129 Ta echorep Ta Echo service reply
130 Ta groupqry Ta Group membership query
130 Ta listqry Ta Multicast listener query
131 Ta grouprep Ta Group membership report
131 Ta listenrep Ta Multicast listener report
132 Ta groupterm Ta Group membership termination
132 Ta listendone Ta Multicast listerner done
133 Ta routersol Ta Router solicitation
134 Ta routeradv Ta Router advertisement
135 Ta neighbrsol Ta Neighbor solicitation
136 Ta neighbradv Ta Neighbor advertisement
137 Ta redir Ta Shorter route exists
138 Ta routrrenum Ta Route renumbering
139 Ta fqdnreq Ta FQDN query
139 Ta niqry Ta Node information query
139 Ta wrureq Ta Who-are-you request
140 Ta fqdnrep Ta FQDN reply
140 Ta nirep Ta Node information reply
140 Ta wrurep Ta Who-are-you reply
200 Ta mtraceresp Ta mtrace response
201 Ta mtrace Ta mtrace messages
The following codes are defined:
Num Ta Abbrev. Ta Type Ta Description
0 Ta noroute-unr Ta unreach Ta route to destination
1 Ta admin-unr Ta unreach Ta Administratively prohibited
2 Ta beyond-unr Ta unreach Ta Beyond scope of source address
2 Ta notnbr-unr Ta unreach Ta Not a neighbor (obselete)
3 Ta addr-unr Ta unreach Ta Address unreachable
4 Ta port-unr Ta unreach Ta Port unreachable
0 Ta transit Ta timex Ta Time exceeded in transit
1 Ta reassemb Ta timex Ta Time exceeded in reassembly
0 Ta badhead Ta paramprob Ta Erroneous header field
1 Ta nxthdr Ta paramprob Ta Unrecognized next header
2 Ta Ta redir Ta Unrecognized option
0 Ta redironlink Ta redir Ta Redirection to on-link node
1 Ta redirrouter Ta redir Ta Redirection to better router
Headers
All ICMPv6 messages are prefixed with an ICMPv6 header.
This header corresponds to the
Vt icmp6_hdr
structure and has the following definition:
icmp6_type
describes the type of the message.
Suitable values are defined in
Aq Pa netinet/icmp6.h .
icmp6_code
describes the sub-type of the message and depends on
icmp6_typeicmp6_cksum
contains the checksum for the message and is filled in by the
kernel on outgoing messages.
The other fields are used for type-specific purposes.
Filters
Because of the extra functionality of ICMPv6 in comparison to ICMPv4,
a larger number of messages may be potentially received on an ICMPv6
socket.
Input filters may therefore be used to restrict input to a subset of the
incoming ICMPv6 messages so only interesting messages are returned by the
recv(2)
family of calls to an application.
The
Vt icmp6_filter
structure may be used to refine the input message set according to the
ICMPv6 type.
By default, all messages types are allowed on newly created raw ICMPv6
sockets.
The following macros may be used to refine the input set:
Ignore all incoming messages.
filterp
is modified to ignore all message types.
void
ICMP6_FILTER_SETPASS (int type struct icmp6_filter *filterp);
Allow ICMPv6 messages with the given
Fa type .
filterp
is modified to allow such messages.
void
ICMP6_FILTER_SETBLOCK (int type struct icmp6_filter *filterp);
Ignore ICMPv6 messages with the given
Fa type .
filterp
is modified to ignore such messages.
int
ICMP6_FILTER_WILLPASS (int type const struct icmp6_filter *filterp);
Determine if the given filter will allow an ICMPv6 message of the given
type.
int
ICMP6_FILTER_WILLBLOCK (int type const struct icmp6_filter *filterp);
Determine if the given filter will ignore an ICMPv6 message of the given
type.
The
getsockopt(2)
and
setsockopt(2)
calls may be used to obtain and install the filter on ICMPv6 sockets at
option level
IPPROTO_ICMPV6
and name
ICMPV6_FILTER
with a pointer to the
Vt icmp6_filter
structure as the option value.