Skip to content

Instantly share code, notes, and snippets.

@dsturnbull
Created October 11, 2013 00:47
Show Gist options
  • Save dsturnbull/6927985 to your computer and use it in GitHub Desktop.
Save dsturnbull/6927985 to your computer and use it in GitHub Desktop.
diff --git a/print.c b/print.c
index bb4e691..30a765e 100644
--- a/print.c
+++ b/print.c
@@ -162,8 +162,6 @@ void proto_tree_print_node(proto_node *node, gpointer data)
{
field_info *fi = PNODE_FINFO(node);
print_data *pdata = (print_data*) data;
- const guint8 *pd;
- gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
/* dissection with an invisible proto tree? */
@@ -177,61 +175,70 @@ void proto_tree_print_node(proto_node *node, gpointer data)
if (!pdata->success)
return;
- /* was a free format label produced? */
- if (fi->rep) {
- label_ptr = fi->rep->representation;
- }
- else { /* no, make a generic label */
- label_ptr = label_str;
- proto_item_fill_label(fi, label_str);
- }
-
- if (PROTO_ITEM_IS_GENERATED(node)) {
- label_ptr = g_strdup_printf("[%s]", label_ptr);
- }
+#define CMP(s) if (strncmp(fi->hfinfo->abbrev, s, strlen(s)) == 0) return;
+
+ CMP("data-text-lines");
+
+ CMP("frame[");
+ CMP("expert");
+
+ CMP("frame.dlt");
+ CMP("frame.offset_shift");
+ CMP("frame.time_delta");
+ CMP("frame.time_delta_displayed");
+ CMP("frame.number");
+ CMP("frame.cap_len");
+ CMP("frame.marked");
+ CMP("frame.ignored");
+ CMP("frame.protocols");
+ CMP("frame.encap_type");
+
+ CMP("eth.lg");
+ CMP("eth.ig");
+ CMP("eth.addr");
+ CMP("eth.type");
+
+ CMP("ip.version");
+ CMP("ip.hdr_len");
+ CMP("ip.dsfield");
+ CMP("ip.dsfield.dscp");
+ CMP("ip.dsfield.ecn");
+ CMP("ip.id");
+ CMP("ip.flags.");
+ CMP("ip.frag_offset");
+ CMP("ip.proto");
+ CMP("ip.checksum");
+
+ CMP("tcp.checksum_good");
+ CMP("tcp.checksum_bad");
+ CMP("ip.opt.type");
+ CMP("tcp.option_kind");
+ CMP("tcp.option_len");
+ CMP("tcp.analysis");
+ CMP("tcp.flags.");
+ CMP("tcp.nxtseq");
+ CMP("tcp.window_size");
+ CMP("tcp.window_size_scalefactor");
+
+ CMP("udp.checksum_good");
+ CMP("udp.checksum_bad");
+
+ CMP("tcp.segment");
+ CMP("data.data");
+ CMP("ssl.app_data");
+ CMP("tcp.data");
+ CMP("udp.data");
+
+ label_ptr = proto_construct_match_selected_string(fi, pdata->edt);
+
+ if (!label_ptr)
+ return;
if (!print_line(pdata->stream, pdata->level, label_ptr)) {
pdata->success = FALSE;
return;
}
- /*
- * If -O is specified, only display the protocols which are in the
- * lookup table. Only check on the first level: once we start printing
- * a tree, print the rest of the subtree. Otherwise we won't print
- * subitems whose abbreviation doesn't match the protocol--for example
- * text items (whose abbreviation is simply "text").
- */
- if ((output_only_tables != NULL) && (pdata->level == 0)
- && (g_hash_table_lookup(output_only_tables, fi->hfinfo->abbrev) == NULL)) {
- pdata->success = TRUE;
- return;
- }
-
- if (PROTO_ITEM_IS_GENERATED(node)) {
- g_free(label_ptr);
- }
-
- /* If it's uninterpreted data, dump it (unless our caller will
- be printing the entire packet in hex). */
- if ((fi->hfinfo->id == proto_data) && (pdata->print_hex_for_data)) {
- /*
- * Find the data for this field.
- */
- pd = get_field_data(pdata->src_list, fi);
- if (pd) {
- if (!print_line(pdata->stream, 0, "")) {
- pdata->success = FALSE;
- return;
- }
- if (!print_hex_data_buffer(pdata->stream, pd,
- fi->length, pdata->encoding)) {
- pdata->success = FALSE;
- return;
- }
- }
- }
-
/* If we're printing all levels, or if this node is one with a
subtree and its subtree is expanded, recurse into the subtree,
if it exists. */
diff --git a/tshark.c b/tshark.c
index 855aaf8..32185bf 100644
--- a/tshark.c
+++ b/tshark.c
@@ -2725,7 +2725,7 @@ process_packet_second_pass(capture_file *cf, frame_data *fdata,
printing packet details, which is true if we're printing stuff
("print_packet_info" is true) and we're in verbose mode
("packet_details" is true). */
- epan_dissect_init(&edt, create_proto_tree, print_packet_info && print_details);
+ epan_dissect_init(&edt, create_proto_tree, print_packet_info);
/* If we're running a read filter, prime the epan_dissect_t with that
filter. */
@@ -2740,7 +2740,7 @@ process_packet_second_pass(capture_file *cf, frame_data *fdata,
2) we're printing packet info but we're *not* verbose; in verbose
mode, we print the protocol tree, not the protocol summary.
*/
- if ((tap_flags & TL_REQUIRES_COLUMNS) || (print_packet_info && print_summary))
+ if ((tap_flags & TL_REQUIRES_COLUMNS) || print_packet_info)
cinfo = &cf->cinfo;
else
cinfo = NULL;
@@ -3170,7 +3170,7 @@ process_packet(capture_file *cf, gint64 offset, struct wtap_pkthdr *whdr,
printing packet details, which is true if we're printing stuff
("print_packet_info" is true) and we're in verbose mode
("packet_details" is true). */
- epan_dissect_init(&edt, create_proto_tree, print_packet_info && print_details);
+ epan_dissect_init(&edt, create_proto_tree, print_packet_info);
/* If we're running a read filter, prime the epan_dissect_t with that
filter. */
@@ -3186,7 +3186,7 @@ process_packet(capture_file *cf, gint64 offset, struct wtap_pkthdr *whdr,
mode, we print the protocol tree, not the protocol summary.
or
3) there is a column mapped as an individual field */
- if ((tap_flags & TL_REQUIRES_COLUMNS) || (print_packet_info && print_summary) || output_fields_has_cols(output_fields))
+ if ((tap_flags & TL_REQUIRES_COLUMNS) || print_packet_info || output_fields_has_cols(output_fields))
cinfo = &cf->cinfo;
else
cinfo = NULL;
@@ -3578,6 +3578,11 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
print_args.print_formfeed = FALSE;
packet_range_init(&print_args.range, &cfile);
*/
+
+ printf("packet ");
+ epan_dissect_fill_in_columns(edt, FALSE, TRUE);
+ print_columns(cf);
+
print_args.print_hex = print_hex;
print_args.print_dissections = print_details ? print_dissections_expanded : print_dissections_none;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment