| 311 | |
| 312 | |
| 313 | class Dot15d4Cmd(Packet): |
| 314 | name = "802.15.4 Command" |
| 315 | fields_desc = [ |
| 316 | XLEShortField("dest_panid", 0xFFFF), |
| 317 | # Users should correctly set the dest_addr field. By default is 0x0 for construction to work. # noqa: E501 |
| 318 | dot15d4AddressField("dest_addr", 0x0, length_of="fcf_destaddrmode"), |
| 319 | ConditionalField(XLEShortField("src_panid", 0x0), \ |
| 320 | lambda pkt:util_srcpanid_present(pkt)), |
| 321 | ConditionalField(dot15d4AddressField("src_addr", None, |
| 322 | length_of="fcf_srcaddrmode"), |
| 323 | lambda pkt:pkt.underlayer.getfieldval("fcf_srcaddrmode") != 0), # noqa: E501 |
| 324 | # Security field present if fcf_security == True |
| 325 | ConditionalField(PacketField("aux_sec_header", Dot15d4AuxSecurityHeader(), Dot15d4AuxSecurityHeader), # noqa: E501 |
| 326 | lambda pkt:pkt.underlayer.getfieldval("fcf_security") is True), # noqa: E501 |
| 327 | ByteEnumField("cmd_id", 0, { |
| 328 | 1: "AssocReq", # Association request |
| 329 | 2: "AssocResp", # Association response |
| 330 | 3: "DisassocNotify", # Disassociation notification |
| 331 | 4: "DataReq", # Data request |
| 332 | 5: "PANIDConflictNotify", # PAN ID conflict notification |
| 333 | 6: "OrphanNotify", # Orphan notification |
| 334 | 7: "BeaconReq", # Beacon request |
| 335 | 8: "CoordRealign", # coordinator realignment |
| 336 | 9: "GTSReq" # GTS request |
| 337 | # 0x0a - 0xff reserved |
| 338 | }), |
| 339 | # TODO command payload |
| 340 | ] |
| 341 | |
| 342 | def mysummary(self): |
| 343 | return self.sprintf("802.15.4 Command %Dot15d4Cmd.cmd_id% ( %Dot15dCmd.src_panid%:%Dot15d4Cmd.src_addr% -> %Dot15d4Cmd.dest_panid%:%Dot15d4Cmd.dest_addr% )") # noqa: E501 |
| 344 | |
| 345 | # command frame payloads are complete: DataReq, PANIDConflictNotify, OrphanNotify, BeaconReq don't have any payload # noqa: E501 |
| 346 | # Although BeaconReq can have an optional ZigBee Beacon payload (implemented in ZigBeeBeacon) # noqa: E501 |
| 347 | def guess_payload_class(self, payload): |
| 348 | if self.cmd_id == 1: |
| 349 | return Dot15d4CmdAssocReq |
| 350 | elif self.cmd_id == 2: |
| 351 | return Dot15d4CmdAssocResp |
| 352 | elif self.cmd_id == 3: |
| 353 | return Dot15d4CmdDisassociation |
| 354 | elif self.cmd_id == 8: |
| 355 | return Dot15d4CmdCoordRealign |
| 356 | elif self.cmd_id == 9: |
| 357 | return Dot15d4CmdGTSReq |
| 358 | else: |
| 359 | return Packet.guess_payload_class(self, payload) |
| 360 | |
| 361 | |
| 362 | class Dot15d4CmdCoordRealign(Packet): |
nothing calls this directly
no test coverage detected
searching dependent graphs…