1
0
mirror of https://github.com/fatedier/frp.git synced 2025-06-19 10:18:21 +00:00

26 lines
538 B
Go
Raw Normal View History

2017-06-04 20:07:03 +08:00
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
2017-06-04 20:47:24 +08:00
func (f *icmpFilter) accept(typ ICMPType) {
2017-06-04 20:07:03 +08:00
f.Data &^= 1 << (uint32(typ) & 31)
}
2017-06-04 20:47:24 +08:00
func (f *icmpFilter) block(typ ICMPType) {
2017-06-04 20:07:03 +08:00
f.Data |= 1 << (uint32(typ) & 31)
}
2017-06-04 20:47:24 +08:00
func (f *icmpFilter) setAll(block bool) {
2017-06-04 20:07:03 +08:00
if block {
f.Data = 1<<32 - 1
} else {
f.Data = 0
}
}
2017-06-04 20:47:24 +08:00
func (f *icmpFilter) willBlock(typ ICMPType) bool {
2017-06-04 20:07:03 +08:00
return f.Data&(1<<(uint32(typ)&31)) != 0
}