1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 import "golang.org/x/net/internal/iana"
9 // BUG(mikio): On Windows, methods related to ICMPFilter are not
12 // An ICMPType represents a type of ICMP message.
15 func (typ ICMPType) String() string {
16 s, ok := icmpTypes[typ]
23 // Protocol returns the ICMPv6 protocol number.
24 func (typ ICMPType) Protocol() int {
25 return iana.ProtocolIPv6ICMP
28 // An ICMPFilter represents an ICMP message filter for incoming
29 // packets. The filter belongs to a packet delivery path on a host and
30 // it cannot interact with forwarding packets or tunnel-outer packets.
32 // Note: RFC 8200 defines a reasonable role model. A node means a
33 // device that implements IP. A router means a node that forwards IP
34 // packets not explicitly addressed to itself, and a host means a node
35 // that is not a router.
36 type ICMPFilter struct {
40 // Accept accepts incoming ICMP packets including the type field value
42 func (f *ICMPFilter) Accept(typ ICMPType) {
46 // Block blocks incoming ICMP packets including the type field value
48 func (f *ICMPFilter) Block(typ ICMPType) {
52 // SetAll sets the filter action to the filter.
53 func (f *ICMPFilter) SetAll(block bool) {
57 // WillBlock reports whether the ICMP type will be blocked.
58 func (f *ICMPFilter) WillBlock(typ ICMPType) bool {
59 return f.willBlock(typ)