def test(self, l4_protos, ext_map): data = create_mock(["pop"]) data.pop.side_effect = ( bytes.fromhex("881103"), "ext0 data", bytes.fromhex("011699"), "ext1 data", bytes.fromhex("FF0806"), "ext1 data", ) l4_protos.append(0xFF) ext0 = create_mock() ext1 = create_mock() ext_map[(7, 3)] = ext0 ext_map[(1, 6)] = ext1 # Call ext_hdrs, hdr_type, unknown = parse_extensions(data, 7) # Tests assert_these_calls(data.pop, ( call(ExtensionHeader.SUBHDR_LEN), call(0x11 * ExtensionHeader.LINE_LEN - ExtensionHeader.SUBHDR_LEN), call(ExtensionHeader.SUBHDR_LEN), call(0x16 * ExtensionHeader.LINE_LEN - ExtensionHeader.SUBHDR_LEN), call(ExtensionHeader.SUBHDR_LEN), call(0x08 * ExtensionHeader.LINE_LEN - ExtensionHeader.SUBHDR_LEN), )) ntools.eq_(ext_hdrs, [ext0.return_value, ext1.return_value]) ntools.eq_(hdr_type, 0xFF) ntools.eq_(unknown, {0x88: [1]})
def _inner_parse(self, data): # pragma: no cover super()._inner_parse(data) # Parse extension headers self.ext_hdrs, self._l4_proto, self._unknown_exts = parse_extensions( data, self.cmn_hdr.next_hdr)