Don't duplicate messages when sending multiple TLVs
This commit is contained in:
parent
597dd658f4
commit
61ab96abdc
|
@ -370,12 +370,12 @@ class Packet:
|
||||||
pkt.body_length = socket.ntohs(int.from_bytes(data[2:4], sys.byteorder))
|
pkt.body_length = socket.ntohs(int.from_bytes(data[2:4], sys.byteorder))
|
||||||
pkt.body = []
|
pkt.body = []
|
||||||
read_bytes = 0
|
read_bytes = 0
|
||||||
while read_bytes <= min(len(data) - 4, pkt.body_length):
|
while read_bytes < min(len(data) - 4, pkt.body_length):
|
||||||
tlv_type = data[4]
|
tlv_type = data[4 + read_bytes]
|
||||||
if not (0 <= tlv_type < len(TLV.tlv_classes())):
|
if not (0 <= tlv_type < len(TLV.tlv_classes())):
|
||||||
raise ValueError(f"TLV type is not supported: {tlv_type}")
|
raise ValueError(f"TLV type is not supported: {tlv_type}")
|
||||||
tlv = TLV.tlv_classes()[tlv_type]()
|
tlv = TLV.tlv_classes()[tlv_type]()
|
||||||
tlv.unmarshal(data[4:4 + pkt.body_length])
|
tlv.unmarshal(data[4 + read_bytes:4 + read_bytes + pkt.body_length])
|
||||||
pkt.body.append(tlv)
|
pkt.body.append(tlv)
|
||||||
read_bytes += len(tlv)
|
read_bytes += len(tlv)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue