tshark: Print the packets' comments in the expert info
Previously 'tshark -z expert' was failing with abort when a packet contains a comment - Add a new comment parameter and update the tshark's manual page - Add a new comment_level severity and change the default lavel to it. - Add various 'tshark -z expert' tests Change-Id: I188317da5e00019b8f2b725f0fe84942f774520f Reviewed-on: https://code.wireshark.org/review/30610 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
2ed4743915
commit
ec95ae98ed
|
@ -1178,7 +1178,7 @@ the number of packets/bytes in each direction as well as the total
|
|||
number of packets/bytes. The table is sorted according to the total
|
||||
number of frames.
|
||||
|
||||
=item B<-z> expert[I<,error|,warn|,note|,chat>][I<,filter>]
|
||||
=item B<-z> expert[I<,error|,warn|,note|,chat|,comment>][I<,filter>]
|
||||
|
||||
Collects information about all expert info, and will display them in order,
|
||||
grouped by severity.
|
||||
|
|
|
@ -192,6 +192,75 @@ class case_tshark_dump_glossaries(subprocesstest.SubprocessTestCase):
|
|||
self.runProcess((config.cmd_tshark, '-G', 'plugins'), env=config.baseEnv())
|
||||
self.assertGreaterEqual(self.countOutput('dissector'), 10, 'Fewer than 10 dissector plugins found')
|
||||
|
||||
class case_tshark_z_expert(subprocesstest.SubprocessTestCase):
|
||||
def test_tshark_z_expert_all(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert',
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')))
|
||||
self.assertTrue(self.grepOutput('Errors'))
|
||||
self.assertTrue(self.grepOutput('Warns'))
|
||||
self.assertTrue(self.grepOutput('Chats'))
|
||||
|
||||
def test_tshark_z_expert_error(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,error',
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')))
|
||||
self.assertTrue(self.grepOutput('Errors'))
|
||||
self.assertFalse(self.grepOutput('Warns'))
|
||||
self.assertFalse(self.grepOutput('Chats'))
|
||||
|
||||
def test_tshark_z_expert_warn(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,warn',
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')))
|
||||
self.assertTrue(self.grepOutput('Errors'))
|
||||
self.assertTrue(self.grepOutput('Warns'))
|
||||
self.assertFalse(self.grepOutput('Chats'))
|
||||
|
||||
def test_tshark_z_expert_note(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,note',
|
||||
'-r', os.path.join(config.capture_dir, 'http2-data-reassembly.pcap')))
|
||||
self.assertTrue(self.grepOutput('Warns'))
|
||||
self.assertTrue(self.grepOutput('Notes'))
|
||||
self.assertFalse(self.grepOutput('Chats'))
|
||||
|
||||
def test_tshark_z_expert_chat(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,chat',
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')))
|
||||
self.assertTrue(self.grepOutput('Errors'))
|
||||
self.assertTrue(self.grepOutput('Warns'))
|
||||
self.assertTrue(self.grepOutput('Chats'))
|
||||
|
||||
def test_tshark_z_expert_comment(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,comment',
|
||||
'-r', os.path.join(config.capture_dir, 'sip.pcapng')))
|
||||
self.assertTrue(self.grepOutput('Notes'))
|
||||
self.assertTrue(self.grepOutput('Comments'))
|
||||
|
||||
def test_tshark_z_expert_invalid_filter(self):
|
||||
invalid_filter = '__invalid_protocol'
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,' + invalid_filter,
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')),
|
||||
expected_return=self.exit_command_line)
|
||||
self.assertTrue(self.grepOutput('Filter "' + invalid_filter + '" is invalid'))
|
||||
|
||||
def test_tshark_z_expert_error_invalid_filter(self):
|
||||
invalid_filter = '__invalid_protocol'
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,error,' + invalid_filter,
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')),
|
||||
expected_return=self.exit_command_line)
|
||||
self.assertTrue(self.grepOutput('Filter "' + invalid_filter + '" is invalid'))
|
||||
|
||||
def test_tshark_z_expert_filter(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,udp', #udp is a filter
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')))
|
||||
self.assertFalse(self.grepOutput('Errors'))
|
||||
self.assertFalse(self.grepOutput('Warns'))
|
||||
self.assertFalse(self.grepOutput('Chats'))
|
||||
|
||||
def test_tshark_z_expert_error_filter(self):
|
||||
self.assertRun((config.cmd_tshark, '-q', '-z', 'expert,error,udp', #udp is a filter
|
||||
'-r', os.path.join(config.capture_dir, 'http-ooo.pcap')))
|
||||
self.assertFalse(self.grepOutput('Errors'))
|
||||
self.assertFalse(self.grepOutput('Warns'))
|
||||
self.assertFalse(self.grepOutput('Chats'))
|
||||
|
||||
# Purposefully fail a test. Used for testing the test framework.
|
||||
# class case_fail_on_purpose(subprocesstest.SubprocessTestCase):
|
||||
|
|
|
@ -24,7 +24,8 @@ void register_tap_listener_expert_info(void);
|
|||
|
||||
/* Tap data */
|
||||
typedef enum severity_level_t {
|
||||
chat_level = 0,
|
||||
comment_level = 0,
|
||||
chat_level,
|
||||
note_level,
|
||||
warn_level,
|
||||
error_level,
|
||||
|
@ -33,7 +34,7 @@ typedef enum severity_level_t {
|
|||
|
||||
/* This variable stores the lowest level that will be displayed.
|
||||
May be changed from the command line */
|
||||
static severity_level_t lowest_report_level = chat_level;
|
||||
static severity_level_t lowest_report_level = comment_level;
|
||||
|
||||
typedef struct expert_entry
|
||||
{
|
||||
|
@ -81,6 +82,9 @@ expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U
|
|||
guint n;
|
||||
|
||||
switch (ei->severity) {
|
||||
case PI_COMMENT:
|
||||
severity_level = comment_level;
|
||||
break;
|
||||
case PI_CHAT:
|
||||
severity_level = chat_level;
|
||||
break;
|
||||
|
@ -176,6 +180,7 @@ expert_stat_draw(void *phs _U_)
|
|||
draw_items_for_severity(hs->ei_array[warn_level], "Warns");
|
||||
draw_items_for_severity(hs->ei_array[note_level], "Notes");
|
||||
draw_items_for_severity(hs->ei_array[chat_level], "Chats");
|
||||
draw_items_for_severity(hs->ei_array[comment_level], "Comments");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -222,6 +227,9 @@ static void expert_stat_init(const char *opt_arg, void *userdata _U_)
|
|||
} else if (g_ascii_strncasecmp(args, ",chat", 5) == 0) {
|
||||
lowest_report_level = chat_level;
|
||||
args += 5;
|
||||
} else if (g_ascii_strncasecmp(args, ",comment", 8) == 0) {
|
||||
lowest_report_level = comment_level;
|
||||
args += 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue