icmp_bsd.go 734 B

123456789101112131415161718192021222324252627282930
  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. //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd
  5. // +build aix darwin dragonfly freebsd netbsd openbsd
  6. package ipv6
  7. func (f *icmpv6Filter) accept(typ ICMPType) {
  8. f.Filt[typ>>5] |= 1 << (uint32(typ) & 31)
  9. }
  10. func (f *icmpv6Filter) block(typ ICMPType) {
  11. f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31)
  12. }
  13. func (f *icmpv6Filter) 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 *icmpv6Filter) willBlock(typ ICMPType) bool {
  23. return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0
  24. }