icmp_solaris.go 663 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 *icmpv6Filter) accept(typ ICMPType) {
  6. f.X__icmp6_filt[typ>>5] |= 1 << (uint32(typ) & 31)
  7. }
  8. func (f *icmpv6Filter) block(typ ICMPType) {
  9. f.X__icmp6_filt[typ>>5] &^= 1 << (uint32(typ) & 31)
  10. }
  11. func (f *icmpv6Filter) setAll(block bool) {
  12. for i := range f.X__icmp6_filt {
  13. if block {
  14. f.X__icmp6_filt[i] = 0
  15. } else {
  16. f.X__icmp6_filt[i] = 1<<32 - 1
  17. }
  18. }
  19. }
  20. func (f *icmpv6Filter) willBlock(typ ICMPType) bool {
  21. return f.X__icmp6_filt[typ>>5]&(1<<(uint32(typ)&31)) == 0
  22. }