Address code-review nits for BAD_FCS support
- decode.py: use the GSMTAP_FLAG_BAD_FCS constant instead of a literal 0x01 in gsmtap_flag_names() (import from ..gsmtap); no behavior change. - tests: add a DB round-trip test (insert_message with BAD_FCS flag → get_messages → decoded.errors) covering the end-to-end path, not just the direct decode_sniff_msg call.
This commit is contained in:
1 parent
66094a0114
commit
79acb3773f
2 files changed
+17
-1
No files matched your search
@@ -4,6 +4,8 @@ Pure Python, no dependencies. Decodes raw TPDU bytes captured by
|
||||
the SIMtrace2 sniffer into structured dicts for the PWA to display.
|
||||
"""
|
||||
|
||||
from ..gsmtap import GSMTAP_FLAG_BAD_FCS
|
||||
|
||||
# ──────────────────── Status Word names ────────────────────
|
||||
|
||||
SW_NAMES = {
|
||||
@@ -4038,7 +4040,7 @@ def gsmtap_flag_names(flags):
|
||||
desynced TPDU (mis-framed exchange / implausible status word).
|
||||
"""
|
||||
names = []
|
||||
if flags & 0x01:
|
||||
if flags & GSMTAP_FLAG_BAD_FCS:
|
||||
names.append('bad FCS (desynced)')
|
||||
return names or None
|
||||
|
||||
|
||||
@@ -1204,6 +1204,20 @@ class TestFileDecoders(unittest.TestCase):
|
||||
|
||||
|
||||
class TestSelectionTracking(unittest.TestCase):
|
||||
def test_bad_fcs_roundtrip(self):
|
||||
# GSMTAP BAD_FCS flag stored via insert_message must surface as a
|
||||
# decode error in the DB → frontend path (not just the direct call).
|
||||
import tempfile
|
||||
from simtrace2_pysniff.server.database import Database
|
||||
from simtrace2_pysniff.gsmtap import GSMTAP_FLAG_BAD_FCS
|
||||
with tempfile.NamedTemporaryFile(suffix='.db') as tmp:
|
||||
db = Database(tmp.name)
|
||||
sid = db.create_session('capture')
|
||||
db.insert_message(sid, 0.1, 'tpdu', bytes.fromhex('80f2000000'),
|
||||
GSMTAP_FLAG_BAD_FCS)
|
||||
msgs = db.get_messages(sid)
|
||||
self.assertIn('bad FCS (desynced)', msgs[0]['decoded']['errors'])
|
||||
|
||||
def test_select_then_read(self):
|
||||
import tempfile
|
||||
from simtrace2_pysniff.server.database import Database
|
||||
|
||||
Reference in new issue
Block a user