aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--display.c4
-rw-r--r--file.c9
-rw-r--r--file.h12
-rw-r--r--globals.h6
-rw-r--r--gtk/keys.h5
-rw-r--r--gtk/print_dlg.c47
-rw-r--r--packet.c3
-rw-r--r--print.c27
-rw-r--r--print.h18
9 files changed, 85 insertions, 46 deletions
diff --git a/display.c b/display.c
index ede240c9c1..218b103c5b 100644
--- a/display.c
+++ b/display.c
@@ -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;
diff --git a/file.c b/file.c
index 97890c7b32..d69b1d813a 100644
--- a/file.c
+++ b/file.c
@@ -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;
}
diff --git a/file.h b/file.h
index 623c7cf153..17ed329442 100644
--- a/file.h
+++ b/file.h
@@ -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 *);
diff --git a/globals.h b/globals.h
index 4cd43d8217..bd4eaaa295 100644
--- a/globals.h
+++ b/globals.h
@@ -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);
}
diff --git a/packet.c b/packet.c
index 37056f2981..dcf12ec83e 100644
--- a/packet.c
+++ b/packet.c
@@ -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;
diff --git a/print.c b/print.c
index 6f7c659049..fd89b2c267 100644
--- a/print.c
+++ b/print.c
@@ -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;
diff --git a/print.h b/print.h
index 64455dd23b..3be9128641 100644
--- a/print.h
+++ b/print.h
@@ -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 */