1998-11-17 04:29:13 +00:00
|
|
|
/* column.c
|
|
|
|
* Routines for handling column preferences
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1998-11-17 04:29:13 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1998-11-17 04:29:13 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-11-17 04:29:13 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-11-17 04:29:13 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-11-17 04:29:13 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
1998-12-17 05:42:33 +00:00
|
|
|
#include <stdio.h>
|
2000-11-17 21:00:40 +00:00
|
|
|
#include <string.h>
|
1998-11-17 04:29:13 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
1998-11-17 04:29:13 +00:00
|
|
|
#include <unistd.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/timestamp.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2007-06-04 20:15:10 +00:00
|
|
|
#include <epan/nstime.h>
|
|
|
|
#include <epan/dfilter/dfilter.h>
|
|
|
|
#include "cfile.h"
|
2004-09-29 02:54:22 +00:00
|
|
|
#include <epan/column.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
1998-11-17 04:29:13 +00:00
|
|
|
|
1999-09-10 07:09:35 +00:00
|
|
|
/* Given a format number (as defined in packet.h), returns its equivalent
|
1998-11-17 04:29:13 +00:00
|
|
|
string */
|
2005-07-23 11:41:25 +00:00
|
|
|
const gchar *
|
1998-11-17 04:29:13 +00:00
|
|
|
col_format_to_string(gint fmt) {
|
2005-07-23 11:41:25 +00:00
|
|
|
const gchar *slist[] = {
|
2007-08-17 19:34:14 +00:00
|
|
|
"%m",
|
|
|
|
"%t",
|
|
|
|
"%Rt",
|
|
|
|
"%At",
|
|
|
|
"%Yt",
|
|
|
|
"%Tt",
|
|
|
|
"%Gt",
|
|
|
|
"%s",
|
|
|
|
"%rs",
|
|
|
|
"%us",
|
|
|
|
"%hs",
|
|
|
|
"%rhs",
|
|
|
|
"%uhs",
|
|
|
|
"%ns",
|
|
|
|
"%rns",
|
|
|
|
"%uns",
|
|
|
|
"%d",
|
|
|
|
"%rd",
|
|
|
|
"%ud",
|
|
|
|
"%hd",
|
|
|
|
"%rhd",
|
2006-06-26 20:46:15 +00:00
|
|
|
"%uhd",
|
2007-08-17 19:34:14 +00:00
|
|
|
"%nd",
|
2006-06-26 20:46:15 +00:00
|
|
|
"%rnd",
|
2007-08-17 19:34:14 +00:00
|
|
|
"%und",
|
|
|
|
"%S",
|
|
|
|
"%rS",
|
|
|
|
"%uS",
|
|
|
|
"%D",
|
|
|
|
"%rD",
|
|
|
|
"%uD",
|
2006-06-26 20:46:15 +00:00
|
|
|
"%p",
|
2007-08-17 19:34:14 +00:00
|
|
|
"%i",
|
|
|
|
"%L",
|
|
|
|
"%B",
|
|
|
|
"%XO",
|
|
|
|
"%XR",
|
|
|
|
"%I",
|
|
|
|
"%c",
|
|
|
|
"%Xs",
|
|
|
|
"%Xd",
|
|
|
|
"%V",
|
|
|
|
"%x",
|
|
|
|
"%e",
|
|
|
|
"%H",
|
|
|
|
"%P",
|
|
|
|
"%y",
|
|
|
|
"%z",
|
|
|
|
"%q",
|
|
|
|
"%f",
|
|
|
|
"%U",
|
2006-11-29 06:44:07 +00:00
|
|
|
"%E",
|
2007-08-17 19:34:14 +00:00
|
|
|
"%C",
|
|
|
|
"%l",
|
|
|
|
"%a",
|
|
|
|
"%F"
|
2005-07-23 11:41:25 +00:00
|
|
|
};
|
2007-08-17 19:34:14 +00:00
|
|
|
|
2005-05-30 20:48:12 +00:00
|
|
|
if (fmt < 0 || fmt >= NUM_COL_FMTS)
|
1998-11-17 04:29:13 +00:00
|
|
|
return NULL;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
return(slist[fmt]);
|
|
|
|
}
|
|
|
|
|
1999-09-10 07:09:35 +00:00
|
|
|
/* Given a format number (as defined in packet.h), returns its
|
1998-11-17 04:29:13 +00:00
|
|
|
description */
|
2005-07-23 11:41:25 +00:00
|
|
|
static const gchar *dlist[NUM_COL_FMTS] = {
|
2006-06-26 20:46:15 +00:00
|
|
|
"Number", /* COL_NUMBER */
|
|
|
|
"Time (format as specified)", /* COL_CLS_TIME */
|
|
|
|
"Relative time", /* COL_REL_TIME */
|
|
|
|
"Absolute time", /* COL_ABS_TIME */
|
|
|
|
"Absolute date and time", /* COL_ABS_DATE_TIME */
|
|
|
|
"Delta time", /* COL_DELTA_TIME */
|
2007-03-23 18:08:17 +00:00
|
|
|
"Delta time displayed", /* COL_DELTA_TIME_DIS */
|
2006-06-26 20:46:15 +00:00
|
|
|
"Source address", /* COL_DEF_SRC */
|
|
|
|
"Src addr (resolved)", /* COL_RES_SRC */
|
|
|
|
"Src addr (unresolved)", /* COL_UNRES_SRC */
|
|
|
|
"Hardware src addr", /* COL_DEF_DL_SRC */
|
|
|
|
"Hw src addr (resolved)", /* COL_RES_DL_SRC*/
|
|
|
|
"Hw src addr (unresolved)", /* COL_UNRES_DL_SRC */
|
|
|
|
"Network src addr", /* COL_DEF_NET_SRC */
|
|
|
|
"Net src addr (resolved)", /* COL_RES_NET_SRC */
|
|
|
|
"Net src addr (unresolved)", /* COL_UNRES_NET_SRC */
|
|
|
|
"Destination address", /* COL_DEF_DST */
|
|
|
|
"Dest addr (resolved)", /* COL_RES_DST */
|
|
|
|
"Dest addr (unresolved)", /* COL_UNRES_DST */
|
|
|
|
"Hardware dest addr", /* COL_DEF_DL_DST */
|
|
|
|
"Hw dest addr (resolved)", /* COL_RES_DL_DST */
|
|
|
|
"Hw dest addr (unresolved)", /* COL_UNRES_DL_DST */
|
|
|
|
"Network dest addr", /* COL_DEF_NET_DST */
|
|
|
|
"Net dest addr (resolved)", /* COL_RES_NET_DST */
|
|
|
|
"Net dest addr (unresolved)", /* COL_UNRES_NET_DST */
|
|
|
|
"Source port", /* COL_DEF_SRC_PORT */
|
|
|
|
"Src port (resolved)", /* COL_RES_SRC_PORT */
|
|
|
|
"Src port (unresolved)", /* COL_UNRES_SRC_PORT */
|
|
|
|
"Destination port", /* COL_DEF_DST_PORT */
|
|
|
|
"Dest port (resolved)", /* COL_RES_DST_PORT */
|
|
|
|
"Dest port (unresolved)", /* COL_UNRES_DST_PORT */
|
|
|
|
"Protocol", /* COL_PROTOCOL */
|
|
|
|
"Information", /* COL_INFO */
|
|
|
|
"Packet length (bytes)" , /* COL_PACKET_LENGTH */
|
|
|
|
"Cumulative Bytes" , /* COL_CUMULATIVE_BYTES */
|
|
|
|
"Fibre Channel OXID", /* COL_OXID */
|
|
|
|
"Fibre Channel RXID", /* COL_RXID */
|
|
|
|
"FW-1 monitor if/direction", /* COL_IF_DIR */
|
|
|
|
"Circuit ID", /* COL_CIRCUIT_ID */
|
|
|
|
"Cisco Src PortIdx", /* COL_SRCIDX */
|
|
|
|
"Cisco Dst PortIdx", /* COL_DSTIDX */
|
|
|
|
"Cisco VSAN", /* COL_VSAN */
|
|
|
|
"IEEE 802.11 TX rate", /* COL_TX_RATE */
|
|
|
|
"IEEE 802.11 RSSI", /* COL_RSSI */
|
|
|
|
"HP-UX Subsystem", /* COL_HPUX_SUBSYS */
|
|
|
|
"HP-UX Device ID", /* COL_HPUX_DEVID */
|
|
|
|
"DCE/RPC call (cn_call_id / dg_seqnum)", /* COL_DCE_CALL */
|
|
|
|
"DCE/RPC context ID (cn_ctx_id)", /* COL_DCE_CTX */
|
|
|
|
"802.1Q VLAN id", /* COL_8021Q_VLAN_ID */
|
2007-08-17 19:34:14 +00:00
|
|
|
"IP DSCP Value", /* COL_DSCP_VALUE */
|
|
|
|
"L2 COS Value (802.1p)", /* COL_COS_VALUE */
|
2006-06-26 20:46:15 +00:00
|
|
|
"TEI", /* XXX - why is it missing in column_utils.c and elsewhere? */
|
2007-08-17 19:34:14 +00:00
|
|
|
"Frame Relay DLCI", /* COL_FR_DLCI */
|
|
|
|
"GPRS BSSGP TLLI", /* COL_BSSGP_TLLI */
|
|
|
|
"Expert Info Severity", /* COL_EXPERT */
|
|
|
|
"Frequency/Channel" /* COL_FREQ_CHAN */
|
2003-01-27 20:45:42 +00:00
|
|
|
};
|
|
|
|
|
2005-07-23 11:41:25 +00:00
|
|
|
const gchar *
|
1998-11-17 04:29:13 +00:00
|
|
|
col_format_desc(gint fmt) {
|
2003-01-27 20:45:42 +00:00
|
|
|
g_assert((fmt >= 0) && (fmt < NUM_COL_FMTS));
|
1998-11-17 04:29:13 +00:00
|
|
|
return(dlist[fmt]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Marks each array element true if it can be substituted for the given
|
|
|
|
column format */
|
|
|
|
void
|
|
|
|
get_column_format_matches(gboolean *fmt_list, gint format) {
|
2001-07-11 04:44:58 +00:00
|
|
|
|
|
|
|
/* Get the obvious: the format itself */
|
|
|
|
if ((format >= 0) && (format < NUM_COL_FMTS))
|
|
|
|
fmt_list[format] = TRUE;
|
|
|
|
|
|
|
|
/* Get any formats lower down on the chain */
|
|
|
|
switch (format) {
|
|
|
|
case COL_DEF_SRC:
|
|
|
|
fmt_list[COL_RES_DL_SRC] = TRUE;
|
|
|
|
fmt_list[COL_RES_NET_SRC] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_RES_SRC:
|
|
|
|
fmt_list[COL_RES_DL_SRC] = TRUE;
|
|
|
|
fmt_list[COL_RES_NET_SRC] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_UNRES_SRC:
|
|
|
|
fmt_list[COL_UNRES_DL_SRC] = TRUE;
|
|
|
|
fmt_list[COL_UNRES_NET_SRC] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_DST:
|
|
|
|
fmt_list[COL_RES_DL_DST] = TRUE;
|
|
|
|
fmt_list[COL_RES_NET_DST] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_RES_DST:
|
|
|
|
fmt_list[COL_RES_DL_DST] = TRUE;
|
|
|
|
fmt_list[COL_RES_NET_DST] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_UNRES_DST:
|
|
|
|
fmt_list[COL_UNRES_DL_DST] = TRUE;
|
|
|
|
fmt_list[COL_UNRES_NET_DST] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_DL_SRC:
|
|
|
|
fmt_list[COL_RES_DL_SRC] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_DL_DST:
|
|
|
|
fmt_list[COL_RES_DL_DST] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_NET_SRC:
|
|
|
|
fmt_list[COL_RES_NET_SRC] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_NET_DST:
|
|
|
|
fmt_list[COL_RES_NET_DST] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_SRC_PORT:
|
|
|
|
fmt_list[COL_RES_SRC_PORT] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_DEF_DST_PORT:
|
|
|
|
fmt_list[COL_RES_DST_PORT] = TRUE;
|
|
|
|
break;
|
2002-12-08 02:32:36 +00:00
|
|
|
case COL_OXID:
|
|
|
|
fmt_list[COL_OXID] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_RXID:
|
|
|
|
fmt_list[COL_RXID] = TRUE;
|
|
|
|
break;
|
2002-12-10 00:12:59 +00:00
|
|
|
case COL_IF_DIR:
|
|
|
|
fmt_list[COL_IF_DIR] = TRUE;
|
|
|
|
break;
|
2002-12-10 01:17:21 +00:00
|
|
|
case COL_CIRCUIT_ID:
|
|
|
|
fmt_list[COL_CIRCUIT_ID] = TRUE;
|
|
|
|
break;
|
2003-01-22 06:26:36 +00:00
|
|
|
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;
|
2004-07-05 09:29:06 +00:00
|
|
|
case COL_TX_RATE:
|
|
|
|
fmt_list[COL_TX_RATE] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_RSSI:
|
|
|
|
fmt_list[COL_RSSI] = TRUE;
|
|
|
|
break;
|
2005-04-01 10:17:05 +00:00
|
|
|
case COL_HPUX_SUBSYS:
|
|
|
|
fmt_list[COL_HPUX_SUBSYS] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_HPUX_DEVID:
|
|
|
|
fmt_list[COL_HPUX_DEVID] = TRUE;
|
|
|
|
break;
|
2005-06-30 22:46:19 +00:00
|
|
|
case COL_DCE_CALL:
|
|
|
|
fmt_list[COL_DCE_CALL] = TRUE;
|
|
|
|
break;
|
2006-06-26 20:46:15 +00:00
|
|
|
case COL_DCE_CTX:
|
|
|
|
fmt_list[COL_DCE_CTX] = TRUE;
|
|
|
|
break;
|
2006-01-20 08:48:43 +00:00
|
|
|
case COL_8021Q_VLAN_ID:
|
|
|
|
fmt_list[COL_8021Q_VLAN_ID] = TRUE;
|
|
|
|
break;
|
2006-12-11 20:24:51 +00:00
|
|
|
case COL_DSCP_VALUE:
|
|
|
|
fmt_list[COL_DSCP_VALUE] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_COS_VALUE:
|
|
|
|
fmt_list[COL_COS_VALUE] = TRUE;
|
|
|
|
break;
|
2006-03-02 21:29:15 +00:00
|
|
|
case COL_TEI:
|
|
|
|
fmt_list[COL_TEI] = TRUE;
|
|
|
|
break;
|
2006-11-29 06:44:07 +00:00
|
|
|
case COL_FR_DLCI:
|
|
|
|
fmt_list[COL_FR_DLCI] = TRUE;
|
|
|
|
break;
|
|
|
|
case COL_BSSGP_TLLI:
|
|
|
|
fmt_list[COL_BSSGP_TLLI] = TRUE;
|
|
|
|
break;
|
2007-07-23 20:11:05 +00:00
|
|
|
case COL_EXPERT:
|
|
|
|
fmt_list[COL_EXPERT] = TRUE;
|
|
|
|
break;
|
2007-08-17 19:34:14 +00:00
|
|
|
case COL_FREQ_CHAN:
|
|
|
|
fmt_list[COL_FREQ_CHAN] = TRUE;
|
|
|
|
break;
|
2001-07-11 04:44:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-17 19:34:14 +00:00
|
|
|
/* Returns a string representing the longest possible value for
|
2005-08-25 21:29:54 +00:00
|
|
|
a timestamp column type. */
|
|
|
|
static const char *
|
|
|
|
get_timestamp_column_longest_string(gint type, gint precision)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case(TS_ABSOLUTE_WITH_DATE):
|
|
|
|
switch(precision) {
|
|
|
|
case(TS_PREC_AUTO_SEC):
|
|
|
|
case(TS_PREC_FIXED_SEC):
|
|
|
|
return "0000-00-00 00:00:00";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_DSEC):
|
|
|
|
case(TS_PREC_FIXED_DSEC):
|
|
|
|
return "0000-00-00 00:00:00.0";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_CSEC):
|
|
|
|
case(TS_PREC_FIXED_CSEC):
|
|
|
|
return "0000-00-00 00:00:00.00";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_MSEC):
|
|
|
|
case(TS_PREC_FIXED_MSEC):
|
|
|
|
return "0000-00-00 00:00:00.000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_USEC):
|
|
|
|
case(TS_PREC_FIXED_USEC):
|
|
|
|
return "0000-00-00 00:00:00.000000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_NSEC):
|
|
|
|
case(TS_PREC_FIXED_NSEC):
|
|
|
|
return "0000-00-00 00:00:00.000000000";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case(TS_ABSOLUTE):
|
|
|
|
switch(precision) {
|
|
|
|
case(TS_PREC_AUTO_SEC):
|
|
|
|
case(TS_PREC_FIXED_SEC):
|
|
|
|
return "00:00:00";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_DSEC):
|
|
|
|
case(TS_PREC_FIXED_DSEC):
|
|
|
|
return "00:00:00.0";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_CSEC):
|
|
|
|
case(TS_PREC_FIXED_CSEC):
|
|
|
|
return "00:00:00.00";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_MSEC):
|
|
|
|
case(TS_PREC_FIXED_MSEC):
|
|
|
|
return "00:00:00.000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_USEC):
|
|
|
|
case(TS_PREC_FIXED_USEC):
|
|
|
|
return "00:00:00.000000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_NSEC):
|
|
|
|
case(TS_PREC_FIXED_NSEC):
|
|
|
|
return "00:00:00.000000000";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case(TS_RELATIVE): /* fallthrough */
|
|
|
|
case(TS_DELTA):
|
2007-03-23 18:08:17 +00:00
|
|
|
case(TS_DELTA_DIS):
|
2005-08-25 21:29:54 +00:00
|
|
|
switch(precision) {
|
|
|
|
case(TS_PREC_AUTO_SEC):
|
|
|
|
case(TS_PREC_FIXED_SEC):
|
|
|
|
return "0000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_DSEC):
|
|
|
|
case(TS_PREC_FIXED_DSEC):
|
|
|
|
return "0000.0";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_CSEC):
|
|
|
|
case(TS_PREC_FIXED_CSEC):
|
|
|
|
return "0000.00";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_MSEC):
|
|
|
|
case(TS_PREC_FIXED_MSEC):
|
|
|
|
return "0000.000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_USEC):
|
|
|
|
case(TS_PREC_FIXED_USEC):
|
|
|
|
return "0000.000000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_NSEC):
|
|
|
|
case(TS_PREC_FIXED_NSEC):
|
|
|
|
return "0000.000000000";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
2006-12-05 03:19:51 +00:00
|
|
|
case(TS_EPOCH):
|
|
|
|
/* This is enough to represent 2^63 (signed 64-bit integer) + fractions */
|
|
|
|
switch(precision) {
|
|
|
|
case(TS_PREC_AUTO_SEC):
|
|
|
|
case(TS_PREC_FIXED_SEC):
|
|
|
|
return "0000000000000000000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_DSEC):
|
|
|
|
case(TS_PREC_FIXED_DSEC):
|
|
|
|
return "0000000000000000000.0";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_CSEC):
|
|
|
|
case(TS_PREC_FIXED_CSEC):
|
|
|
|
return "0000000000000000000.00";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_MSEC):
|
|
|
|
case(TS_PREC_FIXED_MSEC):
|
|
|
|
return "0000000000000000000.000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_USEC):
|
|
|
|
case(TS_PREC_FIXED_USEC):
|
|
|
|
return "0000000000000000000.000000";
|
|
|
|
break;
|
|
|
|
case(TS_PREC_AUTO_NSEC):
|
|
|
|
case(TS_PREC_FIXED_NSEC):
|
|
|
|
return "0000000000000000000.000000000";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
2005-08-25 21:29:54 +00:00
|
|
|
case(TS_NOT_SET):
|
|
|
|
return "0000.000000";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* never reached, satisfy compiler */
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2007-08-17 19:34:14 +00:00
|
|
|
/* Returns the longer string of the column title or the hard-coded width of
|
2006-12-11 20:09:04 +00:00
|
|
|
* its contents for building the packet list layout. */
|
|
|
|
const gchar *
|
|
|
|
get_column_width_string(gint format, gint col)
|
|
|
|
{
|
|
|
|
if(strlen(get_column_longest_string(format)) >
|
|
|
|
strlen(get_column_title(col)))
|
|
|
|
return get_column_longest_string(format);
|
|
|
|
else
|
|
|
|
return get_column_title(col);
|
|
|
|
}
|
|
|
|
|
1999-09-12 06:11:51 +00:00
|
|
|
/* Returns a string representing the longest possible value for a
|
2006-12-11 20:24:51 +00:00
|
|
|
particular column type. See also get_column_width_string() above.
|
2000-01-10 01:44:00 +00:00
|
|
|
|
|
|
|
Except for the COL...SRC and COL...DST columns, these are used
|
|
|
|
only when a capture is being displayed while it's taking place;
|
|
|
|
they are arguably somewhat fragile, as changes to the code that
|
|
|
|
generates them don't cause these widths to change, but that's
|
|
|
|
probably not too big a problem, given that the sizes are
|
|
|
|
recomputed based on the actual data in the columns when the capture
|
|
|
|
is done, and given that the width for COL...SRC and COL...DST columns
|
|
|
|
is somewhat arbitrary in any case. We should probably clean
|
|
|
|
that up eventually, though. */
|
2005-07-23 11:41:25 +00:00
|
|
|
const char *
|
1999-09-12 06:11:51 +00:00
|
|
|
get_column_longest_string(gint format)
|
|
|
|
{
|
1999-07-22 21:14:13 +00:00
|
|
|
switch (format) {
|
|
|
|
case COL_NUMBER:
|
1999-09-12 06:11:51 +00:00
|
|
|
return "0000000";
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
|
|
|
case COL_CLS_TIME:
|
2005-08-25 21:29:54 +00:00
|
|
|
return get_timestamp_column_longest_string(timestamp_get_type(), timestamp_get_precision());
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
2000-11-01 08:31:36 +00:00
|
|
|
case COL_ABS_DATE_TIME:
|
2005-08-25 21:29:54 +00:00
|
|
|
return get_timestamp_column_longest_string(TS_ABSOLUTE_WITH_DATE, timestamp_get_precision());
|
|
|
|
break;
|
|
|
|
case COL_ABS_TIME:
|
|
|
|
return get_timestamp_column_longest_string(TS_ABSOLUTE, timestamp_get_precision());
|
2000-11-01 08:31:36 +00:00
|
|
|
break;
|
1999-07-22 21:14:13 +00:00
|
|
|
case COL_REL_TIME:
|
2005-08-25 21:29:54 +00:00
|
|
|
return get_timestamp_column_longest_string(TS_RELATIVE, timestamp_get_precision());
|
|
|
|
break;
|
1999-07-22 21:14:13 +00:00
|
|
|
case COL_DELTA_TIME:
|
2005-08-25 21:29:54 +00:00
|
|
|
return get_timestamp_column_longest_string(TS_DELTA, timestamp_get_precision());
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
2007-03-23 18:08:17 +00:00
|
|
|
case COL_DELTA_TIME_DIS:
|
|
|
|
return get_timestamp_column_longest_string(TS_DELTA_DIS, timestamp_get_precision());
|
|
|
|
break;
|
1999-07-22 21:14:13 +00:00
|
|
|
case COL_DEF_SRC:
|
|
|
|
case COL_RES_SRC:
|
|
|
|
case COL_UNRES_SRC:
|
|
|
|
case COL_DEF_DL_SRC:
|
|
|
|
case COL_RES_DL_SRC:
|
|
|
|
case COL_UNRES_DL_SRC:
|
|
|
|
case COL_DEF_NET_SRC:
|
|
|
|
case COL_RES_NET_SRC:
|
|
|
|
case COL_UNRES_NET_SRC:
|
|
|
|
case COL_DEF_DST:
|
|
|
|
case COL_RES_DST:
|
|
|
|
case COL_UNRES_DST:
|
|
|
|
case COL_DEF_DL_DST:
|
|
|
|
case COL_RES_DL_DST:
|
|
|
|
case COL_UNRES_DL_DST:
|
|
|
|
case COL_DEF_NET_DST:
|
|
|
|
case COL_RES_NET_DST:
|
|
|
|
case COL_UNRES_NET_DST:
|
1999-09-12 06:11:51 +00:00
|
|
|
return "00000000.000000000000"; /* IPX-style */
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
|
|
|
case COL_DEF_SRC_PORT:
|
|
|
|
case COL_RES_SRC_PORT:
|
|
|
|
case COL_UNRES_SRC_PORT:
|
|
|
|
case COL_DEF_DST_PORT:
|
|
|
|
case COL_RES_DST_PORT:
|
|
|
|
case COL_UNRES_DST_PORT:
|
1999-09-12 06:11:51 +00:00
|
|
|
return "000000";
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
|
|
|
case COL_PROTOCOL:
|
2003-12-09 06:48:40 +00:00
|
|
|
return "Protocol"; /* not the longest, but the longest is too long */
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
|
|
|
case COL_PACKET_LENGTH:
|
2005-06-30 22:46:19 +00:00
|
|
|
return "00000";
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
2004-01-31 04:10:05 +00:00
|
|
|
case COL_CUMULATIVE_BYTES:
|
2003-09-03 10:49:03 +00:00
|
|
|
return "00000000";
|
|
|
|
break;
|
2002-12-08 02:32:36 +00:00
|
|
|
case COL_RXID:
|
|
|
|
case COL_OXID:
|
|
|
|
return "000000";
|
|
|
|
break;
|
2002-12-10 00:12:59 +00:00
|
|
|
case COL_IF_DIR:
|
|
|
|
return "i 00000000 I";
|
|
|
|
break;
|
2002-12-10 01:17:21 +00:00
|
|
|
case COL_CIRCUIT_ID:
|
|
|
|
return "000000";
|
|
|
|
break;
|
2003-01-22 06:26:36 +00:00
|
|
|
case COL_SRCIDX:
|
|
|
|
case COL_DSTIDX:
|
|
|
|
return "0000000";
|
|
|
|
break;
|
|
|
|
case COL_VSAN:
|
2006-11-29 06:44:07 +00:00
|
|
|
return "000000";
|
2003-01-22 06:26:36 +00:00
|
|
|
break;
|
2004-07-05 09:29:06 +00:00
|
|
|
case COL_TX_RATE:
|
|
|
|
return "108.0";
|
|
|
|
break;
|
|
|
|
case COL_RSSI:
|
|
|
|
return "100";
|
|
|
|
break;
|
2005-04-01 10:17:05 +00:00
|
|
|
case COL_HPUX_SUBSYS:
|
|
|
|
return "OTS9000-TRANSPORT";
|
|
|
|
break;
|
|
|
|
case COL_HPUX_DEVID:
|
|
|
|
return "0000";
|
|
|
|
break;
|
2005-06-30 22:46:19 +00:00
|
|
|
case COL_DCE_CALL:
|
|
|
|
return "0000";
|
|
|
|
break;
|
2006-06-26 20:46:15 +00:00
|
|
|
case COL_DCE_CTX:
|
|
|
|
return "0000";
|
|
|
|
break;
|
2006-01-20 08:48:43 +00:00
|
|
|
case COL_8021Q_VLAN_ID:
|
|
|
|
return "0000";
|
|
|
|
break;
|
2006-12-11 20:24:51 +00:00
|
|
|
case COL_DSCP_VALUE:
|
|
|
|
return "00";
|
|
|
|
break;
|
|
|
|
case COL_COS_VALUE:
|
|
|
|
return "0";
|
|
|
|
break;
|
2006-03-02 21:29:15 +00:00
|
|
|
case COL_TEI:
|
|
|
|
return "127";
|
|
|
|
break;
|
2006-11-29 06:44:07 +00:00
|
|
|
case COL_FR_DLCI:
|
|
|
|
return "8388608";
|
|
|
|
break;
|
|
|
|
case COL_BSSGP_TLLI:
|
|
|
|
return "0xffffffff";
|
|
|
|
break;
|
2007-07-23 20:11:05 +00:00
|
|
|
case COL_EXPERT:
|
|
|
|
return "ERROR";
|
|
|
|
break;
|
2007-08-17 19:34:14 +00:00
|
|
|
case COL_FREQ_CHAN:
|
|
|
|
return "9999 MHz [A 999]";
|
|
|
|
break;
|
1999-07-22 21:14:13 +00:00
|
|
|
default: /* COL_INFO */
|
1999-09-12 06:11:51 +00:00
|
|
|
return "Source port: kerberos-master Destination port: kerberos-master";
|
1999-07-22 21:14:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-12 06:11:51 +00:00
|
|
|
/* Returns the longest possible width, in characters, for a particular
|
|
|
|
column type. */
|
|
|
|
gint
|
|
|
|
get_column_char_width(gint format)
|
|
|
|
{
|
|
|
|
return strlen(get_column_longest_string(format));
|
|
|
|
}
|
|
|
|
|
2000-11-01 08:31:36 +00:00
|
|
|
#define TIME_DEF 0
|
|
|
|
#define TIME_REL 1
|
|
|
|
#define TIME_ABS 2
|
|
|
|
#define DATE_TIME_ABS 3
|
|
|
|
#define TIME_DEL 4
|
2007-03-23 18:08:17 +00:00
|
|
|
#define TIME_DEL_DIS 5
|
1998-12-29 04:05:38 +00:00
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
#define RES_DEF 0
|
|
|
|
#define RES_DO 1
|
|
|
|
#define RES_DONT 2
|
|
|
|
|
|
|
|
#define ADDR_DEF 0
|
|
|
|
#define ADDR_DL 3
|
|
|
|
#define ADDR_NET 6
|
|
|
|
|
|
|
|
gint
|
|
|
|
get_column_format(gint col) {
|
1998-11-18 03:01:44 +00:00
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1998-11-18 03:01:44 +00:00
|
|
|
cfmt = (fmt_data *) clp->data;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
return(get_column_format_from_str(cfmt->fmt));
|
|
|
|
}
|
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
gint
|
1998-11-17 04:29:13 +00:00
|
|
|
get_column_format_from_str(gchar *str) {
|
1998-11-18 03:01:44 +00:00
|
|
|
gchar *cptr = str;
|
1998-12-29 04:05:38 +00:00
|
|
|
gint res_off = RES_DEF, addr_off = ADDR_DEF, time_off = TIME_DEF;
|
2002-12-08 02:32:36 +00:00
|
|
|
gint prev_code = -1;
|
1998-11-17 04:29:13 +00:00
|
|
|
|
|
|
|
/* To do: Make this parse %-formatted strings "for real" */
|
|
|
|
while (*cptr != '\0') {
|
|
|
|
switch (*cptr) {
|
|
|
|
case 't': /* To do: fix for absolute and delta */
|
1998-12-29 04:05:38 +00:00
|
|
|
return COL_CLS_TIME + time_off;
|
1998-11-17 04:29:13 +00:00
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
return COL_NUMBER;
|
|
|
|
break;
|
|
|
|
case 's':
|
2003-01-22 06:26:36 +00:00
|
|
|
if (prev_code == COL_OXID) {
|
|
|
|
return COL_SRCIDX;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return COL_DEF_SRC + res_off + addr_off;
|
|
|
|
}
|
1998-11-17 04:29:13 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
2003-01-22 06:26:36 +00:00
|
|
|
if (prev_code == COL_OXID) {
|
|
|
|
return COL_DSTIDX;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return COL_DEF_DST + res_off + addr_off;
|
|
|
|
}
|
1998-11-17 04:29:13 +00:00
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
return COL_DEF_SRC_PORT + res_off;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
return COL_DEF_DST_PORT + res_off;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
return COL_PROTOCOL;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
return COL_INFO;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
res_off = RES_DO;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
res_off = RES_DONT;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
addr_off = ADDR_DL;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
addr_off = ADDR_NET;
|
|
|
|
break;
|
1998-12-29 04:05:38 +00:00
|
|
|
case 'R':
|
2002-12-08 02:32:36 +00:00
|
|
|
if (prev_code == COL_OXID) {
|
|
|
|
return COL_RXID;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
time_off = TIME_REL;
|
|
|
|
}
|
1998-12-29 04:05:38 +00:00
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
time_off = TIME_ABS;
|
|
|
|
break;
|
2000-11-01 08:31:36 +00:00
|
|
|
case 'Y':
|
|
|
|
time_off = DATE_TIME_ABS;
|
|
|
|
break;
|
1998-12-29 04:05:38 +00:00
|
|
|
case 'T':
|
|
|
|
time_off = TIME_DEL;
|
|
|
|
break;
|
2007-03-23 18:08:17 +00:00
|
|
|
case 'G': /* Todo: use a better letter for time since last displayed packet */
|
|
|
|
time_off = TIME_DEL_DIS;
|
|
|
|
break;
|
1999-07-22 16:03:52 +00:00
|
|
|
case 'L':
|
|
|
|
return COL_PACKET_LENGTH;
|
|
|
|
break;
|
2003-09-03 10:49:03 +00:00
|
|
|
case 'B':
|
2004-01-31 04:10:05 +00:00
|
|
|
return COL_CUMULATIVE_BYTES;
|
2003-09-03 10:49:03 +00:00
|
|
|
break;
|
2002-12-08 02:32:36 +00:00
|
|
|
case 'X':
|
|
|
|
prev_code = COL_OXID;
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
return COL_OXID;
|
|
|
|
break;
|
2002-12-10 01:17:21 +00:00
|
|
|
case 'I':
|
|
|
|
return COL_IF_DIR;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
return COL_CIRCUIT_ID;
|
|
|
|
break;
|
2003-01-22 06:26:36 +00:00
|
|
|
case 'V':
|
|
|
|
return COL_VSAN;
|
|
|
|
break;
|
2004-07-05 09:29:06 +00:00
|
|
|
case 'x':
|
|
|
|
return COL_TX_RATE;
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
return COL_RSSI;
|
|
|
|
break;
|
2005-04-01 10:17:05 +00:00
|
|
|
case 'H':
|
|
|
|
return COL_HPUX_SUBSYS;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
return COL_HPUX_DEVID;
|
|
|
|
break;
|
2005-06-30 22:46:19 +00:00
|
|
|
case 'y':
|
|
|
|
return COL_DCE_CALL;
|
|
|
|
break;
|
2006-06-26 20:46:15 +00:00
|
|
|
case 'z':
|
|
|
|
return COL_DCE_CTX;
|
|
|
|
break;
|
2006-12-11 20:24:51 +00:00
|
|
|
case 'q':
|
2006-01-20 08:48:43 +00:00
|
|
|
return COL_8021Q_VLAN_ID;
|
|
|
|
break;
|
2006-12-11 20:24:51 +00:00
|
|
|
case 'f':
|
|
|
|
return COL_DSCP_VALUE;
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
return COL_COS_VALUE;
|
|
|
|
break;
|
2006-03-02 21:29:15 +00:00
|
|
|
case 'E':
|
|
|
|
return COL_TEI;
|
2006-11-29 06:44:07 +00:00
|
|
|
case 'C':
|
|
|
|
return COL_FR_DLCI;
|
|
|
|
case 'l':
|
|
|
|
return COL_BSSGP_TLLI;
|
2006-03-02 21:29:15 +00:00
|
|
|
break;
|
2007-07-23 20:11:05 +00:00
|
|
|
case 'a':
|
|
|
|
return COL_EXPERT;
|
|
|
|
break;
|
2007-08-17 19:34:14 +00:00
|
|
|
case 'F':
|
|
|
|
return COL_FREQ_CHAN;
|
|
|
|
break;
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
cptr++;
|
|
|
|
}
|
2001-07-22 21:50:47 +00:00
|
|
|
return -1; /* illegal */
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
get_column_title(gint col) {
|
1998-11-18 03:01:44 +00:00
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1998-11-18 03:01:44 +00:00
|
|
|
cfmt = (fmt_data *) clp->data;
|
1998-11-17 04:29:13 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
return(cfmt->title);
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
2007-06-04 20:15:10 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
build_column_format_array(capture_file *cfile, gboolean reset_fences)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
col_setup(&cfile->cinfo, prefs.num_cols);
|
|
|
|
|
|
|
|
for (i = 0; i < cfile->cinfo.num_cols; i++) {
|
|
|
|
cfile->cinfo.col_fmt[i] = get_column_format(i);
|
|
|
|
cfile->cinfo.col_title[i] = g_strdup(get_column_title(i));
|
|
|
|
cfile->cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
|
|
|
|
NUM_COL_FMTS);
|
|
|
|
get_column_format_matches(cfile->cinfo.fmt_matx[i],
|
|
|
|
cfile->cinfo.col_fmt[i]);
|
|
|
|
cfile->cinfo.col_data[i] = NULL;
|
|
|
|
|
|
|
|
if (cfile->cinfo.col_fmt[i] == COL_INFO)
|
|
|
|
cfile->cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) *
|
|
|
|
COL_MAX_INFO_LEN);
|
|
|
|
else
|
|
|
|
cfile->cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2007-08-17 19:34:14 +00:00
|
|
|
|
2007-06-04 20:15:10 +00:00
|
|
|
for (i = 0; i < cfile->cinfo.num_cols; i++) {
|
|
|
|
for (j = 0; j < NUM_COL_FMTS; j++) {
|
|
|
|
if (!cfile->cinfo.fmt_matx[i][j])
|
|
|
|
continue;
|
2007-08-17 19:34:14 +00:00
|
|
|
|
2007-06-04 20:15:10 +00:00
|
|
|
if (cfile->cinfo.col_first[j] == -1)
|
|
|
|
cfile->cinfo.col_first[j] = i;
|
|
|
|
|
|
|
|
cfile->cinfo.col_last[j] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|