diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-12-10 00:26:21 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-12-10 00:26:21 +0000 |
commit | 23319ff023bcb144347a1307b958359b5226c699 (patch) | |
tree | b347f1669210e07039ec31051cbb2c5e82422e6b /epan | |
parent | a81a607ed5e3d291940ab75dd82d28d72c222b48 (diff) | |
download | wireshark-23319ff023bcb144347a1307b958359b5226c699.tar.gz wireshark-23319ff023bcb144347a1307b958359b5226c699.tar.bz2 wireshark-23319ff023bcb144347a1307b958359b5226c699.zip |
Move the pointer to the "column_info" structure in the "frame_data"
structure to the "packet_info" structure; only stuff that's permanently
stored with each frame should be in the "frame_data" structure, and the
"column_info" structure is not guaranteed to hold the column values for
that frame at all times - it was only in the "frame_data" structure so
that it could be passed to dissectors, and, as all dissectors are now
passed a pointer to a "packet_info" structure, it could just as well be
put in the "packet_info" structure.
That saves memory, by shrinking the "frame_data" structure (there's one
of those per frame), and also lets us clean up the code a bit.
svn path=/trunk/; revision=4370
Diffstat (limited to 'epan')
-rw-r--r-- | epan/column-utils.c | 293 | ||||
-rw-r--r-- | epan/column-utils.h | 30 | ||||
-rw-r--r-- | epan/epan.c | 6 | ||||
-rw-r--r-- | epan/epan.h | 6 | ||||
-rw-r--r-- | epan/frame_data.h | 33 | ||||
-rw-r--r-- | epan/packet.c | 16 | ||||
-rw-r--r-- | epan/packet.h | 4 | ||||
-rw-r--r-- | epan/packet_info.h | 3 |
8 files changed, 190 insertions, 201 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index 31baabe866..4e57baaa42 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -1,12 +1,11 @@ /* column-utils.c * Routines for column utilities. * - * $Id: column-utils.c,v 1.7 2001/11/21 23:16:23 gram Exp $ + * $Id: column-utils.c,v 1.8 2001/12/10 00:26:16 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 @@ -67,41 +66,33 @@ col_init(column_info *col_info, gint num_cols) col_info->col_buf = (gchar **) g_malloc(sizeof(gchar *) * num_cols); } +#if 0 /* * This function does not appear to be used anywhere... - + */ gboolean -col_get_writable(frame_data *fd) +col_get_writable(column_info *cinfo) { - if (fd) { - - return (fd->cinfo ? fd->cinfo->writable : FALSE); - - } - - return FALSE; - + return (cinfo ? cinfo->writable : FALSE); } - -*/ +#endif void -col_set_writable(frame_data *fd, gboolean writable) +col_set_writable(column_info *cinfo, gboolean writable) { - if (fd->cinfo) { - fd->cinfo->writable = writable; - } + if (cinfo) + 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) { +check_col(column_info *cinfo, gint el) { int i; - if (fd->cinfo && fd->cinfo->writable) { - for (i = 0; i < fd->cinfo->num_cols; i++) { - if (fd->cinfo->fmt_matx[i][el]) + if (cinfo && cinfo->writable) { + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) return TRUE; } } @@ -117,13 +108,13 @@ check_col(frame_data *fd, gint el) { later append to it, as the later append will cause a string copy to be done. */ void -col_clear(frame_data *fd, gint el) { +col_clear(column_info *cinfo, gint el) { int i; - for (i = 0; i < fd->cinfo->num_cols; i++) { - if (fd->cinfo->fmt_matx[i][el]) { - fd->cinfo->col_buf[i][0] = 0; - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) { + cinfo->col_buf[i][0] = 0; + cinfo->col_data[i] = cinfo->col_buf[i]; } } } @@ -131,18 +122,18 @@ col_clear(frame_data *fd, gint el) { /* Use this if "str" points to something that will stay around (and thus needn't be copied). */ void -col_set_str(frame_data *fd, gint el, gchar* str) { +col_set_str(column_info *cinfo, gint el, gchar* str) { int i; - for (i = 0; i < fd->cinfo->num_cols; i++) { - if (fd->cinfo->fmt_matx[i][el]) - fd->cinfo->col_data[i] = str; + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) + cinfo->col_data[i] = str; } } /* Adds a vararg list to a packet info string. */ void -col_add_fstr(frame_data *fd, gint el, gchar *format, ...) { +col_add_fstr(column_info *cinfo, gint el, gchar *format, ...) { va_list ap; int i; size_t max_len; @@ -153,17 +144,17 @@ col_add_fstr(frame_data *fd, gint el, gchar *format, ...) { 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]) { - vsnprintf(fd->cinfo->col_buf[i], max_len, format, ap); - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) { + vsnprintf(cinfo->col_buf[i], max_len, format, ap); + cinfo->col_data[i] = cinfo->col_buf[i]; } } } /* Appends a vararg list to a packet info string. */ void -col_append_fstr(frame_data *fd, gint el, gchar *format, ...) { +col_append_fstr(column_info *cinfo, gint el, gchar *format, ...) { va_list ap; int i; size_t len, max_len; @@ -174,17 +165,17 @@ col_append_fstr(frame_data *fd, gint el, gchar *format, ...) { 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 (fd->cinfo->col_data[i] != fd->cinfo->col_buf[i]) { + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) { + if (cinfo->col_data[i] != cinfo->col_buf[i]) { /* This was set with "col_set_str()"; copy the string they set it to into the buffer, so we can append to it. */ - strncpy(fd->cinfo->col_buf[i], fd->cinfo->col_data[i], max_len); - fd->cinfo->col_buf[i][max_len - 1] = '\0'; + strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); + cinfo->col_buf[i][max_len - 1] = '\0'; } - len = strlen(fd->cinfo->col_buf[i]); - vsnprintf(&fd->cinfo->col_buf[i][len], max_len - len, format, ap); - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + len = strlen(cinfo->col_buf[i]); + vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap); + cinfo->col_data[i] = cinfo->col_buf[i]; } } } @@ -192,7 +183,7 @@ col_append_fstr(frame_data *fd, gint el, gchar *format, ...) { /* Use this if "str" points to something that won't stay around (and must thus be copied). */ void -col_add_str(frame_data *fd, gint el, const gchar* str) { +col_add_str(column_info *cinfo, gint el, const gchar* str) { int i; size_t max_len; @@ -201,17 +192,17 @@ col_add_str(frame_data *fd, gint el, const gchar* str) { 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_buf[i], str, max_len); - fd->cinfo->col_buf[i][max_len - 1] = 0; - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) { + strncpy(cinfo->col_buf[i], str, max_len); + cinfo->col_buf[i][max_len - 1] = 0; + cinfo->col_data[i] = cinfo->col_buf[i]; } } } void -col_append_str(frame_data *fd, gint el, gchar* str) { +col_append_str(column_info *cinfo, gint el, gchar* str) { int i; size_t len, max_len; @@ -220,24 +211,24 @@ col_append_str(frame_data *fd, gint el, gchar* str) { else max_len = COL_MAX_LEN; - for (i = 0; i < fd->cinfo->num_cols; i++) { - if (fd->cinfo->fmt_matx[i][el]) { - if (fd->cinfo->col_data[i] != fd->cinfo->col_buf[i]) { + for (i = 0; i < cinfo->num_cols; i++) { + if (cinfo->fmt_matx[i][el]) { + if (cinfo->col_data[i] != cinfo->col_buf[i]) { /* This was set with "col_set_str()"; copy the string they set it to into the buffer, so we can append to it. */ - strncpy(fd->cinfo->col_buf[i], fd->cinfo->col_data[i], max_len); - fd->cinfo->col_buf[i][max_len - 1] = '\0'; + strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); + cinfo->col_buf[i][max_len - 1] = '\0'; } - len = strlen(fd->cinfo->col_buf[i]); - strncat(fd->cinfo->col_buf[i], str, max_len - len); - fd->cinfo->col_buf[i][max_len - 1] = 0; - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + len = strlen(cinfo->col_buf[i]); + strncat(cinfo->col_buf[i], str, max_len - len); + cinfo->col_buf[i][max_len - 1] = 0; + cinfo->col_data[i] = cinfo->col_buf[i]; } } } static void -col_set_abs_date_time(frame_data *fd, int col) +col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) { struct tm *tmp; time_t then; @@ -245,7 +236,7 @@ col_set_abs_date_time(frame_data *fd, int col) then = fd->abs_secs; tmp = localtime(&then); if (tmp != NULL) { - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, + snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%04ld", tmp->tm_year + 1900, tmp->tm_mon + 1, @@ -255,31 +246,31 @@ col_set_abs_date_time(frame_data *fd, int col) tmp->tm_sec, (long)fd->abs_usecs/100); } else { - fd->cinfo->col_buf[col][0] = '\0'; + cinfo->col_buf[col][0] = '\0'; } - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + cinfo->col_data[col] = cinfo->col_buf[col]; } static void -col_set_rel_time(frame_data *fd, int col) +col_set_rel_time(frame_data *fd, column_info *cinfo, int col) { - display_signed_time(fd->cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, fd->rel_secs, fd->rel_usecs, USECS); - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + cinfo->col_data[col] = cinfo->col_buf[col]; } static void -col_set_delta_time(frame_data *fd, int col) +col_set_delta_time(frame_data *fd, column_info *cinfo, int col) { - display_signed_time(fd->cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, fd->del_secs, fd->del_usecs, USECS); - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + cinfo->col_data[col] = cinfo->col_buf[col]; } /* To do: Add check_col checks to the col_add* routines */ static void -col_set_abs_time(frame_data *fd, int col) +col_set_abs_time(frame_data *fd, column_info *cinfo, int col) { struct tm *tmp; time_t then; @@ -287,15 +278,15 @@ col_set_abs_time(frame_data *fd, int col) then = fd->abs_secs; tmp = localtime(&then); if (tmp != NULL) { - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld", + snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, (long)fd->abs_usecs/100); } else { - fd->cinfo->col_buf[col][0] = '\0'; + cinfo->col_buf[col][0] = '\0'; } - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + cinfo->col_data[col] = cinfo->col_buf[col]; } /* Add "command-line-specified" time. @@ -306,29 +297,29 @@ col_set_abs_time(frame_data *fd, int col) requiring us to stuff the text into the widget from outside, we might be able to clean this up. */ void -col_set_cls_time(frame_data *fd, int col) +col_set_cls_time(frame_data *fd, column_info *cinfo, int col) { switch (timestamp_type) { case ABSOLUTE: - col_set_abs_time(fd, col); + col_set_abs_time(fd, cinfo, col); break; case ABSOLUTE_WITH_DATE: - col_set_abs_date_time(fd, col); + col_set_abs_date_time(fd, cinfo, col); break; case RELATIVE: - col_set_rel_time(fd, col); + col_set_rel_time(fd, cinfo, col); break; case DELTA: - col_set_delta_time(fd, col); + col_set_delta_time(fd, cinfo, col); break; } } static void -col_set_addr(frame_data *fd, int col, address *addr, gboolean is_res) +col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res) { guint32 ipv4_addr; struct e_in6_addr ipv6_addr; @@ -339,82 +330,82 @@ col_set_addr(frame_data *fd, int col, address *addr, gboolean is_res) case AT_ETHER: if (is_res) - strncpy(fd->cinfo->col_buf[col], get_ether_name(addr->data), COL_MAX_LEN); + strncpy(pinfo->cinfo->col_buf[col], get_ether_name(addr->data), COL_MAX_LEN); else - strncpy(fd->cinfo->col_buf[col], ether_to_str(addr->data), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + strncpy(pinfo->cinfo->col_buf[col], ether_to_str(addr->data), COL_MAX_LEN); + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_IPv4: memcpy(&ipv4_addr, addr->data, sizeof ipv4_addr); if (is_res) - strncpy(fd->cinfo->col_buf[col], get_hostname(ipv4_addr), COL_MAX_LEN); + strncpy(pinfo->cinfo->col_buf[col], get_hostname(ipv4_addr), COL_MAX_LEN); else - strncpy(fd->cinfo->col_buf[col], ip_to_str(addr->data), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + strncpy(pinfo->cinfo->col_buf[col], ip_to_str(addr->data), COL_MAX_LEN); + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_IPv6: memcpy(&ipv6_addr.s6_addr, addr->data, sizeof ipv6_addr.s6_addr); if (is_res) - strncpy(fd->cinfo->col_buf[col], get_hostname6(&ipv6_addr), COL_MAX_LEN); + strncpy(pinfo->cinfo->col_buf[col], get_hostname6(&ipv6_addr), COL_MAX_LEN); else - strncpy(fd->cinfo->col_buf[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + strncpy(pinfo->cinfo->col_buf[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN); + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_IPX: - strncpy(fd->cinfo->col_buf[col], + strncpy(pinfo->cinfo->col_buf[col], ipx_addr_to_str(pntohl(&addr->data[0]), &addr->data[4]), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_SNA: switch (addr->len) { case 1: - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%04X", addr->data[0]); + snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%04X", addr->data[0]); break; case 2: - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%04X", + snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%04X", pntohs(&addr->data[0])); break; case SNA_FID_TYPE_4_ADDR_LEN: memcpy(&sna_fid_type_4_addr, addr->data, SNA_FID_TYPE_4_ADDR_LEN); - strncpy(fd->cinfo->col_buf[col], + strncpy(pinfo->cinfo->col_buf[col], sna_fid_type_4_addr_to_str(&sna_fid_type_4_addr), COL_MAX_LEN); break; } - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_ATALK: memcpy(&ddp_addr, addr->data, sizeof ddp_addr); - strncpy(fd->cinfo->col_buf[col], atalk_addr_to_str(&ddp_addr), + strncpy(pinfo->cinfo->col_buf[col], atalk_addr_to_str(&ddp_addr), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_VINES: - strncpy(fd->cinfo->col_buf[col], vines_addr_to_str(&addr->data[0]), + strncpy(pinfo->cinfo->col_buf[col], vines_addr_to_str(&addr->data[0]), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; case AT_OSI: - strncpy(fd->cinfo->col_buf[col], print_nsap_net(addr->data, addr->len), + strncpy(pinfo->cinfo->col_buf[col], print_nsap_net(addr->data, addr->len), COL_MAX_LEN); - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; break; default: @@ -423,142 +414,142 @@ col_set_addr(frame_data *fd, int col, address *addr, gboolean is_res) } static void -col_set_port(frame_data *fd, int col, port_type ptype, guint32 port, +col_set_port(packet_info *pinfo, int col, port_type ptype, guint32 port, gboolean is_res) { switch (ptype) { case PT_SCTP: if (is_res) - strncpy(fd->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN); + strncpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN); else - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%u", port); + snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port); break; case PT_TCP: if (is_res) - strncpy(fd->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN); + strncpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN); else - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%u", port); + snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port); break; case PT_UDP: if (is_res) - strncpy(fd->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN); + strncpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN); else - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%u", port); + snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port); break; default: break; } - fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; - fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; + pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0'; + pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; } void -fill_in_columns(frame_data *fd, packet_info *pinfo) +fill_in_columns(packet_info *pinfo) { int i; - for (i = 0; i < fd->cinfo->num_cols; i++) { - switch (fd->cinfo->col_fmt[i]) { + for (i = 0; i < pinfo->cinfo->num_cols; i++) { + switch (pinfo->cinfo->col_fmt[i]) { case COL_NUMBER: - snprintf(fd->cinfo->col_buf[i], COL_MAX_LEN, "%u", fd->num); - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->num); + pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i]; break; case COL_CLS_TIME: - col_set_cls_time(fd, i); + col_set_cls_time(pinfo->fd, pinfo->cinfo, i); break; case COL_ABS_TIME: - col_set_abs_time(fd, i); + col_set_abs_time(pinfo->fd, pinfo->cinfo, i); break; case COL_ABS_DATE_TIME: - col_set_abs_date_time(fd, i); + col_set_abs_date_time(pinfo->fd, pinfo->cinfo, i); break; case COL_REL_TIME: - col_set_rel_time(fd, i); + col_set_rel_time(pinfo->fd, pinfo->cinfo, i); break; case COL_DELTA_TIME: - col_set_delta_time(fd, i); + col_set_delta_time(pinfo->fd, pinfo->cinfo, i); break; case COL_DEF_SRC: case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */ - col_set_addr(fd, i, &pinfo->src, TRUE); + col_set_addr(pinfo, i, &pinfo->src, TRUE); break; case COL_UNRES_SRC: - col_set_addr(fd, i, &pinfo->src, FALSE); + col_set_addr(pinfo, i, &pinfo->src, FALSE); break; case COL_DEF_DL_SRC: case COL_RES_DL_SRC: - col_set_addr(fd, i, &pinfo->dl_src, TRUE); + col_set_addr(pinfo, i, &pinfo->dl_src, TRUE); break; case COL_UNRES_DL_SRC: - col_set_addr(fd, i, &pinfo->dl_src, FALSE); + col_set_addr(pinfo, i, &pinfo->dl_src, FALSE); break; case COL_DEF_NET_SRC: case COL_RES_NET_SRC: - col_set_addr(fd, i, &pinfo->net_src, TRUE); + col_set_addr(pinfo, i, &pinfo->net_src, TRUE); break; case COL_UNRES_NET_SRC: - col_set_addr(fd, i, &pinfo->net_src, FALSE); + col_set_addr(pinfo, i, &pinfo->net_src, FALSE); break; case COL_DEF_DST: case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */ - col_set_addr(fd, i, &pinfo->dst, TRUE); + col_set_addr(pinfo, i, &pinfo->dst, TRUE); break; case COL_UNRES_DST: - col_set_addr(fd, i, &pinfo->dst, FALSE); + col_set_addr(pinfo, i, &pinfo->dst, FALSE); break; case COL_DEF_DL_DST: case COL_RES_DL_DST: - col_set_addr(fd, i, &pinfo->dl_dst, TRUE); + col_set_addr(pinfo, i, &pinfo->dl_dst, TRUE); break; case COL_UNRES_DL_DST: - col_set_addr(fd, i, &pinfo->dl_dst, FALSE); + col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE); break; case COL_DEF_NET_DST: case COL_RES_NET_DST: - col_set_addr(fd, i, &pinfo->net_dst, TRUE); + col_set_addr(pinfo, i, &pinfo->net_dst, TRUE); break; case COL_UNRES_NET_DST: - col_set_addr(fd, i, &pinfo->net_dst, FALSE); + col_set_addr(pinfo, i, &pinfo->net_dst, FALSE); break; case COL_DEF_SRC_PORT: case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */ - col_set_port(fd, i, pinfo->ptype, pinfo->srcport, TRUE); + col_set_port(pinfo, i, pinfo->ptype, pinfo->srcport, TRUE); break; case COL_UNRES_SRC_PORT: - col_set_port(fd, i, pinfo->ptype, pinfo->srcport, FALSE); + col_set_port(pinfo, i, pinfo->ptype, pinfo->srcport, FALSE); break; case COL_DEF_DST_PORT: case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */ - col_set_port(fd, i, pinfo->ptype, pinfo->destport, TRUE); + col_set_port(pinfo, i, pinfo->ptype, pinfo->destport, TRUE); break; case COL_UNRES_DST_PORT: - col_set_port(fd, i, pinfo->ptype, pinfo->destport, FALSE); + col_set_port(pinfo, i, pinfo->ptype, pinfo->destport, FALSE); break; case COL_PROTOCOL: /* currently done by dissectors */ @@ -566,8 +557,8 @@ fill_in_columns(frame_data *fd, packet_info *pinfo) break; case COL_PACKET_LENGTH: - snprintf(fd->cinfo->col_buf[i], COL_MAX_LEN, "%d", fd->pkt_len); - fd->cinfo->col_data[i] = fd->cinfo->col_buf[i]; + snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%d", pinfo->fd->pkt_len); + pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i]; break; case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */ @@ -575,9 +566,3 @@ fill_in_columns(frame_data *fd, packet_info *pinfo) } } } - - - - - - diff --git a/epan/column-utils.h b/epan/column-utils.h index e16cc926f1..69154c5d47 100644 --- a/epan/column-utils.h +++ b/epan/column-utils.h @@ -1,7 +1,7 @@ /* column-utils.h * Definitions for column utility structures and routines * - * $Id: column-utils.h,v 1.4 2001/11/21 23:16:23 gram Exp $ + * $Id: column-utils.h,v 1.5 2001/12/10 00:26:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -31,7 +31,6 @@ #define COL_MAX_INFO_LEN 4096 #include "column_info.h" -#include "frame_data.h" #include "packet_info.h" /* Allocate all the data structures for constructing column data, given @@ -40,25 +39,22 @@ extern void col_init(column_info *, gint); /* Utility routines used by packet*.c */ -extern void col_set_writable(frame_data *fd, gboolean writable); -extern gint check_col(frame_data *, gint); -extern void col_clear(frame_data *, gint); -extern void col_set_str(frame_data *, gint, gchar *); +extern void col_set_writable(column_info *, gboolean); +extern gint check_col(column_info *, gint); +extern void col_clear(column_info *, gint); +extern void col_set_str(column_info *, gint, gchar *); #if __GNUC__ >= 2 -extern void col_add_fstr(frame_data *, gint, gchar *, ...) +extern void col_add_fstr(column_info *, gint, gchar *, ...) __attribute__((format (printf, 3, 4))); -extern void col_append_fstr(frame_data *, gint, gchar *, ...) +extern void col_append_fstr(column_info *, gint, gchar *, ...) __attribute__((format (printf, 3, 4))); #else -extern void col_add_fstr(frame_data *, gint, gchar *, ...); -extern void col_append_fstr(frame_data *, gint, gchar *, ...); +extern void col_add_fstr(column_info *, gint, gchar *, ...); +extern void col_append_fstr(column_info *, gint, gchar *, ...); #endif -extern void col_add_str(frame_data *, gint, const gchar *); -extern void col_append_str(frame_data *, gint, gchar *); -extern void col_set_cls_time(frame_data *, int); -extern void fill_in_columns(frame_data *, packet_info *); +extern void col_add_str(column_info *, gint, const gchar *); +extern void col_append_str(column_info *, gint, gchar *); +extern void col_set_cls_time(frame_data *, column_info *, int); +extern void fill_in_columns(packet_info *); #endif /* __COLUMN_UTILS_H__ */ - - - diff --git a/epan/epan.c b/epan/epan.c index f9c7099066..96e2b6bf8f 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -1,6 +1,6 @@ /* epan.h * - * $Id: epan.c,v 1.12 2001/12/06 04:25:08 gram Exp $ + * $Id: epan.c,v 1.13 2001/12/10 00:26:16 guy Exp $ * * Ethereal Protocol Analyzer Library * @@ -75,7 +75,7 @@ epan_conversation_init(void) epan_dissect_t* epan_dissect_new(void* pseudo_header, const guint8* data, frame_data *fd, - gboolean create_proto_tree) + gboolean create_proto_tree, column_info *cinfo) { epan_dissect_t *edt; @@ -93,7 +93,7 @@ epan_dissect_new(void* pseudo_header, const guint8* data, frame_data *fd, edt->tree = NULL; } - dissect_packet(edt, pseudo_header, data, fd); + dissect_packet(edt, pseudo_header, data, fd, cinfo); return edt; } diff --git a/epan/epan.h b/epan/epan.h index 7741a2598f..d2e786cd85 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -1,6 +1,6 @@ /* epan.h * - * $Id: epan.h,v 1.9 2001/12/06 04:25:08 gram Exp $ + * $Id: epan.h,v 1.10 2001/12/10 00:26:16 guy Exp $ * * Ethereal Protocol Analyzer Library * @@ -51,12 +51,12 @@ epan_free(epan_t*); typedef struct _epan_dissect_t { tvbuff_t *tvb; proto_tree *tree; - packet_info pi; + packet_info pi; } epan_dissect_t; epan_dissect_t* epan_dissect_new(void* pseudo_header, const guint8* data, frame_data *fd, - gboolean create_proto_tree); + gboolean create_proto_tree, column_info *cinfo); void epan_dissect_free(epan_dissect_t* edt); diff --git a/epan/frame_data.h b/epan/frame_data.h index 75e216b6c8..8999586d92 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -1,12 +1,11 @@ /* frame_data.h * Definitions for frame_data structures and routines * - * $Id: frame_data.h,v 1.1 2001/04/01 04:11:50 hagbard Exp $ + * $Id: frame_data.h,v 1.2 2001/12/10 00:26:16 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 @@ -28,27 +27,25 @@ #include "column_info.h" - /* XXX - some of this stuff is used only while a packet is being dissected; should we keep that stuff in the "packet_info" structure, instead, to save memory? */ typedef struct _frame_data { struct _frame_data *next; /* Next element in list */ struct _frame_data *prev; /* Previous element in list */ - GSList *pfd; /* Per frame proto data */ - GSList *data_src; /* Frame data sources */ - guint32 num; /* Frame number */ - guint32 pkt_len; /* Packet length */ - guint32 cap_len; /* Amount actually captured */ - gint32 rel_secs; /* Relative seconds (yes, it can be negative) */ - gint32 rel_usecs; /* Relative microseconds (yes, it can be negative) */ - guint32 abs_secs; /* Absolute seconds */ - guint32 abs_usecs; /* Absolute microseconds */ - gint32 del_secs; /* Delta seconds (yes, it can be negative) */ - gint32 del_usecs; /* Delta microseconds (yes, it can be negative) */ - long file_off; /* File offset */ - column_info *cinfo; /* Column formatting information */ - int lnk_t; /* Per-packet encapsulation/data-link type */ + GSList *pfd; /* Per frame proto data */ + GSList *data_src; /* Frame data sources */ + guint32 num; /* Frame number */ + guint32 pkt_len; /* Packet length */ + guint32 cap_len; /* Amount actually captured */ + gint32 rel_secs; /* Relative seconds (yes, it can be negative) */ + gint32 rel_usecs; /* Relative microseconds (yes, it can be negative) */ + guint32 abs_secs; /* Absolute seconds */ + guint32 abs_usecs; /* Absolute microseconds */ + gint32 del_secs; /* Delta seconds (yes, it can be negative) */ + gint32 del_usecs; /* Delta microseconds (yes, it can be negative) */ + long file_off; /* File offset */ + int lnk_t; /* Per-packet encapsulation/data-link type */ struct { unsigned int passed_dfilter : 1; /* 1 = display, 0 = no display */ unsigned int encoding : 2; /* Character encoding (ASCII, EBCDIC...) */ diff --git a/epan/packet.c b/epan/packet.c index a4c70dbe47..b6f299a0a1 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.53 2001/12/08 21:00:42 guy Exp $ + * $Id: packet.c,v 1.54 2001/12/10 00:26:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -152,8 +152,10 @@ init_all_protocols(void) /* Creates the top-most tvbuff and calls dissect_frame() */ void dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header, - const u_char *pd, frame_data *fd) + const u_char *pd, frame_data *fd, column_info *cinfo) { + int i; + edt->pi.dl_src.type = AT_NONE; edt->pi.dl_dst.type = AT_NONE; edt->pi.net_src.type = AT_NONE; @@ -174,7 +176,15 @@ dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header, edt->pi.fd = fd; edt->pi.pseudo_header = pseudo_header; - col_set_writable(fd, TRUE); + edt->pi.cinfo = cinfo; + if (cinfo != NULL) { + for (i = 0; i < cinfo->num_cols; i++) { + cinfo->col_buf[i][0] = '\0'; + cinfo->col_data[i] = cinfo->col_buf[i]; + } + + col_set_writable(cinfo, TRUE); + } TRY { edt->tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len, "Frame"); diff --git a/epan/packet.h b/epan/packet.h index 324fcc543c..812e653cbf 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.46 2001/12/08 06:41:47 guy Exp $ + * $Id: packet.h,v 1.47 2001/12/10 00:26:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -228,7 +228,7 @@ extern void init_all_protocols(void); */ extern void dissect_packet(struct _epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header, const u_char *pd, - frame_data *fd); + frame_data *fd, column_info *cinfo); /* These functions are in packet-ethertype.c */ extern void capture_ethertype(guint16 etype, const u_char *pd, int offset, diff --git a/epan/packet_info.h b/epan/packet_info.h index d8a5df5e94..e6200f0339 100644 --- a/epan/packet_info.h +++ b/epan/packet_info.h @@ -1,7 +1,7 @@ /* packet_info.h * Definitions for packet info structures and routines * - * $Id: packet_info.h,v 1.12 2001/11/29 09:05:25 guy Exp $ + * $Id: packet_info.h,v 1.13 2001/12/10 00:26:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -89,6 +89,7 @@ typedef enum { typedef struct _packet_info { const char *current_proto; /* name of protocol currently being dissected */ + column_info *cinfo; /* Column formatting information */ frame_data *fd; union wtap_pseudo_header *pseudo_header; address dl_src; /* link-layer source address */ |