blob: c9122533549785b38d987d36635cd601c1e90718 [file] [log] [blame]
Mikio Harae92559f2014-12-04 17:31:40 +09001// Copyright 2014 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.
4
5package ipv4
6
7func (f *sysICMPFilter) accept(typ ICMPType) {
8 f.Data &^= 1 << (uint32(typ) & 31)
9}
10
11func (f *sysICMPFilter) block(typ ICMPType) {
12 f.Data |= 1 << (uint32(typ) & 31)
13}
14
15func (f *sysICMPFilter) setAll(block bool) {
16 if block {
17 f.Data = 1<<32 - 1
18 } else {
19 f.Data = 0
20 }
21}
22
23func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
24 return f.Data&(1<<(uint32(typ)&31)) != 0
25}