prism.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """
  2. Prism header.
  3. This packet type exists just for convenience. Radiotap should be prefered over prism
  4. because of its superior flexibility. Only use this if there is no support for Radiotap
  5. eg for some Broadcom-Chipsets (stop buying crap man).
  6. """
  7. from pypacker import pypacker, triggerlist
  8. import logging
  9. logger = logging.getLogger("pypacker")
  10. PRISM_TYPE_80211 = 0
  11. PRISM_DID_RSSI = 0x41400000
  12. class Did(pypacker.Packet):
  13. __hdr__ = (
  14. ("id", "I", 0),
  15. ("status", "H", 0),
  16. ("len", "H", 0),
  17. ("value", "I", 0),
  18. )
  19. __byte_order__ = "<"
  20. class Prism(pypacker.Packet):
  21. __hdr__ = (
  22. ("code", "I", 0),
  23. ("len", "I", 144),
  24. ("dev", "16s", b"\x00" * 16),
  25. ("dids", None, triggerlist.TriggerList),
  26. )
  27. def _dissect(self, buf):
  28. off = 24
  29. # assume 10 DIDs, 24 + 10*12 = 144 bytes prism header
  30. end = off + 10 * 12
  31. dids = []
  32. while off < end:
  33. did = Did(buf[off:off + 12])
  34. dids.append(did)
  35. off += 12
  36. self.dids.extend(dids)
  37. self._init_handler(PRISM_TYPE_80211, buf)
  38. return off
  39. # load handler
  40. from pypacker.layer12 import ieee80211
  41. pypacker.Packet.load_handler(Prism,
  42. {
  43. PRISM_TYPE_80211: ieee80211.IEEE80211
  44. }
  45. )