icmp_linux.go 607 B

123456789101112131415161718192021222324252627
  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.
  4. package ipv6
  5. func (f *sysICMPv6Filter) set(typ ICMPType, block bool) {
  6. if block {
  7. f.Data[typ>>5] |= 1 << (uint32(typ) & 31)
  8. } else {
  9. f.Data[typ>>5] &^= 1 << (uint32(typ) & 31)
  10. }
  11. }
  12. func (f *sysICMPv6Filter) setAll(block bool) {
  13. for i := range f.Data {
  14. if block {
  15. f.Data[i] = 1<<32 - 1
  16. } else {
  17. f.Data[i] = 0
  18. }
  19. }
  20. }
  21. func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
  22. return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0
  23. }