frp/vendor/golang.org/x/net/ipv4/icmp_linux.go

26 lines
538 B
Go
Raw Normal View History

2017-06-04 14:07:03 +02: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 14:47:24 +02:00
func (f *icmpFilter) accept(typ ICMPType) {
2017-06-04 14:07:03 +02:00
f.Data &^= 1 << (uint32(typ) & 31)
}
2017-06-04 14:47:24 +02:00
func (f *icmpFilter) block(typ ICMPType) {
2017-06-04 14:07:03 +02:00
f.Data |= 1 << (uint32(typ) & 31)
}
2017-06-04 14:47:24 +02:00
func (f *icmpFilter) setAll(block bool) {
2017-06-04 14:07:03 +02:00
if block {
f.Data = 1<<32 - 1
} else {
f.Data = 0
}
}
2017-06-04 14:47:24 +02:00
func (f *icmpFilter) willBlock(typ ICMPType) bool {
2017-06-04 14:07:03 +02:00
return f.Data&(1<<(uint32(typ)&31)) != 0
}