aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-06-11 12:03:13 -0400
committerAnders Broman <a.broman58@gmail.com>2017-06-12 03:23:38 +0000
commit585d17ae7f03d76713cf8ab2959260d19dabc619 (patch)
treeb9d43744966ae757091c7db606604e6e2fd90a6d
parentf4dd096afb6bb7b3ed7f036a9def10a5c27dcd66 (diff)
Add support for color xml attributes in psml and pdml formats.
Bug: 6682 Change-Id: I19330d06aa3d5692503c61369c3c650d595971f5 Reviewed-on: https://code.wireshark.org/review/22077 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stephen Donnelly <stephen.donnelly@endace.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--doc/README.xml-output2
-rw-r--r--doc/tshark.pod4
-rw-r--r--epan/print.c25
-rw-r--r--epan/print.h4
-rw-r--r--file.c4
-rw-r--r--tfshark.c4
-rw-r--r--tshark.c6
7 files changed, 37 insertions, 12 deletions
diff --git a/doc/README.xml-output b/doc/README.xml-output
index 31fd6e2006..b3011ae24c 100644
--- a/doc/README.xml-output
+++ b/doc/README.xml-output
@@ -143,6 +143,8 @@ In PDML, the "Data" protocol would become another field under HTTP:
</proto>
</packet>
+Note that packet tag may have nonstandard color attributes, "foreground" and "background"
+
tools/WiresharkXML.py
====================
This is a python module which provides some infrastructure for
diff --git a/doc/tshark.pod b/doc/tshark.pod
index 512ff1c906..208d6cc44e 100644
--- a/doc/tshark.pod
+++ b/doc/tshark.pod
@@ -792,6 +792,8 @@ Example of usage:
B<pdml> Packet Details Markup Language, an XML-based format for the details of
a decoded packet. This information is equivalent to the packet details
printed with the B<-V> flag.
+Using the --color option will add color attributes to B<pdml> output. These
+attributes are nonstandard.
B<ps> PostScript for a human-readable one-line summary of each of the packets,
or a multi-line view of the details of each of the packets, depending on
@@ -800,6 +802,8 @@ whether the B<-V> flag was specified.
B<psml> Packet Summary Markup Language, an XML-based format for the summary
information of a decoded packet. This information is equivalent to the
information shown in the one-line summary printed by default.
+Using the --color option will add color attributes to B<pdml> output. These
+attributes are nonstandard.
B<tabs> Similar to the default B<text> report except the human-readable one-line
summary of each packet will include an ASCII horizontal tab (0x09) character
diff --git a/epan/print.c b/epan/print.c
index 074621ae01..d4343aaadb 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -33,6 +33,7 @@
#include <epan/to_str.h>
#include <epan/expert.h>
#include <epan/column-info.h>
+#include <epan/color_filters.h>
#include <epan/prefs.h>
#include <epan/print.h>
#include <epan/charsets.h>
@@ -298,15 +299,23 @@ static gboolean check_protocolfilter(gchar **protocolfilter, const char *str)
}
void
-write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh)
+write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh, gboolean use_color)
{
write_pdml_data data;
+ const color_filter_t *cfp = edt->pi.fd->color_filter;
g_assert(edt);
g_assert(fh);
/* Create the output */
- fprintf(fh, "<packet>\n");
+ if (use_color && (cfp != NULL)) {
+ fprintf(fh, "<packet foreground='#%02x%02x%02x' background='#%02x%02x%02x'>\n",
+ cfp->fg_color.red, cfp->fg_color.green, cfp->fg_color.blue,
+ cfp->bg_color.red, cfp->bg_color.green, cfp->bg_color.blue);
+ }
+ else {
+ fprintf(fh, "<packet>\n");
+ }
/* Print a "geninfo" protocol as required by PDML */
print_pdml_geninfo(edt, fh);
@@ -1287,11 +1296,19 @@ write_psml_preamble(column_info *cinfo, FILE *fh)
}
void
-write_psml_columns(epan_dissect_t *edt, FILE *fh)
+write_psml_columns(epan_dissect_t *edt, FILE *fh, gboolean use_color)
{
gint i;
+ const color_filter_t *cfp = edt->pi.fd->color_filter;
- fprintf(fh, "<packet>\n");
+ if (use_color && (cfp != NULL)) {
+ fprintf(fh, "<packet foreground='#%02x%02x%02x' background='#%02x%02x%02x'>\n",
+ cfp->fg_color.red, cfp->fg_color.green, cfp->fg_color.blue,
+ cfp->bg_color.red, cfp->bg_color.green, cfp->bg_color.blue);
+ }
+ else {
+ fprintf(fh, "<packet>\n");
+ }
for (i = 0; i < edt->pi.cinfo->num_cols; i++) {
fprintf(fh, "<section>");
diff --git a/epan/print.h b/epan/print.h
index 6dedc30878..bfa2ab482a 100644
--- a/epan/print.h
+++ b/epan/print.h
@@ -92,7 +92,7 @@ WS_DLL_PUBLIC gboolean proto_tree_print(print_dissections_e print_dissections,
WS_DLL_PUBLIC gboolean print_hex_data(print_stream_t *stream, epan_dissect_t *edt);
WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const gchar* filename);
-WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh);
+WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh, gboolean use_color);
WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
WS_DLL_PUBLIC void write_json_preamble(FILE *fh);
@@ -111,7 +111,7 @@ WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields,
epan_dissect_t *edt, FILE *fh);
WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
-WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh);
+WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh, gboolean use_color);
WS_DLL_PUBLIC void write_psml_finale(FILE *fh);
WS_DLL_PUBLIC void write_csv_column_titles(column_info *cinfo, FILE *fh);
diff --git a/file.c b/file.c
index 7cbab798ee..a0b4784100 100644
--- a/file.c
+++ b/file.c
@@ -2547,7 +2547,7 @@ write_pdml_packet(capture_file *cf, frame_data *fdata,
epan_dissect_run(&args->edt, cf->cd_t, phdr, frame_tvbuff_new(fdata, pd), fdata, NULL);
/* Write out the information in that tree. */
- write_pdml_proto_tree(NULL, NULL, PF_NONE, &args->edt, args->fh);
+ write_pdml_proto_tree(NULL, NULL, PF_NONE, &args->edt, args->fh, FALSE);
epan_dissect_reset(&args->edt);
@@ -2624,7 +2624,7 @@ write_psml_packet(capture_file *cf, frame_data *fdata,
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
/* Write out the column information. */
- write_psml_columns(&args->edt, args->fh);
+ write_psml_columns(&args->edt, args->fh, FALSE);
epan_dissect_reset(&args->edt);
diff --git a/tfshark.c b/tfshark.c
index 551a87bef0..8eb591654c 100644
--- a/tfshark.c
+++ b/tfshark.c
@@ -1999,7 +1999,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
break;
case WRITE_XML:
- write_psml_columns(edt, stdout);
+ write_psml_columns(edt, stdout, FALSE);
return !ferror(stdout);
case WRITE_FIELDS: /*No non-verbose "fields" format */
g_assert_not_reached();
@@ -2022,7 +2022,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
break;
case WRITE_XML:
- write_pdml_proto_tree(NULL, NULL, PF_NONE, edt, stdout);
+ write_pdml_proto_tree(NULL, NULL, PF_NONE, edt, stdout, FALSE);
printf("\n");
return !ferror(stdout);
case WRITE_FIELDS:
diff --git a/tshark.c b/tshark.c
index 1c4c618a3f..eae9acf34e 100644
--- a/tshark.c
+++ b/tshark.c
@@ -444,6 +444,8 @@ print_usage(FILE *output)
fprintf(output, " a directory named \"destdir\"\n");
fprintf(output, " --color color output text similarly to the Wireshark GUI,\n");
fprintf(output, " requires a terminal with 24-bit color support\n");
+ fprintf(output, " Also supplies color attributes to pdml and psml formats\n");
+ fprintf(output, " (Note that attributes are nonstandard)\n");
fprintf(output, "\n");
fprintf(output, "Miscellaneous:\n");
@@ -3863,7 +3865,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
break;
case WRITE_XML:
- write_psml_columns(edt, stdout);
+ write_psml_columns(edt, stdout, dissect_color);
return !ferror(stdout);
case WRITE_FIELDS: /*No non-verbose "fields" format */
case WRITE_JSON:
@@ -3889,7 +3891,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
break;
case WRITE_XML:
- write_pdml_proto_tree(output_fields, protocolfilter, protocolfilter_flags, edt, stdout);
+ write_pdml_proto_tree(output_fields, protocolfilter, protocolfilter_flags, edt, stdout, dissect_color);
printf("\n");
return !ferror(stdout);
case WRITE_FIELDS: