forked from osmocom/wireshark
"redraw_hex_dump()" can't use "cfile.pd" or "cfile.current_frame", as it
may be redrawing a packet window that displays a frame other than the current frame; give it arguments to specify the raw frame data and "frame_data" structure for the frame. This requires that each packet window have, associated with it, a pointer to the "frame_data" structure; that replaces the "cap_len" and "encoding" fields in a "PacketWinData" structure, as those are just copies of fields from the frame's "frame_data" structure. "packet_hex_print()" needn't be passed both the start and length values from a "field_info" structure - just pass it a pointer to that structure, or NULL for "no field is selected in the packet". It also needn't, any longer, be passed the "cap_len" and "flags.encoding" fields of a "frame_data" structure - just pass it a pointer to that structure. In "redraw_hex_dump_all()", don't redraw the hex dump pane of the main window if there is no current frame. svn path=/trunk/; revision=2404
This commit is contained in:
parent
6e04ac48f9
commit
f0efbd1a02
5
file.c
5
file.c
|
@ -1,7 +1,7 @@
|
|||
/* file.c
|
||||
* File I/O routines
|
||||
*
|
||||
* $Id: file.c,v 1.215 2000/09/08 10:58:51 guy Exp $
|
||||
* $Id: file.c,v 1.216 2000/09/09 10:26:35 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -1556,8 +1556,7 @@ select_packet(capture_file *cf, int row)
|
|||
/* Display the GUI protocol tree and hex dump. */
|
||||
clear_tree_and_hex_views();
|
||||
proto_tree_draw(cf->protocol_tree, tree_view);
|
||||
packet_hex_print(GTK_TEXT(byte_view), cf->pd, cf->current_frame->cap_len,
|
||||
-1, -1, cf->current_frame->flags.encoding);
|
||||
packet_hex_print(GTK_TEXT(byte_view), cf->pd, cf->current_frame, NULL);
|
||||
|
||||
/* A packet is selected. */
|
||||
set_menus_for_selected_packet(TRUE);
|
||||
|
|
10
gtk/main.c
10
gtk/main.c
|
@ -1,6 +1,6 @@
|
|||
/* main.c
|
||||
*
|
||||
* $Id: main.c,v 1.155 2000/09/08 10:59:15 guy Exp $
|
||||
* $Id: main.c,v 1.156 2000/09/09 10:26:53 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -571,8 +571,8 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
|
|||
g_free(help_str);
|
||||
}
|
||||
|
||||
packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len,
|
||||
finfo->start, finfo->length, cfile.current_frame->flags.encoding);
|
||||
packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame,
|
||||
finfo);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -581,8 +581,8 @@ tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer us
|
|||
gtk_statusbar_pop(GTK_STATUSBAR(info_bar), help_ctx);
|
||||
finfo_selected = NULL;
|
||||
set_menus_for_selected_tree_row(FALSE);
|
||||
packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len,
|
||||
-1, -1, cfile.current_frame->flags.encoding);
|
||||
packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void collapse_all_cb(GtkWidget *widget, gpointer data) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
|
||||
*
|
||||
* $Id: packet_win.c,v 1.14 2000/09/08 10:59:18 guy Exp $
|
||||
* $Id: packet_win.c,v 1.15 2000/09/09 10:26:56 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -70,8 +70,7 @@
|
|||
|
||||
/* Data structure holding information about a packet-detail window. */
|
||||
struct PacketWinData {
|
||||
gint cap_len;
|
||||
gint encoding;
|
||||
frame_data *frame; /* The frame being displayed */
|
||||
union wtap_pseudo_header pseudo_header; /* Pseudo-header for packet */
|
||||
guint8 *pd; /* Data for packet */
|
||||
proto_tree *protocol_tree; /* Protocol tree for packet */
|
||||
|
@ -166,14 +165,13 @@ create_new_window ( char *Title, gint tv_size, gint bv_size){
|
|||
/* Allocate data structure to represent this window. */
|
||||
DataPtr = (struct PacketWinData *) g_malloc(sizeof(struct PacketWinData));
|
||||
|
||||
DataPtr->cap_len = cfile.current_frame->cap_len;
|
||||
DataPtr->encoding = cfile.current_frame->flags.encoding;
|
||||
DataPtr->frame = cfile.current_frame;
|
||||
memcpy(&DataPtr->pseudo_header, &cfile.pseudo_header, sizeof DataPtr->pseudo_header);
|
||||
DataPtr->pd = g_malloc(DataPtr->cap_len);
|
||||
memcpy(DataPtr->pd, cfile.pd, DataPtr->cap_len);
|
||||
DataPtr->pd = g_malloc(DataPtr->frame->cap_len);
|
||||
memcpy(DataPtr->pd, cfile.pd, DataPtr->frame->cap_len);
|
||||
DataPtr->protocol_tree = proto_tree_create_root();
|
||||
proto_tree_is_visible = TRUE;
|
||||
dissect_packet(&DataPtr->pseudo_header, DataPtr->pd, cfile.current_frame,
|
||||
dissect_packet(&DataPtr->pseudo_header, DataPtr->pd, DataPtr->frame,
|
||||
DataPtr->protocol_tree);
|
||||
proto_tree_is_visible = FALSE;
|
||||
DataPtr->main = main_w;
|
||||
|
@ -195,8 +193,7 @@ create_new_window ( char *Title, gint tv_size, gint bv_size){
|
|||
|
||||
/* draw the protocol tree & print hex data */
|
||||
proto_tree_draw(DataPtr->protocol_tree, tree_view);
|
||||
packet_hex_print( GTK_TEXT(byte_view), DataPtr->pd,
|
||||
DataPtr->cap_len, -1, -1, DataPtr->encoding);
|
||||
packet_hex_print(GTK_TEXT(byte_view), DataPtr->pd, DataPtr->frame, NULL);
|
||||
|
||||
DataPtr->finfo_selected = NULL;
|
||||
gtk_widget_show(main_w);
|
||||
|
@ -230,8 +227,7 @@ new_tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column,
|
|||
DataPtr->finfo_selected = finfo;
|
||||
|
||||
packet_hex_print(GTK_TEXT(DataPtr->byte_view), DataPtr->pd,
|
||||
DataPtr->cap_len, finfo->start, finfo->length,
|
||||
DataPtr->encoding);
|
||||
DataPtr->frame, finfo);
|
||||
|
||||
}
|
||||
|
||||
|
@ -247,7 +243,7 @@ new_tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column,
|
|||
|
||||
DataPtr->finfo_selected = NULL;
|
||||
packet_hex_print(GTK_TEXT(DataPtr->byte_view), DataPtr->pd,
|
||||
DataPtr->cap_len, -1, -1, DataPtr->encoding);
|
||||
DataPtr->frame, NULL);
|
||||
}
|
||||
|
||||
/* Functions called from elsewhere to act on all popup packet windows. */
|
||||
|
@ -274,7 +270,8 @@ redraw_hex_dump_cb(gpointer data, gpointer user_data)
|
|||
{
|
||||
struct PacketWinData *DataPtr = (struct PacketWinData *)data;
|
||||
|
||||
redraw_hex_dump(DataPtr->byte_view, DataPtr->finfo_selected);
|
||||
redraw_hex_dump(DataPtr->byte_view, DataPtr->pd,
|
||||
DataPtr->frame, DataPtr->finfo_selected);
|
||||
}
|
||||
|
||||
/* Redraw the hex dump part of all the popup packet windows. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* proto_draw.c
|
||||
* Routines for GTK+ packet display
|
||||
*
|
||||
* $Id: proto_draw.c,v 1.20 2000/09/08 10:59:19 guy Exp $
|
||||
* $Id: proto_draw.c,v 1.21 2000/09/09 10:26:56 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -60,22 +60,16 @@ proto_tree_draw_node(GNode *node, gpointer data);
|
|||
|
||||
/* Redraw a given byte view window. */
|
||||
void
|
||||
redraw_hex_dump(GtkWidget *bv, field_info *finfo)
|
||||
redraw_hex_dump(GtkWidget *bv, guint8 *pd, frame_data *fd, field_info *finfo)
|
||||
{
|
||||
if (finfo != NULL) {
|
||||
packet_hex_print(GTK_TEXT(bv), cfile.pd, cfile.current_frame->cap_len,
|
||||
finfo->start, finfo->length,
|
||||
cfile.current_frame->flags.encoding);
|
||||
} else {
|
||||
packet_hex_print(GTK_TEXT(bv), cfile.pd, cfile.current_frame->cap_len,
|
||||
-1, -1, cfile.current_frame->flags.encoding);
|
||||
}
|
||||
packet_hex_print(GTK_TEXT(bv), pd, fd, finfo);
|
||||
}
|
||||
|
||||
void
|
||||
redraw_hex_dump_all(void)
|
||||
{
|
||||
redraw_hex_dump(byte_view, finfo_selected);
|
||||
if (cfile.current_frame != NULL)
|
||||
redraw_hex_dump(byte_view, cfile.pd, cfile.current_frame, finfo_selected);
|
||||
redraw_hex_dump_packet_wins();
|
||||
}
|
||||
|
||||
|
@ -107,16 +101,24 @@ create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
|
|||
}
|
||||
|
||||
void
|
||||
packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
||||
char_enc encoding) {
|
||||
packet_hex_print(GtkText *bv, guint8 *pd, frame_data *fd, field_info *finfo)
|
||||
{
|
||||
gint i = 0, j, k, cur;
|
||||
guchar line[128], hexchars[] = "0123456789abcdef", c = '\0';
|
||||
GdkFont *cur_font, *new_font;
|
||||
gint bstart, blen;
|
||||
gint bend = -1;
|
||||
|
||||
GdkColor *fg, *bg;
|
||||
gboolean reverse, newreverse;
|
||||
|
||||
if (finfo != NULL) {
|
||||
bstart = finfo->start;
|
||||
blen = finfo->length;
|
||||
} else {
|
||||
bstart = -1;
|
||||
blen = -1;
|
||||
}
|
||||
|
||||
/* Freeze the text for faster display */
|
||||
gtk_text_freeze(bv);
|
||||
|
||||
|
@ -133,7 +135,7 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
|||
bend = bstart + blen;
|
||||
}
|
||||
|
||||
while (i < len) {
|
||||
while (i < fd->cap_len) {
|
||||
/* Print the line number */
|
||||
sprintf(line, "%04x ", i);
|
||||
|
||||
|
@ -149,7 +151,7 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
|||
cur = 0;
|
||||
/* Print the hex bit */
|
||||
while (i < k) {
|
||||
if (i < len) {
|
||||
if (i < fd->cap_len) {
|
||||
line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
|
||||
line[cur++] = hexchars[pd[i] & 0x0f];
|
||||
} else {
|
||||
|
@ -196,11 +198,11 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
|||
fg = reverse ? &WHITE : &BLACK;
|
||||
bg = reverse ? &BLACK : &WHITE;
|
||||
while (i < k) {
|
||||
if (i < len) {
|
||||
if (encoding == CHAR_ASCII) {
|
||||
if (i < fd->cap_len) {
|
||||
if (fd->flags.encoding == CHAR_ASCII) {
|
||||
c = pd[i];
|
||||
}
|
||||
else if (encoding == CHAR_EBCDIC) {
|
||||
else if (fd->flags.encoding == CHAR_EBCDIC) {
|
||||
c = EBCDIC_to_ASCII1(pd[i]);
|
||||
}
|
||||
else {
|
||||
|
@ -250,7 +252,7 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
|||
cur = 0;
|
||||
/* Print the hex bit */
|
||||
while (i < k) {
|
||||
if (i < len) {
|
||||
if (i < fd->cap_len) {
|
||||
line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
|
||||
line[cur++] = hexchars[pd[i] & 0x0f];
|
||||
} else {
|
||||
|
@ -276,11 +278,11 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
|||
/* Print the ASCII bit */
|
||||
cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
|
||||
while (i < k) {
|
||||
if (i < len) {
|
||||
if (encoding == CHAR_ASCII) {
|
||||
if (i < fd->cap_len) {
|
||||
if (fd->flags.encoding == CHAR_ASCII) {
|
||||
c = pd[i];
|
||||
}
|
||||
else if (encoding == CHAR_EBCDIC) {
|
||||
else if (fd->flags.encoding == CHAR_EBCDIC) {
|
||||
c = EBCDIC_to_ASCII1(pd[i]);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* gtkpacket.h
|
||||
* Definitions for GTK+ packet display structures and routines
|
||||
*
|
||||
* $Id: proto_draw.h,v 1.9 2000/09/08 10:59:21 guy Exp $
|
||||
* $Id: proto_draw.h,v 1.10 2000/09/09 10:26:58 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -27,11 +27,12 @@
|
|||
#ifndef __GTKPACKET_H__
|
||||
#define __GTKPACKET_H__
|
||||
|
||||
void redraw_hex_dump(GtkWidget *bv, field_info *finfo);
|
||||
void redraw_hex_dump(GtkWidget *bv, guint8 *pd, frame_data *fd,
|
||||
field_info *finfo);
|
||||
void redraw_hex_dump_all(void);
|
||||
void create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
|
||||
GtkWidget **bv_scrollw_p, int pos);
|
||||
void packet_hex_print(GtkText *, guint8 *, gint, gint, gint, char_enc);
|
||||
void packet_hex_print(GtkText *, guint8 *, frame_data *, field_info *);
|
||||
|
||||
#define E_TREEINFO_FIELD_INFO_KEY "tree_info_finfo"
|
||||
|
||||
|
|
Loading…
Reference in New Issue