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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
1998-11-17 04:29:13 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
1998-11-17 04:29:13 +00:00
|
|
|
|
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/dfilter/dfilter.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
|
|
|
|
2013-10-18 13:06:05 +00:00
|
|
|
/* Given a format number (as defined in column-info.h), returns its equivalent
|
1998-11-17 04:29:13 +00:00
|
|
|
string */
|
2005-07-23 11:41:25 +00:00
|
|
|
const gchar *
|
2010-04-03 18:18:50 +00:00
|
|
|
col_format_to_string(const gint fmt) {
|
Declare slist[] as static (reduces storage & code executed: *See below);
Declare dlist[] similarly to slist[] (not really needed since generated storage/code was OK as is)
*On Windows the following program generates sub-optimal code
(when built using VC10 or VC11 with CFLAGS as used when building Wireshark).
void foo(void) {
const char *const zz[] = {"ABC", "abc"};
}
-------------
Code generated:
<snip>
_DATA SEGMENT
$SG1013 DB 'ABC', 00H !!! note string stored twice !!
$SG1014 DB 'ABC', 00H
$SG1015 DB 'abc', 00H
$SG1016 DB 'abc', 00H
_DATA ENDS
<snip>
; 1 : void foo(void) {
push ebp
mov ebp, esp
sub esp, 8
; 2 : const char *const zz[] = {"ABC", "abc"};
mov DWORD PTR _zz$[ebp], OFFSET $SG1014 !! note: each ptr of array
mov DWORD PTR _zz$[ebp+4], OFFSET $SG1016 !! individually pushed on stack
<snip>
Not shown: Declaring zz as 'static' generates much better code....
svn path=/trunk/; revision=50271
2013-06-30 23:03:20 +00:00
|
|
|
static const gchar *const slist[NUM_COL_FMTS] = {
|
2008-02-25 05:13:45 +00:00
|
|
|
"%q", /* 0) COL_8021Q_VLAN_ID */
|
|
|
|
"%Yt", /* 1) COL_ABS_DATE_TIME */
|
|
|
|
"%At", /* 2) COL_ABS_TIME */
|
|
|
|
"%c", /* 3) COL_CIRCUIT_ID */
|
2013-10-27 23:18:19 +00:00
|
|
|
"%Xd", /* 4) COL_DSTIDX - !! DEPRECATED !!*/
|
|
|
|
"%Xs", /* 5) COL_SRCIDX - !! DEPRECATED !!*/
|
|
|
|
"%V", /* 6) COL_VSAN - !! DEPRECATED !!*/
|
2008-02-25 05:13:45 +00:00
|
|
|
"%B", /* 7) COL_CUMULATIVE_BYTES */
|
|
|
|
"%Cus", /* 8) COL_CUSTOM */
|
|
|
|
"%y", /* 9) COL_DCE_CALL */
|
|
|
|
"%z", /* 10) COL_DCE_CTX */
|
|
|
|
"%Tt", /* 11) COL_DELTA_TIME */
|
|
|
|
"%dct", /* 12) COL_DELTA_CONV_TIME */
|
|
|
|
"%Gt", /* 13) COL_DELTA_TIME_DIS */
|
|
|
|
"%rd", /* 14) COL_RES_DST */
|
|
|
|
"%ud", /* 15) COL_UNRES_DST */
|
|
|
|
"%rD", /* 16) COL_RES_DST_PORT */
|
|
|
|
"%uD", /* 17) COL_UNRES_DST_PORT */
|
|
|
|
"%d", /* 18) COL_DEF_DST */
|
|
|
|
"%D", /* 19) COL_DEF_DST_PORT */
|
|
|
|
"%a", /* 20) COL_EXPERT */
|
|
|
|
"%I", /* 21) COL_IF_DIR */
|
|
|
|
"%XO", /* 22) COL_OXID */
|
|
|
|
"%XR", /* 23) COL_RXID */
|
2009-08-23 12:16:10 +00:00
|
|
|
"%C", /* 24) !! DEPRECATED !! - COL_FR_DLCI */
|
2008-02-25 05:13:45 +00:00
|
|
|
"%F", /* 25) COL_FREQ_CHAN */
|
2009-08-25 05:42:14 +00:00
|
|
|
"%l", /* 26) !! DEPRECATED !! - COL_BSSGP_TLLI */
|
2009-08-23 10:25:51 +00:00
|
|
|
"%P", /* 27) !! DEPRECATED !! - COL_HPUX_DEVID */
|
2009-08-23 10:20:42 +00:00
|
|
|
"%H", /* 28) !! DEPRECATED !! - COL_HPUX_SUBSYS */
|
2008-02-25 05:13:45 +00:00
|
|
|
"%hd", /* 29) COL_DEF_DL_DST */
|
|
|
|
"%hs", /* 30) COL_DEF_DL_SRC */
|
|
|
|
"%rhd", /* 31) COL_RES_DL_DST */
|
|
|
|
"%uhd", /* 32) COL_UNRES_DL_DST */
|
|
|
|
"%rhs", /* 33) COL_RES_DL_SRC*/
|
|
|
|
"%uhs", /* 34) COL_UNRES_DL_SRC */
|
|
|
|
"%e", /* 35) COL_RSSI */
|
|
|
|
"%x", /* 36) COL_TX_RATE */
|
|
|
|
"%f", /* 37) COL_DSCP_VALUE */
|
|
|
|
"%i", /* 38) COL_INFO */
|
2009-08-23 09:07:54 +00:00
|
|
|
"%U", /* 39) !! DEPRECATED !! - COL_COS_VALUE */
|
2008-02-25 05:13:45 +00:00
|
|
|
"%rnd", /* 40) COL_RES_NET_DST */
|
|
|
|
"%und", /* 41) COL_UNRES_NET_DST */
|
|
|
|
"%rns", /* 42) COL_RES_NET_SRC */
|
|
|
|
"%uns", /* 43) COL_UNRES_NET_SRC */
|
|
|
|
"%nd", /* 44) COL_DEF_NET_DST */
|
|
|
|
"%ns", /* 45) COL_DEF_NET_SRC */
|
|
|
|
"%m", /* 46) COL_NUMBER */
|
|
|
|
"%L", /* 47) COL_PACKET_LENGTH */
|
|
|
|
"%p", /* 48) COL_PROTOCOL */
|
|
|
|
"%Rt", /* 49) COL_REL_TIME */
|
2009-08-23 12:24:14 +00:00
|
|
|
"%rct", /* 50) !! DEPRECATED !! - COL_REL_CONV_TIME */
|
2008-02-25 05:13:45 +00:00
|
|
|
"%s", /* 51) COL_DEF_SRC */
|
|
|
|
"%S", /* 52) COL_DEF_SRC_PORT */
|
|
|
|
"%rs", /* 53) COL_RES_SRC */
|
|
|
|
"%us", /* 54) COL_UNRES_SRC */
|
|
|
|
"%rS", /* 55) COL_RES_SRC_PORT */
|
|
|
|
"%uS", /* 56) COL_UNRES_SRC_PORT */
|
|
|
|
"%E", /* 57) COL_TEI */
|
2011-07-04 21:43:34 +00:00
|
|
|
"%Yut", /* 58) COL_UTC_DATE_TIME */
|
|
|
|
"%Aut", /* 59) COL_UTC_TIME */
|
|
|
|
"%t" /* 60) COL_CLS_TIME */
|
2007-09-22 00:16:45 +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]);
|
|
|
|
}
|
|
|
|
|
2013-10-18 13:06:05 +00:00
|
|
|
/* Given a format number (as defined in column-info.h), returns its
|
1998-11-17 04:29:13 +00:00
|
|
|
description */
|
Declare slist[] as static (reduces storage & code executed: *See below);
Declare dlist[] similarly to slist[] (not really needed since generated storage/code was OK as is)
*On Windows the following program generates sub-optimal code
(when built using VC10 or VC11 with CFLAGS as used when building Wireshark).
void foo(void) {
const char *const zz[] = {"ABC", "abc"};
}
-------------
Code generated:
<snip>
_DATA SEGMENT
$SG1013 DB 'ABC', 00H !!! note string stored twice !!
$SG1014 DB 'ABC', 00H
$SG1015 DB 'abc', 00H
$SG1016 DB 'abc', 00H
_DATA ENDS
<snip>
; 1 : void foo(void) {
push ebp
mov ebp, esp
sub esp, 8
; 2 : const char *const zz[] = {"ABC", "abc"};
mov DWORD PTR _zz$[ebp], OFFSET $SG1014 !! note: each ptr of array
mov DWORD PTR _zz$[ebp+4], OFFSET $SG1016 !! individually pushed on stack
<snip>
Not shown: Declaring zz as 'static' generates much better code....
svn path=/trunk/; revision=50271
2013-06-30 23:03:20 +00:00
|
|
|
const gchar *
|
|
|
|
col_format_desc(const gint fmt) {
|
|
|
|
static const gchar *const dlist[NUM_COL_FMTS] = {
|
2008-02-25 05:13:45 +00:00
|
|
|
"802.1Q VLAN id", /* 0) COL_8021Q_VLAN_ID */
|
|
|
|
"Absolute date and time", /* 1) COL_ABS_DATE_TIME */
|
|
|
|
"Absolute time", /* 2) COL_ABS_TIME */
|
|
|
|
"Circuit ID", /* 3) COL_CIRCUIT_ID */
|
|
|
|
"Cisco Dst PortIdx", /* 4) COL_DSTIDX */
|
|
|
|
"Cisco Src PortIdx", /* 5) COL_SRCIDX */
|
|
|
|
"Cisco VSAN", /* 6) COL_VSAN */
|
|
|
|
"Cumulative Bytes" , /* 7) COL_CUMULATIVE_BYTES */
|
|
|
|
"Custom", /* 8) COL_CUSTOM */
|
|
|
|
"DCE/RPC call (cn_call_id / dg_seqnum)", /* 9) COL_DCE_CALL */
|
|
|
|
"DCE/RPC context ID (cn_ctx_id)", /* 10) COL_DCE_CTX */
|
|
|
|
"Delta time", /* 11) COL_DELTA_TIME */
|
|
|
|
"Delta time (conversation)", /* 12) COL_DELTA_CONV_TIME */
|
|
|
|
"Delta time displayed", /* 13) COL_DELTA_TIME_DIS */
|
|
|
|
"Dest addr (resolved)", /* 14) COL_RES_DST */
|
|
|
|
"Dest addr (unresolved)", /* 15) COL_UNRES_DST */
|
|
|
|
"Dest port (resolved)", /* 16) COL_RES_DST_PORT */
|
|
|
|
"Dest port (unresolved)", /* 17) COL_UNRES_DST_PORT */
|
|
|
|
"Destination address", /* 18) COL_DEF_DST */
|
|
|
|
"Destination port", /* 19) COL_DEF_DST_PORT */
|
|
|
|
"Expert Info Severity", /* 20) COL_EXPERT */
|
|
|
|
"FW-1 monitor if/direction", /* 21) COL_IF_DIR */
|
|
|
|
"Fibre Channel OXID", /* 22) COL_OXID */
|
|
|
|
"Fibre Channel RXID", /* 23) COL_RXID */
|
2009-08-23 12:16:10 +00:00
|
|
|
"Frame Relay DLCI", /* 24) !! DEPRECATED !! - COL_FR_DLCI */
|
2008-02-25 05:13:45 +00:00
|
|
|
"Frequency/Channel", /* 25) COL_FREQ_CHAN */
|
2009-08-25 06:11:57 +00:00
|
|
|
"GPRS BSSGP TLLI", /* 26) !! DEPRECATED !! - COL_BSSGP_TLLI */
|
2009-08-23 10:25:51 +00:00
|
|
|
"HP-UX Device ID", /* 27) !! DEPRECATED !! - COL_HPUX_DEVID */
|
2009-08-23 10:20:42 +00:00
|
|
|
"HP-UX Subsystem", /* 28) !! DEPRECATED !! - COL_HPUX_SUBSYS */
|
2008-02-25 05:13:45 +00:00
|
|
|
"Hardware dest addr", /* 29) COL_DEF_DL_DST */
|
|
|
|
"Hardware src addr", /* 30) COL_DEF_DL_SRC */
|
|
|
|
"Hw dest addr (resolved)", /* 31) COL_RES_DL_DST */
|
|
|
|
"Hw dest addr (unresolved)", /* 32) COL_UNRES_DL_DST */
|
|
|
|
"Hw src addr (resolved)", /* 33) COL_RES_DL_SRC*/
|
|
|
|
"Hw src addr (unresolved)", /* 34) COL_UNRES_DL_SRC */
|
|
|
|
"IEEE 802.11 RSSI", /* 35) COL_RSSI */
|
|
|
|
"IEEE 802.11 TX rate", /* 36) COL_TX_RATE */
|
|
|
|
"IP DSCP Value", /* 37) COL_DSCP_VALUE */
|
|
|
|
"Information", /* 38) COL_INFO */
|
2009-08-23 09:07:54 +00:00
|
|
|
"L2 COS Value (802.1p)", /* 39) !! DEPRECATED !! - COL_COS_VALUE */
|
2008-02-25 05:13:45 +00:00
|
|
|
"Net dest addr (resolved)", /* 40) COL_RES_NET_DST */
|
|
|
|
"Net dest addr (unresolved)", /* 41) COL_UNRES_NET_DST */
|
|
|
|
"Net src addr (resolved)", /* 42) COL_RES_NET_SRC */
|
|
|
|
"Net src addr (unresolved)", /* 43) COL_UNRES_NET_SRC */
|
|
|
|
"Network dest addr", /* 44) COL_DEF_NET_DST */
|
|
|
|
"Network src addr", /* 45) COL_DEF_NET_SRC */
|
|
|
|
"Number", /* 46) COL_NUMBER */
|
|
|
|
"Packet length (bytes)" , /* 47) COL_PACKET_LENGTH */
|
|
|
|
"Protocol", /* 48) COL_PROTOCOL */
|
|
|
|
"Relative time", /* 49) COL_REL_TIME */
|
2009-08-23 12:24:14 +00:00
|
|
|
"Relative time (conversation)", /* 50) !! DEPRECATED !! - COL_REL_CONV_TIME */
|
2008-02-25 05:13:45 +00:00
|
|
|
"Source address", /* 51) COL_DEF_SRC */
|
|
|
|
"Source port", /* 52) COL_DEF_SRC_PORT */
|
|
|
|
"Src addr (resolved)", /* 53) COL_RES_SRC */
|
|
|
|
"Src addr (unresolved)", /* 54) COL_UNRES_SRC */
|
|
|
|
"Src port (resolved)", /* 55) COL_RES_SRC_PORT */
|
|
|
|
"Src port (unresolved)", /* 56) COL_UNRES_SRC_PORT */
|
|
|
|
"TEI", /* 57) COL_TEI */
|
2011-07-04 21:43:34 +00:00
|
|
|
"UTC date and time", /* 58) COL_UTC_DATE_TIME */
|
|
|
|
"UTC time", /* 59) COL_UTC_TIME */
|
|
|
|
"Time (format as specified)" /* 60) COL_CLS_TIME */
|
Declare slist[] as static (reduces storage & code executed: *See below);
Declare dlist[] similarly to slist[] (not really needed since generated storage/code was OK as is)
*On Windows the following program generates sub-optimal code
(when built using VC10 or VC11 with CFLAGS as used when building Wireshark).
void foo(void) {
const char *const zz[] = {"ABC", "abc"};
}
-------------
Code generated:
<snip>
_DATA SEGMENT
$SG1013 DB 'ABC', 00H !!! note string stored twice !!
$SG1014 DB 'ABC', 00H
$SG1015 DB 'abc', 00H
$SG1016 DB 'abc', 00H
_DATA ENDS
<snip>
; 1 : void foo(void) {
push ebp
mov ebp, esp
sub esp, 8
; 2 : const char *const zz[] = {"ABC", "abc"};
mov DWORD PTR _zz$[ebp], OFFSET $SG1014 !! note: each ptr of array
mov DWORD PTR _zz$[ebp+4], OFFSET $SG1016 !! individually pushed on stack
<snip>
Not shown: Declaring zz as 'static' generates much better code....
svn path=/trunk/; revision=50271
2013-06-30 23:03:20 +00:00
|
|
|
};
|
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]);
|
|
|
|
}
|
|
|
|
|
2013-10-15 18:27:35 +00:00
|
|
|
void
|
|
|
|
column_dump_column_formats(void)
|
|
|
|
{
|
|
|
|
gint fmt;
|
|
|
|
|
|
|
|
for (fmt = 0; fmt < NUM_COL_FMTS; fmt++) {
|
|
|
|
printf("%s\t%s\n", col_format_to_string(fmt), col_format_desc(fmt));
|
|
|
|
}
|
2013-10-23 17:47:47 +00:00
|
|
|
|
|
|
|
printf("\nFor example, to print Wireshark's default columns with tshark:\n\n"
|
|
|
|
#ifdef _WIN32
|
|
|
|
"tshark.exe -o \"gui.column.format:"
|
|
|
|
"\\\"No.\\\",\\\"%%m\\\","
|
|
|
|
"\\\"Time\\\",\\\"%%t\\\","
|
|
|
|
"\\\"Source\\\",\\\"%%s\\\","
|
|
|
|
"\\\"Destination\\\",\\\"%%d\\\","
|
|
|
|
"\\\"Protocol\\\",\\\"%%p\\\","
|
|
|
|
"\\\"Length\\\",\\\"%%L\\\","
|
|
|
|
"\\\"Info\\\",\\\"%%i\\\"\"\n");
|
|
|
|
#else
|
|
|
|
"tshark -o 'gui.column.format:"
|
|
|
|
"\"No.\",\"%%m\","
|
|
|
|
"\"Time\",\"%%t\","
|
|
|
|
"\"Source\",\"%%s\","
|
|
|
|
"\"Destination\",\"%%d\","
|
|
|
|
"\"Protocol\",\"%%p\","
|
|
|
|
"\"Length\",\"%%L\","
|
|
|
|
"\"Info\",\"%%i\"'\n");
|
|
|
|
#endif
|
2013-10-15 18:27:35 +00:00
|
|
|
}
|
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
/* Marks each array element true if it can be substituted for the given
|
|
|
|
column format */
|
|
|
|
void
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_format_matches(gboolean *fmt_list, const 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;
|
|
|
|
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 *
|
2010-04-03 18:18:50 +00:00
|
|
|
get_timestamp_column_longest_string(const gint type, const gint precision)
|
2005-08-25 21:29:54 +00:00
|
|
|
{
|
|
|
|
|
2009-09-08 17:29:57 +00:00
|
|
|
switch(type) {
|
|
|
|
case(TS_ABSOLUTE_WITH_DATE):
|
2011-07-04 21:43:34 +00:00
|
|
|
case(TS_UTC_WITH_DATE):
|
2009-09-08 17:29:57 +00:00
|
|
|
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):
|
2011-07-04 21:43:34 +00:00
|
|
|
case(TS_UTC):
|
2009-09-08 17:29:57 +00:00
|
|
|
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):
|
|
|
|
case(TS_DELTA_DIS):
|
|
|
|
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;
|
|
|
|
case(TS_EPOCH):
|
2006-12-05 03:19:51 +00:00
|
|
|
/* This is enough to represent 2^63 (signed 64-bit integer) + fractions */
|
2009-09-08 17:29:57 +00:00
|
|
|
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;
|
|
|
|
case(TS_NOT_SET):
|
|
|
|
return "0000.000000";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* never reached, satisfy compiler */
|
|
|
|
return "";
|
2005-08-25 21:29:54 +00:00
|
|
|
}
|
|
|
|
|
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 *
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_width_string(const gint format, const gint col)
|
2006-12-11 20:09:04 +00:00
|
|
|
{
|
2009-09-08 17:29:57 +00:00
|
|
|
if(strlen(get_column_longest_string(format)) >
|
|
|
|
strlen(get_column_title(col)))
|
|
|
|
return get_column_longest_string(format);
|
|
|
|
else
|
|
|
|
return get_column_title(col);
|
2006-12-11 20:09:04 +00:00
|
|
|
}
|
|
|
|
|
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 *
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_longest_string(const gint format)
|
1999-09-12 06:11:51 +00:00
|
|
|
{
|
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;
|
2011-07-04 21:43:34 +00:00
|
|
|
case COL_UTC_DATE_TIME:
|
|
|
|
return get_timestamp_column_longest_string(TS_UTC_WITH_DATE, timestamp_get_precision());
|
|
|
|
break;
|
2005-08-25 21:29:54 +00:00
|
|
|
case COL_ABS_TIME:
|
|
|
|
return get_timestamp_column_longest_string(TS_ABSOLUTE, timestamp_get_precision());
|
2000-11-01 08:31:36 +00:00
|
|
|
break;
|
2011-07-04 21:43:34 +00:00
|
|
|
case COL_UTC_TIME:
|
|
|
|
return get_timestamp_column_longest_string(TS_UTC, timestamp_get_precision());
|
|
|
|
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;
|
2009-09-08 17:29:57 +00:00
|
|
|
case COL_REL_CONV_TIME: /* 'abuse' TS_RELATIVE to set the time format */
|
|
|
|
case COL_DELTA_CONV_TIME: /* for the conversation related time columns */
|
2007-10-03 14:02:08 +00:00
|
|
|
return get_timestamp_column_longest_string(TS_RELATIVE, 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:
|
2009-09-08 17:29:57 +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:
|
2013-10-27 23:18:19 +00:00
|
|
|
return "00000000";
|
2003-01-22 06:26:36 +00:00
|
|
|
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;
|
2008-02-22 11:32:36 +00:00
|
|
|
case COL_CUSTOM:
|
2009-09-08 17:29:57 +00:00
|
|
|
return "0000000000"; /* not the longest, but the longest is too long */
|
2008-02-22 11:32:36 +00:00
|
|
|
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
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_char_width(const gint format)
|
1999-09-12 06:11:51 +00:00
|
|
|
{
|
2009-04-07 16:36:52 +00:00
|
|
|
return (gint)strlen(get_column_longest_string(format));
|
1999-09-12 06:11:51 +00:00
|
|
|
}
|
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
gint
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_format(const gint col)
|
2009-10-12 08:04:30 +00:00
|
|
|
{
|
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
|
|
|
|
2009-10-12 07:56:26 +00:00
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return -1;
|
2009-10-12 08:04:30 +00:00
|
|
|
|
1998-11-18 03:01:44 +00:00
|
|
|
cfmt = (fmt_data *) clp->data;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2011-11-13 22:51:49 +00:00
|
|
|
return(cfmt->fmt);
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-09 15:22:53 +00:00
|
|
|
void
|
|
|
|
set_column_format(const gint col, const gint fmt)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
2011-11-13 22:51:49 +00:00
|
|
|
cfmt->fmt = fmt;
|
2010-10-09 15:22:53 +00:00
|
|
|
}
|
|
|
|
|
2000-01-10 01:44:00 +00:00
|
|
|
gint
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_format_from_str(const gchar *str)
|
2009-10-12 08:04:30 +00:00
|
|
|
{
|
2007-09-22 00:16:45 +00:00
|
|
|
gint i;
|
1998-11-17 04:29:13 +00:00
|
|
|
|
2007-09-22 00:16:45 +00:00
|
|
|
for (i = 0; i < NUM_COL_FMTS; i++) {
|
|
|
|
if (strcmp(str, col_format_to_string(i)) == 0)
|
|
|
|
return i;
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
2009-09-08 17:29:57 +00:00
|
|
|
return -1; /* illegal */
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_title(const gint col)
|
2009-10-12 08:04:30 +00:00
|
|
|
{
|
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
|
|
|
|
2009-10-12 08:04:30 +00:00
|
|
|
if (!clp) /* Invalid column requested */
|
2009-10-12 09:13:37 +00:00
|
|
|
return NULL;
|
2009-10-12 08:04:30 +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
|
|
|
|
2010-10-09 15:22:53 +00:00
|
|
|
void
|
|
|
|
set_column_title(const gint col, const gchar *title)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
g_free (cfmt->title);
|
|
|
|
cfmt->title = g_strdup (title);
|
|
|
|
}
|
|
|
|
|
2010-06-20 16:23:43 +00:00
|
|
|
gboolean
|
|
|
|
get_column_visible(const gint col)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
return(cfmt->visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_column_visible(const gint col, gboolean visible)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
cfmt->visible = visible;
|
|
|
|
}
|
|
|
|
|
2010-06-25 06:42:34 +00:00
|
|
|
gboolean
|
|
|
|
get_column_resolved(const gint col)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
return(cfmt->resolved);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_column_resolved(const gint col, gboolean resolved)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
cfmt->resolved = resolved;
|
|
|
|
}
|
|
|
|
|
2008-04-12 19:37:05 +00:00
|
|
|
const gchar *
|
2010-04-03 18:18:50 +00:00
|
|
|
get_column_custom_field(const gint col)
|
2009-10-12 08:04:30 +00:00
|
|
|
{
|
2008-02-22 22:47:19 +00:00
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
2009-10-12 08:04:30 +00:00
|
|
|
if (!clp) /* Invalid column requested */
|
2009-10-12 09:13:37 +00:00
|
|
|
return NULL;
|
2009-10-12 08:04:30 +00:00
|
|
|
|
2008-02-22 22:47:19 +00:00
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
return(cfmt->custom_field);
|
|
|
|
}
|
|
|
|
|
2010-10-09 15:22:53 +00:00
|
|
|
void
|
|
|
|
set_column_custom_field(const gint col, const char *custom_field)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
g_free (cfmt->custom_field);
|
|
|
|
cfmt->custom_field = g_strdup (custom_field);
|
|
|
|
}
|
|
|
|
|
2010-09-22 20:56:14 +00:00
|
|
|
gint
|
|
|
|
get_column_custom_occurrence(const gint col)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
return(cfmt->custom_occurrence);
|
|
|
|
}
|
|
|
|
|
2010-10-09 15:22:53 +00:00
|
|
|
void
|
|
|
|
set_column_custom_occurrence(const gint col, const gint custom_occurrence)
|
|
|
|
{
|
|
|
|
GList *clp = g_list_nth(prefs.col_list, col);
|
|
|
|
fmt_data *cfmt;
|
|
|
|
|
|
|
|
if (!clp) /* Invalid column requested */
|
|
|
|
return;
|
|
|
|
|
|
|
|
cfmt = (fmt_data *) clp->data;
|
|
|
|
|
|
|
|
cfmt->custom_occurrence = custom_occurrence;
|
|
|
|
}
|
|
|
|
|
2007-06-04 20:15:10 +00:00
|
|
|
void
|
2010-04-03 18:18:50 +00:00
|
|
|
build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences)
|
2007-06-04 20:15:10 +00:00
|
|
|
{
|
2009-09-08 17:29:57 +00:00
|
|
|
int i;
|
2007-06-04 20:15:10 +00:00
|
|
|
|
2009-09-08 17:29:57 +00:00
|
|
|
/* Build the column format array */
|
|
|
|
col_setup(cinfo, num_cols);
|
2007-06-04 20:15:10 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
for (i = 0; i < cinfo->num_cols; i++) {
|
|
|
|
cinfo->col_fmt[i] = get_column_format(i);
|
|
|
|
cinfo->col_title[i] = g_strdup(get_column_title(i));
|
2009-09-08 17:29:57 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
if (cinfo->col_fmt[i] == COL_CUSTOM) {
|
|
|
|
cinfo->col_custom_field[i] = g_strdup(get_column_custom_field(i));
|
2010-09-22 20:56:14 +00:00
|
|
|
cinfo->col_custom_occurrence[i] = get_column_custom_occurrence(i);
|
2009-07-23 05:48:39 +00:00
|
|
|
if(!dfilter_compile(cinfo->col_custom_field[i], &cinfo->col_custom_dfilter[i])) {
|
|
|
|
/* XXX: Should we issue a warning? */
|
|
|
|
g_free(cinfo->col_custom_field[i]);
|
|
|
|
cinfo->col_custom_field[i] = NULL;
|
2010-09-22 20:56:14 +00:00
|
|
|
cinfo->col_custom_occurrence[i] = 0;
|
2009-07-23 05:48:39 +00:00
|
|
|
cinfo->col_custom_dfilter[i] = NULL;
|
|
|
|
}
|
2008-02-22 22:47:19 +00:00
|
|
|
} else {
|
2008-04-12 23:34:44 +00:00
|
|
|
cinfo->col_custom_field[i] = NULL;
|
2010-09-22 20:56:14 +00:00
|
|
|
cinfo->col_custom_occurrence[i] = 0;
|
2009-07-23 05:48:39 +00:00
|
|
|
cinfo->col_custom_dfilter[i] = NULL;
|
2008-02-22 22:47:19 +00:00
|
|
|
}
|
2009-09-08 17:29:57 +00:00
|
|
|
|
|
|
|
cinfo->fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * NUM_COL_FMTS);
|
|
|
|
get_column_format_matches(cinfo->fmt_matx[i], cinfo->col_fmt[i]);
|
2008-04-12 23:34:44 +00:00
|
|
|
cinfo->col_data[i] = NULL;
|
2007-06-04 20:15:10 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
if (cinfo->col_fmt[i] == COL_INFO)
|
2009-09-08 17:29:57 +00:00
|
|
|
cinfo->col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
|
2007-06-04 20:15:10 +00:00
|
|
|
else
|
2008-04-12 23:34:44 +00:00
|
|
|
cinfo->col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
2007-06-04 20:15:10 +00:00
|
|
|
|
|
|
|
if(reset_fences)
|
2008-04-12 23:34:44 +00:00
|
|
|
cinfo->col_fence[i] = 0;
|
2007-06-04 20:15:10 +00:00
|
|
|
|
2009-09-08 17:29:57 +00:00
|
|
|
cinfo->col_expr.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
|
|
|
cinfo->col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
2007-06-04 20:15:10 +00:00
|
|
|
}
|
2007-08-17 19:34:14 +00:00
|
|
|
|
2009-02-09 07:10:46 +00:00
|
|
|
cinfo->col_expr.col_expr[i] = NULL;
|
|
|
|
cinfo->col_expr.col_expr_val[i] = NULL;
|
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
for (i = 0; i < cinfo->num_cols; i++) {
|
2009-09-08 17:29:57 +00:00
|
|
|
int j;
|
|
|
|
|
2007-06-04 20:15:10 +00:00
|
|
|
for (j = 0; j < NUM_COL_FMTS; j++) {
|
2008-04-12 23:34:44 +00:00
|
|
|
if (!cinfo->fmt_matx[i][j])
|
2009-09-08 17:29:57 +00:00
|
|
|
continue;
|
2007-08-17 19:34:14 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
if (cinfo->col_first[j] == -1)
|
|
|
|
cinfo->col_first[j] = i;
|
2007-06-04 20:15:10 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
cinfo->col_last[j] = i;
|
2007-06-04 20:15:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-24 22:25:40 +00:00
|
|
|
|
2013-10-15 18:27:35 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 2
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=2 tabstop=2 expandtab:
|
|
|
|
* :indentSize=2:tabSize=2:noTabs=true:
|
|
|
|
*/
|
|
|
|
|