github.com/gopacket/gopacket@v1.1.0/layers/bitfield.go (about)

     1  // Copyright 2021 The GoPacket Authors. All rights reserved.
     2  //
     3  // Use of this source code is governed by a BSD-style license that can be found
     4  // in the LICENSE file in the root of the source tree.
     5  
     6  package layers
     7  
     8  type bitfield [1024]uint64
     9  
    10  // set sets bit i in bitfield b to 1.
    11  func (b *bitfield) set(i uint16) {
    12  	b[i>>6] |= (1 << (i & 0x3f))
    13  }
    14  
    15  // has reports whether bit i is set to 1 in bitfield b.
    16  func (b *bitfield) has(i uint16) bool {
    17  	return b[i>>6]&(1<<(i&0x3f)) != 0
    18  }