3 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>
7 # SPDX-License-Identifier: GPL-2.0-or-later
14 from matchers
import *
17 @pytest.fixture(scope
='session')
18 def cmd_sharkd(program
):
19 return program('sharkd')
23 def run_sharkd_session(cmd_sharkd
, base_env
):
24 def run_sharkd_session_real(sharkd_commands
):
25 sharkd_proc
= subprocess
.Popen(
26 (cmd_sharkd
, '-'), stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, encoding
='utf-8', env
=base_env
)
27 sharkd_proc
.stdin
.write('\n'.join(sharkd_commands
))
28 stdout
, stderr
= sharkd_proc
.communicate()
30 assert 'Hello in child.' in stderr
33 for line
in stdout
.splitlines():
38 jdata
= json
.loads(line
)
39 except json
.JSONDecodeError
:
40 pytest
.fail('Invalid JSON: %r' % line
)
43 return run_sharkd_session_real
47 def check_sharkd_session(run_sharkd_session
):
48 def check_sharkd_session_real(sharkd_commands
, expected_outputs
):
49 sharkd_commands
= [json
.dumps(x
) for x
in sharkd_commands
]
50 actual_outputs
= run_sharkd_session(sharkd_commands
)
51 assert expected_outputs
== actual_outputs
52 return check_sharkd_session_real
56 def test_sharkd_req_load_bad_pcap(self
, check_sharkd_session
, capture_file
):
57 check_sharkd_session((
58 {"jsonrpc":"2.0", "id":1, "method":"load",
59 "params":{"file": capture_file('non-existant.pcap')}
62 {"jsonrpc":"2.0","id":1,"error":{"code":-2001,"message":"Unable to open the file"}},
65 def test_sharkd_req_load_truncated_pcap(self
, check_sharkd_session
, capture_file
):
66 check_sharkd_session((
67 {"jsonrpc":"2.0", "id":1, "method":"load",
68 "params":{"file": capture_file('trunc.pcap')}
71 {"jsonrpc":"2.0","id":1,"result":{"status":"Less data was read than was expected","err":-12}},
74 def test_sharkd_req_status_no_pcap(self
, check_sharkd_session
):
75 check_sharkd_session((
76 {"jsonrpc":"2.0", "id":1, "method":"status"},
78 {"jsonrpc":"2.0","id":1,"result":{"frames":0,"duration":0.000000000,"columns":["No.","Time","Source","Destination","Protocol","Length","Info"],
80 "title":"No.","format": "%m","visible":True, "display": "R"
82 "title": "Time", "format": "%t", "visible":True, "display": "R"
84 "title": "Source", "format": "%s", "visible":True, "display": "R"
86 "title": "Destination", "format": "%d", "visible":True, "display": "R"
88 "title": "Protocol", "format": "%p", "visible":True, "display": "R"
90 "title": "Length", "format": "%L", "visible":True, "display": "R"
92 "title": "Info", "format": "%i", "visible":True, "display": "R"
97 def test_sharkd_req_status(self
, check_sharkd_session
, capture_file
):
98 check_sharkd_session((
99 {"jsonrpc":"2.0", "id":1, "method":"load",
100 "params":{"file": capture_file('dhcp.pcap')}
102 {"jsonrpc":"2.0", "id":2, "method":"status"},
104 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
105 {"jsonrpc":"2.0","id":2,"result":{"frames": 4, "duration": 0.070345000,
106 "filename": "dhcp.pcap", "filesize": 1400,
107 "columns":["No.","Time","Source","Destination","Protocol","Length","Info"],
109 "title":"No.","format": "%m","visible":True, "display": "R"
111 "title": "Time", "format": "%t", "visible":True, "display": "R"
113 "title": "Source", "format": "%s", "visible":True, "display": "R"
115 "title": "Destination", "format": "%d", "visible":True, "display": "R"
117 "title": "Protocol", "format": "%p", "visible":True, "display": "R"
119 "title": "Length", "format": "%L", "visible":True, "display": "R"
121 "title": "Info", "format": "%i", "visible":True, "display": "R"
126 def test_sharkd_req_analyse(self
, check_sharkd_session
, capture_file
):
127 check_sharkd_session((
128 {"jsonrpc":"2.0", "id":1, "method":"load",
129 "params":{"file": capture_file('dhcp.pcap')}
131 {"jsonrpc":"2.0", "id":2, "method":"analyse"},
133 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
134 {"jsonrpc":"2.0","id":2,"result":{"frames": 4, "protocols": ["frame", "eth", "ethertype", "ip", "udp",
135 "dhcp"], "first": 1102274184.317452908, "last": 1102274184.387798071}},
138 def test_sharkd_req_info(self
, check_sharkd_session
):
139 matchTapNameList
= MatchList(
140 {"tap": MatchAny(str), "name": MatchAny(str)})
141 matchNameDescriptionList
= MatchList(
142 {"name": MatchAny(str), "description": MatchAny(str)})
143 check_sharkd_session((
144 {"jsonrpc":"2.0", "id":1, "method":"info"},
146 {"jsonrpc":"2.0","id":1,"result":{
147 "version": MatchAny(str),
148 "columns": MatchList({"format": MatchAny(str), "name": MatchAny(str)}),
149 "stats": matchTapNameList
,
150 "convs": matchTapNameList
,
151 "eo": matchTapNameList
,
152 "srt": matchTapNameList
,
153 "rtd": matchTapNameList
,
154 "seqa": matchTapNameList
,
155 "taps": matchTapNameList
,
156 "follow": matchTapNameList
,
157 "ftypes": MatchList(MatchAny(str)),
158 "capture_types": matchNameDescriptionList
,
159 "encap_types": matchNameDescriptionList
,
160 "nstat": matchTapNameList
,
164 def test_sharkd_req_check(self
, check_sharkd_session
, capture_file
):
165 check_sharkd_session((
166 {"jsonrpc":"2.0", "id":1, "method":"load",
167 "params":{"file": capture_file('dhcp.pcap')}
169 {"jsonrpc":"2.0", "id":2, "method":"check"},
170 {"jsonrpc":"2.0", "id":3, "method":"check", "params":{"filter": "garbage filter"}},
171 {"jsonrpc":"2.0", "id":4, "method":"check", "params":{"field": "garbage field"}},
172 {"jsonrpc":"2.0", "id":5, "method":"check", "params":{"filter": "ip", "field": "ip"}},
174 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
175 {"jsonrpc":"2.0","id":2,"result":{"status":"OK"}},
176 {"jsonrpc":"2.0","id":3,"error":{"code":-5001,"message":"Filter invalid - \"filter\" was unexpected in this context."}},
177 {"jsonrpc":"2.0","id":4,"error":{"code":-5002,"message":"Field garbage field not found"}},
178 {"jsonrpc":"2.0","id":5,"result":{"status":"OK"}},
181 def test_sharkd_req_complete_field(self
, check_sharkd_session
):
182 check_sharkd_session((
183 {"jsonrpc":"2.0", "id":1, "method":"complete"},
184 {"jsonrpc":"2.0", "id":2, "method":"complete", "params":{"field": "frame.le"}},
185 {"jsonrpc":"2.0", "id":3, "method":"complete", "params":{"field": "garbage.nothing.matches"}},
187 {"jsonrpc":"2.0","id":1,"result":{}},
188 {"jsonrpc":"2.0","id":2,"result":{"field": MatchList(
189 {"f": "frame.len", "t": 7, "n": "Frame Length"}, match_element
=any
)}
191 {"jsonrpc":"2.0","id":3,"result":{"field": []}},
194 def test_sharkd_req_complete_pref(self
, check_sharkd_session
):
195 check_sharkd_session((
196 {"jsonrpc":"2.0", "id":1, "method":"complete", "params":{"pref": "tcp."}},
197 {"jsonrpc":"2.0", "id":2, "method":"complete", "params":{"pref": "garbage.nothing.matches"}},
199 {"jsonrpc":"2.0","id":1,"result":{"pref": MatchList(
200 {"f": "tcp.check_checksum", "d": "Validate the TCP checksum if possible"}, match_element
=any
)}
202 {"jsonrpc":"2.0","id":2,"result":{"pref": []}},
205 def test_sharkd_req_frames(self
, check_sharkd_session
, capture_file
):
206 # XXX need test for optional input parameters, ignored/marked/commented
207 check_sharkd_session((
208 {"jsonrpc":"2.0", "id":1, "method":"load",
209 "params":{"file": capture_file('dhcp.pcap')}
211 {"jsonrpc":"2.0", "id":2, "method":"frames"},
213 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
214 {"jsonrpc":"2.0","id":2,"result":
216 "c": MatchList(MatchAny(str)),
217 "num": MatchAny(int),
224 def test_sharkd_req_frames_delta_times(self
, check_sharkd_session
, capture_file
):
225 check_sharkd_session((
226 {"jsonrpc":"2.0", "id":1, "method":"load",
227 "params":{"file": capture_file('logistics_multicast.pcapng')}
229 {"jsonrpc":"2.0", "id":2, "method":"frames","params":{"filter":"frame.number==1||frame.number==800","column0":"frame.time_relative:1","column1":"frame.time_delta:1","column2":"frame.time_delta_displayed:1"}},
231 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
232 {"jsonrpc":"2.0","id":2,"result":
234 {"c":["0.000000000","0.000000000","0.000000000"],"num":1,"bg":"feffd0","fg":"12272e"},
235 {"c":["191.872111000","0.193716000","191.872111000"],"num":800,"bg":"feffd0","fg":"12272e"},
240 def test_sharkd_req_frames_comments(self
, check_sharkd_session
, capture_file
):
241 check_sharkd_session((
242 {"jsonrpc":"2.0", "id":1, "method":"load",
243 "params":{"file": capture_file('comments.pcapng')}
245 {"jsonrpc":"2.0", "id":2, "method":"frames","params":{"filter":"frame.number==3||frame.number==4||frame.number==5"}},
247 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
248 {"jsonrpc":"2.0","id":2,"result":
250 {"c":["3","0.610021","::","ff02::1:ffdc:6277","ICMPv6","78","Neighbor Solicitation for fe80::c2c1:c0ff:fedc:6277"],"num":3,"ct":True,"comments":["hello hello"],"bg":"fce0ff","fg":"12272e"},
251 {"c":["4","0.760023","::","ff02::1:ffdc:6277","ICMPv6","78","Neighbor Solicitation for fec0::c2c1:c0ff:fedc:6277"],"num":4,"ct":True,"comments":["goodbye goodbye"],"bg":"fce0ff","fg":"12272e"},
252 {"c":["5","0.802338","10.0.0.1","224.0.0.251","MDNS","138","Standard query response 0x0000 A, cache flush 10.0.0.1 PTR, cache flush Cisco29401.local NSEC, cache flush Cisco29401.local"],"num":5,"bg":"daeeff","fg":"12272e"}
257 def test_sharkd_req_tap_invalid(self
, check_sharkd_session
, capture_file
):
258 # XXX Unrecognized taps result in an empty line, modify
259 # run_sharkd_session such that checking for it is possible.
260 check_sharkd_session((
261 {"jsonrpc":"2.0", "id":1, "method":"load",
262 "params":{"file": capture_file('dhcp.pcap')}
264 {"jsonrpc":"2.0", "id":2, "method":"tap"},
265 {"jsonrpc":"2.0", "id":3, "method":"tap", "params":{"tap0": "garbage tap"}},
266 {"jsonrpc":"2.0", "id":4, "method":"tap", "params":{"tap0": "conv:Ethernet", "filter": "garbage filter"}},
268 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
269 {"jsonrpc":"2.0","id":2,"error":{"code":-32600,"message":"Mandatory parameter tap0 is missing"}},
270 {"jsonrpc":"2.0","id":3,"error":{"code":-11012,"message":"sharkd_session_process_tap() garbage tap not recognized"}},
271 {"jsonrpc":"2.0","id":4,"error":{"code":-11013,"message":"sharkd_session_process_tap() name=conv:Ethernet error=Filter \"garbage filter\" is invalid - \"filter\" was unexpected in this context."}},
274 def test_sharkd_req_tap(self
, check_sharkd_session
, capture_file
):
275 check_sharkd_session((
276 {"jsonrpc":"2.0", "id":1, "method":"load",
277 "params":{"file": capture_file('dhcp.pcap')}
279 {"jsonrpc":"2.0", "id":2, "method":"tap"},
280 {"jsonrpc":"2.0", "id":3, "method":"tap", "params":{"tap0": "conv:Ethernet", "tap1": "endpt:TCP"}},
282 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
283 {"jsonrpc":"2.0","id":2,"error":{"code":-32600,"message":"Mandatory parameter tap0 is missing"}},
284 {"jsonrpc":"2.0","id":3,"result":{
290 "geoip": MatchAny(bool),
294 "tap": "conv:Ethernet",
297 "geoip": MatchAny(bool),
300 "saddr": MatchAny(str),
301 "daddr": "Broadcast",
308 "filter": "eth.addr==00:0b:82:01:fc:42 && eth.addr==ff:ff:ff:ff:ff:ff",
311 "saddr": MatchAny(str),
312 "daddr": MatchAny(str),
319 "filter": "eth.addr==00:08:74:ad:f1:9b && eth.addr==00:0b:82:01:fc:42",
327 def test_sharkd_req_tap_rtp_streams(self
, check_sharkd_session
, capture_file
):
328 check_sharkd_session((
329 {"jsonrpc":"2.0", "id":1, "method":"load",
330 "params":{"file": capture_file('sip-rtp.pcapng')}
332 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "rtp-streams"}},
333 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "rtp-analyse:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e"}},
335 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
336 {"jsonrpc":"2.0","id":2,"result":{
339 "type":"rtp-streams",
343 "saddr":"200.57.7.204",
345 "daddr":"200.57.7.196",
347 "start_time":8.479371,
348 "duration": 24.124055,
352 "max_delta":5843.742000,
354 "mean_delta":44.102477,
355 "min_jitter":0.388213,
356 "max_jitter":7.406751,
357 "mean_jitter":2.517173,
365 {"jsonrpc":"2.0","id":2,"result":
367 "tap":"rtp-analyse:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e",
368 "type":"rtp-analyse",
370 "max_delta":5843.742000,
372 "max_jitter":7.406751,
373 "mean_jitter":2.517173,
374 "max_skew":319.289000,
377 "duration":24124.055000,
383 def test_sharkd_req_tap_phs(self
, check_sharkd_session
, capture_file
):
384 check_sharkd_session((
385 {"jsonrpc":"2.0", "id":1, "method":"load",
386 "params":{"file": capture_file('protohier-with-comments.pcapng')}
388 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "phs"}},
389 {"jsonrpc":"2.0", "id":3, "method":"load",
390 "params":{"file": capture_file('protohier-without-comments.pcapng')}
392 {"jsonrpc":"2.0", "id":4, "method":"tap", "params":{"tap0": "phs"}},
393 {"jsonrpc":"2.0", "id":5, "method":"tap", "params":{"tap0": "phs", "filter": "ipv6"}},
395 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
396 {"jsonrpc":"2.0","id":2,"result":{
488 {"jsonrpc":"2.0","id":3,"result":{"status":"OK"}},
489 {"jsonrpc":"2.0","id":4,"result":{
581 {"jsonrpc": "2.0", "id": 5, "result": {
619 def test_sharkd_req_tap_voip_calls(self
, check_sharkd_session
, capture_file
):
620 check_sharkd_session((
621 {"jsonrpc":"2.0", "id":1, "method":"load",
622 "params":{"file": capture_file('sip-rtp.pcapng')}
624 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "voip-calls"}},
626 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
627 {"jsonrpc":"2.0","id":2,"result":{
633 "start_time":0.000000,
634 "stop_time":8.524137,
635 "initial_speaker":"200.57.7.195",
636 "from":"<sip:200.57.7.195:55061;user=phone>",
637 "to":"\"francisco@bestel.com\" <sip:francisco@bestel.com:55060>",
641 "comment":"INVITE 200"
644 "start_time":24.665953,
645 "stop_time":24.692752,
646 "initial_speaker":"200.57.7.195",
647 "from":"\"Ivan Alizade\" <sip:5514540002@200.57.7.195:55061;user=phone>",
648 "to":"\"francisco@bestel.com\" <sip:francisco@bestel.com:55060>",
651 "state":"CALL SETUP",
658 def test_sharkd_req_tap_voip_convs(self
, check_sharkd_session
, capture_file
):
659 check_sharkd_session((
660 {"jsonrpc":"2.0", "id":1, "method":"load",
661 "params":{"file": capture_file('sip-rtp.pcapng')}
663 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "voip-convs:"}},
664 {"jsonrpc":"2.0", "id":3, "method":"tap", "params":{"tap0": "voip-convs:0"}},
665 {"jsonrpc":"2.0", "id":4, "method":"tap", "params":{"tap0": "voip-convs:0-1"}},
666 {"jsonrpc":"2.0", "id":5, "method":"tap", "params":{"tap0": "voip-convs:garbage"}},
667 {"jsonrpc":"2.0", "id":6, "method":"tap", "params":{"tap0": "voip-convs:999"}},
668 {"jsonrpc":"2.0", "id":7, "method":"tap", "params":{"tap0": "voip-convs:0,999,0-1,999-999,1,1"}},
670 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
671 {"jsonrpc":"2.0","id":2,"result":{
679 "dst_addr":"200.57.7.204",
681 "src_addr":"200.57.7.195",
683 "label":"INVITE SDP (g711A g729 g723 g711U)",
684 "comment":"SIP INVITE From: <sip:200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12013223@200.57.7.195 CSeq:1"
689 "dst_addr":"200.57.7.195",
691 "src_addr":"200.57.7.204",
693 "label":"100 Trying",
694 "comment":"SIP Status 100 Trying"
699 "dst_addr":"200.57.7.195",
701 "src_addr":"200.57.7.204",
703 "label":"180 Ringing",
704 "comment":"SIP Status 180 Ringing"
709 "dst_addr":"200.57.7.195",
711 "src_addr":"200.57.7.204",
713 "label":"200 Ok SDP (g711A g711U GSM iLBC speex telephone-event)",
714 "comment":"SIP Status 200 Ok"
719 "dst_addr":"200.57.7.196",
721 "src_addr":"200.57.7.204",
723 "label":"RTP (g711A) ",
724 "comment":"RTP, 548 packets. Duration: 24.12s SSRC: 0xD2BD4E3E"
729 "dst_addr":"200.57.7.204",
731 "src_addr":"200.57.7.195",
734 "comment":"SIP Request INVITE ACK 200 CSeq:1"
739 "dst_addr":"200.57.7.204",
741 "src_addr":"200.57.7.195",
743 "label":"INVITE SDP (g711A g729 g723)",
744 "comment":"SIP INVITE From: \"Ivan Alizade\" <sip:5514540002@200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12015624@200.57.7.195 CSeq:1"
749 "dst_addr":"200.57.7.195",
751 "src_addr":"200.57.7.204",
753 "label":"100 Trying",
754 "comment":"SIP Status 100 Trying"
759 "dst_addr":"200.57.7.195",
761 "src_addr":"200.57.7.204",
763 "label":"180 Ringing",
764 "comment":"SIP Status 180 Ringing"
768 {"jsonrpc":"2.0","id":3,"result":{
770 "tap":"voip-convs:0",
776 "dst_addr":"200.57.7.204",
778 "src_addr":"200.57.7.195",
780 "label":"INVITE SDP (g711A g729 g723 g711U)",
781 "comment":"SIP INVITE From: <sip:200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12013223@200.57.7.195 CSeq:1"
786 "dst_addr":"200.57.7.195",
788 "src_addr":"200.57.7.204",
790 "label":"100 Trying",
791 "comment":"SIP Status 100 Trying"
796 "dst_addr":"200.57.7.195",
798 "src_addr":"200.57.7.204",
800 "label":"180 Ringing",
801 "comment":"SIP Status 180 Ringing"
806 "dst_addr":"200.57.7.195",
808 "src_addr":"200.57.7.204",
810 "label":"200 Ok SDP (g711A g711U GSM iLBC speex telephone-event)",
811 "comment":"SIP Status 200 Ok"
816 "dst_addr":"200.57.7.196",
818 "src_addr":"200.57.7.204",
820 "label":"RTP (g711A) ",
821 "comment":"RTP, 548 packets. Duration: 24.12s SSRC: 0xD2BD4E3E"
826 "dst_addr":"200.57.7.204",
828 "src_addr":"200.57.7.195",
829 "src_port":5060,"label":"ACK","comment":"SIP Request INVITE ACK 200 CSeq:1"
833 {"jsonrpc":"2.0","id":4,"result":{
835 "tap":"voip-convs:0-1",
841 "dst_addr":"200.57.7.204",
843 "src_addr":"200.57.7.195",
845 "label":"INVITE SDP (g711A g729 g723 g711U)",
846 "comment":"SIP INVITE From: <sip:200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12013223@200.57.7.195 CSeq:1"
851 "dst_addr":"200.57.7.195",
853 "src_addr":"200.57.7.204",
855 "label":"100 Trying",
856 "comment":"SIP Status 100 Trying"
861 "dst_addr":"200.57.7.195",
863 "src_addr":"200.57.7.204",
865 "label":"180 Ringing",
866 "comment":"SIP Status 180 Ringing"
871 "dst_addr":"200.57.7.195",
873 "src_addr":"200.57.7.204",
875 "label":"200 Ok SDP (g711A g711U GSM iLBC speex telephone-event)",
876 "comment":"SIP Status 200 Ok"
881 "dst_addr":"200.57.7.196",
883 "src_addr":"200.57.7.204",
885 "label":"RTP (g711A) ",
886 "comment":"RTP, 548 packets. Duration: 24.12s SSRC: 0xD2BD4E3E"
891 "dst_addr":"200.57.7.204",
893 "src_addr":"200.57.7.195",
896 "comment":"SIP Request INVITE ACK 200 CSeq:1"
901 "dst_addr":"200.57.7.204",
903 "src_addr":"200.57.7.195",
905 "label":"INVITE SDP (g711A g729 g723)",
906 "comment":"SIP INVITE From: \"Ivan Alizade\" <sip:5514540002@200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12015624@200.57.7.195 CSeq:1"
911 "dst_addr":"200.57.7.195",
913 "src_addr":"200.57.7.204",
915 "label":"100 Trying",
916 "comment":"SIP Status 100 Trying"
921 "dst_addr":"200.57.7.195",
923 "src_addr":"200.57.7.204",
925 "label":"180 Ringing",
926 "comment":"SIP Status 180 Ringing"
930 {"jsonrpc":"2.0","id":5,"error":{
931 "code":-11014,"message":"sharkd_session_process_tap() voip-convs=voip-convs:garbage invalid 'convs' parameter"
933 {"jsonrpc":"2.0","id":6,"result":{
935 "tap":"voip-convs:999",
940 {"jsonrpc":"2.0","id":7,"result":{
942 "tap":"voip-convs:0,999,0-1,999-999,1,1",
948 "dst_addr":"200.57.7.204",
950 "src_addr":"200.57.7.195",
952 "label":"INVITE SDP (g711A g729 g723 g711U)",
953 "comment":"SIP INVITE From: <sip:200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12013223@200.57.7.195 CSeq:1"
958 "dst_addr":"200.57.7.195",
960 "src_addr":"200.57.7.204",
962 "label":"100 Trying",
963 "comment":"SIP Status 100 Trying"
968 "dst_addr":"200.57.7.195",
970 "src_addr":"200.57.7.204",
972 "label":"180 Ringing",
973 "comment":"SIP Status 180 Ringing"
978 "dst_addr":"200.57.7.195",
980 "src_addr":"200.57.7.204",
982 "label":"200 Ok SDP (g711A g711U GSM iLBC speex telephone-event)",
983 "comment":"SIP Status 200 Ok"
988 "dst_addr":"200.57.7.196",
990 "src_addr":"200.57.7.204",
992 "label":"RTP (g711A) ",
993 "comment":"RTP, 548 packets. Duration: 24.12s SSRC: 0xD2BD4E3E"
998 "dst_addr":"200.57.7.204",
1000 "src_addr":"200.57.7.195",
1003 "comment":"SIP Request INVITE ACK 200 CSeq:1"
1008 "dst_addr":"200.57.7.204",
1010 "src_addr":"200.57.7.195",
1012 "label":"INVITE SDP (g711A g729 g723)",
1013 "comment":"SIP INVITE From: \"Ivan Alizade\" <sip:5514540002@200.57.7.195:55061;user=phone> To:\"francisco@bestel.com\" <sip:francisco@bestel.com:55060> Call-ID:12015624@200.57.7.195 CSeq:1"
1018 "dst_addr":"200.57.7.195",
1020 "src_addr":"200.57.7.204",
1022 "label":"100 Trying",
1023 "comment":"SIP Status 100 Trying"
1028 "dst_addr":"200.57.7.195",
1030 "src_addr":"200.57.7.204",
1032 "label":"180 Ringing",
1033 "comment":"SIP Status 180 Ringing"
1039 def test_sharkd_req_tap_hosts(self
, check_sharkd_session
, capture_file
):
1040 matchAddrNameList
= MatchList(
1041 {"name": MatchAny(str), "addr": MatchAny(str)})
1042 check_sharkd_session((
1043 {"jsonrpc":"2.0", "id":1, "method":"load",
1044 "params":{"file": capture_file('dns-mdns.pcap')}
1046 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "hosts:"}},
1047 {"jsonrpc":"2.0", "id":3, "method":"tap", "params":{"tap0": "hosts:ip"}},
1048 {"jsonrpc":"2.0", "id":4, "method":"tap", "params":{"tap0": "hosts:ipv4"}},
1049 {"jsonrpc":"2.0", "id":5, "method":"tap", "params":{"tap0": "hosts:ipv6"}},
1050 {"jsonrpc":"2.0", "id":6, "method":"tap", "params":{"tap0": "hosts:invalid"}},
1051 {"jsonrpc":"2.0", "id":7, "method":"tap", "params":{"tap0": "hosts:ipv4,ipv6"}},
1052 {"jsonrpc":"2.0", "id":8, "method":"tap", "params":{"tap0": "hosts:ipv4,ipv6,invalid"}},
1054 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1055 {"jsonrpc":"2.0","id":2,"result":{
1059 "ipv4_hosts":matchAddrNameList
,
1060 "ipv6_hosts":matchAddrNameList
,
1063 {"jsonrpc":"2.0","id":3,"result":{
1067 "ipv4_hosts":matchAddrNameList
,
1070 {"jsonrpc":"2.0","id":4,"result":{
1074 "ipv4_hosts":matchAddrNameList
,
1077 {"jsonrpc":"2.0","id":5,"result":{
1081 "ipv6_hosts":matchAddrNameList
,
1084 {"jsonrpc":"2.0","id":6,"error":{"code":-11015,"message":"sharkd_session_process_tap() hosts=hosts:invalid invalid 'protos' parameter"}},
1085 {"jsonrpc":"2.0","id":7,"result":{
1087 "tap":"hosts:ipv4,ipv6",
1089 "ipv4_hosts":matchAddrNameList
,
1090 "ipv6_hosts":matchAddrNameList
,
1093 {"jsonrpc":"2.0","id":8,"error":{"code":-11015,"message":"sharkd_session_process_tap() hosts=hosts:ipv4,ipv6,invalid invalid 'protos' parameter"}},
1096 def test_sharkd_req_tap_eo_http(self
, check_sharkd_session
, capture_file
):
1097 check_sharkd_session((
1098 {"jsonrpc":"2.0", "id":1, "method":"load",
1099 "params":{"file": capture_file('http-ooo.pcap')}
1101 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "eo:http"}},
1103 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1104 {"jsonrpc":"2.0","id":2,"result":{
1112 "_download":"eo:http_0",
1114 "sha1":"4a4121ecd766ed16943a0c7b54c18f743e90c3f6"
1117 "_download":"eo:http_1",
1119 "sha1":"29a51e7382d06ff40467272f02e413ca7b51636e"
1122 "_download":"eo:http_2",
1124 "sha1":"f6d0c643351580307b2eaa6a7560e76965496bc7"}]
1129 def test_sharkd_req_follow_bad(self
, check_sharkd_session
, capture_file
):
1130 # Unrecognized taps currently produce no output (not even err).
1131 check_sharkd_session((
1132 {"jsonrpc":"2.0", "id":1, "method":"load",
1133 "params":{"file": capture_file('dhcp.pcap')}
1135 {"jsonrpc":"2.0", "id":2, "method":"follow"},
1136 {"jsonrpc":"2.0", "id":3, "method":"follow",
1137 "params":{"follow": "garbage follow", "filter": "ip"}
1139 {"jsonrpc":"2.0", "id":4, "method":"follow",
1140 "params":{"follow": "HTTP", "filter": "garbage filter"}
1142 {"jsonrpc":"2.0", "id":5, "method":"follow",
1143 "params":{"follow": "HTTP", "filter": "http", "sub_stream": "garbage sub_stream"}
1146 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1147 {"jsonrpc":"2.0","id":2,"error":{"code":-32600,"message":"Mandatory parameter follow is missing"}},
1148 {"jsonrpc":"2.0","id":3,"error":{"code":-12001,"message":"sharkd_session_process_follow() follower=garbage follow not found"}},
1149 {"jsonrpc":"2.0","id":4,
1150 "error":{"code":-12002,"message":"sharkd_session_process_follow() name=HTTP error=Filter \"garbage filter\" is invalid - \"filter\" was unexpected in this context."}
1152 {"jsonrpc":"2.0","id":5,
1153 "error":{"code":-32600,"message":"The data type for member sub_stream is not valid"}
1157 def test_sharkd_req_follow_no_match(self
, check_sharkd_session
, capture_file
):
1158 check_sharkd_session((
1159 {"jsonrpc":"2.0", "id":1, "method":"load",
1160 "params":{"file": capture_file('dhcp.pcap')}
1162 {"jsonrpc":"2.0", "id":2, "method":"follow",
1163 "params":{"follow": "HTTP", "filter": "ip"}
1166 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1167 {"jsonrpc":"2.0","id":2,
1168 "result":{"shost": "NONE", "sport": "0", "sbytes": 0,
1169 "chost": "NONE", "cport": "0", "cbytes": 0}
1173 def test_sharkd_req_follow_udp(self
, check_sharkd_session
, capture_file
):
1174 check_sharkd_session((
1175 {"jsonrpc":"2.0", "id":1, "method":"load",
1176 "params":{"file": capture_file('dhcp.pcap')}
1178 {"jsonrpc":"2.0", "id":2, "method":"follow",
1179 "params":{"follow": "UDP", "filter": "frame.number==1"}
1182 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1183 {"jsonrpc":"2.0","id":2,
1185 "shost": "255.255.255.255", "sport": "67", "sbytes": 272,
1186 "chost": "0.0.0.0", "cport": "68", "cbytes": 0,
1188 {"n": 1, "d": MatchRegExp(r
'AQEGAAAAPR0A[a-zA-Z0-9]{330}AANwQBAwYq/wAAAAAAAAA=')}]}
1192 def test_sharkd_req_follow_http2(self
, check_sharkd_session
, capture_file
, features
):
1193 # If we don't have nghttp2, we output the compressed headers.
1194 # We could test against the expected output in that case, but
1195 # just skip for now.
1196 if not features
.have_nghttp2
:
1197 pytest
.skip('Requires nghttp2.')
1199 check_sharkd_session((
1200 {"jsonrpc":"2.0", "id":1, "method":"load",
1201 "params":{"file": capture_file('quic-with-secrets.pcapng')}
1203 {"jsonrpc":"2.0", "id":2, "method":"follow",
1204 "params":{"follow": "HTTP2", "filter": "tcp.stream eq 0 and http2.streamid eq 1", "sub_stream": 1}
1207 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1208 {"jsonrpc":"2.0","id":2,
1210 "shost": "2606:4700:10::6816:826", "sport": "443", "sbytes": 656,
1211 "chost": "2001:db8:1::1", "cport": "57098", "cbytes": 109643,
1213 {"n": 12, "d": MatchRegExp(r
'^.*VuLVVTLGVuO3E9MC45Cgo.*$')},
1214 {"n": 19, "s": 1, "d": MatchRegExp(r
'^.*7IG1hPTg2NDAwCgo.*$')},
1215 {"n": 44, "s": 1, "d": MatchRegExp(r
'^.*Pgo8L2h0bWw.*$')},
1220 def test_sharkd_req_iograph_bad(self
, check_sharkd_session
, capture_file
):
1221 check_sharkd_session((
1222 {"jsonrpc":"2.0", "id":1, "method":"load",
1223 "params":{"file": capture_file('dhcp.pcap')}
1225 {"jsonrpc":"2.0", "id":2, "method":"iograph"},
1226 {"jsonrpc":"2.0", "id":3, "method":"iograph",
1227 "params":{"graph0": "garbage graph name"}
1229 {"jsonrpc":"2.0", "id":4, "method":"iograph",
1230 "params":{"graph0": "max:udp.length", "filter0": "udp.length", "interval": 0}},
1231 {"jsonrpc":"2.0", "id":5, "method":"iograph",
1232 "params":{"graph0": "max:udp.length", "filter0": "udp.length", "interval_units": "garbage units"}},
1234 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1235 {"jsonrpc":"2.0","id":2,"error":{"code":-32600,"message":"Mandatory parameter graph0 is missing"}},
1236 {"jsonrpc":"2.0","id":3,"result":{"iograph": []}},
1237 {"jsonrpc":"2.0","id":4,"error":{"code":-32600,"message":"The value for interval must be a positive integer"}},
1238 {"jsonrpc":"2.0","id":5,"error":{"code":-7003,"message":"Invalid interval_units parameter: 'garbage units', must be 's', 'ms' or 'us'"}},
1241 def test_sharkd_req_iograph_basic(self
, check_sharkd_session
, capture_file
):
1242 check_sharkd_session((
1243 {"jsonrpc":"2.0", "id":1, "method":"load",
1244 "params":{"file": capture_file('dhcp.pcap')}
1246 {"jsonrpc":"2.0", "id":2, "method":"iograph",
1247 "params":{"graph0": "max:udp.length", "filter0": "udp.length"}
1249 {"jsonrpc":"2.0", "id":3, "method":"iograph",
1250 "params":{"graph0": "packets", "graph1": "bytes"}
1252 {"jsonrpc":"2.0", "id":4, "method":"iograph",
1253 "params":{"graph0": "packets", "filter0": "garbage filter"}
1255 {"jsonrpc":"2.0", "id":5, "method":"iograph",
1256 "params":{"graph0": "packets", "graph1": "bytes", "interval": 1, "interval_units": "us"}
1258 {"jsonrpc":"2.0", "id":6, "method":"iograph",
1259 "params":{"graph0": "packets", "graph1": "bytes", "interval": 1, "interval_units": "ms"}
1261 {"jsonrpc":"2.0", "id":7, "method":"iograph",
1262 "params":{"graph0": "packets", "graph1": "bytes", "interval": 1, "interval_units": "s"}
1265 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1266 {"jsonrpc":"2.0","id":2,"result":{"iograph": [{"items": [308.000000]}]}},
1267 {"jsonrpc":"2.0","id":3,"result":{"iograph": [{"items": [4.000000]}, {"items": [1312.000000]}]}},
1268 {"jsonrpc":"2.0","id":4,"error":{"code":-6001,"message":"Filter \"garbage filter\" is invalid - \"filter\" was unexpected in this context."}},
1269 {"jsonrpc":"2.0","id":5,"result":{"iograph": [
1270 {"items": [1.0, '127', 1.0, '1118f', 1.0, '112c9', 1.0]},
1271 {"items": [314.0, '127', 342.0, '1118f', 314.0, '112c9', 342.0]},
1273 {"jsonrpc":"2.0","id":6,"result":{"iograph": [
1274 {"items": [2.0, '46', 2.0]},
1275 {"items": [656.0, '46', 656.0]},
1277 {"jsonrpc":"2.0","id":7,"result":{"iograph": [
1279 {"items": [1312.0]},
1283 def test_sharkd_req_intervals_bad(self
, check_sharkd_session
, capture_file
):
1284 check_sharkd_session((
1285 {"jsonrpc":"2.0", "id":1, "method":"load",
1286 "params":{"file": capture_file('dhcp.pcap')}
1288 {"jsonrpc":"2.0", "id":2, "method":"intervals",
1289 "params":{"filter": "garbage filter"}
1292 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1293 {"jsonrpc":"2.0","id":2,"error":{"code":-7001,"message":"Invalid filter parameter: garbage filter"}},
1296 def test_sharkd_req_intervals_basic(self
, check_sharkd_session
, capture_file
):
1297 check_sharkd_session((
1298 {"jsonrpc":"2.0", "id":1, "method":"load",
1299 "params":{"file": capture_file('dhcp.pcap')}
1301 {"jsonrpc":"2.0", "id":2, "method":"intervals"},
1302 {"jsonrpc":"2.0", "id":3, "method":"intervals",
1303 "params":{"interval": 1}
1305 {"jsonrpc":"2.0", "id":4, "method":"intervals",
1306 "params":{"filter": "frame.number <= 2"}
1309 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1310 {"jsonrpc":"2.0","id":2,"result":{"intervals":[[0,4,1312]],"last":0,"frames":4,"bytes":1312}},
1311 {"jsonrpc":"2.0","id":3,"result":{"intervals":[[0,2,656],[70,2,656]],"last":70,"frames":4,"bytes":1312}},
1312 {"jsonrpc":"2.0","id":4,"result":{"intervals":[[0,2,656]],"last":0,"frames":2,"bytes":656}},
1315 def test_sharkd_req_frame_basic(self
, check_sharkd_session
, capture_file
):
1316 # XXX add more tests for other options (ref_frame, prev_frame, columns, color, bytes, hidden)
1317 check_sharkd_session((
1318 {"jsonrpc":"2.0", "id":1, "method":"load",
1319 "params":{"file": capture_file('dhcp.pcap')}
1321 {"jsonrpc":"2.0", "id":2, "method":"frame",
1322 "params":{"frame": 2}
1325 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1326 {"jsonrpc":"2.0","id":2,"result":{
1327 "fol": [["UDP", "udp.stream eq 1"]],
1328 "followers": [{"protocol": "UDP","filter": "udp.stream eq 1","stream": 1}]
1332 def test_sharkd_req_frame_http2(self
, check_sharkd_session
, capture_file
):
1333 check_sharkd_session((
1334 {"jsonrpc":"2.0", "id":1, "method":"load",
1335 "params":{"file": capture_file('quic-with-secrets.pcapng')}
1337 {"jsonrpc":"2.0", "id":2, "method":"frame",
1338 "params":{"frame": 12}
1341 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1342 {"jsonrpc":"2.0","id":2,"result":{
1343 "fol": [["HTTP2", "tcp.stream eq 0 and http2.streamid eq 1"],["TCP","tcp.stream eq 0"],["TLS","tcp.stream eq 0"]],
1345 {"protocol": "HTTP2","filter": "tcp.stream eq 0 and http2.streamid eq 1","stream": 0, "sub_stream": 1},
1346 {"protocol": "TCP","filter": "tcp.stream eq 0","stream": 0},
1347 {"protocol": "TLS","filter": "tcp.stream eq 0","stream": 0},
1352 def test_sharkd_req_frame_proto(self
, check_sharkd_session
, capture_file
):
1353 # Check proto tree output (including an UTF-8 value).
1354 check_sharkd_session((
1355 {"jsonrpc":"2.0", "id":1, "method":"load",
1356 "params":{"file": capture_file('dhcp.pcap')}
1358 {"jsonrpc":"2.0", "id":2, "method":"frame",
1359 "params":{"frame": 2, "proto": True}
1362 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1363 {"jsonrpc":"2.0","id":2,"result":
1366 "l": "Dynamic Host Configuration Protocol (Offer)",
1372 "l": "Padding: 0000000000000000000000000000000000000000000000000000",
1374 "f": "dhcp.option.padding == 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
1375 "fn": "dhcp.option.padding"
1376 }, match_element
=any
), # match one element from 'n'
1378 }, match_element
=any
), # match one element from 'tree'
1383 def test_sharkd_req_setcomment(self
, check_sharkd_session
, capture_file
):
1384 check_sharkd_session((
1385 {"jsonrpc":"2.0", "id":1, "method":"load",
1386 "params":{"file": capture_file('dhcp.pcap')}
1388 {"jsonrpc":"2.0", "id":2, "method":"setcomment",
1389 "params":{"frame": 99999, "comment": "meh\nbaz"}
1391 {"jsonrpc":"2.0", "id":3, "method":"setcomment",
1392 "params":{"frame": 3, "comment": "foo\nbar"}
1394 {"jsonrpc":"2.0", "id":4, "method":"frame",
1395 "params":{"frame": 3}
1399 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1400 {"jsonrpc":"2.0","id":2,"error":{"code":-3002,"message":"Frame number is out of range"}},
1401 {"jsonrpc":"2.0","id":3,"result":{"status":"OK"}},
1402 {"jsonrpc":"2.0","id":4,"result":{"comment":["foo\nbar"],"fol": MatchAny(list), "followers": MatchAny(list)}},
1405 def test_sharkd_req_setconf_bad(self
, check_sharkd_session
):
1406 check_sharkd_session((
1407 {"jsonrpc":"2.0", "id":1, "method":"setconf",
1408 "params":{"name": "uat:garbage-pref", "value": "\"\""}
1411 {"jsonrpc":"2.0","id":1,"error":{"code":-4005,"message":"Unable to set the preference"}},
1414 def test_sharkd_req_dumpconf_bad(self
, check_sharkd_session
):
1415 check_sharkd_session((
1416 {"jsonrpc":"2.0", "id":1, "method":"dumpconf",
1417 "params":{"pref": "bad.preference"}
1419 {"jsonrpc":"2.0", "id":2, "method":"dumpconf",
1420 "params":{"pref": "invalid-garbage-preference"}
1422 {"jsonrpc":"2.0", "id":3, "method":"dumpconf",
1423 "params":{"pref": "uat:custom_http_header_fields"}
1426 {"jsonrpc":"2.0","id":1,"error":{"code":-9001,"message":"Invalid pref bad.preference."}},
1427 {"jsonrpc":"2.0","id":2,"error":{"code":-9002,"message":"Invalid pref invalid-garbage-preference."}},
1428 {"jsonrpc":"2.0","id":3,"error":{"code":-9002,"message":"Invalid pref uat:custom_http_header_fields."}},
1431 def test_sharkd_req_dumpconf_all(self
, check_sharkd_session
):
1432 check_sharkd_session((
1433 {"jsonrpc":"2.0", "id":1, "method":"dumpconf"},
1435 {"jsonrpc":"2.0","id":1,"result":{"prefs": MatchObject({"tcp.check_checksum": {"b": 0}})}
1439 def test_sharkd_req_download_tls_secrets(self
, check_sharkd_session
, capture_file
):
1440 # XXX test download for eo: too
1441 check_sharkd_session((
1442 {"jsonrpc":"2.0", "id":1, "method":"load",
1443 "params":{"file": capture_file('tls12-dsb.pcapng')}
1445 {"jsonrpc":"2.0", "id":2, "method":"download",
1446 "params":{"token": "ssl-secrets"}
1449 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1450 # There are two used CLIENT RANDOM secrets, we don't know
1451 # the order they will appear when iterating a hash table,
1452 # and it can be different on Big-Endian systems than L-E.
1453 # Check the Base64 for both "CLIENT_RANDOM f67a" and
1454 # "CLIENT_RANDOM 1e0d".
1455 {"jsonrpc":"2.0","id":2,"result":{"file": "keylog.txt", "mime": "text/plain",
1456 "data": MatchRegExp(r
'Q0xJRU5UX1JBTkRP(TSBmNjdh|TSAxZTBk).+')}
1460 def test_sharkd_req_download_rtp_stream(self
, check_sharkd_session
, capture_file
):
1461 check_sharkd_session((
1462 {"jsonrpc":"2.0", "id":1, "method":"load",
1463 "params":{"file": capture_file('sip-rtp.pcapng')}
1465 {"jsonrpc":"2.0", "id":2, "method":"download",
1466 "params":{"token": "rtp:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e"}},
1467 {"jsonrpc":"2.0", "id":3, "method":"download",
1468 "params":{"token": "rtp:1.1.1.1_8000_1.1.1.2_9000_0xdddddddd"}},
1470 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1471 {"jsonrpc":"2.0","id":2,"result":{
1472 "file":"rtp:200.57.7.204_8000_200.57.7.196_40376_0xd2bd4e3e",
1473 "mime":"audio/x-wav",
1474 "data":MatchRegExp(r
'UklGRv.+')}
1476 {"jsonrpc":"2.0","id":3,"error":{"code":-10003,"message":"no rtp data available"}},
1479 def test_sharkd_req_download_bad_tokens(self
, check_sharkd_session
, capture_file
):
1480 check_sharkd_session((
1481 {"jsonrpc":"2.0", "id":1, "method":"load",
1482 "params":{"file": capture_file('tls12-dsb.pcapng')}
1484 {"jsonrpc":"2.0", "id":2, "method":"download",
1485 "params":{"token": "BOGUSTOKEN"}
1487 {"jsonrpc":"2.0", "id":3, "method":"download",
1491 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1492 {"jsonrpc":"2.0","id":2,"error":{"code":-10004,"message":"unrecognized token"}},
1493 {"jsonrpc":"2.0","id":3,"error":{"code":-10005,"message":"missing token"}},
1496 def test_sharkd_req_download_eo_http_with_prior_tap_eo_http(self
, check_sharkd_session
, capture_file
):
1497 check_sharkd_session((
1498 {"jsonrpc":"2.0", "id":1, "method":"load",
1499 "params":{"file": capture_file('http-ooo.pcap')}
1501 {"jsonrpc":"2.0", "id":2, "method":"tap", "params":{"tap0": "eo:http"}},
1502 {"jsonrpc":"2.0", "id":3, "method":"download",
1503 "params":{"token": "eo:http_0"}},
1504 {"jsonrpc":"2.0", "id":4, "method":"download",
1505 "params":{"token": "eo:http_1"}},
1506 {"jsonrpc":"2.0", "id":5, "method":"download",
1507 "params":{"token": "eo:http_2"}},
1508 {"jsonrpc":"2.0", "id":6, "method":"download",
1509 "params":{"token": "eo:http_999"}},
1511 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1512 {"jsonrpc":"2.0","id":2,"result":{
1520 "_download":"eo:http_0",
1522 "sha1":"4a4121ecd766ed16943a0c7b54c18f743e90c3f6"
1525 "_download":"eo:http_1",
1527 "sha1":"29a51e7382d06ff40467272f02e413ca7b51636e"
1530 "_download":"eo:http_2",
1532 "sha1":"f6d0c643351580307b2eaa6a7560e76965496bc7"}]
1535 {"jsonrpc":"2.0","id":3,"result":{
1536 "file":"4","mime":"application/octet-stream","data":"Zm91cgo="}},
1537 {"jsonrpc":"2.0","id":4,"result":{
1538 "file":"eo:http_1","mime":"application/octet-stream","data":"QVRBDQo="}},
1539 {"jsonrpc":"2.0","id":5,"result":{
1540 "file":"eo:http_2","mime":"application/octet-stream","data":"MA0KDQo="}},
1541 {"jsonrpc":"2.0","id":6,"result":{}},
1543 def test_sharkd_req_download_eo_http_without_prior_tap_eo_http(self
, check_sharkd_session
, capture_file
):
1544 check_sharkd_session((
1545 {"jsonrpc":"2.0", "id":1, "method":"load",
1546 "params":{"file": capture_file('http-ooo.pcap')}
1548 {"jsonrpc":"2.0", "id":2, "method":"download",
1549 "params":{"token": "eo:http_0"}},
1550 {"jsonrpc":"2.0", "id":3, "method":"download",
1551 "params":{"token": "eo:http_1"}},
1552 {"jsonrpc":"2.0", "id":4, "method":"download",
1553 "params":{"token": "eo:http_2"}},
1554 {"jsonrpc":"2.0", "id":5, "method":"download",
1555 "params":{"token": "eo:http_999"}},
1557 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1558 {"jsonrpc":"2.0","id":2,"result":{
1559 "file":"4","mime":"application/octet-stream","data":"Zm91cgo="}},
1560 {"jsonrpc":"2.0","id":3,"result":{
1561 "file":"eo:http_1","mime":"application/octet-stream","data":"QVRBDQo="}},
1562 {"jsonrpc":"2.0","id":4,"result":{
1563 "file":"eo:http_2","mime":"application/octet-stream","data":"MA0KDQo="}},
1564 {"jsonrpc":"2.0","id":5,"result":{}},
1566 def test_sharkd_req_bye(self
, check_sharkd_session
):
1567 check_sharkd_session((
1568 {"jsonrpc":"2.0", "id":1, "method":"bye"},
1570 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1573 def test_sharkd_bad_request(self
, check_sharkd_session
):
1574 check_sharkd_session((
1575 {"jsonrpc":"2.0", "id":1, "method":"dud"},
1577 {'jsonrpc': '2.0', 'id': 1, 'error': {'code': -32601, 'message': 'The method dud is not supported'}},
1580 def test_sharkd_config(self
, check_sharkd_session
):
1581 check_sharkd_session((
1582 {"jsonrpc":"2.0", "id":1, "method":"setconf",
1583 "params":{"name": "uat:custom_http_header_fields", "value": "\"X-Header-Name\", \"Description\""}
1585 {"jsonrpc":"2.0", "id":2, "method":"setconf",
1586 "params":{"name": "tcp.check_checksum", "value": "true"}
1588 {"jsonrpc":"2.0", "id":3, "method":"dumpconf",
1589 "params":{"pref": "tcp.check_checksum"}
1591 {"jsonrpc":"2.0", "id":4, "method":"setconf",
1592 "params":{"name": "tcp.check_checksum", "value": "false"}
1594 {"jsonrpc":"2.0", "id":5, "method":"dumpconf",
1595 "params":{"pref": "tcp.check_checksum"}
1598 # Check that the UAT preference is set. There is no way to query it
1599 # (other than testing for side-effects in dissection).
1600 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
1601 {"jsonrpc":"2.0","id":2,"result":{"status":"OK"}},
1602 {"jsonrpc":"2.0","id":3,"result":{"prefs":{"tcp.check_checksum":{"b":1}}}},
1603 {"jsonrpc":"2.0","id":4,"result":{"status":"OK"}},
1604 {"jsonrpc":"2.0","id":5,"result":{"prefs":{"tcp.check_checksum":{"b":0}}}},
1607 def test_sharkd_config_enum(self
, check_sharkd_session
):
1608 '''Dump default enum preference value, change it and restore it.'''
1609 check_sharkd_session((
1610 {"jsonrpc":"2.0", "id":1, "method":"dumpconf",
1611 "params":{"pref": "wlan.ignore_wep"}
1613 {"jsonrpc":"2.0", "id":2, "method":"setconf",
1614 "params":{"name": "wlan.ignore_wep", "value": "Yes - with IV"}
1616 {"jsonrpc":"2.0", "id":3, "method":"dumpconf",
1617 "params":{"pref": "wlan.ignore_wep"}
1619 {"jsonrpc":"2.0", "id":4, "method":"setconf",
1620 "params":{"name": "wlan.ignore_wep", "value": "No"}
1622 {"jsonrpc":"2.0", "id":5, "method":"dumpconf",
1623 "params":{"pref": "wlan.ignore_wep"}
1626 {"jsonrpc":"2.0","id":1,"result":{"prefs":{"wlan.ignore_wep":{"e":[{"v":0,"s":1,"d":"No"},{"v":1,"d":"Yes - without IV"},{"v":2,"d":"Yes - with IV"}]}}}},
1627 {"jsonrpc":"2.0","id":2,"result":{"status":"OK"}},
1628 {"jsonrpc":"2.0","id":3,"result":{"prefs":{"wlan.ignore_wep":{"e":[{"v":0,"d":"No"},{"v":1,"d":"Yes - without IV"},{"v":2,"s":1,"d":"Yes - with IV"}]}}}},
1629 {"jsonrpc":"2.0","id":4,"result":{"status":"OK"}},
1630 {"jsonrpc":"2.0","id":5,"result":{"prefs":{"wlan.ignore_wep":{"e":[{"v":0,"s":1,"d":"No"},{"v":1,"d":"Yes - without IV"},{"v":2,"d":"Yes - with IV"}]}}}},
1633 def test_sharkd_nested_file(self
, check_sharkd_session
, capture_file
):
1634 '''Request a frame from a file with a deep level of nesting.'''
1635 check_sharkd_session((
1636 {"jsonrpc":"2.0", "id":1, "method":"load",
1637 "params":{"file": capture_file("http2-data-reassembly.pcap")}
1639 {"jsonrpc":"2.0", "id":2, "method":"frame",
1640 "params":{"frame": "4", "proto": "yes"}
1643 {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},