aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-06-08 08:50:51 +0000
committerGuy Harris <guy@alum.mit.edu>2001-06-08 08:50:51 +0000
commit2da9bb269610cd399b161fb521a53a21a9a967a8 (patch)
treed90e725c6804ed82b4e546e7bffc90c984551d9f
parent14c9f7464a698c13c73a1b255f127c2d08fe431a (diff)
When printing the contents of a raw-data field, don't use the raw data
of the current frame as the source, use the raw data of the tvbuff that's the data source of that field. svn path=/trunk/; revision=3531
-rw-r--r--file.c4
-rw-r--r--gtk/print_dlg.c7
-rw-r--r--print.c53
-rw-r--r--print.h7
-rw-r--r--tethereal.c4
5 files changed, 54 insertions, 21 deletions
diff --git a/file.c b/file.c
index 6b83244346..e096b35d29 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.239 2001/06/08 06:27:15 guy Exp $
+ * $Id: file.c,v 1.240 2001/06/08 08:50:49 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1236,7 +1236,7 @@ print_packets(capture_file *cf, print_args_t *print_args)
/* Print the information in that tree. */
proto_tree_print(FALSE, print_args, (GNode *)protocol_tree,
- cf->pd, fdata, cf->print_fh);
+ fdata, cf->print_fh);
proto_tree_free(protocol_tree);
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index 5ef506cf67..5804a41bc0 100644
--- a/gtk/print_dlg.c
+++ b/gtk/print_dlg.c
@@ -1,12 +1,11 @@
/* print_dlg.c
* Dialog boxes for printing
*
- * $Id: print_dlg.c,v 1.22 2000/11/21 23:54:10 guy Exp $
+ * $Id: print_dlg.c,v 1.23 2001/06/08 08:50:51 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -576,7 +575,7 @@ file_print_packet_cmd_cb(GtkWidget *widget, gpointer data) {
print_args.print_summary = FALSE;
print_args.print_hex = FALSE;
print_args.expand_all = TRUE;
- proto_tree_print(TRUE, &print_args, (GNode*) cfile.protocol_tree, cfile.pd,
+ proto_tree_print(TRUE, &print_args, (GNode*) cfile.protocol_tree,
cfile.current_frame, fh);
print_finale(fh, prefs.pr_format);
close_print_dest(print_args.to_file, fh);
diff --git a/print.c b/print.c
index 42792faa4f..fea9b3dac0 100644
--- a/print.c
+++ b/print.c
@@ -1,14 +1,13 @@
/* print.c
* Routines for printing packet analysis trees.
*
- * $Id: print.c,v 1.33 2001/05/16 21:32:04 ashokn Exp $
+ * $Id: print.c,v 1.34 2001/06/08 08:50:49 guy Exp $
*
* Gilbert Ramirez <gram@xiexie.org>
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -40,6 +39,7 @@
#include "print.h"
#include "ps.h"
#include "util.h"
+#include "tvbuff.h"
static void proto_tree_print_node_text(GNode *node, gpointer data);
static void proto_tree_print_node_ps(GNode *node, gpointer data);
@@ -56,7 +56,7 @@ extern int proto_data; /* in packet-data.c */
typedef struct {
int level;
FILE *fh;
- const guint8 *pd;
+ GSList *src_list;
gboolean print_all_levels;
gboolean print_hex_for_data;
char_enc encoding;
@@ -97,14 +97,14 @@ void print_finale(FILE *fh, gint format)
}
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)
+ GNode *protocol_tree, frame_data *fd, FILE *fh)
{
print_data data;
/* Create the output */
data.level = 0;
data.fh = fh;
- data.pd = pd;
+ data.src_list = fd->data_src;
data.encoding = fd->flags.encoding;
data.print_all_levels = print_args->expand_all;
data.print_hex_for_data = !print_args->print_hex;
@@ -120,6 +120,30 @@ void proto_tree_print(gboolean print_one_packet, print_args_t *print_args,
}
}
+/*
+ * Find the data source tvbuff with a specified name, and return a
+ * pointer to the data in it.
+ */
+static const guint8 *
+find_data_source(GSList *src_list, gchar *ds_name)
+{
+ GSList *src;
+ tvbuff_t *src_tvb;
+ guint src_tvb_len;
+
+ for (src = src_list; src != NULL; src = g_slist_next(src)) {
+ src_tvb = src->data;
+ if (strcmp(ds_name, tvb_get_name(src_tvb)) == 0) {
+ /*
+ * Found it.
+ */
+ src_tvb_len = tvb_length(src_tvb);
+ return tvb_get_ptr(src_tvb, 0, src_tvb_len);
+ }
+ }
+ return NULL; /* not found */
+}
+
/* Print a tree's data, and any child nodes, in plain text */
static
void proto_tree_print_node_text(GNode *node, gpointer data)
@@ -129,6 +153,7 @@ void proto_tree_print_node_text(GNode *node, gpointer data)
int i;
int num_spaces;
char space[41];
+ const guint8 *pd;
gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
@@ -161,9 +186,14 @@ void proto_tree_print_node_text(GNode *node, gpointer data)
/* 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_text(pdata->fh, &pdata->pd[fi->start],
+ if (fi->hfinfo->id == proto_data && pdata->print_hex_for_data) {
+ /*
+ * Find the data source tvbuff for this field.
+ */
+ pd = find_data_source(pdata->src_list, fi->ds_name);
+ print_hex_data_text(pdata->fh, &pd[fi->start],
fi->length, pdata->encoding);
+ }
/* If we're printing all levels, or if this level is expanded,
recurse into the subtree, if it exists. */
@@ -264,6 +294,7 @@ void proto_tree_print_node_ps(GNode *node, gpointer data)
print_data *pdata = (print_data*) data;
gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
+ const guint8 *pd;
char psbuffer[MAX_LINE_LENGTH]; /* static sized buffer! */
if (!fi->visible)
@@ -285,7 +316,11 @@ void proto_tree_print_node_ps(GNode *node, gpointer data)
/* 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_ps(pdata->fh, &pdata->pd[fi->start], fi->length,
+ /*
+ * Find the data source tvbuff for this field.
+ */
+ pd = find_data_source(pdata->src_list, fi->ds_name);
+ print_hex_data_ps(pdata->fh, &pd[fi->start], fi->length,
pdata->encoding);
}
diff --git a/print.h b/print.h
index 62845ed4d5..c07e3dc683 100644
--- a/print.h
+++ b/print.h
@@ -1,14 +1,13 @@
/* print.h
* Definitions for printing packet analysis trees.
*
- * $Id: print.h,v 1.21 2001/03/23 18:44:20 jfoster Exp $
+ * $Id: print.h,v 1.22 2001/06/08 08:50:49 guy Exp $
*
* Gilbert Ramirez <gram@xiexie.org>
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -53,7 +52,7 @@ void close_print_dest(int to_file, FILE *fh);
void print_preamble(FILE *fh, gint format);
void print_finale(FILE *fh, gint format);
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);
+ GNode *protocol_tree, frame_data *fd, FILE *fh);
void print_hex_data(FILE *fh, gint format, frame_data *fd);
void print_line(FILE *fh, gint format, char *line);
diff --git a/tethereal.c b/tethereal.c
index ba0b089831..ff6722c75f 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.85 2001/06/08 06:27:16 guy Exp $
+ * $Id: tethereal.c,v 1.86 2001/06/08 08:50:49 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1169,7 +1169,7 @@ wtap_dispatch_cb_print(u_char *user, const struct wtap_pkthdr *phdr, int offset,
print_args.print_hex = print_hex;
print_args.expand_all = TRUE;
proto_tree_print(FALSE, &print_args, (GNode *)protocol_tree,
- buf, &fdata, stdout);
+ &fdata, stdout);
if (!print_hex) {
/* "print_hex_data()" will put out a leading blank line, as well
as a trailing one; print one here, to separate the packets,