Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scapy/layers/zigbee.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

from scapy.packet import bind_layers, bind_bottom_up, Packet
from scapy.fields import BitField, ByteField, XLEIntField, ConditionalField, \
ByteEnumField, EnumField, BitEnumField, FieldListField, FlagsField, \
IntField, PacketListField, ShortField, StrField, StrFixedLenField, \
StrLenField, XLEShortField, XStrField
ByteEnumField, EnumField, BitEnumField, FieldLenField, FieldListField, \
FlagsField, IntField, PacketListField, ShortField, StrField, \
StrFixedLenField, StrLenField, XLEShortField, XStrField

from scapy.layers.dot15d4 import dot15d4AddressField, Dot15d4Beacon, Dot15d4, \
Dot15d4FCS
Expand Down Expand Up @@ -1323,7 +1323,8 @@ class ZCLPricePublishPrice(Packet):
fields_desc = [
XLEIntField("provider_id", 0x00000000), # Unsigned 32-bit Integer (4 octets) # noqa: E501
# Rate Label is a UTF-8 encoded Octet String (0-12 octets). The first Octet indicates the length. # noqa: E501
StrLenField("rate_label", "", length_from=lambda pkt:int(pkt.rate_label[0])), # TODO verify # noqa: E501
FieldLenField("rate_label_len", None, length_of="rate_label", fmt="<B"),
StrLenField("rate_label", "", length_from=lambda pkt: pkt.rate_label_len),
XLEIntField("issuer_event_id", 0x00000000), # Unsigned 32-bit Integer (4 octets) # noqa: E501
XLEIntField("current_time", 0x00000000), # UTCTime (4 octets)
ByteField("unit_of_measure", 0), # 8 bits enumeration (1 octet)
Expand Down
16 changes: 16 additions & 0 deletions test/scapy/layers/dot15d4.uts
Original file line number Diff line number Diff line change
Expand Up @@ -948,3 +948,19 @@ assert ZCLIASZoneZoneEnrollResponse in pkt.layers()
assert pkt[ZCLIASZoneZoneEnrollResponse].rsp_code == 0x00
assert pkt[ZCLIASZoneZoneEnrollResponse].zone_id == 0x3a
assert raw(pkt[ZCLIASZoneZoneEnrollResponse].payload) == b''

= Zigbee - ZCL Price Publish Price rate label

data = bytes.fromhex("1122334404616263645566778899aabbcc01ccdd0203445566778899aabbccdd112233445566778899aabbccddee")
p = ZCLPricePublishPrice(data)
assert p.provider_id == 0x44332211
assert p.rate_label_len == 4
assert p.rate_label == b"abcd"
assert p.issuer_event_id == 0x88776655
assert p.current_time == 0xCCBBAA99
assert p.price == 0xDDCCBBAA
assert p.price_ratio == 0x11
assert p.generation_price == 0x55443322
assert p.number_of_block_thresholds == 0xDD
assert p.price_control == 0xEE
assert raw(p) == data
Loading