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