2 * Routines for column utilities.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include "column-utils.h"
33 #include "timestamp.h"
34 #include "sna-utils.h"
35 #include "atalk-utils.h"
37 #include "packet_info.h"
39 #include "addr_resolv.h"
40 #include "ipv6-utils.h"
41 #include "osi-utils.h"
42 #include "value_string.h"
43 #include "column_info.h"
45 #include <epan/strutil.h>
46 #include <epan/epan.h>
48 /* Allocate all the data structures for constructing column data, given
49 the number of columns. */
51 col_setup(column_info *cinfo, const gint num_cols)
55 cinfo->num_cols = num_cols;
56 cinfo->col_fmt = g_new(gint, num_cols);
57 cinfo->fmt_matx = g_new(gboolean*, num_cols);
58 cinfo->col_first = g_new(int, NUM_COL_FMTS);
59 cinfo->col_last = g_new(int, NUM_COL_FMTS);
60 cinfo->col_title = g_new(gchar*, num_cols);
61 cinfo->col_custom_field = g_new(gchar*, num_cols);
62 cinfo->col_custom_occurrence = g_new(gint, num_cols);
63 cinfo->col_custom_field_id = g_new(int, num_cols);
64 cinfo->col_custom_dfilter = g_new(dfilter_t*, num_cols);
65 cinfo->col_data = (const gchar **)g_new(gchar*, num_cols);
66 cinfo->col_buf = g_new(gchar*, num_cols);
67 cinfo->col_fence = g_new(int, num_cols);
68 cinfo->col_expr.col_expr = (const gchar **) g_new(gchar*, num_cols + 1);
69 cinfo->col_expr.col_expr_val = g_new(gchar*, num_cols + 1);
71 for (i = 0; i < NUM_COL_FMTS; i++) {
72 cinfo->col_first[i] = -1;
73 cinfo->col_last[i] = -1;
77 /* Initialize the data structures for constructing column data. */
79 col_init(column_info *cinfo)
86 for (i = 0; i < cinfo->num_cols; i++) {
87 cinfo->col_buf[i][0] = '\0';
88 cinfo->col_data[i] = cinfo->col_buf[i];
89 cinfo->col_fence[i] = 0;
90 cinfo->col_expr.col_expr[i] = "";
91 cinfo->col_expr.col_expr_val[i][0] = '\0';
93 cinfo->writable = TRUE;
96 #define COL_GET_WRITABLE(cinfo) (cinfo ? cinfo->writable : FALSE)
99 col_get_writable(column_info *cinfo)
101 return COL_GET_WRITABLE(cinfo);
105 col_set_writable(column_info *cinfo, const gboolean writable)
108 cinfo->writable = writable;
111 /* Checks to see if a particular packet information element is needed for the packet list */
112 #define CHECK_COL(cinfo, el) \
113 /* We are constructing columns, and they're writable */ \
114 (COL_GET_WRITABLE(cinfo) && \
115 /* There is at least one column in that format */ \
116 ((cinfo)->col_first[el] >= 0))
119 check_col(column_info *cinfo, const gint el)
121 return CHECK_COL(cinfo, el);
124 /* Sets the fence for a column to be at the end of the column. */
126 col_set_fence(column_info *cinfo, const gint el)
130 if (!CHECK_COL(cinfo, el))
133 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
134 if (cinfo->fmt_matx[i][el]) {
135 cinfo->col_fence[i] = (int)strlen(cinfo->col_data[i]);
140 /* Use this to clear out a column, especially if you're going to be
141 appending to it later; at least on some platforms, it's more
142 efficient than using "col_add_str()" with a null string, and
143 more efficient than "col_set_str()" with a null string if you
144 later append to it, as the later append will cause a string
147 col_clear(column_info *cinfo, const gint el)
152 if (!CHECK_COL(cinfo, el))
155 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
156 if (cinfo->fmt_matx[i][el]) {
158 * At this point, either
160 * 1) col_data[i] is equal to col_buf[i], in which case we
161 * don't have to worry about copying col_data[i] to
164 * 2) col_data[i] isn't equal to col_buf[i], in which case
165 * the only thing that's been done to the column is
166 * "col_set_str()" calls and possibly "col_set_fence()"
167 * calls, in which case the fence is either unset and
168 * at the beginning of the string or set and at the end
169 * of the string - if it's at the beginning, we're just
170 * going to clear the column, and if it's at the end,
171 * we don't do anything.
173 fence = cinfo->col_fence[i];
174 if (cinfo->col_buf[i] == cinfo->col_data[i] || fence == 0) {
176 * The fence isn't at the end of the column, or the column wasn't
177 * last set with "col_set_str()", so clear the column out.
179 cinfo->col_buf[i][fence] = '\0';
180 cinfo->col_data[i] = cinfo->col_buf[i];
182 cinfo->col_expr.col_expr[i] = "";
183 cinfo->col_expr.col_expr_val[i][0] = '\0';
188 #define COL_CHECK_APPEND(cinfo, i, max_len) \
189 if (cinfo->col_data[i] != cinfo->col_buf[i]) { \
190 /* This was set with "col_set_str()"; copy the string they \
191 set it to into the buffer, so we can append to it. */ \
192 g_strlcpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); \
193 cinfo->col_data[i] = cinfo->col_buf[i]; \
196 #define COL_CHECK_REF_TIME(fd, buf) \
197 if(fd->flags.ref_time){ \
198 g_strlcpy(buf, "*REF*", COL_MAX_LEN ); \
202 /* The same as CHECK_COL(), but without the check to see if the column is writable. */
203 #define HAVE_CUSTOM_COLS(cinfo) ((cinfo) && (cinfo)->col_first[COL_CUSTOM] >= 0)
206 have_custom_cols(column_info *cinfo)
208 return HAVE_CUSTOM_COLS(cinfo);
211 /* search in edt tree custom fields */
212 void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo)
216 if(!HAVE_CUSTOM_COLS(cinfo))
219 for (i = cinfo->col_first[COL_CUSTOM];
220 i <= cinfo->col_last[COL_CUSTOM]; i++) {
221 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
222 cinfo->col_custom_field[i] &&
223 cinfo->col_custom_field_id[i] != -1) {
224 cinfo->col_data[i] = cinfo->col_buf[i];
225 cinfo->col_expr.col_expr[i] = epan_custom_set(edt, cinfo->col_custom_field_id[i],
226 cinfo->col_custom_occurrence[i],
228 cinfo->col_expr.col_expr_val[i],
235 col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
239 if(!HAVE_CUSTOM_COLS(cinfo))
242 for (i = cinfo->col_first[COL_CUSTOM];
243 i <= cinfo->col_last[COL_CUSTOM]; i++) {
245 cinfo->col_custom_field_id[i] = -1;
246 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
247 cinfo->col_custom_dfilter[i]){
248 epan_dissect_prime_dfilter(edt, cinfo->col_custom_dfilter[i]);
249 if (cinfo->col_custom_field) {
250 header_field_info* hfinfo = proto_registrar_get_byname(cinfo->col_custom_field[i]);
252 cinfo->col_custom_field_id[i] = hfinfo->id;
258 /* Appends a vararg list to a packet info string.
259 * This function's code is duplicated in col_append_sep_fstr() below because
260 * the for() loop below requires us to call va_start/va_end so intermediate
261 * functions are a problem.
264 col_append_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
270 if (!CHECK_COL(cinfo, el))
274 max_len = COL_MAX_INFO_LEN;
276 max_len = COL_MAX_LEN;
278 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
279 if (cinfo->fmt_matx[i][el]) {
281 * First arrange that we can append, if necessary.
283 COL_CHECK_APPEND(cinfo, i, max_len);
285 len = (int) strlen(cinfo->col_buf[i]);
287 va_start(ap, format);
288 g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
295 /* Appends a vararg list to a packet info string.
296 * Prefixes it with the given separator if the column is not empty.
297 * Code is duplicated from col_append_fstr above().
300 col_append_sep_fstr(column_info *cinfo, const gint el, const gchar *separator,
301 const gchar *format, ...)
304 int len, max_len, sep_len;
307 if (!CHECK_COL(cinfo, el))
310 if (separator == NULL)
311 separator = ", "; /* default */
313 sep_len = (int) strlen(separator);
316 max_len = COL_MAX_INFO_LEN;
318 max_len = COL_MAX_LEN;
320 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
321 if (cinfo->fmt_matx[i][el]) {
323 * First arrange that we can append, if necessary.
325 COL_CHECK_APPEND(cinfo, i, max_len);
327 len = (int) strlen(cinfo->col_buf[i]);
330 * If we have a separator, append it if the column isn't empty.
332 if (separator != NULL) {
334 g_strlcat(cinfo->col_buf[i], separator, max_len);
338 va_start(ap, format);
339 g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
345 /* Prepends a vararg list to a packet info string. */
346 #define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
347 (COL_MAX_INFO_LEN) : (COL_MAX_LEN))
349 col_prepend_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
353 char orig_buf[COL_BUF_MAX_LEN];
357 if (!CHECK_COL(cinfo, el))
361 max_len = COL_MAX_INFO_LEN;
363 max_len = COL_MAX_LEN;
365 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
366 if (cinfo->fmt_matx[i][el]) {
367 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
368 /* This was set with "col_set_str()"; which is effectively const */
369 orig = cinfo->col_data[i];
371 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
374 va_start(ap, format);
375 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
379 * Move the fence, unless it's at the beginning of the string.
381 if (cinfo->col_fence[i] > 0)
382 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
384 g_strlcat(cinfo->col_buf[i], orig, max_len);
385 cinfo->col_data[i] = cinfo->col_buf[i];
390 col_prepend_fence_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
394 char orig_buf[COL_BUF_MAX_LEN];
398 if (!CHECK_COL(cinfo, el))
402 max_len = COL_MAX_INFO_LEN;
404 max_len = COL_MAX_LEN;
406 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
407 if (cinfo->fmt_matx[i][el]) {
408 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
409 /* This was set with "col_set_str()"; which is effectively const */
410 orig = cinfo->col_data[i];
412 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
415 va_start(ap, format);
416 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
420 * Move the fence if it exists, else create a new fence at the
421 * end of the prepended data.
423 if (cinfo->col_fence[i] > 0) {
424 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
426 cinfo->col_fence[i] = (int) strlen(cinfo->col_buf[i]);
428 g_strlcat(cinfo->col_buf[i], orig, max_len);
429 cinfo->col_data[i] = cinfo->col_buf[i];
434 /* Use this if "str" points to something that won't stay around (and
435 must thus be copied). */
437 col_add_str(column_info *cinfo, const gint el, const gchar* str)
443 if (!CHECK_COL(cinfo, el))
447 max_len = COL_MAX_INFO_LEN;
449 max_len = COL_MAX_LEN;
451 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
452 if (cinfo->fmt_matx[i][el]) {
453 fence = cinfo->col_fence[i];
456 * We will append the string after the fence.
457 * First arrange that we can append, if necessary.
459 COL_CHECK_APPEND(cinfo, i, max_len);
462 * There's no fence, so we can just write to the string.
464 cinfo->col_data[i] = cinfo->col_buf[i];
466 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
471 /* Use this if "str" points to something that will stay around (and thus
472 needn't be copied). */
474 col_set_str(column_info *cinfo, const gint el, const gchar* str)
480 DISSECTOR_ASSERT(str);
482 /* The caller is expected to pass in something that 'will stay around' and
483 * something from the ephemeral pool certainly doesn't fit the bill. */
484 DISSECTOR_ASSERT(!ep_verify_pointer(str));
486 if (!CHECK_COL(cinfo, el))
490 max_len = COL_MAX_INFO_LEN;
492 max_len = COL_MAX_LEN;
494 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
495 if (cinfo->fmt_matx[i][el]) {
496 fence = cinfo->col_fence[i];
499 * We will append the string after the fence.
500 * First arrange that we can append, if necessary.
502 COL_CHECK_APPEND(cinfo, i, max_len);
504 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
507 * There's no fence, so we can just set the column to point
510 cinfo->col_data[i] = str;
516 /* Adds a vararg list to a packet info string. */
518 col_add_fstr(column_info *cinfo, const gint el, const gchar *format, ...) {
524 if (!CHECK_COL(cinfo, el))
528 max_len = COL_MAX_INFO_LEN;
530 max_len = COL_MAX_LEN;
532 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
533 if (cinfo->fmt_matx[i][el]) {
534 fence = cinfo->col_fence[i];
537 * We will append the string after the fence.
538 * First arrange that we can append, if necessary.
540 COL_CHECK_APPEND(cinfo, i, max_len);
543 * There's no fence, so we can just write to the string.
545 cinfo->col_data[i] = cinfo->col_buf[i];
547 va_start(ap, format);
548 g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
555 col_do_append_str(column_info *cinfo, const gint el, const gchar* separator,
562 max_len = COL_MAX_INFO_LEN;
564 max_len = COL_MAX_LEN;
566 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
567 if (cinfo->fmt_matx[i][el]) {
569 * First arrange that we can append, if necessary.
571 COL_CHECK_APPEND(cinfo, i, max_len);
573 len = cinfo->col_buf[i][0];
576 * If we have a separator, append it if the column isn't empty.
578 if (separator != NULL) {
580 g_strlcat(cinfo->col_buf[i], separator, max_len);
583 g_strlcat(cinfo->col_buf[i], str, max_len);
589 col_append_str(column_info *cinfo, const gint el, const gchar* str)
591 if (!CHECK_COL(cinfo, el))
594 col_do_append_str(cinfo, el, NULL, str);
598 col_append_sep_str(column_info *cinfo, const gint el, const gchar* separator,
601 if (!CHECK_COL(cinfo, el))
604 if (separator == NULL)
605 separator = ", "; /* default */
607 col_do_append_str(cinfo, el, separator, str);
610 /* --------------------------------- */
612 col_has_time_fmt(column_info *cinfo, const gint col)
614 return ((cinfo->fmt_matx[col][COL_CLS_TIME]) ||
615 (cinfo->fmt_matx[col][COL_ABS_TIME]) ||
616 (cinfo->fmt_matx[col][COL_ABS_DATE_TIME]) ||
617 (cinfo->fmt_matx[col][COL_REL_TIME]) ||
618 (cinfo->fmt_matx[col][COL_DELTA_TIME]) ||
619 (cinfo->fmt_matx[col][COL_DELTA_TIME_DIS]));
623 set_abs_date_time(const frame_data *fd, gchar *buf)
628 then = fd->abs_ts.secs;
629 tmp = localtime(&then);
631 switch(timestamp_get_precision()) {
632 case TS_PREC_FIXED_SEC:
633 case TS_PREC_AUTO_SEC:
634 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d",
642 case TS_PREC_FIXED_DSEC:
643 case TS_PREC_AUTO_DSEC:
644 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%01ld",
651 (long)fd->abs_ts.nsecs / 100000000);
653 case TS_PREC_FIXED_CSEC:
654 case TS_PREC_AUTO_CSEC:
655 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%02ld",
662 (long)fd->abs_ts.nsecs / 10000000);
664 case TS_PREC_FIXED_MSEC:
665 case TS_PREC_AUTO_MSEC:
666 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%03ld",
673 (long)fd->abs_ts.nsecs / 1000000);
675 case TS_PREC_FIXED_USEC:
676 case TS_PREC_AUTO_USEC:
677 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
684 (long)fd->abs_ts.nsecs / 1000);
686 case TS_PREC_FIXED_NSEC:
687 case TS_PREC_AUTO_NSEC:
688 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
695 (long)fd->abs_ts.nsecs);
698 g_assert_not_reached();
707 col_set_abs_date_time(const frame_data *fd, column_info *cinfo, const int col)
709 if (set_abs_date_time(fd, cinfo->col_buf[col])) {
710 cinfo->col_expr.col_expr[col] = "frame.time";
711 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
713 cinfo->col_data[col] = cinfo->col_buf[col];
717 set_time_seconds(const nstime_t *ts, gchar *buf)
719 switch(timestamp_get_precision()) {
720 case TS_PREC_FIXED_SEC:
721 case TS_PREC_AUTO_SEC:
722 display_signed_time(buf, COL_MAX_LEN,
723 (gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
725 case TS_PREC_FIXED_DSEC:
726 case TS_PREC_AUTO_DSEC:
727 display_signed_time(buf, COL_MAX_LEN,
728 (gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
730 case TS_PREC_FIXED_CSEC:
731 case TS_PREC_AUTO_CSEC:
732 display_signed_time(buf, COL_MAX_LEN,
733 (gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
735 case TS_PREC_FIXED_MSEC:
736 case TS_PREC_AUTO_MSEC:
737 display_signed_time(buf, COL_MAX_LEN,
738 (gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
740 case TS_PREC_FIXED_USEC:
741 case TS_PREC_AUTO_USEC:
742 display_signed_time(buf, COL_MAX_LEN,
743 (gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
745 case TS_PREC_FIXED_NSEC:
746 case TS_PREC_AUTO_NSEC:
747 display_signed_time(buf, COL_MAX_LEN,
748 (gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
751 g_assert_not_reached();
757 set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
759 time_t secs = ts->secs;
760 gboolean negative = FALSE;
767 switch(timestamp_get_precision()) {
768 case TS_PREC_FIXED_SEC:
769 case TS_PREC_AUTO_SEC:
770 if (secs >= (60*60)) {
771 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2ds",
772 negative ? "- " : "",
773 (gint32) secs / (60 * 60),
774 (gint32) (secs / 60) % 60,
776 } else if (secs >= 60) {
777 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2ds",
778 negative ? "- " : "",
782 g_snprintf(buf, COL_MAX_LEN, "%s%ds",
783 negative ? "- " : "",
787 case TS_PREC_FIXED_DSEC:
788 case TS_PREC_AUTO_DSEC:
789 if (secs >= (60*60)) {
790 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%01lds",
791 negative ? "- " : "",
792 (gint32) secs / (60 * 60),
793 (gint32) (secs / 60) % 60,
795 (long)ts->nsecs / 100000000);
796 } else if (secs >= 60) {
797 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%01lds",
798 negative ? "- " : "",
801 (long)ts->nsecs / 100000000);
803 g_snprintf(buf, COL_MAX_LEN, "%s%d.%01lds",
804 negative ? "- " : "",
806 (long)ts->nsecs / 100000000);
809 case TS_PREC_FIXED_CSEC:
810 case TS_PREC_AUTO_CSEC:
811 if (secs >= (60*60)) {
812 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%02lds",
813 negative ? "- " : "",
814 (gint32) secs / (60 * 60),
815 (gint32) (secs / 60) % 60,
817 (long)ts->nsecs / 10000000);
818 } else if (secs >= 60) {
819 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%02lds",
820 negative ? "- " : "",
823 (long)ts->nsecs / 10000000);
825 g_snprintf(buf, COL_MAX_LEN, "%s%d.%02lds",
826 negative ? "- " : "",
828 (long)ts->nsecs / 10000000);
831 case TS_PREC_FIXED_MSEC:
832 case TS_PREC_AUTO_MSEC:
833 if (secs >= (60*60)) {
834 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%03lds",
835 negative ? "- " : "",
836 (gint32) secs / (60 * 60),
837 (gint32) (secs / 60) % 60,
839 (long)ts->nsecs / 1000000);
840 } else if (secs >= 60) {
841 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%03lds",
842 negative ? "- " : "",
845 (long)ts->nsecs / 1000000);
847 g_snprintf(buf, COL_MAX_LEN, "%s%d.%03lds",
848 negative ? "- " : "",
850 (long)ts->nsecs / 1000000);
853 case TS_PREC_FIXED_USEC:
854 case TS_PREC_AUTO_USEC:
855 if (secs >= (60*60)) {
856 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%06lds",
857 negative ? "- " : "",
858 (gint32) secs / (60 * 60),
859 (gint32) (secs / 60) % 60,
861 (long)ts->nsecs / 1000);
862 } else if (secs >= 60) {
863 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%06lds",
864 negative ? "- " : "",
867 (long)ts->nsecs / 1000);
869 g_snprintf(buf, COL_MAX_LEN, "%s%d.%06lds",
870 negative ? "- " : "",
872 (long)ts->nsecs / 1000);
875 case TS_PREC_FIXED_NSEC:
876 case TS_PREC_AUTO_NSEC:
877 if (secs >= (60*60)) {
878 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%09lds",
879 negative ? "- " : "",
880 (gint32) secs / (60 * 60),
881 (gint32) (secs / 60) % 60,
884 } else if (secs >= 60) {
885 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%09lds",
886 negative ? "- " : "",
891 g_snprintf(buf, COL_MAX_LEN, "%s%d.%09lds",
892 negative ? "- " : "",
898 g_assert_not_reached();
905 col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
907 switch (timestamp_get_seconds_type()) {
908 case TS_SECONDS_DEFAULT:
909 if (set_time_seconds(&fd->rel_ts, cinfo->col_buf[col])) {
910 cinfo->col_expr.col_expr[col] = "frame.time_relative";
911 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
914 case TS_SECONDS_HOUR_MIN_SEC:
915 if (set_time_hour_min_sec(&fd->rel_ts, cinfo->col_buf[col])) {
916 cinfo->col_expr.col_expr[col] = "frame.time_relative";
917 set_time_seconds(&fd->rel_ts, cinfo->col_expr.col_expr_val[col]);
921 g_assert_not_reached();
923 cinfo->col_data[col] = cinfo->col_buf[col];
927 col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
929 switch (timestamp_get_seconds_type()) {
930 case TS_SECONDS_DEFAULT:
931 if (set_time_seconds(&fd->del_cap_ts, cinfo->col_buf[col])) {
932 cinfo->col_expr.col_expr[col] = "frame.time_delta";
933 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
936 case TS_SECONDS_HOUR_MIN_SEC:
937 if (set_time_hour_min_sec(&fd->del_cap_ts, cinfo->col_buf[col])) {
938 cinfo->col_expr.col_expr[col] = "frame.time_delta";
939 set_time_seconds(&fd->del_cap_ts, cinfo->col_expr.col_expr_val[col]);
943 g_assert_not_reached();
946 cinfo->col_data[col] = cinfo->col_buf[col];
950 col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
952 switch (timestamp_get_seconds_type()) {
953 case TS_SECONDS_DEFAULT:
954 if (set_time_seconds(&fd->del_dis_ts, cinfo->col_buf[col])) {
955 cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
956 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
959 case TS_SECONDS_HOUR_MIN_SEC:
960 if (set_time_hour_min_sec(&fd->del_dis_ts, cinfo->col_buf[col])) {
961 cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
962 set_time_seconds(&fd->del_dis_ts, cinfo->col_expr.col_expr_val[col]);
966 g_assert_not_reached();
969 cinfo->col_data[col] = cinfo->col_buf[col];
973 set_abs_time(const frame_data *fd, gchar *buf)
978 then = fd->abs_ts.secs;
979 tmp = localtime(&then);
981 switch(timestamp_get_precision()) {
982 case TS_PREC_FIXED_SEC:
983 case TS_PREC_AUTO_SEC:
984 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d",
989 case TS_PREC_FIXED_DSEC:
990 case TS_PREC_AUTO_DSEC:
991 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%01ld",
995 (long)fd->abs_ts.nsecs / 100000000);
997 case TS_PREC_FIXED_CSEC:
998 case TS_PREC_AUTO_CSEC:
999 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%02ld",
1003 (long)fd->abs_ts.nsecs / 10000000);
1005 case TS_PREC_FIXED_MSEC:
1006 case TS_PREC_AUTO_MSEC:
1007 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%03ld",
1011 (long)fd->abs_ts.nsecs / 1000000);
1013 case TS_PREC_FIXED_USEC:
1014 case TS_PREC_AUTO_USEC:
1015 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%06ld",
1019 (long)fd->abs_ts.nsecs / 1000);
1021 case TS_PREC_FIXED_NSEC:
1022 case TS_PREC_AUTO_NSEC:
1023 g_snprintf(buf, COL_MAX_LEN, "%02d:%02d:%02d.%09ld",
1027 (long)fd->abs_ts.nsecs);
1030 g_assert_not_reached();
1040 col_set_abs_time(const frame_data *fd, column_info *cinfo, const int col)
1042 if (set_abs_time(fd, cinfo->col_buf[col])) {
1043 cinfo->col_expr.col_expr[col] = "frame.time";
1044 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1046 cinfo->col_data[col] = cinfo->col_buf[col];
1050 set_epoch_time(const frame_data *fd, gchar *buf)
1052 switch(timestamp_get_precision()) {
1053 case TS_PREC_FIXED_SEC:
1054 case TS_PREC_AUTO_SEC:
1055 display_epoch_time(buf, COL_MAX_LEN,
1056 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
1058 case TS_PREC_FIXED_DSEC:
1059 case TS_PREC_AUTO_DSEC:
1060 display_epoch_time(buf, COL_MAX_LEN,
1061 fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
1063 case TS_PREC_FIXED_CSEC:
1064 case TS_PREC_AUTO_CSEC:
1065 display_epoch_time(buf, COL_MAX_LEN,
1066 fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
1068 case TS_PREC_FIXED_MSEC:
1069 case TS_PREC_AUTO_MSEC:
1070 display_epoch_time(buf, COL_MAX_LEN,
1071 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
1073 case TS_PREC_FIXED_USEC:
1074 case TS_PREC_AUTO_USEC:
1075 display_epoch_time(buf, COL_MAX_LEN,
1076 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
1078 case TS_PREC_FIXED_NSEC:
1079 case TS_PREC_AUTO_NSEC:
1080 display_epoch_time(buf, COL_MAX_LEN,
1081 fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
1084 g_assert_not_reached();
1090 col_set_epoch_time(const frame_data *fd, column_info *cinfo, const int col)
1092 if (set_epoch_time(fd, cinfo->col_buf[col])) {
1093 cinfo->col_expr.col_expr[col] = "frame.time_delta";
1094 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1096 cinfo->col_data[col] = cinfo->col_buf[col];
1100 /* Set the format of the variable time format.
1101 XXX - this is called from "file.c" when the user changes the time
1102 format they want for "command-line-specified" time; it's a bit ugly
1103 that we have to export it, but if we go to a CList-like widget that
1104 invokes callbacks to get the text for the columns rather than
1105 requiring us to stuff the text into the widget from outside, we
1106 might be able to clean this up. */
1108 set_cls_time(frame_data *fd, gchar *buf)
1110 COL_CHECK_REF_TIME(fd, cinfo->col_buf[col]);
1112 switch (timestamp_get_type()) {
1114 set_abs_time(fd, buf);
1117 case TS_ABSOLUTE_WITH_DATE:
1118 set_abs_date_time(fd, buf);
1122 set_rel_time(fd, buf);
1126 set_delta_time(fd, buf);
1130 set_delta_time_dis(fd, buf);
1134 set_epoch_time(fd, buf);
1138 /* code is missing for this case, but I don't know which [jmayer20051219] */
1146 col_set_cls_time(const frame_data *fd, column_info *cinfo, const gint col)
1148 switch (timestamp_get_type()) {
1150 col_set_abs_time(fd, cinfo, col);
1153 case TS_ABSOLUTE_WITH_DATE:
1154 col_set_abs_date_time(fd, cinfo, col);
1158 col_set_rel_time(fd, cinfo, col);
1162 col_set_delta_time(fd, cinfo, col);
1166 col_set_delta_time_dis(fd, cinfo, col);
1170 col_set_epoch_time(fd, cinfo, col);
1174 /* code is missing for this case, but I don't know which [jmayer20051219] */
1175 g_assert_not_reached();
1180 /* Set the format of the variable time format.
1181 XXX - this is called from "file.c" when the user changes the time
1182 format they want for "command-line-specified" time; it's a bit ugly
1183 that we have to export it, but if we go to a CList-like widget that
1184 invokes callbacks to get the text for the columns rather than
1185 requiring us to stuff the text into the widget from outside, we
1186 might be able to clean this up. */
1188 col_set_fmt_time(const frame_data *fd, column_info *cinfo, const gint fmt, const gint col)
1190 COL_CHECK_REF_TIME(fd, cinfo->col_buf[col]);
1194 col_set_cls_time(fd, cinfo, col);
1198 col_set_abs_time(fd, cinfo, col);
1201 case COL_ABS_DATE_TIME:
1202 col_set_abs_date_time(fd, cinfo, col);
1206 col_set_rel_time(fd, cinfo, col);
1209 case COL_DELTA_TIME:
1210 col_set_delta_time(fd, cinfo, col);
1213 case COL_DELTA_TIME_DIS:
1214 col_set_delta_time_dis(fd, cinfo, col);
1218 g_assert_not_reached();
1223 /* --------------------------- */
1224 /* Set the given (relative) time to a column element.
1226 * Used by multiple dissectors to set the time in the column
1227 * COL_DELTA_CONV_TIME
1229 * @param cinfo the current packet row
1230 * @param col the column to use, e.g. COL_INFO
1231 * @param ts the time to set in the column
1232 * @param fieldname the fieldname to use for creating a filter (when
1233 * applying/preparing/copying as filter)
1236 col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, char *fieldname)
1240 if (!CHECK_COL(cinfo, el))
1243 /** @todo TODO: We don't respect fd->flags.ref_time (no way to access 'fd')
1244 COL_CHECK_REF_TIME(fd, buf);
1247 for (col = cinfo->col_first[el]; col <= cinfo->col_last[el]; col++) {
1248 if (cinfo->fmt_matx[col][el]) {
1249 switch(timestamp_get_precision()) {
1250 case TS_PREC_FIXED_SEC:
1251 case TS_PREC_AUTO_SEC:
1252 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1253 (gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
1255 case TS_PREC_FIXED_DSEC:
1256 case TS_PREC_AUTO_DSEC:
1257 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1258 (gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
1260 case TS_PREC_FIXED_CSEC:
1261 case TS_PREC_AUTO_CSEC:
1262 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1263 (gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
1265 case TS_PREC_FIXED_MSEC:
1266 case TS_PREC_AUTO_MSEC:
1267 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1268 (gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
1270 case TS_PREC_FIXED_USEC:
1271 case TS_PREC_AUTO_USEC:
1272 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1273 (gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
1275 case TS_PREC_FIXED_NSEC:
1276 case TS_PREC_AUTO_NSEC:
1277 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1278 (gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
1281 g_assert_not_reached();
1283 cinfo->col_data[col] = cinfo->col_buf[col];
1284 cinfo->col_expr.col_expr[col] = fieldname;
1285 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1291 col_set_addr(packet_info *pinfo, const int col, const address *addr, const gboolean is_src, const gboolean fill_col_exprs)
1293 if (addr->type == AT_NONE) {
1294 /* No address, nothing to do */
1298 #ifdef NEW_PACKET_LIST
1299 pinfo->cinfo->col_data[col] = se_get_addr_name(addr);
1301 get_addr_name_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1302 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1305 if (!fill_col_exprs)
1308 switch (addr->type) {
1312 pinfo->cinfo->col_expr.col_expr[col] = "eth.src";
1314 pinfo->cinfo->col_expr.col_expr[col] = "eth.dst";
1315 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1320 pinfo->cinfo->col_expr.col_expr[col] = "ip.src";
1322 pinfo->cinfo->col_expr.col_expr[col] = "ip.dst";
1323 ip_to_str_buf(addr->data, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1328 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.src";
1330 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.dst";
1331 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1336 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src";
1338 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst";
1339 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1344 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.src";
1346 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.dst";
1347 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1352 pinfo->cinfo->col_expr.col_expr[col] = "uri.src";
1354 pinfo->cinfo->col_expr.col_expr[col] = "uri.dst";
1355 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1363 /* ------------------------ */
1365 col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gboolean is_src, const gboolean fill_col_exprs _U_)
1370 port = pinfo->srcport;
1372 port = pinfo->destport;
1374 /* TODO: Use fill_col_exprs */
1376 switch (pinfo->ptype) {
1379 g_strlcpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
1381 guint32_to_str_buf(port, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1385 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1387 g_strlcpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
1389 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1391 pinfo->cinfo->col_expr.col_expr[col] = "tcp.srcport";
1393 pinfo->cinfo->col_expr.col_expr[col] = "tcp.dstport";
1397 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1399 g_strlcpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
1401 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1403 pinfo->cinfo->col_expr.col_expr[col] = "udp.srcport";
1405 pinfo->cinfo->col_expr.col_expr[col] = "udp.dstport";
1410 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src_socket";
1412 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst_socket";
1413 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1414 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1418 /* XXX - resolve IPX socket numbers */
1419 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1420 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1422 pinfo->cinfo->col_expr.col_expr[col] = "ipx.src.socket";
1424 pinfo->cinfo->col_expr.col_expr[col] = "ipx.dst.socket";
1428 /* XXX - resolve IDP socket numbers */
1429 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1430 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1432 pinfo->cinfo->col_expr.col_expr[col] = "idp.src.socket";
1434 pinfo->cinfo->col_expr.col_expr[col] = "idp.dst.socket";
1438 /* XXX - resolve USB endpoint numbers */
1439 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port);
1440 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1442 pinfo->cinfo->col_expr.col_expr[col] = "usb.src.endpoint";
1444 pinfo->cinfo->col_expr.col_expr[col] = "usb.dst.endpoint";
1450 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1454 col_based_on_frame_data(column_info *cinfo, const gint col)
1457 g_assert(col < cinfo->num_cols);
1459 switch (cinfo->col_fmt[col]) {
1464 case COL_ABS_DATE_TIME:
1466 case COL_DELTA_TIME:
1467 case COL_DELTA_TIME_DIS:
1468 case COL_PACKET_LENGTH:
1469 case COL_CUMULATIVE_BYTES:
1478 col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, const gboolean fill_col_exprs)
1480 switch (cinfo->col_fmt[col]) {
1483 guint32_to_str_buf(fd->num, cinfo->col_buf[col], COL_MAX_LEN);
1484 cinfo->col_data[col] = cinfo->col_buf[col];
1489 case COL_ABS_DATE_TIME:
1491 case COL_DELTA_TIME:
1492 case COL_DELTA_TIME_DIS:
1493 /* TODO: Pass on fill_col_exprs */
1494 col_set_fmt_time(fd, cinfo, cinfo->col_fmt[col], col);
1497 case COL_PACKET_LENGTH:
1498 guint32_to_str_buf(fd->pkt_len, cinfo->col_buf[col], COL_MAX_LEN);
1499 cinfo->col_data[col] = cinfo->col_buf[col];
1502 case COL_CUMULATIVE_BYTES:
1503 guint32_to_str_buf(fd->cum_bytes, cinfo->col_buf[col], COL_MAX_LEN);
1504 cinfo->col_data[col] = cinfo->col_buf[col];
1511 if (!fill_col_exprs)
1514 switch (cinfo->col_fmt[col]) {
1517 cinfo->col_expr.col_expr[col] = "frame.number";
1518 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1523 case COL_ABS_DATE_TIME:
1525 case COL_DELTA_TIME:
1526 case COL_DELTA_TIME_DIS:
1527 /* Already handled above */
1530 case COL_PACKET_LENGTH:
1531 cinfo->col_expr.col_expr[col] = "frame.len";
1532 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1535 case COL_CUMULATIVE_BYTES:
1544 col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
1551 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1552 switch (pinfo->cinfo->col_fmt[i]) {
1557 case COL_ABS_DATE_TIME:
1559 case COL_DELTA_TIME:
1560 case COL_DELTA_TIME_DIS:
1561 case COL_PACKET_LENGTH:
1562 case COL_CUMULATIVE_BYTES:
1564 col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i, fill_col_exprs);
1568 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1569 col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs);
1573 col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs);
1576 case COL_DEF_DL_SRC:
1577 case COL_RES_DL_SRC:
1578 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, fill_col_exprs);
1581 case COL_UNRES_DL_SRC:
1582 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, fill_col_exprs);
1585 case COL_DEF_NET_SRC:
1586 case COL_RES_NET_SRC:
1587 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, fill_col_exprs);
1590 case COL_UNRES_NET_SRC:
1591 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, fill_col_exprs);
1595 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1596 col_set_addr(pinfo, i, &pinfo->dst, FALSE, fill_col_exprs);
1600 col_set_addr(pinfo, i, &pinfo->dst, FALSE, fill_col_exprs);
1603 case COL_DEF_DL_DST:
1604 case COL_RES_DL_DST:
1605 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, fill_col_exprs);
1608 case COL_UNRES_DL_DST:
1609 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, fill_col_exprs);
1612 case COL_DEF_NET_DST:
1613 case COL_RES_NET_DST:
1614 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, fill_col_exprs);
1617 case COL_UNRES_NET_DST:
1618 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, fill_col_exprs);
1621 case COL_DEF_SRC_PORT:
1622 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1623 col_set_port(pinfo, i, TRUE, TRUE, fill_col_exprs);
1626 case COL_UNRES_SRC_PORT:
1627 col_set_port(pinfo, i, FALSE, TRUE, fill_col_exprs);
1630 case COL_DEF_DST_PORT:
1631 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1632 col_set_port(pinfo, i, TRUE, FALSE, fill_col_exprs);
1635 case COL_UNRES_DST_PORT:
1636 col_set_port(pinfo, i, FALSE, FALSE, fill_col_exprs);
1640 guint32_to_str_buf(pinfo->vsan, pinfo->cinfo->col_buf[i], COL_MAX_LEN);
1641 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1644 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1645 g_assert_not_reached();
1648 if (pinfo->cinfo->col_fmt[i] >= NUM_COL_FMTS) {
1649 g_assert_not_reached();
1652 * Formatting handled by col_custom_set_edt() (COL_CUSTOM), expert.c
1653 * (COL_EXPERT), or individual dissectors.
1661 XXX this needs more rework?
1662 /* --------------------------- */
1665 set_addr(address *addr, gboolean is_res)
1667 if (addr->type == AT_NONE)
1668 return ""; /* no address, nothing to do */
1671 return se_get_addr_name(addr /*, COL_MAX_LEN*/);
1673 return se_address_to_str(addr);
1676 /* Fills col_text in the frame data structure */
1678 col_fill_fdata(packet_info *pinfo)
1691 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1693 switch (pinfo->cinfo->col_fmt[i]) {
1694 case COL_NUMBER: /* frame number */
1695 case COL_PACKET_LENGTH: /* fd->pkt_len */
1696 case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */
1699 case COL_ABS_DATE_TIME: /* from fd structures */
1701 case COL_DELTA_TIME:
1702 case COL_DELTA_TIME_DIS:
1706 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1709 fdata->col_text[i] = set_addr(&pinfo->src, res);
1712 case COL_DEF_DL_SRC:
1713 case COL_RES_DL_SRC:
1715 case COL_UNRES_DL_SRC:
1716 fdata->col_text[i] = set_addr (&pinfo->dl_src, res);
1719 case COL_DEF_NET_SRC:
1720 case COL_RES_NET_SRC:
1722 case COL_UNRES_NET_SRC:
1723 fdata->col_text[i] = set_addr (&pinfo->net_src, res);
1727 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1730 fdata->col_text[i] = set_addr (&pinfo->dst, res);
1733 case COL_DEF_DL_DST:
1734 case COL_RES_DL_DST:
1736 case COL_UNRES_DL_DST:
1737 fdata->col_text[i] = set_addr (&pinfo->dl_dst, res);
1740 case COL_DEF_NET_DST:
1741 case COL_RES_NET_DST:
1743 case COL_UNRES_NET_DST:
1744 fdata->col_text[i] = set_addr (&pinfo->net_dst, res);
1747 case COL_DEF_SRC_PORT:
1748 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1749 fdata->col_text[i] = set_port(pinfo, TRUE, pinfo->srcport);
1751 case COL_UNRES_SRC_PORT:
1752 fdata->col_text[i] = set_port(pinfo, FALSE, pinfo->srcport);
1755 case COL_DEF_DST_PORT:
1756 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1757 fdata->col_text[i] = set_port(pinfo, TRUE, pinfo->destport);
1760 case COL_UNRES_DST_PORT:
1761 fdata->col_text[i] = set_port(pinfo, FALSE, pinfo->destport);
1764 case COL_IF_DIR: /* currently done by dissectors */
1767 case COL_HPUX_SUBSYS:
1768 case COL_HPUX_DEVID:
1770 case COL_8021Q_VLAN_ID:
1771 case COL_DSCP_VALUE:
1774 case COL_BSSGP_TLLI:
1778 if (pinfo->cinfo->col_data[i] != pinfo->cinfo->col_buf[i]) {
1779 /* XXX assume it's a constant */
1780 fdata->col_text[i] = (gchar *)pinfo->cinfo->col_data[i];
1784 fdata->col_text[i] = se_strdup(pinfo->cinfo->col_data[i]);
1788 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->oxid));
1791 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->rxid));
1793 case COL_CIRCUIT_ID:
1794 set_circuit_id(pinfo);
1797 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->src_idx));
1800 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->dst_idx));
1803 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->vsan));
1806 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1807 g_assert_not_reached();
1813 /* XXX Gets/creates the text from col_text in frame data */
1814 /* --------------------- */
1816 col_get_text(frame_data *fd, column_info *cinfo, gint col)
1818 static gchar fmtbuf[3][COL_MAX_LEN];
1823 idx = (idx + 1) % 3;
1828 switch (cinfo->col_fmt[col]) {
1829 case COL_NUMBER: /* frame number */
1830 guint32_to_str_buf(fd->num, buf, COL_MAX_LEN);
1834 set_cls_time(fd, buf);
1837 set_abs_time(fd, buf);
1839 case COL_ABS_DATE_TIME:
1840 set_abs_date_time(fd, buf);
1843 set_rel_time(fd, buf);
1845 case COL_DELTA_TIME:
1846 set_delta_time(fd, buf);
1848 case COL_DELTA_TIME_DIS:
1849 set_delta_time_dis(fd, buf);
1852 case COL_PACKET_LENGTH: /* fd->pkt_len */
1853 guint32_to_str_buf(fd->pkt_len, buf, COL_MAX_LEN);
1856 case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */
1857 guint32_to_str_buf(fd->cum_bytes, buf, COL_MAX_LEN);
1861 case COL_RES_SRC: /* network address */
1863 case COL_DEF_DL_SRC:
1864 case COL_RES_DL_SRC:
1865 case COL_UNRES_DL_SRC:
1866 case COL_DEF_NET_SRC:
1867 case COL_RES_NET_SRC:
1868 case COL_UNRES_NET_SRC:
1872 case COL_DEF_DL_DST:
1873 case COL_RES_DL_DST:
1874 case COL_UNRES_DL_DST:
1875 case COL_DEF_NET_DST:
1876 case COL_RES_NET_DST:
1877 case COL_UNRES_NET_DST:
1880 case COL_CIRCUIT_ID:
1883 case COL_HPUX_SUBSYS:
1884 case COL_HPUX_DEVID:
1886 case COL_8021Q_VLAN_ID:
1887 case COL_DSCP_VALUE:
1890 case COL_BSSGP_TLLI:
1894 ptr = fd->col_text[col];
1897 case COL_DEF_SRC_PORT:
1898 case COL_RES_SRC_PORT:
1899 case COL_UNRES_SRC_PORT:
1900 case COL_DEF_DST_PORT:
1901 case COL_RES_DST_PORT:
1902 case COL_UNRES_DST_PORT:
1904 if (GPOINTER_TO_UINT(fd->col_text[col]) <= 65536)
1905 guint32_to_str_buf(GPOINTER_TO_UINT(fd->col_text[col], buf, COL_MAX_LEN));
1907 ptr = fd->col_text[col];
1914 g_snprintf(buf, COL_MAX_LEN, "0x%x", GPOINTER_TO_UINT(fd->col_text[col]));
1918 guint32_to_str_buf(GPOINTER_TO_UINT(fd->col_text[col]), buf, COL_MAX_LEN);
1921 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1922 g_assert_not_reached();