*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <epan/timestamp.h>
#include <epan/prefs.h>
-#include <epan/nstime.h>
#include <epan/dfilter/dfilter.h>
#include <epan/column.h>
#include <epan/packet.h>
/* Given a format number (as defined in column_info.h), returns its equivalent
string */
const gchar *
-col_format_to_string(gint fmt) {
- const gchar *slist[] = {
+col_format_to_string(const gint fmt) {
+ static const gchar *const slist[NUM_COL_FMTS] = {
"%q", /* 0) COL_8021Q_VLAN_ID */
"%Yt", /* 1) COL_ABS_DATE_TIME */
"%At", /* 2) COL_ABS_TIME */
"%rS", /* 55) COL_RES_SRC_PORT */
"%uS", /* 56) COL_UNRES_SRC_PORT */
"%E", /* 57) COL_TEI */
- "%t" /* 58) COL_CLS_TIME */
+ "%Yut", /* 58) COL_UTC_DATE_TIME */
+ "%Aut", /* 59) COL_UTC_TIME */
+ "%t" /* 60) COL_CLS_TIME */
};
if (fmt < 0 || fmt >= NUM_COL_FMTS)
/* Given a format number (as defined in column_info.h), returns its
description */
-static const gchar *dlist[NUM_COL_FMTS] = {
+const gchar *
+col_format_desc(const gint fmt) {
+ static const gchar *const dlist[NUM_COL_FMTS] = {
"802.1Q VLAN id", /* 0) COL_8021Q_VLAN_ID */
"Absolute date and time", /* 1) COL_ABS_DATE_TIME */
"Absolute time", /* 2) COL_ABS_TIME */
"Src port (resolved)", /* 55) COL_RES_SRC_PORT */
"Src port (unresolved)", /* 56) COL_UNRES_SRC_PORT */
"TEI", /* 57) COL_TEI */
- "Time (format as specified)" /* 58) COL_CLS_TIME */
-};
+ "UTC date and time", /* 58) COL_UTC_DATE_TIME */
+ "UTC time", /* 59) COL_UTC_TIME */
+ "Time (format as specified)" /* 60) COL_CLS_TIME */
+ };
-const gchar *
-col_format_desc(gint fmt) {
g_assert((fmt >= 0) && (fmt < NUM_COL_FMTS));
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) {
+get_column_format_matches(gboolean *fmt_list, const gint format) {
/* Get the obvious: the format itself */
if ((format >= 0) && (format < NUM_COL_FMTS))
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;
- case COL_TX_RATE:
- fmt_list[COL_TX_RATE] = TRUE;
- break;
- case COL_RSSI:
- fmt_list[COL_RSSI] = TRUE;
- break;
- case COL_HPUX_SUBSYS:
- fmt_list[COL_HPUX_SUBSYS] = TRUE;
- break;
- case COL_HPUX_DEVID:
- fmt_list[COL_HPUX_DEVID] = TRUE;
- break;
- case COL_DCE_CALL:
- fmt_list[COL_DCE_CALL] = TRUE;
- break;
- case COL_DCE_CTX:
- fmt_list[COL_DCE_CTX] = TRUE;
- break;
- case COL_8021Q_VLAN_ID:
- fmt_list[COL_8021Q_VLAN_ID] = TRUE;
- break;
- case COL_DSCP_VALUE:
- fmt_list[COL_DSCP_VALUE] = TRUE;
- break;
- case COL_COS_VALUE:
- fmt_list[COL_COS_VALUE] = TRUE;
- break;
- case COL_TEI:
- fmt_list[COL_TEI] = TRUE;
- break;
- case COL_FR_DLCI:
- fmt_list[COL_FR_DLCI] = TRUE;
- break;
- case COL_BSSGP_TLLI:
- fmt_list[COL_BSSGP_TLLI] = TRUE;
- break;
- case COL_EXPERT:
- fmt_list[COL_EXPERT] = TRUE;
- break;
- case COL_FREQ_CHAN:
- fmt_list[COL_FREQ_CHAN] = TRUE;
- break;
- case COL_CUSTOM:
- fmt_list[COL_CUSTOM] = TRUE;
- break;
default:
break;
}
/* Returns a string representing the longest possible value for
a timestamp column type. */
static const char *
-get_timestamp_column_longest_string(gint type, gint precision)
+get_timestamp_column_longest_string(const gint type, const gint precision)
{
switch(type) {
case(TS_ABSOLUTE_WITH_DATE):
+ case(TS_UTC_WITH_DATE):
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
}
break;
case(TS_ABSOLUTE):
+ case(TS_UTC):
switch(precision) {
case(TS_PREC_AUTO_SEC):
case(TS_PREC_FIXED_SEC):
/* Returns the longer string of the column title or the hard-coded width of
* its contents for building the packet list layout. */
const gchar *
-get_column_width_string(gint format, gint col)
+get_column_width_string(const gint format, const gint col)
{
if(strlen(get_column_longest_string(format)) >
strlen(get_column_title(col)))
is somewhat arbitrary in any case. We should probably clean
that up eventually, though. */
const char *
-get_column_longest_string(gint format)
+get_column_longest_string(const gint format)
{
switch (format) {
case COL_NUMBER:
case COL_ABS_DATE_TIME:
return get_timestamp_column_longest_string(TS_ABSOLUTE_WITH_DATE, timestamp_get_precision());
break;
+ case COL_UTC_DATE_TIME:
+ return get_timestamp_column_longest_string(TS_UTC_WITH_DATE, timestamp_get_precision());
+ break;
case COL_ABS_TIME:
return get_timestamp_column_longest_string(TS_ABSOLUTE, timestamp_get_precision());
break;
+ case COL_UTC_TIME:
+ return get_timestamp_column_longest_string(TS_UTC, timestamp_get_precision());
+ break;
case COL_REL_TIME:
return get_timestamp_column_longest_string(TS_RELATIVE, timestamp_get_precision());
break;
/* Returns the longest possible width, in characters, for a particular
column type. */
gint
-get_column_char_width(gint format)
+get_column_char_width(const gint format)
{
return (gint)strlen(get_column_longest_string(format));
}
gint
-get_column_format(gint col) {
+get_column_format(const gint col)
+{
GList *clp = g_list_nth(prefs.col_list, col);
fmt_data *cfmt;
if (!clp) /* Invalid column requested */
return -1;
-
+
+ cfmt = (fmt_data *) clp->data;
+
+ return(cfmt->fmt);
+}
+
+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;
- return(get_column_format_from_str(cfmt->fmt));
+ cfmt->fmt = fmt;
}
gint
-get_column_format_from_str(gchar *str) {
+get_column_format_from_str(const gchar *str)
+{
gint i;
for (i = 0; i < NUM_COL_FMTS; i++) {
}
gchar *
-get_column_title(gint col) {
+get_column_title(const gint col)
+{
GList *clp = g_list_nth(prefs.col_list, col);
fmt_data *cfmt;
+ if (!clp) /* Invalid column requested */
+ return NULL;
+
cfmt = (fmt_data *) clp->data;
return(cfmt->title);
}
+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);
+}
+
+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;
+}
+
+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;
+}
+
const gchar *
-get_column_custom_field(gint col) {
+get_column_custom_field(const gint col)
+{
GList *clp = g_list_nth(prefs.col_list, col);
fmt_data *cfmt;
+ if (!clp) /* Invalid column requested */
+ return NULL;
+
cfmt = (fmt_data *) clp->data;
return(cfmt->custom_field);
}
void
-build_column_format_array(column_info *cinfo, gint num_cols, gboolean reset_fences)
+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);
+}
+
+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);
+}
+
+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;
+}
+
+void
+build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences)
{
int i;
if (cinfo->col_fmt[i] == COL_CUSTOM) {
cinfo->col_custom_field[i] = g_strdup(get_column_custom_field(i));
+ cinfo->col_custom_occurrence[i] = get_column_custom_occurrence(i);
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;
+ cinfo->col_custom_occurrence[i] = 0;
cinfo->col_custom_dfilter[i] = NULL;
}
} else {
cinfo->col_custom_field[i] = NULL;
+ cinfo->col_custom_occurrence[i] = 0;
cinfo->col_custom_dfilter[i] = NULL;
}
}
}
}
+