diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2000-07-08 10:46:23 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2000-07-08 10:46:23 +0000 |
commit | 57d8e47ad0ef7be6aa8e9d378d9aac2d6468ed27 (patch) | |
tree | 021b7f33838763b124f997460a0242be751b4704 /packet.c | |
parent | e6fea28e9b7a055c845b9201a5490b59fce263f0 (diff) |
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
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 50 |
1 files changed, 32 insertions, 18 deletions
@@ -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; - for (i = 0; i < fd->cinfo->num_cols; i++) { - if (fd->cinfo->fmt_matx[i][el]) { - if (el == COL_INFO) + if (el == COL_INFO) max_len = COL_MAX_INFO_LEN; - else + else max_len = COL_MAX_LEN; + + for (i = 0; i < fd->cinfo->num_cols; i++) { + if (fd->cinfo->fmt_matx[i][el]) { 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 : |