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