github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/net/ipv6/icmp_zos.go (about) 1 // Copyright 2020 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 package ipv6 6 7 func (f *icmpv6Filter) accept(typ ICMPType) { 8 f.Filt[typ>>5] |= 1 << (uint32(typ) & 31) 9 10 } 11 12 func (f *icmpv6Filter) block(typ ICMPType) { 13 f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31) 14 15 } 16 17 func (f *icmpv6Filter) setAll(block bool) { 18 for i := range f.Filt { 19 if block { 20 f.Filt[i] = 0 21 } else { 22 f.Filt[i] = 1<<32 - 1 23 } 24 } 25 } 26 27 func (f *icmpv6Filter) willBlock(typ ICMPType) bool { 28 return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 29 }