From a02b38cce8419acef874413ac448574f2e227f82 Mon Sep 17 00:00:00 2001 From: Marek Sebera Date: Sat, 12 Mar 2022 13:37:34 +0100 Subject: [PATCH] excluding USRP packets by parse, pcap extraction of single-fragment-lc and vbptc32,11, release v0.5 --- okdmr/dmrlib/tools/pcap_tool.py | 5 ++++- okdmr/dmrlib/utils/parsing.py | 6 ++++++ okdmr/tests/dmrlib/etsi/fec/test_vbptc_32_11.py | 3 +++ okdmr/tests/dmrlib/utils/test_parsing.py | 4 ++++ setup.py | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/okdmr/dmrlib/tools/pcap_tool.py b/okdmr/dmrlib/tools/pcap_tool.py index 9ec4d95..4d9a76f 100644 --- a/okdmr/dmrlib/tools/pcap_tool.py +++ b/okdmr/dmrlib/tools/pcap_tool.py @@ -7,6 +7,7 @@ from bitarray import bitarray from kaitaistruct import KaitaiStruct +from okdmr.dmrlib.etsi.fec.vbptc_32_11 import VBPTC3211 from okdmr.kaitai.homebrew.mmdvm2020 import Mmdvm2020 from okdmr.kaitai.hytera.ip_site_connect_heartbeat import IpSiteConnectHeartbeat from okdmr.kaitai.hytera.ip_site_connect_protocol import IpSiteConnectProtocol @@ -43,10 +44,12 @@ def process_packet(self, data: bytes, packet: IP) -> Optional[FullLinkControl]: burst and burst.has_emb and burst.emb.link_control_start_stop == LCSS.SingleFragmentLCorCSBK + and burst.embedded_signalling_bits.count(1) ): print( - f"Single burst data for VBPTC 32,11 [{burst.emb.preemption_and_power_control_indicator}] {burst.embedded_signalling_bits}" + f"Single burst data for VBPTC 32,11 [{burst.emb.preemption_and_power_control_indicator}] on-air(fec protected) {burst.embedded_signalling_bits} (vbptc deinterleaved) {VBPTC3211.deinterleave_data_bits(burst.embedded_signalling_bits)} in {data.hex()}" ) + return if ( not burst diff --git a/okdmr/dmrlib/utils/parsing.py b/okdmr/dmrlib/utils/parsing.py index 386aa20..48b9bbc 100644 --- a/okdmr/dmrlib/utils/parsing.py +++ b/okdmr/dmrlib/utils/parsing.py @@ -48,6 +48,12 @@ def parse_hytera_data(bytedata: bytes) -> KaitaiStruct: def try_parse_packet(udpdata: bytes) -> Optional[KaitaiStruct]: + try: + if udpdata[:4] == b"USRP": + return None + finally: + pass + # Try MMDVM/Homebrew packets try: mmdvm = Mmdvm2020.from_bytes(udpdata) diff --git a/okdmr/tests/dmrlib/etsi/fec/test_vbptc_32_11.py b/okdmr/tests/dmrlib/etsi/fec/test_vbptc_32_11.py index 42153c8..0b4cf6b 100644 --- a/okdmr/tests/dmrlib/etsi/fec/test_vbptc_32_11.py +++ b/okdmr/tests/dmrlib/etsi/fec/test_vbptc_32_11.py @@ -15,6 +15,9 @@ def test_vbptc_sanity(): def test_encode_decode_vbptc(): bursts: List[(str,)] = [ ("00000100010110000000100010100100",), + # following are not valid vbptc protected payloads, probably something proprietary / unidentified + # ("00001100000100010010010001000001",), + # ("00010111000010100000011001000100",), ] for (burst,) in bursts: diff --git a/okdmr/tests/dmrlib/utils/test_parsing.py b/okdmr/tests/dmrlib/utils/test_parsing.py index 7c91ef9..c580bf5 100644 --- a/okdmr/tests/dmrlib/utils/test_parsing.py +++ b/okdmr/tests/dmrlib/utils/test_parsing.py @@ -53,3 +53,7 @@ def test_parsing_detection(): mmdvm_hex: str = "52505443002338c84f4b314c5044202034333331303030303034333331303030303030313031302e30303030303030302e3030303030303030304e6f7768657265202020202020202020202020204d756c74692d4d6f6465205265706561746572347777772e676f6f676c652e636f2e756b202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020323031393031333120202020202020202020202020202020202020202020202020202020202020204d4d44564d5f4d4d44564d5f48535f48617420202020202020202020202020202020202020202020" pkt: KaitaiStruct = try_parse_packet(bytes.fromhex(mmdvm_hex)) assert isinstance(pkt, Mmdvm2020) + + usrp_hex: str = "55535250000000730000000000000001000000000000000000000000000000001e00faffe2ffeeff00000c0012000c00e2ffcaffe2ff0c0048008400b400a2005a00060094ff3aff2eff4cff7cffd6ff1e00420066007e005a002a001800e2ffc4ffbeffacff9affa0ffcaff1200540084007e003600eeffbeffb2ffd6fffaff0c0012000600eefff4fffaff12003c003c001800f4ffd6ffc4ffdcff0c002a002a001e000000e2ffe8fffaff12002a001e00f4ffdcffcaffcaff00004e0084009c009c005a001200d0ff88ff58ff58ff64ff88ffd0ff240060006c0072005a0030001800eeffc4ffa6ff88ff82ffa6ffdcff12003c0054005400360018000600faffeeffe2ffe8ffe8ffeefffaff060006000c00180024001e0018000000eefff4ffeeff000018000c00faff06000600faff0c000c00faff06000000e8ffe8fffaff0c003c009000b40096004e00e2ff6aff2eff4cff7cffb8ffeeff00001200" + pkt: Optional[KaitaiStruct] = try_parse_packet(bytes.fromhex(usrp_hex)) + assert pkt is None diff --git a/setup.py b/setup.py index ac36f4f..5d022de 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ author="Marek Sebera", author_email="marek.sebera@gmail.com", license="AGPL-3.0", - version="0.4", + version="0.5", packages=[ "okdmr.dmrlib", "okdmr.dmrlib.transmission",