From 692c27ff0d42f7791795ff35d93d1469f7a7a8d1 Mon Sep 17 00:00:00 2001 From: Nils Weiss Date: Wed, 11 Oct 2023 09:46:29 +0200 Subject: [PATCH 1/3] Fix unittests for pypy3.10 --- test/contrib/automotive/ecu_am.uts | 125 +++-- test/contrib/automotive/interface_mockup.py | 3 +- test/contrib/automotive/obd/obd.uts | 12 +- test/contrib/automotive/scanner/graph.uts | 3 +- .../automotive/scanner/staged_test_case.uts | 15 +- test/contrib/automotive/scanner/test_case.uts | 3 +- .../automotive/scanner/uds_scanner.uts | 2 + test/contrib/automotive/uds.uts | 14 - test/contrib/bp.uts | 23 +- test/contrib/canfdsocket_python_can.uts | 16 +- test/contrib/cansocket.uts | 39 +- test/contrib/cansocket_python_can.uts | 33 +- test/contrib/coap.uts | 6 +- test/contrib/enipTCP.uts | 3 +- test/contrib/esmc.uts | 7 +- test/contrib/gtp_v2.uts | 4 +- test/contrib/hicp.uts | 33 +- test/contrib/iec104.uts | 90 ++-- test/contrib/ikev2.uts | 160 +++--- test/contrib/isotp_packet.uts | 13 +- test/contrib/isotp_soft_socket.uts | 67 ++- test/contrib/isotpscan.uts | 30 +- test/contrib/lacp.uts | 12 +- test/contrib/lldp.uts | 121 ++--- test/contrib/ltp.uts | 34 +- test/contrib/mac_control.uts | 70 ++- test/contrib/mqttsn.uts | 16 +- test/contrib/opc_da.uts | 110 ++--- test/contrib/ospf.uts | 12 +- test/contrib/pcom.uts | 12 +- test/contrib/pfcp.uts | 455 +++++++++--------- test/contrib/pim.uts | 98 ++-- test/contrib/pnio.uts | 23 +- test/contrib/pnio_dcp.uts | 39 +- test/contrib/pnio_rpc.uts | 108 +---- test/contrib/postgres.uts | 18 +- test/contrib/ppi_cace.uts | 259 ++++++---- test/contrib/roce.uts | 12 +- test/contrib/rpl.uts | 13 +- test/contrib/rtcp.uts | 12 +- test/contrib/rtps.uts | 109 ++--- test/contrib/stun.uts | 51 +- test/contrib/tzsp.uts | 211 +------- test/scapy/layers/bluetooth.uts | 8 +- test/scapy/layers/bluetooth4LE.uts | 199 ++++---- test/scapy/layers/dhcp6.uts | 3 +- test/scapy/layers/ipsec.uts | 199 ++++---- test/scapy/layers/l2.uts | 13 +- test/scapy/layers/lltd.uts | 6 +- test/scapy/layers/pptp.uts | 72 +-- 50 files changed, 1271 insertions(+), 1725 deletions(-) diff --git a/test/contrib/automotive/ecu_am.uts b/test/contrib/automotive/ecu_am.uts index d2eea1e3aeb..a849bbae19c 100644 --- a/test/contrib/automotive/ecu_am.uts +++ b/test/contrib/automotive/ecu_am.uts @@ -25,8 +25,8 @@ ecu.pair(tester) = Simple check with RDBI and Negative Response -example_responses = \ - [EcuResponse([EcuState(session=1)], responses=UDS() / UDS_RDBIPR(dataIdentifier=0x1234) / Raw(b"deadbeef"))] +example_responses = [ + EcuResponse([EcuState(session=1)], responses=UDS() / UDS_RDBIPR(dataIdentifier=0x1234) / Raw(b"deadbeef"))] success = False answering_machine = EcuAnsweringMachine(supported_responses=example_responses, main_socket=ecu, basecls=UDS, verbose=False) @@ -54,11 +54,11 @@ assert success = Simple check with different Sessions -example_responses = \ - [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"deadbeef1")), - EcuResponse(EcuState(session=[3, 4]), responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"deadbeef2")), - EcuResponse(EcuState(session=[5, 6, 7]), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef3")), - EcuResponse(EcuState(session=[8, 9]), responses=UDS() / UDS_RDBIPR(dataIdentifier=9) / Raw(b"deadbeef4"))] +example_responses = [ + EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"deadbeef1")), + EcuResponse(EcuState(session=[3, 4]), responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"deadbeef2")), + EcuResponse(EcuState(session=[5, 6, 7]), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef3")), + EcuResponse(EcuState(session=[8, 9]), responses=UDS() / UDS_RDBIPR(dataIdentifier=9) / Raw(b"deadbeef4"))] success = False @@ -100,22 +100,33 @@ assert success = Simple check with different Sessions and diagnosticSessionControl -example_responses = \ - [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"deadbeef1")), - EcuResponse(EcuState(session=range(3,5)), responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"deadbeef2")), - EcuResponse(EcuState(session=[5,6,7]), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef3")), - EcuResponse(EcuState(session=9), responses=UDS() / UDS_RDBIPR(dataIdentifier=9) / Raw(b"deadbeef4")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=1, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=2, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=3, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=4, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=5, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=6, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=7, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(0,8))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=8, sessionParameterRecord=b"dead")), - EcuResponse([EcuState(), EcuState(session=range(8,10))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead1")), - EcuResponse([EcuState(), EcuState(session=range(8,10))], responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead2")), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] +example_responses = [ + EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"deadbeef1")), + EcuResponse(EcuState(session=range(3, 5)), responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"deadbeef2")), + EcuResponse(EcuState(session=[5, 6, 7]), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef3")), + EcuResponse(EcuState(session=9), responses=UDS() / UDS_RDBIPR(dataIdentifier=9) / Raw(b"deadbeef4")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=1, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=2, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=3, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=4, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=5, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=6, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=7, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(0, 8))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=8, sessionParameterRecord=b"dead")), + EcuResponse([EcuState(), EcuState(session=range(8, 10))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead1")), + EcuResponse([EcuState(), EcuState(session=range(8, 10))], + responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead2")), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] success = False @@ -182,15 +193,21 @@ def custom_answers(resp, req): return resp.answers(req) return False -example_responses = \ - [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"deadbeef1")), - EcuResponse(EcuState(session=range(3,5)), responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"deadbeef2")), - EcuResponse(EcuState(session=[5,6,7]), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef3")), - EcuResponse(EcuState(session=[9, 10]), responses=UDS() / UDS_RDBIPR(dataIdentifier=9) / Raw(b"deadbeef4")), - EcuResponse(EcuState(session=range(0,8)), responses=UDS() / UDS_DSCPR(diagnosticSessionType=1, sessionParameterRecord=b"dead"), answers=custom_answers), - EcuResponse(EcuState(session=range(8,10)), responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead1")), - EcuResponse(EcuState(session=range(8,10)), responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead2")), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] + +example_responses = [ + EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"deadbeef1")), + EcuResponse(EcuState(session=range(3, 5)), responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"deadbeef2")), + EcuResponse(EcuState(session=[5, 6, 7]), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef3")), + EcuResponse(EcuState(session=[9, 10]), responses=UDS() / UDS_RDBIPR(dataIdentifier=9) / Raw(b"deadbeef4")), + EcuResponse(EcuState(session=range(0, 8)), + responses=UDS() / UDS_DSCPR(diagnosticSessionType=1, sessionParameterRecord=b"dead"), + answers=custom_answers), + EcuResponse(EcuState(session=range(8, 10)), + responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead1")), + EcuResponse(EcuState(session=range(8, 10)), + responses=UDS() / UDS_DSCPR(diagnosticSessionType=9, sessionParameterRecord=b"dead2")), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] success = False @@ -261,11 +278,16 @@ def custom_answers(resp, req): return resp.answers(req) and req.securityKey == security_seed + security_seed return False -example_responses = \ - [EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_SAPR(securityAccessType=1, securitySeed=b"1234"), answers=custom_answers), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_SAPR(securityAccessType=2), answers=custom_answers), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x35, requestServiceId=0x27)), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] + +example_responses = [ + EcuResponse(EcuState(session=range(0, 255)), responses=UDS() / UDS_SAPR(securityAccessType=1, securitySeed=b"1234"), + answers=custom_answers), + EcuResponse(EcuState(session=range(0, 255)), responses=UDS() / UDS_SAPR(securityAccessType=2), + answers=custom_answers), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x35, requestServiceId=0x27)), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] success = False @@ -308,11 +330,15 @@ def custom_answers(resp, req): return resp.answers(req) and req.securityKey == security_seed + security_seed return False -example_responses = \ - [EcuResponse(EcuState(session=range(0,255)), responses=[UDS()/UDS_NR(negativeResponseCode=0x78, requestServiceId=0x27), UDS() / UDS_SAPR(securityAccessType=1, securitySeed=b"1234")], answers=custom_answers), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_SAPR(securityAccessType=2), answers=custom_answers), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x35, requestServiceId=0x27)), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] +example_responses = [EcuResponse(EcuState(session=range(0,255)), responses=[ + UDS() / UDS_NR(negativeResponseCode=0x78, requestServiceId=0x27), + UDS() / UDS_SAPR(securityAccessType=1, securitySeed=b"1234")], answers=custom_answers), + EcuResponse(EcuState(session=range(0, 255)), responses=UDS() / UDS_SAPR(securityAccessType=2), + answers=custom_answers), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x35, requestServiceId=0x27)), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] success = False @@ -355,11 +381,16 @@ def custom_answers(resp, req): return resp.answers(req) and req.securityKey == security_seed + security_seed return False -example_responses = \ - [EcuResponse(EcuState(session=range(0,255)), responses=[UDS()/UDS_NR(negativeResponseCode=0x78, requestServiceId=0x27), UDS() / UDS_SAPR(securityAccessType=1, securitySeed=b"1234")], answers=custom_answers), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_SAPR(securityAccessType=2), answers=custom_answers), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x35, requestServiceId=0x27)), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] +example_responses = [EcuResponse(EcuState(session=range(0, 255)), + responses=[UDS() / UDS_NR(negativeResponseCode=0x78, requestServiceId=0x27), + UDS() / UDS_SAPR(securityAccessType=1, securitySeed=b"1234")], + answers=custom_answers), + EcuResponse(EcuState(session=range(0, 255)), responses=UDS() / UDS_SAPR(securityAccessType=2), + answers=custom_answers), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x35, requestServiceId=0x27)), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x10))] conf.contribs['UDS']['treat-response-pending-as-answer'] = True diff --git a/test/contrib/automotive/interface_mockup.py b/test/contrib/automotive/interface_mockup.py index 1e7b2388afd..0e0b6ba557e 100644 --- a/test/contrib/automotive/interface_mockup.py +++ b/test/contrib/automotive/interface_mockup.py @@ -176,8 +176,7 @@ def exit_if_no_isotp_module(): # ############################################################################ # """ Save configuration """ # ############################################################################ -conf.contribs['ISOTP'] = \ - {'use-can-isotp-kernel-module': ISOTP_KERNEL_MODULE_AVAILABLE} +conf.contribs['ISOTP'] = {'use-can-isotp-kernel-module': ISOTP_KERNEL_MODULE_AVAILABLE} # ############################################################################ # """ reload ISOTP kernel module in case configuration changed """ diff --git a/test/contrib/automotive/obd/obd.uts b/test/contrib/automotive/obd/obd.uts index fa65e95e447..78bbc2f4503 100644 --- a/test/contrib/automotive/obd/obd.uts +++ b/test/contrib/automotive/obd/obd.uts @@ -319,10 +319,8 @@ assert p.data_records[0].turbo_a_compressor_outlet_temperature_supported == 1 assert p.data_records[0].turbo_a_compressor_inlet_temperature_supported == 0 assert p.data_records[0].turbocharger_a_compressor_inlet_temperature == 0x00-40 assert p.data_records[0].turbocharger_a_compressor_outlet_temperature == 0x11-40 -assert p.data_records[0].turbocharger_a_turbine_inlet_temperature == \ - round((0x2233 * 0.1) - 40, 3) -assert p.data_records[0].turbocharger_a_turbine_outlet_temperature == \ - round((0x4455 * 0.1) - 40, 3) +assert p.data_records[0].turbocharger_a_turbine_inlet_temperature == round((0x2233 * 0.1) - 40, 3) +assert p.data_records[0].turbocharger_a_turbine_outlet_temperature == round((0x4455 * 0.1) - 40, 3) r = OBD(b'\x01\x75') assert p.answers(r) @@ -441,10 +439,8 @@ assert p.data_records[0].turbo_a_compressor_outlet_temperature_supported == 1 assert p.data_records[0].turbo_a_compressor_inlet_temperature_supported == 0 assert p.data_records[0].turbocharger_a_compressor_inlet_temperature == 0x00 - 40 assert p.data_records[0].turbocharger_a_compressor_outlet_temperature == 0x11 - 40 -assert p.data_records[0].turbocharger_a_turbine_inlet_temperature == \ - round((0x2233 * 0.1) - 40, 3) -assert p.data_records[0].turbocharger_a_turbine_outlet_temperature == \ - round((0x4455 * 0.1) - 40, 3) +assert p.data_records[0].turbocharger_a_turbine_inlet_temperature == round((0x2233 * 0.1) - 40, 3) +assert p.data_records[0].turbocharger_a_turbine_outlet_temperature == round((0x4455 * 0.1) - 40, 3) r = OBD(b'\x02\x75\x00') assert p.answers(r) diff --git a/test/contrib/automotive/scanner/graph.uts b/test/contrib/automotive/scanner/graph.uts index 8cd11dcd97d..ab49044ab55 100644 --- a/test/contrib/automotive/scanner/graph.uts +++ b/test/contrib/automotive/scanner/graph.uts @@ -46,8 +46,7 @@ g.add_edge(("5", "6")) print(g.dijkstra(g, "1", "6")) -assert g.dijkstra(g, "1", "6") == ["1", "2", "3", "5", "6"] or \ - g.dijkstra(g, "1", "6") == ['1', '4', '3', '5', '6'] +assert g.dijkstra(g, "1", "6") == ["1", "2", "3", "5", "6"] or g.dijkstra(g, "1", "6") == ['1', '4', '3', '5', '6'] g.add_edge(("2", "5")) diff --git a/test/contrib/automotive/scanner/staged_test_case.uts b/test/contrib/automotive/scanner/staged_test_case.uts index cc6d37d3144..fbf8011442e 100644 --- a/test/contrib/automotive/scanner/staged_test_case.uts +++ b/test/contrib/automotive/scanner/staged_test_case.uts @@ -19,18 +19,21 @@ class MyTestCase1(AutomotiveTestCase): _description = "MyTestCase1" @property def supported_responses(self): - return [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"de")), - EcuResponse([EcuState(session=2), EcuState(security_level=6)], responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"dea2")), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x13))] + return [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=2) / Raw(b"de")), + EcuResponse([EcuState(session=2), EcuState(security_level=6)], + responses=UDS() / UDS_RDBIPR(dataIdentifier=3) / Raw(b"dea2")), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x7f, requestServiceId=0x13))] class MyTestCase2(AutomotiveTestCase): _description = "MyTestCase2" @property def supported_responses(self): - return [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef1")), - EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=6) / Raw(b"deadbeef2")), - EcuResponse(EcuState(session=range(0,255)), responses=UDS() / UDS_NR(negativeResponseCode=0x10, requestServiceId=0x11))] + return [EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=5) / Raw(b"deadbeef1")), + EcuResponse(EcuState(session=2), responses=UDS() / UDS_RDBIPR(dataIdentifier=6) / Raw(b"deadbeef2")), + EcuResponse(EcuState(session=range(0, 255)), + responses=UDS() / UDS_NR(negativeResponseCode=0x10, requestServiceId=0x11))] = Create instance of stage test diff --git a/test/contrib/automotive/scanner/test_case.uts b/test/contrib/automotive/scanner/test_case.uts index f910be6e457..6a235296160 100644 --- a/test/contrib/automotive/scanner/test_case.uts +++ b/test/contrib/automotive/scanner/test_case.uts @@ -35,8 +35,7 @@ try: assert False except Scapy_Exception as e: assert "Keyword-Value" in str(e) - assert "is not instance of type " in str(e) or \ - "is not instance of type " in str(e) + assert "is not instance of type " in str(e) or "is not instance of type " in str(e) = Create instance of test class diff --git a/test/contrib/automotive/scanner/uds_scanner.uts b/test/contrib/automotive/scanner/uds_scanner.uts index 8dc67970ae0..6284f97eb26 100644 --- a/test/contrib/automotive/scanner/uds_scanner.uts +++ b/test/contrib/automotive/scanner/uds_scanner.uts @@ -25,6 +25,8 @@ from scapy.contrib.automotive.ecu import * load_layer("can") +conf.debug_dissector = False + = Define Testfunction diff --git a/test/contrib/automotive/uds.uts b/test/contrib/automotive/uds.uts index ea3bb085530..0eab3684d70 100644 --- a/test/contrib/automotive/uds.uts +++ b/test/contrib/automotive/uds.uts @@ -1046,20 +1046,6 @@ assert rdtcipr.DTCCount == 0xddaa assert rdtcipr.answers(rdtci) -rdtcipr1 = UDS(b'\x59\x02\xff\x11\x07\x11\'\x022\x12\'\x01\x07\x11\'\x01\x18\x12\'\x01\x13\x12\'\x01"\x11\'\x06C\x00\'\x06S\x00\'\x161\x00\'\x14\x03\x12\'') - -assert len(rdtcipr1.DTCAndStatusRecord) == 10 -assert rdtcipr1.DTCAndStatusRecord[0].dtc.system == 0 -assert rdtcipr1.DTCAndStatusRecord[0].dtc.type == 1 -assert rdtcipr1.DTCAndStatusRecord[0].dtc.numeric_value_code == 263 -assert rdtcipr1.DTCAndStatusRecord[0].dtc.additional_information_code == 17 -assert rdtcipr1.DTCAndStatusRecord[0].status == 0x27 -assert rdtcipr1.DTCAndStatusRecord[-1].dtc.system == 0 -assert rdtcipr1.DTCAndStatusRecord[-1].dtc.type == 1 -assert rdtcipr1.DTCAndStatusRecord[-1].dtc.numeric_value_code == 1027 -assert rdtcipr1.DTCAndStatusRecord[-1].dtc.additional_information_code == 18 -assert rdtcipr1.DTCAndStatusRecord[-1].status == 0x27 - = Check UDS_RDTCI rdtci = UDS(b'\x19\x02\xff') diff --git a/test/contrib/bp.uts b/test/contrib/bp.uts index cf738c62498..0b3c53199ed 100644 --- a/test/contrib/bp.uts +++ b/test/contrib/bp.uts @@ -10,18 +10,17 @@ from scapy.contrib.ltp import LTPex -pkt = Ether(src="aa:aa:aa:aa:aa:aa", dst="bb:bb:bb:bb:bb:bb")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP()/LTP(flags=7,\ - SessionOriginator=2, - SessionNumber=113, - HeaderExtensions=[ - LTPex(ExTag=1, ExData=b"\x00"), - ], - DATA_ClientServiceID=1, - DATA_PayloadOffset=0, - LTP_Payload=[ - BP(ProcFlags=415)/\ - BPBLOCK(ProcFlags=10, load="data") - ]) +pkt = Ether(src="aa:aa:aa:aa:aa:aa", dst="bb:bb:bb:bb:bb:bb") / IP(src="192.168.0.1", dst="192.168.0.2") / UDP() / LTP( + flags=7, SessionOriginator=2, + SessionNumber=113, + HeaderExtensions=[ + LTPex(ExTag=1, ExData=b"\x00"), + ], + DATA_ClientServiceID=1, + DATA_PayloadOffset=0, + LTP_Payload=[ + BP(ProcFlags=415) / BPBLOCK(ProcFlags=10, load="data") + ]) pkt = Ether(raw(pkt)) assert LTP in pkt diff --git a/test/contrib/canfdsocket_python_can.uts b/test/contrib/canfdsocket_python_can.uts index 6ae7b526bfa..76211d3b501 100644 --- a/test/contrib/canfdsocket_python_can.uts +++ b/test/contrib/canfdsocket_python_can.uts @@ -76,8 +76,8 @@ assert rx2 == CAN(identifier=0x7ff,length=1,data=b'\x01') = CAN Socket send recv small packet test with -with CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2: +with (CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, + CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2): sock2.send(CANFD(identifier=0x7ff,length=1,data=b'\x01')) rx = sock1.recv() @@ -85,8 +85,8 @@ assert rx == CANFD(identifier=0x7ff,length=1,data=b'\x01') = CAN Socket basecls test -with CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2: +with (CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, + CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2): sock1.basecls = Raw sock2.send(CANFD(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) rx = sock1.recv() @@ -96,8 +96,8 @@ with CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, \ conf.contribs['CAN']['swap-bytes'] = True -with CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2: +with (CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock1, + CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2): sock2.send(CANFD(identifier=0x7ff,length=64,data=b'\x01' * 64)) sock1.basecls = CAN rx = sock1.recv() @@ -114,8 +114,8 @@ msgs = [CANFD(identifier=0x200, length=64, data=b'\x01\x02\x03\x04\x05\x06\x07\x CANFD(identifier=0x100, length=64, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' * 8), CANFD(identifier=0x200, length=64, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' * 8)] -with CANSocket(bustype='socketcan', channel='vcan0', fd=True, can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2: +with (CANSocket(bustype='socketcan', channel='vcan0', fd=True, can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, + CANSocket(bustype='socketcan', channel='vcan0', fd=True) as sock2): for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=3) diff --git a/test/contrib/cansocket.uts b/test/contrib/cansocket.uts index 52165634c9a..b3f7b930da5 100644 --- a/test/contrib/cansocket.uts +++ b/test/contrib/cansocket.uts @@ -55,8 +55,8 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') = NativeCANSocket send recv small packet test with -with NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, + NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): sock2.send(CAN(identifier=0x7ff,length=1,data=b'\x01')) rx = sock1.recv() @@ -76,8 +76,8 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') = PythonCANSocket send recv small packet test with -with PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, + PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): sock2.send(CAN(identifier=0x7ff,length=1,data=b'\x01')) rx = sock1.recv() @@ -87,8 +87,8 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') conf.contribs['CAN']['swap-bytes'] = True -with NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, + NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) rx = sock1.sniff(count=1, timeout=1) assert len(rx) == 1 @@ -100,8 +100,8 @@ conf.contribs['CAN']['swap-bytes'] = False conf.contribs['CAN']['swap-bytes'] = True -with PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, + PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) rx = sock1.sniff(count=1, timeout=1) assert rx[0] == CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08') @@ -117,8 +117,8 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x100, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, \ - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, + NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=3) @@ -133,8 +133,8 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x100, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, \ - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, + PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=3) @@ -150,8 +150,8 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x700, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x7ff, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, \ - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, + NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -167,8 +167,8 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x700, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x7ff, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, \ - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: +with (PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, + ythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -191,15 +191,16 @@ def bridge(): global bridgeStarted bSock0 = NativeCANSocket( bustype='socketcan', channel='vcan0', - bitrate=250000) + bitrate=250000) bSock1 = NativeCANSocket( bustype='socketcan', channel='vcan1', - bitrate=250000) + bitrate=250000) def pnr(pkt): return pkt bSock0.timeout = 0.01 bSock1.timeout = 0.01 - bridge_and_sniff(if1=bSock0, if2=bSock1, xfrm12=pnr, xfrm21=pnr, timeout=0.5, started_callback=bridgeStarted.set, count=6) + bridge_and_sniff(if1=bSock0, if2=bSock1, xfrm12=pnr, xfrm21=pnr, timeout=0.5, started_callback=bridgeStarted.set, + count=6) bSock0.close() bSock1.close() diff --git a/test/contrib/cansocket_python_can.uts b/test/contrib/cansocket_python_can.uts index 78fa349d899..d7777872396 100644 --- a/test/contrib/cansocket_python_can.uts +++ b/test/contrib/cansocket_python_can.uts @@ -71,8 +71,7 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') = CAN Socket send recv small packet test with -with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0') as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=1,data=b'\x01')) rx = sock1.recv() @@ -83,8 +82,7 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') from scapy.contrib.isotp import ISOTPHeader, ISOTP_FF -with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0') as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(ISOTPHeader(identifier=0x7ff)/ISOTP_FF(message_size=100, data=b'abcdef')) rx = sock1.recv() assert rx == CAN(identifier=0x7ff,length=8,data=b'\x10\x64abcdef') @@ -92,8 +90,7 @@ with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ = CAN Socket basecls test -with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0') as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: sock1.basecls = Raw sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) rx = sock1.recv() @@ -101,8 +98,7 @@ with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ = CAN Socket send recv -with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0') as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) sock1.basecls = CAN rx = sock1.recv() @@ -112,8 +108,7 @@ with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ conf.contribs['CAN']['swap-bytes'] = True -with CANSocket(bustype='socketcan', channel='vcan0') as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0') as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) sock1.basecls = CAN rx = sock1.recv() @@ -130,8 +125,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x100, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=3) @@ -147,8 +141,7 @@ msgs = [CAN(identifier=0x212, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x2aa, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x700}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x700}]) as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -163,8 +156,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x700, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x100, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0xff}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0xff}]) as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -180,8 +172,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x700, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x7ff, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -197,8 +188,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -213,8 +203,7 @@ msgs = [CAN(flags='extended', identifier=0x10010000, length=8, data=b'\x01\x02\x CAN(flags='extended', identifier=0x10040000, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(flags='extended', identifier=0x10000000, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x10000000, 'can_mask': 0x1fffffff}]) as sock1, \ - CANSocket(bustype='socketcan', channel='vcan0') as sock2: +with CANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x10000000, 'can_mask': 0x1fffffff}]) as sock1, CANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=2) diff --git a/test/contrib/coap.uts b/test/contrib/coap.uts index 16dfc0f99b7..76cdba71e20 100644 --- a/test/contrib/coap.uts +++ b/test/contrib/coap.uts @@ -42,11 +42,7 @@ p = UDP()/CoAP() assert p[UDP].dport == 5683 = Source port -s = b'\x16\x33\xa0\xa4\x00\x78\xfe\x8b\x60\x45\xd9\xe1\xc1\x28\xff\x3c\x2f\x3e\x3b\x74\x69\x74\x6c\x65\x3d\x22\x47\x65' \ - b'\x6e\x65\x72\x61\x6c\x20\x49\x6e\x66\x6f\x22\x3b\x63\x74\x3d\x30\x2c\x3c\x2f\x74\x69\x6d\x65\x3e\x3b\x69\x66\x3d' \ - b'\x22\x63\x6c\x6f\x63\x6b\x22\x3b\x72\x74\x3d\x22\x54\x69\x63\x6b\x73\x22\x3b\x74\x69\x74\x6c\x65\x3d\x22\x49\x6e' \ - b'\x74\x65\x72\x6e\x61\x6c\x20\x43\x6c\x6f\x63\x6b\x22\x3b\x63\x74\x3d\x30\x3b\x6f\x62\x73\x2c\x3c\x2f\x61\x73\x79' \ - b'\x6e\x63\x3e\x3b\x63\x74\x3d\x30' +s = b'\x16\x33\xa0\xa4\x00\x78\xfe\x8b\x60\x45\xd9\xe1\xc1\x28\xff\x3c\x2f\x3e\x3b\x74\x69\x74\x6c\x65\x3d\x22\x47\x65\x6e\x65\x72\x61\x6c\x20\x49\x6e\x66\x6f\x22\x3b\x63\x74\x3d\x30\x2c\x3c\x2f\x74\x69\x6d\x65\x3e\x3b\x69\x66\x3d\x22\x63\x6c\x6f\x63\x6b\x22\x3b\x72\x74\x3d\x22\x54\x69\x63\x6b\x73\x22\x3b\x74\x69\x74\x6c\x65\x3d\x22\x49\x6e\x74\x65\x72\x6e\x61\x6c\x20\x43\x6c\x6f\x63\x6b\x22\x3b\x63\x74\x3d\x30\x3b\x6f\x62\x73\x2c\x3c\x2f\x61\x73\x79\x6e\x63\x3e\x3b\x63\x74\x3d\x30' assert CoAP in UDP(s) = building with a text/plain payload diff --git a/test/contrib/enipTCP.uts b/test/contrib/enipTCP.uts index d2d820c669e..5f91effecfc 100644 --- a/test/contrib/enipTCP.uts +++ b/test/contrib/enipTCP.uts @@ -42,8 +42,7 @@ assert pkt.items[0].serviceName == b'test' pkt=ENIPTCP() pkt.commandId=0x63 assert pkt.commandId == 0x63 -assert raw(pkt) == b"c\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ -b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +assert raw(pkt) == b"c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" = ENIP List Identity Default Values pkt=ENIPListIdentity() diff --git a/test/contrib/esmc.uts b/test/contrib/esmc.uts index ed01e85466c..78a3792322f 100644 --- a/test/contrib/esmc.uts +++ b/test/contrib/esmc.uts @@ -10,8 +10,7 @@ pkt = Ether(src="00:13:c4:12:0f:0d") / SlowProtocol() / ESMC(event=1) / QLTLV(ssmCode=0x2) pkt.show() s = raw(pkt) -raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x0a\x00\x19\xa7\x00' \ - b'\x01\x18\x00\x00\x00\x01\x00\x04\x02' +raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x0a\x00\x19\xa7\x00\x01\x18\x00\x00\x00\x01\x00\x04\x02' assert s == raw_pkt p = Ether(s) @@ -23,9 +22,7 @@ assert raw(p) == raw_pkt pkt = pkt / EQLTLV(clockIdentity=b'\x11\x22\x33\x44\x55\x66\x77\x88') pkt.show() s = raw(pkt) -raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x0a\x00\x19\xa7\x00' \ - b'\x01\x18\x00\x00\x00\x01\x00\x04\x02\x02\x00\x14\xff\x11\x22\x33\x44\x55\x66' \ - b'\x77\x88\x00\x01\x00\x00\x00\x00\x00\x00' +raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x0a\x00\x19\xa7\x00\x01\x18\x00\x00\x00\x01\x00\x04\x02\x02\x00\x14\xff\x11\x22\x33\x44\x55\x66\x77\x88\x00\x01\x00\x00\x00\x00\x00\x00' assert s == raw_pkt p = Ether(s) diff --git a/test/contrib/gtp_v2.uts b/test/contrib/gtp_v2.uts index e2339c8beb5..bb32e44cf6b 100644 --- a/test/contrib/gtp_v2.uts +++ b/test/contrib/gtp_v2.uts @@ -14,9 +14,7 @@ gtp = IP()/UDP(dport=2123) / GTPHeader(seq=12345) / GTPV2EchoRequest() gtp.dport == 2123 and gtp.seq == 12345 and gtp.gtp_type == 1 and gtp.T == 0 = GTPV2CreateSessionRequest, basic instantiation -gtp = IP() / UDP(dport=2123) / \ - GTPHeader(gtp_type="create_session_req", teid=2807, seq=12345) / \ - GTPV2CreateSessionRequest() +gtp = IP() / UDP(dport=2123) / GTPHeader(gtp_type="create_session_req", teid=2807, seq=12345) / GTPV2CreateSessionRequest() gtp.dport == 2123 and gtp.teid == 2807 and gtp.seq == 12345 = GTPV2EchoRequest, dissection diff --git a/test/contrib/hicp.uts b/test/contrib/hicp.uts index 12d0e4832b4..dd5f933ddbc 100644 --- a/test/contrib/hicp.uts +++ b/test/contrib/hicp.uts @@ -23,20 +23,14 @@ pkt=HICPModuleScanResponse(fieldbus_type="kwack") assert(pkt.protocol_version == b"1.00") assert(pkt.fieldbus_type == b"kwack") assert(pkt.mac_address == "ff:ff:ff:ff:ff:ff") -pkt=HICP( -b"\x50\x72\x6f\x74\x6f\x63\x6f\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e" \ -b"\x20\x3d\x20\x31\x2e\x30\x30\x3b\x46\x42\x20\x74\x79\x70\x65\x20" \ -b"\x3d\x20\x3b\x4d\x6f\x64\x75\x6c\x65\x20\x76\x65\x72\x73\x69\x6f" \ -b"\x6e\x20\x3d\x20\x3b\x4d\x41\x43\x20\x3d\x20\x65\x65\x3a\x65\x65" \ -b"\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3b\x49\x50\x20" \ -b"\x3d\x20\x32\x35\x35\x2e\x32\x35\x35\x2e\x32\x35\x35\x2e\x32\x35" \ -b"\x35\x3b\x53\x4e\x20\x3d\x20\x32\x35\x35\x2e\x32\x35\x35\x2e\x32" \ -b"\x35\x35\x2e\x30\x3b\x47\x57\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e" \ -b"\x30\x3b\x44\x48\x43\x50\x20\x3d\x20\x4f\x46\x46\x3b\x48\x4e\x20" \ -b"\x3d\x20\x3b\x44\x4e\x53\x31\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e" \ -b"\x30\x3b\x44\x4e\x53\x32\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e\x30" \ -b"\x3b\x00" -) +pkt = HICP( + b"\x50\x72\x6f\x74\x6f\x63\x6f\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x20\x3d\x20\x31\x2e\x30\x30\x3b\x46\x42\x20\x74" + b"\x79\x70\x65\x20\x3d\x20\x3b\x4d\x6f\x64\x75\x6c\x65\x20\x76\x65\x72\x73\x69\x6f\x6e\x20\x3d\x20\x3b\x4d\x41\x43" + b"\x20\x3d\x20\x65\x65\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3a\x65\x65\x3b\x49\x50\x20\x3d\x20\x32\x35" + b"\x35\x2e\x32\x35\x35\x2e\x32\x35\x35\x2e\x32\x35\x35\x3b\x53\x4e\x20\x3d\x20\x32\x35\x35\x2e\x32\x35\x35\x2e\x32" + b"\x35\x35\x2e\x30\x3b\x47\x57\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e\x30\x3b\x44\x48\x43\x50\x20\x3d\x20\x4f\x46\x46" + b"\x3b\x48\x4e\x20\x3d\x20\x3b\x44\x4e\x53\x31\x20\x3d\x20\x30\x2e\x30\x2e\x30\x2e\x30\x3b\x44\x4e\x53\x32\x20\x3d" + b"\x20\x30\x2e\x30\x2e\x30\x2e\x30\x3b\x00") assert(pkt.hicp_command == b"Module scan response") assert(pkt.protocol_version == b"1.00") assert(pkt.mac_address == "ee:ee:ee:ee:ee:ee") @@ -81,8 +75,7 @@ assert(pkt.hostname == b"llama") pkt = HICPReconfigured(source="11:00:00:00:00:00") assert(pkt.source == "11:00:00:00:00:00") assert(raw(pkt) == b"Reconfigured: 11-00-00-00-00-00\x00") -pkt = HICP(b"\x52\x65\x63\x6f\x6e\x66\x69\x67\x75\x72\x65\x64\x3a\x20\x31\x31" \ -b"\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00") +pkt = HICP(b"\x52\x65\x63\x6f\x6e\x66\x69\x67\x75\x72\x65\x64\x3a\x20\x31\x31\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00") assert(pkt.hicp_command == b"Reconfigured") assert(pkt.source == "11:00:00:00:00:00") @@ -93,9 +86,7 @@ pkt = HICPInvalidConfiguration(source="00:11:00:00:00:00") assert(pkt.source == "00:11:00:00:00:00") assert(raw(pkt) == b"Invalid Configuration: 00-11-00-00-00-00\x00") pkt = HICP( -b"\x49\x6e\x76\x61\x6c\x69\x64\x20\x43\x6f\x6e\x66\x69\x67\x75\x72" \ -b"\x61\x74\x69\x6f\x6e\x3a\x20\x30\x30\x2d\x31\x31\x2d\x30\x30\x2d" \ -b"\x30\x30\x2d\x30\x30\x2d\x30\x30\x00" +b"\x49\x6e\x76\x61\x6c\x69\x64\x20\x43\x6f\x6e\x66\x69\x67\x75\x72\x61\x74\x69\x6f\x6e\x3a\x20\x30\x30\x2d\x31\x31\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00" ) assert(pkt.hicp_command == b"Invalid Configuration") assert(pkt.source == "00:11:00:00:00:00") @@ -106,8 +97,6 @@ assert(pkt.source == "00:11:00:00:00:00") pkt = HICPInvalidPassword(source="00:00:11:00:00:00") assert(pkt.source == "00:00:11:00:00:00") assert(raw(pkt) == b"Invalid Password: 00-00-11-00-00-00\x00") -pkt = HICP(b"\x49\x6e\x76\x61\x6c\x69" \ -b"\x64\x20\x50\x61\x73\x73\x77\x6f\x72\x64\x3a\x20\x30\x30\x2d\x30" \ -b"\x30\x2d\x31\x31\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00") +pkt = HICP(b"\x49\x6e\x76\x61\x6c\x69\x64\x20\x50\x61\x73\x73\x77\x6f\x72\x64\x3a\x20\x30\x30\x2d\x30\x30\x2d\x31\x31\x2d\x30\x30\x2d\x30\x30\x2d\x30\x30\x00") assert(pkt.hicp_command == b"Invalid Password") assert(pkt.source == "00:00:11:00:00:00") diff --git a/test/contrib/iec104.uts b/test/contrib/iec104.uts index 4ab561cd030..3f7d1c6442d 100644 --- a/test/contrib/iec104.uts +++ b/test/contrib/iec104.uts @@ -186,9 +186,8 @@ assert u_msg.stopdt_con == 1 = double IEC104 U Message -frm = Ether()/IP()/TCP()/\ - IEC104_U_Message(startdt_act = 1, stopdt_con = 1, testfr_act=1)/\ - IEC104_U_Message(startdt_con = 1, stopdt_act = 1, testfr_con=1) +frm = Ether() / IP() / TCP() / IEC104_U_Message(startdt_act=1, stopdt_con=1, testfr_act=1) / IEC104_U_Message( + startdt_con=1, stopdt_act=1, testfr_con=1) frm = Ether(frm.do_build()) u_msg = frm.getlayer(IEC104_U_Message) @@ -243,9 +242,9 @@ assert (m_sp_ta_1_lyr.sec_milli == 4) = Single IOA, multiple IOs - information object types dissection -frm = Ether()/IP()/TCP(sport=IEC_104_IANA_PORT, dport=56780)/\ - IEC104_I_Message_SingleIOA(io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=1111, minutes = 1, sec_milli = 2), - IEC104_IO_C_RC_TA_1_IOA(information_object_address=2222,minutes = 3, sec_milli = 4)]) +frm = Ether()/IP()/TCP(sport=IEC_104_IANA_PORT, dport=56780) / IEC104_I_Message_SingleIOA( + io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=1111, minutes=1, sec_milli=2), + IEC104_IO_C_RC_TA_1_IOA(information_object_address=2222, minutes=3, sec_milli=4)]) frm = Ether(frm.do_build()) i_msg_lyr = frm.getlayer(IEC104_I_Message_SingleIOA) @@ -264,13 +263,13 @@ assert (m_sp_ta_1_lyr.sec_milli == 4) = Sequence IOA, multiple APDUs -frm = Ether()/IP()/TCP(sport=IEC_104_IANA_PORT, dport=56780)/\ - IEC104_I_Message_SeqIOA(information_object_address=1234, - io=[IEC104_IO_C_RC_TA_1(minutes = 1, sec_milli = 2), - IEC104_IO_C_RC_TA_1(minutes = 3, sec_milli = 4)])/ \ - IEC104_I_Message_SeqIOA(information_object_address=5432, - io=[IEC104_IO_C_RC_TA_1(minutes = 5, sec_milli = 6), - IEC104_IO_C_RC_TA_1(minutes = 7, sec_milli = 8)]) +frm = Ether() / IP() / TCP(sport=IEC_104_IANA_PORT, dport=56780) / IEC104_I_Message_SeqIOA( + information_object_address=1234, + io=[IEC104_IO_C_RC_TA_1(minutes=1, sec_milli=2), + IEC104_IO_C_RC_TA_1(minutes=3, sec_milli=4)]) / IEC104_I_Message_SeqIOA( + information_object_address=5432, + io=[IEC104_IO_C_RC_TA_1(minutes=5, sec_milli=6), + IEC104_IO_C_RC_TA_1(minutes=7, sec_milli=8)]) frm = Ether(frm.do_build()) i_msg_lyr = frm.getlayer(IEC104_I_Message_SeqIOA, nb=1) @@ -293,15 +292,15 @@ assert i_msg_lyr.io[1].sec_milli == 8 = Single IOA, multiple APDUs -frm = Ether()/IP()/TCP(sport=IEC_104_IANA_PORT, dport=56780)/\ - IEC104_I_Message_SingleIOA(io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=1111, - minutes = 1, sec_milli = 2), - IEC104_IO_C_RC_TA_1_IOA(information_object_address=2222, - minutes = 3, sec_milli = 4)])/ \ - IEC104_I_Message_SingleIOA(io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=3333, - minutes = 5, sec_milli = 6), - IEC104_IO_C_RC_TA_1_IOA(information_object_address=4444, - minutes = 7, sec_milli = 8)]) +frm = Ether() / IP() / TCP(sport=IEC_104_IANA_PORT, dport=56780) / IEC104_I_Message_SingleIOA( + io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=1111, + minutes=1, sec_milli=2), + IEC104_IO_C_RC_TA_1_IOA(information_object_address=2222, + minutes=3, sec_milli=4)]) / IEC104_I_Message_SingleIOA( + io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=3333, + minutes=5, sec_milli=6), + IEC104_IO_C_RC_TA_1_IOA(information_object_address=4444, + minutes=7, sec_milli=8)]) frm = Ether(frm.do_build()) i_msg_lyr = frm.getlayer(IEC104_I_Message_SingleIOA, nb=1) @@ -326,18 +325,17 @@ assert i_msg_lyr.io[1].sec_milli == 8 = Mixed Single and Sequence IOA, multiple APDU -frm = Ether()/IP()/TCP(sport=IEC_104_IANA_PORT, dport=56780)/\ - IEC104_I_Message_SeqIOA(information_object_address=1111, - io=[IEC104_IO_C_RC_TA_1_IOA(minutes = 1, sec_milli = 2), - IEC104_IO_C_RC_TA_1_IOA(minutes = 3, sec_milli = 4)])/ \ - IEC104_I_Message_SingleIOA(io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=3333, - minutes = 5, sec_milli = 6), - IEC104_IO_C_RC_TA_1_IOA(information_object_address=4444, - minutes = 7, sec_milli = 8)])/ \ - IEC104_I_Message_SeqIOA(information_object_address=5555, - io=[IEC104_IO_C_RC_TA_1_IOA(minutes = 1, sec_milli = 9), - IEC104_IO_C_RC_TA_1_IOA(minutes = 3, sec_milli = 10)])/ \ - IEC104_I_Message_SingleIOA(io=IEC104_IO_C_RP_NA_1_IOA(information_object_address=5555)) +frm = Ether() / IP() / TCP(sport=IEC_104_IANA_PORT, dport=56780) / IEC104_I_Message_SeqIOA( + information_object_address=1111, + io=[IEC104_IO_C_RC_TA_1_IOA(minutes=1, sec_milli=2), + IEC104_IO_C_RC_TA_1_IOA(minutes=3, sec_milli=4)]) / IEC104_I_Message_SingleIOA( + io=[IEC104_IO_C_RC_TA_1_IOA(information_object_address=3333, + minutes=5, sec_milli=6), + IEC104_IO_C_RC_TA_1_IOA(information_object_address=4444, + minutes=7, sec_milli=8)]) / IEC104_I_Message_SeqIOA(information_object_address=5555, + io=[IEC104_IO_C_RC_TA_1_IOA( + minutes=1, sec_milli=9), + IEC104_IO_C_RC_TA_1_IOA(minutes = 3, sec_milli = 10)])/IEC104_I_Message_SingleIOA(io=IEC104_IO_C_RP_NA_1_IOA(information_object_address=5555)) frm = Ether(frm.do_build()) @@ -357,14 +355,12 @@ assert (i_msg_lyr.io[0].information_object_address == 3333) = I/U/S Message sequence (mixed APDUs) -frm = Ether()/IP()/TCP(sport=IEC_104_IANA_PORT, dport=56780)/\ - IEC104_I_Message_SeqIOA(information_object_address=1111, - rx_seq_num=1234, - tx_seq_num=6789, - io=[IEC104_IO_C_RC_TA_1_IOA(minutes = 1, sec_milli = 2), - IEC104_IO_C_RC_TA_1_IOA(minutes = 3, sec_milli = 4)])/\ - IEC104_U_Message()/ \ - IEC104_S_Message(rx_seq_num=666) +frm = Ether() / IP() / TCP(sport=IEC_104_IANA_PORT, dport=56780) / IEC104_I_Message_SeqIOA( + information_object_address=1111, + rx_seq_num=1234, + tx_seq_num=6789, + io=[IEC104_IO_C_RC_TA_1_IOA(minutes=1, sec_milli=2), + IEC104_IO_C_RC_TA_1_IOA(minutes=3, sec_milli=4)]) / IEC104_U_Message() / IEC104_S_Message(rx_seq_num=666) frm = Ether(frm.do_build()) i_msg = frm.getlayer(IEC104_I_Message_SeqIOA) @@ -440,11 +436,11 @@ frm = Ether() / IP() / TCP() / IEC104_I_Message_SeqIOA(information_object_addres io=[ IEC104_IO_C_RD_NA_1(), IEC104_IO_C_RD_NA_1() - ])/ \ - IEC104_I_Message_SeqIOA(information_object_address=0x445566, - io=[IEC104_IO_M_DP_NA_1(dpi_value=IEC104_IE_DIQ.DPI_FLAG_STATE_UNDEFINED)])/ \ - IEC104_I_Message_SeqIOA(information_object_address=0x445567, - io=[IEC104_IO_C_RD_NA_1()]) + ]) / IEC104_I_Message_SeqIOA(information_object_address=0x445566, + io=[IEC104_IO_M_DP_NA_1( + dpi_value=IEC104_IE_DIQ.DPI_FLAG_STATE_UNDEFINED)]) / IEC104_I_Message_SeqIOA( + information_object_address=0x445567, + io=[IEC104_IO_C_RD_NA_1()]) frm = Ether(frm.do_build()) diff --git a/test/contrib/ikev2.uts b/test/contrib/ikev2.uts index db503867fc1..dbbd0425899 100644 --- a/test/contrib/ikev2.uts +++ b/test/contrib/ikev2.uts @@ -43,14 +43,15 @@ transform_1 = IKEv2_Transform(next_payload = 'Transform', transform_type = 'Encr transform_2 = IKEv2_Transform(next_payload = 'Transform', transform_type = 'PRF', transform_id = 2) transform_3 = IKEv2_Transform(next_payload = 'Transform', transform_type = 'Integrity', transform_id = 2) transform_4 = IKEv2_Transform(next_payload = 'None', transform_type = 'GroupDesc', transform_id = 2) -packet = IP(dst = '192.168.1.10', src = '192.168.1.130') /\ - UDP(dport = 500) /\ - IKEv2(init_SPI = b'KWdxMhjA', next_payload = 'SA', exch_type = 'IKE_SA_INIT', flags='Initiator') /\ - IKEv2_SA(next_payload = 'KE', prop = IKEv2_Proposal(trans_nb = 4, trans = transform_1 / transform_2 / transform_3 / transform_4, )) /\ - IKEv2_KE(next_payload = 'Nonce', group = '1024MODPgr', ke = key_exchange) /\ - IKEv2_Nonce(next_payload = 'Notify', nonce = nonce) /\ - IKEv2_Notify(next_payload = 'Notify', type = 16388, notify = nat_detection_source_ip) /\ - IKEv2_Notify(next_payload = 'None', type = 16389, notify = nat_detection_destination_ip) +packet = IP(dst='192.168.1.10', src='192.168.1.130') / UDP(dport=500) / IKEv2(init_SPI=b'KWdxMhjA', next_payload='SA', + exch_type='IKE_SA_INIT', + flags='Initiator') / IKEv2_SA( + next_payload='KE', + prop=IKEv2_Proposal(trans_nb=4, trans=transform_1 / transform_2 / transform_3 / transform_4, )) / IKEv2_KE( + next_payload='Nonce', group='1024MODPgr', ke=key_exchange) / IKEv2_Nonce(next_payload='Notify', + nonce=nonce) / IKEv2_Notify( + next_payload='Notify', type=16388, notify=nat_detection_source_ip) / IKEv2_Notify(next_payload='None', type=16389, + notify=nat_detection_destination_ip) assert raw(packet) == b'E\x00\x01L\x00\x01\x00\x00@\x11\xf5\xc3\xc0\xa8\x01\x82\xc0\xa8\x01\n\x01\xf4\x01\xf4\x018\xa6\xc0KWdxMhjA\x00\x00\x00\x00\x00\x00\x00\x00! "\x08\x00\x00\x00\x00\x00\x00\x010"\x00\x000\x00\x00\x00,\x01\x01\x00\x04\x03\x00\x00\x0c\x01\x00\x00\x0c\x80\x0e\x00\x80\x03\x00\x00\x08\x02\x00\x00\x02\x03\x00\x00\x08\x03\x00\x00\x02\x00\x00\x00\x08\x04\x00\x00\x02(\x00\x00\x88\x00\x02\x00\x00\xbbA\xbbA\xcf\xaf4\xe3\xb3 \x96r\xae\xf1\xc5\x1b\x9dR\x91\x9f\x17\x81\xd0\xb4\xcd\x88\x9dJ\xaf\xe2ah\x87v\x00\x0c=\x901PZ\xef\xc0\x18ig\xea\xf5\xa7f7%\xfb\x10,Y\xc3\x9bzp\xd8\xd9\x16\x1c;\xd0\xebDX\x88\xb5\x02\x8e\xa0c\xba\n\xe0\x1f[?0\x80\x8akg\x10\xdc\x9b\xab`\x1eA\x16\x15}\x7fX\xcf\x83\\\xb63\xc6J\xbc\xb3\xa5\xc6\x1c">\x932S\x8b\xfc\x9f(,\xb6-\x1f\x00\xf4\xee\x88\x02)\x00\x00$\x8d\xfc\xf88L\\2\xf1\xb2\x94\xc6N\xabi\xf9\x8e\x9d\x8c\xf7\xe7\xf3R\x97\x1a\x91\xffgw\xd4}\xff\xed)\x00\x00\x1c\x00\x00@\x04\xe6L\x81\xc4\x15*\xd8;\xd6\xe05\x00\x9f\xbb\x90\x04\x06\xbe7\x1f\x00\x00\x00\x1c\x00\x00@\x05(\xcd\x99\xb9\xfa\x12geKS\xf6\x08\x87\xc9\xc3[\xcfg\xa8\xff' @@ -1348,11 +1349,14 @@ frames = [ c0 a8 e1 0b 00 00 00 18 01 00 00 00 07 00 00 10 00 00 ff ff c0 a8 e1 00 c0 a8 e1 ff """.split())), - Ether(dst='00:50:56:99:bf:d5', src='00:50:56:99:69:93', type=2048) /\ - IP(version=4, ihl=5, tos=0, len=312, id=24626, flags=2, frag=0, ttl=64, proto=17, chksum=49423, src='10.5.2.54', dst='10.5.2.52') /\ - UDP(sport=47257, dport=4500, len=292, chksum=6569) /\ - NON_ESP(non_esp=0) /\ - IKEv2( + Ether(dst='00:50:56:99:bf:d5', src='00:50:56:99:69:93', type=2048) / IP(version=4, ihl=5, tos=0, len=312, + id=24626, flags=2, frag=0, ttl=64, + proto=17, chksum=49423, src='10.5.2.54', + dst='10.5.2.52') / UDP(sport=47257, + dport=4500, + len=292, + chksum=6569) / NON_ESP( + non_esp=0) / IKEv2( init_SPI=b'F\xb3\xf6\x88M7_\x9a', resp_SPI=b'\xf58\x825\xea\x87^\x8a', next_payload=41, @@ -1361,8 +1365,7 @@ frames = [ flags=0, id=0, length=280 - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=33, flags=0, length=12, @@ -1371,34 +1374,32 @@ frames = [ type=16393, SPI=b'_\xc7\xffZ', notify=b'' - ) /\ - IKEv2_SA( + ) / IKEv2_SA( prop=IKEv2_Proposal( trans=( - IKEv2_Transform(next_payload=3, flags=0, length=12, transform_type=1, res2=0, transform_id=20, key_length=128) /\ - IKEv2_Transform(next_payload=3, flags=0, length=8, transform_type=4, res2=0, transform_id=28) /\ - IKEv2_Transform(next_payload=0, flags=0, length=8, transform_type=5, res2=0, transform_id=0) + IKEv2_Transform(next_payload=3, flags=0, length=12, transform_type=1, res2=0, transform_id=20, + key_length=128) / IKEv2_Transform(next_payload=3, flags=0, length=8, + transform_type=4, res2=0, + transform_id=28) / IKEv2_Transform( + next_payload=0, flags=0, length=8, transform_type=5, res2=0, transform_id=0) ), next_payload=0, flags=0, length=40, proposal=1, proto=3, SPIsize=4, trans_nb=3, SPI=b'k!\x88 '), next_payload=40, flags=0, length=44 - ) /\ - IKEv2_Nonce( + ) / IKEv2_Nonce( next_payload=34, flags=0, length=44, nonce=b'\xea~\x88WJ6d\xcdg\xe3\xb9U' - ) /\ - IKEv2_TSi( + ) / IKEv2_TSi( traffic_selector=[ IPv4TrafficSelector( TS_type=7, @@ -1415,8 +1416,7 @@ frames = [ length=24, number_of_TSs=1, res2=0 - ) /\ - IKEv2_TSr( + ) / IKEv2_TSr( traffic_selector=[ IPv4TrafficSelector( TS_type=7, @@ -1478,10 +1478,12 @@ frames = [ 402e290000080000 4016000000100000 402f000100020003 0004 """.split())), # packet: Ether / IP / UDP / IKEv2 / ... - Ether(dst='00:50:56:99:bf:d5', src='00:50:56:99:1b:cc', type=2048) /\ - IP(version=4, ihl=5, tos=0, id=46899, flags=0, frag=0, ttl=127, proto=17, chksum=27308, src='10.5.2.60', dst='10.5.2.52') /\ - UDP(sport=10952, dport=500, chksum=25272) /\ - IKEv2( + Ether(dst='00:50:56:99:bf:d5', src='00:50:56:99:1b:cc', type=2048) / IP(version=4, ihl=5, tos=0, id=46899, + flags=0, frag=0, ttl=127, proto=17, + chksum=27308, src='10.5.2.60', + dst='10.5.2.52') / UDP(sport=10952, + dport=500, + chksum=25272) / IKEv2( init_SPI=b'\x88iH\x81Iu(\xad', resp_SPI=b'\x00\x00\x00\x00\x00\x00\x00\x00', next_payload=33, @@ -1489,62 +1491,56 @@ frames = [ exch_type=34, flags=8, id=0 - ) /\ - IKEv2_SA( + ) / IKEv2_SA( prop=IKEv2_Proposal( trans=( - IKEv2_Transform(next_payload=3, flags=0, length=12, transform_type=1, res2=0, transform_id=20, key_length=256) /\ - IKEv2_Transform(next_payload=3, flags=0, length=8, transform_type=2, res2=0, transform_id=5) /\ - IKEv2_Transform(next_payload=0, flags=0, length=8, transform_type=4, res2=0, transform_id=28) + IKEv2_Transform(next_payload=3, flags=0, length=12, transform_type=1, res2=0, transform_id=20, + key_length=256) / IKEv2_Transform(next_payload=3, flags=0, length=8, + transform_type=2, res2=0, + transform_id=5) / IKEv2_Transform( + next_payload=0, flags=0, length=8, transform_type=4, res2=0, transform_id=28) ), next_payload=0, flags=0, length=36, proposal=1, proto='IKE', trans_nb=3), next_payload=34, flags=0, length=40 - ) /\ - IKEv2_KE( + ) / IKEv2_KE( next_payload=40, flags=0, length=72, group=28, res2=0, ke=b'(\x95\xd4\x8eG\r\x8c\xb8\x81\x96b\xf37\x0cW\xb2l\xd3I\xc1o^\xc1\xb3\x19Y\xf9\xefiT\x80\xbcs#R\xf9m\n|JT\xf1\xd5\x96\xbbO\xcc/6\x8e1\x98Zv\xeaZ|w\xd41\r7-\x96' - ) /\ - IKEv2_Nonce( + ) / IKEv2_Nonce( next_payload=41, flags=0, length=44, nonce=b'K\xf3\xeal\xd0\xc6\xaf\xe7\x02\xc5g\xfe}\xb3\xff\x974$\xbb^\x9d\xe6\xaf\x12:A\x97Zo\xfb&n\x9c[L\x91W\x95\x13+' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=28, proto='IKE', type='NAT_DETECTION_DESTINATION_IP', notify=b'P\x9b\x01\xb4=\xc2\x8c\x9d\xf8I\xfdv\\d\x8aQ)Y\xacP' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=28, proto='IKE', type='NAT_DETECTION_SOURCE_IP', notify=b'S\x12\t\x859\x9e\x14\xcf+y!\x1f7[C\x9b\xd001\xac' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=8, type='IKEV2_FRAGMENTATION_SUPPORTED', - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=8, type='REDIRECT_SUPPORTED', - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=0, flags=0, length=16, @@ -1567,10 +1563,10 @@ frames = [ 9de6af123a41975a 6ffb266e9c5b4c91 5795132b """.split())), # packet: Ether / IP / UDP / IKEv2 / ... - Ether(dst='00:50:56:99:1b:cc', src='00:50:56:99:bf:d5', type=2048) /\ - IP(version=4, ihl=5, tos=0, id=50387, flags=0, frag=0, ttl=64, proto=17, src='10.5.2.52', dst='10.5.2.60') /\ - UDP(sport=500, dport=10952) /\ - IKEv2( + Ether(dst='00:50:56:99:1b:cc', src='00:50:56:99:bf:d5', type=2048) / IP(version=4, ihl=5, tos=0, id=50387, + flags=0, frag=0, ttl=64, proto=17, + src='10.5.2.52', dst='10.5.2.60') / UDP( + sport=500, dport=10952) / IKEv2( init_SPI=b'\x88iH\x81Iu(\xad', resp_SPI=b'\x00\x00\x00\x00\x00\x00\x00\x00', next_payload=41, @@ -1578,8 +1574,7 @@ frames = [ exch_type=34, flags=32, id=0 - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=0, flags=0, length=78, @@ -1609,23 +1604,24 @@ frames = [ 402e2900000e0000 401801040a050234 000000100000402f 0001000200030004 """.split())), # packet: Ether / IP / UDP / IKEv2 / ... - Ether(dst='00:50:56:99:07:66', src='00:50:56:99:1b:cc', type=2048) /\ - IP(version=4, ihl=5, tos=0, id=37036, flags=0, frag=0, ttl=127, proto=17, src='10.5.2.60', dst='10.5.2.53') /\ - UDP(sport=10952, dport=500) /\ - IKEv2( + Ether(dst='00:50:56:99:07:66', src='00:50:56:99:1b:cc', type=2048) / IP(version=4, ihl=5, tos=0, id=37036, + flags=0, frag=0, ttl=127, proto=17, + src='10.5.2.60', dst='10.5.2.53') / UDP( + sport=10952, dport=500) / IKEv2( init_SPI=b'\x1c\x88\xee\x0bw\x93\xd5.', resp_SPI=b'\x00\x00\x00\x00\x00\x00\x00\x00', next_payload=33, version=32, exch_type=34, flags=8, - id=0) /\ - IKEv2_SA( + id=0) / IKEv2_SA( prop=IKEv2_Proposal( trans=( - IKEv2_Transform(next_payload=3, flags=0, length=12, transform_type=1, res2=0, transform_id=20, key_length=256) /\ - IKEv2_Transform(next_payload=3, flags=0, length=8, transform_type=2, res2=0, transform_id=5) /\ - IKEv2_Transform(next_payload=0, flags=0, length=8, transform_type=4, res2=0, transform_id=28) + IKEv2_Transform(next_payload=3, flags=0, length=12, transform_type=1, res2=0, transform_id=20, + key_length=256) / IKEv2_Transform(next_payload=3, flags=0, length=8, + transform_type=2, res2=0, + transform_id=5) / IKEv2_Transform( + next_payload=0, flags=0, length=8, transform_type=4, res2=0, transform_id=28) ), next_payload=0, flags=0, @@ -1637,44 +1633,38 @@ frames = [ next_payload=34, flags=0, length=40 - ) /\ - IKEv2_KE( + ) / IKEv2_KE( next_payload=40, flags=0, length=72, group=28, res2=0, ke=b'F\x16\x84\x82\xfeS#?\xc1\xe2/\x97&\xb7\xad\xfe\r\xfc\xf5=\x15X\xfdf1h$\xce\xec2\xd4\xd3?\x57\x79\x41\xd3\xd5.\x92\x9b;\xed\x0b.\xef\x12\x88a\x17\xcd5\x86U\xf2\xf6\xff\xd6\xfbT\xfdH\xbb\xc5' - ) /\ - IKEv2_Nonce( + ) / IKEv2_Nonce( next_payload=41, flags=0, length=44, nonce=b'\xa5s\xe3?b\xcf(\x93\xf8\n\xbe\xd1g|\xa3\x03$\x9b\xf9\n\xae\x99\x98\x00R\xcb\xdf\xd9\xccknp`Xi\xef\x14+\xcd\xfd' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=28, proto='IKE', type='NAT_DETECTION_DESTINATION_IP', notify=b",\x07\xd7Q\x9a\xd8\xdf#\xa20'\xe9\xe7\xc2eK2\xc4\xe0\xf3" - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=28, proto='IKE', type='NAT_DETECTION_SOURCE_IP', notify=b'\x1a\x1d\x00\x1c\xd4\xd0oB\xd1\xce\x83o|\xeda\xc6\x83\xb1\x87\xef' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=8, type='IKEV2_FRAGMENTATION_SUPPORTED' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=41, flags=0, length=14, @@ -1682,8 +1672,7 @@ frames = [ gw_id_type=1, gw_id_len=4, gw_id='10.5.2.52' - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=0, flags=0, length=16, @@ -1703,10 +1692,10 @@ frames = [ 0000000000240000 00080100000e """.split())), # packet: Ether / IP / UDP / IKEv2 / ... - Ether(dst='00:50:56:99:1b:cc', src='00:50:56:99:07:66', type=2048) /\ - IP(version=4, ihl=5, tos=0, id=62028, flags=0, frag=0, ttl=64, proto=17, src='10.5.2.53', dst='10.5.2.60') /\ - UDP(sport=500, dport=10952) /\ - IKEv2( + Ether(dst='00:50:56:99:1b:cc', src='00:50:56:99:07:66', type=2048) / IP(version=4, ihl=5, tos=0, id=62028, + flags=0, frag=0, ttl=64, proto=17, + src='10.5.2.53', dst='10.5.2.60') / UDP( + sport=500, dport=10952) / IKEv2( init_SPI=b'\x1c\x88\xee\x0bw\x93\xd5.', resp_SPI=b'c\xcc\x9c\x19\x19\xde3\xe7', next_payload=41, @@ -1714,8 +1703,7 @@ frames = [ exch_type=34, flags=32, id=0 - ) /\ - IKEv2_Notify( + ) / IKEv2_Notify( next_payload=0, flags=0, length=8, diff --git a/test/contrib/isotp_packet.uts b/test/contrib/isotp_packet.uts index e0225eb09ef..aa76f7615b5 100644 --- a/test/contrib/isotp_packet.uts +++ b/test/contrib/isotp_packet.uts @@ -127,13 +127,12 @@ assert isotpno.data == isotpex.data assert isotpno.message_size == isotpex.message_size = Dissect multiple packets -frames = \ - [b'\x00\x00\x00\x00\x08\x00\x00\x00\x10(\xde\xad\xbe\xef\xde\xad', - b'\x00\x00\x00\x00\x08\x00\x00\x00!\xbe\xef\xde\xad\xbe\xef\xde', - b'\x00\x00\x00\x00\x08\x00\x00\x00"\xad\xbe\xef\xde\xad\xbe\xef', - b'\x00\x00\x00\x00\x08\x00\x00\x00#\xde\xad\xbe\xef\xde\xad\xbe', - b'\x00\x00\x00\x00\x08\x00\x00\x00$\xef\xde\xad\xbe\xef\xde\xad', - b'\x00\x00\x00\x00\x07\x00\x00\x00%\xbe\xef\xde\xad\xbe\xef'] +frames = [b'\x00\x00\x00\x00\x08\x00\x00\x00\x10(\xde\xad\xbe\xef\xde\xad', + b'\x00\x00\x00\x00\x08\x00\x00\x00!\xbe\xef\xde\xad\xbe\xef\xde', + b'\x00\x00\x00\x00\x08\x00\x00\x00"\xad\xbe\xef\xde\xad\xbe\xef', + b'\x00\x00\x00\x00\x08\x00\x00\x00#\xde\xad\xbe\xef\xde\xad\xbe', + b'\x00\x00\x00\x00\x08\x00\x00\x00$\xef\xde\xad\xbe\xef\xde\xad', + b'\x00\x00\x00\x00\x07\x00\x00\x00%\xbe\xef\xde\xad\xbe\xef'] isotpframes = [ISOTPHeader(x) for x in frames] diff --git a/test/contrib/isotp_soft_socket.uts b/test/contrib/isotp_soft_socket.uts index b2b7295805d..6738dbd8e19 100644 --- a/test/contrib/isotp_soft_socket.uts +++ b/test/contrib/isotp_soft_socket.uts @@ -312,9 +312,7 @@ with TestSocket(CAN) as ss, TestSocket(CAN) as sr: assert len(p)==1 = Send single frame ISOTP message, using send -with TestSocket(CAN) as isocan, \ - ISOTPSoftSocket(isocan, tx_id=0x641, rx_id=0x241) as s, \ - TestSocket(CAN) as cans: +with TestSocket(CAN) as isocan, ISOTPSoftSocket(isocan, tx_id=0x641, rx_id=0x241) as s, TestSocket(CAN) as cans: cans.pair(isocan) can = cans.sniff(timeout=2, count=1, started_callback=lambda: s.send(ISOTP(data=dhex("01 02 03 04 05")))) assert can[0].identifier == 0x641 @@ -322,9 +320,7 @@ with TestSocket(CAN) as isocan, \ = Send many single frame ISOTP messages, using send -with TestSocket(CAN) as isocan, \ - ISOTPSoftSocket(isocan, tx_id=0x641, rx_id=0x241) as s, \ - TestSocket(CAN) as cans: +with TestSocket(CAN) as isocan, ISOTPSoftSocket(isocan, tx_id=0x641, rx_id=0x241) as s, TestSocket(CAN) as cans: cans.pair(isocan) for i in range(100): data = dhex("01 02 03 04 05") + struct.pack("B", i) @@ -916,8 +912,8 @@ assert "Overflow happened at the receiver side" in log_stream.getvalue() = ISOTPSoftSocket sr1 msg = ISOTP(b'\x11\x22\x33\x11\x22\x33\x11\x22\x33\x11\x22\x33') -with TestSocket(CAN) as isocan_tx, ISOTPSoftSocket(isocan_tx, 0x123, 0x321) as sock_tx, \ - TestSocket(CAN) as isocan_rx, ISOTPSoftSocket(isocan_rx, 0x321, 0x123) as sock_rx: +with TestSocket(CAN) as isocan_tx, ISOTPSoftSocket(isocan_tx, 0x123, 0x321) as sock_tx, TestSocket( + CAN) as isocan_rx, ISOTPSoftSocket(isocan_rx, 0x321, 0x123) as sock_rx: isocan_rx.pair(isocan_tx) sniffer = AsyncSniffer(opened_socket=sock_rx, timeout=1, count=1, prn=lambda x: sock_rx.send(msg)) sniffer.start() @@ -932,8 +928,8 @@ assert rx2 == msg = ISOTPSoftSocket sniff msg = ISOTP(b'\x11\x22\x33\x11\x22\x33\x11\x22\x33\x11\x22\x33') -with TestSocket(CAN) as isocan1, ISOTPSoftSocket(isocan1, 0x123, 0x321) as sock, \ - TestSocket(CAN) as isocan, ISOTPSoftSocket(isocan, 0x321, 0x123) as rx_sock: +with TestSocket(CAN) as isocan1, ISOTPSoftSocket(isocan1, 0x123, 0x321) as sock, TestSocket( + CAN) as isocan, ISOTPSoftSocket(isocan, 0x321, 0x123) as rx_sock: isocan1.pair(isocan) msg.data += b'0' sock.send(msg) @@ -964,14 +960,11 @@ assert rx[4] == msg = bridge and sniff with isotp soft sockets set up vcan0 and vcan1 for package forwarding vcan1 succ = False -with TestSocket(CAN) as can0_0, \ - TestSocket(CAN) as can0_1, \ - TestSocket(CAN) as can1_0, \ - TestSocket(CAN) as can1_1, \ - ISOTPSoftSocket(can0_0, tx_id=0x241, rx_id=0x641) as isoTpSocket0, \ - ISOTPSoftSocket(can1_0, tx_id=0x541, rx_id=0x141) as isoTpSocket1, \ - ISOTPSoftSocket(can0_1, tx_id=0x641, rx_id=0x241) as bSocket0, \ - ISOTPSoftSocket(can1_1, tx_id=0x141, rx_id=0x141) as bSocket1: +with TestSocket(CAN) as can0_0, TestSocket(CAN) as can0_1, TestSocket(CAN) as can1_0, TestSocket( + CAN) as can1_1, ISOTPSoftSocket(can0_0, tx_id=0x241, rx_id=0x641) as isoTpSocket0, ISOTPSoftSocket(can1_0, + tx_id=0x541, + rx_id=0x141) as isoTpSocket1, ISOTPSoftSocket( + can0_1, tx_id=0x641, rx_id=0x241) as bSocket0, ISOTPSoftSocket(can1_1, tx_id=0x141, rx_id=0x141) as bSocket1: can0_0.pair(can0_1) can1_1.pair(can1_0) evt = threading.Event() @@ -1002,14 +995,11 @@ N = 3 T = 3 succ = False -with TestSocket(CAN) as can0_0, \ - TestSocket(CAN) as can0_1, \ - TestSocket(CAN) as can1_0, \ - TestSocket(CAN) as can1_1, \ - ISOTPSoftSocket(can0_0, tx_id=0x241, rx_id=0x641) as isoTpSocket0, \ - ISOTPSoftSocket(can1_0, tx_id=0x541, rx_id=0x141) as isoTpSocket1, \ - ISOTPSoftSocket(can0_1, tx_id=0x641, rx_id=0x241) as bSocket0, \ - ISOTPSoftSocket(can1_1, tx_id=0x141, rx_id=0x541) as bSocket1: +with TestSocket(CAN) as can0_0, TestSocket(CAN) as can0_1, TestSocket(CAN) as can1_0, TestSocket( + CAN) as can1_1, ISOTPSoftSocket(can0_0, tx_id=0x241, rx_id=0x641) as isoTpSocket0, ISOTPSoftSocket(can1_0, + tx_id=0x541, + rx_id=0x141) as isoTpSocket1, ISOTPSoftSocket( + can0_1, tx_id=0x641, rx_id=0x241) as bSocket0, ISOTPSoftSocket(can1_1, tx_id=0x141, rx_id=0x541) as bSocket1: can0_0.pair(can0_1) can1_1.pair(can1_0) evt = threading.Event() @@ -1040,14 +1030,11 @@ assert succ = bridge and sniff with isotp soft sockets set up vcan0 and vcan1 for package change vcan1 succ = False -with TestSocket(CAN) as can0_0, \ - TestSocket(CAN) as can0_1, \ - TestSocket(CAN) as can1_0, \ - TestSocket(CAN) as can1_1, \ - ISOTPSoftSocket(can0_0, tx_id=0x241, rx_id=0x641) as isoTpSocket0, \ - ISOTPSoftSocket(can1_0, tx_id=0x641, rx_id=0x241) as isoTpSocket1, \ - ISOTPSoftSocket(can0_1, tx_id=0x641, rx_id=0x241) as bSocket0, \ - ISOTPSoftSocket(can1_1, tx_id=0x241, rx_id=0x641) as bSocket1: +with TestSocket(CAN) as can0_0, TestSocket(CAN) as can0_1, TestSocket(CAN) as can1_0, TestSocket( + CAN) as can1_1, ISOTPSoftSocket(can0_0, tx_id=0x241, rx_id=0x641) as isoTpSocket0, ISOTPSoftSocket(can1_0, + tx_id=0x641, + rx_id=0x241) as isoTpSocket1, ISOTPSoftSocket( + can0_1, tx_id=0x641, rx_id=0x241) as bSocket0, ISOTPSoftSocket(can1_1, tx_id=0x241, rx_id=0x641) as bSocket1: can0_0.pair(can0_1) can1_1.pair(can1_0) evt = threading.Event() @@ -1072,8 +1059,8 @@ assert succ = Two ISOTPSoftSockets at the same time, sending and receiving -with TestSocket(CAN) as cs1, ISOTPSoftSocket(cs1, tx_id=0x641, rx_id=0x241) as s1, \ - TestSocket(CAN) as cs2, ISOTPSoftSocket(cs2, tx_id=0x241, rx_id=0x641) as s2: +with TestSocket(CAN) as cs1, ISOTPSoftSocket(cs1, tx_id=0x641, rx_id=0x241) as s1, TestSocket( + CAN) as cs2, ISOTPSoftSocket(cs2, tx_id=0x241, rx_id=0x641) as s2: cs1.pair(cs2) isotp = ISOTP(data=b"\x10\x25" * 43) s2.send(isotp) @@ -1085,8 +1072,8 @@ assert result[0].data == isotp.data = Two ISOTPSoftSockets at the same time, sending and receiving with tx_gap -with TestSocket(CAN) as cs1, ISOTPSoftSocket(cs1, tx_id=0x641, rx_id=0x241, stmin=1) as s1, \ - TestSocket(CAN) as cs2, ISOTPSoftSocket(cs2, tx_id=0x241, rx_id=0x641) as s2: +with TestSocket(CAN) as cs1, ISOTPSoftSocket(cs1, tx_id=0x641, rx_id=0x241, stmin=1) as s1, TestSocket( + CAN) as cs2, ISOTPSoftSocket(cs2, tx_id=0x241, rx_id=0x641) as s2: cs1.pair(cs2) isotp = ISOTP(data=b"\x10\x25" * 43) s2.send(isotp) @@ -1098,8 +1085,8 @@ assert result[0].data == isotp.data = Two ISOTPSoftSockets at the same time, multiple sends/receives def test(): - with TestSocket(CAN) as cs1, ISOTPSoftSocket(cs1, tx_id=0x641, rx_id=0x241) as s1, \ - TestSocket(CAN) as cs2, ISOTPSoftSocket(cs2, tx_id=0x241, rx_id=0x641) as s2: + with TestSocket(CAN) as cs1, ISOTPSoftSocket(cs1, tx_id=0x641, rx_id=0x241) as s1, TestSocket( + CAN) as cs2, ISOTPSoftSocket(cs2, tx_id=0x241, rx_id=0x641) as s2: cs1.pair(cs2) for i in range(1, 40, 5): isotp = ISOTP(data=bytearray(range(i, i * 2))) diff --git a/test/contrib/isotpscan.uts b/test/contrib/isotpscan.uts index ac88be3ee15..a0a95cdc688 100644 --- a/test/contrib/isotpscan.uts +++ b/test/contrib/isotpscan.uts @@ -207,10 +207,8 @@ with ISOTPSoftSocket(sock_recv1, tx_id=0x702, rx_id=0x602), ISOTPSoftSocket(sock can_interface="can0", verbose=False) -s1 = "ISOTPSocket(can0, tx_id=0x602, rx_id=0x702, " \ - "padding=False, basecls=ISOTP)\n" -s2 = "ISOTPSocket(can0, tx_id=0x603, rx_id=0x703, " \ - "padding=False, basecls=ISOTP)\n" +s1 = "ISOTPSocket(can0, tx_id=0x602, rx_id=0x702, padding=False, basecls=ISOTP)\n" +s2 = "ISOTPSocket(can0, tx_id=0x603, rx_id=0x703, padding=False, basecls=ISOTP)\n" assert s1 in result assert s2 in result @@ -234,10 +232,8 @@ with ISOTPSoftSocket(sock_recv1, tx_id=0x702, rx_id=0x602), ISOTPSoftSocket(sock can_interface="can0", verbose=False) -s1 = "\"iface\": \"can0\", \"tx_id\": 1538, \"rx_id\": 1794, " \ - "\"padding\": false, \"basecls\": \"ISOTP\"" -s2 = "\"iface\": \"can0\", \"tx_id\": 1539, \"rx_id\": 1795, " \ - "\"padding\": false, \"basecls\": \"ISOTP\"" +s1 = "\"iface\": \"can0\", \"tx_id\": 1538, \"rx_id\": 1794, \"padding\": false, \"basecls\": \"ISOTP\"" +s2 = "\"iface\": \"can0\", \"tx_id\": 1539, \"rx_id\": 1795, \"padding\": false, \"basecls\": \"ISOTP\"" print(result) assert s1 in result assert s2 in result @@ -262,10 +258,8 @@ with ISOTPSoftSocket(sock_recv1, tx_id=0x702, rx_id=0x602), ISOTPSoftSocket(sock can_interface="can0", verbose=False) -s1 = "ISOTPSocket(can0, tx_id=0x602, rx_id=0x702, " \ - "padding=False, basecls=ISOTP)\n" -s2 = "ISOTPSocket(can0, tx_id=0x603, rx_id=0x703, " \ - "padding=False, basecls=ISOTP)\n" +s1 = "ISOTPSocket(can0, tx_id=0x602, rx_id=0x702, padding=False, basecls=ISOTP)\n" +s2 = "ISOTPSocket(can0, tx_id=0x603, rx_id=0x703, padding=False, basecls=ISOTP)\n" assert s1 not in result assert s2 in result @@ -291,10 +285,8 @@ with ISOTPSoftSocket(sock_recv1, tx_id=0x702, rx_id=0x602, ext_address=0x11, rx_ can_interface="can0", verbose=False) -s1 = "ISOTPSocket(can0, tx_id=0x602, rx_id=0x702, padding=False, " \ - "ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" -s2 = "ISOTPSocket(can0, tx_id=0x603, rx_id=0x703, padding=False, " \ - "ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" +s1 = "ISOTPSocket(can0, tx_id=0x602, rx_id=0x702, padding=False, ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" +s2 = "ISOTPSocket(can0, tx_id=0x603, rx_id=0x703, padding=False, ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" assert s1 in result assert s2 in result @@ -320,10 +312,8 @@ with ISOTPSoftSocket(sock_recv1, tx_id=0x1ffff702, rx_id=0x1ffff602, ext_address can_interface="can0", verbose=False) -s1 = "ISOTPSocket(can0, tx_id=0x1ffff602, rx_id=0x1ffff702, padding=False, " \ - "ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" -s2 = "ISOTPSocket(can0, tx_id=0x1ffff603, rx_id=0x1ffff703, padding=False, " \ - "ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" +s1 = "ISOTPSocket(can0, tx_id=0x1ffff602, rx_id=0x1ffff702, padding=False, ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" +s2 = "ISOTPSocket(can0, tx_id=0x1ffff603, rx_id=0x1ffff703, padding=False, ext_address=0x22, rx_ext_address=0x11, basecls=ISOTP)" print(result) assert s1 in result assert s2 in result diff --git a/test/contrib/lacp.uts b/test/contrib/lacp.uts index 3c778e890d1..df971705594 100644 --- a/test/contrib/lacp.uts +++ b/test/contrib/lacp.uts @@ -25,13 +25,11 @@ params = dict( ) pkt = Ether(src="00:13:c4:12:0f:0d") / SlowProtocol() / LACP(**params) s = raw(pkt) -raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x01\x01\x01\x14\x80' \ - b'\x00\x00\x13\xc4\x12\x0f\x00\x00\x0d\x80\x00\x00\x16\x85\x00\x00\x00\x02\x14' \ - b'\x80\x00\x00\x0e\x83\x16\xf5\x00\x00\x0d\x80\x00\x00\x19\x36\x00\x00\x00\x03' \ - b'\x10\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +raw_pkt = (b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x01\x01\x01\x14\x80\x00\x00\x13\xc4\x12\x0f\x00' + b'\x00\x0d\x80\x00\x00\x16\x85\x00\x00\x00\x02\x14\x80\x00\x00\x0e\x83\x16\xf5\x00\x00\x0d\x80\x00\x00\x19' + b'\x36\x00\x00\x00\x03\x10\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') assert s == raw_pkt p = Ether(s) diff --git a/test/contrib/lldp.uts b/test/contrib/lldp.uts index 3310d5ca11d..851efa2c08d 100644 --- a/test/contrib/lldp.uts +++ b/test/contrib/lldp.uts @@ -8,57 +8,46 @@ + Basic layer handling = build basic LLDP frames -frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC)/ \ - LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id=b'\x06\x05\x04\x03\x02\x01') / \ - LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_MAC_ADDRESS, id=b'\x01\x02\x03\x04\x05\x06')/\ - LLDPDUTimeToLive()/\ - LLDPDUSystemName(system_name='mate')/\ - LLDPDUSystemCapabilities(telephone_available=1, router_available=1, telephone_enabled=1)/\ - LLDPDUManagementAddress( - management_address_subtype=LLDPDUManagementAddress.SUBTYPE_MANAGEMENT_ADDRESS_IPV4, - management_address='1.2.3.4', - interface_numbering_subtype=LLDPDUManagementAddress.SUBTYPE_INTERFACE_NUMBER_IF_INDEX, - interface_number=23, - object_id='abcd') / \ - LLDPDUEndOfLLDPDU() +frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUChassisID( + subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id=b'\x06\x05\x04\x03\x02\x01') / LLDPDUPortID( + subtype=LLDPDUPortID.SUBTYPE_MAC_ADDRESS, id=b'\x01\x02\x03\x04\x05\x06') / LLDPDUTimeToLive() / LLDPDUSystemName( + system_name='mate') / LLDPDUSystemCapabilities(telephone_available=1, router_available=1, + telephone_enabled=1) / LLDPDUManagementAddress( + management_address_subtype=LLDPDUManagementAddress.SUBTYPE_MANAGEMENT_ADDRESS_IPV4, + management_address='1.2.3.4', + interface_numbering_subtype=LLDPDUManagementAddress.SUBTYPE_INTERFACE_NUMBER_IF_INDEX, + interface_number=23, + object_id='abcd') / LLDPDUEndOfLLDPDU() frm = frm.build() frm = Ether(frm) = build: check length calculation (#GH3107) -frame = Ether(src='aa:bb:cc:dd:ee:ff', dst='11:22:33:44:55:66') / \ - LLDPDUChassisID(subtype=0x04, id='aa:bb:cc:dd:ee:ff') / \ - LLDPDUPortID(subtype=0x05, id='1') / \ - LLDPDUTimeToLive(ttl=5) / \ - LLDPDUManagementAddress(management_address_subtype=0x01, management_address=socket.inet_aton('192.168.0.10')) +frame = Ether(src='aa:bb:cc:dd:ee:ff', dst='11:22:33:44:55:66') / LLDPDUChassisID(subtype=0x04, + id='aa:bb:cc:dd:ee:ff') / LLDPDUPortID( + subtype=0x05, id='1') / LLDPDUTimeToLive(ttl=5) / LLDPDUManagementAddress(management_address_subtype=0x01, + management_address=socket.inet_aton( + '192.168.0.10')) data = b'\x11"3DUf\xaa\xbb\xcc\xdd\xee\xff\x88\xcc\x02\x07\x04\xaa\xbb\xcc\xdd\xee\xff\x04\x02\x051\x06\x02\x00\x05\x10\x0c\x05\x01\xc0\xa8\x00\n\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' assert bytes(frame) == data = add padding if required conf.contribs['LLDP'].strict_mode_disable() -frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / \ - LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_INTERFACE_NAME, id='eth0') / \ - LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / \ - LLDPDUTimeToLive() / \ - LLDPDUEndOfLLDPDU() +frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUPortID( + subtype=LLDPDUPortID.SUBTYPE_INTERFACE_NAME, id='eth0') / LLDPDUChassisID( + subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / LLDPDUTimeToLive() / LLDPDUEndOfLLDPDU() assert len(raw(frm)) == 60 assert len(raw(Ether(raw(frm))[Padding])) == 24 -frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / \ - LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_INTERFACE_NAME, id='eth012345678901234567890123') / \ - LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / \ - LLDPDUTimeToLive() / \ - LLDPDUEndOfLLDPDU() +frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUPortID( + subtype=LLDPDUPortID.SUBTYPE_INTERFACE_NAME, id='eth012345678901234567890123') / LLDPDUChassisID( + subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / LLDPDUTimeToLive() / LLDPDUEndOfLLDPDU() assert (len(raw(frm)) == 60) assert (len(raw(Ether(raw(frm))[Padding])) == 1) -frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / \ - LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_INTERFACE_NAME, id='eth0123456789012345678901234') / \ - LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / \ - LLDPDUTimeToLive() / \ - LLDPDUEndOfLLDPDU() +frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_INTERFACE_NAME, id='eth0123456789012345678901234') / LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / LLDPDUTimeToLive() / LLDPDUEndOfLLDPDU() assert (len(raw(frm)) == 60) try: Ether(raw(frm))[Padding] @@ -201,12 +190,12 @@ except LLDPInvalidFrameStructure: # missing LLDPDUEndOfLLDPDU try: - frm = Ether() / LLDPDUChassisID(id='slartibart') / LLDPDUPortID(id='42') / \ - LLDPDUPortID(id='23') / LLDPDUTimeToLive() / LLDPDUEndOfLLDPDU() - Ether(frm.build()) - assert False + frm = Ether() / LLDPDUChassisID(id='slartibart') / LLDPDUPortID(id='42') / LLDPDUPortID( + id='23') / LLDPDUTimeToLive() / LLDPDUEndOfLLDPDU() + Ether(frm.build()) + assert False except LLDPInvalidFrameStructure: - pass + pass conf.contribs['LLDP'].strict_mode_disable() frm = Ether()/LLDPDUChassisID()/LLDPDUTimeToLive()/LLDPDUEndOfLLDPDU() @@ -251,24 +240,19 @@ frm = Ether(frm.build()) conf.contribs['LLDP'].strict_mode_enable() -frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC)/ \ - LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / \ - LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_MAC_ADDRESS, id='01:02:03:04:05:06')/\ - LLDPDUTimeToLive()/\ - LLDPDUSystemName(system_name='things will')/\ - LLDPDUSystemCapabilities(telephone_available=1, - router_available=1, - telephone_enabled=1, - router_enabled=1)/\ - LLDPDUManagementAddress( - management_address_subtype=LLDPDUManagementAddress.SUBTYPE_MANAGEMENT_ADDRESS_IPV4, - management_address='1.2.3.4', - interface_numbering_subtype=LLDPDUManagementAddress.SUBTYPE_INTERFACE_NUMBER_IF_INDEX, - interface_number=23, - object_id='burn') / \ - LLDPDUSystemDescription(description='without tests.') / \ - LLDPDUPortDescription(description='always!') / \ - LLDPDUEndOfLLDPDU() +frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUChassisID( + subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id='06:05:04:03:02:01') / LLDPDUPortID( + subtype=LLDPDUPortID.SUBTYPE_MAC_ADDRESS, id='01:02:03:04:05:06') / LLDPDUTimeToLive() / LLDPDUSystemName( + system_name='things will') / LLDPDUSystemCapabilities(telephone_available=1, + router_available=1, + telephone_enabled=1, + router_enabled=1) / LLDPDUManagementAddress( + management_address_subtype=LLDPDUManagementAddress.SUBTYPE_MANAGEMENT_ADDRESS_IPV4, + management_address='1.2.3.4', + interface_numbering_subtype=LLDPDUManagementAddress.SUBTYPE_INTERFACE_NUMBER_IF_INDEX, + interface_number=23, + object_id='burn') / LLDPDUSystemDescription(description='without tests.') / LLDPDUPortDescription( + description='always!') / LLDPDUEndOfLLDPDU() frm = Ether(frm.build()) @@ -338,15 +322,14 @@ assert three_b_enum_field.i2repr(None, 0x49763) == '300899' = LLDPDUGenericOrganisationSpecific tests -frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC)/\ - LLDPDUChassisID(subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id=b'\x06\x05\x04\x03\x02\x01')/\ - LLDPDUPortID(subtype=LLDPDUPortID.SUBTYPE_MAC_ADDRESS, id=b'\x01\x02\x03\x04\x05\x06')/\ - LLDPDUTimeToLive()/\ - LLDPDUGenericOrganisationSpecific(org_code=LLDPDUGenericOrganisationSpecific.ORG_UNIQUE_CODE_PNO, - subtype=0x42, - data=b'FooBar'*5 - )/\ - LLDPDUEndOfLLDPDU() +frm = Ether(src='01:01:01:01:01:01', dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUChassisID( + subtype=LLDPDUChassisID.SUBTYPE_MAC_ADDRESS, id=b'\x06\x05\x04\x03\x02\x01') / LLDPDUPortID( + subtype=LLDPDUPortID.SUBTYPE_MAC_ADDRESS, + id=b'\x01\x02\x03\x04\x05\x06') / LLDPDUTimeToLive() / LLDPDUGenericOrganisationSpecific( + org_code=LLDPDUGenericOrganisationSpecific.ORG_UNIQUE_CODE_PNO, + subtype=0x42, + data=b'FooBar' * 5 + ) / LLDPDUEndOfLLDPDU() frm = frm.build() frm = Ether(frm) @@ -360,11 +343,9 @@ assert org_spec_layer._length == 34 l="A" * 24 c=LLDPDUChassisID.SUBTYPE_CHASSIS_COMPONENT p=LLDPDUPortID.SUBTYPE_MAC_ADDRESS -frm = Ether(dst=LLDP_NEAREST_BRIDGE_MAC)/ \ - LLDPDUChassisID(subtype=c, id=l)/ \ - LLDPDUPortID(subtype=p, id=l)/ \ - LLDPDUTimeToLive(ttl=2)/ \ - LLDPDUEndOfLLDPDU() +frm = Ether(dst=LLDP_NEAREST_BRIDGE_MAC) / LLDPDUChassisID(subtype=c, id=l) / LLDPDUPortID(subtype=p, + id=l) / LLDPDUTimeToLive( + ttl=2) / LLDPDUEndOfLLDPDU() try: frm = frm.build() diff --git a/test/contrib/ltp.uts b/test/contrib/ltp.uts index 0366ad0383f..f1df46d5357 100644 --- a/test/contrib/ltp.uts +++ b/test/contrib/ltp.uts @@ -9,23 +9,23 @@ = Build packets & dissect load_contrib("ltp") -pkt = Ether(src="aa:aa:aa:aa:aa:aa", dst="bb:bb:bb:bb:bb:bb")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP()/LTP(flags=8,\ - SessionOriginator=2, - SessionNumber=113, - ReportCheckpointSerialNo=12, - ReportUpperBound=0, - ReportLowerBound=5, - ReportReceptionClaims=[ - LTPReceptionClaim(ReceptionClaimOffset=1, ReceptionClaimLength=4), - LTPReceptionClaim(ReceptionClaimOffset=2, ReceptionClaimLength=3), - ], - HeaderExtensions=[ - LTPex(ExTag=1, ExData=b"\x00"), - ], - TrailerExtensions=[ - LTPex(ExTag=0, ExData=b"\x01"), - LTPex(ExTag=1, ExData=b"\x02"), - ]) +pkt = Ether(src="aa:aa:aa:aa:aa:aa", dst="bb:bb:bb:bb:bb:bb") / IP(src="192.168.0.1", dst="192.168.0.2") / UDP() / LTP( + flags=8, SessionOriginator=2, + SessionNumber=113, + ReportCheckpointSerialNo=12, + ReportUpperBound=0, + ReportLowerBound=5, + ReportReceptionClaims=[ + LTPReceptionClaim(ReceptionClaimOffset=1, ReceptionClaimLength=4), + LTPReceptionClaim(ReceptionClaimOffset=2, ReceptionClaimLength=3), + ], + HeaderExtensions=[ + LTPex(ExTag=1, ExData=b"\x00"), + ], + TrailerExtensions=[ + LTPex(ExTag=0, ExData=b"\x01"), + LTPex(ExTag=1, ExData=b"\x02"), + ]) pkt = Ether(raw(pkt)) assert LTP in pkt diff --git a/test/contrib/mac_control.uts b/test/contrib/mac_control.uts index ee559a579d9..4db55645944 100644 --- a/test/contrib/mac_control.uts +++ b/test/contrib/mac_control.uts @@ -9,8 +9,7 @@ = pause frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/\ - MACControlPause(pause_time=0x1234) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlPause(pause_time=0x1234) frm = Ether(frm.do_build()) @@ -20,8 +19,7 @@ assert pause_layer.get_pause_time(ETHER_SPEED_MBIT_10) == 0.238592 = gate frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/\ - MACControlGate(timestamp=0x12345678) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlGate(timestamp=0x12345678) frm = Ether(frm.do_build()) gate_layer = frm[MACControlGate] @@ -29,8 +27,8 @@ assert gate_layer.timestamp == 0x12345678 = report frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/\ - MACControlReport(timestamp=0x12345678, pending_grants=0x23) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlReport(timestamp=0x12345678, + pending_grants=0x23) frm = Ether(frm.do_build()) @@ -42,19 +40,18 @@ assert report_layer.pending_grants == 0x23 = report frame flags (generic for all other register frame types) for flag in MACControl.REGISTER_FLAGS: - frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / \ - MACControlReport(timestamp=0x12345678, flags=flag) - frm = Ether(frm.do_build()) - report_layer = frm[MACControlReport] - assert report_layer.flags == flag + frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlReport(timestamp=0x12345678, + flags=flag) + frm = Ether(frm.do_build()) + report_layer = frm[MACControlReport] + assert report_layer.flags == flag = register_req frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/\ - MACControlRegisterReq(timestamp=0x87654321, - echoed_pending_grants=0x12, - sync_time=0x3344, - assigned_port=0x7766) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlRegisterReq(timestamp=0x87654321, + echoed_pending_grants=0x12, + sync_time=0x3344, + assigned_port=0x7766) frm = Ether(frm.do_build()) register_req_layer = frm[MACControlRegisterReq] @@ -66,10 +63,9 @@ assert (register_req_layer.assigned_port == 0x7766) = register frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/\ - MACControlRegister(timestamp=0x11223344, - echoed_assigned_port=0x2277, - echoed_sync_time=0x3399) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlRegister(timestamp=0x11223344, + echoed_assigned_port=0x2277, + echoed_sync_time=0x3399) frm = Ether(frm.do_build()) register_layer = frm[MACControlRegister] @@ -79,10 +75,9 @@ assert register_layer.echoed_sync_time == 0x3399 = register_ack frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/\ - MACControlRegisterAck(timestamp=0x11223344, - echoed_assigned_port=0x2277, - echoed_sync_time=0x3399) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlRegisterAck(timestamp=0x11223344, + echoed_assigned_port=0x2277, + echoed_sync_time=0x3399) frm = Ether(frm.do_build()) register_ack_layer = frm[MACControlRegisterAck] @@ -92,9 +87,11 @@ assert register_ack_layer.echoed_sync_time == 0x3399 = class based flow control frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC)/ \ - MACControlClassBasedFlowControl(c0_enabled=1, c0_pause_time=0x4321, - c5_enabled=1, c5_pause_time=0x1234) + +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlClassBasedFlowControl(c0_enabled=1, + c0_pause_time=0x4321, + c5_enabled=1, + c5_pause_time=0x1234) frm = Ether(frm.do_build()) cbfc_layer = frm[MACControlClassBasedFlowControl] @@ -112,36 +109,31 @@ assert cbfc_layer._reserved == 0 = naked frame -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / \ - MACControlRegisterAck(timestamp=0x12345678) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlRegisterAck(timestamp=0x12345678) frm = frm.do_build() assert len(frm) == 60 = single vlan tag -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / \ - Dot1Q(vlan=42) / \ - MACControlRegisterAck(timestamp=0x12345678) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / Dot1Q(vlan=42) / MACControlRegisterAck( + timestamp=0x12345678) frm = frm.do_build() assert len(frm) == 60 = QinQ -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / \ - Dot1Q(vlan=42) / \ - Dot1Q(vlan=42) / \ - MACControlRegisterAck(timestamp=0x12345678) +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / Dot1Q(vlan=42) / Dot1Q( + vlan=42) / MACControlRegisterAck(timestamp=0x12345678) frm = frm.do_build() assert len(frm) == 60 = hand craftet payload (disabled auto padding) -frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / \ - MACControlRegisterAck(timestamp=0x12345678) / \ - Raw(b'may pass devices') +frm = Ether(src='00:01:01:01:01:01', dst=MACControl.DEFAULT_DST_MAC) / MACControlRegisterAck( + timestamp=0x12345678) / Raw(b'may pass devices') frm = Ether(frm.do_build()) raw_layer = frm[Raw] diff --git a/test/contrib/mqttsn.uts b/test/contrib/mqttsn.uts index 564e4ff6a1a..81e135f0445 100644 --- a/test/contrib/mqttsn.uts +++ b/test/contrib/mqttsn.uts @@ -704,8 +704,7 @@ assert p.type == WILLMSGRESP assert p.return_code == REJ_TID = MQTTSNEncaps, packet instantiation -p = MQTTSN() / MQTTSNEncaps(radius=1, w_node_id="test") / MQTTSN() / \ - MQTTSNConnack() +p = MQTTSN() / MQTTSNEncaps(radius=1, w_node_id="test") / MQTTSN() / MQTTSNConnack() assert p.len is None assert p.type == ENCAPS_MSG assert p.radius == 1 @@ -736,8 +735,7 @@ assert p.payload.payload.type == CONNACK assert p.payload.payload.return_code == ACCEPTED = MQTTSNEncaps, packet dissection -- long payload -b = b"\x07\xfe\x02test" + b"\x01\x04\x64\x0c" + b"\x00\xb1\x39\xd7\x4a" + \ - (1115 * b"X") +b = b"\x07\xfe\x02test" + b"\x01\x04\x64\x0c" + b"\x00\xb1\x39\xd7\x4a" + (1115 * b"X") p = MQTTSN(b) assert p.len == 7 assert p.type == ENCAPS_MSG @@ -795,18 +793,12 @@ assert type(MQTTSN().fieldtype["len"].randval() + 0) == int = Disect full IPv6 packages ~ dport == 1883 (0x75b) -b = b"\x60\x00\x00\x00\x00\x2c\x11\x40\x20\x01\x0d\xb8\x00\x00\x00\x00" \ - b"\x17\x11\x6b\x10\x65\xf7\x5f\x0a\x20\x01\x0d\xb8\x00\x00\x00\x00" \ - b"\x17\x11\x6b\x10\x65\xfd\xbe\x06\xc0\x00\x07\x5b\x00\x2c\x40\x7e" \ - b"\x0b\x0a\0\0\x48\x8a/testing" +b = b"\x60\x00\x00\x00\x00\x2c\x11\x40\x20\x01\x0d\xb8\x00\x00\x00\x00\x17\x11\x6b\x10\x65\xf7\x5f\x0a\x20\x01\x0d\xb8\x00\x00\x00\x00\x17\x11\x6b\x10\x65\xfd\xbe\x06\xc0\x00\x07\x5b\x00\x2c\x40\x7e\x0b\x0a\0\0\x48\x8a/testing" p = IPv6(b) assert MQTTSNRegister in p ~ sport == 1883 (0x75b) -b = b"\x60\x00\x00\x00\x00\x0f\x11\x40\x20\x01\x0d\xb8\x00\x00\x00\x00" \ - b"\x17\x11\x6b\x10\x65\xfd\xbe\x06\x20\x01\x0d\xb8\x00\x00\x00\x00" \ - b"\x17\x11\x6b\x10\x65\xf7\x5f\x0a\x07\x5b\xc0\x00\x00\x0f\x62\x7c" \ - b"\x07\x0d\x00\x01\x86\x2f\x00" +b = b"\x60\x00\x00\x00\x00\x0f\x11\x40\x20\x01\x0d\xb8\x00\x00\x00\x00\x17\x11\x6b\x10\x65\xfd\xbe\x06\x20\x01\x0d\xb8\x00\x00\x00\x00\x17\x11\x6b\x10\x65\xf7\x5f\x0a\x07\x5b\xc0\x00\x00\x0f\x62\x7c\x07\x0d\x00\x01\x86\x2f\x00" p = IPv6(b) assert MQTTSNPuback in p diff --git a/test/contrib/opc_da.uts b/test/contrib/opc_da.uts index c664a6ede74..055cfa55dd7 100644 --- a/test/contrib/opc_da.uts +++ b/test/contrib/opc_da.uts @@ -5,14 +5,14 @@ opcdaRequestPacket_Dissect = hex_bytes(b'050000830000000000640000000000150000003c000600050000c41d0a9c0000d7028c761299f7bf00000000') elem1 = raw(OpcDaMessage(opcdaRequestPacket_Dissect)) -opcdaRequestPacket_Build = OpcDaMessage(OpcDaMessage= \ -OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=0, \ - pfc_flags = 131,integerRepresentation='bigEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderN(fragLength=100,authLength=0,callID=21)\ - / OpcDaRequest(allocHint=60,contextId=6,opNum=5,\ - uuid=b'0000c41d-0a9c-0000-d702-8c761299f7bf',stubData=RequestStubData(\ - versionMajor=0,versionMinor=0,stubdata=''))) +opcdaRequestPacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=0, pfc_flags=131, + integerRepresentation='bigEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderN(fragLength=100, + authLength=0, + callID=21) / OpcDaRequest( + allocHint=60, contextId=6, opNum=5, uuid=b'0000c41d-0a9c-0000-d702-8c761299f7bf', + stubData=RequestStubData(versionMajor=0, versionMinor=0, stubdata=''))) elem2 = raw(opcdaRequestPacket_Build) assert elem1 == elem2 @@ -21,15 +21,15 @@ assert elem1 == elem2 opcdaRequestLEPacket_Dissect = hex_bytes(b'050000831000000064000000150000003c000000060005001dc400009c0a0000d7028c761299f7bf000000000000000000000000512d4e34ab431449a2cf7784b21b3ea1') elem1 = raw(OpcDaMessage(opcdaRequestLEPacket_Dissect)) -opcdaRequestLEPacket_Build = OpcDaMessage(OpcDaMessage= \ -OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=0, \ - pfc_flags = 131,integerRepresentation='littleEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderNLE(fragLength=100,authLength=0,callID=21)\ - / OpcDaRequestLE (allocHint=60,contextId=6,opNum=5,\ - uuid=b'0000c41d-0a9c-0000-d702-8c761299f7bf',\ - stubData=RequestStubDataLE(versionMajor=0,versionMinor=0,\ - stubdata=b'\x00\x00\x00\x00\x00\x00\x00\x00Q-N4\xabC\x14I\xa2\xcfw\x84\xb2\x1b>\xa1'))) +opcdaRequestLEPacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=0, pfc_flags=131, + integerRepresentation='littleEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderNLE(fragLength=100, + authLength=0, + callID=21) / OpcDaRequestLE( + allocHint=60, contextId=6, opNum=5, uuid=b'0000c41d-0a9c-0000-d702-8c761299f7bf', + stubData=RequestStubDataLE(versionMajor=0, versionMinor=0, + stubdata=b'\x00\x00\x00\x00\x00\x00\x00\x00Q-N4\xabC\x14I\xa2\xcfw\x84\xb2\x1b>\xa1'))) elem2 = raw(opcdaRequestLEPacket_Build) assert elem1 == elem2 @@ -40,12 +40,12 @@ assert elem1 == elem2 opcdaPingPacket_Dissect = hex_bytes(b'0500010310000000640000001500000000') elem1 = raw(OpcDaMessage(opcdaPingPacket_Dissect)) -opcdaPingPacket_Build = OpcDaMessage(OpcDaMessage= \ - OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=1, \ - pfc_flags = 3,integerRepresentation='littleEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderNLE(fragLength=100,authLength=0,callID=21)\ - / OpcDaPing()) / '\x00' +opcdaPingPacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=1, pfc_flags=3, + integerRepresentation='littleEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderNLE(fragLength=100, + authLength=0, + callID=21) / OpcDaPing()) / '\x00' elem2 = raw(opcdaPingPacket_Build) assert elem1 == elem2 @@ -56,13 +56,13 @@ assert elem1 == elem2 opcDaResponsePacket_Dissect = hex_bytes(b'050002030000000000d4000000000015000000bc00060000303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030') elem1 = raw(OpcDaMessage(opcDaResponsePacket_Dissect)) -opcDaResponsePacket_Build = OpcDaMessage(OpcDaMessage= \ - OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=2, \ - pfc_flags = 3,integerRepresentation='bigEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderN(fragLength=212,authLength=0,callID=21)\ - / OpcDaResponse(allocHint=188,contextId=6,cancelCount=0,reserved=0,\ - stubData=b'0'*(212-32))) +opcDaResponsePacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=2, pfc_flags=3, + integerRepresentation='bigEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderN(fragLength=212, + authLength=0, + callID=21) / OpcDaResponse( + allocHint=188, contextId=6, cancelCount=0, reserved=0, stubData=b'0' * (212 - 32))) elem2 = raw(opcDaResponsePacket_Build) assert elem1 == elem2 @@ -71,13 +71,13 @@ assert elem1 == elem2 opcDaResponseLEPacket_Dissect = hex_bytes(b'0500020310000000d400000015000000bc00000006000000303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030') elem1 = raw(OpcDaMessage(opcDaResponseLEPacket_Dissect)) -opcDaResponseLEPacket_Build = OpcDaMessage(OpcDaMessage= \ - OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=2, \ - pfc_flags = 3,integerRepresentation='littleEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderNLE(fragLength=212,authLength=0,callID=21)\ - / OpcDaResponseLE(allocHint=188,contextId=6,cancelCount=0,reserved=0,\ - stubData=b'0'*(212-32))) +opcDaResponseLEPacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=2, pfc_flags=3, + integerRepresentation='littleEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderNLE(fragLength=212, + authLength=0, + callID=21) / OpcDaResponseLE( + allocHint=188, contextId=6, cancelCount=0, reserved=0, stubData=b'0' * (212 - 32))) elem2 = raw(opcDaResponseLEPacket_Build) assert elem1 == elem2 @@ -136,32 +136,28 @@ assert elem1 == elem2 opcDaAlter_contextPacket_Dissect = hex_bytes(b'05000e0300000000004800000000001716d016d00008294500000001070001000101000000000000c00000000000004600000000045d888aeb1cc9119fe808002b10486002000000') elem1 = raw(OpcDaMessage(opcDaAlter_contextPacket_Dissect)) -ocDaAlter_contextPacket_Build = OpcDaMessage(OpcDaMessage= \ - OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=14, \ - pfc_flags = 3,integerRepresentation='bigEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderN(fragLength=72,authLength=0,callID=23)\ - / OpcDaAlter_context(maxXmitFrag=5840,maxRecvtFrag=5840,\ - assocGroupId=534853)) \ - / '\x00\x00\x00\x01\x07\x00\x01\x00\x01\x01\x00\x00\x00\x00\x00\x00\xc0'\ - '\x00\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9'\ - '\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00' +ocDaAlter_contextPacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=14, pfc_flags=3, + integerRepresentation='bigEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderN(fragLength=72, + authLength=0, + callID=23) / OpcDaAlter_context( + maxXmitFrag=5840, maxRecvtFrag=5840, + assocGroupId=534853)) / '\x00\x00\x00\x01\x07\x00\x01\x00\x01\x01\x00\x00\x00\x00\x00\x00\xc0' '\x00\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9' '\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00' elem2 = raw(ocDaAlter_contextPacket_Build) = OpcDaAlter_contextLE opcDaAlter_contextLEPacket_Dissect = hex_bytes(b'05000e03100000004800000017000000d016d0164529080001000000070001000101000000000000c00000000000004600000000045d888aeb1cc9119fe808002b10486002000000') elem1 = raw(OpcDaMessage(opcDaAlter_contextLEPacket_Dissect)) -ocDaAlter_contextLEPacket_Build = OpcDaMessage(OpcDaMessage= \ - OpcDaHeaderMessage (versionMajor=5,versionMinor=0,pduType=14, \ - pfc_flags = 3,integerRepresentation='littleEndian',\ - characterRepresentation='ascii',floatingPointRepresentation='ieee',\ - res=0)/ OpcDaHeaderNLE(fragLength=72,authLength=0,callID=23)\ - / OpcDaAlter_contextLE(maxXmitFrag=5840,maxRecvtFrag=5840,\ - assocGroupId=534853)) \ - / '\x01\x00\x00\x00\x07\x00\x01\x00\x01\x01\x00\x00\x00\x00\x00\x00\xc0'\ - '\x00\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9'\ - '\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00' +ocDaAlter_contextLEPacket_Build = OpcDaMessage( + OpcDaMessage=OpcDaHeaderMessage(versionMajor=5, versionMinor=0, pduType=14, pfc_flags=3, + integerRepresentation='littleEndian', characterRepresentation='ascii', + floatingPointRepresentation='ieee', res=0) / OpcDaHeaderNLE(fragLength=72, + authLength=0, + callID=23) / OpcDaAlter_contextLE( + maxXmitFrag=5840, maxRecvtFrag=5840, + assocGroupId=534853)) / '\x01\x00\x00\x00\x07\x00\x01\x00\x01\x01\x00\x00\x00\x00\x00\x00\xc0' '\x00\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9' '\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00' elem2 = raw(ocDaAlter_contextLEPacket_Build) + Test Alter_context_Resp diff --git a/test/contrib/ospf.uts b/test/contrib/ospf.uts index 081d180e64c..591022cc631 100644 --- a/test/contrib/ospf.uts +++ b/test/contrib/ospf.uts @@ -29,8 +29,11 @@ assert (p[OSPF_LSUpd][OSPF_Router_LSA].linklist[0][OSPF_Link].metric == 10) = OSPF - build -pkt = Ether(dst="01:00:5e:00:00:05", src="ca:11:09:b3:00:1c")/IP(tos=0xc0, ttl=1, ihl=5, id=36333, dst="224.0.0.5", src="10.75.0.254")/OSPF_Hdr(src="75.1.3.1")/\ - OSPF_Hello(options=0x12, router="10.75.0.254", backup="10.75.0.1", neighbors=["75.1.0.1"])/OSPF_LLS_Hdr(llstlv=[LLS_Extended_Options(options='\x00\x00\x00\x01')]) +pkt = Ether(dst="01:00:5e:00:00:05", src="ca:11:09:b3:00:1c") / IP(tos=0xc0, ttl=1, ihl=5, id=36333, dst="224.0.0.5", + src="10.75.0.254") / OSPF_Hdr( + src="75.1.3.1") / OSPF_Hello(options=0x12, router="10.75.0.254", backup="10.75.0.1", + neighbors=["75.1.0.1"]) / OSPF_LLS_Hdr( + llstlv=[LLS_Extended_Options(options='\x00\x00\x00\x01')]) assert raw(pkt) == b'\x01\x00^\x00\x00\x05\xca\x11\t\xb3\x00\x1c\x08\x00E\xc0\x00P\x8d\xed\x00\x00\x01Y?Z\nK\x00\xfe\xe0\x00\x00\x05\x02\x01\x000K\x01\x03\x01\x00\x00\x00\x00>\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00\x00\n\x12\x01\x00\x00\x00(\nK\x00\xfe\nK\x00\x01K\x01\x00\x01\xff\xf6\x00\x03\x00\x01\x00\x04\x00\x00\x00\x01' = OSPF - answers @@ -44,8 +47,9 @@ assert a.answers(b) = OSPFv3 - build -pkt = Ether(dst="01:00:5e:00:00:05", src="ca:11:09:b3:00:1c")/IPv6(dst="::1", src="fe80::160c:12aa:fe7e:cd28")/OSPFv3_Hdr(src="75.1.3.1")/\ - OSPFv3_Hello(options=0x12, router="10.75.0.254", backup="10.75.0.1", neighbors=["75.1.0.1"]) +pkt = Ether(dst="01:00:5e:00:00:05", src="ca:11:09:b3:00:1c") / IPv6(dst="::1", + src="fe80::160c:12aa:fe7e:cd28") / OSPFv3_Hdr( + src="75.1.3.1") / OSPFv3_Hello(options=0x12, router="10.75.0.254", backup="10.75.0.1", neighbors=["75.1.0.1"]) assert raw(pkt) == b'\x01\x00^\x00\x00\x05\xca\x11\t\xb3\x00\x1c\x86\xdd`\x00\x00\x00\x00(Y@\xfe\x80\x00\x00\x00\x00\x00\x00\x16\x0c\x12\xaa\xfe~\xcd(\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x01\x00(K\x01\x03\x01\x00\x00\x00\x00Y\x98\x00\x00\x00\x00\x00\x00\x01\x00\x00\x12\x00\n\x00(\nK\x00\xfe\nK\x00\x01K\x01\x00\x01' = OSPFv2 Opaque lsa diff --git a/test/contrib/pcom.uts b/test/contrib/pcom.uts index b5ad57e8586..3e68117c3f9 100755 --- a/test/contrib/pcom.uts +++ b/test/contrib/pcom.uts @@ -41,21 +41,17 @@ assert f.i2repr(None, 'CC') == 'Reply of Admin Commands (CC*) \'CC\'' + Test PCOM/Binary = PCOM/Binary Default values -r = b'\x66\x00\x1b\x00\x2f\x5f\x4f\x50\x4c\x43\x00\xfe\x01\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x00\x00\x00\x45\xfd\x00\x00\x5c' +r = b'\x66\x00\x1b\x00\x2f\x5f\x4f\x50\x4c\x43\x00\xfe\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x45\xfd\x00\x00\x5c' raw(PCOMRequest(mode=0x66) / PCOMBinaryRequest())[2:] == r -r = b'\x66\x00\x1b\x00\x2f\x5f\x4f\x50\x4c\x43\xfe\x00\x01\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x00\x00\x00\x45\xfd\x00\x00\x5c' +r = b'\x66\x00\x1b\x00\x2f\x5f\x4f\x50\x4c\x43\xfe\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x45\xfd\x00\x00\x5c' raw(PCOMResponse(mode=0x66) / PCOMBinaryResponse())[2:] == r = PCOM/Binary Checksum data = b'\x01\x00\x01\x01' -r = b'\x66\x00\x1f\x00\x2f\x5f\x4f\x50\x4c\x43\x00\xfe\x01\x01\x00\x00\x4d\x00\ -\x00\x00\x00\x00\x00\x01\x04\x00\xf2\xfc\x01\x00\x01\x01\xfd\xff\x5c' +r = b'\x66\x00\x1f\x00\x2f\x5f\x4f\x50\x4c\x43\x00\xfe\x01\x01\x00\x00\x4d\x00\x00\x00\x00\x00\x00\x01\x04\x00\xf2\xfc\x01\x00\x01\x01\xfd\xff\x5c' raw(PCOMRequest(mode=0x66) / PCOMBinaryRequest(command=0x4d,reserved3=0x01, commandSpecific='\x00\x00\x00\x00\x00\x01', len=4, data= data))[2:] == r -r = b'\x66\x00\x1f\x00\x2f\x5f\x4f\x50\x4c\x43\xfe\x00\x01\x01\x00\x00\x4d\x00\ -\x00\x00\x00\x00\x00\x01\x04\x00\xf2\xfc\x01\x00\x01\x01\xfd\xff\x5c' +r = b'\x66\x00\x1f\x00\x2f\x5f\x4f\x50\x4c\x43\xfe\x00\x01\x01\x00\x00\x4d\x00\x00\x00\x00\x00\x00\x01\x04\x00\xf2\xfc\x01\x00\x01\x01\xfd\xff\x5c' raw(PCOMResponse(mode=0x66) / PCOMBinaryResponse(command=0x4d,reserved3=0x01, commandSpecific='\x00\x00\x00\x00\x00\x01', len=4, data= data))[2:] == r diff --git a/test/contrib/pfcp.uts b/test/contrib/pfcp.uts index df2d581b2b6..98139b42c2c 100644 --- a/test/contrib/pfcp.uts +++ b/test/contrib/pfcp.uts @@ -35,8 +35,7 @@ def command(pkt): for fn, fv in sorted(pkt.fields.items(), key=lambda item: item[0]): if fn in ("length", "message_type"): continue - if fn == "ietype" and not isinstance(pkt, IE_EnterpriseSpecific) and \ - not isinstance(pkt, IE_NotImplemented): + if fn == "ietype" and not isinstance(pkt, IE_EnterpriseSpecific) and not isinstance(pkt, IE_NotImplemented): continue if fn.startswith("num_") or fn.endswith("_length"): continue @@ -177,8 +176,7 @@ for n, pkt in enumerate(rdpcap("test/pcaps/pfcp.pcap"), 1): pfcpASReqBytes = hex_bytes("200500160000010000600004e1a47d08003c0006020465726777") -pfcpASReq = PFCP(version=1, S=0, seq=1) / \ - PFCPAssociationSetupRequest(IE_list=[ +pfcpASReq = PFCP(version=1, S=0, seq=1) / PFCPAssociationSetupRequest(IE_list=[ IE_RecoveryTimeStamp(timestamp=3785653512), IE_NodeId(id_type="FQDN", id="ergw") ]) @@ -208,8 +206,7 @@ assert ies[1].id == b"ergw" pfcpASRespBytes = hex_bytes("2006008c00000100001300010100600004e1a47af9002b00020001007400092980ac1201020263708002006448f9767070207631392e30382e312d3339377e673465333431343066612d6469727479206275696c7420627920726f6f74206f6e206275696c646b697473616e64626f7820617420576564204465632031312031353a30323a3535205554432032303139") -pfcpASResp = PFCP(version=1, S=0, seq=1) / \ - PFCPAssociationSetupResponse(IE_list=[ +pfcpASResp = PFCP(version=1, S=0, seq=1) / PFCPAssociationSetupResponse(IE_list=[ IE_Cause(cause="Request accepted"), IE_RecoveryTimeStamp(timestamp=3785652985), IE_UPFunctionFeatures( @@ -283,8 +280,7 @@ assert pfcpASResp.answers(pfcpASReq) pfcpSEReq1Bytes = hex_bytes("2132011300000000000000000000020000030021002c000102006c00040000000200040010002a00010000160007066163636573730003000d002c000101006c00040000000100010038006c000400000002005f000100000200190015000901104c9033ac120102001600030263700014000103003800020002001d00040000006400010057006c000400000001000200350016000706616363657373001700210100001d7065726d6974206f75742069702066726f6d20616e7920746f20616e790014000100003800020001001d00040000fde800510004000000010006001b003e000104002500021000004a00040000003c00510004000000010039000d02ffde7210bf97810aac120101003c0006020465726777") -pfcpSEReq1 = PFCP(version=1, S=1, seq=2, seid=0, spare_oct=0) / \ - PFCPSessionEstablishmentRequest(IE_list=[ +pfcpSEReq1 = PFCP(version=1, S=1, seq=2, seid=0, spare_oct=0) / PFCPSessionEstablishmentRequest(IE_list=[ IE_CreateFAR(IE_list=[ IE_ApplyAction(FORW=1), IE_FAR_Id(id=2), @@ -435,147 +431,146 @@ assert bytes(PFCP(pfcpSEReq2Bytes)) == pfcpSEReq2Bytes pfcpSEReq3Bytes = hex_bytes("213203a10000000000000000000003000003001e002c000102006c0004000000060004000d002a000102001600040373676900030037002c000102006c00040000000400040026002a000102001600040373676900260015020012687474703a2f2f6578616d706c652e636f6d0003001e002c000102006c0004000000020004000d002a000102001600040373676900030021002c000102006c00040000000500040010002a000100001600070661636365737300030021002c000102006c00040000000300040010002a000100001600070661636365737300030021002c000102006c00040000000100040010002a000100001600070661636365737300010042006c000400000006000200200018000354535400160007066163636573730014000100005d0005020ac00000003800020006001d00040000009600510004000000030001006d006c0004000000040002004b00160007066163636573730017002e0100002a7065726d6974206f75742069702066726f6d203139382e31392e36352e3420746f2061737369676e65640014000100005d0005020ac00000003800020004001d00040000006400510004000000020001006d006c0004000000020002004b00160007066163636573730017002e0100002a7065726d6974206f75742069702066726f6d203139382e31392e36352e3220746f2061737369676e65640014000100005d0005020ac00000003800020002001d0004000000c800510004000000010001003f006c0004000000050002001d0018000354535400160004037367690014000102005d0005060ac00000003800020005001d00040000009600510004000000030001006a006c0004000000030002004800160004037367690017002e0100002a7065726d6974206f75742069702066726f6d203139382e31392e36352e3420746f2061737369676e65640014000102005d0005060ac00000003800020003001d00040000006400510004000000020001006a006c0004000000010002004800160004037367690017002e0100002a7065726d6974206f75742069702066726f6d203139382e31392e36352e3220746f2061737369676e65640014000102005d0005060ac00000003800020001001d0004000000c8005100040000000100060013003e000102002500020000005100040000000200060013003e000103002500020000005100040000000300060013003e00010200250002000000510004000000010039000d02ffde7211a5ab800aac120101003c0006020465726777") -pfcpSEReq3 = PFCP(seq=3) / \ - PFCPSessionEstablishmentRequest(IE_list=[ - IE_CreateFAR(IE_list=[ - IE_ApplyAction(FORW=1), - IE_FAR_Id(id=6), - IE_ForwardingParameters(IE_list=[ - IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), - IE_NetworkInstance(instance="sgi") - ]) - ]), - IE_CreateFAR(IE_list=[ - IE_ApplyAction(FORW=1), - IE_FAR_Id(id=4), - IE_ForwardingParameters(IE_list=[ - IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), - IE_NetworkInstance(instance="sgi"), - IE_RedirectInformation(type="URL", address="http://example.com") - ]) - ]), - IE_CreateFAR(IE_list=[ - IE_ApplyAction(FORW=1), - IE_FAR_Id(id=2), - IE_ForwardingParameters(IE_list=[ - IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), - IE_NetworkInstance(instance="sgi") - ]) - ]), - IE_CreateFAR(IE_list=[ - IE_ApplyAction(FORW=1), - IE_FAR_Id(id=5), - IE_ForwardingParameters(IE_list=[ - IE_DestinationInterface(interface="Access"), - IE_NetworkInstance(instance="access") - ]) - ]), - IE_CreateFAR(IE_list=[ - IE_ApplyAction(FORW=1), - IE_FAR_Id(id=3), - IE_ForwardingParameters(IE_list=[ - IE_DestinationInterface(interface="Access"), - IE_NetworkInstance(instance="access") - ]) - ]), - IE_CreateFAR(IE_list=[ - IE_ApplyAction(FORW=1), - IE_FAR_Id(id=1), - IE_ForwardingParameters(IE_list=[ - IE_DestinationInterface(interface="Access"), - IE_NetworkInstance(instance="access") - ]) - ]), - IE_CreatePDR(IE_list=[ - IE_FAR_Id(id=6), - IE_PDI(IE_list=[ - IE_ApplicationId(id="TST"), - IE_NetworkInstance(instance="access"), - IE_SourceInterface(interface="Access"), - IE_UE_IP_Address(ipv4='10.192.0.0', V4=1) - ]), - IE_PDR_Id(id=6), - IE_Precedence(precedence=150), - IE_URR_Id(id=3) - ]), - IE_CreatePDR(IE_list=[ - IE_FAR_Id(id=4), - IE_PDI(IE_list=[ - IE_NetworkInstance(instance="access"), - IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.4 to assigned"), - IE_SourceInterface(interface="Access"), - IE_UE_IP_Address(ipv4='10.192.0.0', V4=1) - ]), - IE_PDR_Id(id=4), - IE_Precedence(precedence=100), - IE_URR_Id(id=2) - ]), - IE_CreatePDR(IE_list=[ - IE_FAR_Id(id=2), - IE_PDI(IE_list=[ - IE_NetworkInstance(instance="access"), - IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.2 to assigned"), - IE_SourceInterface(interface="Access"), - IE_UE_IP_Address(ipv4='10.192.0.0', V4=1) - ]), - IE_PDR_Id(id=2), - IE_Precedence(precedence=200), - IE_URR_Id(id=1) - ]), - IE_CreatePDR(IE_list=[ - IE_FAR_Id(id=5), - IE_PDI(IE_list=[ - IE_ApplicationId(id="TST"), - IE_NetworkInstance(instance="sgi"), - IE_SourceInterface(interface="SGi-LAN/N6-LAN"), - IE_UE_IP_Address(ipv4='10.192.0.0', SD=1, V4=1) - ]), - IE_PDR_Id(id=5), - IE_Precedence(precedence=150), - IE_URR_Id(id=3) - ]), - IE_CreatePDR(IE_list=[ - IE_FAR_Id(id=3), - IE_PDI(IE_list=[ - IE_NetworkInstance(instance="sgi"), - IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.4 to assigned"), - IE_SourceInterface(interface="SGi-LAN/N6-LAN"), - IE_UE_IP_Address(ipv4='10.192.0.0', SD=1, V4=1) - ]), - IE_PDR_Id(id=3), - IE_Precedence(precedence=100), - IE_URR_Id(id=2) - ]), - IE_CreatePDR(IE_list=[ - IE_FAR_Id(id=1), - IE_PDI(IE_list=[ - IE_NetworkInstance(instance="sgi"), - IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.2 to assigned"), - IE_SourceInterface(interface="SGi-LAN/N6-LAN"), - IE_UE_IP_Address(ipv4='10.192.0.0', SD=1, V4=1) - ]), - IE_PDR_Id(id=1), - IE_Precedence(precedence=200), - IE_URR_Id(id=1) - ]), - IE_CreateURR(IE_list=[ - IE_MeasurementMethod(VOLUM=1), - IE_ReportingTriggers(), - IE_URR_Id(id=2) - ]), - IE_CreateURR(IE_list=[ - IE_MeasurementMethod(VOLUM=1, DURAT=1), - IE_ReportingTriggers(), - IE_URR_Id(id=3) - ]), - IE_CreateURR(IE_list=[ - IE_MeasurementMethod(VOLUM=1), - IE_ReportingTriggers(), - IE_URR_Id(id=1) - ]), - IE_FSEID(ipv4='172.18.1.1', v4=1, seid=0xffde7211a5ab800a), - IE_NodeId(id_type="FQDN", id="ergw") - ]) +pfcpSEReq3 = PFCP(seq=3) / PFCPSessionEstablishmentRequest(IE_list=[ + IE_CreateFAR(IE_list=[ + IE_ApplyAction(FORW=1), + IE_FAR_Id(id=6), + IE_ForwardingParameters(IE_list=[ + IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), + IE_NetworkInstance(instance="sgi") + ]) + ]), + IE_CreateFAR(IE_list=[ + IE_ApplyAction(FORW=1), + IE_FAR_Id(id=4), + IE_ForwardingParameters(IE_list=[ + IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), + IE_NetworkInstance(instance="sgi"), + IE_RedirectInformation(type="URL", address="http://example.com") + ]) + ]), + IE_CreateFAR(IE_list=[ + IE_ApplyAction(FORW=1), + IE_FAR_Id(id=2), + IE_ForwardingParameters(IE_list=[ + IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), + IE_NetworkInstance(instance="sgi") + ]) + ]), + IE_CreateFAR(IE_list=[ + IE_ApplyAction(FORW=1), + IE_FAR_Id(id=5), + IE_ForwardingParameters(IE_list=[ + IE_DestinationInterface(interface="Access"), + IE_NetworkInstance(instance="access") + ]) + ]), + IE_CreateFAR(IE_list=[ + IE_ApplyAction(FORW=1), + IE_FAR_Id(id=3), + IE_ForwardingParameters(IE_list=[ + IE_DestinationInterface(interface="Access"), + IE_NetworkInstance(instance="access") + ]) + ]), + IE_CreateFAR(IE_list=[ + IE_ApplyAction(FORW=1), + IE_FAR_Id(id=1), + IE_ForwardingParameters(IE_list=[ + IE_DestinationInterface(interface="Access"), + IE_NetworkInstance(instance="access") + ]) + ]), + IE_CreatePDR(IE_list=[ + IE_FAR_Id(id=6), + IE_PDI(IE_list=[ + IE_ApplicationId(id="TST"), + IE_NetworkInstance(instance="access"), + IE_SourceInterface(interface="Access"), + IE_UE_IP_Address(ipv4='10.192.0.0', V4=1) + ]), + IE_PDR_Id(id=6), + IE_Precedence(precedence=150), + IE_URR_Id(id=3) + ]), + IE_CreatePDR(IE_list=[ + IE_FAR_Id(id=4), + IE_PDI(IE_list=[ + IE_NetworkInstance(instance="access"), + IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.4 to assigned"), + IE_SourceInterface(interface="Access"), + IE_UE_IP_Address(ipv4='10.192.0.0', V4=1) + ]), + IE_PDR_Id(id=4), + IE_Precedence(precedence=100), + IE_URR_Id(id=2) + ]), + IE_CreatePDR(IE_list=[ + IE_FAR_Id(id=2), + IE_PDI(IE_list=[ + IE_NetworkInstance(instance="access"), + IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.2 to assigned"), + IE_SourceInterface(interface="Access"), + IE_UE_IP_Address(ipv4='10.192.0.0', V4=1) + ]), + IE_PDR_Id(id=2), + IE_Precedence(precedence=200), + IE_URR_Id(id=1) + ]), + IE_CreatePDR(IE_list=[ + IE_FAR_Id(id=5), + IE_PDI(IE_list=[ + IE_ApplicationId(id="TST"), + IE_NetworkInstance(instance="sgi"), + IE_SourceInterface(interface="SGi-LAN/N6-LAN"), + IE_UE_IP_Address(ipv4='10.192.0.0', SD=1, V4=1) + ]), + IE_PDR_Id(id=5), + IE_Precedence(precedence=150), + IE_URR_Id(id=3) + ]), + IE_CreatePDR(IE_list=[ + IE_FAR_Id(id=3), + IE_PDI(IE_list=[ + IE_NetworkInstance(instance="sgi"), + IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.4 to assigned"), + IE_SourceInterface(interface="SGi-LAN/N6-LAN"), + IE_UE_IP_Address(ipv4='10.192.0.0', SD=1, V4=1) + ]), + IE_PDR_Id(id=3), + IE_Precedence(precedence=100), + IE_URR_Id(id=2) + ]), + IE_CreatePDR(IE_list=[ + IE_FAR_Id(id=1), + IE_PDI(IE_list=[ + IE_NetworkInstance(instance="sgi"), + IE_SDF_Filter(FD=1, flow_description="permit out ip from 198.19.65.2 to assigned"), + IE_SourceInterface(interface="SGi-LAN/N6-LAN"), + IE_UE_IP_Address(ipv4='10.192.0.0', SD=1, V4=1) + ]), + IE_PDR_Id(id=1), + IE_Precedence(precedence=200), + IE_URR_Id(id=1) + ]), + IE_CreateURR(IE_list=[ + IE_MeasurementMethod(VOLUM=1), + IE_ReportingTriggers(), + IE_URR_Id(id=2) + ]), + IE_CreateURR(IE_list=[ + IE_MeasurementMethod(VOLUM=1, DURAT=1), + IE_ReportingTriggers(), + IE_URR_Id(id=3) + ]), + IE_CreateURR(IE_list=[ + IE_MeasurementMethod(VOLUM=1), + IE_ReportingTriggers(), + IE_URR_Id(id=1) + ]), + IE_FSEID(ipv4='172.18.1.1', v4=1, seid=0xffde7211a5ab800a), + IE_NodeId(id_type="FQDN", id="ergw") +]) assert bytes(pfcpSEReq3) == pfcpSEReq3Bytes assert bytes(PFCP(pfcpSEReq3Bytes)) == pfcpSEReq3Bytes @@ -584,11 +579,10 @@ assert bytes(PFCP(pfcpSEReq3Bytes)) == pfcpSEReq3Bytes pfcpSERespBytes = hex_bytes("21330022ffde7210bf97810a0000020000130001010039000d02ffde7210bf97810aac120102") -pfcpSEResp = PFCP(version=1, S=1, seq=2, seid=0xffde7210bf97810a) / \ - PFCPSessionEstablishmentResponse(IE_list=[ - IE_Cause(cause="Request accepted"), - IE_FSEID(ipv4="172.18.1.2", v4=1, seid=0xffde7210bf97810a), - ]) +pfcpSEResp = PFCP(version=1, S=1, seq=2, seid=0xffde7210bf97810a) / PFCPSessionEstablishmentResponse(IE_list=[ + IE_Cause(cause="Request accepted"), + IE_FSEID(ipv4="172.18.1.2", v4=1, seid=0xffde7210bf97810a), +]) assert bytes(pfcpSEResp) == pfcpSERespBytes assert bytes(PFCP(pfcpSERespBytes)) == pfcpSERespBytes @@ -598,10 +592,9 @@ assert pfcpSEResp.answers(pfcpSEReq1) pfcpHReqBytes = hex_bytes("2001000c0000030000600004e1a47d08") -pfcpHReq = PFCP(version=1, S=0, seq=3) / \ - PFCPHeartbeatRequest(IE_list=[ - IE_RecoveryTimeStamp(timestamp=3785653512) - ]) +pfcpHReq = PFCP(version=1, S=0, seq=3) / PFCPHeartbeatRequest(IE_list=[ + IE_RecoveryTimeStamp(timestamp=3785653512) +]) assert bytes(pfcpHReq) == pfcpHReqBytes assert bytes(PFCP(pfcpHReqBytes)) == pfcpHReqBytes @@ -610,10 +603,9 @@ assert bytes(PFCP(pfcpHReqBytes)) == pfcpHReqBytes pfcpHRespBytes = hex_bytes("2002000c0000030000600004e1a47af9") -pfcpHResp = PFCP(version=1, S=0, seq=3) / \ - PFCPHeartbeatResponse(IE_list=[ - IE_RecoveryTimeStamp(timestamp=3785652985) - ]) +pfcpHResp = PFCP(version=1, S=0, seq=3) / PFCPHeartbeatResponse(IE_list=[ + IE_RecoveryTimeStamp(timestamp=3785652985) +]) assert bytes(pfcpHResp) == pfcpHRespBytes assert bytes(PFCP(pfcpHRespBytes)) == pfcpHRespBytes @@ -623,64 +615,62 @@ assert pfcpHResp.answers(pfcpHReq) pfcpSRReq1Bytes = hex_bytes("21380034ffde7210bf99c00300006b0000270001020050001f00510004000000010068000400000001003f00021000005d0005020ac00001") -pfcpSRReq1 = PFCP(seq=107, version=1, S=1, seid=18437299340760956931) / \ - PFCPSessionReportRequest(IE_list=[ - IE_ReportType(USAR=1), - IE_UsageReport_SRR(IE_list=[ - IE_URR_Id(id=1), - IE_UR_SEQN(number=1), - IE_UsageReportTrigger(START=1), - IE_UE_IP_Address(ipv4="10.192.0.1", V4=1) - ]) - ]) +pfcpSRReq1 = PFCP(seq=107, version=1, S=1, seid=18437299340760956931) / PFCPSessionReportRequest(IE_list=[ + IE_ReportType(USAR=1), + IE_UsageReport_SRR(IE_list=[ + IE_URR_Id(id=1), + IE_UR_SEQN(number=1), + IE_UsageReportTrigger(START=1), + IE_UE_IP_Address(ipv4="10.192.0.1", V4=1) + ]) +]) assert bytes(pfcpSRReq1) == pfcpSRReq1Bytes assert bytes(PFCP(pfcpSRReq1Bytes)) == pfcpSRReq1Bytes pfcpSRReq2Bytes = hex_bytes("2138008a0ffde7210bf940000000310000270001020050007500510004000000030068000400000018003f00020100004b0004e1b44787004c0004e1b447910042001907000000000000000000000000000000000000000000000000004300040000000a8003000a48f9e1b4479137cbd8008004000a48f9e1b4478737cbd8008005000a48f9e1b4479137cbd800") -pfcpSRReq2 = PFCP(seq=49, seid=1152331208797536256) / \ - PFCPSessionReportRequest(IE_list=[ - IE_ReportType(USAR=1), - IE_UsageReport_SRR(IE_list=[ - IE_URR_Id(id=3), - IE_UR_SEQN(number=24), - IE_UsageReportTrigger(PERIO=1), - IE_StartTime(timestamp=3786688391), - IE_EndTime(timestamp=3786688401), - IE_VolumeMeasurement( - DLVOL=1, ULVOL=1, TOVOL=1, total=0, uplink=0, downlink=0), - IE_DurationMeasurement(duration=10), - IE_EnterpriseSpecific( - ietype=32771, - enterprise_id=18681, - data=b'\xe1\xb4G\x917\xcb\xd8\x00'), - IE_EnterpriseSpecific( - ietype=32772, - enterprise_id=18681, - data=b'\xe1\xb4G\x877\xcb\xd8\x00'), - IE_EnterpriseSpecific( - ietype=32773, - enterprise_id=18681, - data=b'\xe1\xb4G\x917\xcb\xd8\x00') - ]) - ]) +pfcpSRReq2 = PFCP(seq=49, seid=1152331208797536256) / PFCPSessionReportRequest(IE_list=[ + IE_ReportType(USAR=1), + IE_UsageReport_SRR(IE_list=[ + IE_URR_Id(id=3), + IE_UR_SEQN(number=24), + IE_UsageReportTrigger(PERIO=1), + IE_StartTime(timestamp=3786688391), + IE_EndTime(timestamp=3786688401), + IE_VolumeMeasurement( + DLVOL=1, ULVOL=1, TOVOL=1, total=0, uplink=0, downlink=0), + IE_DurationMeasurement(duration=10), + IE_EnterpriseSpecific( + ietype=32771, + enterprise_id=18681, + data=b'\xe1\xb4G\x917\xcb\xd8\x00'), + IE_EnterpriseSpecific( + ietype=32772, + enterprise_id=18681, + data=b'\xe1\xb4G\x877\xcb\xd8\x00'), + IE_EnterpriseSpecific( + ietype=32773, + enterprise_id=18681, + data=b'\xe1\xb4G\x917\xcb\xd8\x00') + ]) +]) assert bytes(pfcpSRReq2) == pfcpSRReq2Bytes assert bytes(PFCP(pfcpSRReq2Bytes)) == pfcpSRReq2Bytes -pfcpSRReq3Bytes = hex_bytes("21380035a2a2aa9ad7f316fd0000010000270001020050002000510004000000010068000400000000003f0003100000005d000502ac100202") +pfcpSRReq3Bytes = hex_bytes( + "21380035a2a2aa9ad7f316fd0000010000270001020050002000510004000000010068000400000000003f0003100000005d000502ac100202") -pfcpSRReq3 = PFCP(seq=1, seid=11719116762396169981) / \ - PFCPSessionReportRequest(IE_list=[ - IE_ReportType(USAR=1), - IE_UsageReport_SRR(IE_list=[ - IE_URR_Id(id=1), - IE_UR_SEQN(number=0), - IE_UsageReportTrigger(START=1, extra_data=b'\x00'), - IE_UE_IP_Address(ipv4='172.16.2.2', V4=1) - ]) +pfcpSRReq3 = PFCP(seq=1, seid=11719116762396169981) / PFCPSessionReportRequest(IE_list=[ + IE_ReportType(USAR=1), + IE_UsageReport_SRR(IE_list=[ + IE_URR_Id(id=1), + IE_UR_SEQN(number=0), + IE_UsageReportTrigger(START=1, extra_data=b'\x00'), + IE_UE_IP_Address(ipv4='172.16.2.2', V4=1) ]) +]) assert bytes(pfcpSRReq3) == pfcpSRReq3Bytes assert bytes(PFCP(pfcpSRReq3Bytes)) == pfcpSRReq3Bytes @@ -689,10 +679,9 @@ assert bytes(PFCP(pfcpSRReq3Bytes)) == pfcpSRReq3Bytes pfcpSRRespBytes = hex_bytes("21390011ffde7210bf99c00300006b000013000101") -pfcpSRResp = PFCP(version=1, S=1, seq=107, seid=0xffde7210bf99c003) / \ - PFCPSessionReportResponse(IE_list=[ - IE_Cause(cause="Request accepted") - ]) +pfcpSRResp = PFCP(version=1, S=1, seq=107, seid=0xffde7210bf99c003) / PFCPSessionReportResponse(IE_list=[ + IE_Cause(cause="Request accepted") +]) assert bytes(pfcpSRResp) == pfcpSRRespBytes assert bytes(PFCP(pfcpSRRespBytes)) == pfcpSRRespBytes @@ -703,33 +692,32 @@ assert pfcpSRResp.answers(pfcpSRReq1) pfcpSMReqBytes = hex_bytes("21340018ffde72125aeb00a300000600004d00080051000400000001") pfcpSMReq = PFCP(pfcpSMReqBytes) -pfcpSMReq = PFCP(version=1, seq=6, seid=0xffde72125aeb00a3) / \ - PFCPSessionModificationRequest(IE_list=[ - IE_QueryURR(IE_list=[IE_URR_Id(id=1)]) - ]) +pfcpSMReq = PFCP(version=1, seq=6, seid=0xffde72125aeb00a3) / PFCPSessionModificationRequest(IE_list=[ + IE_QueryURR(IE_list=[IE_URR_Id(id=1)]) +]) assert bytes(pfcpSMReq) == pfcpSMReqBytes assert bytes(PFCP(pfcpSMReqBytes)) == pfcpSMReqBytes = Build and dissect PFCP Session Modification Response -pfcpSMRespBytes = hex_bytes("2135008affde72125aeb00a3000006000013000101004e007500510004000000010068000400000000003f00028000004b0004e16e7efa004c0004e16e7efa004200190700000000000000000000000000000000000000000000000000430004000000008003000a48f9e16e7efa05566c008004000a48f9e16e7efa027f08008005000a48f9e16e7efa027f0800") - -pfcpSMResp = PFCP(version=1, seq=6, seid=0xffde72125aeb00a3) / \ - PFCPSessionModificationResponse(IE_list=[ - IE_Cause(cause=1), - IE_UsageReport_SMR(IE_list=[ - IE_URR_Id(id=1), - IE_UR_SEQN(number=0), - IE_UsageReportTrigger(IMMER=1), - IE_StartTime(timestamp=3782115066), - IE_EndTime(timestamp=3782115066), - IE_VolumeMeasurement(DLVOL=1, ULVOL=1, TOVOL=1), - IE_DurationMeasurement(), - IE_EnterpriseSpecific(ietype=32771, enterprise_id=18681, data=b'\xe1n~\xfa\x05Vl\x00'), - IE_EnterpriseSpecific(ietype=32772, enterprise_id=18681, data=b'\xe1n~\xfa\x02\x7f\x08\x00'), - IE_EnterpriseSpecific(ietype=32773, enterprise_id=18681, data=b'\xe1n~\xfa\x02\x7f\x08\x00') - ]) +pfcpSMRespBytes = hex_bytes( + "2135008affde72125aeb00a3000006000013000101004e007500510004000000010068000400000000003f00028000004b0004e16e7efa004c0004e16e7efa004200190700000000000000000000000000000000000000000000000000430004000000008003000a48f9e16e7efa05566c008004000a48f9e16e7efa027f08008005000a48f9e16e7efa027f0800") + +pfcpSMResp = PFCP(version=1, seq=6, seid=0xffde72125aeb00a3) / PFCPSessionModificationResponse(IE_list=[ + IE_Cause(cause=1), + IE_UsageReport_SMR(IE_list=[ + IE_URR_Id(id=1), + IE_UR_SEQN(number=0), + IE_UsageReportTrigger(IMMER=1), + IE_StartTime(timestamp=3782115066), + IE_EndTime(timestamp=3782115066), + IE_VolumeMeasurement(DLVOL=1, ULVOL=1, TOVOL=1), + IE_DurationMeasurement(), + IE_EnterpriseSpecific(ietype=32771, enterprise_id=18681, data=b'\xe1n~\xfa\x05Vl\x00'), + IE_EnterpriseSpecific(ietype=32772, enterprise_id=18681, data=b'\xe1n~\xfa\x02\x7f\x08\x00'), + IE_EnterpriseSpecific(ietype=32773, enterprise_id=18681, data=b'\xe1n~\xfa\x02\x7f\x08\x00') ]) +]) assert bytes(pfcpSMResp) == pfcpSMRespBytes assert bytes(PFCP(pfcpSMRespBytes)) == pfcpSMRespBytes @@ -738,6 +726,7 @@ assert pfcpSMResp.answers(pfcpSMReq) = Verify IEs from difflib import unified_diff + cases = [ dict( hex="0054000a0100010000000a177645", diff --git a/test/contrib/pim.uts b/test/contrib/pim.uts index 8aa4f7e2b1c..79b4c11e729 100644 --- a/test/contrib/pim.uts +++ b/test/contrib/pim.uts @@ -82,49 +82,61 @@ assert (jp_pkt[PIMv2JoinPrune].jp_ips[2].prune_ips[0][PIMv2PruneAddrs].src_ip == = PIMv2 Hello - build -hello_delay_pkt = Ether(dst="01:00:5e:00:00:0d", src="00:d0:cb:00:ba:e4")/IP(version=4, ihl=5, tos=0xc0, id=23037, ttl=1, proto=103, src="21.21.21.21", dst="224.0.0.13")/\ - PIMv2Hdr(version=2, type=0, reserved=0)/\ - PIMv2Hello(option=[PIMv2HelloHoldtime(type=1, holdtime=105), PIMv2HelloDRPriority(type=19, dr_priority=0), - PIMv2HelloLANPruneDelay(type=2, value=[PIMv2HelloLANPruneDelayValue(t=0, propagation_delay=500, override_interval=2500)]), - PIMv2HelloGenerationID(type=20, generation_id=459007194)]) - -assert raw(hello_delay_pkt) == b'\x01\x00^\x00\x00\r\x00\xd0\xcb\x00\xba\xe4\x08\x00E\xc0\x006Y\xfd\x00\x00\x01gTm\x15\x15\x15\x15\xe0\x00\x00\r \x00\xd3p\x00\x01\x00\x02\x00i\x00\x13\x00\x04\x00\x00\x00\x00\x00\x02\x00\x04\x01\xf4\t\xc4\x00\x14\x00\x04\x1b[\xe4\xda' - -hello_refresh_pkt = Ether(dst="01:00:5e:00:00:0d", src="c2:01:52:72:00:00")/IP(version=4, ihl=5, tos=0xc0, id=121, ttl=1, proto=103, src="10.0.0.1", dst="224.0.0.13")/\ - PIMv2Hdr(version=2, type=0, reserved=0)/\ - PIMv2Hello(option=[PIMv2HelloHoldtime(type=1, holdtime=105), PIMv2HelloGenerationID(type=20, generation_id=3613938422), - PIMv2HelloDRPriority(type=19, dr_priority=1), - PIMv2HelloStateRefresh(type=21, value=[PIMv2HelloStateRefreshValue(version=1, interval=0, reserved=0)])]) - -assert raw(hello_refresh_pkt) == b'\x01\x00^\x00\x00\r\xc2\x01Rr\x00\x00\x08\x00E\xc0\x006\x00y\x00\x00\x01g\xce\x1a\n\x00\x00\x01\xe0\x00\x00\r \x00\xb3\xeb\x00\x01\x00\x02\x00i\x00\x14\x00\x04\xd7hR\xf6\x00\x13\x00\x04\x00\x00\x00\x01\x00\x15\x00\x04\x01\x00\x00\x00' +hello_delay_pkt = Ether(dst="01:00:5e:00:00:0d", src="00:d0:cb:00:ba:e4") / IP(version=4, ihl=5, tos=0xc0, id=23037, + ttl=1, proto=103, src="21.21.21.21", + dst="224.0.0.13") / PIMv2Hdr(version=2, + type=0, + reserved=0) / PIMv2Hello( + option=[PIMv2HelloHoldtime(type=1, holdtime=105), PIMv2HelloDRPriority(type=19, dr_priority=0), + PIMv2HelloLANPruneDelay(type=2, value=[ + PIMv2HelloLANPruneDelayValue(t=0, propagation_delay=500, override_interval=2500)]), + PIMv2HelloGenerationID(type=20, generation_id=459007194)]) + +assert raw( + hello_delay_pkt) == b'\x01\x00^\x00\x00\r\x00\xd0\xcb\x00\xba\xe4\x08\x00E\xc0\x006Y\xfd\x00\x00\x01gTm\x15\x15\x15\x15\xe0\x00\x00\r \x00\xd3p\x00\x01\x00\x02\x00i\x00\x13\x00\x04\x00\x00\x00\x00\x00\x02\x00\x04\x01\xf4\t\xc4\x00\x14\x00\x04\x1b[\xe4\xda' + +hello_refresh_pkt = Ether(dst="01:00:5e:00:00:0d", src="c2:01:52:72:00:00") / IP(version=4, ihl=5, tos=0xc0, id=121, + ttl=1, proto=103, src="10.0.0.1", + dst="224.0.0.13") / PIMv2Hdr(version=2, + type=0, + reserved=0) / PIMv2Hello( + option=[PIMv2HelloHoldtime(type=1, holdtime=105), PIMv2HelloGenerationID(type=20, generation_id=3613938422), + PIMv2HelloDRPriority(type=19, dr_priority=1), + PIMv2HelloStateRefresh(type=21, value=[PIMv2HelloStateRefreshValue(version=1, interval=0, reserved=0)])]) + +assert raw( + hello_refresh_pkt) == b'\x01\x00^\x00\x00\r\xc2\x01Rr\x00\x00\x08\x00E\xc0\x006\x00y\x00\x00\x01g\xce\x1a\n\x00\x00\x01\xe0\x00\x00\r \x00\xb3\xeb\x00\x01\x00\x02\x00i\x00\x14\x00\x04\xd7hR\xf6\x00\x13\x00\x04\x00\x00\x00\x01\x00\x15\x00\x04\x01\x00\x00\x00' = PIMv2 Join/Prune - build -join_pkt = Ether(dst="01:00:5e:00:00:0d", src="c2:02:3d:80:00:01")/IP(version=4, ihl=5, tos=0xc0, id=139, ttl=1, proto=103, src="10.0.0.14", dst="224.0.0.13")/\ - PIMv2Hdr(version=2, type=3, reserved=0)/\ - PIMv2JoinPrune(up_addr_family=1, up_encoding_type=0, up_neighbor_ip="10.0.0.13", reserved=0, num_group=1, holdtime=210, - jp_ips=[PIMv2GroupAddrs(addr_family=1, encoding_type=0, bidirection=0, reserved=0, admin_scope_zone=0, - mask_len=32, gaddr="239.123.123.123", - join_ips=[PIMv2JoinAddrs(addr_family=1, encoding_type=0, rsrvd=0, sparse=1, wildcard=1, - rpt=1, mask_len=32, src_ip="1.1.1.1")], - prune_ips=[]) - ] - ) - - -assert raw(join_pkt) == b'\x01\x00^\x00\x00\r\xc2\x02=\x80\x00\x01\x08\x00E\xc0\x006\x00\x8b\x00\x00\x01g\xcd\xfb\n\x00\x00\x0e\xe0\x00\x00\r#\x00Z\xe5\x01\x00\n\x00\x00\r\x00\x01\x00\xd2\x01\x00\x00 \xef{{{\x00\x01\x00\x00\x01\x00\x07 \x01\x01\x01\x01' - - - -prune_pkt = Ether(dst="01:00:5e:00:00:0d", src="c2:02:3d:80:00:01")/IP(version=4, ihl=5, tos=0xc0, id=139, ttl=1, proto=103, src="10.0.0.2", dst="224.0.0.13")/\ - PIMv2Hdr(version=2, type=3, reserved=0)/\ - PIMv2JoinPrune(up_addr_family=1, up_encoding_type=0, up_neighbor_ip="10.0.0.1", reserved=0, num_group=1, holdtime=210, - jp_ips=[PIMv2GroupAddrs(addr_family=1, encoding_type=0, bidirection=0, reserved=0, admin_scope_zone=0, - mask_len=32, gaddr="239.123.123.123", - prune_ips=[PIMv2PruneAddrs(addr_family=1, encoding_type=0, rsrvd=0, sparse=0, wildcard=0, rpt=0, - mask_len=32, src_ip="172.16.40.10")]) - ] - ) - -assert raw(prune_pkt) == b'\x01\x00^\x00\x00\r\xc2\x02=\x80\x00\x01\x08\x00E\xc0\x006\x00\x8b\x00\x00\x01g\xce\x07\n\x00\x00\x02\xe0\x00\x00\r#\x00\x8f\xd8\x01\x00\n\x00\x00\x01\x00\x01\x00\xd2\x01\x00\x00 \xef{{{\x00\x00\x00\x01\x01\x00\x00 \xac\x10(\n' - +join_pkt = Ether(dst="01:00:5e:00:00:0d", src="c2:02:3d:80:00:01") / IP(version=4, ihl=5, tos=0xc0, id=139, ttl=1, + proto=103, src="10.0.0.14", + dst="224.0.0.13") / PIMv2Hdr(version=2, type=3, + reserved=0) / PIMv2JoinPrune( + up_addr_family=1, up_encoding_type=0, up_neighbor_ip="10.0.0.13", reserved=0, num_group=1, holdtime=210, + jp_ips=[PIMv2GroupAddrs(addr_family=1, encoding_type=0, bidirection=0, reserved=0, admin_scope_zone=0, + mask_len=32, gaddr="239.123.123.123", + join_ips=[PIMv2JoinAddrs(addr_family=1, encoding_type=0, rsrvd=0, sparse=1, wildcard=1, + rpt=1, mask_len=32, src_ip="1.1.1.1")], + prune_ips=[]) + ] + ) + +assert raw( + join_pkt) == b'\x01\x00^\x00\x00\r\xc2\x02=\x80\x00\x01\x08\x00E\xc0\x006\x00\x8b\x00\x00\x01g\xcd\xfb\n\x00\x00\x0e\xe0\x00\x00\r#\x00Z\xe5\x01\x00\n\x00\x00\r\x00\x01\x00\xd2\x01\x00\x00 \xef{{{\x00\x01\x00\x00\x01\x00\x07 \x01\x01\x01\x01' + +prune_pkt = Ether(dst="01:00:5e:00:00:0d", src="c2:02:3d:80:00:01") / IP(version=4, ihl=5, tos=0xc0, id=139, ttl=1, + proto=103, src="10.0.0.2", + dst="224.0.0.13") / PIMv2Hdr(version=2, type=3, + reserved=0) / PIMv2JoinPrune( + up_addr_family=1, up_encoding_type=0, up_neighbor_ip="10.0.0.1", reserved=0, num_group=1, holdtime=210, + jp_ips=[PIMv2GroupAddrs(addr_family=1, encoding_type=0, bidirection=0, reserved=0, admin_scope_zone=0, + mask_len=32, gaddr="239.123.123.123", + prune_ips=[ + PIMv2PruneAddrs(addr_family=1, encoding_type=0, rsrvd=0, sparse=0, wildcard=0, rpt=0, + mask_len=32, src_ip="172.16.40.10")]) + ] + ) + +assert raw( + prune_pkt) == b'\x01\x00^\x00\x00\r\xc2\x02=\x80\x00\x01\x08\x00E\xc0\x006\x00\x8b\x00\x00\x01g\xce\x07\n\x00\x00\x02\xe0\x00\x00\r#\x00\x8f\xd8\x01\x00\n\x00\x00\x01\x00\x01\x00\xd2\x01\x00\x00 \xef{{{\x00\x00\x00\x01\x01\x00\x00 \xac\x10(\n' diff --git a/test/contrib/pnio.uts b/test/contrib/pnio.uts index 9528e6b0d58..5f82af671a2 100644 --- a/test/contrib/pnio.uts +++ b/test/contrib/pnio.uts @@ -116,16 +116,7 @@ p = Ether(src='01:03:05:07:09:0b', dst='00:02:04:06:08:0a')/ProfinetIO(frameID = ) assert( - raw(p) == \ - b'\x00\x02\x04\x06\x08\x0a' \ - b'\x01\x03\x05\x07\x09\x0b' \ - b'\x88\x92' \ - b'\x00\x80' \ - b'\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x03\x84' \ - b'\x35' \ - b'\x00' + raw(p) == b'\x00\x02\x04\x06\x08\x0a\x01\x03\x05\x07\x09\x0b\x88\x92\x00\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x00\x00\x00\x00\x00\x00\x00\x00\x03\x84\x35\x00' ) = ProfinetIO RTC PDU parsing with config @@ -136,17 +127,7 @@ scapy.config.conf.contribs['PNIO_RTC'][('01:03:05:07:09:0b', '00:02:04:06:08:0a' PNIORealTimeCyclicPDU.build_fixed_len_raw_type(2) ] p = Ether( - b'\x00\x02\x04\x06\x08\x0a' \ - b'\x01\x03\x05\x07\x09\x0B' \ - b'\x88\x92' \ - b'\x80\x10' \ - b'\x01\x02\x03\x04\x05' \ - b'\x01\x02\x03' \ - b'\x01\x02' \ - b'\x00\x00' \ - b'\xf0\x00' \ - b'\x35' \ - b'\x00' + b'\x00\x02\x04\x06\x08\x0a\x01\x03\x05\x07\x09\x0B\x88\x92\x80\x10\x01\x02\x03\x04\x05\x01\x02\x03\x01\x02\x00\x00\xf0\x00\x35\x00' ) assert p[Ether].dst == '00:02:04:06:08:0a' diff --git a/test/contrib/pnio_dcp.uts b/test/contrib/pnio_dcp.uts index b018db92356..5e88d54a3d0 100644 --- a/test/contrib/pnio_dcp.uts +++ b/test/contrib/pnio_dcp.uts @@ -15,10 +15,7 @@ conf.debug_dissector=True = DCP Identify All Request parsing -p = Ether(b'\x01\x0e\xcf\x00\x00\x00\x01\x23\x45\x67\x89\xab\x88\x92\xfe\xfe' \ - b'\x05\x00\x01\x00\x00\x01\x00\x01\x00\x04\xff\xff\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +p = Ether(b'\x01\x0e\xcf\x00\x00\x00\x01\x23\x45\x67\x89\xab\x88\x92\xfe\xfe\x05\x00\x01\x00\x00\x01\x00\x01\x00\x04\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') assert p[Ether].dst == '01:0e:cf:00:00:00' assert p[Ether].src == '01:23:45:67:89:ab' @@ -36,10 +33,7 @@ assert p[ProfinetDCP].dcp_block_length == 0x00 = DCP Set Request parsing -p = Ether(b'\x01\x23\x45\x67\x89\xac\x01\x23\x45\x67\x89\xab\x88\x92\xfe\xfd' \ - b'\x04\x00\x00\x00\x00\x01\x00\x00\x00\x0c\x02\x02\x00\x08\x00\x01' \ - b'\x64\x65\x76\x69\x63\x65\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +p = Ether(b'\x01\x23\x45\x67\x89\xac\x01\x23\x45\x67\x89\xab\x88\x92\xfe\xfd\x04\x00\x00\x00\x00\x01\x00\x00\x00\x0c\x02\x02\x00\x08\x00\x01\x64\x65\x76\x69\x63\x65\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') assert p[Ether].dst == '01:23:45:67:89:ac' assert p[Ether].src == '01:23:45:67:89:ab' @@ -58,13 +52,7 @@ assert p[ProfinetDCP].block_qualifier == 0x01 = DCP Identify Response parsing -p = Ether(b'\x94\x65\x9c\x51\x90\x7d\xac\x64\x17\x21\x35\xcf\x81\x00\x00\x00' \ - b'\x88\x92\xfe\xff\x05\x01\x01\x00\x00\x01\x00\x00\x00\x4e\x02\x05' \ - b'\x00\x04\x00\x00\x02\x07\x02\x01\x00\x09\x00\x00\x45\x54\x32\x30' \ - b'\x30\x53\x50\x00\x02\x02\x00\x08\x00\x00\x64\x65\x76\x69\x63\x65' \ - b'\x02\x03\x00\x06\x00\x00\x00\x2a\x03\x13\x02\x04\x00\x04\x00\x00' \ - b'\x01\x00\x02\x07\x00\x04\x00\x00\x00\x01\x01\x02\x00\x0e\x00\x01' \ - b'\xc0\xa8\x01\x0e\xff\xff\xff\x00\xc0\xa8\x01\x0e') +p = Ether(b'\x94\x65\x9c\x51\x90\x7d\xac\x64\x17\x21\x35\xcf\x81\x00\x00\x00\x88\x92\xfe\xff\x05\x01\x01\x00\x00\x01\x00\x00\x00\x4e\x02\x05\x00\x04\x00\x00\x02\x07\x02\x01\x00\x09\x00\x00\x45\x54\x32\x30\x30\x53\x50\x00\x02\x02\x00\x08\x00\x00\x64\x65\x76\x69\x63\x65\x02\x03\x00\x06\x00\x00\x00\x2a\x03\x13\x02\x04\x00\x04\x00\x00\x01\x00\x02\x07\x00\x04\x00\x00\x00\x01\x01\x02\x00\x0e\x00\x01\xc0\xa8\x01\x0e\xff\xff\xff\x00\xc0\xa8\x01\x0e') # General assert p[ProfinetIO].frameID == 0xfeff @@ -132,15 +120,7 @@ assert p[DCPIPBlock].gateway == "192.168.1.14" = DCP Identify Response parsing with new DCP packages (DCPOEMIDBlock, DCPDeviceInitiativeBlock) -p = Ether(b'\x01\x0e\xcf\x00\x00\x00\x01\x23\x45\x67\x89\xab\x88\x92' \ - b'\xfe\xff\x05\x01\x01\x00\x00\x01\x00\x00\x00\x7a\x02\x02\x00\x02\x00' \ - b'\x00\x01\x02\x00\x0e\x00\x01\xc0\xa8\x01\x0b\xff\xff\xff\x00\x00\x00' \ - b'\x00\x00\x02\x03\x00\x06\x00\x00\x01\x6a\x04\x00\x02\x05\x00\x16\x00' \ - b'\x00\x01\x01\x01\x02\x02\x01\x02\x02\x02\x03\x02\x04\x02\x05\x02\x07' \ - b'\x02\x08\x06\x01\x02\x04\x00\x04\x00\x00\x01\x00\x06\x01\x00\x04\x00' \ - b'\x00\x00\x00\x02\x01\x00\x18\x00\x00\x31\x32\x33\x34\x20\x44\x44\x44' - b'\x20\x33\x58\x58\x32\x2d\x31\x32\x31\x2d\x30\x46\x44\x44\x02\x07\x00' \ - b'\x04\x00\x00\x00\x01\x02\x08\x00\x06\x00\x00\x01\x1e\xff\xff') +p = Ether(b'\x01\x0e\xcf\x00\x00\x00\x01\x23\x45\x67\x89\xab\x88\x92\xfe\xff\x05\x01\x01\x00\x00\x01\x00\x00\x00\x7a\x02\x02\x00\x02\x00\x00\x01\x02\x00\x0e\x00\x01\xc0\xa8\x01\x0b\xff\xff\xff\x00\x00\x00\x00\x00\x02\x03\x00\x06\x00\x00\x01\x6a\x04\x00\x02\x05\x00\x16\x00\x00\x01\x01\x01\x02\x02\x01\x02\x02\x02\x03\x02\x04\x02\x05\x02\x07\x02\x08\x06\x01\x02\x04\x00\x04\x00\x00\x01\x00\x06\x01\x00\x04\x00\x00\x00\x00\x02\x01\x00\x18\x00\x00\x31\x32\x33\x34\x20\x44\x44\x44\x20\x33\x58\x58\x32\x2d\x31\x32\x31\x2d\x30\x46\x44\x44\x02\x07\x00\x04\x00\x00\x00\x01\x02\x08\x00\x06\x00\x00\x01\x1e\xff\xff') # - General assert p[Ether].dst == '01:0e:cf:00:00:00' @@ -186,10 +166,7 @@ assert p[DCPOEMIDBlock].device_id == 0xffff = DCP Set Request parsing -p = Ether(b'\x94\x65\x9c\x51\x90\x7d\xac\x64\x17\x21\x35\xcf\x81\x00\x00\x00' \ - b'\x88\x92\xfe\xfd\x04\x01\x00\x00\x00\x01\x00\x00\x00\x08\x05\x04' \ - b'\x00\x03\x02\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +p = Ether(b'\x94\x65\x9c\x51\x90\x7d\xac\x64\x17\x21\x35\xcf\x81\x00\x00\x00\x88\x92\xfe\xfd\x04\x01\x00\x00\x00\x01\x00\x00\x00\x08\x05\x04\x00\x03\x02\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') assert p[ProfinetIO].frameID == 0xfefd assert p[ProfinetDCP].service_id == 0x04 @@ -208,11 +185,7 @@ assert p[DCPControlBlock].block_error == 0x00 = DCP Set Full IP Suite Request parsing -p = Ether(b'\x12\x34\x00\x78\x90\xab\xc8\x5b\x76\xe6\x89\xdf' \ - b'\x88\x92\xfe\xfd\x04\x00\x00\x00\x00\x04\x00\x00' \ - b'\x00\x28\x01\x03\x00\x1e\x00\x00\xc0\xa8\x01\xab' \ - b'\xff\xff\xff\x00\xc0\xa8\x01\x01\x01\x02\x03\x04' \ - b'\x05\x06\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00') +p = Ether(b'\x12\x34\x00\x78\x90\xab\xc8\x5b\x76\xe6\x89\xdf\x88\x92\xfe\xfd\x04\x00\x00\x00\x00\x04\x00\x00\x00\x28\x01\x03\x00\x1e\x00\x00\xc0\xa8\x01\xab\xff\xff\xff\x00\xc0\xa8\x01\x01\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00') assert p[ProfinetIO].frameID == 0xfefd assert p[ProfinetDCP].service_id == 0x04 diff --git a/test/contrib/pnio_rpc.uts b/test/contrib/pnio_rpc.uts index 62e433d534e..c2d72222146 100644 --- a/test/contrib/pnio_rpc.uts +++ b/test/contrib/pnio_rpc.uts @@ -125,16 +125,12 @@ bytes(IODWriteMultipleReq(ARUUID='01234567-89ab-cdef-0123-456789abcdef', blocks= index=0x1234 ) / b'\x01\x02', ]) - ) == bytearray.fromhex('0008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000086000000000000000000000000000000000000000000000000') + \ - bytearray.fromhex('0008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000002000000000000000000000000000000000000000000000000abcd') + b'\0\0' + \ - bytearray.fromhex('0008003c010000020123456789abcdef0123456789abcdef000000020003000400001234000000020000000000000000000000000000000000000000000000000102') + ) == bytearray.fromhex('0008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000086000000000000000000000000000000000000000000000000') + bytearray.fromhex('0008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000002000000000000000000000000000000000000000000000000abcd') + b'\0\0' + bytearray.fromhex('0008003c010000020123456789abcdef0123456789abcdef000000020003000400001234000000020000000000000000000000000000000000000000000000000102') ######### = IODWriteMultipleReq dissection p = IODWriteMultipleReq( - bytearray.fromhex('0008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000086000000000000000000000000000000000000000000000000') + \ - bytearray.fromhex('0008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000002000000000000000000000000000000000000000000000000abcd') + b'\0\0' + \ - bytearray.fromhex('0008003c010000020123456789abcdef0123456789abcdef000000020003000400001234000000020000000000000000000000000000000000000000000000000102') + b'\xef' + bytearray.fromhex('0008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000086000000000000000000000000000000000000000000000000') + bytearray.fromhex('0008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000002000000000000000000000000000000000000000000000000abcd') + b'\0\0' + bytearray.fromhex('0008003c010000020123456789abcdef0123456789abcdef000000020003000400001234000000020000000000000000000000000000000000000000000000000102') + b'\xef' ) p == IODWriteMultipleReq(ARUUID='01234567-89ab-cdef-0123-456789abcdef', recordDataLength=0x86, padding=b'\0'*2, RWPadding=b'\0'*24, block_length=60, blocks=[ @@ -181,15 +177,11 @@ bytes(IODWriteMultipleRes(ARUUID='01234567-89ab-cdef-0123-456789abcdef', blocks= index=0x1234 ), ]) - ) == bytearray.fromhex('8008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000080000000000000000000000000000000000000000000000000') + \ - bytearray.fromhex('8008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000000000000000000000000000000000000000000000000000000') + \ - bytearray.fromhex('8008003c010000020123456789abcdef0123456789abcdef00000002000300040000123400000000000000000000000000000000000000000000000000000000') + ) == bytearray.fromhex('8008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000080000000000000000000000000000000000000000000000000') + bytearray.fromhex('8008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000000000000000000000000000000000000000000000000000000') + bytearray.fromhex('8008003c010000020123456789abcdef0123456789abcdef00000002000300040000123400000000000000000000000000000000000000000000000000000000') = IODWriteMultipleRes dissection p = IODWriteMultipleRes( - bytearray.fromhex('8008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000080000000000000000000000000000000000000000000000000') + \ - bytearray.fromhex('8008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000000000000000000000000000000000000000000000000000000') + \ - bytearray.fromhex('8008003c010000020123456789abcdef0123456789abcdef00000002000300040000123400000000000000000000000000000000000000000000000000000000') + b'\xef' + bytearray.fromhex('8008003c010000000123456789abcdef0123456789abcdefffffffffffffffff0000e04000000080000000000000000000000000000000000000000000000000') + bytearray.fromhex('8008003c010000010123456789abcdef0123456789abcdef00000001000200030000432100000000000000000000000000000000000000000000000000000000') + bytearray.fromhex('8008003c010000020123456789abcdef0123456789abcdef00000002000300040000123400000000000000000000000000000000000000000000000000000000') + b'\xef' ) p == IODWriteMultipleRes(ARUUID='01234567-89ab-cdef-0123-456789abcdef', recordDataLength=0x80, padding=b'\0'*2, RWPadding=b'\0'*16, block_length=60, blocks=[ @@ -357,16 +349,11 @@ p = IOCRBlockReq( ), ] ) -bytes(p) == \ - bytearray.fromhex('01020052010000020001889200000000002f80140002002000010000ffffffff000a000ac0000000000000000002' + \ - '0000000400020002000100000001000100090000' + \ - '00000000000100030001000f0001000300010004') +bytes(p) == bytearray.fromhex('01020052010000020001889200000000002f80140002002000010000ffffffff000a000ac0000000000000000002' + '0000000400020002000100000001000100090000' + '00000000000100030001000f0001000300010004') = IOCRBlockReq dissection p = IOCRBlockReq( - bytearray.fromhex('01020052010000020001889200000000002f80140002002000010000ffffffff000a000ac0000102030405060002' + \ - '0000000400020002000100000001000100090000' + \ - '00000000000100030001000f0001000300010004') + b'\xef') + bytearray.fromhex('01020052010000020001889200000000002f80140002002000010000ffffffff000a000ac0000102030405060002' + '0000000400020002000100000001000100090000' + '00000000000100030001000f0001000300010004') + b'\xef') p == IOCRBlockReq( IOCRType='OutputCR', IOCRReference=1, SendClockFactor=2, IOCRMulticastMACAdd='01:02:03:04:05:06', ReductionRatio=32, DataLength=47, FrameID=0x8014, block_length=82, @@ -456,20 +443,11 @@ p = ExpectedSubmoduleBlockReq( ), ] ) -bytes(p) == \ - bytearray.fromhex('0104002601000001') + \ - bytearray.fromhex('000000040002000008c400000001') + \ - bytearray.fromhex('0001000001230003') + \ - bytearray.fromhex('000200050002') + \ - bytearray.fromhex('000100030201') +bytes(p) == bytearray.fromhex('0104002601000001') + bytearray.fromhex('000000040002000008c400000001') + bytearray.fromhex('0001000001230003') + bytearray.fromhex('000200050002') + bytearray.fromhex('000100030201') = ExpectedSubmoduleBlockReq dissection p = ExpectedSubmoduleBlockReq( - bytearray.fromhex('0104002601000001') + \ - bytearray.fromhex('000000040002000008c400000001') + \ - bytearray.fromhex('0001000001230003') + \ - bytearray.fromhex('000200050002') + \ - bytearray.fromhex('000100030201') + b'\xef' + bytearray.fromhex('0104002601000001') + bytearray.fromhex('000000040002000008c400000001') + bytearray.fromhex('0001000001230003') + bytearray.fromhex('000200050002') + bytearray.fromhex('000100030201') + b'\xef' ) p == ExpectedSubmoduleBlockReq(block_length=38, NumberOfAPIs=1, APIs=[ @@ -545,9 +523,7 @@ assert s[:18] + s[24:] == b'\x04\x00\x00\x00\x10\x00\x00\x00\x00\x00\xa0\xde\x97 = PNIOServiceReqPDU dissection p = DceRpc4( - bytes(bytearray.fromhex('0400000000000000dea000006c9711d18271010203040506dea000016c9711d1827100a02442df7d000000000000000000000000000000000000000000000001000000000000ffffffff001c00000000' + \ - '0000000f000000080000000f0000000000000008' + \ - '0000000401000102ef') + bytes(bytearray.fromhex('0400000000000000dea000006c9711d18271010203040506dea000016c9711d1827100a02442df7d000000000000000000000000000000000000000000000001000000000000ffffffff001c00000000' + '0000000f000000080000000f0000000000000008' + '0000000401000102ef') )) bytes(p.payload) == bytes(PNIOServiceReqPDU(args_length=8, args_max=15, max_count=15, actual_count=8, blocks=[ @@ -572,9 +548,7 @@ assert s[:18] + s[24:] == b'\x04\x02\x00\x00\x10\x00\x00\x00\x00\x00\xa0\xde\x97 = PNIOServiceResPDU dissection p = DceRpc4( - bytes(bytearray.fromhex('0402000000000000dea000006c9711d18271010203040506dea000026c9711d1827100a02442df7d000000000000000000000000000000000000000000000001000000000000ffffffff001c00000000' + \ - '00001234000000080000000f0000000000000008' + \ - '0000000401000102ef') + bytes(bytearray.fromhex('0402000000000000dea000006c9711d18271010203040506dea000026c9711d1827100a02442df7d000000000000000000000000000000000000000000000001000000000000ffffffff001c00000000' + '00001234000000080000000f0000000000000008' + '0000000401000102ef') )) bytes(p.payload) == bytes(PNIOServiceResPDU(status=0x1234, args_length=8, max_count=15, actual_count=8, blocks=[ @@ -681,20 +655,7 @@ p = DceRpc4( ] ) bytes(p) == bytearray.fromhex( - '04000000100000000000a0de976cd11182710102030405060100a0de976cd111827100a02442df7d67452301ab89efcd0123456789abcdef0000000001000000000000000000ffffffff250100000000' + \ - '1101000011010000110100000000000011010000' + \ - '0101003b01000001fedcba9876543210fedcba98765432100000010203040506dea000006c9711d182710102030405060000001103e888920005') + b'plc-1' + \ - bytearray.fromhex('0102003e010000010001889200000000002880000002002000010000ffffffff000a000ac0000000000000000001' + \ - '00000000000100030001000f0001000300010004' + \ - '0102003e0100000200028892000000000034ffff0008002000010000ffffffff000a000ac0000000000000000001' + \ - '0000000000020003000100000001000200090000' + \ - '0104002601000001000000000003000008c400000001' + \ - '0001000001240003' + \ - '000200030101' + \ - '000100050002' + \ - '0104002001000001000000000001000008c300000001' + \ - '0002000004240002' + \ - '000200050001') + '04000000100000000000a0de976cd11182710102030405060100a0de976cd111827100a02442df7d67452301ab89efcd0123456789abcdef0000000001000000000000000000ffffffff250100000000' + '1101000011010000110100000000000011010000' + '0101003b01000001fedcba9876543210fedcba98765432100000010203040506dea000006c9711d182710102030405060000001103e888920005') + b'plc-1' + bytearray.fromhex('0102003e010000010001889200000000002880000002002000010000ffffffff000a000ac0000000000000000001' + '00000000000100030001000f0001000300010004' + '0102003e0100000200028892000000000034ffff0008002000010000ffffffff000a000ac0000000000000000001' + '0000000000020003000100000001000200090000' + '0104002601000001000000000003000008c400000001' + '0001000001240003' + '000200030101' + '000100050002' + '0104002001000001000000000001000008c300000001' + '0002000004240002' + '000200050001') #### Write Request @@ -723,13 +684,7 @@ p = DceRpc4( ] ) bytes(p) == bytearray.fromhex( - '04000000100000000000a0de976cd11182710102030405060100a0de976cd111827100a02442df7d67452301ab89efcd0123456789abcdef0000000001000000010000000200ffffffffe20000000000' + \ - 'ce000000ce000000ce00000000000000ce000000' + \ - '0008003c01000000fedcba9876543210fedcba9876543210ffffffffffffffff0000e0400000008e' + '00' * 24 + \ - '0008003c01000001fedcba9876543210fedcba987654321000000000000100010000012300000002' + '00' * 24 + \ - '01020000' + \ - '0008003c01000002fedcba9876543210fedcba98765432100000000000030001000001000000000a' + '00' * 24 + \ - '484000c100c201f41234') + '04000000100000000000a0de976cd11182710102030405060100a0de976cd111827100a02442df7d67452301ab89efcd0123456789abcdef0000000001000000010000000200ffffffffe20000000000' + 'ce000000ce000000ce00000000000000ce000000' + '0008003c01000000fedcba9876543210fedcba9876543210ffffffffffffffff0000e0400000008e' + '00' * 24 + '0008003c01000001fedcba9876543210fedcba987654321000000000000100010000012300000002' + '00' * 24 + '01020000' + '0008003c01000002fedcba9876543210fedcba98765432100000000000030001000001000000000a' + '00' * 24 + '484000c100c201f41234') #### PrmEnd control Request @@ -744,9 +699,7 @@ p = DceRpc4( ] ) bytes(p) == bytearray.fromhex( - '04000000100000000000a0de976cd11182710102030405060100a0de976cd111827100a02442df7d67452301ab89efcd0123456789abcdef0000000001000000020000000000ffffffff340000000000' + \ - '2000000020000000200000000000000020000000' + \ - '0110001c01000000fedcba9876543210fedcba98765432100000000000010000') + '04000000100000000000a0de976cd11182710102030405060100a0de976cd111827100a02442df7d67452301ab89efcd0123456789abcdef0000000001000000020000000000ffffffff340000000000' + '2000000020000000200000000000000020000000' + '0110001c01000000fedcba9876543210fedcba98765432100000000000010000') #### ApplicationReady control Request = A PNIO RPC PrmEnd Control Request @@ -761,25 +714,14 @@ p = DceRpc4( ] ) bytes(p) == bytearray.fromhex( - '04000000100000000000a0de976cd11182710605040302010200a0de976cd111827100a02442df7d0403020106050807090a0b0c0d0e0f000000000001000000000000000000ffffffff340000000000' + \ - '2000000020000000200000000000000020000000' + \ - '0112001c01000000fedcba9876543210fedcba98765432100000000000020000') + '04000000100000000000a0de976cd11182710605040302010200a0de976cd111827100a02442df7d0403020106050807090a0b0c0d0e0f000000000001000000000000000000ffffffff340000000000' + '2000000020000000200000000000000020000000' + '0112001c01000000fedcba9876543210fedcba98765432100000000000020000') ### PNIO Alarms = PNIO Alarm decoding (Alarm_Low) -p = Ether(b'\x00\x11\x22\x33\x44\x55' \ - b'\x00\x66\x77\x88\x99\xaa' \ - b'\x81\x00\xa0\x00' \ - b'\x88\x92' \ - b'\xfe\x01' \ - b'\x00\x03\x00\x03\x11\x11\xff\xff\xff\xfe\x00\x36' \ - b'\x00\x02\x00\x32\x01\x00\x00\x01\x00\x00\x00\x00\x00' \ - b'\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00' \ - b'\x81\x00\x0f\x00\x00\x08\x01\x00\x00\x00\x00\x00\x00\x02' \ - b'\x80\x02\x00\x0f\x2c\x00\x00\x05\x80\x00\x00\x00\x00\x22') +p = Ether(b'\x00\x11\x22\x33\x44\x55\x00\x66\x77\x88\x99\xaa\x81\x00\xa0\x00\x88\x92\xfe\x01\x00\x03\x00\x03\x11\x11\xff\xff\xff\xfe\x00\x36\x00\x02\x00\x32\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x81\x00\x0f\x00\x00\x08\x01\x00\x00\x00\x00\x00\x00\x02\x80\x02\x00\x0f\x2c\x00\x00\x05\x80\x00\x00\x00\x00\x22') assert p[ProfinetIO].frameID == 0xfe01 assert isinstance(p[ProfinetIO].payload, Alarm_Low) assert p[AlarmNotification_Low].block_type == 0x0002 @@ -789,16 +731,7 @@ assert isinstance(p[AlarmNotification_Low].AlarmPayload[1], DiagnosisItem) assert p[DiagnosisItem].UserStructureIdentifier == 0x8002 = PNIO Alarm decoding (Alarm_High) -p = Ether(b'\x00\x11\x22\x33\x44\x55' \ - b'\x00\x66\x77\x88\x99\xaa' \ - b'\x81\x00\xa0\x00' \ - b'\x88\x92' \ - b'\xfc\x01' \ - b'\x00\x03\x00\x03\x11\x11\xff\xff\xff\xfe\x00\x36' \ - b'\x00\x02\x00\x32\x01\x00\x00\x01\x00\x00\x00\x00\x00' \ - b'\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00' \ - b'\x81\x00\x0f\x00\x00\x08\x01\x00\x00\x00\x00\x00\x00\x02' \ - b'\x80\x02\x00\x0f\x2c\x00\x00\x05\x80\x00\x00\x00\x00\x22') +p = Ether(b'\x00\x11\x22\x33\x44\x55\x00\x66\x77\x88\x99\xaa\x81\x00\xa0\x00\x88\x92\xfc\x01\x00\x03\x00\x03\x11\x11\xff\xff\xff\xfe\x00\x36\x00\x02\x00\x32\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x81\x00\x0f\x00\x00\x08\x01\x00\x00\x00\x00\x00\x00\x02\x80\x02\x00\x0f\x2c\x00\x00\x05\x80\x00\x00\x00\x00\x22') assert p[ProfinetIO].frameID == 0xfc01 assert isinstance(p[ProfinetIO].payload, Alarm_High) assert p[AlarmNotification_High].block_type == 0x0002 @@ -830,14 +763,7 @@ p = AlarmNotification_Low(AlarmPayload=[MaintenanceItem(), PRAL_AlarmItem()]) assert raw(p) == bytearray.fromhex('0002002e01000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000') = PNIO PDPortDataAdjust Decoding -raw = bytearray.fromhex('0402280000000000dea000006c9711d182710001000305f9dea000016' \ - 'c9711d1827100a02442df7d0777bc51ddaa4d07addb7075183fc28b00' \ - '00000000000001000000000002ffffffff007c0000000000000000000' \ - '000680000004000000000000000688009003c0100000002ba501cd47e' \ - '40d3a0b545fd4ac70eb900000000000080020000802f0000002800000' \ - '000000000000000000000000000000000000000000002020024010000' \ - '00000080020224000c010000000000000100000000021b00080100000' \ - '000010000') +raw = bytearray.fromhex('0402280000000000dea000006c9711d182710001000305f9dea000016c9711d1827100a02442df7d0777bc51ddaa4d07addb7075183fc28b0000000000000001000000000002ffffffff007c0000000000000000000000680000004000000000000000688009003c0100000002ba501cd47e40d3a0b545fd4ac70eb900000000000080020000802f000000280000000000000000000000000000000000000000000000000202002401000000000080020224000c010000000000000100000000021b00080100000000010000') p = DceRpc4(raw) assert p[PDPortDataAdjust].subslotNumber == 0x8002 assert p[AdjustPeerToPeerBoundary].peerToPeerBoundary == 0x1 diff --git a/test/contrib/postgres.uts b/test/contrib/postgres.uts index f6e0aae55f7..461d217f7fa 100644 --- a/test/contrib/postgres.uts +++ b/test/contrib/postgres.uts @@ -196,28 +196,14 @@ assert copyin_response.cols[1] == 0 # Text assert copyin_response.cols[2] == 0 # Text assert copyin_response.cols[3] == 0 # Text -copydata_in = PostgresFrontend(b"\x64\x00\x00\x00\x10\x31\x2c\x42\x6f\x62\x2c\x32\x33\x2c\x31\x0d" \ -b"\x0a\x64\x00\x00\x00\x12\x32\x2c\x53\x61\x6c\x6c\x79\x2c\x34\x33" \ -b"\x2c\x32\x0d\x0a\x64\x00\x00\x00\x14\x33\x2c\x50\x61\x72\x64\x65" \ -b"\x65\x70\x2c\x35\x34\x2c\x33\x0d\x0a\x64\x00\x00\x00\x0f\x34\x2c" \ -b"\x53\x75\x2c\x33\x32\x2c\x34\x0d\x0a\x64\x00\x00\x00\x0f\x35\x2c" \ -b"\x58\x69\x2c\x34\x33\x2c\x35\x0d\x0a\x64\x00\x00\x00\x0e\x36\x2c" \ -b"\x50\x69\x70\x2c\x36\x36\x2c\x36\x63\x00\x00\x00\x04" +copydata_in = PostgresFrontend(b"\x64\x00\x00\x00\x10\x31\x2c\x42\x6f\x62\x2c\x32\x33\x2c\x31\x0d\x0a\x64\x00\x00\x00\x12\x32\x2c\x53\x61\x6c\x6c\x79\x2c\x34\x33\x2c\x32\x0d\x0a\x64\x00\x00\x00\x14\x33\x2c\x50\x61\x72\x64\x65\x65\x70\x2c\x35\x34\x2c\x33\x0d\x0a\x64\x00\x00\x00\x0f\x34\x2c\x53\x75\x2c\x33\x32\x2c\x34\x0d\x0a\x64\x00\x00\x00\x0f\x35\x2c\x58\x69\x2c\x34\x33\x2c\x35\x0d\x0a\x64\x00\x00\x00\x0e\x36\x2c\x50\x69\x70\x2c\x36\x36\x2c\x36\x63\x00\x00\x00\x04" ) copyout_response = CopyOutResponse(b"\x48\x00\x00\x00\x0f\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00") assert copyout_response.len == 15 # Combined message -copydata_out = PostgresBackend(b"\x48\x00\x00\x00\x0f\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00" \ -b"\x64\x00\x00\x00\x0f\x31\x09\x42\x6f\x62\x09\x32\x33\x09\x31\x0a" \ -b"\x64\x00\x00\x00\x11\x32\x09\x53\x61\x6c\x6c\x79\x09\x34\x33\x09" \ -b"\x32\x0a\x64\x00\x00\x00\x13\x33\x09\x50\x61\x72\x64\x65\x65\x70" \ -b"\x09\x35\x34\x09\x33\x0a\x64\x00\x00\x00\x0e\x34\x09\x53\x75\x09" \ -b"\x33\x32\x09\x34\x0a\x64\x00\x00\x00\x0e\x35\x09\x58\x69\x09\x34" \ -b"\x33\x09\x35\x0a\x64\x00\x00\x00\x0f\x36\x09\x50\x69\x70\x09\x36" \ -b"\x36\x09\x36\x0a\x63\x00\x00\x00\x04\x43\x00\x00\x00\x0b\x43\x4f" \ -b"\x50\x59\x20\x36\x00\x5a\x00\x00\x00\x05\x49") +copydata_out = PostgresBackend(b"\x48\x00\x00\x00\x0f\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x0f\x31\x09\x42\x6f\x62\x09\x32\x33\x09\x31\x0a\x64\x00\x00\x00\x11\x32\x09\x53\x61\x6c\x6c\x79\x09\x34\x33\x09\x32\x0a\x64\x00\x00\x00\x13\x33\x09\x50\x61\x72\x64\x65\x65\x70\x09\x35\x34\x09\x33\x0a\x64\x00\x00\x00\x0e\x34\x09\x53\x75\x09\x33\x32\x09\x34\x0a\x64\x00\x00\x00\x0e\x35\x09\x58\x69\x09\x34\x33\x09\x35\x0a\x64\x00\x00\x00\x0f\x36\x09\x50\x69\x70\x09\x36\x36\x09\x36\x0a\x63\x00\x00\x00\x04\x43\x00\x00\x00\x0b\x43\x4f\x50\x59\x20\x36\x00\x5a\x00\x00\x00\x05\x49") assert len(copydata_out.contents) == 10 assert copydata_out.contents[0].len == 15 diff --git a/test/contrib/ppi_cace.uts b/test/contrib/ppi_cace.uts index 49719858bee..8eba59e6ba6 100644 --- a/test/contrib/ppi_cace.uts +++ b/test/contrib/ppi_cace.uts @@ -9,154 +9,195 @@ from scapy.contrib.ppi_cace import * from scapy.contrib.ppi_geotag import * - def Pkt_10_1(): """GPS Only""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(Latitude=40.787743,Longitude=-73.971210)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:01")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.1") + PPI_Hdr() / PPI_Geotag_GPS(Latitude=40.787743, Longitude=-73.971210)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:01") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.1") return PPI(raw(pkt)) + def Pkt_10_2(): - """GPS + VECTOR + ANTENNA + RADIOTAP""" #No radiotap support yet... + """GPS + VECTOR + ANTENNA + RADIOTAP""" # No radiotap support yet... pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(Latitude=40.787743, Longitude=-73.971210), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars="Antenna", Pitch=90.0, Roll=0.0, Heading=0.0, DescString="Antenna-1 orientation"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x02,Gain=8,HorizBw=360.0,ModelName="8dBi-MagMountOmni"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-80,Antnoise=-110,Ch_Freq=2437)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:02")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.2") + PPI_Hdr() / PPI_Geotag_GPS(Latitude=40.787743, Longitude=-73.971210), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars="Antenna", Pitch=90.0, Roll=0.0, Heading=0.0, + DescString="Antenna-1 orientation"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x02, Gain=8, HorizBw=360.0, ModelName="8dBi-MagMountOmni"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-80, Antnoise=-110, Ch_Freq=2437)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:02") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.2") return PPI(raw(pkt)) + def Pkt_10_3(): """Direction of travel + one directional antenna, with Pitch in ForwardFrame""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x06, Pitch=10.0, Heading=22.5, DescString="VehicleVec"), - PPI_Hdr()/PPI_Geotag_Sensor(SensorType="Velocity", Val_T=20.0), - PPI_Hdr()/PPI_Geotag_Vector( VectorChars=0x01, Heading=90.0, DescString="AntennaVec"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x02,Gain=9,HorizBw=120,ModelName="SA24-120-9"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-75,Antnoise=-110,Ch_Freq=2437)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:03")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.3") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x06, Pitch=10.0, Heading=22.5, + DescString="VehicleVec"), + PPI_Hdr() / PPI_Geotag_Sensor(SensorType="Velocity", Val_T=20.0), + PPI_Hdr() / PPI_Geotag_Vector(VectorChars=0x01, Heading=90.0, DescString="AntennaVec"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x02, Gain=9, HorizBw=120, ModelName="SA24-120-9"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-75, Antnoise=-110, Ch_Freq=2437)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:03") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.3") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_4(): """Two static directional antennas with offsets""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210, Altitude_g=2.00), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x06, Pitch=10.0, Heading=22.5), - PPI_Hdr()/PPI_Geotag_Sensor(SensorType="Velocity", Val_T=8.5), - PPI_Hdr()/PPI_Geotag_Sensor(SensorType="Acceleration", Val_T=0.5), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=90.0, Off_X=0.75, Off_Y=0.6, Off_Z=-0.2, DescString="Antenna1Vec"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x02,Gain=9,HorizBw=120,ModelName="SA24-120-9",DescString="RightAntenna"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-75,Antnoise=-110,Ch_Freq=2437), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=270.0, Off_X=-0.75, Off_Y=0.6, Off_Z=-0.2, DescString="Antenna2Vec"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x02,Gain=9,HorizBw=120,ModelName="SA24-120-9",DescString="LeftAntenna"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-95,Antnoise=-110,Ch_Freq=2437)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:04")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.4") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210, Altitude_g=2.00), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x06, Pitch=10.0, Heading=22.5), + PPI_Hdr() / PPI_Geotag_Sensor(SensorType="Velocity", Val_T=8.5), + PPI_Hdr() / PPI_Geotag_Sensor(SensorType="Acceleration", Val_T=0.5), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=90.0, Off_X=0.75, Off_Y=0.6, + Off_Z=-0.2, DescString="Antenna1Vec"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x02, Gain=9, HorizBw=120, ModelName="SA24-120-9", + DescString="RightAntenna"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-75, Antnoise=-110, Ch_Freq=2437), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=270.0, Off_X=-0.75, Off_Y=0.6, + Off_Z=-0.2, DescString="Antenna2Vec"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x02, Gain=9, HorizBw=120, ModelName="SA24-120-9", + DescString="LeftAntenna"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-95, Antnoise=-110, Ch_Freq=2437)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:04") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.4") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_5(): """Similar to 10_3, but with a electronically steerable antenna""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x06, Pitch=00.0, Heading=22.5, DescString="VehicleVec"), - PPI_Hdr()/PPI_Geotag_Vector( VectorChars=0x01, Heading=120.0, DescString="AntennaVec"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x010002,Gain=12,HorizBw=60,BeamID=0xF1A1, ModelName="ElectronicallySteerableExAntenna", AppId=0x04030201), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-75,Antnoise=-110,Ch_Freq=2437)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:05")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.5") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x06, Pitch=00.0, Heading=22.5, + DescString="VehicleVec"), + PPI_Hdr() / PPI_Geotag_Vector(VectorChars=0x01, Heading=120.0, DescString="AntennaVec"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x010002, Gain=12, HorizBw=60, BeamID=0xF1A1, + ModelName="ElectronicallySteerableExAntenna", AppId=0x04030201), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-75, Antnoise=-110, Ch_Freq=2437)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:05") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.5") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_6(): """Mechanically steerable antenna. Non-intuitive forward""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x06, Heading=22.5, DescString="VehicleVec"), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x00, Heading=202.5, DescString="ForwardVec"), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=75.0, DescString="AntennaVec"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x020002,Gain=12,HorizBw=60,ModelName="MechanicallySteerableAnt"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-77,Antnoise=-110,Ch_Freq=2437)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:06")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.6") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags=0x02, Latitude=40.787743, Longitude=-73.971210), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x06, Heading=22.5, DescString="VehicleVec"), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x00, Heading=202.5, DescString="ForwardVec"), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=75.0, DescString="AntennaVec"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x020002, Gain=12, HorizBw=60, + ModelName="MechanicallySteerableAnt"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-77, Antnoise=-110, Ch_Freq=2437)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:06") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.6") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_7(): """Drifting boat.""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags=0x02, Latitude= 41.876154, Longitude=-87.608602), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x04, Heading=50.0, DescString="VehicleVec"), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x02, Heading=230.0, DescString="DOT-Vec"), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=90.0, DescString="AntennaVec"), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x02,Gain=9,HorizBw=120,ModelName="SA24-120-9"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-77,Antnoise=-110,Ch_Freq=2437)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:07")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.7") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags=0x02, Latitude=41.876154, Longitude=-87.608602), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x04, Heading=50.0, DescString="VehicleVec"), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x02, Heading=230.0, DescString="DOT-Vec"), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x01, Heading=90.0, DescString="AntennaVec"), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x02, Gain=9, HorizBw=120, ModelName="SA24-120-9"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-77, Antnoise=-110, Ch_Freq=2437)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", + addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:07") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.7") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_8(): """Time of arrival analysis""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861885, Longitude=-87.616926, GPSTime=1288720719, FractionalTime=0.20), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, DescString="Antenna-1 orientation"), - PPI_Hdr()/PPI_Geotag_Sensor(SensorType="TDOA_Clock", ScaleFactor=-9, Val_T=60.8754, AppId=0x04030201), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x01,Gain=5,HorizBw=360.0,ModelName="8dBi-Omni", DescString="Signal 1"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-60), - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861904, Longitude=-87.616365, GPSTime=1288720719, FractionalTime=0.20), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, DescString="Antenna-2 orientation"), - PPI_Hdr()/PPI_Geotag_Sensor(SensorType="TDOA_Clock", ScaleFactor=-9, Val_T=178.124, AppId=0x04030201), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x01,Gain=5,HorizBw=360.0,ModelName="8dBi-Omni", DescString="Signal 2"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-80)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:08")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.8") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861885, Longitude=-87.616926, + GPSTime=1288720719, FractionalTime=0.20), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, + DescString="Antenna-1 orientation"), + PPI_Hdr() / PPI_Geotag_Sensor(SensorType="TDOA_Clock", ScaleFactor=-9, Val_T=60.8754, AppId=0x04030201), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x01, Gain=5, HorizBw=360.0, ModelName="8dBi-Omni", + DescString="Signal 1"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-60), + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861904, Longitude=-87.616365, + GPSTime=1288720719, FractionalTime=0.20), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, + DescString="Antenna-2 orientation"), + PPI_Hdr() / PPI_Geotag_Sensor(SensorType="TDOA_Clock", ScaleFactor=-9, Val_T=178.124, AppId=0x04030201), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x01, Gain=5, HorizBw=360.0, ModelName="8dBi-Omni", + DescString="Signal 2"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-80)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:08") / Dot11Beacon() / Dot11Elt(ID=0, + info="Test-10.8") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_9(): """Time of arrival analysis(AOA)""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861904, Longitude=-87.616365, GPSTime=1288720719, FractionalTime=0.20), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, DescString="Antenna-2 orientation"), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x08, Heading=323.4, Err_Rot=10.0, DescString="AOA at Antenna-2", AppId=0x04030201), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x01,Gain=5,HorizBw=360.0,ModelName="8dBi-Omni", DescString="Signal 2"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-80)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:098")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.9") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861904, Longitude=-87.616365, + GPSTime=1288720719, FractionalTime=0.20), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, + DescString="Antenna-2 orientation"), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x08, Heading=323.4, Err_Rot=10.0, + DescString="AOA at Antenna-2", AppId=0x04030201), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x01, Gain=5, HorizBw=360.0, ModelName="8dBi-Omni", + DescString="Signal 2"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-80)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:098") / Dot11Beacon() / Dot11Elt( + ID=0, info="Test-10.9") + return PPI(raw(pkt)) # Cause the fields to be built + def Pkt_10_10(): """Transmitter Position/AOA example""" pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861904, Longitude=-87.616365, GPSTime=1288720719, FractionalTime=0.20), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, DescString="Antenna-2 orientation"), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x08, Heading=323.4, Err_Rot=10.0, DescString="AOA at Antenna-2", AppId=0x04030201), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x10, Off_Y=40, Err_Off=2.0, DescString="Transmitter Position", AppId=0x4030201), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x01,Gain=5,HorizBw=360.0,ModelName="8dBi-Omni", DescString="Signal 2"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-80)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:0A")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-10.10") - return PPI(raw(pkt)) #Cause the fields to be built + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=41.861904, Longitude=-87.616365, + GPSTime=1288720719, FractionalTime=0.20), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x02, VectorChars=0x01, Pitch=90.0, + DescString="Antenna-2 orientation"), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x03, VectorChars=0x08, Heading=323.4, Err_Rot=10.0, + DescString="AOA at Antenna-2", AppId=0x04030201), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags=0x00, VectorChars=0x10, Off_Y=40, Err_Off=2.0, + DescString="Transmitter Position", AppId=0x4030201), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x01, Gain=5, HorizBw=360.0, ModelName="8dBi-Omni", + DescString="Signal 2"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-80)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:0A") / Dot11Beacon() / Dot11Elt(ID=0, + info="Test-10.10") + return PPI(raw(pkt)) # Cause the fields to be built + def TestPackets(): """Returns a list of test packets""" return [ - ("10.1", Pkt_10_1(), test_Pkt_10_1), - ("10.2", Pkt_10_2(), test_Pkt_10_2), - ("10.3", Pkt_10_3(), test_Pkt_10_3), - ("10.4", Pkt_10_4(), test_Pkt_10_4), - ("10.5", Pkt_10_5(), test_Pkt_10_5), - ("10.6", Pkt_10_6(), test_Pkt_10_6), - ("10.7", Pkt_10_7(), test_Pkt_10_7), - ("10.8", Pkt_10_8(), test_Pkt_10_8), - ("10.9", Pkt_10_9(), test_Pkt_10_9), - ("10.10", Pkt_10_10(), test_Pkt_10_10) ] + ("10.1", Pkt_10_1(), test_Pkt_10_1), + ("10.2", Pkt_10_2(), test_Pkt_10_2), + ("10.3", Pkt_10_3(), test_Pkt_10_3), + ("10.4", Pkt_10_4(), test_Pkt_10_4), + ("10.5", Pkt_10_5(), test_Pkt_10_5), + ("10.6", Pkt_10_6(), test_Pkt_10_6), + ("10.7", Pkt_10_7(), test_Pkt_10_7), + ("10.8", Pkt_10_8(), test_Pkt_10_8), + ("10.9", Pkt_10_9(), test_Pkt_10_9), + ("10.10", Pkt_10_10(), test_Pkt_10_10)] = Pkt_10_1 a = Pkt_10_1() raw(a) -assert raw(a) == b'\x00\x00\x1c\x00i\x00\x00\x002u\x10\x00\x02\x00\x10\x00\x06\x00\x00\x006\x89\x99\x83\x9c\xb52?\x80\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x01\x02\x03\x04\x05\x00\x01\x02\t\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d\x00\x00\x00\x00\tTest-10.1' +assert raw( + a) == b'\x00\x00\x1c\x00i\x00\x00\x002u\x10\x00\x02\x00\x10\x00\x06\x00\x00\x006\x89\x99\x83\x9c\xb52?\x80\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x01\x02\x03\x04\x05\x00\x01\x02\t\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d\x00\x00\x00\x00\tTest-10.1' assert a.headers[0].present == 6 assert a.headers[0].Latitude == 40.7877430 assert a[Dot11Beacon].beacon_interval == 100 @@ -165,7 +206,8 @@ assert a[Dot11Elt].info == b'Test-10.1' = Pkt_10_2 a = Pkt_10_2() a.show() -assert raw(a) == b'\x00\x00\xa9\x00i\x00\x00\x002u\x10\x00\x02\x00\x10\x00\x06\x00\x00\x006\x89\x99\x83\x9c\xb52?3u<\x00\x02\x00<\x00\x1f\x00\x00\x10\x02\x00\x00\x00\x01\x00\x00\x00\x80J]\x05\x00\x00\x00\x00\x00\x00\x00\x00Antenna-1 orientation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x005u1\x00\x02\x001\x00\x07\x00\x00\x08\x02\x00\x00\x00\x08\x00*u\x158dBi-MagMountOmni\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x85\t\x00\x00\x00\x00\xb0\x92\x80\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x01\x02\x03\x04\x05\x00\x01\x02\t\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d\x00\x00\x00\x00\tTest-10.2' +assert raw( + a) == b'\x00\x00\xa9\x00i\x00\x00\x002u\x10\x00\x02\x00\x10\x00\x06\x00\x00\x006\x89\x99\x83\x9c\xb52?3u<\x00\x02\x00<\x00\x1f\x00\x00\x10\x02\x00\x00\x00\x01\x00\x00\x00\x80J]\x05\x00\x00\x00\x00\x00\x00\x00\x00Antenna-1 orientation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x005u1\x00\x02\x001\x00\x07\x00\x00\x08\x02\x00\x00\x00\x08\x00*u\x158dBi-MagMountOmni\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x85\t\x00\x00\x00\x00\xb0\x92\x80\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x01\x02\x03\x04\x05\x00\x01\x02\t\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d\x00\x00\x00\x00\tTest-10.2' assert isinstance(a.headers[0].payload, PPI_Geotag_GPS) assert a.headers[0].present == 6 assert isinstance(a.headers[1].payload, PPI_Geotag_Vector) @@ -238,12 +280,15 @@ assert pkt[Dot11Elt].ID == 0 = All-wrong-data packet pkt = PPI(headers=[ - PPI_Hdr()/PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=-181, Longitude=181, GPSTime=1288720719, FractionalTime=-1, ept=100, eph=-1, epv=1000, Altitude=-999999, Altitude_g=999999), - PPI_Hdr()/PPI_Geotag_Vector(VectorFlags="DefinesForward+RelativeToEarth", VectorChars=0x08, Heading=323.4, Err_Rot=10.0, DescString="AOA at Antenna-2", AppId=0x04030201), - PPI_Hdr()/PPI_Geotag_Antenna(AntennaFlags=0x01,Gain=5,HorizBw=360.0,ModelName="8dBi-Omni", DescString="Signal 2"), - PPI_Hdr()/PPI_Dot11Common(Antsignal=-80)])/\ - Dot11(addr1="FF:FF:FF:FF:FF:FF",addr2="00:01:02:03:04:05",addr3="00:01:02:09:01:0A")/\ - Dot11Beacon()/Dot11Elt(ID=0,info="Test-allwrong") + PPI_Hdr() / PPI_Geotag_GPS(GPSFlags="Manual Input", Latitude=-181, Longitude=181, GPSTime=1288720719, + FractionalTime=-1, ept=100, eph=-1, epv=1000, Altitude=-999999, Altitude_g=999999), + PPI_Hdr() / PPI_Geotag_Vector(VectorFlags="DefinesForward+RelativeToEarth", VectorChars=0x08, Heading=323.4, + Err_Rot=10.0, DescString="AOA at Antenna-2", AppId=0x04030201), + PPI_Hdr() / PPI_Geotag_Antenna(AntennaFlags=0x01, Gain=5, HorizBw=360.0, ModelName="8dBi-Omni", + DescString="Signal 2"), + PPI_Hdr() / PPI_Dot11Common(Antsignal=-80)]) / Dot11(addr1="FF:FF:FF:FF:FF:FF", addr2="00:01:02:03:04:05", + addr3="00:01:02:09:01:0A") / Dot11Beacon() / Dot11Elt(ID=0, + info="Test-allwrong") pkt = PPI(raw(pkt)) pkt.show() assert pkt.headers[0].Latitude == -180.0 diff --git a/test/contrib/roce.uts b/test/contrib/roce.uts index 757163d3049..48b024490fe 100644 --- a/test/contrib/roce.uts +++ b/test/contrib/roce.uts @@ -13,12 +13,7 @@ = RoCE layer # an example UC packet -pkt = Ether(dst='24:8a:07:a8:fa:22', src='24:8a:07:a8:fa:22')/ \ - IP(version=4, ihl=5, tos=0x1, id=1144, flags='DF', frag=0, \ - ttl=64, src='192.168.0.7', dst='192.168.0.7', len=64)/ \ - UDP(sport=49152, dport=4791, len=44)/ \ - BTH(opcode='UC_SEND_ONLY', migreq=1, padcount=2, pkey=0xffff, dqpn=211, psn=13571856)/ \ - Raw(b'F0\x81\x8b\xe2\x895\xd9\x0e\x9a\x95PT\x01\xbe\x88^P\x00\x00') +pkt = Ether(dst='24:8a:07:a8:fa:22', src='24:8a:07:a8:fa:22')/ IP(version=4, ihl=5, tos=0x1, id=1144, flags='DF', frag=0, ttl=64, src='192.168.0.7', dst='192.168.0.7', len=64)/ UDP(sport=49152, dport=4791, len=44)/ BTH(opcode='UC_SEND_ONLY', migreq=1, padcount=2, pkey=0xffff, dqpn=211, psn=13571856)/ Raw(b'F0\x81\x8b\xe2\x895\xd9\x0e\x9a\x95PT\x01\xbe\x88^P\x00\x00') # include ICRC placeholder pkt = Ether(pkt.build() + b'\x00' * 4) @@ -37,10 +32,7 @@ assert pkt[BTH].icrc == 0x78f353f3 # based on this example packet: # https://community.mellanox.com/s/article/rocev2-cnp-packet-format-example -pkt = Ether()/IP(src='22.22.22.8', dst='22.22.22.7', id=0x98c6, flags='DF', - ttl=0x20, tos=0x89)/ \ - UDP(sport=56238, dport=4791, chksum=0)/ \ - cnp(dqpn=0xd2) +pkt = Ether()/IP(src='22.22.22.8', dst='22.22.22.7', id=0x98c6, flags='DF', ttl=0x20, tos=0x89)/ UDP(sport=56238, dport=4791, chksum=0)/ cnp(dqpn=0xd2) pkt = Ether(pkt.build()) assert pkt[IP].len == 60 diff --git a/test/contrib/rpl.uts b/test/contrib/rpl.uts index e2d678dfdf8..c40fe66ca18 100644 --- a/test/contrib/rpl.uts +++ b/test/contrib/rpl.uts @@ -85,14 +85,11 @@ assert raw(ICMPv6RPL()/RPLDIS()/RPLOptSolInfo()) == b'\x9b\x00\x00\x00\x00\x00\x assert raw(ICMPv6RPL()/RPLDIO()/RPLOptDAGMC()/RPLDAGMCLinkETX()) == b'\x9b\x01\x00\x00\x32\x00\x00\x01\x88\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x06\x07\x00\x00\x02\x00\x01' # Normal DAO message with single target, since transit -assert raw(IPv6(src="fe80::1", dst="fe80::2")/\ - ICMPv6RPL()/RPLDAO()/\ - RPLOptTgt(plen=128,prefix="fd00::1")/\ - RPLOptTIO()) == \ - b'\x60\x00\x00\x00\x00\x22\x3a\x40\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x9b\x02\x2c\x04\x32\x00\x00\x01\x05\x12\x00\x80\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x06\x04\x00\x00\x00\xff' - -assert raw(ICMPv6RPL()/RPLDAO(D=1, dodagid="fd00::1")/RPLOptDAGMC()) == \ - b'\x9b\x02\x00\x00\x32\x40\x00\x01\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00' +assert raw(IPv6(src="fe80::1", dst="fe80::2") / ICMPv6RPL() / RPLDAO() / RPLOptTgt(plen=128, + prefix="fd00::1") / RPLOptTIO()) == b'\x60\x00\x00\x00\x00\x22\x3a\x40\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x9b\x02\x2c\x04\x32\x00\x00\x01\x05\x12\x00\x80\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x06\x04\x00\x00\x00\xff' + +assert raw(ICMPv6RPL() / RPLDAO(D=1, + dodagid="fd00::1") / RPLOptDAGMC()) == b'\x9b\x02\x00\x00\x32\x40\x00\x01\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00' p=IPv6(b'\x60\x00\x00\x00\x00\x1c\x3a\x40\xfe\x80\x00\x00\x00\x00\x00\x00\x0f\x86\xcc\x88\xaf\xfa\xbe\x25\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x9b\x07\xe8\x3f\x32\x00\x00\x01\x05\x12\x00\x80\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') assert p.payload.code == 7 # Its a DCO diff --git a/test/contrib/rtcp.uts b/test/contrib/rtcp.uts index 13afe20eb59..210c5ff74d6 100644 --- a/test/contrib/rtcp.uts +++ b/test/contrib/rtcp.uts @@ -49,10 +49,7 @@ assert parsed.report_blocks[0].delay_since_last_SR == 212763 = test source description report parse -raw = b"\x81\xca\x00\x0c\xa2\xdf\x02\x72\x01\x1c\x75\x73\x65\x72\x31\x35" \ - b"\x30\x33\x34\x38\x38\x39\x30\x31\x40\x68\x6f\x73\x74\x2d\x65\x37" \ - b"\x32\x64\x62\x34\x33\x64\x06\x09\x47\x53\x74\x72\x65\x61\x6d\x65" \ - b"\x72\x00\x00\x00" +raw = b"\x81\xca\x00\x0c\xa2\xdf\x02\x72\x01\x1c\x75\x73\x65\x72\x31\x35\x30\x33\x34\x38\x38\x39\x30\x31\x40\x68\x6f\x73\x74\x2d\x65\x37\x32\x64\x62\x34\x33\x64\x06\x09\x47\x53\x74\x72\x65\x61\x6d\x65\x72\x00\x00\x00" parsed = RTCP(raw) assert parsed.version == 2 assert parsed.padding == 0 @@ -70,9 +67,4 @@ assert parsed.sdes_chunks[0].items[1].value == b'GStreamer' + RTCP parsing tests = test parse SR and SDES stacked -raw = b"\x81\xc9\x00\x07\xa2\xdf\x02\x72\x49\x6e\x93\xbd\x00\xff\xff\xff" \ - b"\x00\x00\x59\x47\x00\x00\x00\x00\xe4\x8f\xb9\x3a\x00\x03\x3f\x1b" \ - b"\x81\xca\x00\x0c\xa2\xdf\x02\x72\x01\x1c\x75\x73\x65\x72\x31\x35" \ - b"\x30\x33\x34\x38\x38\x39\x30\x31\x40\x68\x6f\x73\x74\x2d\x65\x37" \ - b"\x32\x64\x62\x34\x33\x64\x06\x09\x47\x53\x74\x72\x65\x61\x6d\x65" \ - b"\x72\x00\x00\x00" +raw = b"\x81\xc9\x00\x07\xa2\xdf\x02\x72\x49\x6e\x93\xbd\x00\xff\xff\xff\x00\x00\x59\x47\x00\x00\x00\x00\xe4\x8f\xb9\x3a\x00\x03\x3f\x1b\x81\xca\x00\x0c\xa2\xdf\x02\x72\x01\x1c\x75\x73\x65\x72\x31\x35\x30\x33\x34\x38\x38\x39\x30\x31\x40\x68\x6f\x73\x74\x2d\x65\x37\x32\x64\x62\x34\x33\x64\x06\x09\x47\x53\x74\x72\x65\x61\x6d\x65\x72\x00\x00\x00" diff --git a/test/contrib/rtps.uts b/test/contrib/rtps.uts index ea4c25fa3ed..e88604688af 100644 --- a/test/contrib/rtps.uts +++ b/test/contrib/rtps.uts @@ -21,27 +21,18 @@ + Syntax check = Import the RTPS layer from scapy.contrib.rtps import * -pkt = b"\x52\x54\x50\x53\x02\x01\x01\x10\x57\x63\x10\x01\xd6\xab\x40\x7f" \ - b"\x5b\xd9\xbb\x1c\x0e\x01\x0c\x00\x88\x2a\x10\x01\x5d\x8c\x97\x40" \ - b"\x78\xb6\x2d\xc2\x09\x01\x08\x00\xf4\x50\x81\x60\x51\xdd\x5c\x1c" \ - b"\x15\x05\x10\x01\x00\x00\x10\x00\x00\x01\x00\xc7\x00\x01\x00\xc2" \ - b"\x00\x00\x00\x00\x01\x00\x00\x00\x00\x03\x00\x00\x15\x00\x04\x00" \ - b"\x02\x01\x00\x00\x16\x00\x04\x00\x01\x10\x00\x00\x02\x00\x08\x00" \ - b"\x0a\x00\x00\x00\x00\x00\x00\x00\x50\x00\x10\x00\x57\x63\x10\x01" \ - b"\xd6\xab\x40\x7f\x5b\xd9\xbb\x1c\x00\x00\x01\xc1\x58\x00\x04\x00" \ - b"\x3f\x0c\x00\x00\x0f\x00\x04\x00\x00\x00\x00\x00\x31\x00\x18\x00" \ - b"\x01\x00\x00\x00\xbd\xeb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - b"\x00\x00\x00\x00\xac\x11\x00\x02\x48\x00\x18\x00\x01\x00\x00\x00" \ - b"\xe9\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - b"\xef\xff\x00\x01\x32\x00\x18\x00\x01\x00\x00\x00\xbd\xeb\x00\x00" \ - b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xac\x11\x00\x02" \ - b"\x33\x00\x18\x00\x01\x00\x00\x00\xe8\x1c\x00\x00\x00\x00\x00\x00" \ - b"\x00\x00\x00\x00\x00\x00\x00\x00\xef\xff\x00\x01\x07\x80\x38\x00" \ - b"\x00\x00\x00\x00\x2c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - b"\x00\x00\x00\x00\x1d\x00\x00\x00\x74\x65\x73\x74\x2e\x6c\x6f\x63" \ - b"\x61\x6c\x2f\x30\x2e\x38\x2e\x30\x2f\x4c\x69\x6e\x75\x78\x2f\x4c" \ - b"\x69\x6e\x75\x78\x00\x00\x00\x00\x19\x80\x04\x00\x00\x80\x06\x00" \ - b"\x01\x00\x00\x00" +pkt = (b"\x52\x54\x50\x53\x02\x01\x01\x10\x57\x63\x10\x01\xd6\xab\x40\x7f\x5b\xd9\xbb\x1c\x0e\x01\x0c\x00\x88\x2a\x10" + b"\x01\x5d\x8c\x97\x40\x78\xb6\x2d\xc2\x09\x01\x08\x00\xf4\x50\x81\x60\x51\xdd\x5c\x1c\x15\x05\x10\x01\x00\x00" + b"\x10\x00\x00\x01\x00\xc7\x00\x01\x00\xc2\x00\x00\x00\x00\x01\x00\x00\x00\x00\x03\x00\x00\x15\x00\x04\x00\x02" + b"\x01\x00\x00\x16\x00\x04\x00\x01\x10\x00\x00\x02\x00\x08\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x50\x00\x10\x00" + b"\x57\x63\x10\x01\xd6\xab\x40\x7f\x5b\xd9\xbb\x1c\x00\x00\x01\xc1\x58\x00\x04\x00\x3f\x0c\x00\x00\x0f\x00\x04" + b"\x00\x00\x00\x00\x00\x31\x00\x18\x00\x01\x00\x00\x00\xbd\xeb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + b"\x00\x00\xac\x11\x00\x02\x48\x00\x18\x00\x01\x00\x00\x00\xe9\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + b"\x00\x00\x00\xef\xff\x00\x01\x32\x00\x18\x00\x01\x00\x00\x00\xbd\xeb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + b"\x00\x00\x00\x00\xac\x11\x00\x02\x33\x00\x18\x00\x01\x00\x00\x00\xe8\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00" + b"\x00\x00\x00\x00\x00\xef\xff\x00\x01\x07\x80\x38\x00\x00\x00\x00\x00\x2c\x00\x00\x00\x00\x00\x00\x00\x00\x00" + b"\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x74\x65\x73\x74\x2e\x6c\x6f\x63\x61\x6c\x2f\x30\x2e\x38\x2e\x30\x2f" + b"\x4c\x69\x6e\x75\x78\x2f\x4c\x69\x6e\x75\x78\x00\x00\x00\x00\x19\x80\x04\x00\x00\x80\x06\x00\x01\x00\x00\x00") + Test endianness = PID_BUILTIN_ENDPOINT_QOS endianness @@ -187,54 +178,34 @@ assert pkt3.build() == pkt + Test RTI RTPS = Test dissection -d = b"\x52\x54\x50\x53\x02\x03\x01\x01\x01\x01\x30\xba\xa8\x7b\x1d\xce" \ - b"\xb3\x29\x1e\x43\x09\x01\x08\x00\xd6\x64\xa8\x61\x16\x09\x34\x7c" \ - b"\x15\x05\xdc\x02\x00\x00\x10\x00\x00\x00\x00\x00\x00\x01\x00\xc2" \ - b"\x00\x00\x00\x00\x01\x00\x00\x00\x00\x03\x00\x00\x50\x00\x10\x00" \ - b"\x01\x01\x30\xba\xa8\x7b\x1d\xce\xb3\x29\x1e\x43\x00\x00\x01\xc1" \ - b"\x58\x00\x04\x00\x3f\x0c\x00\x00\x77\x00\x04\x00\x01\x00\x00\x00" \ - b"\x15\x00\x04\x00\x02\x03\x00\x00\x16\x00\x04\x00\x01\x01\x00\x00" \ - b"\x00\x80\x04\x00\x06\x00\x01\x00\x59\x00\x78\x01\x06\x00\x00\x00" \ - b"\x16\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f\x69\x6e\x66\x6f" \ - b"\x2e\x68\x6f\x73\x74\x6e\x61\x6d\x65\x00\x00\x00\x0d\x00\x00\x00" \ - b"\x64\x66\x30\x62\x36\x64\x38\x33\x61\x62\x34\x36\x00\x00\x00\x00" \ - b"\x18\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f\x69\x6e\x66\x6f" \ - b"\x2e\x70\x72\x6f\x63\x65\x73\x73\x5f\x69\x64\x00\x05\x00\x00\x00" \ - b"\x34\x38\x33\x30\x00\x00\x00\x00\x21\x00\x00\x00\x64\x64\x73\x2e" \ - b"\x73\x79\x73\x5f\x69\x6e\x66\x6f\x2e\x65\x78\x65\x63\x75\x74\x61" \ - b"\x62\x6c\x65\x5f\x66\x69\x6c\x65\x70\x61\x74\x68\x00\x00\x00\x00" \ - b"\x42\x00\x00\x00\x2f\x75\x73\x72\x2f\x6c\x6f\x63\x61\x6c\x2f\x73" \ - b"\x72\x63\x2f\x72\x74\x69\x2f\x72\x65\x73\x6f\x75\x72\x63\x65\x2f" \ - b"\x61\x70\x70\x2f\x62\x69\x6e\x2f\x78\x36\x34\x4c\x69\x6e\x75\x78" \ - b"\x32\x2e\x36\x67\x63\x63\x34\x2e\x34\x2e\x35\x2f\x72\x74\x69\x64" \ - b"\x64\x73\x73\x70\x79\x00\x00\x00\x14\x00\x00\x00\x64\x64\x73\x2e" \ - b"\x73\x79\x73\x5f\x69\x6e\x66\x6f\x2e\x74\x61\x72\x67\x65\x74\x00" \ - b"\x14\x00\x00\x00\x78\x36\x34\x4c\x69\x6e\x75\x78\x32\x2e\x36\x67" \ - b"\x63\x63\x34\x2e\x34\x2e\x35\x00\x20\x00\x00\x00\x64\x64\x73\x2e" \ - b"\x73\x79\x73\x5f\x69\x6e\x66\x6f\x2e\x63\x72\x65\x61\x74\x69\x6f" \ - b"\x6e\x5f\x74\x69\x6d\x65\x73\x74\x61\x6d\x70\x00\x14\x00\x00\x00" \ - b"\x32\x30\x32\x31\x2d\x30\x36\x2d\x37\x20\x30\x34\x3a\x30\x39\x3a" \ - b"\x30\x32\x5a\x00\x21\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f" \ - b"\x69\x6e\x66\x6f\x2e\x65\x78\x65\x63\x75\x74\x69\x6f\x6e\x5f\x74" \ - b"\x69\x6d\x65\x73\x74\x61\x6d\x70\x00\x00\x00\x00\x14\x00\x00\x00" \ - b"\x32\x30\x32\x31\x2d\x31\x32\x2d\x31\x20\x30\x39\x3a\x31\x35\x3a" \ - b"\x32\x39\x5a\x00\x31\x00\x18\x00\x01\x00\x00\x00\xf3\x1c\x00\x00" \ - b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - b"\x31\x00\x18\x00\x00\x00\x00\x01\xf3\x1c\x00\x00\x61\xab\xd9\x79" \ - b"\xb5\x7c\x13\xa5\x29\x49\x2c\xa3\x00\x00\x00\x00\x32\x00\x18\x00" \ - b"\x01\x00\x00\x00\xf2\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - b"\x00\x00\x00\x00\x00\x00\x00\x00\x32\x00\x18\x00\x00\x00\x00\x01" \ - b"\xf2\x1c\x00\x00\x61\xab\xd9\x79\xb5\x7c\x13\xa5\x29\x49\x2c\xa3" \ - b"\x00\x00\x00\x00\x33\x00\x18\x00\x01\x00\x00\x00\xe8\x1c\x00\x00" \ - b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xef\xff\x00\x01" \ - b"\x02\x00\x08\x00\x06\x00\x00\x00\xff\xff\xff\x7f\x01\x80\x04\x00" \ - b"\xff\xff\x00\x00\x62\x00\x28\x00\x22\x00\x00\x00\x52\x54\x49\x20" \ - b"\x44\x61\x74\x61\x20\x44\x69\x73\x74\x72\x69\x62\x75\x74\x69\x6f" \ - b"\x6e\x20\x53\x65\x72\x76\x69\x63\x65\x20\x53\x70\x79\x00\x00\x00" \ - b"\x0f\x00\x04\x00\x00\x00\x00\x00\x0f\x80\x04\x00\x00\x00\x00\x00" \ - b"\x10\x80\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\xe3\xff\x00\x00" \ - b"\x00\x00\x00\x01\x00\x00\x01\x00\x16\x80\x08\x00\x10\x00\x00\x00" \ - b"\x00\x00\x00\x00\x17\x80\x04\x00\x03\x00\x00\x00\x01\x00\x00\x00" +d = (b"\x52\x54\x50\x53\x02\x03\x01\x01\x01\x01\x30\xba\xa8\x7b\x1d\xce\xb3\x29\x1e\x43\x09\x01\x08\x00\xd6\x64\xa8\x61" + b"\x16\x09\x34\x7c\x15\x05\xdc\x02\x00\x00\x10\x00\x00\x00\x00\x00\x00\x01\x00\xc2\x00\x00\x00\x00\x01\x00\x00\x00" + b"\x00\x03\x00\x00\x50\x00\x10\x00\x01\x01\x30\xba\xa8\x7b\x1d\xce\xb3\x29\x1e\x43\x00\x00\x01\xc1\x58\x00\x04\x00" + b"\x3f\x0c\x00\x00\x77\x00\x04\x00\x01\x00\x00\x00\x15\x00\x04\x00\x02\x03\x00\x00\x16\x00\x04\x00\x01\x01\x00\x00" + b"\x00\x80\x04\x00\x06\x00\x01\x00\x59\x00\x78\x01\x06\x00\x00\x00\x16\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f" + b"\x69\x6e\x66\x6f\x2e\x68\x6f\x73\x74\x6e\x61\x6d\x65\x00\x00\x00\x0d\x00\x00\x00\x64\x66\x30\x62\x36\x64\x38\x33" + b"\x61\x62\x34\x36\x00\x00\x00\x00\x18\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f\x69\x6e\x66\x6f\x2e\x70\x72\x6f" + b"\x63\x65\x73\x73\x5f\x69\x64\x00\x05\x00\x00\x00\x34\x38\x33\x30\x00\x00\x00\x00\x21\x00\x00\x00\x64\x64\x73\x2e" + b"\x73\x79\x73\x5f\x69\x6e\x66\x6f\x2e\x65\x78\x65\x63\x75\x74\x61\x62\x6c\x65\x5f\x66\x69\x6c\x65\x70\x61\x74\x68" + b"\x00\x00\x00\x00\x42\x00\x00\x00\x2f\x75\x73\x72\x2f\x6c\x6f\x63\x61\x6c\x2f\x73\x72\x63\x2f\x72\x74\x69\x2f\x72" + b"\x65\x73\x6f\x75\x72\x63\x65\x2f\x61\x70\x70\x2f\x62\x69\x6e\x2f\x78\x36\x34\x4c\x69\x6e\x75\x78\x32\x2e\x36\x67" + b"\x63\x63\x34\x2e\x34\x2e\x35\x2f\x72\x74\x69\x64\x64\x73\x73\x70\x79\x00\x00\x00\x14\x00\x00\x00\x64\x64\x73\x2e" + b"\x73\x79\x73\x5f\x69\x6e\x66\x6f\x2e\x74\x61\x72\x67\x65\x74\x00\x14\x00\x00\x00\x78\x36\x34\x4c\x69\x6e\x75\x78" + b"\x32\x2e\x36\x67\x63\x63\x34\x2e\x34\x2e\x35\x00\x20\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f\x69\x6e\x66\x6f" + b"\x2e\x63\x72\x65\x61\x74\x69\x6f\x6e\x5f\x74\x69\x6d\x65\x73\x74\x61\x6d\x70\x00\x14\x00\x00\x00\x32\x30\x32\x31" + b"\x2d\x30\x36\x2d\x37\x20\x30\x34\x3a\x30\x39\x3a\x30\x32\x5a\x00\x21\x00\x00\x00\x64\x64\x73\x2e\x73\x79\x73\x5f" + b"\x69\x6e\x66\x6f\x2e\x65\x78\x65\x63\x75\x74\x69\x6f\x6e\x5f\x74\x69\x6d\x65\x73\x74\x61\x6d\x70\x00\x00\x00\x00" + b"\x14\x00\x00\x00\x32\x30\x32\x31\x2d\x31\x32\x2d\x31\x20\x30\x39\x3a\x31\x35\x3a\x32\x39\x5a\x00\x31\x00\x18\x00" + b"\x01\x00\x00\x00\xf3\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x31\x00\x18\x00" + b"\x00\x00\x00\x01\xf3\x1c\x00\x00\x61\xab\xd9\x79\xb5\x7c\x13\xa5\x29\x49\x2c\xa3\x00\x00\x00\x00\x32\x00\x18\x00" + b"\x01\x00\x00\x00\xf2\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x32\x00\x18\x00" + b"\x00\x00\x00\x01\xf2\x1c\x00\x00\x61\xab\xd9\x79\xb5\x7c\x13\xa5\x29\x49\x2c\xa3\x00\x00\x00\x00\x33\x00\x18\x00" + b"\x01\x00\x00\x00\xe8\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xef\xff\x00\x01\x02\x00\x08\x00" + b"\x06\x00\x00\x00\xff\xff\xff\x7f\x01\x80\x04\x00\xff\xff\x00\x00\x62\x00\x28\x00\x22\x00\x00\x00\x52\x54\x49\x20" + b"\x44\x61\x74\x61\x20\x44\x69\x73\x74\x72\x69\x62\x75\x74\x69\x6f\x6e\x20\x53\x65\x72\x76\x69\x63\x65\x20\x53\x70" + b"\x79\x00\x00\x00\x0f\x00\x04\x00\x00\x00\x00\x00\x0f\x80\x04\x00\x00\x00\x00\x00\x10\x80\x14\x00\x02\x00\x00\x00" + b"\x01\x00\x00\x00\xe3\xff\x00\x00\x00\x00\x00\x01\x00\x00\x01\x00\x16\x80\x08\x00\x10\x00\x00\x00\x00\x00\x00\x00" + b"\x17\x80\x04\x00\x03\x00\x00\x00\x01\x00\x00\x00") p0 = RTPS(d) p1 = RTPS( diff --git a/test/contrib/stun.uts b/test/contrib/stun.uts index 2a22a690248..5189c37dc84 100644 --- a/test/contrib/stun.uts +++ b/test/contrib/stun.uts @@ -12,14 +12,11 @@ = test STUN binding request 1 -raw = b"\x00\x01\x00\x64\x21\x12\xa4\x42\xcf\xac\xb2\xa4\x3a\xa2\xde\x5a" \ - b"\x9d\x56\xd8\x5a\x00\x25\x00\x00\x00\x24\x00\x04\x6e\x20\x00\xff" \ - b"\x80\x2a\x00\x08\x1b\x0a\xb9\x8b\x6e\x8e\xff\xa6\x00\x06\x00\x25" \ - b"\x6f\x4e\x70\x68\x3a\x48\x74\x31\x31\x4d\x61\x52\x5a\x48\x63\x34" \ - b"\x47\x4f\x4c\x4a\x55\x73\x62\x75\x31\x52\x33\x59\x43\x73\x37\x32" \ - b"\x48\x59\x4e\x32\x35\x20\x20\x20\x00\x08\x00\x14\xfc\xbc\x47\x21" \ - b"\x68\x1f\xdb\x59\x91\x33\x42\xbe\x96\x19\x9e\x7f\x3e\xf0\xe7\x77" \ - b"\x80\x28\x00\x04\x87\x18\xc3\xa4" +raw = (b"\x00\x01\x00\x64\x21\x12\xa4\x42\xcf\xac\xb2\xa4\x3a\xa2\xde\x5a\x9d\x56\xd8\x5a\x00\x25\x00\x00\x00\x24" + b"\x00\x04\x6e\x20\x00\xff\x80\x2a\x00\x08\x1b\x0a\xb9\x8b\x6e\x8e\xff\xa6\x00\x06\x00\x25\x6f\x4e\x70\x68" + b"\x3a\x48\x74\x31\x31\x4d\x61\x52\x5a\x48\x63\x34\x47\x4f\x4c\x4a\x55\x73\x62\x75\x31\x52\x33\x59\x43\x73" + b"\x37\x32\x48\x59\x4e\x32\x35\x20\x20\x20\x00\x08\x00\x14\xfc\xbc\x47\x21\x68\x1f\xdb\x59\x91\x33\x42\xbe" + b"\x96\x19\x9e\x7f\x3e\xf0\xe7\x77\x80\x28\x00\x04\x87\x18\xc3\xa4") parsed = STUN(raw) assert parsed.RESERVED == 0x00, parsed.RESERVED @@ -38,14 +35,11 @@ assert parsed.attributes == [ = test STUN binding request 2 -raw = b"\x00\x01\x00\x6c\x21\x12\xa4\x42\x34\x79\x47\x65\x34\x63\x59\x36" \ - b"\x31\x6a\x79\x6a\x00\x06\x00\x25\x48\x74\x31\x31\x4d\x61\x52\x5a" \ - b"\x48\x63\x34\x47\x4f\x4c\x4a\x55\x73\x62\x75\x31\x52\x33\x59\x43" \ - b"\x73\x37\x32\x48\x59\x4e\x32\x35\x3a\x6f\x4e\x70\x68\x00\x00\x00" \ - b"\xc0\x57\x00\x04\x00\x00\x03\xe7\x80\x2a\x00\x08\xa6\x96\x81\x9e" \ - b"\x91\xc9\x37\xda\x00\x25\x00\x00\x00\x24\x00\x04\x6e\x00\x1e\xff" \ - b"\x00\x08\x00\x14\xc1\x87\xaa\xfa\xb1\xe0\xf3\x12\x31\x43\x3a\xb1" \ - b"\x4d\x67\x6b\xc7\xb9\x89\xbd\x5f\x80\x28\x00\x04\xc9\x56\x6c\xfc" +raw = (b"\x00\x01\x00\x6c\x21\x12\xa4\x42\x34\x79\x47\x65\x34\x63\x59\x36\x31\x6a\x79\x6a\x00\x06\x00\x25\x48\x74" + b"\x31\x31\x4d\x61\x52\x5a\x48\x63\x34\x47\x4f\x4c\x4a\x55\x73\x62\x75\x31\x52\x33\x59\x43\x73\x37\x32\x48" + b"\x59\x4e\x32\x35\x3a\x6f\x4e\x70\x68\x00\x00\x00\xc0\x57\x00\x04\x00\x00\x03\xe7\x80\x2a\x00\x08\xa6\x96" + b"\x81\x9e\x91\xc9\x37\xda\x00\x25\x00\x00\x00\x24\x00\x04\x6e\x00\x1e\xff\x00\x08\x00\x14\xc1\x87\xaa\xfa" + b"\xb1\xe0\xf3\x12\x31\x43\x3a\xb1\x4d\x67\x6b\xc7\xb9\x89\xbd\x5f\x80\x28\x00\x04\xc9\x56\x6c\xfc") parsed = STUN(raw) assert parsed.RESERVED == 0x00, parsed.RESERVED @@ -66,10 +60,9 @@ assert parsed.attributes == [ = test STUN binding success response 1 -raw = b"\x01\x01\x00\x2c\x21\x12\xa4\x42\xcf\xac\xb2\xa4\x3a\xa2\xde\x5a" \ - b"\x9d\x56\xd8\x5a\x00\x20\x00\x08\x00\x01\xbf\x32\x8d\x06\xa4\x68" \ - b"\x00\x08\x00\x14\xb7\x1f\xc9\x23\x58\x97\xc8\x02\xe3\xff\xf8\xe3" \ - b"\xd8\x89\xfa\x41\x42\x8d\x96\x7d\x80\x28\x00\x04\xea\x9b\x65\x59" +raw = (b"\x01\x01\x00\x2c\x21\x12\xa4\x42\xcf\xac\xb2\xa4\x3a\xa2\xde\x5a\x9d\x56\xd8\x5a\x00\x20\x00\x08\x00\x01" + b"\xbf\x32\x8d\x06\xa4\x68\x00\x08\x00\x14\xb7\x1f\xc9\x23\x58\x97\xc8\x02\xe3\xff\xf8\xe3\xd8\x89\xfa\x41" + b"\x42\x8d\x96\x7d\x80\x28\x00\x04\xea\x9b\x65\x59") parsed = STUN(raw) assert parsed.RESERVED == 0x00, parsed.RESERVED @@ -85,13 +78,11 @@ assert parsed.attributes == [ = test STUN binding success response 2 -raw = b"\x01\x01\x00\x58\x21\x12\xa4\x42\x34\x79\x47\x65\x34\x63\x59\x36" \ - b"\x31\x6a\x79\x6a\x00\x20\x00\x08\x00\x01\x40\xba\x8d\x06\xa4\x8a" \ - b"\x00\x06\x00\x25\x48\x74\x31\x31\x4d\x61\x52\x5a\x48\x63\x34\x47" \ - b"\x4f\x4c\x4a\x55\x73\x62\x75\x31\x52\x33\x59\x43\x73\x37\x32\x48" \ - b"\x59\x4e\x32\x35\x3a\x6f\x4e\x70\x68\x20\x20\x20\x00\x08\x00\x14" \ - b"\x4b\x67\x03\x6d\xfb\x65\xca\x84\xd6\x3b\xca\xc8\x6c\x8d\x59\x81" \ - b"\xdf\x65\x70\x31\x80\x28\x00\x04\x40\x41\xe9\xc3" +raw = (b"\x01\x01\x00\x58\x21\x12\xa4\x42\x34\x79\x47\x65\x34\x63\x59\x36\x31\x6a\x79\x6a\x00\x20\x00\x08\x00\x01" + b"\x40\xba\x8d\x06\xa4\x8a\x00\x06\x00\x25\x48\x74\x31\x31\x4d\x61\x52\x5a\x48\x63\x34\x47\x4f\x4c\x4a\x55" + b"\x73\x62\x75\x31\x52\x33\x59\x43\x73\x37\x32\x48\x59\x4e\x32\x35\x3a\x6f\x4e\x70\x68\x20\x20\x20\x00\x08" + b"\x00\x14\x4b\x67\x03\x6d\xfb\x65\xca\x84\xd6\x3b\xca\xc8\x6c\x8d\x59\x81\xdf\x65\x70\x31\x80\x28\x00\x04" + b"\x40\x41\xe9\xc3") parsed = STUN(raw) assert parsed.RESERVED == 0x00, parsed.RESERVED @@ -109,8 +100,7 @@ assert parsed.attributes == [ = test STUN binding indication 1 -raw = b"\x00\x11\x00\x08\x21\x12\xa4\x42\x29\x3d\x68\x7b\x0f\xbc\x44\x7c" \ - b"\x01\xb5\x8d\x2e\x80\x28\x00\x04\xc8\x84\xfe\x99" +raw = b"\x00\x11\x00\x08\x21\x12\xa4\x42\x29\x3d\x68\x7b\x0f\xbc\x44\x7c\x01\xb5\x8d\x2e\x80\x28\x00\x04\xc8\x84\xfe\x99" parsed = STUN(raw) assert parsed.RESERVED == 0x00, parsed.RESERVED @@ -124,8 +114,7 @@ assert parsed.attributes == [ = test STUN binding indication 2 -raw = b"\x00\x11\x00\x08\x21\x12\xa4\x42\x1d\x93\x57\xa1\xe9\x4a\x20\x51" \ - b"\x27\x19\x96\xd9\x80\x28\x00\x04\x53\x80\x0d\x81" +raw = b"\x00\x11\x00\x08\x21\x12\xa4\x42\x1d\x93\x57\xa1\xe9\x4a\x20\x51\x27\x19\x96\xd9\x80\x28\x00\x04\x53\x80\x0d\x81" parsed = STUN(raw) assert parsed.RESERVED == 0x00, parsed.RESERVED diff --git a/test/contrib/tzsp.uts b/test/contrib/tzsp.uts index 45ea280282c..03b0b8962b4 100644 --- a/test/contrib/tzsp.uts +++ b/test/contrib/tzsp.uts @@ -13,10 +13,7 @@ bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ \ - IP(src='1.1.1.1', dst='2.2.2.2')/ \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ \ - TZSP(type=TZSP.TYPE_KEEPALIVE, encapsulated_protocol=0) +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ IP(src='1.1.1.1', dst='2.2.2.2')/ UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ TZSP(type=TZSP.TYPE_KEEPALIVE, encapsulated_protocol=0) frm = frm.build() frm = Ether(frm) @@ -28,11 +25,7 @@ assert not tzsp_lyr.payload bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ \ - IP(src='1.1.1.1', dst='2.2.2.2')/ \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ \ - TZSP(type=TZSP.TYPE_KEEPALIVE, encapsulated_protocol=0)/ \ - TZSPTagEnd() +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ IP(src='1.1.1.1', dst='2.2.2.2')/ UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ TZSP(type=TZSP.TYPE_KEEPALIVE, encapsulated_protocol=0)/ TZSPTagEnd() frm = frm.build() frm = Ether(frm) @@ -44,13 +37,7 @@ assert tzsp_lyr.guess_payload_class(tzsp_lyr.payload) is scapy.packet.Raw bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -68,14 +55,7 @@ assert encapsulated_ether_lyr.src == '00:03:03:03:03:03' bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagPadding() / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagPadding() / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -92,15 +72,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagRawRSSIByte(raw_rssi=42) / \ - TZSPTagRawRSSIShort(raw_rssi=12345) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagRawRSSIByte(raw_rssi=42) / TZSPTagRawRSSIShort(raw_rssi=12345) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -122,15 +94,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagSNRByte(snr=23) / \ - TZSPTagSNRShort(snr=54321) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagSNRByte(snr=23) / TZSPTagSNRShort(snr=54321) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -154,14 +118,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagDataRate(data_rate=TZSPTagDataRate.DATA_RATE_33) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagDataRate(data_rate=TZSPTagDataRate.DATA_RATE_33) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -180,14 +137,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagTimestamp(timestamp=0x11223344) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagTimestamp(timestamp=0x11223344) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -206,15 +156,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagContentionFree(contention_free=TZSPTagContentionFree.NO) / \ - TZSPTagContentionFree(contention_free=TZSPTagContentionFree.YES) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagContentionFree(contention_free=TZSPTagContentionFree.NO) / TZSPTagContentionFree(contention_free=TZSPTagContentionFree.YES) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -238,15 +180,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagDecrypted(decrypted=TZSPTagDecrypted.NO) / \ - TZSPTagDecrypted(decrypted=TZSPTagDecrypted.YES) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagDecrypted(decrypted=TZSPTagDecrypted.NO) / TZSPTagDecrypted(decrypted=TZSPTagDecrypted.YES) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -270,15 +204,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagError(fcs_error=TZSPTagError.NO) / \ - TZSPTagError(fcs_error=TZSPTagError.YES) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagError(fcs_error=TZSPTagError.NO) / TZSPTagError(fcs_error=TZSPTagError.YES) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -302,14 +228,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagRXChannel(rx_channel=123) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagRXChannel(rx_channel=123) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -328,14 +247,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagPacketCount(packet_count=0x44332211) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagPacketCount(packet_count=0x44332211) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -354,14 +266,7 @@ assert tzsp_tag_end.type == 1 bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagRXFrameLength(rx_frame_length=0xbad0) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagRXFrameLength(rx_frame_length=0xbad0) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -382,14 +287,7 @@ bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) SENSOR_ID = b'1E:AT:DE:AD:BE:EF' -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagWlanRadioHdrSerial(sensor_id=SENSOR_ID) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagWlanRadioHdrSerial(sensor_id=SENSOR_ID) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -410,15 +308,7 @@ bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) SENSOR_ID = b'1E:AT:DE:AD:BE:EF' -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagUnknown(len=6, data=b'\x06\x05\x04\x03\x02\x01') / \ - TZSPTagWlanRadioHdrSerial(sensor_id=SENSOR_ID) / \ - TZSPTagEnd() / \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / \ - Raw('foobar') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagUnknown(len=6, data=b'\x06\x05\x04\x03\x02\x01') / TZSPTagWlanRadioHdrSerial(sensor_id=SENSOR_ID) / TZSPTagEnd() / Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04') / Raw('foobar') frm = frm.build() frm = Ether(frm) @@ -432,30 +322,7 @@ assert type(tzsp_tag_unknown) is TZSPTagUnknown bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ \ - IP(src='1.1.1.1', dst='2.2.2.2')/ \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ \ - TZSP()/ \ - TZSPTagRawRSSIByte(raw_rssi=12)/ \ - TZSPTagRawRSSIShort(raw_rssi=1234)/ \ - TZSPTagSNRByte(snr=12)/ \ - TZSPTagSNRShort(snr=1234)/ \ - TZSPTagDataRate(data_rate = TZSPTagDataRate.DATA_RATE_54)/ \ - TZSPTagTimestamp(timestamp=12345)/ \ - TZSPTagContentionFree(contention_free = TZSPTagContentionFree.NO)/ \ - TZSPTagContentionFree(contention_free = TZSPTagContentionFree.YES)/ \ - TZSPTagDecrypted(decrypted=TZSPTagDecrypted.NO)/ \ - TZSPTagDecrypted(decrypted=TZSPTagDecrypted.YES)/ \ - TZSPTagError(fcs_error = TZSPTagError.YES)/ \ - TZSPTagError(fcs_error = TZSPTagError.NO)/ \ - TZSPTagRXChannel(rx_channel = 42)/ \ - TZSPTagPacketCount(packet_count = 987654)/ \ - TZSPTagRXFrameLength(rx_frame_length = 0x0bad)/ \ - TZSPTagWlanRadioHdrSerial(sensor_id = 'foobar')/ \ - TZSPTagPadding()/ \ - TZSPTagEnd()/ \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04')/ \ - ARP() +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ IP(src='1.1.1.1', dst='2.2.2.2')/ UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ TZSP()/ TZSPTagRawRSSIByte(raw_rssi=12)/ TZSPTagRawRSSIShort(raw_rssi=1234)/ TZSPTagSNRByte(snr=12)/ TZSPTagSNRShort(snr=1234)/ TZSPTagDataRate(data_rate = TZSPTagDataRate.DATA_RATE_54)/ TZSPTagTimestamp(timestamp=12345)/ TZSPTagContentionFree(contention_free = TZSPTagContentionFree.NO)/ TZSPTagContentionFree(contention_free = TZSPTagContentionFree.YES)/ TZSPTagDecrypted(decrypted=TZSPTagDecrypted.NO)/ TZSPTagDecrypted(decrypted=TZSPTagDecrypted.YES)/ TZSPTagError(fcs_error = TZSPTagError.YES)/ TZSPTagError(fcs_error = TZSPTagError.NO)/ TZSPTagRXChannel(rx_channel = 42)/ TZSPTagPacketCount(packet_count = 987654)/ TZSPTagRXFrameLength(rx_frame_length = 0x0bad)/ TZSPTagWlanRadioHdrSerial(sensor_id = 'foobar')/ TZSPTagPadding()/ TZSPTagEnd()/ Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04')/ ARP() frm = frm.build() frm = Ether(frm) @@ -528,12 +395,7 @@ assert encapsulated_ether_lyr.src == '00:03:03:03:03:03' bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ \ - IP(src='1.1.1.1', dst='2.2.2.2')/ \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ \ - TZSP()/ \ - TZSPTagContentionFree(contention_free = 0xff)/ \ - TZSPTagEnd() +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ IP(src='1.1.1.1', dst='2.2.2.2')/ UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ TZSP()/ TZSPTagContentionFree(contention_free = 0xff)/ TZSPTagEnd() frm = frm.build() frm = Ether(frm) @@ -548,12 +410,7 @@ assert symb_str == 'yes' bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ \ - IP(src='1.1.1.1', dst='2.2.2.2')/ \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ \ - TZSP()/ \ - TZSPTagError(fcs_error=TZSPTagError.NO)/ \ - TZSPTagEnd() +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ IP(src='1.1.1.1', dst='2.2.2.2')/ UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ TZSP()/ TZSPTagError(fcs_error=TZSPTagError.NO)/ TZSPTagEnd() frm = frm.build() frm = Ether(frm) @@ -564,12 +421,7 @@ assert tzsp_tag_error_attr symb_str = tzsp_tag_error_attr.i2repr(tzsp_tag_error, tzsp_tag_error.fcs_error) assert symb_str == 'no' -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ \ - IP(src='1.1.1.1', dst='2.2.2.2')/ \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ \ - TZSP()/ \ - TZSPTagError(fcs_error=TZSPTagError.YES + 1)/ \ - TZSPTagEnd() +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02')/ IP(src='1.1.1.1', dst='2.2.2.2')/ UDP(sport=12345, dport=TZSP_PORT_DEFAULT)/ TZSP()/ TZSPTagError(fcs_error=TZSPTagError.YES + 1)/ TZSPTagEnd() frm = frm.build() frm = Ether(frm) @@ -582,9 +434,7 @@ assert symb_str == 'reserved' == missing TZSP header before end tag -frm = TZSPTagEnd()/ \ - Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04')/ \ - ARP() +frm = TZSPTagEnd()/ Ether(src='00:03:03:03:03:03', dst='00:04:04:04:04:04')/ ARP() frm = frm.build() try: @@ -597,12 +447,7 @@ except TZSPStructureException: bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - TZSPTagRawRSSIByte(len=3) / \ - TZSPTagEnd() +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / TZSPTagRawRSSIByte(len=3) / TZSPTagEnd() frm = frm.build() frm = Ether(frm) @@ -616,11 +461,7 @@ bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) SENSOR_ID = '1E:AT:DE:AD:BE:EF' -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - Raw(b'\xff\x0a\x01\x02\x03\x04\x05') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / Raw(b'\xff\x0a\x01\x02\x03\x04\x05') frm = frm.build() frm = Ether(frm) @@ -637,11 +478,7 @@ bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT) SENSOR_ID = '1E:AT:DE:AD:BE:EF' -frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / \ - IP(src='1.1.1.1', dst='2.2.2.2') / \ - UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / \ - TZSP() / \ - Raw(b'\xff') +frm = Ether(src='00:01:01:01:01:01', dst='00:02:02:02:02:02') / IP(src='1.1.1.1', dst='2.2.2.2') / UDP(sport=12345, dport=TZSP_PORT_DEFAULT) / TZSP() / Raw(b'\xff') frm = frm.build() frm = Ether(frm) diff --git a/test/scapy/layers/bluetooth.uts b/test/scapy/layers/bluetooth.uts index 539a3d97ffd..6bfbb5e29aa 100644 --- a/test/scapy/layers/bluetooth.uts +++ b/test/scapy/layers/bluetooth.uts @@ -294,9 +294,7 @@ assert evt_pkt[HCI_LE_Meta_Connection_Update_Complete].timeout == 60 + Bluetooth LE Advertising / Scan Response Data Parsing = Parse EIR_Flags, EIR_CompleteList16BitServiceUUIDs, EIR_CompleteLocalName and EIR_TX_Power_Level -ad_report_raw_data = \ - hex_bytes("043e2b020100016522c00181781f0201020303d9fe1409" \ - "506562626c652054696d65204c452037314536020a0cde") +ad_report_raw_data = hex_bytes("043e2b020100016522c00181781f0201020303d9fe1409506562626c652054696d65204c452037314536020a0cde") scapy_packet = HCI_Hdr(ad_report_raw_data) assert scapy_packet[EIR_Flags].flags == 0x02 @@ -306,9 +304,7 @@ assert scapy_packet[EIR_TX_Power_Level].level == 12 = Parse EIR_Manufacturer_Specific_Data -scan_resp_raw_data = \ - hex_bytes("043e2302010401be5e0eb9f04f1716ff5401005f423331" \ - "3134374432343631fc00030c0000de") +scan_resp_raw_data = hex_bytes("043e2302010401be5e0eb9f04f1716ff5401005f4233313134374432343631fc00030c0000de") scapy_packet = HCI_Hdr(scan_resp_raw_data) assert raw(scapy_packet[EIR_Manufacturer_Specific_Data].payload) == b'\x00_B31147D2461\xfc\x00\x03\x0c\x00\x00' diff --git a/test/scapy/layers/bluetooth4LE.uts b/test/scapy/layers/bluetooth4LE.uts index b671a0c347f..533a2dfee96 100644 --- a/test/scapy/layers/bluetooth4LE.uts +++ b/test/scapy/layers/bluetooth4LE.uts @@ -8,7 +8,7 @@ = Default build -a = BTLE()/BTLE_ADV()/BTLE_ADV_IND() +a = BTLE() / BTLE_ADV() / BTLE_ADV_IND() assert raw(a) == b'\xd6\xbe\x89\x8e\x00\x06\x00\x00\x00\x00\x00\x00Z9`' = Basic dissection @@ -19,14 +19,14 @@ assert b[BTLE_ADV_IND].AdvA == '00:00:00:00:00:00' = BTLE_DATA build -a = BTLE(access_addr=0)/BTLE_DATA()/"toto" +a = BTLE(access_addr=0) / BTLE_DATA() / "toto" a = BTLE(raw(a)) assert a[BTLE_DATA].len == 4 assert a[Raw].load == b"toto" = Longer BTLE_ADV -a = BTLE()/BTLE_ADV()/BTLE_CONNECT_REQ()/(b"X"*200) +a = BTLE() / BTLE_ADV() / BTLE_CONNECT_REQ() / (b"X" * 200) assert raw(a) == b'\xd6\xbe\x89\x8e\x05\xea\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXI\xfc\xcf' pkt = BTLE(raw(a)) assert pkt.Length == 0xea @@ -34,14 +34,15 @@ assert pkt.load == b"X" * 200 = BTLE_DATA + EIR_ShortenedLocalName -test1 = BTLE() / BTLE_ADV() / BTLE_ADV_IND() / EIR_Hdr() / EIR_ShortenedLocalName(local_name= 'wussa') +test1 = BTLE() / BTLE_ADV() / BTLE_ADV_IND() / EIR_Hdr() / EIR_ShortenedLocalName(local_name='wussa') test1e = BTLE(raw(test1)) assert test1e[EIR_ShortenedLocalName].local_name == b"wussa" = LL_CONNECTION_UPDATE_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CONNECTION_UPDATE_IND(win_size=2, win_offset=5, interval=0x400, timeout=500, instant=0xFEFE) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CONNECTION_UPDATE_IND(win_size=2, win_offset=5, + interval=0x400, timeout=500, + instant=0xFEFE) test = BTLE(raw(test)) assert test[LL_CONNECTION_UPDATE_IND].win_size == 2 assert test[LL_CONNECTION_UPDATE_IND].win_offset == 5 @@ -51,24 +52,21 @@ assert test[LL_CONNECTION_UPDATE_IND].instant == 0xFEFE = LL_CHANNEL_MAP_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CHANNEL_MAP_IND(chM=0x1A1B1C1D1E, instant=0xFEFE) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CHANNEL_MAP_IND(chM=0x1A1B1C1D1E, instant=0xFEFE) test = BTLE(raw(test)) assert test[LL_CHANNEL_MAP_IND].chM == 0x1A1B1C1D1E assert test[LL_CHANNEL_MAP_IND].instant == 0xFEFE = LL_TERMINATE_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_TERMINATE_IND(code=0x16) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_TERMINATE_IND(code=0x16) test = BTLE(raw(test)) assert test[LL_TERMINATE_IND].code == 0x16 = LL_ENC_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_ENC_REQ(rand=0x1112131415161718, ediv=0x4321, - skdm=0x1817161514131211, ivm=0x87654321) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_ENC_REQ(rand=0x1112131415161718, ediv=0x4321, + skdm=0x1817161514131211, ivm=0x87654321) test = BTLE(raw(test)) assert test[LL_ENC_REQ].rand == 0x1112131415161718 assert test[LL_ENC_REQ].ediv == 0x4321 @@ -77,8 +75,7 @@ assert test[LL_ENC_REQ].ivm == 0x87654321 = LL_ENC_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_ENC_RSP(skds=0x1817161514131211, ivs=0x87654321) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_ENC_RSP(skds=0x1817161514131211, ivs=0x87654321) test = BTLE(raw(test)) assert test[LL_ENC_RSP].skds == 0x1817161514131211 assert test[LL_ENC_RSP].ivs == 0x87654321 @@ -105,16 +102,15 @@ assert test[LL_UNKNOWN_RSP].code == 4 test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_FEATURE_REQ(feature_set=0x011234) test = BTLE(raw(test)) -assert test[LL_FEATURE_REQ].feature_set == \ - "ext_reject_ind+le_ping+le_data_len_ext+tx_mod_idx+le_ext_adv+conn_cte_req" +assert test[LL_FEATURE_REQ].feature_set == "ext_reject_ind+le_ping+le_data_len_ext+tx_mod_idx+le_ext_adv+conn_cte_req" = LL_FEATURE_RSP test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_FEATURE_RSP(feature_set=0x104321) test = BTLE(raw(test)) print(test[LL_FEATURE_RSP].feature_set) -assert test[LL_FEATURE_RSP].feature_set == \ - "le_encryption+le_data_len_ext+le_2m_phy+tx_mod_idx+ch_sel_alg+antenna_switching_cte_aod_tx" +assert test[ + LL_FEATURE_RSP].feature_set == "le_encryption+le_data_len_ext+le_2m_phy+tx_mod_idx+ch_sel_alg+antenna_switching_cte_aod_tx" = LL_PAUSE_ENC_REQ @@ -130,8 +126,7 @@ assert test[BTLE_CTRL].opcode == 11 = LL_VERSION_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_VERSION_IND(version=7, company=0x59, subversion=1) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_VERSION_IND(version=7, company=0x59, subversion=1) test = BTLE(raw(test)) assert test[LL_VERSION_IND].version == 7 assert test[LL_VERSION_IND].company == 0x59 @@ -147,15 +142,16 @@ assert test[LL_REJECT_IND].code == 4 test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_SLAVE_FEATURE_REQ(feature_set=0x1234) test = BTLE(raw(test)) -assert test[LL_SLAVE_FEATURE_REQ].feature_set == \ - "ext_reject_ind+le_ping+le_data_len_ext+tx_mod_idx+le_ext_adv" +assert test[LL_SLAVE_FEATURE_REQ].feature_set == "ext_reject_ind+le_ping+le_data_len_ext+tx_mod_idx+le_ext_adv" = LL_CONNECTION_PARAM_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CONNECTION_PARAM_REQ(interval_min=10, interval_max=12, latency=1, timeout=2, - preferred_periodicity=3, reference_conn_evt_count=4, - offset0=5, offset1=6, offset2=7, offset3=8, offset4=9, offset5=10) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CONNECTION_PARAM_REQ(interval_min=10, interval_max=12, + latency=1, timeout=2, + preferred_periodicity=3, + reference_conn_evt_count=4, offset0=5, + offset1=6, offset2=7, offset3=8, + offset4=9, offset5=10) test = BTLE(raw(test)) assert test[LL_CONNECTION_PARAM_REQ].interval_min == 10 assert test[LL_CONNECTION_PARAM_REQ].interval_max == 12 @@ -172,10 +168,12 @@ assert test[LL_CONNECTION_PARAM_REQ].offset5 == 10 = LL_CONNECTION_PARAM_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CONNECTION_PARAM_RSP(interval_min=10, interval_max=12, latency=1, timeout=2, - preferred_periodicity=3, reference_conn_evt_count=4, - offset0=5, offset1=6, offset2=7, offset3=8, offset4=9, offset5=10) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CONNECTION_PARAM_RSP(interval_min=10, interval_max=12, + latency=1, timeout=2, + preferred_periodicity=3, + reference_conn_evt_count=4, offset0=5, + offset1=6, offset2=7, offset3=8, + offset4=9, offset5=10) test = BTLE(raw(test)) assert test[LL_CONNECTION_PARAM_RSP].interval_min == 10 assert test[LL_CONNECTION_PARAM_RSP].interval_max == 12 @@ -192,8 +190,7 @@ assert test[LL_CONNECTION_PARAM_RSP].offset5 == 10 = LL_REJECT_EXT_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_REJECT_EXT_IND(reject_opcode=2, error_code=4) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_REJECT_EXT_IND(reject_opcode=2, error_code=4) test = BTLE(raw(test)) assert test[LL_REJECT_EXT_IND].reject_opcode == 2 assert test[LL_REJECT_EXT_IND].error_code == 4 @@ -212,8 +209,8 @@ assert test[BTLE_CTRL].opcode == 19 = LL_LENGTH_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_LENGTH_REQ(max_rx_bytes=28, max_rx_time=329, max_tx_bytes=29, max_tx_time=330) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_LENGTH_REQ(max_rx_bytes=28, max_rx_time=329, + max_tx_bytes=29, max_tx_time=330) test = BTLE(raw(test)) assert test[LL_LENGTH_REQ].max_rx_bytes == 28 assert test[LL_LENGTH_REQ].max_rx_time == 329 @@ -222,8 +219,8 @@ assert test[LL_LENGTH_REQ].max_tx_time == 330 = LL_LENGTH_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_LENGTH_RSP(max_tx_bytes=28, max_tx_time=329, max_rx_bytes=29, max_rx_time=330) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_LENGTH_RSP(max_tx_bytes=28, max_tx_time=329, + max_rx_bytes=29, max_rx_time=330) test = BTLE(raw(test)) assert test[LL_LENGTH_RSP].max_tx_bytes == 28 assert test[LL_LENGTH_RSP].max_tx_time == 329 @@ -232,24 +229,22 @@ assert test[LL_LENGTH_RSP].max_rx_time == 330 = LL_PHY_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_PHY_REQ(tx_phys="phy_1m+phy_2m", rx_phys="phy_coded") +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_PHY_REQ(tx_phys="phy_1m+phy_2m", rx_phys="phy_coded") test = BTLE(raw(test)) assert test[LL_PHY_REQ].tx_phys == "phy_1m+phy_2m" assert test[LL_PHY_REQ].rx_phys == "phy_coded" = LL_PHY_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_PHY_RSP(tx_phys="phy_1m+phy_2m", rx_phys="phy_coded") +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_PHY_RSP(tx_phys="phy_1m+phy_2m", rx_phys="phy_coded") test = BTLE(raw(test)) assert test[LL_PHY_RSP].tx_phys == "phy_1m+phy_2m" assert test[LL_PHY_RSP].rx_phys == "phy_coded" = LL_PHY_UPDATE_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_PHY_UPDATE_IND(tx_phy="phy_2m", rx_phy="phy_coded", instant=1234) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_PHY_UPDATE_IND(tx_phy="phy_2m", rx_phy="phy_coded", + instant=1234) test = BTLE(raw(test)) assert test[LL_PHY_UPDATE_IND].tx_phy == "phy_2m" assert test[LL_PHY_UPDATE_IND].rx_phy == "phy_coded" @@ -257,38 +252,33 @@ assert test[LL_PHY_UPDATE_IND].instant == 1234 # LL_MIN_USED_CHANNELS_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_MIN_USED_CHANNELS_IND(phys="phy_1m+phy_2m", min_used_channels=3) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_MIN_USED_CHANNELS_IND(phys="phy_1m+phy_2m", + min_used_channels=3) test = BTLE(raw(test)) assert test[LL_MIN_USED_CHANNELS_IND].phys == "phy_1m+phy_2m" assert test[LL_MIN_USED_CHANNELS_IND].min_used_channels == 3 # LL_CTE_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CTE_REQ(min_cte_len_req=20, rfu=1, cte_type_req=2) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CTE_REQ(min_cte_len_req=20, rfu=1, cte_type_req=2) test = BTLE(raw(test)) assert test[LL_CTE_REQ].min_cte_len_req == 20 assert test[LL_CTE_REQ].rfu == 1 assert test[LL_CTE_REQ].cte_type_req == 2 - # LL_CTE_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CTE_RSP() +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CTE_RSP() test = BTLE(raw(test)) - # LL_PERIODIC_SYNC_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_PERIODIC_SYNC_IND(id=2, - sync_info=12345, - conn_event_count=0x4321, - last_pa_event_counter=0xabcd, sid=0xF, - a_type=1, sca=3, phy=2, AdvA="cc:bb:bb:bb:bb:bb", - sync_conn_event_count=32) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_PERIODIC_SYNC_IND(id=2, sync_info=12345, + conn_event_count=0x4321, + last_pa_event_counter=0xabcd, sid=0xF, + a_type=1, sca=3, phy=2, + AdvA="cc:bb:bb:bb:bb:bb", + sync_conn_event_count=32) test = BTLE(raw(test)) assert test[LL_PERIODIC_SYNC_IND].id == 2 assert test[LL_PERIODIC_SYNC_IND].sync_info == 12345 @@ -301,36 +291,31 @@ assert test[LL_PERIODIC_SYNC_IND].phy == 2 assert test[LL_PERIODIC_SYNC_IND].AdvA == "cc:bb:bb:bb:bb:bb" assert test[LL_PERIODIC_SYNC_IND].sync_conn_event_count == 32 - # LL_CLOCK_ACCURACY_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CLOCK_ACCURACY_REQ(sca=2) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CLOCK_ACCURACY_REQ(sca=2) test = BTLE(raw(test)) assert test[LL_CLOCK_ACCURACY_REQ].sca == 2 - # LL_CLOCK_ACCURACY_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CLOCK_ACCURACY_RSP(sca=3) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CLOCK_ACCURACY_RSP(sca=3) test = BTLE(raw(test)) assert test[LL_CLOCK_ACCURACY_RSP].sca == 3 - # LL_CIS_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CIS_REQ(cig_id=3, cis_id=2, phy_c_to_p=1, phy_p_to_c=2, - max_sdu_c_to_p=123, max_sdu_p_to_c=321, - sdu_interval_c_to_p=234, framed=1, sdu_interval_p_to_c=432, - max_pdu_c_to_p=123, max_pdu_p_to_c=234, - nse=10, subinterval=4567, - bn_c_to_p=3, bn_p_to_c=2, - ft_c_to_p=15, ft_p_to_c=16, - iso_interval=12345, - cis_offset_min=1, cis_offset_max=999, - conn_event_count=2) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CIS_REQ(cig_id=3, cis_id=2, phy_c_to_p=1, phy_p_to_c=2, + max_sdu_c_to_p=123, max_sdu_p_to_c=321, + sdu_interval_c_to_p=234, framed=1, + sdu_interval_p_to_c=432, max_pdu_c_to_p=123, + max_pdu_p_to_c=234, + nse=10, subinterval=4567, + bn_c_to_p=3, bn_p_to_c=2, + ft_c_to_p=15, ft_p_to_c=16, + iso_interval=12345, + cis_offset_min=1, cis_offset_max=999, + conn_event_count=2) test = BTLE(raw(test)) assert test[LL_CIS_REQ].cig_id == 3 assert test[LL_CIS_REQ].cis_id == 2 @@ -354,22 +339,20 @@ assert test[LL_CIS_REQ].cis_offset_min == 1 assert test[LL_CIS_REQ].cis_offset_max == 999 assert test[LL_CIS_REQ].conn_event_count == 2 - # LL_CIS_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CIS_RSP(cis_offset_min=1, cis_offset_max=999, conn_event_count=400) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CIS_RSP(cis_offset_min=1, cis_offset_max=999, + conn_event_count=400) test = BTLE(raw(test)) assert test[LL_CIS_RSP].cis_offset_min == 1 assert test[LL_CIS_RSP].cis_offset_max == 999 assert test[LL_CIS_RSP].conn_event_count == 400 - # LL_CIS_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CIS_IND(AA=0x12345678, cis_offset=1, - cig_sync_delay=999, cis_sync_delay=400, conn_event_count=300) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CIS_IND(AA=0x12345678, cis_offset=1, + cig_sync_delay=999, cis_sync_delay=400, + conn_event_count=300) test = BTLE(raw(test)) assert test[LL_CIS_IND].AA == 0x12345678 assert test[LL_CIS_IND].cis_offset == 1 @@ -377,31 +360,26 @@ assert test[LL_CIS_IND].cig_sync_delay == 999 assert test[LL_CIS_IND].cis_sync_delay == 400 assert test[LL_CIS_IND].conn_event_count == 300 - # LL_CIS_TERMINATE_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CIS_TERMINATE_IND(cig_id=33, cis_id=44, error_code=55) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CIS_TERMINATE_IND(cig_id=33, cis_id=44, error_code=55) test = BTLE(raw(test)) assert test[LL_CIS_TERMINATE_IND].cig_id == 33 assert test[LL_CIS_TERMINATE_IND].cis_id == 44 assert test[LL_CIS_TERMINATE_IND].error_code == 55 - # LL_POWER_CONTROL_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_POWER_CONTROL_REQ(phy=3, delta=-34, tx_power=55) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_POWER_CONTROL_REQ(phy=3, delta=-34, tx_power=55) test = BTLE(raw(test)) assert test[LL_POWER_CONTROL_REQ].phy == 3 assert test[LL_POWER_CONTROL_REQ].delta == -34 assert test[LL_POWER_CONTROL_REQ].tx_power == 55 - # LL_POWER_CONTROL_RSP -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_POWER_CONTROL_RSP(min=0, max=1, delta=-34, tx_power=55, apr=4) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_POWER_CONTROL_RSP(min=0, max=1, delta=-34, tx_power=55, + apr=4) test = BTLE(raw(test)) assert test[LL_POWER_CONTROL_RSP].min == 0 assert test[LL_POWER_CONTROL_RSP].max == 1 @@ -409,11 +387,10 @@ assert test[LL_POWER_CONTROL_RSP].delta == -34 assert test[LL_POWER_CONTROL_RSP].tx_power == 55 assert test[LL_POWER_CONTROL_RSP].apr == 4 - # LL_POWER_CHANGE_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_POWER_CHANGE_IND(phy=3, min=0, max=1, delta=-34, tx_power=55) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_POWER_CHANGE_IND(phy=3, min=0, max=1, delta=-34, + tx_power=55) test = BTLE(raw(test)) assert test[LL_POWER_CHANGE_IND].phy == 3 assert test[LL_POWER_CHANGE_IND].min == 0 @@ -421,13 +398,11 @@ assert test[LL_POWER_CHANGE_IND].max == 1 assert test[LL_POWER_CHANGE_IND].delta == -34 assert test[LL_POWER_CHANGE_IND].tx_power == 55 - - # LL_SUBRATE_REQ -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_SUBRATE_REQ(subrate_factor_min=3, subrate_factor_max=0, - max_latency=1, continuation_number=123, timeout=55) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_SUBRATE_REQ(subrate_factor_min=3, subrate_factor_max=0, + max_latency=1, continuation_number=123, + timeout=55) test = BTLE(raw(test)) assert test[LL_SUBRATE_REQ].subrate_factor_min == 3 assert test[LL_SUBRATE_REQ].subrate_factor_max == 0 @@ -435,12 +410,10 @@ assert test[LL_SUBRATE_REQ].max_latency == 1 assert test[LL_SUBRATE_REQ].continuation_number == 123 assert test[LL_SUBRATE_REQ].timeout == 55 - # LL_SUBRATE_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_SUBRATE_IND(subrate_factor=3, subrate_base_event=0, - latency=1, continuation_number=123, timeout=55) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_SUBRATE_IND(subrate_factor=3, subrate_base_event=0, + latency=1, continuation_number=123, timeout=55) test = BTLE(raw(test)) assert test[LL_SUBRATE_IND].subrate_factor == 3 assert test[LL_SUBRATE_IND].subrate_base_event == 0 @@ -448,28 +421,25 @@ assert test[LL_SUBRATE_IND].latency == 1 assert test[LL_SUBRATE_IND].continuation_number == 123 assert test[LL_SUBRATE_IND].timeout == 55 - # LL_CHANNEL_REPORTING_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CHANNEL_REPORTING_IND(enable=1, min_spacing=123, max_delay=124) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CHANNEL_REPORTING_IND(enable=1, min_spacing=123, + max_delay=124) test = BTLE(raw(test)) assert test[LL_CHANNEL_REPORTING_IND].enable == 1 assert test[LL_CHANNEL_REPORTING_IND].min_spacing == 123 assert test[LL_CHANNEL_REPORTING_IND].max_delay == 124 - # LL_CHANNEL_STATUS_IND -test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / \ - LL_CHANNEL_STATUS_IND(channel_classification=123456789012345) +test = BTLE(access_addr=1) / BTLE_DATA() / BTLE_CTRL() / LL_CHANNEL_STATUS_IND(channel_classification=123456789012345) test = BTLE(raw(test)) assert test[LL_CHANNEL_STATUS_IND].channel_classification == 123456789012345 = BTLE_DATA + BTLE_EMPTY_PDU -test = BTLE(access_addr=1)/BTLE_DATA(LLID=1, len=0)/BTLE_EMPTY_PDU() +test = BTLE(access_addr=1) / BTLE_DATA(LLID=1, len=0) / BTLE_EMPTY_PDU() a = BTLE(raw(test)) print(dir(a)) print(a.layers) @@ -478,7 +448,8 @@ assert a[BTLE_DATA].len == 0 = BTLE_DATA + ATT_PrepareWriteReq -test3 = BTLE(access_addr=1) / BTLE_DATA() / L2CAP_Hdr() / ATT_Hdr() / ATT_Prepare_Write_Request(gatt_handle = 0xa, data="test") +test3 = BTLE(access_addr=1) / BTLE_DATA() / L2CAP_Hdr() / ATT_Hdr() / ATT_Prepare_Write_Request(gatt_handle=0xa, + data="test") test3e = BTLE(raw(test3)) assert test3e[ATT_Prepare_Write_Request].data == b"test" assert test3e[ATT_Prepare_Write_Request].gatt_handle == 0xa @@ -487,7 +458,7 @@ assert test3e[ATT_Hdr].opcode == 0x16 = BTLE layers # a crazy packet with all classes in it! -pkt = BTLE()/BTLE_ADV()/BTLE_ADV_DIRECT_IND()/BTLE_ADV_IND()/BTLE_ADV_NONCONN_IND()/BTLE_ADV_SCAN_IND()/BTLE_CONNECT_REQ()/BTLE_DATA()/BTLE_PPI()/BTLE_SCAN_REQ()/BTLE_SCAN_RSP() +pkt = BTLE() / BTLE_ADV() / BTLE_ADV_DIRECT_IND() / BTLE_ADV_IND() / BTLE_ADV_NONCONN_IND() / BTLE_ADV_SCAN_IND() / BTLE_CONNECT_REQ() / BTLE_DATA() / BTLE_PPI() / BTLE_SCAN_REQ() / BTLE_SCAN_RSP() assert BTLE in pkt.layers() assert BTLE_ADV in pkt.layers() assert BTLE_ADV_DIRECT_IND in pkt.layers() @@ -502,7 +473,7 @@ assert BTLE_SCAN_RSP in pkt.layers() = BTLE_RF link -a = BTLE_RF()/BTLE()/BTLE_ADV()/BTLE_SCAN_REQ() +a = BTLE_RF() / BTLE() / BTLE_ADV() / BTLE_SCAN_REQ() a.ScanA = "aa:aa:aa:aa:aa:aa" a.AdvA = "bb:bb:bb:bb:bb:bb" a.reference_access_address_valid = 1 diff --git a/test/scapy/layers/dhcp6.uts b/test/scapy/layers/dhcp6.uts index 9aebfe4c94f..52b958f31c9 100644 --- a/test/scapy/layers/dhcp6.uts +++ b/test/scapy/layers/dhcp6.uts @@ -86,8 +86,7 @@ a=DUID_UUID() raw(DUID_UUID()) == b"\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" = DUID_UUID build with specific values -raw(DUID_UUID(uuid="272adcca-138c-4e8d-b3f4-634e953128cf")) == \ - b"\x00\x04'*\xdc\xca\x13\x8cN\x8d\xb3\xf4cN\x951(\xcf" +raw(DUID_UUID(uuid="272adcca-138c-4e8d-b3f4-634e953128cf")) == b"\x00\x04'*\xdc\xca\x13\x8cN\x8d\xb3\xf4cN\x951(\xcf" = DUID_UUID basic dissection a=DUID_UUID(raw(DUID_UUID())) diff --git a/test/scapy/layers/ipsec.uts b/test/scapy/layers/ipsec.uts index 39697a40eca..19ff30329e1 100644 --- a/test/scapy/layers/ipsec.uts +++ b/test/scapy/layers/ipsec.uts @@ -77,15 +77,14 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel enc 'cbc(des)' '0x38627974656b6579' auth digest_null '' flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x0f\x6d\x2f\x3d\x1e\xc1\x0b\xc2\xb6\x8f\xfd\x67\x39\xc0\x96\x2c' - b'\x17\x79\x88\xf6\xbc\x4d\xf7\x45\xd8\x36\x63\x86\xcd\x08\x7c\x08' - b'\x2b\xf8\xa2\x91\x18\x21\x88\xd9\x26\x00\xc5\x21\x24\xbf\x8f\xf5' - b'\x6c\x47\xb0\x3a\x8e\xdb\x75\x21\xd9\x33\x85\x5a\x15\xc6\x31\x00' - b'\x1c\xef\x3e\x12\xce\x70\xec\x8f\x48\xc7\x81\x9b\x66\xcb\xf5\x39' - b'\x91\xb3\x8e\x72\xfb\x7f\x64\x65\x6c\xf4\xa9\xf2\x5e\x63\x2f\x60', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x0f\x6d\x2f\x3d\x1e\xc1\x0b\xc2\xb6\x8f\xfd\x67\x39\xc0\x96\x2c' + b'\x17\x79\x88\xf6\xbc\x4d\xf7\x45\xd8\x36\x63\x86\xcd\x08\x7c\x08' + b'\x2b\xf8\xa2\x91\x18\x21\x88\xd9\x26\x00\xc5\x21\x24\xbf\x8f\xf5' + b'\x6c\x47\xb0\x3a\x8e\xdb\x75\x21\xd9\x33\x85\x5a\x15\xc6\x31\x00' + b'\x1c\xef\x3e\x12\xce\x70\xec\x8f\x48\xc7\x81\x9b\x66\xcb\xf5\x39' + b'\x91\xb3\x8e\x72\xfb\x7f\x64\x65\x6c\xf4\xa9\xf2\x5e\x63\x2f\x60', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -129,15 +128,14 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel enc 'cbc(des3_ede)' '0x7468726565646966666572656e743862797465736b657973' auth digest_null '' flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x36\x5c\x9b\x41\x37\xc8\x59\x1e\x39\x63\xe8\x6b\xf7\x0d\x97\x54' - b'\x13\x84\xf6\x81\x66\x19\xe7\xcb\x75\x94\xf1\x0b\x8e\xa3\xf1\xa0' - b'\x3e\x88\x51\xc4\x50\xd0\xa9\x1f\x16\x25\xc6\xbd\xe9\x0b\xdc\xae' - b'\xf8\x13\x00\xa3\x8c\x53\xee\x1c\x96\xc0\xfe\x99\x70\xab\x94\x77' - b'\xd7\xc4\xe8\xfd\x9f\x96\x28\xb8\x95\x20\x86\x7b\x19\xbc\x8f\xf5' - b'\x96\xb0\x7e\xcc\x04\x83\xae\x4d\xa3\xba\x1d\x44\xf0\xba\x2e\xcd', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x36\x5c\x9b\x41\x37\xc8\x59\x1e\x39\x63\xe8\x6b\xf7\x0d\x97\x54' + b'\x13\x84\xf6\x81\x66\x19\xe7\xcb\x75\x94\xf1\x0b\x8e\xa3\xf1\xa0' + b'\x3e\x88\x51\xc4\x50\xd0\xa9\x1f\x16\x25\xc6\xbd\xe9\x0b\xdc\xae' + b'\xf8\x13\x00\xa3\x8c\x53\xee\x1c\x96\xc0\xfe\x99\x70\xab\x94\x77' + b'\xd7\xc4\xe8\xfd\x9f\x96\x28\xb8\x95\x20\x86\x7b\x19\xbc\x8f\xf5' + b'\x96\xb0\x7e\xcc\x04\x83\xae\x4d\xa3\xba\x1d\x44\xf0\xba\x2e\xcd', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -180,16 +178,15 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel enc 'cbc(aes)' '0x7369787465656e6279746573206b6579' auth digest_null '' flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x08\x2f\x94\xe6\x53\xd8\x8e\x13\x70\xe8\xff\x61\x52\x90\x27\x3c' - b'\xf2\xb4\x1f\x75\xd2\xa0\xac\xae\x1c\xa8\x5e\x1c\x78\x21\x4c\x7f' - b'\xc3\x30\x17\x6a\x8d\xf3\xb1\xa7\xd1\xa8\x42\x01\xd6\x8d\x2d\x7e' - b'\x5d\x06\xdf\xaa\x05\x27\x42\xb1\x00\x12\xcf\xff\x64\x02\x5a\x40' - b'\xcd\xca\x1b\x91\xba\xf8\xc8\x59\xe7\xbd\x4d\x19\xb4\x8d\x39\x25' - b'\x6c\x73\xf1\x2d\xaa\xee\xe1\x0b\x71\xcd\xfc\x11\x1d\x56\xce\x60' - b'\xed\xd2\x32\x87\xd4\x90\xc3\xf5\x31\x47\x97\x69\x83\x82\x6d\x38', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x08\x2f\x94\xe6\x53\xd8\x8e\x13\x70\xe8\xff\x61\x52\x90\x27\x3c' + b'\xf2\xb4\x1f\x75\xd2\xa0\xac\xae\x1c\xa8\x5e\x1c\x78\x21\x4c\x7f' + b'\xc3\x30\x17\x6a\x8d\xf3\xb1\xa7\xd1\xa8\x42\x01\xd6\x8d\x2d\x7e' + b'\x5d\x06\xdf\xaa\x05\x27\x42\xb1\x00\x12\xcf\xff\x64\x02\x5a\x40' + b'\xcd\xca\x1b\x91\xba\xf8\xc8\x59\xe7\xbd\x4d\x19\xb4\x8d\x39\x25' + b'\x6c\x73\xf1\x2d\xaa\xee\xe1\x0b\x71\xcd\xfc\x11\x1d\x56\xce\x60' + b'\xed\xd2\x32\x87\xd4\x90\xc3\xf5\x31\x47\x97\x69\x83\x82\x6d\x38', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -232,15 +229,14 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel enc 'rfc3686(ctr(aes))' '0x3136627974656b65792b34627974656e6f6e6365' auth digest_null '' flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\xc4\xca\x09\x0f\x8b\xd3\x05\x3d\xac\x5a\x2f\x87\xca\x71\x10\x01' - b'\xa7\x95\xc9\x07\xcc\xd4\x05\x58\x65\x23\x22\x4b\x63\x9b\x1f\xef' - b'\x55\xb9\x1a\x91\x52\x76\x00\xf7\x94\x7b\x1d\xe1\x8e\x03\x2e\x85' - b'\xad\xdd\x83\x22\x8a\xc3\x88\x6e\x85\xf5\x9b\xed\xa9\x6e\xb1\xc3' - b'\x78\x00\x2f\xcd\x77\xe8\x3e\xec\x0e\x77\x94\xb2\x9b\x0f\x64\x5e' - b'\x09\x83\x03\x7d\x83\x22\x39\xbb\x94\x66\xae\x9f\xbf\x01\xda\xfb', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\xc4\xca\x09\x0f\x8b\xd3\x05\x3d\xac\x5a\x2f\x87\xca\x71\x10\x01' + b'\xa7\x95\xc9\x07\xcc\xd4\x05\x58\x65\x23\x22\x4b\x63\x9b\x1f\xef' + b'\x55\xb9\x1a\x91\x52\x76\x00\xf7\x94\x7b\x1d\xe1\x8e\x03\x2e\x85' + b'\xad\xdd\x83\x22\x8a\xc3\x88\x6e\x85\xf5\x9b\xed\xa9\x6e\xb1\xc3' + b'\x78\x00\x2f\xcd\x77\xe8\x3e\xec\x0e\x77\x94\xb2\x9b\x0f\x64\x5e' + b'\x09\x83\x03\x7d\x83\x22\x39\xbb\x94\x66\xae\x9f\xbf\x01\xda\xfb', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -283,15 +279,14 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel enc 'cbc(blowfish)' '0x7369787465656e6279746573206b6579' auth digest_null '' flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x93\x9f\x5a\x10\x55\x57\x30\xa0\xb4\x00\x72\x1e\x46\x42\x46\x20' - b'\xbc\x01\xef\xc3\x79\xcc\x3e\x55\x64\xba\x09\xc2\x6a\x5a\x5c\xb3' - b'\xcc\xb5\xd5\x87\x82\xb0\x0a\x94\x58\xfc\x50\x37\x40\xe1\x03\xd3' - b'\x4a\x09\xb2\x23\x53\x56\xa4\x45\x4c\xbb\x81\x1c\xdb\x31\xa7\x67' - b'\xbd\x38\x8e\xba\x55\xd9\x1f\xf1\x3c\xeb\x07\x4c\x02\xb0\x3e\xc5' - b'\xf6\x60\xdd\x68\xe1\xd4\xec\xee\x27\xc0\x6d\x1a\x80\xe2\xcc\x7d', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x93\x9f\x5a\x10\x55\x57\x30\xa0\xb4\x00\x72\x1e\x46\x42\x46\x20' + b'\xbc\x01\xef\xc3\x79\xcc\x3e\x55\x64\xba\x09\xc2\x6a\x5a\x5c\xb3' + b'\xcc\xb5\xd5\x87\x82\xb0\x0a\x94\x58\xfc\x50\x37\x40\xe1\x03\xd3' + b'\x4a\x09\xb2\x23\x53\x56\xa4\x45\x4c\xbb\x81\x1c\xdb\x31\xa7\x67' + b'\xbd\x38\x8e\xba\x55\xd9\x1f\xf1\x3c\xeb\x07\x4c\x02\xb0\x3e\xc5' + b'\xf6\x60\xdd\x68\xe1\xd4\xec\xee\x27\xc0\x6d\x1a\x80\xe2\xcc\x7d', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -334,15 +329,14 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel enc 'cbc(cast5)' '0x7369787465656e6279746573206b6579' auth digest_null '' flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\xcd\x4a\x46\x05\x51\x54\x73\x35\x1d\xad\x4b\x10\xc1\x15\xe2\x70' - b'\xbc\x9c\x53\x8f\x4d\x1c\x87\x1a\xc1\xb0\xdf\x80\xd1\x0c\xa4\x59' - b'\xe6\x50\xde\x46\xdb\x3f\x28\xc2\xda\x6c\x2b\x81\x5e\x7c\x7b\x4f' - b'\xbc\x8d\xc1\x6d\x4a\x2b\x04\x91\x9e\xc4\x0b\xba\x05\xba\x3b\x71' - b'\xac\xe3\x16\xcf\x7f\x00\xc5\x87\x7d\x72\x48\xe6\x5b\x43\x19\x24' - b'\xae\xa6\x2c\xcc\xad\xbf\x37\x6c\x6e\xea\x71\x67\x73\xd6\x11\x9f', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\xcd\x4a\x46\x05\x51\x54\x73\x35\x1d\xad\x4b\x10\xc1\x15\xe2\x70' + b'\xbc\x9c\x53\x8f\x4d\x1c\x87\x1a\xc1\xb0\xdf\x80\xd1\x0c\xa4\x59' + b'\xe6\x50\xde\x46\xdb\x3f\x28\xc2\xda\x6c\x2b\x81\x5e\x7c\x7b\x4f' + b'\xbc\x8d\xc1\x6d\x4a\x2b\x04\x91\x9e\xc4\x0b\xba\x05\xba\x3b\x71' + b'\xac\xe3\x16\xcf\x7f\x00\xc5\x87\x7d\x72\x48\xe6\x5b\x43\x19\x24' + b'\xae\xa6\x2c\xcc\xad\xbf\x37\x6c\x6e\xea\x71\x67\x73\xd6\x11\x9f', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -1541,16 +1535,15 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel aead 'rfc4106(gcm(aes))' '0x3136627974656b65792b34627974656e6f6e6365' 128 flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x66\x00\x28\x86\xe9\xdf\xc5\x24\xb0\xbd\xfd\x62\x61\x7e\xd3\x76' - b'\x7b\x48\x28\x8e\x76\xaa\xea\x48\xb8\x40\x30\x8a\xce\x50\x71\xbb' - b'\xc0\xb2\x47\x71\xd7\xa4\xa0\xcb\x03\x68\xd3\x16\x5a\x7c\x37\x84' - b'\x87\xc7\x19\x59\xb4\x7c\x76\xe3\x48\xc0\x90\x4b\xd2\x36\x95\xc1' - b'\xb7\xa4\xb6\x7b\x89\xe6\x4f\x10\xae\xdb\x84\x47\x46\x00\xb4\x44' - b'\xe6\x6d\x16\x55\x5f\x82\x36\xa5\x49\xf7\x52\x81\x65\x90\x4d\x28' - b'\x92\xb2\xe3\xf1\xa4\x02\xd2\x37\xac\x0b\x7a\x10\xcf\x64\x46\xb9', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x66\x00\x28\x86\xe9\xdf\xc5\x24\xb0\xbd\xfd\x62\x61\x7e\xd3\x76' + b'\x7b\x48\x28\x8e\x76\xaa\xea\x48\xb8\x40\x30\x8a\xce\x50\x71\xbb' + b'\xc0\xb2\x47\x71\xd7\xa4\xa0\xcb\x03\x68\xd3\x16\x5a\x7c\x37\x84' + b'\x87\xc7\x19\x59\xb4\x7c\x76\xe3\x48\xc0\x90\x4b\xd2\x36\x95\xc1' + b'\xb7\xa4\xb6\x7b\x89\xe6\x4f\x10\xae\xdb\x84\x47\x46\x00\xb4\x44' + b'\xe6\x6d\x16\x55\x5f\x82\x36\xa5\x49\xf7\x52\x81\x65\x90\x4d\x28' + b'\x92\xb2\xe3\xf1\xa4\x02\xd2\x37\xac\x0b\x7a\x10\xcf\x64\x46\xb9', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -1593,16 +1586,15 @@ assert d[TCP] == p[TCP] # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel aead 'rfc4106(gcm(aes))' '0x3136627974656b65792b34627974656e6f6e6365' 128 flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x66\x00\x28\x86\xe9\xdf\xc5\x24\xb0\xbd\xfd\x62\x61\x7e\xd3\x76' - b'\x7b\x48\x28\x8e\x76\xaa\xea\x48\xb8\x40\x30\x8a\xce\x50\x71\xbb' - b'\xc0\xb2\x47\x71\xd7\xa4\xa0\xcb\x03\x68\xd3\x16\x5a\x7c\x37\x84' - b'\x87\xc7\x19\x59\xb4\x7c\x76\xe3\x48\xc0\x90\x4b\xd2\x36\x95\xc1' - b'\xb7\xa4\xb6\x7b\x89\xe6\x4f\x10\xae\xdb\x84\x47\x46\x00\xb4\x44' - b'\xe6\x6d\x16\x55\x5f\x82\x36\xa5\x49\xf7\x52\x81\x65\x90\x4d\x28' - b'\xfe\x4d\x22\x83\x6a\x81\x0d\x60\x94\xdb\x45\x22\x03\x92\xf6\x94', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x66\x00\x28\x86\xe9\xdf\xc5\x24\xb0\xbd\xfd\x62\x61\x7e\xd3\x76' + b'\x7b\x48\x28\x8e\x76\xaa\xea\x48\xb8\x40\x30\x8a\xce\x50\x71\xbb' + b'\xc0\xb2\x47\x71\xd7\xa4\xa0\xcb\x03\x68\xd3\x16\x5a\x7c\x37\x84' + b'\x87\xc7\x19\x59\xb4\x7c\x76\xe3\x48\xc0\x90\x4b\xd2\x36\x95\xc1' + b'\xb7\xa4\xb6\x7b\x89\xe6\x4f\x10\xae\xdb\x84\x47\x46\x00\xb4\x44' + b'\xe6\x6d\x16\x55\x5f\x82\x36\xa5\x49\xf7\x52\x81\x65\x90\x4d\x28' + b'\xfe\x4d\x22\x83\x6a\x81\x0d\x60\x94\xdb\x45\x22\x03\x92\xf6\x94', + seq=1) d_ref = sa.decrypt(ref) d_ref @@ -1718,16 +1710,15 @@ assert d[TCP] == p[TCP] # Generated with Linux 5.15.0-1034-azure #41-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 0x222 reqid 1 \ # mode tunnel aead 'rfc4543(gcm(aes))' '0x3136627974656b65792b34627974656e6f6e6365' 128 flag align4 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x54\x70\x6c\x6a\x9f\xba\xa6\x18\x45\x00\x00\x54\xbc\x53\x00\x00' - b'\x40\x01\xa9\x59\x0a\x7d\x00\x01\x0a\x7d\x00\x02\x00\x00\xad\x53' - b'\xa8\x83\x00\x01\x02\xe6\x09\x64\x00\x00\x00\x00\xd9\x0a\x06\x00' - b'\x00\x00\x00\x00\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b' - b'\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b' - b'\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x01\x02\x02\x04' - b'\x9b\x76\x32\x30\xf6\x49\x92\xa8\x8f\x6a\x20\x87\x2c\x74\x0c\x18', - seq=22) +ref = IP() / ESP(spi=0x222, + data=b'\x54\x70\x6c\x6a\x9f\xba\xa6\x18\x45\x00\x00\x54\xbc\x53\x00\x00' + b'\x40\x01\xa9\x59\x0a\x7d\x00\x01\x0a\x7d\x00\x02\x00\x00\xad\x53' + b'\xa8\x83\x00\x01\x02\xe6\x09\x64\x00\x00\x00\x00\xd9\x0a\x06\x00' + b'\x00\x00\x00\x00\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b' + b'\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b' + b'\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x01\x02\x02\x04' + b'\x9b\x76\x32\x30\xf6\x49\x92\xa8\x8f\x6a\x20\x87\x2c\x74\x0c\x18', + seq=22) d_ref = sa.decrypt(ref) d_ref @@ -1770,16 +1761,15 @@ assert d[TCP] == p[TCP] # Generated with Linux 5.15.0-1034-azure #41-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 0x222 reqid 1 replay-oseq-hi 0x1 \ # mode tunnel aead 'rfc4543(gcm(aes))' '0x3136627974656b65792b34627974656e6f6e6365' 128 flag align4 esn -ref = IP() \ - / ESP(spi=0x222, - data=b'\x43\xe6\xa1\xce\x70\x9d\x67\xf4\x45\x00\x00\x54\x2e\x4a\x40\x00' - b'\x40\x01\xf7\x62\x0a\x7d\x00\x02\x0a\x7d\x00\x01\x08\x00\xd3\x32' - b'\x8f\x4c\x00\x02\x8d\xec\x09\x64\x00\x00\x00\x00\x3c\x5b\x03\x00' - b'\x00\x00\x00\x00\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b' - b'\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b' - b'\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x01\x02\x02\x04' - b'\x76\xd4\x93\x90\x75\xee\x3f\xa3\xf3\xcf\xcc\x27\xf5\x5b\x12\xb6', - seq=5) +ref = IP() / ESP(spi=0x222, + data=b'\x43\xe6\xa1\xce\x70\x9d\x67\xf4\x45\x00\x00\x54\x2e\x4a\x40\x00' + b'\x40\x01\xf7\x62\x0a\x7d\x00\x02\x0a\x7d\x00\x01\x08\x00\xd3\x32' + b'\x8f\x4c\x00\x02\x8d\xec\x09\x64\x00\x00\x00\x00\x3c\x5b\x03\x00' + b'\x00\x00\x00\x00\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b' + b'\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b' + b'\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x01\x02\x02\x04' + b'\x76\xd4\x93\x90\x75\xee\x3f\xa3\xf3\xcf\xcc\x27\xf5\x5b\x12\xb6', + seq=5) d_ref = sa.decrypt(ref) d_ref @@ -1898,16 +1888,15 @@ assert d == p # Generated with Linux 4.4.0-62-generic #83-Ubuntu # ip xfrm state add src 10.125.0.2 dst 10.125.0.1 proto esp spi 546 reqid 1 \ # mode tunnel aead 'rfc4309(ccm(aes))' '0x3136627974656b657933627974656e6f6e6365' 64 -ref = IP() \ - / ESP(spi=0x222, - data=b'\x2e\x02\x9f\x1f\xad\x76\x80\x58\x8f\xeb\x45\xf1\x66\xe3\xad\xa6' - b'\x90\x1b\x2b\x7d\xd3\x3d\xa4\x53\x35\xc8\xfa\x92\xfd\xd7\x42\x2f' - b'\x87\x60\x9b\x46\xb0\x21\x5e\x82\xfb\x2f\x59\xba\xf0\x6c\xe5\x51' - b'\xb8\x36\x20\x88\xfe\x49\x86\x60\xe8\x0a\x3d\x36\xb5\x8a\x08\xa9' - b'\x5e\xe3\x87\xfa\x93\x3f\xe8\xc2\xc5\xbf\xb1\x2e\x6f\x7d\xc5\xa5' - b'\xd8\xe5\xf3\x25\x21\x81\x43\x16\x48\x10\x7c\x04\x31\x20\x07\x7c' - b'\x7b\xda\x5d\x1a\x72\x45\xc4\x79', - seq=1) +ref = IP() / ESP(spi=0x222, + data=b'\x2e\x02\x9f\x1f\xad\x76\x80\x58\x8f\xeb\x45\xf1\x66\xe3\xad\xa6' + b'\x90\x1b\x2b\x7d\xd3\x3d\xa4\x53\x35\xc8\xfa\x92\xfd\xd7\x42\x2f' + b'\x87\x60\x9b\x46\xb0\x21\x5e\x82\xfb\x2f\x59\xba\xf0\x6c\xe5\x51' + b'\xb8\x36\x20\x88\xfe\x49\x86\x60\xe8\x0a\x3d\x36\xb5\x8a\x08\xa9' + b'\x5e\xe3\x87\xfa\x93\x3f\xe8\xc2\xc5\xbf\xb1\x2e\x6f\x7d\xc5\xa5' + b'\xd8\xe5\xf3\x25\x21\x81\x43\x16\x48\x10\x7c\x04\x31\x20\x07\x7c' + b'\x7b\xda\x5d\x1a\x72\x45\xc4\x79', + seq=1) d_ref = sa.decrypt(ref) d_ref diff --git a/test/scapy/layers/l2.uts b/test/scapy/layers/l2.uts index d4d5185670d..8bbf3d4cea4 100644 --- a/test/scapy/layers/l2.uts +++ b/test/scapy/layers/l2.uts @@ -77,9 +77,9 @@ def sendp_spoof(x, *args, **kwargs): assert x[1].pdst == "192.168.0.2" import mock -with mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), \ - mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), \ - mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof): +with (mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), + mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), + mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof)): arp_mitm( "192.168.0.1", "192.168.0.2", @@ -124,9 +124,10 @@ def sendp_spoof(x, *args, **kwargs): pass import mock -with mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), \ - mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), \ - mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof): + +with (mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), + mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), + mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof)): arp_mitm( "192.168.0.1", "192.168.0.2/24", diff --git a/test/scapy/layers/lltd.uts b/test/scapy/layers/lltd.uts index 3b5dab77487..7e5651c989b 100644 --- a/test/scapy/layers/lltd.uts +++ b/test/scapy/layers/lltd.uts @@ -30,10 +30,8 @@ assert all(isinstance(LLTDAttribute(raw(LLTDAttribute(type=i))), LLTDAttribute) = Large TLV m1, m2, seq = RandMAC()._fix(), RandMAC()._fix(), 123 -preqbase = Ether(src=m1, dst=m2) / LLTD() / \ - LLTDQueryLargeTlv(type="Detailed Icon Image") -prespbase = Ether(src=m2, dst=m1) / LLTD() / \ - LLTDQueryLargeTlvResp() +preqbase = Ether(src=m1, dst=m2) / LLTD() / LLTDQueryLargeTlv(type="Detailed Icon Image") +prespbase = Ether(src=m2, dst=m1) / LLTD() / LLTDQueryLargeTlvResp() plist = [] pkt = preqbase.copy() pkt.seq = seq diff --git a/test/scapy/layers/pptp.uts b/test/scapy/layers/pptp.uts index 880d3401b2b..f3254791a97 100644 --- a/test/scapy/layers/pptp.uts +++ b/test/scapy/layers/pptp.uts @@ -24,8 +24,7 @@ assert gre.proto == 0x800 = Test IP/GRE v1 decoding with PPP LCP ~ gre ip pptp ppp lcp -data = hex_bytes('4500003c18324000402f0e5a0a0000020a0000063001880b001c9bf500000000ff03'\ - 'c021010100180206000000000304c2270506fbb8831007020802') +data = hex_bytes('4500003c18324000402f0e5a0a0000020a0000063001880b001c9bf500000000ff03c021010100180206000000000304c2270506fbb8831007020802') pkt = IP(data) assert GRE_PPTP in pkt gre_pptp = pkt[GRE_PPTP] @@ -50,12 +49,13 @@ assert PPP_LCP_Configure in pkt = Test IP/GRE v1 encoding/decoding with PPP LCP Echo ~ gre ip pptp ppp hdlc lcp lcp_echo -pkt = IP(src='192.168.0.1', dst='192.168.0.2') /\ - GRE_PPTP(seqnum_present=1, acknum_present=1, sequence_number=47, ack_number=42) /\ - HDLC() / PPP() / PPP_LCP_Echo(id=42, magic_number=4242, data='abcdef') +pkt = IP(src='192.168.0.1', dst='192.168.0.2') / GRE_PPTP(seqnum_present=1, acknum_present=1, sequence_number=47, + ack_number=42) / HDLC() / PPP() / PPP_LCP_Echo(id=42, + magic_number=4242, + data='abcdef') pkt_data = raw(pkt) -pkt_data_ref = hex_bytes('4500003600010000402ff944c0a80001c0a800023081880b001200000000002f000000'\ - '2aff03c021092a000e00001092616263646566') +pkt_data_ref = hex_bytes( + '4500003600010000402ff944c0a80001c0a800023081880b001200000000002f0000002aff03c021092a000e00001092616263646566') assert (pkt_data == pkt_data_ref) pkt_decoded = IP(pkt_data_ref) assert IP in pkt @@ -472,12 +472,12 @@ start_control_connection = PPTPStartControlConnectionRequest(framing_capabilitie firmware_revision=47, host_name='test host name', vendor_string='test vendor string') -start_control_connection_ref_data = hex_bytes('009c00011a2b3c4d00010000010000000000000100000002002a00'\ - '2f7465737420686f7374206e616d65000000000000000000000000'\ - '000000000000000000000000000000000000000000000000000000'\ - '0000000000000000000000746573742076656e646f722073747269'\ - '6e6700000000000000000000000000000000000000000000000000'\ - '000000000000000000000000000000000000000000') +start_control_connection_ref_data = hex_bytes('009c00011a2b3c4d00010000010000000000000100000002002a00' \ + '2f7465737420686f7374206e616d65000000000000000000000000' \ + '000000000000000000000000000000000000000000000000000000' \ + '0000000000000000000000746573742076656e646f722073747269' \ + '6e6700000000000000000000000000000000000000000000000000' \ + '000000000000000000000000000000000000000000') assert raw(start_control_connection) == start_control_connection_ref_data @@ -500,12 +500,12 @@ start_control_connection_reply = PPTPStartControlConnectionReply(result_code='Ge framing_capabilities='Synchronous Framing supported', bearer_capabilities='Analog access supported', vendor_string='vendor') -start_control_connection_reply_ref_data = hex_bytes('009c00011a2b3c4d00020000010002010000000200000001ffff0'\ - '1006c696e75780000000000000000000000000000000000000000'\ - '00000000000000000000000000000000000000000000000000000'\ - '000000000000000000000000076656e646f720000000000000000'\ - '00000000000000000000000000000000000000000000000000000'\ - '00000000000000000000000000000000000000000000000') +start_control_connection_reply_ref_data = hex_bytes('009c00011a2b3c4d00020000010002010000000200000001ffff0' \ + '1006c696e75780000000000000000000000000000000000000000' \ + '00000000000000000000000000000000000000000000000000000' \ + '000000000000000000000000076656e646f720000000000000000' \ + '00000000000000000000000000000000000000000000000000000' \ + '00000000000000000000000000000000000000000000000') assert raw(start_control_connection_reply) == start_control_connection_reply_ref_data @@ -604,12 +604,12 @@ outgoing_call = PPTPOutgoingCallRequest(call_id=4242, call_serial_number=47, pkt_window_size=16, pkt_proc_delay=1, phone_number_len=9, phone_number='123456789', subaddress='test') -outgoing_call_ref_data = hex_bytes('00a800011a2b3c4d000700001092002f000003e8000027100000000200'\ - '0000030010000100090000313233343536373839000000000000000000'\ - '0000000000000000000000000000000000000000000000000000000000'\ - '0000000000000000000000000000000000746573740000000000000000'\ - '0000000000000000000000000000000000000000000000000000000000'\ - '0000000000000000000000000000000000000000000000') +outgoing_call_ref_data = hex_bytes('00a800011a2b3c4d000700001092002f000003e8000027100000000200' \ + '0000030010000100090000313233343536373839000000000000000000' \ + '0000000000000000000000000000000000000000000000000000000000' \ + '0000000000000000000000000000000000746573740000000000000000' \ + '0000000000000000000000000000000000000000000000000000000000' \ + '0000000000000000000000000000000000000000000000') assert raw(outgoing_call) == outgoing_call_ref_data @@ -670,12 +670,12 @@ incoming_call = PPTPIncomingCallRequest(call_id=4242, call_serial_number=47, bea channel_id=12, dialed_number_len=9, dialing_number_len=10, dialed_number='123456789', dialing_number='0123456789', subaddress='test') -incoming_call_ref_data = hex_bytes('00dc00011a2b3c4d000900001092002f000000020000000c0009000a313233343536373839'\ - '00000000000000000000000000000000000000000000000000000000000000000000000000'\ - '00000000000000000000000000000000000030313233343536373839000000000000000000'\ - '00000000000000000000000000000000000000000000000000000000000000000000000000'\ - '00000000000000007465737400000000000000000000000000000000000000000000000000'\ - '0000000000000000000000000000000000000000000000000000000000000000000000') +incoming_call_ref_data = hex_bytes('00dc00011a2b3c4d000900001092002f000000020000000c0009000a313233343536373839' \ + '00000000000000000000000000000000000000000000000000000000000000000000000000' \ + '00000000000000000000000000000000000030313233343536373839000000000000000000' \ + '00000000000000000000000000000000000000000000000000000000000000000000000000' \ + '00000000000000007465737400000000000000000000000000000000000000000000000000' \ + '0000000000000000000000000000000000000000000000000000000000000000000000') assert raw(incoming_call) == incoming_call_ref_data @@ -765,11 +765,11 @@ assert call_clear_request_pkt.call_id == 4242 ~ pptp call_disconnect_notify = PPTPCallDisconnectNotify(call_id=4242, result_code='Admin Shutdown', error_code='None', cause_code=47, call_statistic='some description') -call_disconnect_notify_ref_data = hex_bytes('009400011a2b3c4d000d000010920300002f0000736f6d65206465736372697074696'\ - 'f6e000000000000000000000000000000000000000000000000000000000000000000'\ - '000000000000000000000000000000000000000000000000000000000000000000000'\ - '000000000000000000000000000000000000000000000000000000000000000000000'\ - '00000000000000000000') +call_disconnect_notify_ref_data = hex_bytes('009400011a2b3c4d000d000010920300002f0000736f6d65206465736372697074696' \ + 'f6e000000000000000000000000000000000000000000000000000000000000000000' \ + '000000000000000000000000000000000000000000000000000000000000000000000' \ + '000000000000000000000000000000000000000000000000000000000000000000000' \ + '00000000000000000000') assert raw(call_disconnect_notify) == call_disconnect_notify_ref_data From f752b39af9be8f5cbdbaa80c6041b69b8c2d8af3 Mon Sep 17 00:00:00 2001 From: Nils Weiss Date: Wed, 11 Oct 2023 10:04:15 +0200 Subject: [PATCH 2/3] fix unit test --- test/scapy/layers/l2.uts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/scapy/layers/l2.uts b/test/scapy/layers/l2.uts index 8bbf3d4cea4..5b86228d04f 100644 --- a/test/scapy/layers/l2.uts +++ b/test/scapy/layers/l2.uts @@ -77,9 +77,7 @@ def sendp_spoof(x, *args, **kwargs): assert x[1].pdst == "192.168.0.2" import mock -with (mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), - mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), - mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof)): +with mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof): arp_mitm( "192.168.0.1", "192.168.0.2", @@ -125,9 +123,7 @@ def sendp_spoof(x, *args, **kwargs): import mock -with (mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), - mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), - mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof)): +with mock.patch('scapy.layers.l2.srp', side_effect=srp_spoof), mock.patch('scapy.layers.l2.srploop', side_effect=srploop_spoof), mock.patch('scapy.layers.l2.sendp', side_effect=sendp_spoof): arp_mitm( "192.168.0.1", "192.168.0.2/24", From dae8123262b5b514456275edca6ef842ea53df42 Mon Sep 17 00:00:00 2001 From: Nils Weiss Date: Wed, 11 Oct 2023 10:06:33 +0200 Subject: [PATCH 3/3] fix unit test --- test/contrib/cansocket.uts | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/test/contrib/cansocket.uts b/test/contrib/cansocket.uts index b3f7b930da5..34dafe8f050 100644 --- a/test/contrib/cansocket.uts +++ b/test/contrib/cansocket.uts @@ -55,8 +55,7 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') = NativeCANSocket send recv small packet test with -with (NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=1,data=b'\x01')) rx = sock1.recv() @@ -76,8 +75,7 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') = PythonCANSocket send recv small packet test with -with (PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=1,data=b'\x01')) rx = sock1.recv() @@ -87,8 +85,7 @@ assert rx == CAN(identifier=0x7ff,length=1,data=b'\x01') conf.contribs['CAN']['swap-bytes'] = True -with (NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with NativeCANSocket(bustype='socketcan', channel='vcan0') as sock1, NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) rx = sock1.sniff(count=1, timeout=1) assert len(rx) == 1 @@ -100,8 +97,7 @@ conf.contribs['CAN']['swap-bytes'] = False conf.contribs['CAN']['swap-bytes'] = True -with (PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with PythonCANSocket(bustype='socketcan', channel='vcan0') as sock1, PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: sock2.send(CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08')) rx = sock1.sniff(count=1, timeout=1) assert rx[0] == CAN(identifier=0x7ff,length=8,data=b'\x01\x02\x03\x04\x05\x06\x07\x08') @@ -117,8 +113,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x100, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with (NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=3) @@ -133,8 +128,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x100, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with (PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, - PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}]) as sock1, PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=3) @@ -150,8 +144,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x700, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x7ff, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with (NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, - NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with NativeCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, NativeCANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -167,8 +160,7 @@ msgs = [CAN(identifier=0x200, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08' CAN(identifier=0x700, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08'), CAN(identifier=0x7ff, length=8, data=b'\x01\x02\x03\x04\x05\x06\x07\x08')] -with (PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, - ythonCANSocket(bustype='socketcan', channel='vcan0') as sock2): +with PythonCANSocket(bustype='socketcan', channel='vcan0', can_filters=[{'can_id': 0x200, 'can_mask': 0x7ff}, {'can_id': 0x400, 'can_mask': 0x7ff}, {'can_id': 0x600, 'can_mask': 0x7ff}, {'can_id': 0x7ff, 'can_mask': 0x7ff}]) as sock1, PythonCANSocket(bustype='socketcan', channel='vcan0') as sock2: for m in msgs: sock2.send(m) packets = sock1.sniff(timeout=0.1, count=4) @@ -199,8 +191,7 @@ def bridge(): return pkt bSock0.timeout = 0.01 bSock1.timeout = 0.01 - bridge_and_sniff(if1=bSock0, if2=bSock1, xfrm12=pnr, xfrm21=pnr, timeout=0.5, started_callback=bridgeStarted.set, - count=6) + bridge_and_sniff(if1=bSock0, if2=bSock1, xfrm12=pnr, xfrm21=pnr, timeout=0.5, started_callback=bridgeStarted.set, count=6) bSock0.close() bSock1.close()