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 static column_info *ci;
50 /* Allocate all the data structures for constructing column data, given
51 the number of columns. */
53 col_setup(column_info *cinfo, gint num_cols)
57 cinfo->num_cols = num_cols;
58 cinfo->col_fmt = g_new(gint, num_cols);
59 cinfo->fmt_matx = g_new(gboolean*, num_cols);
60 cinfo->col_first = g_new(int, NUM_COL_FMTS);
61 cinfo->col_last = g_new(int, NUM_COL_FMTS);
62 cinfo->col_title = g_new(gchar*, num_cols);
63 cinfo->col_custom_field = g_new(gchar*, 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;
97 col_get_writable(column_info *cinfo)
99 return (cinfo ? cinfo->writable : FALSE);
103 col_set_writable(column_info *cinfo, gboolean writable)
106 cinfo->writable = writable;
109 /* Checks to see if a particular packet information element is needed for
112 check_col(column_info *cinfo, gint el) {
114 if (col_get_writable(cinfo)) {
115 /* We are constructing columns, and they're writable */
116 if (cinfo->col_first[el] >= 0) {
117 /* There is at least one column in that format */
124 /* Sets the fence for a column to be at the end of the column. */
126 col_set_fence(column_info *cinfo, 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, 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 (fence == 0 || cinfo->col_buf[i] == cinfo->col_data[i]) {
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 /* Use this if "str" points to something that will stay around (and thus
203 needn't be copied). */
205 col_set_str(column_info *cinfo, gint el, const gchar* str)
211 if (!check_col(cinfo, el))
215 max_len = COL_MAX_INFO_LEN;
217 max_len = COL_MAX_LEN;
219 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
220 if (cinfo->fmt_matx[i][el]) {
221 fence = cinfo->col_fence[i];
224 * We will append the string after the fence.
225 * First arrange that we can append, if necessary.
227 COL_CHECK_APPEND(cinfo, i, max_len);
229 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
232 * There's no fence, so we can just set the column to point
235 cinfo->col_data[i] = str;
241 /* Adds a vararg list to a packet info string. */
243 col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) {
249 if (!check_col(cinfo, el))
253 max_len = COL_MAX_INFO_LEN;
255 max_len = COL_MAX_LEN;
257 va_start(ap, format);
258 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
259 if (cinfo->fmt_matx[i][el]) {
260 fence = cinfo->col_fence[i];
263 * We will append the string after the fence.
264 * First arrange that we can append, if necessary.
266 COL_CHECK_APPEND(cinfo, i, max_len);
269 * There's no fence, so we can just write to the string.
271 cinfo->col_data[i] = cinfo->col_buf[i];
273 g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
281 col_custom_set_fstr(header_field_info *hfinfo, const gchar *format, ...)
286 if (!have_custom_cols(ci))
289 va_start(ap, format);
290 for (i = ci->col_first[COL_CUSTOM];
291 i <= ci->col_last[COL_CUSTOM]; i++) {
292 if (ci->fmt_matx[i][COL_CUSTOM] &&
293 ci->col_custom_field[i] &&
294 strcmp(ci->col_custom_field[i], hfinfo->abbrev) == 0) {
295 ci->col_data[i] = ci->col_buf[i];
296 g_vsnprintf(ci->col_buf[i], COL_MAX_LEN, format, ap);
298 ci->col_expr.col_expr[i] = hfinfo->abbrev;
300 switch(hfinfo->type) {
303 g_snprintf(ci->col_expr.col_expr_val[i], COL_MAX_LEN, "\"%s\"", ci->col_buf[i]);
307 g_strlcpy(ci->col_expr.col_expr_val[i], ci->col_buf[i], COL_MAX_LEN);
315 /* search in edt tree custom fields */
316 void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo)
320 if(!have_custom_cols(cinfo))
323 for (i = cinfo->col_first[COL_CUSTOM];
324 i <= cinfo->col_last[COL_CUSTOM]; i++) {
325 if (cinfo->fmt_matx[i][COL_CUSTOM] && cinfo->col_custom_field[i]) {
326 cinfo->col_data[i] = cinfo->col_buf[i];
328 cinfo->col_expr.col_expr[i] = epan_custom_set(edt, cinfo->col_custom_field[i],
330 cinfo->col_expr.col_expr_val[i],
337 col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
341 ci = cinfo; /* Save this into the static variable ci for use by
342 * col_custom_set_fstr() later. */
344 if(!have_custom_cols(cinfo))
347 for (i = cinfo->col_first[COL_CUSTOM];
348 i <= cinfo->col_last[COL_CUSTOM]; i++) {
349 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
350 cinfo->col_custom_dfilter[i])
351 epan_dissect_prime_dfilter(edt, cinfo->col_custom_dfilter[i]);
356 have_custom_cols(column_info *cinfo)
358 /* The same as check_col(), but without the check to see if the column
360 if (cinfo && cinfo->col_first[COL_CUSTOM] >= 0)
367 col_has_time_fmt(column_info *cinfo, gint col)
369 return ((cinfo->fmt_matx[col][COL_CLS_TIME]) ||
370 (cinfo->fmt_matx[col][COL_ABS_TIME]) ||
371 (cinfo->fmt_matx[col][COL_ABS_DATE_TIME]) ||
372 (cinfo->fmt_matx[col][COL_REL_TIME]) ||
373 (cinfo->fmt_matx[col][COL_DELTA_TIME]) ||
374 (cinfo->fmt_matx[col][COL_DELTA_TIME_DIS]));
378 col_do_append_sep_va_fstr(column_info *cinfo, gint el, const gchar *separator,
379 const gchar *format, va_list ap)
382 int len, max_len, sep_len;
385 max_len = COL_MAX_INFO_LEN;
387 max_len = COL_MAX_LEN;
389 if (separator == NULL)
392 sep_len = (int) strlen(separator);
393 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
394 if (cinfo->fmt_matx[i][el]) {
396 * First arrange that we can append, if necessary.
398 COL_CHECK_APPEND(cinfo, i, max_len);
400 len = (int) strlen(cinfo->col_buf[i]);
403 * If we have a separator, append it if the column isn't empty.
405 if (separator != NULL) {
407 g_strlcat(cinfo->col_buf[i], separator, max_len);
411 g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
412 cinfo->col_buf[i][max_len-1] = 0;
417 /* Appends a vararg list to a packet info string. */
419 col_append_fstr(column_info *cinfo, gint el, const gchar *format, ...)
423 if (!check_col(cinfo, el))
426 va_start(ap, format);
427 col_do_append_sep_va_fstr(cinfo, el, NULL, format, ap);
431 /* Appends a vararg list to a packet info string.
432 * Prefixes it with the given separator if the column is not empty. */
434 col_append_sep_fstr(column_info *cinfo, gint el, const gchar *separator,
435 const gchar *format, ...)
439 if (!check_col(cinfo, el))
442 if (separator == NULL)
443 separator = ", "; /* default */
444 va_start(ap, format);
445 col_do_append_sep_va_fstr(cinfo, el, separator, format, ap);
451 /* Prepends a vararg list to a packet info string. */
452 #define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
453 (COL_MAX_INFO_LEN) : (COL_MAX_LEN))
455 col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
459 char orig_buf[COL_BUF_MAX_LEN];
463 if (!check_col(cinfo, el))
467 max_len = COL_MAX_INFO_LEN;
469 max_len = COL_MAX_LEN;
471 va_start(ap, format);
472 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
473 if (cinfo->fmt_matx[i][el]) {
474 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
475 /* This was set with "col_set_str()"; which is effectively const */
476 orig = cinfo->col_data[i];
478 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
481 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
482 cinfo->col_buf[i][max_len - 1] = '\0';
485 * Move the fence, unless it's at the beginning of the string.
487 if (cinfo->col_fence[i] > 0)
488 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
490 g_strlcat(cinfo->col_buf[i], orig, max_len);
491 cinfo->col_data[i] = cinfo->col_buf[i];
497 col_prepend_fence_fstr(column_info *cinfo, gint el, const gchar *format, ...)
501 char orig_buf[COL_BUF_MAX_LEN];
505 if (!check_col(cinfo, el))
509 max_len = COL_MAX_INFO_LEN;
511 max_len = COL_MAX_LEN;
513 va_start(ap, format);
514 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
515 if (cinfo->fmt_matx[i][el]) {
516 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
517 /* This was set with "col_set_str()"; which is effectively const */
518 orig = cinfo->col_data[i];
520 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
523 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
524 cinfo->col_buf[i][max_len - 1] = '\0';
527 * Move the fence if it exists, else create a new fence at the
528 * end of the prepended data.
530 if (cinfo->col_fence[i] > 0) {
531 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
533 cinfo->col_fence[i] = (int) strlen(cinfo->col_buf[i]);
535 g_strlcat(cinfo->col_buf[i], orig, max_len);
536 cinfo->col_data[i] = cinfo->col_buf[i];
542 /* Use this if "str" points to something that won't stay around (and
543 must thus be copied). */
545 col_add_str(column_info *cinfo, gint el, const gchar* str)
551 if (!check_col(cinfo, el))
555 max_len = COL_MAX_INFO_LEN;
557 max_len = COL_MAX_LEN;
559 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
560 if (cinfo->fmt_matx[i][el]) {
561 fence = cinfo->col_fence[i];
564 * We will append the string after the fence.
565 * First arrange that we can append, if necessary.
567 COL_CHECK_APPEND(cinfo, i, max_len);
570 * There's no fence, so we can just write to the string.
572 cinfo->col_data[i] = cinfo->col_buf[i];
574 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
580 col_do_append_str(column_info *cinfo, gint el, const gchar* separator,
584 size_t len, max_len, sep_len;
586 if (!check_col(cinfo, el))
590 max_len = COL_MAX_INFO_LEN;
592 max_len = COL_MAX_LEN;
594 if (separator == NULL)
597 sep_len = strlen(separator);
599 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
600 if (cinfo->fmt_matx[i][el]) {
602 * First arrange that we can append, if necessary.
604 COL_CHECK_APPEND(cinfo, i, max_len);
606 len = cinfo->col_buf[i][0];
609 * If we have a separator, append it if the column isn't empty.
611 if (separator != NULL) {
613 g_strlcat(cinfo->col_buf[i], separator, max_len);
616 g_strlcat(cinfo->col_buf[i], str, max_len);
622 col_append_str(column_info *cinfo, gint el, const gchar* str)
624 col_do_append_str(cinfo, el, NULL, str);
628 col_append_sep_str(column_info *cinfo, gint el, const gchar* separator,
631 if (separator == NULL)
632 separator = ", "; /* default */
633 col_do_append_str(cinfo, el, separator, str);
636 /* --------------------------------- */
638 set_abs_date_time(frame_data *fd, gchar *buf)
643 COL_CHECK_REF_TIME(fd, buf);
645 then = fd->abs_ts.secs;
646 tmp = localtime(&then);
648 switch(timestamp_get_precision()) {
649 case(TS_PREC_FIXED_SEC):
650 case(TS_PREC_AUTO_SEC):
651 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d",
659 case(TS_PREC_FIXED_DSEC):
660 case(TS_PREC_AUTO_DSEC):
661 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%01ld",
668 (long)fd->abs_ts.nsecs / 100000000);
670 case(TS_PREC_FIXED_CSEC):
671 case(TS_PREC_AUTO_CSEC):
672 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%02ld",
679 (long)fd->abs_ts.nsecs / 10000000);
681 case(TS_PREC_FIXED_MSEC):
682 case(TS_PREC_AUTO_MSEC):
683 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%03ld",
690 (long)fd->abs_ts.nsecs / 1000000);
692 case(TS_PREC_FIXED_USEC):
693 case(TS_PREC_AUTO_USEC):
694 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
701 (long)fd->abs_ts.nsecs / 1000);
703 case(TS_PREC_FIXED_NSEC):
704 case(TS_PREC_AUTO_NSEC):
705 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
712 (long)fd->abs_ts.nsecs);
715 g_assert_not_reached();
724 col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
726 if (set_abs_date_time(fd, cinfo->col_buf[col])) {
727 cinfo->col_expr.col_expr[col] = "frame.time";
728 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
730 cinfo->col_data[col] = cinfo->col_buf[col];
733 /* --------------------------------- */
735 set_rel_time(frame_data *fd, gchar *buf)
737 COL_CHECK_REF_TIME(fd, buf);
739 switch(timestamp_get_precision()) {
740 case(TS_PREC_FIXED_SEC):
741 case(TS_PREC_AUTO_SEC):
742 display_signed_time(buf, COL_MAX_LEN,
743 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000000, SECS);
745 case(TS_PREC_FIXED_DSEC):
746 case(TS_PREC_AUTO_DSEC):
747 display_signed_time(buf, COL_MAX_LEN,
748 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 100000000, DSECS);
750 case(TS_PREC_FIXED_CSEC):
751 case(TS_PREC_AUTO_CSEC):
752 display_signed_time(buf, COL_MAX_LEN,
753 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 10000000, CSECS);
755 case(TS_PREC_FIXED_MSEC):
756 case(TS_PREC_AUTO_MSEC):
757 display_signed_time(buf, COL_MAX_LEN,
758 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000, MSECS);
760 case(TS_PREC_FIXED_USEC):
761 case(TS_PREC_AUTO_USEC):
762 display_signed_time(buf, COL_MAX_LEN,
763 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS);
765 case(TS_PREC_FIXED_NSEC):
766 case(TS_PREC_AUTO_NSEC):
767 display_signed_time(buf, COL_MAX_LEN,
768 (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs, NSECS);
771 g_assert_not_reached();
777 col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
779 if (set_rel_time(fd, cinfo->col_buf[col])) {
780 cinfo->col_expr.col_expr[col] = "frame.time_relative";
781 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
783 cinfo->col_data[col] = cinfo->col_buf[col];
786 /* ------------------------------------------ */
788 set_delta_time(frame_data *fd, gchar *buf)
790 COL_CHECK_REF_TIME(fd, buf);
792 switch(timestamp_get_precision()) {
793 case(TS_PREC_FIXED_SEC):
794 case(TS_PREC_AUTO_SEC):
795 display_signed_time(buf, COL_MAX_LEN,
796 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000000, SECS);
798 case(TS_PREC_FIXED_DSEC):
799 case(TS_PREC_AUTO_DSEC):
800 display_signed_time(buf, COL_MAX_LEN,
801 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 100000000, DSECS);
803 case(TS_PREC_FIXED_CSEC):
804 case(TS_PREC_AUTO_CSEC):
805 display_signed_time(buf, COL_MAX_LEN,
806 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 10000000, CSECS);
808 case(TS_PREC_FIXED_MSEC):
809 case(TS_PREC_AUTO_MSEC):
810 display_signed_time(buf, COL_MAX_LEN,
811 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000, MSECS);
813 case(TS_PREC_FIXED_USEC):
814 case(TS_PREC_AUTO_USEC):
815 display_signed_time(buf, COL_MAX_LEN,
816 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000, USECS);
818 case(TS_PREC_FIXED_NSEC):
819 case(TS_PREC_AUTO_NSEC):
820 display_signed_time(buf, COL_MAX_LEN,
821 (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs, NSECS);
824 g_assert_not_reached();
830 col_set_delta_time(frame_data *fd, column_info *cinfo, int col)
832 if (set_delta_time(fd, cinfo->col_buf[col])) {
833 cinfo->col_expr.col_expr[col] = "frame.time_delta";
834 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
836 cinfo->col_data[col] = cinfo->col_buf[col];
839 /* ------------------------------------------
840 To do: Add check_col checks to the col_add* routines
843 set_delta_time_dis(frame_data *fd, gchar *buf)
845 COL_CHECK_REF_TIME(fd, buf);
847 switch(timestamp_get_precision()) {
848 case(TS_PREC_FIXED_SEC):
849 case(TS_PREC_AUTO_SEC):
850 display_signed_time(buf, COL_MAX_LEN,
851 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000000, SECS);
853 case(TS_PREC_FIXED_DSEC):
854 case(TS_PREC_AUTO_DSEC):
855 display_signed_time(buf, COL_MAX_LEN,
856 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 100000000, DSECS);
858 case(TS_PREC_FIXED_CSEC):
859 case(TS_PREC_AUTO_CSEC):
860 display_signed_time(buf, COL_MAX_LEN,
861 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 10000000, CSECS);
863 case(TS_PREC_FIXED_MSEC):
864 case(TS_PREC_AUTO_MSEC):
865 display_signed_time(buf, COL_MAX_LEN,
866 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000, MSECS);
868 case(TS_PREC_FIXED_USEC):
869 case(TS_PREC_AUTO_USEC):
870 display_signed_time(buf, COL_MAX_LEN,
871 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000, USECS);
873 case(TS_PREC_FIXED_NSEC):
874 case(TS_PREC_AUTO_NSEC):
875 display_signed_time(buf, COL_MAX_LEN,
876 (gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs, NSECS);
879 g_assert_not_reached();
885 col_set_delta_time_dis(frame_data *fd, column_info *cinfo, int col)
887 if (set_delta_time_dis(fd, cinfo->col_buf[col])) {
888 cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
889 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
891 cinfo->col_data[col] = cinfo->col_buf[col];
894 /* ------------------------ */
895 /* To do: Add check_col checks to the col_add* routines */
898 set_abs_time(frame_data *fd, gchar *buf)
903 COL_CHECK_REF_TIME(fd, buf);
905 then = fd->abs_ts.secs;
906 tmp = localtime(&then);
908 switch(timestamp_get_precision()) {
909 case(TS_PREC_FIXED_SEC):
910 case(TS_PREC_AUTO_SEC):
911 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d",
916 case(TS_PREC_FIXED_DSEC):
917 case(TS_PREC_AUTO_DSEC):
918 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%01ld",
922 (long)fd->abs_ts.nsecs / 100000000);
924 case(TS_PREC_FIXED_CSEC):
925 case(TS_PREC_AUTO_CSEC):
926 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%02ld",
930 (long)fd->abs_ts.nsecs / 10000000);
932 case(TS_PREC_FIXED_MSEC):
933 case(TS_PREC_AUTO_MSEC):
934 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%03ld",
938 (long)fd->abs_ts.nsecs / 1000000);
940 case(TS_PREC_FIXED_USEC):
941 case(TS_PREC_AUTO_USEC):
942 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%06ld",
946 (long)fd->abs_ts.nsecs / 1000);
948 case(TS_PREC_FIXED_NSEC):
949 case(TS_PREC_AUTO_NSEC):
950 g_snprintf(buf, COL_MAX_LEN, "%02d:%02d:%02d.%09ld",
954 (long)fd->abs_ts.nsecs);
957 g_assert_not_reached();
967 col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
969 if (set_abs_time(fd, cinfo->col_buf[col])) {
970 cinfo->col_expr.col_expr[col] = "frame.time";
971 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
973 cinfo->col_data[col] = cinfo->col_buf[col];
976 /* ------------------------ */
978 set_epoch_time(frame_data *fd, gchar *buf)
981 COL_CHECK_REF_TIME(fd, buf);
983 switch(timestamp_get_precision()) {
984 case(TS_PREC_FIXED_SEC):
985 case(TS_PREC_AUTO_SEC):
986 display_epoch_time(buf, COL_MAX_LEN,
987 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, SECS);
989 case(TS_PREC_FIXED_DSEC):
990 case(TS_PREC_AUTO_DSEC):
991 display_epoch_time(buf, COL_MAX_LEN,
992 fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, DSECS);
994 case(TS_PREC_FIXED_CSEC):
995 case(TS_PREC_AUTO_CSEC):
996 display_epoch_time(buf, COL_MAX_LEN,
997 fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, CSECS);
999 case(TS_PREC_FIXED_MSEC):
1000 case(TS_PREC_AUTO_MSEC):
1001 display_epoch_time(buf, COL_MAX_LEN,
1002 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, MSECS);
1004 case(TS_PREC_FIXED_USEC):
1005 case(TS_PREC_AUTO_USEC):
1006 display_epoch_time(buf, COL_MAX_LEN,
1007 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, USECS);
1009 case(TS_PREC_FIXED_NSEC):
1010 case(TS_PREC_AUTO_NSEC):
1011 display_epoch_time(buf, COL_MAX_LEN,
1012 fd->abs_ts.secs, fd->abs_ts.nsecs, NSECS);
1015 g_assert_not_reached();
1021 col_set_epoch_time(frame_data *fd, column_info *cinfo, int col)
1024 if (set_epoch_time(fd, cinfo->col_buf[col])) {
1025 cinfo->col_expr.col_expr[col] = "frame.time_delta";
1026 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1028 cinfo->col_data[col] = cinfo->col_buf[col];
1031 /* Set the format of the variable time format.
1032 XXX - this is called from "file.c" when the user changes the time
1033 format they want for "command-line-specified" time; it's a bit ugly
1034 that we have to export it, but if we go to a CList-like widget that
1035 invokes callbacks to get the text for the columns rather than
1036 requiring us to stuff the text into the widget from outside, we
1037 might be able to clean this up. */
1039 set_cls_time(frame_data *fd, gchar *buf)
1041 switch (timestamp_get_type()) {
1043 set_abs_time(fd, buf);
1046 case TS_ABSOLUTE_WITH_DATE:
1047 set_abs_date_time(fd, buf);
1051 set_rel_time(fd, buf);
1055 set_delta_time(fd, buf);
1059 set_delta_time_dis(fd, buf);
1063 set_epoch_time(fd, buf);
1067 /* code is missing for this case, but I don't know which [jmayer20051219] */
1075 col_set_cls_time(frame_data *fd, column_info *cinfo, gint col)
1077 switch (timestamp_get_type()) {
1079 col_set_abs_time(fd, cinfo, col);
1082 case TS_ABSOLUTE_WITH_DATE:
1083 col_set_abs_date_time(fd, cinfo, col);
1087 col_set_rel_time(fd, cinfo, col);
1091 col_set_delta_time(fd, cinfo, col);
1095 col_set_delta_time_dis(fd, cinfo, col);
1099 col_set_epoch_time(fd, cinfo, col);
1103 /* code is missing for this case, but I don't know which [jmayer20051219] */
1109 /* Set the format of the variable time format.
1110 XXX - this is called from "file.c" when the user changes the time
1111 format they want for "command-line-specified" time; it's a bit ugly
1112 that we have to export it, but if we go to a CList-like widget that
1113 invokes callbacks to get the text for the columns rather than
1114 requiring us to stuff the text into the widget from outside, we
1115 might be able to clean this up. */
1117 col_set_fmt_time(frame_data *fd, column_info *cinfo, gint fmt, gint col)
1121 col_set_cls_time(fd, cinfo, col);
1125 col_set_abs_time(fd, cinfo, col);
1128 case COL_ABS_DATE_TIME:
1129 col_set_abs_date_time(fd, cinfo, col);
1133 col_set_rel_time(fd, cinfo, col);
1136 case COL_DELTA_TIME:
1137 col_set_delta_time(fd, cinfo, col);
1140 case COL_DELTA_TIME_DIS:
1141 col_set_delta_time_dis(fd, cinfo, col);
1145 g_assert_not_reached();
1150 /* --------------------------- */
1152 col_set_time(column_info *cinfo, gint el, nstime_t *ts, char *fieldname)
1156 if (!check_col(cinfo, el))
1159 for (col = cinfo->col_first[el]; col <= cinfo->col_last[el]; col++) {
1160 if (cinfo->fmt_matx[col][el]) {
1161 switch(timestamp_get_precision()) {
1162 case(TS_PREC_FIXED_SEC):
1163 case(TS_PREC_AUTO_SEC):
1164 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1165 (gint32) ts->secs, ts->nsecs / 1000000000, SECS);
1167 case(TS_PREC_FIXED_DSEC):
1168 case(TS_PREC_AUTO_DSEC):
1169 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1170 (gint32) ts->secs, ts->nsecs / 100000000, DSECS);
1172 case(TS_PREC_FIXED_CSEC):
1173 case(TS_PREC_AUTO_CSEC):
1174 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1175 (gint32) ts->secs, ts->nsecs / 10000000, CSECS);
1177 case(TS_PREC_FIXED_MSEC):
1178 case(TS_PREC_AUTO_MSEC):
1179 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1180 (gint32) ts->secs, ts->nsecs / 1000000, MSECS);
1182 case(TS_PREC_FIXED_USEC):
1183 case(TS_PREC_AUTO_USEC):
1184 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1185 (gint32) ts->secs, ts->nsecs / 1000, USECS);
1187 case(TS_PREC_FIXED_NSEC):
1188 case(TS_PREC_AUTO_NSEC):
1189 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1190 (gint32) ts->secs, ts->nsecs, NSECS);
1193 g_assert_not_reached();
1195 cinfo->col_data[col] = cinfo->col_buf[col];
1196 cinfo->col_expr.col_expr[col] = fieldname;
1197 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1203 col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res,
1206 struct e_in6_addr ipv6_addr;
1208 if (addr->type == AT_NONE)
1209 return; /* no address, nothing to do */
1212 get_addr_name_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1214 address_to_str_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1216 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1218 switch (addr->type) {
1222 pinfo->cinfo->col_expr.col_expr[col] = "eth.src";
1224 pinfo->cinfo->col_expr.col_expr[col] = "eth.dst";
1225 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ether_to_str(addr->data), COL_MAX_LEN);
1230 pinfo->cinfo->col_expr.col_expr[col] = "ip.src";
1232 pinfo->cinfo->col_expr.col_expr[col] = "ip.dst";
1233 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ip_to_str(addr->data), COL_MAX_LEN);
1238 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.src";
1240 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.dst";
1241 memcpy(&ipv6_addr.bytes, addr->data, sizeof ipv6_addr.bytes);
1242 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN);
1247 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src";
1249 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst";
1250 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1255 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.src";
1257 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.dst";
1258 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1263 pinfo->cinfo->col_expr.col_expr[col] = "uri.src";
1265 pinfo->cinfo->col_expr.col_expr[col] = "uri.dst";
1266 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1274 /* ------------------------ */
1276 col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src)
1281 port = pinfo->srcport;
1283 port = pinfo->destport;
1285 switch (pinfo->ptype) {
1288 g_strlcpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
1290 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
1294 g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", port);
1296 g_strlcpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
1298 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1300 pinfo->cinfo->col_expr.col_expr[col] = "tcp.srcport";
1302 pinfo->cinfo->col_expr.col_expr[col] = "tcp.dstport";
1306 g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", port);
1308 g_strlcpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
1310 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1312 pinfo->cinfo->col_expr.col_expr[col] = "udp.srcport";
1314 pinfo->cinfo->col_expr.col_expr[col] = "udp.dstport";
1319 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src_socket";
1321 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst_socket";
1322 g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", port);
1323 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1327 /* XXX - resolve IPX socket numbers */
1328 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1329 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1331 pinfo->cinfo->col_expr.col_expr[col] = "ipx.src.socket";
1333 pinfo->cinfo->col_expr.col_expr[col] = "ipx.dst.socket";
1337 /* XXX - resolve IDP socket numbers */
1338 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1339 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1341 pinfo->cinfo->col_expr.col_expr[col] = "idp.src.socket";
1343 pinfo->cinfo->col_expr.col_expr[col] = "idp.dst.socket";
1347 /* XXX - resolve USB endpoint numbers */
1348 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port);
1349 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1351 pinfo->cinfo->col_expr.col_expr[col] = "usb.src.endpoint";
1353 pinfo->cinfo->col_expr.col_expr[col] = "usb.dst.endpoint";
1359 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1363 * XXX - this should be in some common code in the epan directory, shared
1364 * by this code and packet-isdn.c.
1366 static const value_string channel_vals[] = {
1403 col_set_circuit_id(packet_info *pinfo, int col)
1405 switch (pinfo->ctype) {
1407 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1408 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1409 pinfo->cinfo->col_expr.col_expr[col] = "fr.dlci";
1413 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%s",
1414 val_to_str(pinfo->circuit_id, channel_vals, "Unknown (%u)"));
1415 pinfo->cinfo->col_expr.col_expr[col] = "isdn.channel";
1416 g_snprintf(pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1420 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1424 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1425 pinfo->cinfo->col_expr.col_expr[col] = "isup.cic";
1426 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col],pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1432 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1437 set_circuit_id(packet_info *pinfo)
1440 switch (pinfo->ctype) {
1445 ret = se_strdup_printf("%u", pinfo->circuit_id);
1449 ret = se_strdup_printf("%s", val_to_str(pinfo->circuit_id, channel_vals, "Unknown (%u)"));
1460 col_based_on_frame_data(column_info *cinfo, gint col)
1462 if (col_has_time_fmt(cinfo, col))
1465 switch (cinfo->col_fmt[col]) {
1468 case COL_PACKET_LENGTH:
1469 case COL_CUMULATIVE_BYTES:
1478 col_fill_in_frame_data(frame_data *fd, column_info *cinfo, gint col)
1480 switch (cinfo->col_fmt[col]) {
1483 g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%u", fd->num);
1484 cinfo->col_data[col] = cinfo->col_buf[col];
1485 cinfo->col_expr.col_expr[col] = "frame.number";
1486 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1491 case COL_ABS_DATE_TIME:
1493 case COL_DELTA_TIME:
1494 case COL_DELTA_TIME_DIS:
1495 col_set_fmt_time(fd, cinfo, cinfo->col_fmt[col], col);
1498 case COL_PACKET_LENGTH:
1499 g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%u", fd->pkt_len);
1500 cinfo->col_data[col] = cinfo->col_buf[col];
1501 cinfo->col_expr.col_expr[col] = "frame.len";
1502 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1505 case COL_CUMULATIVE_BYTES:
1506 g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%u", fd->cum_bytes);
1507 cinfo->col_data[col] = cinfo->col_buf[col];
1515 /* -------------------------- */
1517 col_fill_in(packet_info *pinfo, gboolean fill_fd_colums)
1524 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1525 switch (pinfo->cinfo->col_fmt[i]) {
1529 col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i);
1534 case COL_ABS_DATE_TIME:
1536 case COL_DELTA_TIME:
1537 case COL_DELTA_TIME_DIS:
1539 col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i);
1543 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1544 col_set_addr(pinfo, i, &pinfo->src, TRUE, TRUE);
1548 col_set_addr(pinfo, i, &pinfo->src, FALSE, TRUE);
1551 case COL_DEF_DL_SRC:
1552 case COL_RES_DL_SRC:
1553 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, TRUE);
1556 case COL_UNRES_DL_SRC:
1557 col_set_addr(pinfo, i, &pinfo->dl_src, FALSE, TRUE);
1560 case COL_DEF_NET_SRC:
1561 case COL_RES_NET_SRC:
1562 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, TRUE);
1565 case COL_UNRES_NET_SRC:
1566 col_set_addr(pinfo, i, &pinfo->net_src, FALSE, TRUE);
1570 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1571 col_set_addr(pinfo, i, &pinfo->dst, TRUE, FALSE);
1575 col_set_addr(pinfo, i, &pinfo->dst, FALSE, FALSE);
1578 case COL_DEF_DL_DST:
1579 case COL_RES_DL_DST:
1580 col_set_addr(pinfo, i, &pinfo->dl_dst, TRUE, FALSE);
1583 case COL_UNRES_DL_DST:
1584 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, FALSE);
1587 case COL_DEF_NET_DST:
1588 case COL_RES_NET_DST:
1589 col_set_addr(pinfo, i, &pinfo->net_dst, TRUE, FALSE);
1592 case COL_UNRES_NET_DST:
1593 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, FALSE);
1596 case COL_DEF_SRC_PORT:
1597 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1598 col_set_port(pinfo, i, TRUE, TRUE);
1601 case COL_UNRES_SRC_PORT:
1602 col_set_port(pinfo, i, FALSE, TRUE);
1605 case COL_DEF_DST_PORT:
1606 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1607 col_set_port(pinfo, i, TRUE, FALSE);
1610 case COL_UNRES_DST_PORT:
1611 col_set_port(pinfo, i, FALSE, FALSE);
1614 case COL_PROTOCOL: /* currently done by dissectors */
1615 case COL_INFO: /* currently done by dissectors */
1618 case COL_PACKET_LENGTH:
1619 case COL_CUMULATIVE_BYTES:
1621 col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i);
1625 g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->oxid);
1626 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1630 g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->rxid);
1631 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1634 case COL_IF_DIR: /* currently done by dissectors */
1638 g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->src_idx);
1639 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1643 g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->dst_idx);
1644 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1648 g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->vsan);
1649 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1652 case COL_DCE_CALL: /* done by dcerpc */
1655 case COL_DCE_CTX: /* done by dcerpc */
1658 case COL_8021Q_VLAN_ID: /* done by packet-nstrace.c and packet-vlan.c */
1661 case COL_BSSGP_TLLI: /* done by packet-bssgp.c */
1664 case COL_EXPERT: /* done by expert.c */
1667 case COL_FREQ_CHAN: /* done by radio dissectors */
1670 case COL_CUSTOM: /* done by col_custom_set_fstr() called from proto.c */
1673 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1674 g_assert_not_reached();
1680 XXX this needs more rework?
1681 /* --------------------------- */
1684 set_addr(address *addr, gboolean is_res)
1686 if (addr->type == AT_NONE)
1687 return ""; /* no address, nothing to do */
1690 return se_get_addr_name(addr /*, COL_MAX_LEN*/);
1692 return se_address_to_str(addr);
1695 /* Fills col_text in the frame data structure */
1697 col_fill_fdata(packet_info *pinfo)
1710 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1712 switch (pinfo->cinfo->col_fmt[i]) {
1713 case COL_NUMBER: /* frame number */
1714 case COL_PACKET_LENGTH: /* fd->pkt_len */
1715 case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */
1718 case COL_ABS_DATE_TIME: /* from fd structures */
1720 case COL_DELTA_TIME:
1721 case COL_DELTA_TIME_DIS:
1725 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1728 fdata->col_text[i] = set_addr(&pinfo->src, res);
1731 case COL_DEF_DL_SRC:
1732 case COL_RES_DL_SRC:
1734 case COL_UNRES_DL_SRC:
1735 fdata->col_text[i] = set_addr (&pinfo->dl_src, res);
1738 case COL_DEF_NET_SRC:
1739 case COL_RES_NET_SRC:
1741 case COL_UNRES_NET_SRC:
1742 fdata->col_text[i] = set_addr (&pinfo->net_src, res);
1746 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1749 fdata->col_text[i] = set_addr (&pinfo->dst, res);
1752 case COL_DEF_DL_DST:
1753 case COL_RES_DL_DST:
1755 case COL_UNRES_DL_DST:
1756 fdata->col_text[i] = set_addr (&pinfo->dl_dst, res);
1759 case COL_DEF_NET_DST:
1760 case COL_RES_NET_DST:
1762 case COL_UNRES_NET_DST:
1763 fdata->col_text[i] = set_addr (&pinfo->net_dst, res);
1766 case COL_DEF_SRC_PORT:
1767 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1768 fdata->col_text[i] = set_port(pinfo, TRUE, pinfo->srcport);
1770 case COL_UNRES_SRC_PORT:
1771 fdata->col_text[i] = set_port(pinfo, FALSE, pinfo->srcport);
1774 case COL_DEF_DST_PORT:
1775 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1776 fdata->col_text[i] = set_port(pinfo, TRUE, pinfo->destport);
1779 case COL_UNRES_DST_PORT:
1780 fdata->col_text[i] = set_port(pinfo, FALSE, pinfo->destport);
1783 case COL_IF_DIR: /* currently done by dissectors */
1786 case COL_HPUX_SUBSYS:
1787 case COL_HPUX_DEVID:
1789 case COL_8021Q_VLAN_ID:
1790 case COL_DSCP_VALUE:
1793 case COL_BSSGP_TLLI:
1797 if (pinfo->cinfo->col_data[i] != pinfo->cinfo->col_buf[i]) {
1798 /* XXX assume it's a constant */
1799 fdata->col_text[i] = (gchar *)pinfo->cinfo->col_data[i];
1803 fdata->col_text[i] = se_strdup(pinfo->cinfo->col_data[i]);
1807 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->oxid));
1810 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->rxid));
1812 case COL_CIRCUIT_ID:
1813 set_circuit_id(pinfo);
1816 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->src_idx));
1819 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->dst_idx));
1822 fdata->col_text[i] = (gchar *)(GUINT_TO_POINTER((guint)pinfo->vsan));
1825 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1826 g_assert_not_reached();
1832 /* XXX Gets/creates the text fro col_text in frame data */
1833 /* --------------------- */
1835 col_get_text(frame_data *fd, column_info *cinfo, gint col)
1837 static gchar fmtbuf[3][COL_MAX_LEN];
1842 idx = (idx + 1) % 3;
1847 switch (cinfo->col_fmt[col]) {
1848 case COL_NUMBER: /* frame number */
1849 g_snprintf(buf, COL_MAX_LEN, "%u", fd->num);
1853 set_cls_time(fd, buf);
1856 set_abs_time(fd, buf);
1858 case COL_ABS_DATE_TIME:
1859 set_abs_date_time(fd, buf);
1862 set_rel_time(fd, buf);
1864 case COL_DELTA_TIME:
1865 set_delta_time(fd, buf);
1867 case COL_DELTA_TIME_DIS:
1868 set_delta_time_dis(fd, buf);
1871 case COL_PACKET_LENGTH: /* fd->pkt_len */
1872 g_snprintf(buf, COL_MAX_LEN, "%u", fd->pkt_len);
1875 case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */
1876 g_snprintf(buf, COL_MAX_LEN, "%u", fd->cum_bytes);
1880 case COL_RES_SRC: /* network address */
1882 case COL_DEF_DL_SRC:
1883 case COL_RES_DL_SRC:
1884 case COL_UNRES_DL_SRC:
1885 case COL_DEF_NET_SRC:
1886 case COL_RES_NET_SRC:
1887 case COL_UNRES_NET_SRC:
1891 case COL_DEF_DL_DST:
1892 case COL_RES_DL_DST:
1893 case COL_UNRES_DL_DST:
1894 case COL_DEF_NET_DST:
1895 case COL_RES_NET_DST:
1896 case COL_UNRES_NET_DST:
1899 case COL_CIRCUIT_ID:
1902 case COL_HPUX_SUBSYS:
1903 case COL_HPUX_DEVID:
1905 case COL_8021Q_VLAN_ID:
1906 case COL_DSCP_VALUE:
1909 case COL_BSSGP_TLLI:
1913 ptr = fd->col_text[col];
1916 case COL_DEF_SRC_PORT:
1917 case COL_RES_SRC_PORT:
1918 case COL_UNRES_SRC_PORT:
1919 case COL_DEF_DST_PORT:
1920 case COL_RES_DST_PORT:
1921 case COL_UNRES_DST_PORT:
1923 if (GPOINTER_TO_UINT(fd->col_text[col]) <= 65536)
1924 g_snprintf(buf, COL_MAX_LEN, "%u", GPOINTER_TO_UINT(fd->col_text[col]));
1926 ptr = fd->col_text[col];
1933 g_snprintf(buf, COL_MAX_LEN, "0x%x", GPOINTER_TO_UINT(fd->col_text[col]));
1937 g_snprintf(buf, COL_MAX_LEN, "%u", GPOINTER_TO_UINT(fd->col_text[col]));
1940 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1941 g_assert_not_reached();