Add preference for placement of AH payload, at same level or in subtree.

Move max_len settings in various col_* functions outside of loop.

Add 'writable' flag to col_info. check_col() honors its. dissect_packet()
sets it as TRUE. dissect_ah() optionally sets it to FALSE.

Add col_set_writable() function to set the 'writable' flag. Accepts
frame_data arg just like the rest of the column functions. It checks to
make sure fd->cinfo is not NULL.

svn path=/trunk/; revision=2125
This commit is contained in:
Gilbert Ramirez 2000-07-08 10:46:23 +00:00
parent e6fea28e9b
commit 57d8e47ad0
3 changed files with 67 additions and 25 deletions

View File

@ -1,7 +1,7 @@
/* packet-ipsec.c
* Routines for IPsec/IPComp packet disassembly
*
* $Id: packet-ipsec.c,v 1.17 2000/06/05 03:21:02 gram Exp $
* $Id: packet-ipsec.c,v 1.18 2000/07/08 10:46:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -42,6 +42,10 @@
#include "packet-ipsec.h"
#include "packet-ip.h"
#include "resolv.h"
#include "prefs.h"
/* Place AH payload in sub tree */
gboolean g_ah_payload_in_subtree = FALSE;
static int proto_ah = -1;
static int hf_ah_spi = -1;
@ -144,7 +148,7 @@ dissect_ah_old(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
void
dissect_ah(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
proto_tree *ah_tree;
proto_tree *ah_tree, *next_tree = NULL;
proto_item *ti;
struct newah ah;
int advance;
@ -176,15 +180,27 @@ dissect_ah(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
(guint32)ntohl(ah.ah_seq));
proto_tree_add_text(ah_tree, NullTVB, offset + sizeof(ah), (ah.ah_len - 1) << 2,
"ICV");
/* Decide where to place next protocol decode */
if (g_ah_payload_in_subtree) {
next_tree = ah_tree;
}
else {
next_tree = tree;
}
}
/* start of the new header (could be a extension header) */
offset += advance;
/* do lookup with the subdissector table */
if (!dissector_try_port(ip_dissector_table, ah.ah_nxt, pd, offset, fd, tree)) {
dissect_data(pd, offset, fd, tree);
}
if (g_ah_payload_in_subtree) {
col_set_writable(fd, FALSE);
}
/* do lookup with the subdissector table */
if (!dissector_try_port(ip_dissector_table, ah.ah_nxt, pd, offset, fd, next_tree)) {
dissect_data(pd, offset, fd, next_tree);
}
}
static void
@ -317,6 +333,8 @@ proto_register_ipsec(void)
&ett_ipcomp,
};
module_t *ah_module;
proto_ah = proto_register_protocol("Authentication Header", "ah");
proto_register_field_array(proto_ah, hf_ah, array_length(hf_ah));
@ -327,6 +345,13 @@ proto_register_ipsec(void)
proto_register_field_array(proto_ipcomp, hf_ipcomp, array_length(hf_ipcomp));
proto_register_subtree_array(ett, array_length(ett));
/* Register a configuration option for placement of AH payload dissection */
ah_module = prefs_register_module("ah", "AH", NULL);
prefs_register_bool_preference(ah_module, "place_ah_payload_in_subtree",
"Place AH payload in subtree",
"Whether the AH payload decode should be placed in a subtree",
&g_ah_payload_in_subtree);
}
void

View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.95 2000/06/27 04:35:45 guy Exp $
* $Id: packet.c,v 1.96 2000/07/08 10:46:21 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -694,13 +694,21 @@ decode_numeric_bitfield(guint32 val, guint32 mask, int width,
return buf;
}
void
col_set_writable(frame_data *fd, gboolean writable)
{
if (fd->cinfo) {
fd->cinfo->writable = writable;
}
}
/* Checks to see if a particular packet information element is needed for
the packet list */
gint
check_col(frame_data *fd, gint el) {
int i;
if (fd->cinfo) {
if (fd->cinfo && fd->cinfo->writable) {
for (i = 0; i < fd->cinfo->num_cols; i++) {
if (fd->cinfo->fmt_matx[i][el])
return TRUE;
@ -715,14 +723,15 @@ col_add_fstr(frame_data *fd, gint el, gchar *format, ...) {
va_list ap;
int i;
size_t max_len;
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
va_start(ap, format);
for (i = 0; i < fd->cinfo->num_cols; i++) {
if (fd->cinfo->fmt_matx[i][el]) {
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
vsnprintf(fd->cinfo->col_data[i], max_len, format, ap);
}
}
@ -733,12 +742,13 @@ col_add_str(frame_data *fd, gint el, const gchar* str) {
int i;
size_t max_len;
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
for (i = 0; i < fd->cinfo->num_cols; i++) {
if (fd->cinfo->fmt_matx[i][el]) {
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
strncpy(fd->cinfo->col_data[i], str, max_len);
fd->cinfo->col_data[i][max_len - 1] = 0;
}
@ -752,14 +762,15 @@ col_append_fstr(frame_data *fd, gint el, gchar *format, ...) {
int i;
size_t len, max_len;
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
va_start(ap, format);
for (i = 0; i < fd->cinfo->num_cols; i++) {
if (fd->cinfo->fmt_matx[i][el]) {
len = strlen(fd->cinfo->col_data[i]);
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
vsnprintf(&fd->cinfo->col_data[i][len], max_len - len, format, ap);
}
}
@ -770,13 +781,14 @@ col_append_str(frame_data *fd, gint el, gchar* str) {
int i;
size_t len, max_len;
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
for (i = 0; i < fd->cinfo->num_cols; i++) {
if (fd->cinfo->fmt_matx[i][el]) {
len = strlen(fd->cinfo->col_data[i]);
if (el == COL_INFO)
max_len = COL_MAX_LEN;
else
max_len = COL_MAX_INFO_LEN;
strncat(fd->cinfo->col_data[i], str, max_len - len);
fd->cinfo->col_data[i][max_len - 1] = 0;
}
@ -1173,6 +1185,8 @@ dissect_packet(union wtap_pseudo_header *pseudo_header, const u_char *pd,
pi.compat_top_tvb = tvb;
pi.pseudo_header = pseudo_header;
col_set_writable(fd, TRUE);
TRY {
switch (fd->lnk_t) {
case WTAP_ENCAP_ETHERNET :

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.189 2000/05/26 22:08:16 guy Exp $
* $Id: packet.h,v 1.190 2000/07/08 10:46:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -94,6 +94,7 @@ typedef struct _column_info {
gint *col_width; /* Column widths to use during a "-S" capture */
gchar **col_title; /* Column titles */
gchar **col_data; /* Column data */
gboolean writable; /* Are we stil writing to the columns? */
} column_info;
#define COL_MAX_LEN 256
@ -302,6 +303,8 @@ const char *decode_enumerated_bitfield(guint32 val, guint32 mask, int width,
const value_string *tab, const char *fmt);
const char *decode_numeric_bitfield(guint32 val, guint32 mask, int width,
const char *fmt);
void col_set_writable(frame_data *fd, gboolean writable);
gint check_col(frame_data *, gint);
#if __GNUC__ == 2
void col_add_fstr(frame_data *, gint, gchar *, ...)