Update manuf to current IEEE entries.
[obnox/wireshark/wip.git] / column.c
index 1fdc3e93485c2f2d90c67f1a2365abf0c3178bdc..cc4a8e11a740f9dfe0b157fb5f2022061e9ca6be 100644 (file)
--- a/column.c
+++ b/column.c
@@ -1,23 +1,22 @@
 /* column.c
  * Routines for handling column preferences
  *
- * $Id: column.c,v 1.31 2001/07/11 04:44:58 guy Exp $
+ * $Id: column.c,v 1.42 2003/01/27 20:45:42 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
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <sys/stat.h>
 #endif
 
-#include "timestamp.h"
+#include <epan/timestamp.h>
 #include "prefs.h"
 #include "column.h"
-#include "packet.h"
+#include <epan/packet.h>
 
 /* Given a format number (as defined in packet.h), returns its equivalent
    string */
@@ -57,38 +52,62 @@ col_format_to_string(gint fmt) {
                      "%us","%hs", "%rhs", "%uhs", "%ns", "%rns", "%uns", "%d",
                      "%rd", "%ud", "%hd", "%rhd", "%uhd", "%nd", "%rnd",
                      "%und", "%S", "%rS", "%uS", "%D", "%rD", "%uD", "%p",
-                     "%i", "%L" };
-  
+                     "%i", "%L", "%XO", "%XR", "%I", "%c", "%Xs", "%Xd", "%V" };
+                     
   if (fmt < 0 || fmt > NUM_COL_FMTS)
     return NULL;
-  
+
   return(slist[fmt]);
 }
 
 /* Given a format number (as defined in packet.h), returns its
   description */
+static gchar *dlist[NUM_COL_FMTS] = {
+       "Number",
+       "Time (command line specified)",
+       "Relative time",
+       "Absolute time",
+       "Absolute date and time",
+       "Delta time",
+       "Source address",
+       "Src addr (resolved)",
+       "Src addr (unresolved)",
+       "Hardware src addr",
+       "Hw src addr (resolved)",
+       "Hw src addr (unresolved)",
+       "Network src addr",
+       "Net src addr (resolved)",
+       "Net src addr (unresolved)",
+       "Destination address",
+       "Dest addr (resolved)",
+       "Dest addr (unresolved)",
+       "Hardware dest addr",
+       "Hw dest addr (resolved)",
+       "Hw dest addr (unresolved)",
+       "Network dest addr",
+       "Net dest addr (resolved)",
+       "Net dest addr (unresolved)",
+       "Source port",
+       "Src port (resolved)",
+       "Src port (unresolved)",
+       "Destination port",
+       "Dest port (resolved)",
+       "Dest port (unresolved)",
+       "Protocol",
+       "Information",
+       "Packet length (bytes)" ,
+       "OXID",
+       "RXID",
+       "FW-1 monitor if/direction",
+       "Circuit ID",
+       "Src PortIdx",
+       "Dst PortIdx",
+       "VSAN",
+};
+
 gchar *
 col_format_desc(gint fmt) {
-  gchar *dlist[] = { "Number", "Time (command line specified)",
-                     "Relative time", "Absolute time",
-                    "Absolute date and time", "Delta time",
-                     "Source address", "Src addr (resolved)",
-                     "Src addr (unresolved)", "Hardware src addr",
-                     "Hw src addr (resolved)", "Hw src addr (unresolved)",
-                     "Network src addr", "Net src addr (resolved)",
-                     "Net src addr (unresolved)", "Destination address",
-                     "Dest addr (resolved)", "Dest addr (unresolved)",
-                     "Hardware dest addr", "Hw dest addr (resolved)",
-                     "Hw dest addr (unresolved)", "Network dest addr",
-                     "Net dest addr (resolved)", "Net dest addr (unresolved)",
-                     "Source port", "Src port (resolved)",
-                     "Src port (unresolved)", "Destination port",
-                     "Dest port (resolved)", "Dest port (unresolved)",
-                     "Protocol", "Information", "Packet length (bytes)" };
-  
-  if (fmt < 0 || fmt > NUM_COL_FMTS)
-    return NULL;
-  
+  g_assert((fmt >= 0) && (fmt < NUM_COL_FMTS));
   return(dlist[fmt]);
 }
 
@@ -145,6 +164,27 @@ get_column_format_matches(gboolean *fmt_list, gint format) {
     case COL_DEF_DST_PORT:
       fmt_list[COL_RES_DST_PORT] = TRUE;
       break;
+    case COL_OXID:
+      fmt_list[COL_OXID] = TRUE;
+      break;
+    case COL_RXID:
+      fmt_list[COL_RXID] = TRUE;
+      break;
+    case COL_IF_DIR:
+      fmt_list[COL_IF_DIR] = TRUE;
+      break;
+    case COL_CIRCUIT_ID:
+      fmt_list[COL_CIRCUIT_ID] = TRUE;
+      break;
+    case COL_SRCIDX:
+      fmt_list[COL_SRCIDX] = TRUE;
+      break;
+    case COL_DSTIDX:
+      fmt_list[COL_DSTIDX] = TRUE;
+      break;
+    case COL_VSAN:
+      fmt_list[COL_VSAN] = TRUE;
+      break;
     default:
       break;
   }
@@ -221,6 +261,23 @@ get_column_longest_string(gint format)
     case COL_PACKET_LENGTH:
       return "000000";
       break;
+    case COL_RXID:
+    case COL_OXID:
+      return "000000";
+      break;
+    case COL_IF_DIR:
+      return "i 00000000 I";
+      break;
+    case COL_CIRCUIT_ID:
+      return "000000";
+      break;
+    case COL_SRCIDX:
+    case COL_DSTIDX:
+      return "0000000";
+      break;
+    case COL_VSAN:
+      return "000000";
+      break;
     default: /* COL_INFO */
       return "Source port: kerberos-master  Destination port: kerberos-master";
       break;
@@ -252,6 +309,8 @@ get_column_resize_type(gint format) {
     case COL_UNRES_DST_PORT:
     case COL_PROTOCOL:
     case COL_PACKET_LENGTH:
+    case COL_IF_DIR:
+    case COL_CIRCUIT_ID:
       /* We don't want these to resize during a live capture, as that
          gets in the way of trying to look at the data while it's being
         captured. */
@@ -275,6 +334,11 @@ get_column_resize_type(gint format) {
     case COL_DEF_NET_DST:
     case COL_RES_NET_DST:
     case COL_UNRES_NET_DST:
+    case COL_OXID:
+    case COL_RXID:
+    case COL_SRCIDX:
+    case COL_DSTIDX:
+    case COL_VSAN:
       /* We don't want these to resize dynamically; if they get resolved
          to names, those names could be very long, and auto-resizing
         columns showing those names may leave too little room for
@@ -308,9 +372,9 @@ gint
 get_column_format(gint col) {
   GList    *clp = g_list_nth(prefs.col_list, col);
   fmt_data *cfmt;
-  
+
   cfmt = (fmt_data *) clp->data;
-  
+
   return(get_column_format_from_str(cfmt->fmt));
 }
 
@@ -318,6 +382,7 @@ gint
 get_column_format_from_str(gchar *str) {
   gchar *cptr = str;
   gint      res_off = RES_DEF, addr_off = ADDR_DEF, time_off = TIME_DEF;
+  gint      prev_code = -1;
 
   /* To do: Make this parse %-formatted strings "for real" */
   while (*cptr != '\0') {
@@ -329,10 +394,20 @@ get_column_format_from_str(gchar *str) {
         return COL_NUMBER;
         break;
       case 's':
-        return COL_DEF_SRC + res_off + addr_off;
+        if (prev_code == COL_OXID) {
+          return COL_SRCIDX;
+        }
+        else {
+          return COL_DEF_SRC + res_off + addr_off;
+        }
         break;
       case 'd':
-        return COL_DEF_DST + res_off + addr_off;
+        if (prev_code == COL_OXID) {
+          return COL_DSTIDX;
+        }
+        else {
+          return COL_DEF_DST + res_off + addr_off;
+        }
         break;
       case 'S':
         return COL_DEF_SRC_PORT + res_off;
@@ -359,7 +434,12 @@ get_column_format_from_str(gchar *str) {
         addr_off = ADDR_NET;
         break;
       case 'R':
-        time_off = TIME_REL;
+        if (prev_code == COL_OXID) {
+            return COL_RXID;
+        }
+        else {
+            time_off = TIME_REL;
+        }
         break;
       case 'A':
         time_off = TIME_ABS;
@@ -373,65 +453,33 @@ get_column_format_from_str(gchar *str) {
       case 'L':
         return COL_PACKET_LENGTH;
         break;
+      case 'X':
+        prev_code = COL_OXID;
+        break;
+      case 'O':
+        return COL_OXID;
+        break;
+      case 'I':
+        return COL_IF_DIR;
+        break;
+      case 'c':
+        return COL_CIRCUIT_ID;
+        break;
+      case 'V':
+        return COL_VSAN;
+        break;
     }
     cptr++;
   }
-  return COL_NUMBER;
+  return -1;   /* illegal */
 }
 
 gchar *
 get_column_title(gint col) {
   GList    *clp = g_list_nth(prefs.col_list, col);
   fmt_data *cfmt;
-  
+
   cfmt = (fmt_data *) clp->data;
 
-  return(cfmt->title);  
+  return(cfmt->title);
 }
-
-#define MAX_FMT_PREF_LEN      1024
-#define MAX_FMT_PREF_LINE_LEN   60
-gchar *
-col_format_to_pref_str() {
-  static gchar  pref_str[MAX_FMT_PREF_LEN] = "";
-  GList        *clp = g_list_first(prefs.col_list);
-  fmt_data     *cfmt;
-  int           cur_pos = 0, cur_len = 0, fmt_len;
-  
-  while (clp) {
-    cfmt = (fmt_data *) clp->data;
-    
-    fmt_len = strlen(cfmt->title) + 4;
-    if ((fmt_len + cur_len) < (MAX_FMT_PREF_LEN - 1)) {
-      if ((fmt_len + cur_pos) > MAX_FMT_PREF_LINE_LEN) {
-        cur_len--;
-        cur_pos = 0;
-               pref_str[cur_len] = '\n'; cur_len++;
-        pref_str[cur_len] = '\t'; cur_len++;
-      }
-      sprintf(&pref_str[cur_len], "\"%s\", ", cfmt->title);
-      cur_len += fmt_len;
-      cur_pos += fmt_len;
-    }
-
-    fmt_len = strlen(cfmt->fmt) + 4;
-    if ((fmt_len + cur_len) < (MAX_FMT_PREF_LEN - 1)) {
-      if ((fmt_len + cur_pos) > MAX_FMT_PREF_LINE_LEN) {
-        cur_len--;
-        cur_pos = 0;
-        pref_str[cur_len] = '\n'; cur_len++;
-        pref_str[cur_len] = '\t'; cur_len++;
-      }
-      sprintf(&pref_str[cur_len], "\"%s\", ", cfmt->fmt);
-      cur_len += fmt_len;
-      cur_pos += fmt_len;
-    }
-    
-    clp = clp->next;
-  }
-  
-  if (cur_len > 2)
-    pref_str[cur_len - 2] = '\0';
-
-  return(pref_str);
-}