icmp_bsd.go 658 B

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