| 223 | |
| 224 | |
| 225 | class Dot15d4Data(Packet): |
| 226 | name = "802.15.4 Data" |
| 227 | fields_desc = [ |
| 228 | XLEShortField("dest_panid", 0xFFFF), |
| 229 | dot15d4AddressField("dest_addr", 0xFFFF, length_of="fcf_destaddrmode"), |
| 230 | ConditionalField(XLEShortField("src_panid", 0x0), |
| 231 | lambda pkt:util_srcpanid_present(pkt)), |
| 232 | ConditionalField(dot15d4AddressField("src_addr", None, length_of="fcf_srcaddrmode"), # noqa: E501 |
| 233 | lambda pkt:pkt.underlayer.getfieldval("fcf_srcaddrmode") != 0), # noqa: E501 |
| 234 | # Security field present if fcf_security == True |
| 235 | ConditionalField(PacketField("aux_sec_header", Dot15d4AuxSecurityHeader(), Dot15d4AuxSecurityHeader), # noqa: E501 |
| 236 | lambda pkt:pkt.underlayer.getfieldval("fcf_security") is True), # noqa: E501 |
| 237 | ] |
| 238 | |
| 239 | def guess_payload_class(self, payload): |
| 240 | # TODO: See how it's done in wireshark: |
| 241 | # https://github.com/wireshark/wireshark/blob/93c60b3b7c801dddd11d8c7f2a0ea4b7d02d700a/epan/dissectors/packet-ieee802154.c#L2061 # noqa: E501 |
| 242 | # it's too magic to me |
| 243 | from scapy.layers.sixlowpan import SixLoWPAN |
| 244 | from scapy.layers.zigbee import ZigbeeNWK |
| 245 | if conf.dot15d4_protocol == "sixlowpan": |
| 246 | return SixLoWPAN |
| 247 | elif conf.dot15d4_protocol == "zigbee": |
| 248 | return ZigbeeNWK |
| 249 | else: |
| 250 | if conf.dot15d4_protocol is None: |
| 251 | _msg = "Please set conf.dot15d4_protocol to select a " + \ |
| 252 | "802.15.4 protocol. Values must be in the list: " |
| 253 | else: |
| 254 | _msg = "Unknown conf.dot15d4_protocol value: must be in " |
| 255 | warning(_msg + |
| 256 | "['sixlowpan', 'zigbee']" + |
| 257 | " Defaulting to SixLoWPAN") |
| 258 | return SixLoWPAN |
| 259 | |
| 260 | def mysummary(self): |
| 261 | return self.sprintf("802.15.4 Data ( %Dot15d4Data.src_panid%:%Dot15d4Data.src_addr% -> %Dot15d4Data.dest_panid%:%Dot15d4Data.dest_addr% )") # noqa: E501 |
| 262 | |
| 263 | |
| 264 | class Dot15d4Beacon(Packet): |
nothing calls this directly
no test coverage detected
searching dependent graphs…