Custom column updates:
authorsfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 1 Mar 2008 05:16:45 +0000 (05:16 +0000)
committersfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 1 Mar 2008 05:16:45 +0000 (05:16 +0000)
 - Change apply / prepare / ... as filter to use the field's value, which
   is now stored in fdata as well as cinfo.  Now we don't have to reprocess
   the entire packet list when using these features.  This also prevents
   the use of these features from overwriting custom column information.
   (custom columns can now be used in apply / prepare ... as filter)
 - Break col_expr and col_expr_val out into a struct that is included not only
   in cinfo, but now also fdata.
 - Have col_custom_set_fstr() quote FT_STRING & FT_STRINGZ when storing the
   col_expr_val value (for filter creation).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24511 f5534014-38df-0310-8fa8-9805f1628bb7

epan/column-utils.c
epan/column-utils.h
epan/column.c
epan/column_info.h
epan/frame_data.h
epan/proto.c
file.c
gtk/main.c
rawshark.c
tshark.c

index df1062b003f0dce72ee9f2c8282f7c2e392b98a1..676cb0bdca2e10d10a11ba9c63c14c500038e58f 100644 (file)
@@ -64,8 +64,8 @@ col_setup(column_info *cinfo, gint num_cols)
   cinfo->col_data      = (const gchar **) g_malloc(sizeof(gchar *) * num_cols);
   cinfo->col_buf       = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
   cinfo->col_fence     = (int *) g_malloc(sizeof(int) * num_cols);
-  cinfo->col_expr      = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
-  cinfo->col_expr_val = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
+  cinfo->col_expr.col_expr = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
+  cinfo->col_expr.col_expr_val = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
 
   for (i = 0; i < NUM_COL_FMTS; i++) {
     cinfo->col_first[i] = -1;
@@ -83,8 +83,8 @@ col_init(column_info *cinfo)
     cinfo->col_buf[i][0] = '\0';
     cinfo->col_data[i] = cinfo->col_buf[i];
     cinfo->col_fence[i] = 0;
-    cinfo->col_expr[i][0] = '\0';
-    cinfo->col_expr_val[i][0] = '\0';
+    cinfo->col_expr.col_expr[i][0] = '\0';
+    cinfo->col_expr.col_expr_val[i][0] = '\0';
   }
   cinfo->writable = TRUE;
 }
@@ -176,8 +176,8 @@ col_clear(column_info *cinfo, gint el)
         cinfo->col_buf[i][fence] = '\0';
         cinfo->col_data[i] = cinfo->col_buf[i];
       }
-      cinfo->col_expr[i][0] = '\0';
-      cinfo->col_expr_val[i][0] = '\0';
+      cinfo->col_expr.col_expr[i][0] = '\0';
+      cinfo->col_expr.col_expr_val[i][0] = '\0';
     }
   }
 }
@@ -272,7 +272,7 @@ col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) {
 }
 
 void
-col_custom_set_fstr(const gchar *field_name, const gchar *format, ...)
+col_custom_set_fstr(header_field_info *hfinfo, const gchar *format, ...)
 {
   va_list ap;
   int     i;
@@ -284,11 +284,23 @@ col_custom_set_fstr(const gchar *field_name, const gchar *format, ...)
   for (i = ci->col_first[COL_CUSTOM];
        i <= ci->col_last[COL_CUSTOM]; i++) {
     if (ci->fmt_matx[i][COL_CUSTOM] &&
-       strcmp(ci->col_custom_field[i], field_name) == 0) {
+       strcmp(ci->col_custom_field[i], hfinfo->abbrev) == 0) {
       ci->col_data[i] = ci->col_buf[i];
       g_vsnprintf(ci->col_buf[i], COL_MAX_LEN, format, ap);
-      strncpy(ci->col_expr[i], field_name, COL_MAX_LEN);
-      strncpy(ci->col_expr_val[i], ci->col_buf[i], COL_MAX_LEN);
+
+      g_strlcpy(ci->col_expr.col_expr[i], hfinfo->abbrev, COL_MAX_LEN);
+
+      switch(hfinfo->type) {
+      case FT_STRING:
+      case FT_STRINGZ:
+        g_snprintf(ci->col_expr.col_expr_val[i], COL_MAX_LEN, "\"%s\"",
+           ci->col_buf[i]);
+       break;
+
+      default:
+       g_strlcpy(ci->col_expr.col_expr_val[i], ci->col_buf[i], COL_MAX_LEN);
+       break;
+      }
     }
   }
   va_end(ap);
@@ -663,8 +675,8 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
     cinfo->col_buf[col][0] = '\0';
   }
   cinfo->col_data[col] = cinfo->col_buf[col];
-  strcpy(cinfo->col_expr[col],"frame.time");
-  strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+  strcpy(cinfo->col_expr.col_expr[col],"frame.time");
+  strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
 }
 
 static void
@@ -707,8 +719,8 @@ col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
                  g_assert_not_reached();
   }
   cinfo->col_data[col] = cinfo->col_buf[col];
-  strcpy(cinfo->col_expr[col],"frame.time_relative");
-  strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+  strcpy(cinfo->col_expr.col_expr[col],"frame.time_relative");
+  strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
 }
 
 static void
@@ -751,8 +763,8 @@ col_set_delta_time(frame_data *fd, column_info *cinfo, int col)
                  g_assert_not_reached();
   }
   cinfo->col_data[col] = cinfo->col_buf[col];
-  strcpy(cinfo->col_expr[col],"frame.time_delta");
-  strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+  strcpy(cinfo->col_expr.col_expr[col],"frame.time_delta");
+  strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
 }
 
 static void
@@ -795,8 +807,8 @@ col_set_delta_time_dis(frame_data *fd, column_info *cinfo, int col)
                  g_assert_not_reached();
   }
   cinfo->col_data[col] = cinfo->col_buf[col];
-  strcpy(cinfo->col_expr[col],"frame.time_delta_displayed");
-  strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+  strcpy(cinfo->col_expr.col_expr[col],"frame.time_delta_displayed");
+  strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
 }
 
 /* To do: Add check_col checks to the col_add* routines */
@@ -873,8 +885,8 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
     cinfo->col_buf[col][0] = '\0';
   }
   cinfo->col_data[col] = cinfo->col_buf[col];
-  strcpy(cinfo->col_expr[col],"frame.time");
-  strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+  strcpy(cinfo->col_expr.col_expr[col],"frame.time");
+  strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
 }
 
 static void
@@ -918,8 +930,8 @@ col_set_epoch_time(frame_data *fd, column_info *cinfo, int col)
                  g_assert_not_reached();
   }
   cinfo->col_data[col] = cinfo->col_buf[col];
-  strcpy(cinfo->col_expr[col],"frame.time_delta");
-  strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+  strcpy(cinfo->col_expr.col_expr[col],"frame.time_delta");
+  strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
 }
 /* Set the format of the variable time format.
    XXX - this is called from "file.c" when the user changes the time
@@ -1007,8 +1019,8 @@ col_set_time(column_info *cinfo, gint el, nstime_t *ts, char *fieldname)
          g_assert_not_reached();
       }
       cinfo->col_data[col] = cinfo->col_buf[col];
-      strcpy(cinfo->col_expr[col],fieldname);
-      strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
+      strcpy(cinfo->col_expr.col_expr[col],fieldname);
+      strcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col]);
     }
   }
 }
@@ -1019,8 +1031,8 @@ col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res,
 {
   struct e_in6_addr ipv6_addr;
 
-  pinfo->cinfo->col_expr[col][0] = '\0';
-  pinfo->cinfo->col_expr_val[col][0] = '\0';
+  pinfo->cinfo->col_expr.col_expr[col][0] = '\0';
+  pinfo->cinfo->col_expr.col_expr_val[col][0] = '\0';
 
   if (addr->type == AT_NONE)
     return;    /* no address, nothing to do */
@@ -1036,50 +1048,50 @@ col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res,
 
   case AT_ETHER:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "eth.src");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "eth.src");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "eth.dst");
-    g_strlcpy(pinfo->cinfo->col_expr_val[col], ether_to_str(addr->data), COL_MAX_LEN);
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "eth.dst");
+    g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ether_to_str(addr->data), COL_MAX_LEN);
     break;
 
   case AT_IPv4:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "ip.src");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ip.src");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "ip.dst");
-    g_strlcpy(pinfo->cinfo->col_expr_val[col], ip_to_str(addr->data), COL_MAX_LEN);
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ip.dst");
+    g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ip_to_str(addr->data), COL_MAX_LEN);
     break;
 
   case AT_IPv6:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "ipv6.src");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ipv6.src");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "ipv6.dst");
-    g_strlcpy(pinfo->cinfo->col_expr_val[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN);
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ipv6.dst");
+    g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN);
     break;
 
   case AT_ATALK:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "ddp.src");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ddp.src");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "ddp.dst");
-    strcpy(pinfo->cinfo->col_expr_val[col], pinfo->cinfo->col_buf[col]);
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ddp.dst");
+    strcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col]);
     break;
 
   case AT_ARCNET:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "arcnet.src");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "arcnet.src");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "arcnet.dst");
-    strcpy(pinfo->cinfo->col_expr_val[col], pinfo->cinfo->col_buf[col]);
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "arcnet.dst");
+    strcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col]);
     break;
 
   case AT_URI:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "uri.src");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "uri.src");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "uri.dst");
-    address_to_str_buf(addr, pinfo->cinfo->col_expr_val[col], COL_MAX_LEN);
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "uri.dst");
+    address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
     break;
 
   default:
@@ -1096,8 +1108,8 @@ col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src)
     port = pinfo->srcport;
   else
     port = pinfo->destport;
-  pinfo->cinfo->col_expr[col][0] = '\0';
-  pinfo->cinfo->col_expr_val[col][0] = '\0';
+  pinfo->cinfo->col_expr.col_expr[col][0] = '\0';
+  pinfo->cinfo->col_expr.col_expr_val[col][0] = '\0';
   switch (pinfo->ptype) {
 
   case PT_SCTP:
@@ -1113,11 +1125,11 @@ col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src)
     else
       g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "tcp.srcport");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "tcp.srcport");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "tcp.dstport");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "tcp.dstport");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", port);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case PT_UDP:
@@ -1126,54 +1138,54 @@ col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src)
     else
       g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "udp.srcport");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "udp.srcport");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "udp.dstport");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "udp.dstport");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", port);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case PT_DDP:
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "ddp.src_socket");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ddp.src_socket");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "ddp.dst_socket");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ddp.dst_socket");
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", port);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case PT_IPX:
     /* XXX - resolve IPX socket numbers */
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "ipx.src.socket");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ipx.src.socket");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "ipx.dst.socket");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "ipx.dst.socket");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case PT_IDP:
     /* XXX - resolve IDP socket numbers */
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "idp.src.socket");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "idp.src.socket");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "idp.dst.socket");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "idp.dst.socket");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case PT_USB:
     /* XXX - resolve USB endpoint numbers */
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port);
     if (is_src)
-      strcpy(pinfo->cinfo->col_expr[col], "usb.src.endpoint");
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "usb.src.endpoint");
     else
-      strcpy(pinfo->cinfo->col_expr[col], "usb.dst.endpoint");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%08x", port);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+      strcpy(pinfo->cinfo->col_expr.col_expr[col], "usb.dst.endpoint");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "0x%08x", port);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   default:
@@ -1225,23 +1237,23 @@ static const value_string channel_vals[] = {
 static void
 col_set_circuit_id(packet_info *pinfo, int col)
 {
-  pinfo->cinfo->col_expr[col][0] = '\0';
-  pinfo->cinfo->col_expr_val[col][0] = '\0';
+  pinfo->cinfo->col_expr.col_expr[col][0] = '\0';
+  pinfo->cinfo->col_expr.col_expr_val[col][0] = '\0';
   switch (pinfo->ctype) {
 
   case CT_DLCI:
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
-    strcpy(pinfo->cinfo->col_expr[col], "fr.dlci");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+    strcpy(pinfo->cinfo->col_expr.col_expr[col], "fr.dlci");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case CT_ISDN:
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%s",
             val_to_str(pinfo->circuit_id, channel_vals, "Unknown (%u)"));
-    strcpy(pinfo->cinfo->col_expr[col], "isdn.channel");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+    strcpy(pinfo->cinfo->col_expr.col_expr[col], "isdn.channel");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   case CT_X25:
@@ -1250,9 +1262,9 @@ col_set_circuit_id(packet_info *pinfo, int col)
 
   case CT_ISUP:
     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
-    strcpy(pinfo->cinfo->col_expr[col], "isup.cic");
-    g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
-    pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
+    strcpy(pinfo->cinfo->col_expr.col_expr[col], "isup.cic");
+    g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
+    pinfo->cinfo->col_expr.col_expr_val[col][COL_MAX_LEN - 1] = '\0';
     break;
 
   default:
@@ -1273,8 +1285,8 @@ col_fill_in(packet_info *pinfo)
     case COL_NUMBER:
       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->num);
       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
-      strcpy(pinfo->cinfo->col_expr[i], "frame.number");
-      strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]);
+      strcpy(pinfo->cinfo->col_expr.col_expr[i], "frame.number");
+      strcpy(pinfo->cinfo->col_expr.col_expr_val[i], pinfo->cinfo->col_buf[i]);
       break;
 
     case COL_CLS_TIME:
@@ -1384,8 +1396,8 @@ col_fill_in(packet_info *pinfo)
     case COL_PACKET_LENGTH:
       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->pkt_len);
       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
-      strcpy(pinfo->cinfo->col_expr[i], "frame.pkt_len");
-      strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]);
+      strcpy(pinfo->cinfo->col_expr.col_expr[i], "frame.pkt_len");
+      strcpy(pinfo->cinfo->col_expr.col_expr_val[i], pinfo->cinfo->col_buf[i]);
       break;
 
     case COL_CUMULATIVE_BYTES:
index cfac09786e187bf595ba6c6852e0672a3809af56..9042bccf90e26be09b61b43bcc3108647f370074 100644 (file)
@@ -144,7 +144,7 @@ extern void col_add_fstr(column_info *cinfo, gint col, const gchar *format, ...)
     GNUC_FORMAT_CHECK(printf, 3, 4);
 
 /* For internal Wireshark use only.  Not to be called from dissectors. */
-void col_custom_set_fstr(const gchar *field_name, const gchar *format, ...)
+void col_custom_set_fstr(header_field_info *hfinfo, const gchar *format, ...)
     GNUC_FORMAT_CHECK(printf, 2, 3);
 
 /* For internal Wireshark use only.  Not to be called from dissectors. */
index 8b14c07a0e634df08ef870e4585d69a0f0408abd..d7348e11c58467d81e12c2ba87ec46a9775ac396 100644 (file)
@@ -687,9 +687,10 @@ build_column_format_array(capture_file *cfile, gboolean reset_fences)
     if(reset_fences)
       cfile->cinfo.col_fence[i] = 0;
 
-    cfile->cinfo.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
-    cfile->cinfo.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) *
-                                                    COL_MAX_LEN);
+    cfile->cinfo.col_expr.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) *
+                                                           COL_MAX_LEN);
+    cfile->cinfo.col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) *
+                                                               COL_MAX_LEN);
   }
 
   for (i = 0; i < cfile->cinfo.num_cols; i++) {
index 3d7d095212cff4965d4bdf2fec762d48864da865..f175fba6f59ba24be089b2fb9c37913745cfef76 100644 (file)
@@ -34,6 +34,11 @@ extern "C" {
 #define COL_MAX_LEN 256
 #define COL_MAX_INFO_LEN 4096
 
+typedef struct {
+  gchar      **col_expr;     /* Filter expression */
+  gchar      **col_expr_val; /* Value for filter expression */
+} col_expr_t;
+
 typedef struct _column_info {
   gint          num_cols;    /* Number of columns */
   gint         *col_fmt;     /* Format of column */
@@ -45,8 +50,7 @@ typedef struct _column_info {
   const gchar **col_data;    /* Column data */
   gchar       **col_buf;     /* Buffer into which to copy data for column */
   int         *col_fence;    /* Stuff in column buffer before this index is immutable */
-  gchar      **col_expr;     /* Filter expression */
-  gchar      **col_expr_val; /* Value for filter expression */
+  col_expr_t   col_expr;     /* Column expressions and values */
   gboolean     writable;     /* Are we still writing to the columns? */
   gboolean columns_changed;  /* Have the columns been changed in the prefs? */
 } column_info;
index 52f9ef798c9bc0c4a48fa8e0a8e2a376b414a5a8..f8332803e96c8f4799641755a47a63ebe2ef052a 100644 (file)
@@ -58,6 +58,7 @@ typedef struct _frame_data {
        unsigned int ref_time           : 1; /* 1 = marked as a reference time frame, 0 = normal */
   } flags;
   void *color_filter;       /* Per-packet matching color_filter_t object */
+  col_expr_t   col_expr;   /* Column expressions & values */
 } frame_data;
 
 /*
index 5cb8d26fd31d37656dfdefe9238f3489ddc82291..4197b5c1a948e16e95c5739d18d88d3cebd0e0b6 100644 (file)
@@ -1471,7 +1471,7 @@ proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length)
        if (length > 0) {
                g_byte_array_append(bytes, start_ptr, length);
        }
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%s", bytes_to_str(bytes->data,
+       col_custom_set_fstr(fi->hfinfo, "%s", bytes_to_str(bytes->data,
                                                                   length));
        fvalue_set(&fi->value, bytes, TRUE);
 }
@@ -1569,9 +1569,9 @@ proto_tree_set_time(field_info *fi, nstime_t *value_ptr)
        hfinfo = fi->hfinfo;
 
        if (hfinfo->type == FT_ABSOLUTE_TIME) {
-               col_custom_set_fstr(hfinfo->abbrev, "%s", abs_time_to_str(value_ptr));
+               col_custom_set_fstr(fi->hfinfo, "%s", abs_time_to_str(value_ptr));
        } else if (hfinfo->type == FT_RELATIVE_TIME) {
-               col_custom_set_fstr(hfinfo->abbrev, "%s", rel_time_to_secs_str(value_ptr));
+               col_custom_set_fstr(fi->hfinfo, "%s", rel_time_to_secs_str(value_ptr));
        }
        fvalue_set(&fi->value, value_ptr, FALSE);
 }
@@ -1735,7 +1735,7 @@ proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
 static void
 proto_tree_set_ipv4(field_info *fi, guint32 value)
 {
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%s",
+       col_custom_set_fstr(fi->hfinfo, "%s",
                            ip_to_str((guint8 *)&value));
        fvalue_set_uinteger(&fi->value, value);
 }
@@ -1909,7 +1909,7 @@ static void
 proto_tree_set_guid(field_info *fi, const e_guid_t *value_ptr)
 {
        DISSECTOR_ASSERT(value_ptr != NULL);
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%s",
+       col_custom_set_fstr(fi->hfinfo, "%s",
                            guid_to_str(value_ptr));
        fvalue_set(&fi->value, (gpointer) value_ptr, FALSE);
 }
@@ -2010,7 +2010,7 @@ proto_tree_set_oid(field_info *fi, const guint8* value_ptr, gint length)
        if (length > 0) {
                g_byte_array_append(bytes, value_ptr, length);
        }
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%s",
+       col_custom_set_fstr(fi->hfinfo, "%s",
                            oid_resolved_from_encoded(value_ptr, length));
        fvalue_set(&fi->value, bytes, TRUE);
 }
@@ -2024,7 +2024,7 @@ proto_tree_set_oid_tvb(field_info *fi, tvbuff_t *tvb, gint start, gint length)
 static void
 proto_tree_set_uint64(field_info *fi, guint64 value)
 {
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%" G_GINT64_MODIFIER "u",
+       col_custom_set_fstr(fi->hfinfo, "%" G_GINT64_MODIFIER "u",
                            value);
        fvalue_set_integer64(&fi->value, value);
 }
@@ -2189,11 +2189,11 @@ static void
 proto_tree_set_string(field_info *fi, const char* value)
 {
        if (value) {
-               col_custom_set_fstr(fi->hfinfo->abbrev, "%s",
+               col_custom_set_fstr(fi->hfinfo, "%s",
                                    format_text(value, strlen(value)));
                fvalue_set(&fi->value, (gpointer) value, FALSE);
        } else {
-               col_custom_set_fstr(fi->hfinfo->abbrev, "[ Null ]");
+               col_custom_set_fstr(fi->hfinfo, "[ Null ]");
                fvalue_set(&fi->value, (gpointer) "[ Null ]", FALSE);
        }
 }
@@ -2304,7 +2304,7 @@ proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s
 static void
 proto_tree_set_ether(field_info *fi, const guint8* value)
 {
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%s", bytes_to_str_punct(value, 6, ':'));
+       col_custom_set_fstr(fi->hfinfo, "%s", bytes_to_str_punct(value, 6, ':'));
        fvalue_set(&fi->value, (gpointer) value, FALSE);
 }
 
@@ -2474,7 +2474,7 @@ proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s
 static void
 proto_tree_set_float(field_info *fi, float value)
 {
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%." STRINGIFY(FLT_DIG) "f",
+       col_custom_set_fstr(fi->hfinfo, "%." STRINGIFY(FLT_DIG) "f",
                            value);
        fvalue_set_floating(&fi->value, value);
 }
@@ -2557,7 +2557,7 @@ proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint
 static void
 proto_tree_set_double(field_info *fi, double value)
 {
-       col_custom_set_fstr(fi->hfinfo->abbrev, "%." STRINGIFY(DBL_DIG) "g",
+       col_custom_set_fstr(fi->hfinfo, "%." STRINGIFY(DBL_DIG) "g",
                            value);
        fvalue_set_floating(&fi->value, value);
 }
@@ -2671,13 +2671,13 @@ proto_tree_set_uint(field_info *fi, guint32 value)
                if (hfinfo->strings) {
                        tfstring = (const struct true_false_string*) hfinfo->strings;
                }
-               col_custom_set_fstr(hfinfo->abbrev, "%s", value ? tfstring->true_string : tfstring->false_string);
+               col_custom_set_fstr(fi->hfinfo, "%s", value ? tfstring->true_string : tfstring->false_string);
        } else if (hfinfo->strings) {
-               col_custom_set_fstr(hfinfo->abbrev, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));
+               col_custom_set_fstr(fi->hfinfo, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));
        } else if (IS_BASE_DUAL(hfinfo->display)) {
-               col_custom_set_fstr(hfinfo->abbrev, hfinfo_uint_value_format(hfinfo), integer, integer);
+               col_custom_set_fstr(fi->hfinfo, hfinfo_uint_value_format(hfinfo), integer, integer);
        } else {
-               col_custom_set_fstr(hfinfo->abbrev, hfinfo_uint_value_format(hfinfo), integer);
+               col_custom_set_fstr(fi->hfinfo, hfinfo_uint_value_format(hfinfo), integer);
        }
        fvalue_set_uinteger(&fi->value, integer);
 }
@@ -2845,11 +2845,11 @@ proto_tree_set_int(field_info *fi, gint32 value)
        }
 
        if (hfinfo->strings) {
-               col_custom_set_fstr(hfinfo->abbrev, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));
+               col_custom_set_fstr(fi->hfinfo, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));
        } else if (IS_BASE_DUAL(hfinfo->display)) {
-               col_custom_set_fstr(hfinfo->abbrev, hfinfo_int_value_format(hfinfo), integer, integer);
+               col_custom_set_fstr(fi->hfinfo, hfinfo_int_value_format(hfinfo), integer, integer);
        } else {
-               col_custom_set_fstr(hfinfo->abbrev, hfinfo_int_value_format(hfinfo), integer);
+               col_custom_set_fstr(fi->hfinfo, hfinfo_int_value_format(hfinfo), integer);
        }
        fvalue_set_sinteger(&fi->value, integer);
 }
diff --git a/file.c b/file.c
index f286a2f30ba21fd1fb3abc37f0f6e6501d6b9266..9620d9c384bd0bb90bf3ed6d5600bf5cc1c91f94 100644 (file)
--- a/file.c
+++ b/file.c
@@ -78,6 +78,8 @@
 #include <epan/dfilter/dfilter-macro.h>
 #include "file_util.h"
 #include <epan/column-utils.h>
+#include <epan/strutil.h>
+#include <epan/emem.h>
 
 #ifdef HAVE_LIBPCAP
 gboolean auto_scroll_live;
@@ -889,6 +891,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
        gboolean refilter)
 {
   gint          row;
+  gint          col;
   gboolean     create_proto_tree = FALSE;
   epan_dissect_t *edt;
 
@@ -1010,6 +1013,20 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
     /* This is the last frame we've seen so far. */
     cf->last_displayed = fdata;
 
+    /* Setup and copy data into fdata->col_expr.col_expr & .col_expr_val */
+    fdata->col_expr.col_expr =
+           (gchar **) se_alloc(sizeof(gchar *) * cf->cinfo.num_cols);
+    fdata->col_expr.col_expr_val =
+           (gchar **) se_alloc(sizeof(gchar *) * cf->cinfo.num_cols);
+
+    for(col = 0; col < cf->cinfo.num_cols; col++) {
+           fdata->col_expr.col_expr[col] = 
+                   se_strdup(cf->cinfo.col_expr.col_expr[col]);
+           fdata->col_expr.col_expr_val[col] = 
+                   se_strdup(cf->cinfo.col_expr.col_expr_val[col]);
+
+    }
+    
     row = packet_list_append(cf->cinfo.col_data, fdata);
 
     /* colorize packet: first apply color filters
index 459b40d62d4508190e1bb2eedd1480abfbcf87a0..7f06357f9e4b37aec2b42e9164c58e04eeb21f3c 100644 (file)
@@ -492,38 +492,14 @@ get_text_from_packet_list(gpointer data)
     gint       row = GPOINTER_TO_INT(OBJECT_GET_DATA(data, E_MPACKET_LIST_ROW_KEY));
     gint       column = GPOINTER_TO_INT(OBJECT_GET_DATA(data, E_MPACKET_LIST_COL_KEY));
     frame_data *fdata = (frame_data *)packet_list_get_row_data(row);
-    epan_dissect_t *edt;
-    gchar      *buf=NULL;
-    int         len;
-    int         err;
-    gchar       *err_info;
-
-    if (fdata != NULL) {
-       if (!wtap_seek_read(cfile.wth, fdata->file_off, &cfile.pseudo_header,
-                      cfile.pd, fdata->cap_len, &err, &err_info)) {
-           simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-                         cf_read_error_message(err, err_info), cfile.filename);
-           return NULL;
-       }
-
-       edt = epan_dissect_new(FALSE, FALSE);
-       epan_dissect_run(edt, &cfile.pseudo_header, cfile.pd, fdata,
-                        &cfile.cinfo);
-       epan_dissect_fill_in_columns(edt);
-
-       if (strlen(cfile.cinfo.col_expr[column]) != 0 &&
-           strlen(cfile.cinfo.col_expr_val[column]) != 0) {
-           len = strlen(cfile.cinfo.col_expr[column]) +
-                 strlen(cfile.cinfo.col_expr_val[column]) + 5;
-           buf = ep_alloc0(len);
-           g_snprintf(buf, len, "%s == %s", cfile.cinfo.col_expr[column],
-                    cfile.cinfo.col_expr_val[column]);
-       }
-
-       epan_dissect_free(edt);
-    }
 
-    return buf;
+    if(strlen(fdata->col_expr.col_expr[column]) != 0 &&
+       strlen(fdata->col_expr.col_expr_val[column]) != 0)
+           return ep_strdup_printf("%s == %s",
+                                   fdata->col_expr.col_expr[column],
+                                   fdata->col_expr.col_expr_val[column]);
+    else
+           return NULL;
 }
 
 void
index 2d7615d9bde916aa72bb154ab4acf76f0a0b640f..97c91178d224a909018aa8fd2d3f03ad1d8e2a07 100644 (file)
@@ -770,8 +770,8 @@ main(int argc, char *argv[])
     else
       cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
     cfile.cinfo.col_fence[i] = 0;
-    cfile.cinfo.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
-    cfile.cinfo.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+    cfile.cinfo.col_expr.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+    cfile.cinfo.col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
   }
 
   for (i = 0; i < cfile.cinfo.num_cols; i++) {
index 2e04d4c2b3ca3d70fc4be51b754f85a1672b4b34..fd5c1a70b9f17cc842ea664a06ff2a256bde710f 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -1419,8 +1419,8 @@ main(int argc, char *argv[])
     else
       cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
     cfile.cinfo.col_fence[i] = 0;
-    cfile.cinfo.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
-    cfile.cinfo.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+    cfile.cinfo.col_expr.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+    cfile.cinfo.col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
   }
 
   for (i = 0; i < cfile.cinfo.num_cols; i++) {