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 // An ICMPType represents a type of ICMP message.
12 func (typ ICMPType) String() string {
13 s, ok := icmpTypes[typ]
20 // Protocol returns the ICMPv4 protocol number.
21 func (typ ICMPType) Protocol() int {
22 return iana.ProtocolICMP
25 // An ICMPFilter represents an ICMP message filter for incoming
26 // packets. The filter belongs to a packet delivery path on a host and
27 // it cannot interact with forwarding packets or tunnel-outer packets.
29 // Note: RFC 8200 defines a reasonable role model and it works not
30 // only for IPv6 but IPv4. A node means a device that implements IP.
31 // A router means a node that forwards IP packets not explicitly
32 // addressed to itself, and a host means a node that is not a router.
33 type ICMPFilter struct {
37 // Accept accepts incoming ICMP packets including the type field value
39 func (f *ICMPFilter) Accept(typ ICMPType) {
43 // Block blocks incoming ICMP packets including the type field value
45 func (f *ICMPFilter) Block(typ ICMPType) {
49 // SetAll sets the filter action to the filter.
50 func (f *ICMPFilter) SetAll(block bool) {
54 // WillBlock reports whether the ICMP type will be blocked.
55 func (f *ICMPFilter) WillBlock(typ ICMPType) bool {
56 return f.willBlock(typ)