From e09aac4cb78c5e11f1b87213ce98d06fc12a4406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Wed, 12 Aug 2026 21:16:11 +0300 Subject: [PATCH] Add session export to PCAP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pcap.py: build_pcap(packets) — build PCAP bytes in memory (same format as PcapWriter) database.py: get_messages_raw() — raw elapsed/type/data without decode server.py: GET /api/sessions//pcap generates a GSMTAP-encapsulated PCAP (ATR/TPDU) with real timestamps and downloads it as .pcap (ASCII filename fallback + RFC 5987 UTF-8 for spaces/unicode via _content_disposition) tests: build_pcap + _content_disposition (67 total) --- simtrace2_pysniff/pcap.py | 34 ++++++++++++++++ simtrace2_pysniff/server/database.py | 6 +++ simtrace2_pysniff/server/server.py | 50 ++++++++++++++++++++++- tests/test_pcap.py | 60 ++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 tests/test_pcap.py diff --git a/simtrace2_pysniff/pcap.py b/simtrace2_pysniff/pcap.py index a86b260..e79f070 100644 --- a/simtrace2_pysniff/pcap.py +++ b/simtrace2_pysniff/pcap.py @@ -4,6 +4,7 @@ Writes a standard PCAP file with LINKTYPE_GSMTAP (155, 0x009b). Each packet is a GSMTAP header + raw APDU/ATR data. """ +import io import struct import time @@ -17,6 +18,39 @@ _PCAP_PKT_HDR_FMT = '