You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
609 B

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