def get_channelinfo(channel_bytes): """ return -- [channel_mhz, channel_flags] """ return [ unpack_H_le(channel_bytes[0:2])[0], unpack_H_le(channel_bytes[2:4])[0] ]
def _dissect(self, buf): # Needed by _parse_flags() self.present_flags = unpack_I(buf[4:8])[0] #logger.debug("Flags: 0x%X" % flags) pos_end = len(buf) # Check for FSC, needs to be skipped for upper layers if self.present_flags & FLAGS_MASK == FLAGS_MASK: #logger.debug("Flags mask matched") flags_off = 8 # TSFT present -> Flags values are after TSFT value if self.present_flags & TSFT_MASK == TSFT_MASK: flags_off = 8 + 8 if buf[flags_off] & 0x10 != 0: #logger.debug("FCS found") self._fcs = buf[-4:] pos_end = -4 hdr_len = unpack_H_le(buf[2:4])[0] #logger.debug("Bytes for flags (%d): %s" % (hdr_len, buf[8: hdr_len])) self._init_triggerlist("flags", buf[8: hdr_len], self._parse_flags) #logger.debug("rtap bytes:=%r" % buf[:hdr_len]) # now we got the correct header length self._init_handler(RTAP_TYPE_80211, buf[hdr_len: pos_end]) #logger.debug("Adding %d flags" % len(self.flags)) return hdr_len
def _dissect(self, buf): typeinfo_be = unpack_H_le(buf[1:3])[0] hlen = 5 # VS_PL_LNK_STATUS does not have frag if typeinfo_be in {0xA0B8, 0xA0B9}: # logger.debug("disabling frag") self.frag_info = None self.frag_seq = None hlen = 3 # logger.debug("Got type %X", typeinfo_be) self._init_handler(typeinfo_be, buf[hlen:]) return hlen
def in_cksum_add(s, buf): """Add checksum value to the given value s. Adds 0x0 padding if not multiple of 2.""" n = len(buf) # logger.debug("buflen for checksum: %d" % n) # len=123 -> len=122 a = array_call("H", buf[:n & (~0x1)]) if ENDIANNES != "little": a.byteswap() if n & 0x1 == 0x1: # not multiple of 2: add padding a.append(unpack_H_le(buf[-1:] + b"\x00")[0]) return s + sum(a)
def in_cksum_add(s, buf): """return -- s + checksum value of buf. Adds 0x0 padding to buf if not multiple of 2.""" buflen = len(buf) # logger.debug("buflen for checksum: %d" % n) #a = [unpack_H_le(buf[off: off+2])[0] for off in range(0, buflen & ~0x1, 2)] # seems to be slower a = array_call("H", buf[:buflen & ~0x1]) if ENDIANNES_IS_BIG: a.byteswap() if buflen & 0x1 == 0x1: # not multiple of 2: add padding a.append(unpack_H_le(buf[-1:] + b"\x00")[0]) return s + sum(a)
def _dissect(self, buf): flags = self._present_flags = unpack_I(buf[4:8])[0] pos_end = len(buf) if flags & FLAGS_MASK == FLAGS_MASK: off = 0 if flags & TSFT_MASK == TSFT_MASK: off = 8 if buf[off] & 0x10 != 0: #logger.debug("fcs found") self._fcs = buf[-4:] pos_end = -4 hdr_len = unpack_H_le(buf[2:4])[0] #logger.debug("hdr length is: %d" % hdr_len) self._init_triggerlist("flags", buf[8:hdr_len], self._parse_flags) #logger.debug("rtap bytes:=%r" % buf[:hdr_len]) # now we got the correct header length self._init_handler(RTAP_TYPE_80211, buf[hdr_len:pos_end]) #logger.debug(adding %d flags" % len(self.flags)) return hdr_len