[tests] add traffic analysis for Cert_5_3_08 as TestPlan (#2484)

This commit adds the method set_lowpan_context to set the lowpan context of sniffer.
This commit is contained in:
Zhanglong Xia
2018-01-22 16:48:00 +00:00
committed by Jonathan Hui
parent 092021ad45
commit 2636df1952
8 changed files with 161 additions and 52 deletions
+9
View File
@@ -731,6 +731,9 @@ class LowpanIpv6HeaderFactory:
elif iphc.m == self.IPHC_M_YES:
return self._decompress_multicast_dst_addr(iphc, dci, data)
def set_lowpan_context(self, cid, prefix):
self._context_manager[cid] = Context(prefix)
def parse(self, data, message_info):
iphc = LowpanIPHC.from_bytes(bytearray(data.read(2)))
@@ -776,6 +779,9 @@ class LowpanDecompressor:
def _is_next_header_compressed(self, header):
return (header.next_header is None)
def set_lowpan_context(self, cid, prefix):
self._lowpan_ip_header_factory.set_lowpan_context(cid, prefix)
def decompress(self, data, message_info):
ipv6_header = self._lowpan_ip_header_factory.parse(data, message_info)
@@ -1076,6 +1082,9 @@ class LowpanParser(object):
return self._ipv6_packet_factory.parse(io.BytesIO(decompressed_data), message_info)
def set_lowpan_context(self, cid, prefix):
self._lowpan_decompressor.set_lowpan_context(cid, prefix)
def parse(self, data, message_info):
while data.tell() < len(data.getvalue()):