From ac28130c76d93329c0019f4a420166164c02e916 Mon Sep 17 00:00:00 2001 From: Zach Chadwick Date: Tue, 28 Feb 2023 15:16:26 -0500 Subject: Sharkd: show RTP ssrc as hex and improve errors The token format used by rtp-analyse and rtp-download expect the SSRC field to be a hex string parsable by `ws_hexstrtou32()` as seen in sharkd_session.c:760. The output from tap:rtp-streams was displaying it as an unsigned integer. For consistency, this field is now displayed as a hex string in the output. If the call to download an RTP stream did not match any payloads, Sharkd would not return any information at all. This now returns an error message indicating that there is no RTP data available. Adds three new selftests and sample pcap. --- test/captures/sip-rtp.pcapng | Bin 0 -> 144300 bytes test/suite_sharkd.py | 70 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/captures/sip-rtp.pcapng (limited to 'test') diff --git a/test/captures/sip-rtp.pcapng b/test/captures/sip-rtp.pcapng new file mode 100644 index 0000000000..5ea96eef1b Binary files /dev/null and b/test/captures/sip-rtp.pcapng differ diff --git a/test/suite_sharkd.py b/test/suite_sharkd.py index 93b263dd50..8c21e9a57e 100644 --- a/test/suite_sharkd.py +++ b/test/suite_sharkd.py @@ -261,6 +261,55 @@ class case_sharkd(subprocesstest.SubprocessTestCase): }}, )) + def test_sharkd_req_tap_rtp_streams(self, check_sharkd_session, capture_file): + check_sharkd_session(( + {"jsonrpc":"2.0", "id":1, "method":"load", + "params":{"file": capture_file('sip-rtp.pcapng')} + }, + {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "rtp-streams"}}, + {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "rtp-analyse:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e"}}, + ), ( + {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}}, + {"jsonrpc":"2.0","id":2,"result":{ + "taps":[{ + "tap":"rtp-streams", + "type":"rtp-streams", + "streams":[{ + "ssrc":"0xd2bd4e3e", + "payload":"g711A", + "saddr":"200.57.7.204", + "sport":8000, + "daddr":"200.57.7.196", + "dport":40376, + "pkts":548, + "max_delta":5843.742000, + "max_jitter":7.406751, + "mean_jitter":2.517173, + "expectednr":548, + "totalnr":548, + "problem":False, + "ipver":4 + }] + }] + }}, + {"jsonrpc":"2.0","id":2,"result": + {"taps":[{ + "tap":"rtp-analyse:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e", + "type":"rtp-analyse", + "ssrc":"0xd2bd4e3e", + "max_delta":5843.742000, + "max_delta_nr":168, + "max_jitter":7.406751, + "mean_jitter":2.517173, + "max_skew":319.289000, + "total_nr":548, + "seq_err":0, + "duration":24124.055000, + "items": MatchAny() + }] + }}, + )) + def test_sharkd_req_follow_bad(self, check_sharkd_session, capture_file): # Unrecognized taps currently produce no output (not even err). check_sharkd_session(( @@ -486,7 +535,7 @@ class case_sharkd(subprocesstest.SubprocessTestCase): )) def test_sharkd_req_download_tls_secrets(self, check_sharkd_session, capture_file): - # XXX test download for eo: and rtp: too + # XXX test download for eo: too check_sharkd_session(( {"jsonrpc":"2.0", "id":1, "method":"load", "params":{"file": capture_file('tls12-dsb.pcapng')} @@ -502,6 +551,25 @@ class case_sharkd(subprocesstest.SubprocessTestCase): }, )) + def test_sharkd_req_download_rtp_stream(self, check_sharkd_session, capture_file): + check_sharkd_session(( + {"jsonrpc":"2.0", "id":1, "method":"load", + "params":{"file": capture_file('sip-rtp.pcapng')} + }, + {"jsonrpc":"2.0", "id":2, "method":"download", + "params":{"token": "rtp:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e"}}, + {"jsonrpc":"2.0", "id":3, "method":"download", + "params":{"token": "rtp:1.1.1.1_8000_1.1.1.2_9000_0xdddddddd"}}, + ), ( + {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}}, + {"jsonrpc":"2.0","id":2,"result":{ + "file":"rtp:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e", + "mime":"audio/x-wav", + "data":MatchRegExp(r'UklGRv.+')} + }, + {"jsonrpc":"2.0","id":3,"error":{"code":-10003,"message":"no rtp data available"}}, + )) + def test_sharkd_req_bye(self, check_sharkd_session): check_sharkd_session(( {"jsonrpc":"2.0", "id":1, "method":"bye"}, -- cgit v1.2.3