2 * Routines for column utilities.
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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 #ifdef NEED_SNPRINTF_H
33 # include "snprintf.h"
36 #include "column-utils.h"
37 #include "timestamp.h"
38 #include "sna-utils.h"
39 #include "atalk-utils.h"
41 #include "packet_info.h"
43 #include "addr_resolv.h"
44 #include "ipv6-utils.h"
45 #include "osi-utils.h"
46 #include "value_string.h"
48 /* Allocate all the data structures for constructing column data, given
49 the number of columns. */
51 col_setup(column_info *col_info, gint num_cols)
55 col_info->num_cols = num_cols;
56 col_info->col_fmt = (gint *) g_malloc(sizeof(gint) * num_cols);
57 col_info->fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * num_cols);
58 col_info->col_first = (int *) g_malloc(sizeof(int) * (NUM_COL_FMTS));
59 col_info->col_last = (int *) g_malloc(sizeof(int) * (NUM_COL_FMTS));
60 col_info->col_title = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
61 col_info->col_data = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
62 col_info->col_buf = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
63 col_info->col_fence = (int *) g_malloc(sizeof(int) * num_cols);
64 col_info->col_expr = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
65 col_info->col_expr_val = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
67 for (i = 0; i < NUM_COL_FMTS; i++) {
68 col_info->col_first[i] = -1;
69 col_info->col_last[i] = -1;
73 /* Initialize the data structures for constructing column data. */
75 col_init(column_info *cinfo)
79 for (i = 0; i < cinfo->num_cols; i++) {
80 cinfo->col_buf[i][0] = '\0';
81 cinfo->col_data[i] = cinfo->col_buf[i];
82 cinfo->col_fence[i] = 0;
83 cinfo->col_expr[i][0] = '\0';
84 cinfo->col_expr_val[i][0] = '\0';
86 cinfo->writable = TRUE;
90 col_get_writable(column_info *cinfo)
92 return (cinfo ? cinfo->writable : FALSE);
96 col_set_writable(column_info *cinfo, gboolean writable)
99 cinfo->writable = writable;
102 /* Checks to see if a particular packet information element is needed for
105 check_col(column_info *cinfo, gint el) {
107 if (cinfo && cinfo->writable) {
108 /* We are constructing columns, and they're writable */
109 if (cinfo->col_first[el] >= 0) {
110 /* There is at least one column in that format */
117 /* Sets the fence for a column to be at the end of the column. */
119 col_set_fence(column_info *cinfo, gint el)
123 if (cinfo && cinfo->writable) {
124 /* We are constructing columns, and they're writable */
125 if (cinfo->col_first[el] >= 0) {
126 /* There is at least one column in that format */
127 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
128 if (cinfo->fmt_matx[i][el]) {
129 cinfo->col_fence[i] = strlen(cinfo->col_data[i]);
136 /* Use this to clear out a column, especially if you're going to be
137 appending to it later; at least on some platforms, it's more
138 efficient than using "col_add_str()" with a null string, and
139 more efficient than "col_set_str()" with a null string if you
140 later append to it, as the later append will cause a string
143 col_clear(column_info *cinfo, gint el)
148 g_assert(cinfo->col_first[el] >= 0);
149 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
150 if (cinfo->fmt_matx[i][el]) {
152 * At this point, either
154 * 1) col_data[i] is equal to col_buf[i], in which case we
155 * don't have to worry about copying col_data[i] to
158 * 2) col_data[i] isn't equal to col_buf[i], in which case
159 * the only thing that's been done to the column is
160 * "col_set_str()" calls and possibly "col_set_fence()"
161 * calls, in which case the fence is either unset and
162 * at the beginning of the string or set and at the end
163 * of the string - if it's at the beginning, we're just
164 * going to clear the column, and if it's at the end,
165 * we don't do anything.
167 fence = cinfo->col_fence[i];
168 if (fence == 0 || cinfo->col_buf[i] == cinfo->col_data[i]) {
170 * The fence isn't at the end of the column, or the column wasn't
171 * last set with "col_set_str()", so clear the column out.
173 cinfo->col_buf[i][fence] = '\0';
174 cinfo->col_data[i] = cinfo->col_buf[i];
176 cinfo->col_expr[i][0] = '\0';
177 cinfo->col_expr_val[i][0] = '\0';
182 #define COL_CHECK_APPEND(cinfo, i, max_len) \
183 if (cinfo->col_data[i] != cinfo->col_buf[i]) { \
184 /* This was set with "col_set_str()"; copy the string they \
185 set it to into the buffer, so we can append to it. */ \
186 strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); \
187 cinfo->col_buf[i][max_len - 1] = '\0'; \
188 cinfo->col_data[i] = cinfo->col_buf[i]; \
191 /* Use this if "str" points to something that will stay around (and thus
192 needn't be copied). */
194 col_set_str(column_info *cinfo, gint el, gchar* str)
201 max_len = COL_MAX_INFO_LEN;
203 max_len = COL_MAX_LEN;
205 g_assert(cinfo->col_first[el] >= 0);
206 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
207 if (cinfo->fmt_matx[i][el]) {
208 fence = cinfo->col_fence[i];
211 * We will append the string after the fence.
212 * First arrange that we can append, if necessary.
214 COL_CHECK_APPEND(cinfo, i, max_len);
216 strncpy(&cinfo->col_buf[i][fence], str, max_len - fence);
217 cinfo->col_buf[i][max_len - 1] = 0;
220 * There's no fence, so we can just set the column to point
223 cinfo->col_data[i] = str;
229 /* Adds a vararg list to a packet info string. */
231 col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) {
237 g_assert(cinfo->col_first[el] >= 0);
239 max_len = COL_MAX_INFO_LEN;
241 max_len = COL_MAX_LEN;
243 va_start(ap, format);
244 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
245 if (cinfo->fmt_matx[i][el]) {
246 fence = cinfo->col_fence[i];
249 * We will append the string after the fence.
250 * First arrange that we can append, if necessary.
252 COL_CHECK_APPEND(cinfo, i, max_len);
255 * There's no fence, so we can just write to the string.
257 cinfo->col_data[i] = cinfo->col_buf[i];
259 vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
260 cinfo->col_buf[i][max_len - 1] = '\0';
267 col_do_append_sep_va_fstr(column_info *cinfo, gint el, const gchar *separator,
268 const gchar *format, va_list ap)
271 size_t len, max_len, sep_len;
273 g_assert(cinfo->col_first[el] >= 0);
275 max_len = COL_MAX_INFO_LEN;
277 max_len = COL_MAX_LEN;
279 if (separator == NULL)
282 sep_len = strlen(separator);
283 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
284 if (cinfo->fmt_matx[i][el]) {
286 * First arrange that we can append, if necessary.
288 COL_CHECK_APPEND(cinfo, i, max_len);
290 len = strlen(cinfo->col_buf[i]);
293 * If we have a separator, append it if the column isn't empty.
295 if (separator != NULL) {
297 strncat(cinfo->col_buf[i], separator, max_len - len);
301 vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
302 cinfo->col_buf[i][max_len-1] = 0;
307 /* Appends a vararg list to a packet info string. */
309 col_append_fstr(column_info *cinfo, gint el, const gchar *format, ...)
313 va_start(ap, format);
314 col_do_append_sep_va_fstr(cinfo, el, NULL, format, ap);
318 /* Appends a vararg list to a packet info string.
319 * Prefixes it with the given separator if the column is not empty. */
321 col_append_sep_fstr(column_info *cinfo, gint el, const gchar *separator,
322 const gchar *format, ...)
326 if (separator == NULL)
327 separator = ", "; /* default */
328 va_start(ap, format);
329 col_do_append_sep_va_fstr(cinfo, el, separator, format, ap);
335 /* Prepends a vararg list to a packet info string. */
336 #define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
337 (COL_MAX_INFO_LEN) : (COL_MAX_LEN))
339 col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
343 char orig_buf[COL_BUF_MAX_LEN];
347 g_assert(cinfo->col_first[el] >= 0);
349 max_len = COL_MAX_INFO_LEN;
351 max_len = COL_MAX_LEN;
353 va_start(ap, format);
354 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
355 if (cinfo->fmt_matx[i][el]) {
356 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
357 /* This was set with "col_set_str()"; which is effectively const */
358 orig = cinfo->col_data[i];
361 strncpy(orig, cinfo->col_buf[i], max_len);
362 orig[max_len - 1] = '\0';
364 vsnprintf(cinfo->col_buf[i], max_len, format, ap);
365 cinfo->col_buf[i][max_len - 1] = '\0';
368 * Move the fence, unless it's at the beginning of the string.
370 if (cinfo->col_fence[i] > 0)
371 cinfo->col_fence[i] += strlen(cinfo->col_buf[i]);
373 strncat(cinfo->col_buf[i], orig, max_len);
374 cinfo->col_buf[i][max_len - 1] = '\0';
375 cinfo->col_data[i] = cinfo->col_buf[i];
381 /* Use this if "str" points to something that won't stay around (and
382 must thus be copied). */
384 col_add_str(column_info *cinfo, gint el, const gchar* str)
390 g_assert(cinfo->col_first[el] >= 0);
392 max_len = COL_MAX_INFO_LEN;
394 max_len = COL_MAX_LEN;
396 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
397 if (cinfo->fmt_matx[i][el]) {
398 fence = cinfo->col_fence[i];
401 * We will append the string after the fence.
402 * First arrange that we can append, if necessary.
404 COL_CHECK_APPEND(cinfo, i, max_len);
407 * There's no fence, so we can just write to the string.
409 cinfo->col_data[i] = cinfo->col_buf[i];
411 strncpy(&cinfo->col_buf[i][fence], str, max_len - fence);
412 cinfo->col_buf[i][max_len - 1] = 0;
418 col_do_append_str(column_info *cinfo, gint el, const gchar* separator,
422 size_t len, max_len, sep_len;
424 g_assert(cinfo->col_first[el] >= 0);
426 max_len = COL_MAX_INFO_LEN;
428 max_len = COL_MAX_LEN;
430 if (separator == NULL)
433 sep_len = strlen(separator);
435 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
436 if (cinfo->fmt_matx[i][el]) {
438 * First arrange that we can append, if necessary.
440 COL_CHECK_APPEND(cinfo, i, max_len);
442 len = strlen(cinfo->col_buf[i]);
445 * If we have a separator, append it if the column isn't empty.
447 if (separator != NULL) {
449 strncat(cinfo->col_buf[i], separator, max_len - len);
453 strncat(cinfo->col_buf[i], str, max_len - len);
454 cinfo->col_buf[i][max_len - 1] = 0;
460 col_append_str(column_info *cinfo, gint el, const gchar* str)
462 col_do_append_str(cinfo, el, NULL, str);
466 col_append_sep_str(column_info *cinfo, gint el, const gchar* separator,
469 if (separator == NULL)
470 separator = ", "; /* default */
471 col_do_append_str(cinfo, el, separator, str);
475 col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
481 tmp = localtime(&then);
483 snprintf(cinfo->col_buf[col], COL_MAX_LEN,
484 "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
491 (long)fd->abs_usecs);
493 cinfo->col_buf[col][0] = '\0';
495 cinfo->col_data[col] = cinfo->col_buf[col];
496 strcpy(cinfo->col_expr[col],"frame.time");
497 strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
501 col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
503 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
504 fd->rel_secs, fd->rel_usecs, USECS);
505 cinfo->col_data[col] = cinfo->col_buf[col];
506 strcpy(cinfo->col_expr[col],"frame.time_relative");
507 strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
511 col_set_delta_time(frame_data *fd, column_info *cinfo, int col)
513 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
514 fd->del_secs, fd->del_usecs, USECS);
515 cinfo->col_data[col] = cinfo->col_buf[col];
516 strcpy(cinfo->col_expr[col],"frame.time_delta");
517 strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
520 /* To do: Add check_col checks to the col_add* routines */
523 col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
529 tmp = localtime(&then);
531 snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%06ld",
535 (long)fd->abs_usecs);
537 cinfo->col_buf[col][0] = '\0';
539 cinfo->col_data[col] = cinfo->col_buf[col];
540 strcpy(cinfo->col_expr[col],"frame.time");
541 strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
544 /* Add "command-line-specified" time.
545 XXX - this is called from "file.c" when the user changes the time
546 format they want for "command-line-specified" time; it's a bit ugly
547 that we have to export it, but if we go to a CList-like widget that
548 invokes callbacks to get the text for the columns rather than
549 requiring us to stuff the text into the widget from outside, we
550 might be able to clean this up. */
552 col_set_cls_time(frame_data *fd, column_info *cinfo, int col)
554 switch (get_timestamp_setting()) {
556 col_set_abs_time(fd, cinfo, col);
559 case TS_ABSOLUTE_WITH_DATE:
560 col_set_abs_date_time(fd, cinfo, col);
564 col_set_rel_time(fd, cinfo, col);
568 col_set_delta_time(fd, cinfo, col);
574 col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res,
578 struct e_in6_addr ipv6_addr;
580 pinfo->cinfo->col_expr[col][0] = '\0';
581 pinfo->cinfo->col_expr_val[col][0] = '\0';
582 if (addr->type == AT_NONE)
583 return; /* no address, nothing to do */
585 switch (addr->type) {
588 strncpy(pinfo->cinfo->col_buf[col], get_ether_name(addr->data), COL_MAX_LEN);
589 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
593 memcpy(&ipv4_addr, addr->data, sizeof ipv4_addr);
594 strncpy(pinfo->cinfo->col_buf[col], get_hostname(ipv4_addr), COL_MAX_LEN);
595 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
599 memcpy(&ipv6_addr.s6_addr, addr->data, sizeof ipv6_addr.s6_addr);
600 strncpy(pinfo->cinfo->col_buf[col], get_hostname6(&ipv6_addr), COL_MAX_LEN);
601 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
605 /* XXX - should be done in "address_to_str_buf()", but that routine
606 doesn't know COL_MAX_LEN; it should be changed to take the
607 maximum length as an argument. */
608 strncpy(pinfo->cinfo->col_buf[col], addr->data, COL_MAX_LEN);
609 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
613 address_to_str_buf(addr, pinfo->cinfo->col_buf[col]);
617 switch (addr->type) {
620 /* XXX - should be done in "address_to_str_buf()", but that routine
621 doesn't know COL_MAX_LEN; it should be changed to take the
622 maximum length as an argument. */
623 strncpy(pinfo->cinfo->col_buf[col], addr->data, COL_MAX_LEN);
624 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
628 address_to_str_buf(addr, pinfo->cinfo->col_buf[col]);
632 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
634 switch (addr->type) {
638 strcpy(pinfo->cinfo->col_expr[col], "eth.src");
640 strcpy(pinfo->cinfo->col_expr[col], "eth.dst");
641 strncpy(pinfo->cinfo->col_expr_val[col], ether_to_str(addr->data), COL_MAX_LEN);
642 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
647 strcpy(pinfo->cinfo->col_expr[col], "ip.src");
649 strcpy(pinfo->cinfo->col_expr[col], "ip.dst");
650 strncpy(pinfo->cinfo->col_expr_val[col], ip_to_str(addr->data), COL_MAX_LEN);
651 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
656 strcpy(pinfo->cinfo->col_expr[col], "ipv6.src");
658 strcpy(pinfo->cinfo->col_expr[col], "ipv6.dst");
659 strncpy(pinfo->cinfo->col_expr_val[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN);
660 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
665 strcpy(pinfo->cinfo->col_expr[col], "ddp.src");
667 strcpy(pinfo->cinfo->col_expr[col], "ddp.dst");
668 strcpy(pinfo->cinfo->col_expr_val[col], pinfo->cinfo->col_buf[col]);
673 strcpy(pinfo->cinfo->col_expr[col], "arcnet.src");
675 strcpy(pinfo->cinfo->col_expr[col], "arcnet.dst");
676 strcpy(pinfo->cinfo->col_expr_val[col], pinfo->cinfo->col_buf[col]);
685 col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src)
690 port = pinfo->srcport;
692 port = pinfo->destport;
693 pinfo->cinfo->col_expr[col][0] = '\0';
694 pinfo->cinfo->col_expr_val[col][0] = '\0';
695 switch (pinfo->ptype) {
699 strncpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
701 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
706 strncpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
708 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
710 strcpy(pinfo->cinfo->col_expr[col], "tcp.srcport");
712 strcpy(pinfo->cinfo->col_expr[col], "tcp.dstport");
713 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
714 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
719 strncpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
721 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
723 strcpy(pinfo->cinfo->col_expr[col], "udp.srcport");
725 strcpy(pinfo->cinfo->col_expr[col], "udp.dstport");
726 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
727 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
732 strcpy(pinfo->cinfo->col_expr[col], "ddp.src_socket");
734 strcpy(pinfo->cinfo->col_expr[col], "ddp.dst_socket");
735 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
736 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
737 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
741 /* XXX - resolve IPX socket numbers */
742 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
744 strcpy(pinfo->cinfo->col_expr[col], "ipx.src.socket");
746 strcpy(pinfo->cinfo->col_expr[col], "ipx.dst.socket");
747 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
748 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
754 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
755 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
759 * XXX - this should be in some common code in the epan directory, shared
760 * by this code and packet-isdn.c.
762 static const value_string channel_vals[] = {
798 col_set_circuit_id(packet_info *pinfo, int col)
800 pinfo->cinfo->col_expr[col][0] = '\0';
801 pinfo->cinfo->col_expr_val[col][0] = '\0';
802 switch (pinfo->ctype) {
805 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
806 strcpy(pinfo->cinfo->col_expr[col], "fr.dlci");
807 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
808 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
812 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%s",
813 val_to_str(pinfo->circuit_id, channel_vals, "Unknown (%u)"));
814 strcpy(pinfo->cinfo->col_expr[col], "isdn.channel");
815 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
816 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
820 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
824 snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
825 strcpy(pinfo->cinfo->col_expr[col], "isup.cic");
826 snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
827 pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
833 pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
834 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
838 fill_in_columns(packet_info *pinfo)
842 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
843 switch (pinfo->cinfo->col_fmt[i]) {
846 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->num);
847 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
848 strcpy(pinfo->cinfo->col_expr[i], "frame.number");
849 strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]);
853 if(pinfo->fd->flags.ref_time){
854 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "*REF*");
855 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
857 col_set_cls_time(pinfo->fd, pinfo->cinfo, i);
862 if(pinfo->fd->flags.ref_time){
863 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "*REF*");
864 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
866 col_set_abs_time(pinfo->fd, pinfo->cinfo, i);
870 case COL_ABS_DATE_TIME:
871 if(pinfo->fd->flags.ref_time){
872 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "*REF*");
873 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
875 col_set_abs_date_time(pinfo->fd, pinfo->cinfo, i);
880 if(pinfo->fd->flags.ref_time){
881 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "*REF*");
882 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
884 col_set_rel_time(pinfo->fd, pinfo->cinfo, i);
889 if(pinfo->fd->flags.ref_time){
890 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "*REF*");
891 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
893 col_set_delta_time(pinfo->fd, pinfo->cinfo, i);
898 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
899 col_set_addr(pinfo, i, &pinfo->src, TRUE, TRUE);
903 col_set_addr(pinfo, i, &pinfo->src, FALSE, TRUE);
908 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, TRUE);
911 case COL_UNRES_DL_SRC:
912 col_set_addr(pinfo, i, &pinfo->dl_src, FALSE, TRUE);
915 case COL_DEF_NET_SRC:
916 case COL_RES_NET_SRC:
917 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, TRUE);
920 case COL_UNRES_NET_SRC:
921 col_set_addr(pinfo, i, &pinfo->net_src, FALSE, TRUE);
925 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
926 col_set_addr(pinfo, i, &pinfo->dst, TRUE, FALSE);
930 col_set_addr(pinfo, i, &pinfo->dst, FALSE, FALSE);
935 col_set_addr(pinfo, i, &pinfo->dl_dst, TRUE, FALSE);
938 case COL_UNRES_DL_DST:
939 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, FALSE);
942 case COL_DEF_NET_DST:
943 case COL_RES_NET_DST:
944 col_set_addr(pinfo, i, &pinfo->net_dst, TRUE, FALSE);
947 case COL_UNRES_NET_DST:
948 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, FALSE);
951 case COL_DEF_SRC_PORT:
952 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
953 col_set_port(pinfo, i, TRUE, TRUE);
956 case COL_UNRES_SRC_PORT:
957 col_set_port(pinfo, i, FALSE, TRUE);
960 case COL_DEF_DST_PORT:
961 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
962 col_set_port(pinfo, i, TRUE, FALSE);
965 case COL_UNRES_DST_PORT:
966 col_set_port(pinfo, i, FALSE, FALSE);
969 case COL_PROTOCOL: /* currently done by dissectors */
970 case COL_INFO: /* currently done by dissectors */
973 case COL_PACKET_LENGTH:
974 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->pkt_len);
975 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
976 strcpy(pinfo->cinfo->col_expr[i], "frame.pkt_len");
977 strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]);
980 case COL_CUMULATIVE_BYTES:
981 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->cum_bytes);
982 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
986 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->oxid);
987 pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
988 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
992 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->rxid);
993 pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
994 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
997 case COL_IF_DIR: /* currently done by dissectors */
1000 case COL_CIRCUIT_ID:
1001 col_set_circuit_id(pinfo, i);
1005 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->src_idx);
1006 pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1007 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1011 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->dst_idx);
1012 pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1013 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1017 snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->vsan);
1018 pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1019 pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1022 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1023 g_assert_not_reached();