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