diff options
author | Guy Harris <guy@alum.mit.edu> | 1999-09-29 22:19:24 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 1999-09-29 22:19:24 +0000 |
commit | e4f7809763fd5590e28107184445ed1bbd3df971 (patch) | |
tree | 40ff25b9f7aa331a5f7530fea5daca6cb006f073 | |
parent | 7b732a9f80f3ff44071520c9ff1101a012fc7b28 (diff) |
Add an item to the "File/Print" dialog box to ask that the full hex data
of the packet be printed (this is only done if "Print detail" is
selected; it should be grayed out of "Print summary" is selected).
If that item is selected, suppress the hex printing of uninterpreted
data items in the protocol tree.
Move some GTK+ keys not used outside of "gtk/print_dlg.c" from
"gtk/keys.h" into "gtk/print_dlg.c".
svn path=/trunk/; revision=736
-rw-r--r-- | display.c | 4 | ||||
-rw-r--r-- | file.c | 9 | ||||
-rw-r--r-- | file.h | 12 | ||||
-rw-r--r-- | globals.h | 6 | ||||
-rw-r--r-- | gtk/keys.h | 5 | ||||
-rw-r--r-- | gtk/print_dlg.c | 47 | ||||
-rw-r--r-- | packet.c | 3 | ||||
-rw-r--r-- | print.c | 27 | ||||
-rw-r--r-- | print.h | 18 |
9 files changed, 85 insertions, 46 deletions
@@ -1,7 +1,7 @@ /* display.c * Routines for packet display windows * - * $Id: display.c,v 1.11 1999/09/26 14:39:11 deniel Exp $ + * $Id: display.c,v 1.12 1999/09/29 22:19:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -76,11 +76,11 @@ # include <sys/sockio.h> #endif +#include "globals.h" #include "timestamp.h" #include "packet.h" #include "file.h" #include "display.h" -#include "globals.h" extern capture_file cf; extern GtkWidget *packet_list; @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.99 1999/09/29 14:41:34 gram Exp $ + * $Id: file.c,v 1.100 1999/09/29 22:19:14 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -871,11 +871,16 @@ print_packets(capture_file *cf, print_args_t *print_args) dissect_packet(cf->pd, fd, protocol_tree); /* Print the information in that tree. */ - proto_tree_print(FALSE, print_args->expand_all, (GNode *)protocol_tree, + proto_tree_print(FALSE, print_args, (GNode *)protocol_tree, cf->pd, fd, cf->print_fh); proto_tree_free(protocol_tree); + if (print_args->print_hex) { + /* Print the full packet data as hex. */ + print_hex_data(cf->print_fh, cf->pd, fd->cap_len); + } + /* Print a blank line if we print anything after this. */ print_separator = TRUE; } @@ -1,7 +1,7 @@ /* file.h * Definitions for file structures and routines * - * $Id: file.h,v 1.46 1999/09/23 04:38:52 ashokn Exp $ + * $Id: file.h,v 1.47 1999/09/29 22:19:13 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -133,16 +133,6 @@ int read_cap_file(capture_file *); int tail_cap_file(char *, capture_file *); /* size_t read_frame_header(capture_file *); */ -typedef struct { - gboolean to_file; /* TRUE if we're printing to a file */ - char *dest; /* if printing to file, pathname; - if not, command string */ - gboolean print_summary; /* TRUE if we should just print summary; - FALSE if we should print protocol tree. */ - gboolean expand_all; /* TRUE if we should expand all levels; - FALSE if we should expand as displayed. */ -} print_args_t; - int print_packets(capture_file *cf, print_args_t *print_args); void filter_packets(capture_file *); void change_time_formats(capture_file *); @@ -1,7 +1,7 @@ /* globals.h * Global defines, etc. * - * $Id: globals.h,v 1.7 1999/09/26 14:39:12 deniel Exp $ + * $Id: globals.h,v 1.8 1999/09/29 22:19:13 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -38,6 +38,10 @@ #include <gtk/gtk.h> #endif +#ifndef __PRINT_H__ +#include "print.h" +#endif + #ifndef __FILE_H__ #include "file.h" #endif diff --git a/gtk/keys.h b/gtk/keys.h index 9b1296c7fa..3d2b26ef40 100644 --- a/gtk/keys.h +++ b/gtk/keys.h @@ -1,7 +1,7 @@ /* keys.h * Key definitions for various objects * - * $Id: keys.h,v 1.5 1999/09/12 23:54:09 guy Exp $ + * $Id: keys.h,v 1.6 1999/09/29 22:19:24 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -36,8 +36,5 @@ #define PRINT_FILE_BT_KEY "printer_file_button" #define PRINT_FILE_TE_KEY "printer_file_entry" #define PRINT_DEST_RB_KEY "printer_destination_radio_button" -#define PRINT_SUMMARY_RB_KEY "printer_summary_radio_button" -#define PRINT_EXPAND_ALL_RB_KEY "printer_expand_all_radio_button" -#define PRINT_AS_DISPLAYED_RB_KEY "printer_as_displayed_radio_button" #endif diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c index 65afa3016c..25c09d1efd 100644 --- a/gtk/print_dlg.c +++ b/gtk/print_dlg.c @@ -1,7 +1,7 @@ /* print_dlg.c * Dialog boxes for printing * - * $Id: print_dlg.c,v 1.6 1999/09/12 23:54:09 guy Exp $ + * $Id: print_dlg.c,v 1.7 1999/09/29 22:19:23 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -63,6 +63,11 @@ static void print_close_cb(GtkWidget *close_bt, gpointer parent_w); */ static int print_to_file; +#define PRINT_SUMMARY_RB_KEY "printer_summary_radio_button" +#define PRINT_HEX_CB_KEY "printer_hex_check_button" +#define PRINT_EXPAND_ALL_RB_KEY "printer_expand_all_radio_button" +#define PRINT_AS_DISPLAYED_RB_KEY "printer_as_displayed_radio_button" + /* Print the capture */ void file_print_cmd_cb(GtkWidget *widget, gpointer data) @@ -79,7 +84,7 @@ file_print_cmd_cb(GtkWidget *widget, gpointer data) GtkWidget *file_bt_hb, *file_bt, *file_te; GSList *dest_grp; GtkWidget *options_hb; - GtkWidget *summary_vb, *summary_rb, *detail_rb; + GtkWidget *print_type_vb, *summary_rb, *detail_rb, *hex_cb; GSList *summary_grp; GtkWidget *expand_vb, *expand_all_rb, *as_displayed_rb; GSList *expand_grp; @@ -202,24 +207,30 @@ file_print_cmd_cb(GtkWidget *widget, gpointer data) gtk_widget_show(options_hb); /* Vertical box into which to put the "Print summary"/"Print detail" - radio buttons. */ - summary_vb = gtk_vbox_new(FALSE, 5); - gtk_container_border_width(GTK_CONTAINER(summary_vb), 5); - gtk_container_add(GTK_CONTAINER(options_hb), summary_vb); - gtk_widget_show(summary_vb); + radio buttons and the "Print hex" check button. */ + print_type_vb = gtk_vbox_new(FALSE, 5); + gtk_container_border_width(GTK_CONTAINER(print_type_vb), 5); + gtk_container_add(GTK_CONTAINER(options_hb), print_type_vb); + gtk_widget_show(print_type_vb); /* "Print summary"/"Print detail" radio buttons */ summary_rb = gtk_radio_button_new_with_label(NULL, "Print summary"); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(summary_rb), FALSE); summary_grp = gtk_radio_button_group(GTK_RADIO_BUTTON(summary_rb)); - gtk_container_add(GTK_CONTAINER(summary_vb), summary_rb); + gtk_container_add(GTK_CONTAINER(print_type_vb), summary_rb); gtk_widget_show(summary_rb); detail_rb = gtk_radio_button_new_with_label(summary_grp, "Print detail"); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(detail_rb), TRUE); gtk_signal_connect(GTK_OBJECT(detail_rb), "toggled", GTK_SIGNAL_FUNC(print_cmd_toggle_detail), NULL); - gtk_container_add(GTK_CONTAINER(summary_vb), detail_rb); + gtk_container_add(GTK_CONTAINER(print_type_vb), detail_rb); gtk_widget_show(detail_rb); + + /* "Print hex" check button. */ + hex_cb = gtk_check_button_new_with_label("Print hex data"); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hex_cb), FALSE); + gtk_container_add(GTK_CONTAINER(print_type_vb), hex_cb); + gtk_widget_show(hex_cb); /* Vertical box into which to put the "Expand all levels"/"Print as displayed" radio buttons. */ @@ -256,6 +267,7 @@ file_print_cmd_cb(GtkWidget *widget, gpointer data) gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_CMD_TE_KEY, cmd_te); gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_FILE_TE_KEY, file_te); gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_SUMMARY_RB_KEY, summary_rb); + gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_HEX_CB_KEY, hex_cb); gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_EXPAND_ALL_RB_KEY, expand_all_rb); gtk_signal_connect(GTK_OBJECT(ok_bt), "clicked", GTK_SIGNAL_FUNC(print_ok_cb), GTK_OBJECT(print_w)); @@ -382,6 +394,10 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w) print_args.print_summary = GTK_TOGGLE_BUTTON (button)->active; button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(ok_bt), + PRINT_HEX_CB_KEY); + print_args.print_hex = GTK_TOGGLE_BUTTON (button)->active; + + button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(ok_bt), PRINT_EXPAND_ALL_RB_KEY); print_args.expand_all = GTK_TOGGLE_BUTTON (button)->active; @@ -418,15 +434,20 @@ print_close_cb(GtkWidget *close_bt, gpointer parent_w) void file_print_packet_cmd_cb(GtkWidget *widget, gpointer data) { FILE *fh; + print_args_t print_args; switch (prefs.pr_dest) { case PR_DEST_CMD: fh = popen(prefs.pr_cmd, "w"); + print_args.to_file = FALSE; + print_args.dest = prefs.pr_cmd; break; case PR_DEST_FILE: fh = fopen(prefs.pr_file, "w"); + print_args.to_file = TRUE; + print_args.dest = prefs.pr_file; break; default: @@ -450,8 +471,12 @@ file_print_packet_cmd_cb(GtkWidget *widget, gpointer data) { } print_preamble(fh); - proto_tree_print(TRUE, TRUE, (GNode*) cf.protocol_tree, cf.pd, cf.fd, fh); + print_args.print_summary = FALSE; + print_args.print_hex = FALSE; + print_args.expand_all = TRUE; + proto_tree_print(TRUE, &print_args, (GNode*) cf.protocol_tree, cf.pd, + cf.fd, fh); print_finale(fh); - close_print_dest(prefs.pr_dest == PR_DEST_FILE, fh); + close_print_dest(print_args.to_file, fh); } @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.44 1999/09/18 15:44:41 deniel Exp $ + * $Id: packet.c,v 1.45 1999/09/29 22:19:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -56,6 +56,7 @@ #endif #include "packet.h" +#include "print.h" #include "file.h" extern capture_file cf; @@ -1,7 +1,7 @@ /* print.c * Routines for printing packet analysis trees. * - * $Id: print.c,v 1.20 1999/09/12 20:23:33 guy Exp $ + * $Id: print.c,v 1.21 1999/09/29 22:19:13 guy Exp $ * * Gilbert Ramirez <gram@verdict.uthscsa.edu> * @@ -43,11 +43,10 @@ #include "ps.h" static void proto_tree_print_node_text(GNode *node, gpointer data); -static void dumpit (FILE *fh, register const u_char *cp, register u_int length); static void proto_tree_print_node_ps(GNode *node, gpointer data); static void ps_clean_string(unsigned char *out, const unsigned char *in, int outbuf_size); -static void dumpit_ps (FILE *fh, register const u_char *cp, register u_int length); +static void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length); extern int proto_data; /* in packet-data.c */ @@ -57,6 +56,7 @@ typedef struct { FILE *fh; const guint8 *pd; gboolean print_all_levels; + gboolean print_hex_for_data; } print_data; FILE *open_print_dest(int to_file, const char *dest) @@ -93,7 +93,7 @@ void print_finale(FILE *fh) print_ps_finale(fh); } -void proto_tree_print(gboolean print_one_packet, gboolean print_all_levels, +void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh) { print_data data; @@ -102,7 +102,10 @@ void proto_tree_print(gboolean print_one_packet, gboolean print_all_levels, data.level = 0; data.fh = fh; data.pd = pd; - data.print_all_levels = print_all_levels; + data.print_all_levels = print_args->expand_all; + data.print_hex_for_data = !print_args->print_hex; + /* If we're printing the entire packet in hex, don't + print uninterpreted data fields in hex as well. */ /* XXX - printing multiple frames in PostScript looks as if it's tricky - you have to deal with page boundaries, I think - @@ -157,9 +160,10 @@ void proto_tree_print_node_text(GNode *node, gpointer data) /* Print the text */ fprintf(pdata->fh, "%s%s\n", space, label_ptr); - /* If it's uninterpreted data, dump it. */ - if (fi->hfinfo->id == proto_data) - dumpit(pdata->fh, &pdata->pd[fi->start], fi->length); + /* 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) + print_hex_data(pdata->fh, &pdata->pd[fi->start], fi->length); /* If we're printing all levels, or if this level is expanded, recurse into the subtree, if it exists. */ @@ -175,8 +179,7 @@ void proto_tree_print_node_text(GNode *node, gpointer data) /* This routine was created by Dan Lasley <DLASLEY@PROMUS.com>, and only slightly modified for ethereal by Gilbert Ramirez. */ -static -void dumpit (FILE *fh, register const u_char *cp, register u_int length) +void print_hex_data(FILE *fh, register const u_char *cp, register u_int length) { register int ad, i, j, k; u_char c; @@ -239,7 +242,7 @@ void proto_tree_print_node_ps(GNode *node, gpointer data) /* If it's uninterpreted data, dump it. */ if (fi->hfinfo->id == proto_data) { print_ps_hex(pdata->fh); - dumpit_ps(pdata->fh, &pdata->pd[fi->start], fi->length); + print_hex_data_ps(pdata->fh, &pdata->pd[fi->start], fi->length); } /* Recurse into the subtree, if it exists */ @@ -280,7 +283,7 @@ void ps_clean_string(unsigned char *out, const unsigned char *in, } static -void dumpit_ps (FILE *fh, register const u_char *cp, register u_int length) +void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length) { register int ad, i, j, k; u_char c; @@ -1,7 +1,7 @@ /* print.h * Definitions for printing packet analysis trees. * - * $Id: print.h,v 1.12 1999/09/12 20:23:34 guy Exp $ + * $Id: print.h,v 1.13 1999/09/29 22:19:13 guy Exp $ * * Gilbert Ramirez <gram@verdict.uthscsa.edu> * @@ -28,13 +28,27 @@ #ifndef __PRINT_H__ #define __PRINT_H__ +typedef struct { + gboolean to_file; /* TRUE if we're printing to a file */ + char *dest; /* if printing to file, pathname; + if not, command string */ + gboolean print_summary; /* TRUE if we should just print summary; + FALSE if we should print protocol tree. */ + gboolean print_hex; /* TRUE if we should also print hex data; + FALSE if we should print only if not dissected. */ + gboolean expand_all; /* TRUE if we should expand all levels; + FALSE if we should expand as displayed. */ +} print_args_t; + /* Functions in print.h */ FILE *open_print_dest(int to_file, const char *dest); void close_print_dest(int to_file, FILE *fh); void print_preamble(FILE *fh); void print_finale(FILE *fh); -void proto_tree_print(gboolean print_one_packet, gboolean print_all_levels, +void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh); +void print_hex_data(FILE *fh, register const u_char *cp, + register u_int length); #endif /* print.h */ |