docs: def getfield(self, pkt, s):
  
          """
          extract data from raw str
  
          collect all instances belonging to the bit field set.
          if we reach a field that ends at a octet boundary, dissect the whole bit field at once  # noqa: E501
  
          :param pkt: packet instance the field belongs to
          :param s: raw string representing the frame -or- tuple containing raw str, number of bits and array of fields  # noqa: E501
          :return: tuple containing raw str, number of bits and array of fields -or- remaining raw str and value of this  # noqa: E501
          """
  
          if type(s) is tuple and len(s) == 3:
              s, bits_in_set, fields = s
          else:
              bits_in_set = 0
              fields = []
  
          bits_in_set += self.size
  
          fields.append(self)
  
          if bits_in_set % 8:
              # we are in between the bitfield
              return (s, bits_in_set, fields), None
  
          else:
              cur_val = 0
              cur_val_bit_idx = 0
              this_val = 0
  
              field_idx = 0
              field = fields[field_idx]
              field_required_bits = field.size
              idx = 0
  
              s = bytearray(s)
              bf_total_byte_length = bits_in_set // 8
  
              for octet in s[0:bf_total_byte_length]:
                  idx += 1
  
                  octet_bits_left = 8
  
                  while octet_bits_left:
  
                      if field_required_bits == octet_bits_left:
                          # whole field fits into remaining bits
                          # as this also signals byte-alignment this should exit the inner and outer loop  # noqa: E501
                          cur_val |= octet << cur_val_bit_idx
                          pkt.fields[field.name] = cur_val
  
                          '''
                          TODO: check if do_dessect() needs a non-None check for assignment to raw_packet_cache_fields  # noqa: E501
  
                          setfieldval() is evil as it sets raw_packet_cache_fields to None - but this attribute  # noqa: E501
                          is accessed in do_dissect() without checking for None... exception is caught and the  # noqa: E501
                          user ends up with a layer decoded as raw...
  
                          pkt.setfieldval(field.name, int(bit_str[:field.size], 2))  # noqa: E501
                          '''
  
                          octet_bits_left = 0
  
                          this_val = cur_val
  
                      elif field_required_bits < octet_bits_left:
                          # pick required bits
                          cur_val |= (octet & ((2 ** field_required_bits) - 1)) << cur_val_bit_idx  # noqa: E501
                          pkt.fields[field.name] = cur_val
  
                          # remove consumed bits
                          octet >>= field_required_bits
                          octet_bits_left -= field_required_bits
  
                          # and move to the next field
                          field_idx += 1
                          field = fields[field_idx]
                          field_required_bits = field.size
                          cur_val_bit_idx = 0
                          cur_val = 0
  
                      elif field_required_bits > octet_bits_left:
                          # take remaining bits
                          cur_val |= octet << cur_val_bit_idx
  
                          cur_val_bit_idx += octet_bits_left
                          field_required_bits -= octet_bits_left
                          octet_bits_left = 0
  
              return s[bf_total_byte_length:], this_val