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, 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_field_id = g_new(int, num_cols);
63 cinfo->col_custom_dfilter = g_new(dfilter_t*, num_cols);
64 cinfo->col_data = (const gchar **)g_new(gchar*, num_cols);
65 cinfo->col_buf = g_new(gchar*, num_cols);
66 cinfo->col_fence = g_new(int, num_cols);
67 cinfo->col_expr.col_expr = (const gchar **) g_new(gchar*, num_cols + 1);
68 cinfo->col_expr.col_expr_val = g_new(gchar*, num_cols + 1);
70 for (i = 0; i < NUM_COL_FMTS; i++) {
71 cinfo->col_first[i] = -1;
72 cinfo->col_last[i] = -1;
76 /* Initialize the data structures for constructing column data. */
78 col_init(column_info *cinfo)
85 for (i = 0; i < cinfo->num_cols; i++) {
86 cinfo->col_buf[i][0] = '\0';
87 cinfo->col_data[i] = cinfo->col_buf[i];
88 cinfo->col_fence[i] = 0;
89 cinfo->col_expr.col_expr[i] = "";
90 cinfo->col_expr.col_expr_val[i][0] = '\0';
92 cinfo->writable = TRUE;
95 #define COL_GET_WRITABLE(cinfo) (cinfo ? cinfo->writable : FALSE)
98 col_get_writable(column_info *cinfo)
100 return COL_GET_WRITABLE(cinfo);
104 col_set_writable(column_info *cinfo, gboolean writable)
107 cinfo->writable = writable;
110 /* Checks to see if a particular packet information element is needed for the packet list */
111 #define CHECK_COL(cinfo, el) \
112 /* We are constructing columns, and they're writable */ \
113 (COL_GET_WRITABLE(cinfo) && \
114 /* There is at least one column in that format */ \
115 ((cinfo)->col_first[el] >= 0))
118 check_col(column_info *cinfo, gint el)
120 return CHECK_COL(cinfo, el);
123 /* Sets the fence for a column to be at the end of the column. */
125 col_set_fence(column_info *cinfo, gint el)
129 if (!CHECK_COL(cinfo, el))
132 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
133 if (cinfo->fmt_matx[i][el]) {
134 cinfo->col_fence[i] = (int)strlen(cinfo->col_data[i]);
139 /* Use this to clear out a column, especially if you're going to be
140 appending to it later; at least on some platforms, it's more
141 efficient than using "col_add_str()" with a null string, and
142 more efficient than "col_set_str()" with a null string if you
143 later append to it, as the later append will cause a string
146 col_clear(column_info *cinfo, gint el)
151 if (!CHECK_COL(cinfo, el))
154 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
155 if (cinfo->fmt_matx[i][el]) {
157 * At this point, either
159 * 1) col_data[i] is equal to col_buf[i], in which case we
160 * don't have to worry about copying col_data[i] to
163 * 2) col_data[i] isn't equal to col_buf[i], in which case
164 * the only thing that's been done to the column is
165 * "col_set_str()" calls and possibly "col_set_fence()"
166 * calls, in which case the fence is either unset and
167 * at the beginning of the string or set and at the end
168 * of the string - if it's at the beginning, we're just
169 * going to clear the column, and if it's at the end,
170 * we don't do anything.
172 fence = cinfo->col_fence[i];
173 if (cinfo->col_buf[i] == cinfo->col_data[i] || fence == 0) {
175 * The fence isn't at the end of the column, or the column wasn't
176 * last set with "col_set_str()", so clear the column out.
178 cinfo->col_buf[i][fence] = '\0';
179 cinfo->col_data[i] = cinfo->col_buf[i];
181 cinfo->col_expr.col_expr[i] = "";
182 cinfo->col_expr.col_expr_val[i][0] = '\0';
187 #define COL_CHECK_APPEND(cinfo, i, max_len) \
188 if (cinfo->col_data[i] != cinfo->col_buf[i]) { \
189 /* This was set with "col_set_str()"; copy the string they \
190 set it to into the buffer, so we can append to it. */ \
191 g_strlcpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); \
192 cinfo->col_data[i] = cinfo->col_buf[i]; \
195 #define COL_CHECK_REF_TIME(fd, buf) \
196 if(fd->flags.ref_time){ \
197 g_strlcpy(buf, "*REF*", COL_MAX_LEN ); \
201 /* The same as CHECK_COL(), but without the check to see if the column is writable. */
202 #define HAVE_CUSTOM_COLS(cinfo) ((cinfo) && (cinfo)->col_first[COL_CUSTOM] >= 0)
205 have_custom_cols(column_info *cinfo)
207 return HAVE_CUSTOM_COLS(cinfo);
210 /* search in edt tree custom fields */
211 void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo)
215 if(!HAVE_CUSTOM_COLS(cinfo))
218 for (i = cinfo->col_first[COL_CUSTOM];
219 i <= cinfo->col_last[COL_CUSTOM]; i++) {
220 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
221 cinfo->col_custom_field[i] &&
222 cinfo->col_custom_field_id[i] != -1) {
223 cinfo->col_data[i] = cinfo->col_buf[i];
224 cinfo->col_expr.col_expr[i] = epan_custom_set(edt, cinfo->col_custom_field_id[i],
226 cinfo->col_expr.col_expr_val[i],
233 col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
237 if(!HAVE_CUSTOM_COLS(cinfo))
240 for (i = cinfo->col_first[COL_CUSTOM];
241 i <= cinfo->col_last[COL_CUSTOM]; i++) {
243 cinfo->col_custom_field_id[i] = -1;
244 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
245 cinfo->col_custom_dfilter[i]){
246 epan_dissect_prime_dfilter(edt, cinfo->col_custom_dfilter[i]);
247 if (cinfo->col_custom_field) {
248 header_field_info* hfinfo = proto_registrar_get_byname(cinfo->col_custom_field[i]);
250 cinfo->col_custom_field_id[i] = hfinfo->id;
257 col_do_append_sep_va_fstr(column_info *cinfo, gint el, const gchar *separator,
258 const gchar *format, va_list ap)
261 int len, max_len, sep_len;
264 max_len = COL_MAX_INFO_LEN;
266 max_len = COL_MAX_LEN;
268 if (separator == NULL)
271 sep_len = (int) strlen(separator);
272 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
273 if (cinfo->fmt_matx[i][el]) {
275 * First arrange that we can append, if necessary.
277 COL_CHECK_APPEND(cinfo, i, max_len);
279 len = (int) strlen(cinfo->col_buf[i]);
282 * If we have a separator, append it if the column isn't empty.
284 if (separator != NULL) {
286 g_strlcat(cinfo->col_buf[i], separator, max_len);
290 g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
295 /* Appends a vararg list to a packet info string. */
297 col_append_fstr(column_info *cinfo, gint el, const gchar *format, ...)
301 if (!CHECK_COL(cinfo, el))
304 va_start(ap, format);
305 col_do_append_sep_va_fstr(cinfo, el, NULL, format, ap);
309 /* Appends a vararg list to a packet info string.
310 * Prefixes it with the given separator if the column is not empty. */
312 col_append_sep_fstr(column_info *cinfo, gint el, const gchar *separator,
313 const gchar *format, ...)
317 if (!CHECK_COL(cinfo, el))
320 if (separator == NULL)
321 separator = ", "; /* default */
322 va_start(ap, format);
323 col_do_append_sep_va_fstr(cinfo, el, separator, format, ap);
329 /* Prepends a vararg list to a packet info string. */
330 #define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
331 (COL_MAX_INFO_LEN) : (COL_MAX_LEN))
333 col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
337 char orig_buf[COL_BUF_MAX_LEN];
341 if (!CHECK_COL(cinfo, el))
345 max_len = COL_MAX_INFO_LEN;
347 max_len = COL_MAX_LEN;
349 va_start(ap, format);
350 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
351 if (cinfo->fmt_matx[i][el]) {
352 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
353 /* This was set with "col_set_str()"; which is effectively const */
354 orig = cinfo->col_data[i];
356 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
359 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
362 * Move the fence, unless it's at the beginning of the string.
364 if (cinfo->col_fence[i] > 0)
365 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
367 g_strlcat(cinfo->col_buf[i], orig, max_len);
368 cinfo->col_data[i] = cinfo->col_buf[i];
374 col_prepend_fence_fstr(column_info *cinfo, gint el, const gchar *format, ...)
378 char orig_buf[COL_BUF_MAX_LEN];
382 if (!CHECK_COL(cinfo, el))
386 max_len = COL_MAX_INFO_LEN;
388 max_len = COL_MAX_LEN;
390 va_start(ap, format);
391 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
392 if (cinfo->fmt_matx[i][el]) {
393 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
394 /* This was set with "col_set_str()"; which is effectively const */
395 orig = cinfo->col_data[i];
397 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
400 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
403 * Move the fence if it exists, else create a new fence at the
404 * end of the prepended data.
406 if (cinfo->col_fence[i] > 0) {
407 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
409 cinfo->col_fence[i] = (int) strlen(cinfo->col_buf[i]);
411 g_strlcat(cinfo->col_buf[i], orig, max_len);
412 cinfo->col_data[i] = cinfo->col_buf[i];
418 /* Use this if "str" points to something that won't stay around (and
419 must thus be copied). */
421 col_add_str(column_info *cinfo, gint el, const gchar* str)
427 if (!CHECK_COL(cinfo, el))
431 max_len = COL_MAX_INFO_LEN;
433 max_len = COL_MAX_LEN;
435 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
436 if (cinfo->fmt_matx[i][el]) {
437 fence = cinfo->col_fence[i];
440 * We will append the string after the fence.
441 * First arrange that we can append, if necessary.
443 COL_CHECK_APPEND(cinfo, i, max_len);
446 * There's no fence, so we can just write to the string.
448 cinfo->col_data[i] = cinfo->col_buf[i];
450 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
455 /* Use this if "str" points to something that will stay around (and thus
456 needn't be copied). */
458 col_set_str(column_info *cinfo, gint el, const gchar* str)
464 DISSECTOR_ASSERT(str);
466 /* The caller is expected to pass in something that 'will stay around' and
467 * something from the ephemeral pool certainly doesn't fit the bill. */
468 DISSECTOR_ASSERT(!ep_verify_pointer(str));
470 if (!CHECK_COL(cinfo, el))
474 max_len = COL_MAX_INFO_LEN;
476 max_len = COL_MAX_LEN;
478 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
479 if (cinfo->fmt_matx[i][el]) {
480 fence = cinfo->col_fence[i];
483 * We will append the string after the fence.
484 * First arrange that we can append, if necessary.
486 COL_CHECK_APPEND(cinfo, i, max_len);
488 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
491 * There's no fence, so we can just set the column to point
494 cinfo->col_data[i] = str;
500 /* Adds a vararg list to a packet info string. */
502 col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) {
508 if (!CHECK_COL(cinfo, el))
512 max_len = COL_MAX_INFO_LEN;
514 max_len = COL_MAX_LEN;
516 va_start(ap, format);
517 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
518 if (cinfo->fmt_matx[i][el]) {
519 fence = cinfo->col_fence[i];
522 * We will append the string after the fence.
523 * First arrange that we can append, if necessary.
525 COL_CHECK_APPEND(cinfo, i, max_len);
528 * There's no fence, so we can just write to the string.
530 cinfo->col_data[i] = cinfo->col_buf[i];
532 g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
539 col_do_append_str(column_info *cinfo, gint el, const gchar* separator,
546 max_len = COL_MAX_INFO_LEN;
548 max_len = COL_MAX_LEN;
550 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
551 if (cinfo->fmt_matx[i][el]) {
553 * First arrange that we can append, if necessary.
555 COL_CHECK_APPEND(cinfo, i, max_len);
557 len = cinfo->col_buf[i][0];
560 * If we have a separator, append it if the column isn't empty.
562 if (separator != NULL) {
564 g_strlcat(cinfo->col_buf[i], separator, max_len);
567 g_strlcat(cinfo->col_buf[i], str, max_len);
573 col_append_str(column_info *cinfo, gint el, const gchar* str)
575 if (!CHECK_COL(cinfo, el))
578 col_do_append_str(cinfo, el, NULL, str);
582 col_append_sep_str(column_info *cinfo, gint el, const gchar* separator,
585 if (!CHECK_COL(cinfo, el))
588 if (separator == NULL)
589 separator = ", "; /* default */
591 col_do_append_str(cinfo, el, separator, str);
594 /* --------------------------------- */
596 col_has_time_fmt(column_info *cinfo, gint col)
598 return ((cinfo->fmt_matx[col][COL_CLS_TIME]) ||
599 (cinfo->fmt_matx[col][COL_ABS_TIME]) ||
600 (cinfo->fmt_matx[col][COL_ABS_DATE_TIME]) ||
601 (cinfo->fmt_matx[col][COL_REL_TIME]) ||
602 (cinfo->fmt_matx[col][COL_DELTA_TIME]) ||
603 (cinfo->fmt_matx[col][COL_DELTA_TIME_DIS]));
607 set_abs_date_time(frame_data *fd, gchar *buf)
612 then = fd->abs_ts.secs;
613 tmp = localtime(&then);
615 switch(timestamp_get_precision()) {
616 case(TS_PREC_FIXED_SEC):
617 case(TS_PREC_AUTO_SEC):
618 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d",
626 case(TS_PREC_FIXED_DSEC):
627 case(TS_PREC_AUTO_DSEC):
628 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%01ld",
635 (long)fd->abs_ts.nsecs / 100000000);
637 case(TS_PREC_FIXED_CSEC):
638 case(TS_PREC_AUTO_CSEC):
639 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%02ld",
646 (long)fd->abs_ts.nsecs / 10000000);
648 case(TS_PREC_FIXED_MSEC):
649 case(TS_PREC_AUTO_MSEC):
650 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%03ld",
657 (long)fd->abs_ts.nsecs / 1000000);
659 case(TS_PREC_FIXED_USEC):
660 case(TS_PREC_AUTO_USEC):
661 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
668 (long)fd->abs_ts.nsecs / 1000);
670 case(TS_PREC_FIXED_NSEC):
671 case(TS_PREC_AUTO_NSEC):
672 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
679 (long)fd->abs_ts.nsecs);
682 g_assert_not_reached();
691 col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
693 if (set_abs_date_time(fd, cinfo->col_buf[col])) {
694 cinfo->col_expr.col_expr[col] = "frame.time";
695 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
697 cinfo->col_data[col] = cinfo->col_buf[col];
701 set_rel_time(frame_data *fd, gchar *buf)
703 switch(timestamp_get_precision()) {
704 case(TS_PREC_FIXED_SEC):
705 case(TS_PREC_AUTO_SEC):
706 display_signed_time(buf, COL_MAX_LEN,
707 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
709 case(TS_PREC_FIXED_DSEC):
710 case(TS_PREC_AUTO_DSEC):
711 display_signed_time(buf, COL_MAX_LEN,
712 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
714 case(TS_PREC_FIXED_CSEC):
715 case(TS_PREC_AUTO_CSEC):
716 display_signed_time(buf, COL_MAX_LEN,
717 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
719 case(TS_PREC_FIXED_MSEC):
720 case(TS_PREC_AUTO_MSEC):
721 display_signed_time(buf, COL_MAX_LEN,
722 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
724 case(TS_PREC_FIXED_USEC):
725 case(TS_PREC_AUTO_USEC):
726 display_signed_time(buf, COL_MAX_LEN,
727 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
729 case(TS_PREC_FIXED_NSEC):
730 case(TS_PREC_AUTO_NSEC):
731 display_signed_time(buf, COL_MAX_LEN,
732 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
735 g_assert_not_reached();
741 col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
743 if (set_rel_time(fd, cinfo->col_buf[col])) {
744 cinfo->col_expr.col_expr[col] = "frame.time_relative";
745 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
747 cinfo->col_data[col] = cinfo->col_buf[col];
751 set_delta_time(frame_data *fd, gchar *buf)
753 switch(timestamp_get_precision()) {
754 case(TS_PREC_FIXED_SEC):
755 case(TS_PREC_AUTO_SEC):
756 display_signed_time(buf, COL_MAX_LEN,
757 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
759 case(TS_PREC_FIXED_DSEC):
760 case(TS_PREC_AUTO_DSEC):
761 display_signed_time(buf, COL_MAX_LEN,
762 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
764 case(TS_PREC_FIXED_CSEC):
765 case(TS_PREC_AUTO_CSEC):
766 display_signed_time(buf, COL_MAX_LEN,
767 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
769 case(TS_PREC_FIXED_MSEC):
770 case(TS_PREC_AUTO_MSEC):
771 display_signed_time(buf, COL_MAX_LEN,
772 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
774 case(TS_PREC_FIXED_USEC):
775 case(TS_PREC_AUTO_USEC):
776 display_signed_time(buf, COL_MAX_LEN,
777 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
779 case(TS_PREC_FIXED_NSEC):
780 case(TS_PREC_AUTO_NSEC):
781 display_signed_time(buf, COL_MAX_LEN,
782 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
785 g_assert_not_reached();
791 col_set_delta_time(frame_data *fd, column_info *cinfo, int col)
793 if (set_delta_time(fd, cinfo->col_buf[col])) {
794 cinfo->col_expr.col_expr[col] = "frame.time_delta";
795 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
797 cinfo->col_data[col] = cinfo->col_buf[col];
801 set_delta_time_dis(frame_data *fd, gchar *buf)
803 switch(timestamp_get_precision()) {
804 case(TS_PREC_FIXED_SEC):
805 case(TS_PREC_AUTO_SEC):
806 display_signed_time(buf, COL_MAX_LEN,
807 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
809 case(TS_PREC_FIXED_DSEC):
810 case(TS_PREC_AUTO_DSEC):
811 display_signed_time(buf, COL_MAX_LEN,
812 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
814 case(TS_PREC_FIXED_CSEC):
815 case(TS_PREC_AUTO_CSEC):
816 display_signed_time(buf, COL_MAX_LEN,
817 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
819 case(TS_PREC_FIXED_MSEC):
820 case(TS_PREC_AUTO_MSEC):
821 display_signed_time(buf, COL_MAX_LEN,
822 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
824 case(TS_PREC_FIXED_USEC):
825 case(TS_PREC_AUTO_USEC):
826 display_signed_time(buf, COL_MAX_LEN,
827 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
829 case(TS_PREC_FIXED_NSEC):
830 case(TS_PREC_AUTO_NSEC):
831 display_signed_time(buf, COL_MAX_LEN,
832 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
835 g_assert_not_reached();
841 col_set_delta_time_dis(frame_data *fd, column_info *cinfo, int col)
843 if (set_delta_time_dis(fd, cinfo->col_buf[col])) {
844 cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
845 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
847 cinfo->col_data[col] = cinfo->col_buf[col];
851 set_abs_time(frame_data *fd, gchar *buf)
856 then = fd->abs_ts.secs;
857 tmp = localtime(&then);
859 switch(timestamp_get_precision()) {
860 case(TS_PREC_FIXED_SEC):
861 case(TS_PREC_AUTO_SEC):
862 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d",
867 case(TS_PREC_FIXED_DSEC):
868 case(TS_PREC_AUTO_DSEC):
869 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%01ld",
873 (long)fd->abs_ts.nsecs / 100000000);
875 case(TS_PREC_FIXED_CSEC):
876 case(TS_PREC_AUTO_CSEC):
877 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%02ld",
881 (long)fd->abs_ts.nsecs / 10000000);
883 case(TS_PREC_FIXED_MSEC):
884 case(TS_PREC_AUTO_MSEC):
885 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%03ld",
889 (long)fd->abs_ts.nsecs / 1000000);
891 case(TS_PREC_FIXED_USEC):
892 case(TS_PREC_AUTO_USEC):
893 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%06ld",
897 (long)fd->abs_ts.nsecs / 1000);
899 case(TS_PREC_FIXED_NSEC):
900 case(TS_PREC_AUTO_NSEC):
901 g_snprintf(buf, COL_MAX_LEN, "%02d:%02d:%02d.%09ld",
905 (long)fd->abs_ts.nsecs);
908 g_assert_not_reached();
918 col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
920 if (set_abs_time(fd, cinfo->col_buf[col])) {
921 cinfo->col_expr.col_expr[col] = "frame.time";
922 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
924 cinfo->col_data[col] = cinfo->col_buf[col];
928 set_epoch_time(frame_data *fd, gchar *buf)
930 switch(timestamp_get_precision()) {
931 case(TS_PREC_FIXED_SEC):
932 case(TS_PREC_AUTO_SEC):
933 display_epoch_time(buf, COL_MAX_LEN,
934 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
936 case(TS_PREC_FIXED_DSEC):
937 case(TS_PREC_AUTO_DSEC):
938 display_epoch_time(buf, COL_MAX_LEN,
939 fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
941 case(TS_PREC_FIXED_CSEC):
942 case(TS_PREC_AUTO_CSEC):
943 display_epoch_time(buf, COL_MAX_LEN,
944 fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
946 case(TS_PREC_FIXED_MSEC):
947 case(TS_PREC_AUTO_MSEC):
948 display_epoch_time(buf, COL_MAX_LEN,
949 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
951 case(TS_PREC_FIXED_USEC):
952 case(TS_PREC_AUTO_USEC):
953 display_epoch_time(buf, COL_MAX_LEN,
954 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
956 case(TS_PREC_FIXED_NSEC):
957 case(TS_PREC_AUTO_NSEC):
958 display_epoch_time(buf, COL_MAX_LEN,
959 fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
962 g_assert_not_reached();
968 col_set_epoch_time(frame_data *fd, column_info *cinfo, int col)
970 if (set_epoch_time(fd, cinfo->col_buf[col])) {
971 cinfo->col_expr.col_expr[col] = "frame.time_delta";
972 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
974 cinfo->col_data[col] = cinfo->col_buf[col];
978 /* Set the format of the variable time format.
979 XXX - this is called from "file.c" when the user changes the time
980 format they want for "command-line-specified" time; it's a bit ugly
981 that we have to export it, but if we go to a CList-like widget that
982 invokes callbacks to get the text for the columns rather than
983 requiring us to stuff the text into the widget from outside, we
984 might be able to clean this up. */
986 set_cls_time(frame_data *fd, gchar *buf)
988 COL_CHECK_REF_TIME(fd, cinfo->col_buf[col]);
990 switch (timestamp_get_type()) {
992 set_abs_time(fd, buf);
995 case TS_ABSOLUTE_WITH_DATE:
996 set_abs_date_time(fd, buf);
1000 set_rel_time(fd, buf);
1004 set_delta_time(fd, buf);
1008 set_delta_time_dis(fd, buf);
1012 set_epoch_time(fd, buf);
1016 /* code is missing for this case, but I don't know which [jmayer20051219] */
1024 col_set_cls_time(frame_data *fd, column_info *cinfo, gint col)
1026 switch (timestamp_get_type()) {
1028 col_set_abs_time(fd, cinfo, col);
1031 case TS_ABSOLUTE_WITH_DATE:
1032 col_set_abs_date_time(fd, cinfo, col);
1036 col_set_rel_time(fd, cinfo, col);
1040 col_set_delta_time(fd, cinfo, col);
1044 col_set_delta_time_dis(fd, cinfo, col);
1048 col_set_epoch_time(fd, cinfo, col);
1052 /* code is missing for this case, but I don't know which [jmayer20051219] */
1053 g_assert_not_reached();
1058 /* Set the format of the variable time format.
1059 XXX - this is called from "file.c" when the user changes the time
1060 format they want for "command-line-specified" time; it's a bit ugly
1061 that we have to export it, but if we go to a CList-like widget that
1062 invokes callbacks to get the text for the columns rather than
1063 requiring us to stuff the text into the widget from outside, we
1064 might be able to clean this up. */
1066 col_set_fmt_time(frame_data *fd, column_info *cinfo, gint fmt, gint col)
1068 COL_CHECK_REF_TIME(fd, cinfo->col_buf[col]);
1072 col_set_cls_time(fd, cinfo, col);
1076 col_set_abs_time(fd, cinfo, col);
1079 case COL_ABS_DATE_TIME:
1080 col_set_abs_date_time(fd, cinfo, col);
1084 col_set_rel_time(fd, cinfo, col);
1087 case COL_DELTA_TIME:
1088 col_set_delta_time(fd, cinfo, col);
1091 case COL_DELTA_TIME_DIS:
1092 col_set_delta_time_dis(fd, cinfo, col);
1096 g_assert_not_reached();
1101 /* --------------------------- */
1103 col_set_time(column_info *cinfo, gint el, nstime_t *ts, char *fieldname)
1107 if (!CHECK_COL(cinfo, el))
1110 /* TODO: We don't respect fd->flags.ref_time (no way to access 'fd')
1111 COL_CHECK_REF_TIME(fd, buf);
1114 for (col = cinfo->col_first[el]; col <= cinfo->col_last[el]; col++) {
1115 if (cinfo->fmt_matx[col][el]) {
1116 switch(timestamp_get_precision()) {
1117 case(TS_PREC_FIXED_SEC):
1118 case(TS_PREC_AUTO_SEC):
1119 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1120 (gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
1122 case(TS_PREC_FIXED_DSEC):
1123 case(TS_PREC_AUTO_DSEC):
1124 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1125 (gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
1127 case(TS_PREC_FIXED_CSEC):
1128 case(TS_PREC_AUTO_CSEC):
1129 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1130 (gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
1132 case(TS_PREC_FIXED_MSEC):
1133 case(TS_PREC_AUTO_MSEC):
1134 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1135 (gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
1137 case(TS_PREC_FIXED_USEC):
1138 case(TS_PREC_AUTO_USEC):
1139 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1140 (gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
1142 case(TS_PREC_FIXED_NSEC):
1143 case(TS_PREC_AUTO_NSEC):
1144 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1145 (gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
1148 g_assert_not_reached();
1150 cinfo->col_data[col] = cinfo->col_buf[col];
1151 cinfo->col_expr.col_expr[col] = fieldname;
1152 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1158 col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_src, gboolean fill_col_exprs)
1160 if (addr->type == AT_NONE) {
1161 pinfo->cinfo->col_data[col] = "";
1162 /* No address, nothing to do */
1166 #ifdef NEW_PACKET_LIST
1167 pinfo->cinfo->col_data[col] = se_get_addr_name(addr);
1169 get_addr_name_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1170 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1173 if (!fill_col_exprs)
1176 switch (addr->type) {
1180 pinfo->cinfo->col_expr.col_expr[col] = "eth.src";
1182 pinfo->cinfo->col_expr.col_expr[col] = "eth.dst";
1183 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1188 pinfo->cinfo->col_expr.col_expr[col] = "ip.src";
1190 pinfo->cinfo->col_expr.col_expr[col] = "ip.dst";
1191 ip_to_str_buf(addr->data, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1196 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.src";
1198 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.dst";
1199 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1204 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src";
1206 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst";
1207 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1212 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.src";
1214 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.dst";
1215 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1220 pinfo->cinfo->col_expr.col_expr[col] = "uri.src";
1222 pinfo->cinfo->col_expr.col_expr[col] = "uri.dst";
1223 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1231 /* ------------------------ */
1233 col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src, gboolean fill_col_exprs _U_)
1238 port = pinfo->srcport;
1240 port = pinfo->destport;
1242 /* TODO: Use fill_col_exprs */
1244 switch (pinfo->ptype) {
1247 g_strlcpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
1249 guint32_to_str_buf(port, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1253 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1255 g_strlcpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
1257 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1259 pinfo->cinfo->col_expr.col_expr[col] = "tcp.srcport";
1261 pinfo->cinfo->col_expr.col_expr[col] = "tcp.dstport";
1265 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1267 g_strlcpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
1269 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1271 pinfo->cinfo->col_expr.col_expr[col] = "udp.srcport";
1273 pinfo->cinfo->col_expr.col_expr[col] = "udp.dstport";
1278 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src_socket";
1280 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst_socket";
1281 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1282 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1286 /* XXX - resolve IPX socket numbers */
1287 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1288 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1290 pinfo->cinfo->col_expr.col_expr[col] = "ipx.src.socket";
1292 pinfo->cinfo->col_expr.col_expr[col] = "ipx.dst.socket";
1296 /* XXX - resolve IDP socket numbers */
1297 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1298 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1300 pinfo->cinfo->col_expr.col_expr[col] = "idp.src.socket";
1302 pinfo->cinfo->col_expr.col_expr[col] = "idp.dst.socket";
1306 /* XXX - resolve USB endpoint numbers */
1307 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port);
1308 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1310 pinfo->cinfo->col_expr.col_expr[col] = "usb.src.endpoint";
1312 pinfo->cinfo->col_expr.col_expr[col] = "usb.dst.endpoint";
1318 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1322 col_based_on_frame_data(column_info *cinfo, gint col)
1325 g_assert(col < cinfo->num_cols);
1327 switch (cinfo->col_fmt[col]) {
1332 case COL_ABS_DATE_TIME:
1334 case COL_DELTA_TIME:
1335 case COL_DELTA_TIME_DIS:
1336 case COL_PACKET_LENGTH:
1337 case COL_CUMULATIVE_BYTES:
1346 col_fill_in_frame_data(frame_data *fd, column_info *cinfo, gint col, gboolean fill_col_exprs)
1348 switch (cinfo->col_fmt[col]) {
1351 guint32_to_str_buf(fd->num, cinfo->col_buf[col], COL_MAX_LEN);
1352 cinfo->col_data[col] = cinfo->col_buf[col];
1357 case COL_ABS_DATE_TIME:
1359 case COL_DELTA_TIME:
1360 case COL_DELTA_TIME_DIS:
1361 /* TODO: Pass on fill_col_exprs */
1362 col_set_fmt_time(fd, cinfo, cinfo->col_fmt[col], col);
1365 case COL_PACKET_LENGTH:
1366 guint32_to_str_buf(fd->pkt_len, cinfo->col_buf[col], COL_MAX_LEN);
1367 cinfo->col_data[col] = cinfo->col_buf[col];
1370 case COL_CUMULATIVE_BYTES:
1371 guint32_to_str_buf(fd->cum_bytes, cinfo->col_buf[col], COL_MAX_LEN);
1372 cinfo->col_data[col] = cinfo->col_buf[col];
1379 if (!fill_col_exprs)
1382 switch (cinfo->col_fmt[col]) {
1385 cinfo->col_expr.col_expr[col] = "frame.number";
1386 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1391 case COL_ABS_DATE_TIME:
1393 case COL_DELTA_TIME:
1394 case COL_DELTA_TIME_DIS:
1395 /* Already handled above */
1398 case COL_PACKET_LENGTH:
1399 cinfo->col_expr.col_expr[col] = "frame.len";
1400 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1403 case COL_CUMULATIVE_BYTES:
1412 col_fill_in(packet_info *pinfo, gboolean fill_col_exprs, gboolean fill_fd_colums)
1419 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1420 switch (pinfo->cinfo->col_fmt[i]) {
1425 case COL_ABS_DATE_TIME:
1427 case COL_DELTA_TIME:
1428 case COL_DELTA_TIME_DIS:
1429 case COL_PACKET_LENGTH:
1430 case COL_CUMULATIVE_BYTES:
1432 col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i, fill_col_exprs);
1436 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1437 col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs);
1441 col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs);
1444 case COL_DEF_DL_SRC:
1445 case COL_RES_DL_SRC:
1446 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, fill_col_exprs);
1449 case COL_UNRES_DL_SRC:
1450 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, fill_col_exprs);
1453 case COL_DEF_NET_SRC:
1454 case COL_RES_NET_SRC:
1455 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, fill_col_exprs);
1458 case COL_UNRES_NET_SRC:
1459 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, fill_col_exprs);
1463 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1464 col_set_addr(pinfo, i, &pinfo->dst, FALSE, fill_col_exprs);
1468 col_set_addr(pinfo, i, &pinfo->dst, FALSE, fill_col_exprs);
1471 case COL_DEF_DL_DST:
1472 case COL_RES_DL_DST:
1473 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, fill_col_exprs);
1476 case COL_UNRES_DL_DST:
1477 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, fill_col_exprs);
1480 case COL_DEF_NET_DST:
1481 case COL_RES_NET_DST:
1482 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, fill_col_exprs);
1485 case COL_UNRES_NET_DST:
1486 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, fill_col_exprs);
1489 case COL_DEF_SRC_PORT:
1490 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1491 col_set_port(pinfo, i, TRUE, TRUE, fill_col_exprs);
1494 case COL_UNRES_SRC_PORT:
1495 col_set_port(pinfo, i, FALSE, TRUE, fill_col_exprs);
1498 case COL_DEF_DST_PORT:
1499 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1500 col_set_port(pinfo, i, TRUE, FALSE, fill_col_exprs);
1503 case COL_UNRES_DST_PORT:
1504 col_set_port(pinfo, i, FALSE, FALSE, fill_col_exprs);
1508 guint32_to_str_buf(pinfo->vsan, pinfo->cinfo->col_buf[i], COL_MAX_LEN);
1509 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1512 case COL_CUSTOM: /* done by col_custom_set_edt() */
1515 case COL_PROTOCOL: /* currently done by dissectors */
1516 case COL_INFO: /* currently done by dissectors */
1519 case COL_IF_DIR: /* currently done by dissectors */
1522 case COL_DCE_CALL: /* done by dcerpc */
1525 case COL_8021Q_VLAN_ID: /* done by packet-nstrace.c and packet-vlan.c */
1528 case COL_EXPERT: /* done by expert.c */
1531 case COL_FREQ_CHAN: /* done by radio dissectors */
1534 case COL_TX_RATE: /* done by packet-radiotap.c */
1537 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1539 g_assert_not_reached();
1546 XXX this needs more rework?
1547 /* --------------------------- */
1550 set_addr(address *addr, gboolean is_res)
1552 if (addr->type == AT_NONE)
1553 return ""; /* no address, nothing to do */
1556 return se_get_addr_name(addr /*, COL_MAX_LEN*/);
1558 return se_address_to_str(addr);
1561 /* Fills col_text in the frame data structure */
1563 col_fill_fdata(packet_info *pinfo)
1576 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1578 switch (pinfo->cinfo->col_fmt[i]) {
1579 case COL_NUMBER: /* frame number */
1580 case COL_PACKET_LENGTH: /* fd->pkt_len */
1581 case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */
1584 case COL_ABS_DATE_TIME: /* from fd structures */
1586 case COL_DELTA_TIME:
1587 case COL_DELTA_TIME_DIS:
1591 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1594 fdata->col_text[i] = set_addr(&pinfo->src, res);
1597 case COL_DEF_DL_SRC:
1598 case COL_RES_DL_SRC:
1600 case COL_UNRES_DL_SRC:
1601 fdata->col_text[i] = set_addr (&pinfo->dl_src, res);
1604 case COL_DEF_NET_SRC:
1605 case COL_RES_NET_SRC:
1607 case COL_UNRES_NET_SRC:
1608 fdata->col_text[i] = set_addr (&pinfo->net_src, res);
1612 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1615 fdata->col_text[i] = set_addr (&pinfo->dst, res);
1618 case COL_DEF_DL_DST:
1619 case COL_RES_DL_DST:
1621 case COL_UNRES_DL_DST:
1622 fdata->col_text[i] = set_addr (&pinfo->dl_dst, res);
1625 case COL_DEF_NET_DST:
1626 case COL_RES_NET_DST:
1628 case COL_UNRES_NET_DST:
1629 fdata->col_text[i] = set_addr (&pinfo->net_dst, res);
1632 case COL_DEF_SRC_PORT:
1633 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1634 fdata->col_text[i] = set_port(pinfo, TRUE, pinfo->srcport);
1636 case COL_UNRES_SRC_PORT:
1637 fdata->col_text[i] = set_port(pinfo, FALSE, pinfo->srcport);
1640 case COL_DEF_DST_PORT:
1641 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1642 fdata->col_text[i] = set_port(pinfo, TRUE, pinfo->destport);
1645 case COL_UNRES_DST_PORT:
1646 fdata->col_text[i] = set_port(pinfo, FALSE, pinfo->destport);
1649 case COL_IF_DIR: /* currently done by dissectors */
1652 case COL_HPUX_SUBSYS:
1653 case COL_HPUX_DEVID:
1655 case COL_8021Q_VLAN_ID:
1656 case COL_DSCP_VALUE:
1659 case COL_BSSGP_TLLI:
1663 if (pinfo->cinfo->col_data[i] != pinfo->cinfo->col_buf[i]) {
1664 /* XXX assume it's a constant */
1665 fdata->col_text[i] = (gchar *)pinfo->cinfo->col_data[i];
1669 fdata->col_text[i] = se_strdup(pinfo->cinfo->col_data[i]);
1673 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->oxid));
1676 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->rxid));
1678 case COL_CIRCUIT_ID:
1679 set_circuit_id(pinfo);
1682 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->src_idx));
1685 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->dst_idx));
1688 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->vsan));
1691 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1692 g_assert_not_reached();
1698 /* XXX Gets/creates the text from col_text in frame data */
1699 /* --------------------- */
1701 col_get_text(frame_data *fd, column_info *cinfo, gint col)
1703 static gchar fmtbuf[3][COL_MAX_LEN];
1708 idx = (idx + 1) % 3;
1713 switch (cinfo->col_fmt[col]) {
1714 case COL_NUMBER: /* frame number */
1715 guint32_to_str_buf(fd->num, buf, COL_MAX_LEN);
1719 set_cls_time(fd, buf);
1722 set_abs_time(fd, buf);
1724 case COL_ABS_DATE_TIME:
1725 set_abs_date_time(fd, buf);
1728 set_rel_time(fd, buf);
1730 case COL_DELTA_TIME:
1731 set_delta_time(fd, buf);
1733 case COL_DELTA_TIME_DIS:
1734 set_delta_time_dis(fd, buf);
1737 case COL_PACKET_LENGTH: /* fd->pkt_len */
1738 guint32_to_str_buf(fd->pkt_len, buf, COL_MAX_LEN);
1741 case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */
1742 guint32_to_str_buf(fd->cum_bytes, buf, COL_MAX_LEN);
1746 case COL_RES_SRC: /* network address */
1748 case COL_DEF_DL_SRC:
1749 case COL_RES_DL_SRC:
1750 case COL_UNRES_DL_SRC:
1751 case COL_DEF_NET_SRC:
1752 case COL_RES_NET_SRC:
1753 case COL_UNRES_NET_SRC:
1757 case COL_DEF_DL_DST:
1758 case COL_RES_DL_DST:
1759 case COL_UNRES_DL_DST:
1760 case COL_DEF_NET_DST:
1761 case COL_RES_NET_DST:
1762 case COL_UNRES_NET_DST:
1765 case COL_CIRCUIT_ID:
1768 case COL_HPUX_SUBSYS:
1769 case COL_HPUX_DEVID:
1771 case COL_8021Q_VLAN_ID:
1772 case COL_DSCP_VALUE:
1775 case COL_BSSGP_TLLI:
1779 ptr = fd->col_text[col];
1782 case COL_DEF_SRC_PORT:
1783 case COL_RES_SRC_PORT:
1784 case COL_UNRES_SRC_PORT:
1785 case COL_DEF_DST_PORT:
1786 case COL_RES_DST_PORT:
1787 case COL_UNRES_DST_PORT:
1789 if (GPOINTER_TO_UINT(fd->col_text[col]) <= 65536)
1790 guint32_to_str_buf(GPOINTER_TO_UINT(fd->col_text[col], buf, COL_MAX_LEN));
1792 ptr = fd->col_text[col];
1799 g_snprintf(buf, COL_MAX_LEN, "0x%x", GPOINTER_TO_UINT(fd->col_text[col]));
1803 guint32_to_str_buf(GPOINTER_TO_UINT(fd->col_text[col]), buf, COL_MAX_LEN);
1806 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1807 g_assert_not_reached();