HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / column-utils.c
blobf5cbbc39b39ec4bb6740523289db6bb74c3d49f0
1 /* column-utils.c
2 * Routines for column utilities.
4 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "config.h"
27 #include <string.h>
28 #include <time.h>
30 #include "column-utils.h"
31 #include "timestamp.h"
32 #include "sna-utils.h"
33 #include "atalk-utils.h"
34 #include "to_str.h"
35 #include "packet_info.h"
36 #include "wsutil/pint.h"
37 #include "addr_resolv.h"
38 #include "ipv6-utils.h"
39 #include "osi-utils.h"
40 #include "value_string.h"
41 #include "column-info.h"
42 #include "proto.h"
44 #include <epan/strutil.h>
45 #include <epan/emem.h>
46 #include <epan/epan.h>
48 /* Allocate all the data structures for constructing column data, given
49 the number of columns. */
50 void
51 col_setup(column_info *cinfo, const gint num_cols)
53 int i;
55 cinfo->num_cols = num_cols;
56 cinfo->col_fmt = g_new(gint, num_cols);
57 cinfo->fmt_matx = g_new(gboolean*, num_cols);
58 cinfo->col_first = g_new(int, NUM_COL_FMTS);
59 cinfo->col_last = g_new(int, NUM_COL_FMTS);
60 cinfo->col_title = g_new(gchar*, num_cols);
61 cinfo->col_custom_field = g_new(gchar*, num_cols);
62 cinfo->col_custom_occurrence = g_new(gint, num_cols);
63 cinfo->col_custom_field_id = g_new(int, num_cols);
64 cinfo->col_custom_dfilter = g_new(dfilter_t*, num_cols);
65 cinfo->col_data = g_new(const 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 = g_new(const 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 /* Cleanup all the data structures for constructing column data; undoes
78 the allocations that col_setup() does. */
79 void
80 col_cleanup(column_info *cinfo)
82 g_free(cinfo->col_fmt);
83 g_free(cinfo->fmt_matx);
84 g_free(cinfo->col_first);
85 g_free(cinfo->col_last);
86 g_free(cinfo->col_title);
87 g_free(cinfo->col_custom_field);
88 g_free(cinfo->col_custom_occurrence);
89 g_free(cinfo->col_custom_field_id);
90 g_free(cinfo->col_custom_dfilter);
92 * XXX - MSVC doesn't correctly handle the "const" qualifier; it thinks
93 * "const XXX **" means "pointer to const pointer to XXX", i.e. that
94 * it's a pointer to something that's "const"ant, not "pointer to
95 * pointer to const XXX", i.e. that it's a pointer to a pointer to
96 * something that's "const"ant. Cast its bogus complaints away.
98 g_free((gchar **)cinfo->col_data);
99 g_free(cinfo->col_buf);
100 g_free(cinfo->col_fence);
101 /* XXX - see above */
102 g_free((gchar **)cinfo->col_expr.col_expr);
103 g_free(cinfo->col_expr.col_expr_val);
106 /* Initialize the data structures for constructing column data. */
107 void
108 col_init(column_info *cinfo, const struct epan_session *epan)
110 int i;
112 if (!cinfo)
113 return;
115 for (i = 0; i < cinfo->num_cols; i++) {
116 cinfo->col_buf[i][0] = '\0';
117 cinfo->col_data[i] = cinfo->col_buf[i];
118 cinfo->col_fence[i] = 0;
119 cinfo->col_expr.col_expr[i] = "";
120 cinfo->col_expr.col_expr_val[i][0] = '\0';
122 cinfo->writable = TRUE;
123 cinfo->epan = epan;
126 #define COL_GET_WRITABLE(cinfo) (cinfo ? cinfo->writable : FALSE)
128 gboolean
129 col_get_writable(column_info *cinfo)
131 return COL_GET_WRITABLE(cinfo);
134 void
135 col_set_writable(column_info *cinfo, const gboolean writable)
137 if (cinfo)
138 cinfo->writable = writable;
141 /* Checks to see if a particular packet information element is needed for the packet list */
142 #define CHECK_COL(cinfo, el) \
143 /* We are constructing columns, and they're writable */ \
144 (COL_GET_WRITABLE(cinfo) && \
145 /* There is at least one column in that format */ \
146 ((cinfo)->col_first[el] >= 0))
148 /* Sets the fence for a column to be at the end of the column. */
149 void
150 col_set_fence(column_info *cinfo, const gint el)
152 int i;
154 if (!CHECK_COL(cinfo, el))
155 return;
157 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
158 if (cinfo->fmt_matx[i][el]) {
159 cinfo->col_fence[i] = (int)strlen(cinfo->col_data[i]);
164 /* Gets the text of a column */
165 const gchar *
166 col_get_text(column_info *cinfo, const gint el)
168 int i;
169 const gchar* text = NULL;
171 if (!(cinfo && (cinfo)->col_first[el] >= 0)) {
172 return NULL;
175 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
176 if (cinfo->fmt_matx[i][el]) {
177 text = (cinfo->col_data[i]);
180 return text;
184 /* Use this to clear out a column, especially if you're going to be
185 appending to it later; at least on some platforms, it's more
186 efficient than using "col_add_str()" with a null string, and
187 more efficient than "col_set_str()" with a null string if you
188 later append to it, as the later append will cause a string
189 copy to be done. */
190 void
191 col_clear(column_info *cinfo, const gint el)
193 int i;
194 int fence;
196 if (!CHECK_COL(cinfo, el))
197 return;
199 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
200 if (cinfo->fmt_matx[i][el]) {
202 * At this point, either
204 * 1) col_data[i] is equal to col_buf[i], in which case we
205 * don't have to worry about copying col_data[i] to
206 * col_buf[i];
208 * 2) col_data[i] isn't equal to col_buf[i], in which case
209 * the only thing that's been done to the column is
210 * "col_set_str()" calls and possibly "col_set_fence()"
211 * calls, in which case the fence is either unset and
212 * at the beginning of the string or set and at the end
213 * of the string - if it's at the beginning, we're just
214 * going to clear the column, and if it's at the end,
215 * we don't do anything.
217 fence = cinfo->col_fence[i];
218 if (cinfo->col_buf[i] == cinfo->col_data[i] || fence == 0) {
220 * The fence isn't at the end of the column, or the column wasn't
221 * last set with "col_set_str()", so clear the column out.
223 cinfo->col_buf[i][fence] = '\0';
224 cinfo->col_data[i] = cinfo->col_buf[i];
226 cinfo->col_expr.col_expr[i] = "";
227 cinfo->col_expr.col_expr_val[i][0] = '\0';
232 #define COL_CHECK_APPEND(cinfo, i, max_len) \
233 if (cinfo->col_data[i] != cinfo->col_buf[i]) { \
234 /* This was set with "col_set_str()"; copy the string they \
235 set it to into the buffer, so we can append to it. */ \
236 g_strlcpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); \
237 cinfo->col_data[i] = cinfo->col_buf[i]; \
240 #define COL_CHECK_REF_TIME(fd, buf) \
241 if (fd->flags.ref_time) { \
242 g_strlcpy(buf, "*REF*", COL_MAX_LEN ); \
243 return; \
246 /* The same as CHECK_COL(), but without the check to see if the column is writable. */
247 #define HAVE_CUSTOM_COLS(cinfo) ((cinfo) && (cinfo)->col_first[COL_CUSTOM] >= 0)
249 gboolean
250 have_custom_cols(column_info *cinfo)
252 return HAVE_CUSTOM_COLS(cinfo);
255 /* search in edt tree custom fields */
256 void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo)
258 int i;
260 if (!HAVE_CUSTOM_COLS(cinfo))
261 return;
263 for (i = cinfo->col_first[COL_CUSTOM];
264 i <= cinfo->col_last[COL_CUSTOM]; i++) {
265 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
266 cinfo->col_custom_field[i] &&
267 cinfo->col_custom_field_id[i] != -1) {
268 cinfo->col_data[i] = cinfo->col_buf[i];
269 cinfo->col_expr.col_expr[i] = epan_custom_set(edt, cinfo->col_custom_field_id[i],
270 cinfo->col_custom_occurrence[i],
271 cinfo->col_buf[i],
272 cinfo->col_expr.col_expr_val[i],
273 COL_MAX_LEN);
278 void
279 col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
281 int i;
283 if (!HAVE_CUSTOM_COLS(cinfo))
284 return;
286 for (i = cinfo->col_first[COL_CUSTOM];
287 i <= cinfo->col_last[COL_CUSTOM]; i++) {
289 cinfo->col_custom_field_id[i] = -1;
290 if (cinfo->fmt_matx[i][COL_CUSTOM] &&
291 cinfo->col_custom_dfilter[i]) {
292 epan_dissect_prime_dfilter(edt, cinfo->col_custom_dfilter[i]);
293 if (cinfo->col_custom_field) {
294 header_field_info* hfinfo = proto_registrar_get_byname(cinfo->col_custom_field[i]);
295 cinfo->col_custom_field_id[i] = hfinfo ? hfinfo->id : -1;
301 /* Appends a vararg list to a packet info string.
302 * This function's code is duplicated in col_append_sep_fstr() below because
303 * the for() loop below requires us to call va_start/va_end so intermediate
304 * functions are a problem.
306 void
307 col_append_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
309 int i;
310 int len, max_len;
311 va_list ap;
313 if (!CHECK_COL(cinfo, el))
314 return;
316 if (el == COL_INFO)
317 max_len = COL_MAX_INFO_LEN;
318 else
319 max_len = COL_MAX_LEN;
321 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
322 if (cinfo->fmt_matx[i][el]) {
324 * First arrange that we can append, if necessary.
326 COL_CHECK_APPEND(cinfo, i, max_len);
328 len = (int) strlen(cinfo->col_buf[i]);
330 va_start(ap, format);
331 g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
332 va_end(ap);
338 /* Appends a vararg list to a packet info string.
339 * Prefixes it with the given separator if the column is not empty.
340 * Code is duplicated from col_append_fstr above().
342 void
343 col_append_sep_fstr(column_info *cinfo, const gint el, const gchar *separator,
344 const gchar *format, ...)
346 int i;
347 int len, max_len, sep_len;
348 va_list ap;
350 if (!CHECK_COL(cinfo, el))
351 return;
353 if (separator == NULL)
354 separator = ", "; /* default */
356 sep_len = (int) strlen(separator);
358 if (el == COL_INFO)
359 max_len = COL_MAX_INFO_LEN;
360 else
361 max_len = COL_MAX_LEN;
363 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
364 if (cinfo->fmt_matx[i][el]) {
366 * First arrange that we can append, if necessary.
368 COL_CHECK_APPEND(cinfo, i, max_len);
370 len = (int) strlen(cinfo->col_buf[i]);
373 * If we have a separator, append it if the column isn't empty.
375 if (sep_len != 0) {
376 if (len != 0) {
377 g_strlcat(cinfo->col_buf[i], separator, max_len);
378 len += sep_len;
381 va_start(ap, format);
382 g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
383 va_end(ap);
388 /* Prepends a vararg list to a packet info string. */
389 #define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
390 (COL_MAX_INFO_LEN) : (COL_MAX_LEN))
391 void
392 col_prepend_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
394 va_list ap;
395 int i;
396 char orig_buf[COL_BUF_MAX_LEN];
397 const char *orig;
398 int max_len;
400 if (!CHECK_COL(cinfo, el))
401 return;
403 if (el == COL_INFO)
404 max_len = COL_MAX_INFO_LEN;
405 else
406 max_len = COL_MAX_LEN;
408 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
409 if (cinfo->fmt_matx[i][el]) {
410 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
411 /* This was set with "col_set_str()"; which is effectively const */
412 orig = cinfo->col_data[i];
413 } else {
414 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
415 orig = orig_buf;
417 va_start(ap, format);
418 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
419 va_end(ap);
422 * Move the fence, unless it's at the beginning of the string.
424 if (cinfo->col_fence[i] > 0)
425 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
427 g_strlcat(cinfo->col_buf[i], orig, max_len);
428 cinfo->col_data[i] = cinfo->col_buf[i];
432 void
433 col_prepend_fence_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
435 va_list ap;
436 int i;
437 char orig_buf[COL_BUF_MAX_LEN];
438 const char *orig;
439 int max_len;
441 if (!CHECK_COL(cinfo, el))
442 return;
444 if (el == COL_INFO)
445 max_len = COL_MAX_INFO_LEN;
446 else
447 max_len = COL_MAX_LEN;
449 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
450 if (cinfo->fmt_matx[i][el]) {
451 if (cinfo->col_data[i] != cinfo->col_buf[i]) {
452 /* This was set with "col_set_str()"; which is effectively const */
453 orig = cinfo->col_data[i];
454 } else {
455 g_strlcpy(orig_buf, cinfo->col_buf[i], max_len);
456 orig = orig_buf;
458 va_start(ap, format);
459 g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
460 va_end(ap);
463 * Move the fence if it exists, else create a new fence at the
464 * end of the prepended data.
466 if (cinfo->col_fence[i] > 0) {
467 cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]);
468 } else {
469 cinfo->col_fence[i] = (int) strlen(cinfo->col_buf[i]);
471 g_strlcat(cinfo->col_buf[i], orig, max_len);
472 cinfo->col_data[i] = cinfo->col_buf[i];
477 /* Use this if "str" points to something that won't stay around (and
478 must thus be copied). */
479 void
480 col_add_str(column_info *cinfo, const gint el, const gchar* str)
482 int i;
483 int fence;
484 size_t max_len;
486 if (!CHECK_COL(cinfo, el))
487 return;
489 if (el == COL_INFO)
490 max_len = COL_MAX_INFO_LEN;
491 else
492 max_len = COL_MAX_LEN;
494 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
495 if (cinfo->fmt_matx[i][el]) {
496 fence = cinfo->col_fence[i];
497 if (fence != 0) {
499 * We will append the string after the fence.
500 * First arrange that we can append, if necessary.
502 COL_CHECK_APPEND(cinfo, i, max_len);
503 } else {
505 * There's no fence, so we can just write to the string.
507 cinfo->col_data[i] = cinfo->col_buf[i];
509 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
514 /* Use this if "str" points to something that will stay around (and thus
515 needn't be copied). */
516 void
517 col_set_str(column_info *cinfo, const gint el, const gchar* str)
519 int i;
520 int fence;
521 size_t max_len;
523 DISSECTOR_ASSERT(str);
525 /* The caller is expected to pass in something that 'will stay around' and
526 * something from the ephemeral pool certainly doesn't fit the bill. */
527 DISSECTOR_ASSERT(!ep_verify_pointer(str));
529 if (!CHECK_COL(cinfo, el))
530 return;
532 if (el == COL_INFO)
533 max_len = COL_MAX_INFO_LEN;
534 else
535 max_len = COL_MAX_LEN;
537 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
538 if (cinfo->fmt_matx[i][el]) {
539 fence = cinfo->col_fence[i];
540 if (fence != 0) {
542 * We will append the string after the fence.
543 * First arrange that we can append, if necessary.
545 COL_CHECK_APPEND(cinfo, i, max_len);
547 g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence);
548 } else {
550 * There's no fence, so we can just set the column to point
551 * to the string.
553 cinfo->col_data[i] = str;
559 /* Adds a vararg list to a packet info string. */
560 void
561 col_add_fstr(column_info *cinfo, const gint el, const gchar *format, ...) {
562 va_list ap;
563 int i;
564 int fence;
565 int max_len;
567 if (!CHECK_COL(cinfo, el))
568 return;
570 if (el == COL_INFO)
571 max_len = COL_MAX_INFO_LEN;
572 else
573 max_len = COL_MAX_LEN;
575 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
576 if (cinfo->fmt_matx[i][el]) {
577 fence = cinfo->col_fence[i];
578 if (fence != 0) {
580 * We will append the string after the fence.
581 * First arrange that we can append, if necessary.
583 COL_CHECK_APPEND(cinfo, i, max_len);
584 } else {
586 * There's no fence, so we can just write to the string.
588 cinfo->col_data[i] = cinfo->col_buf[i];
590 va_start(ap, format);
591 g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
592 va_end(ap);
597 static void
598 col_do_append_str(column_info *cinfo, const gint el, const gchar* separator,
599 const gchar* str)
601 int i;
602 size_t len, max_len;
604 if (el == COL_INFO)
605 max_len = COL_MAX_INFO_LEN;
606 else
607 max_len = COL_MAX_LEN;
609 for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
610 if (cinfo->fmt_matx[i][el]) {
612 * First arrange that we can append, if necessary.
614 COL_CHECK_APPEND(cinfo, i, max_len);
616 len = cinfo->col_buf[i][0];
619 * If we have a separator, append it if the column isn't empty.
621 if (separator != NULL) {
622 if (len != 0) {
623 g_strlcat(cinfo->col_buf[i], separator, max_len);
626 g_strlcat(cinfo->col_buf[i], str, max_len);
631 void
632 col_append_str(column_info *cinfo, const gint el, const gchar* str)
634 if (!CHECK_COL(cinfo, el))
635 return;
637 col_do_append_str(cinfo, el, NULL, str);
640 void
641 col_append_sep_str(column_info *cinfo, const gint el, const gchar* separator,
642 const gchar* str)
644 if (!CHECK_COL(cinfo, el))
645 return;
647 if (separator == NULL)
648 separator = ", "; /* default */
650 col_do_append_str(cinfo, el, separator, str);
653 /* --------------------------------- */
654 gboolean
655 col_has_time_fmt(column_info *cinfo, const gint col)
657 return ((cinfo->fmt_matx[col][COL_CLS_TIME]) ||
658 (cinfo->fmt_matx[col][COL_ABS_TIME]) ||
659 (cinfo->fmt_matx[col][COL_ABS_YMD_TIME]) ||
660 (cinfo->fmt_matx[col][COL_ABS_YDOY_TIME]) ||
661 (cinfo->fmt_matx[col][COL_UTC_TIME]) ||
662 (cinfo->fmt_matx[col][COL_UTC_YMD_TIME]) ||
663 (cinfo->fmt_matx[col][COL_UTC_YDOY_TIME]) ||
664 (cinfo->fmt_matx[col][COL_REL_TIME]) ||
665 (cinfo->fmt_matx[col][COL_DELTA_TIME]) ||
666 (cinfo->fmt_matx[col][COL_DELTA_TIME_DIS]));
669 static void
670 set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local)
672 struct tm *tmp;
673 time_t then;
675 if (fd->flags.has_ts) {
676 then = fd->abs_ts.secs;
677 if (local)
678 tmp = localtime(&then);
679 else
680 tmp = gmtime(&then);
681 } else
682 tmp = NULL;
683 if (tmp != NULL) {
684 switch (timestamp_get_precision()) {
685 case TS_PREC_FIXED_SEC:
686 case TS_PREC_AUTO_SEC:
687 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d",
688 tmp->tm_year + 1900,
689 tmp->tm_mon + 1,
690 tmp->tm_mday,
691 tmp->tm_hour,
692 tmp->tm_min,
693 tmp->tm_sec);
694 break;
695 case TS_PREC_FIXED_DSEC:
696 case TS_PREC_AUTO_DSEC:
697 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%01d",
698 tmp->tm_year + 1900,
699 tmp->tm_mon + 1,
700 tmp->tm_mday,
701 tmp->tm_hour,
702 tmp->tm_min,
703 tmp->tm_sec,
704 fd->abs_ts.nsecs / 100000000);
705 break;
706 case TS_PREC_FIXED_CSEC:
707 case TS_PREC_AUTO_CSEC:
708 g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%02d",
709 tmp->tm_year + 1900,
710 tmp->tm_mon + 1,
711 tmp->tm_mday,
712 tmp->tm_hour,
713 tmp->tm_min,
714 tmp->tm_sec,
715 fd->abs_ts.nsecs / 10000000);
716 break;
717 case TS_PREC_FIXED_MSEC:
718 case TS_PREC_AUTO_MSEC:
719 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%03d",
720 tmp->tm_year + 1900,
721 tmp->tm_mon + 1,
722 tmp->tm_mday,
723 tmp->tm_hour,
724 tmp->tm_min,
725 tmp->tm_sec,
726 fd->abs_ts.nsecs / 1000000);
727 break;
728 case TS_PREC_FIXED_USEC:
729 case TS_PREC_AUTO_USEC:
730 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06d",
731 tmp->tm_year + 1900,
732 tmp->tm_mon + 1,
733 tmp->tm_mday,
734 tmp->tm_hour,
735 tmp->tm_min,
736 tmp->tm_sec,
737 fd->abs_ts.nsecs / 1000);
738 break;
739 case TS_PREC_FIXED_NSEC:
740 case TS_PREC_AUTO_NSEC:
741 g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%09d",
742 tmp->tm_year + 1900,
743 tmp->tm_mon + 1,
744 tmp->tm_mday,
745 tmp->tm_hour,
746 tmp->tm_min,
747 tmp->tm_sec,
748 fd->abs_ts.nsecs);
749 break;
750 default:
751 g_assert_not_reached();
753 } else {
754 buf[0] = '\0';
758 static void
759 col_set_abs_ymd_time(const frame_data *fd, column_info *cinfo, const int col)
761 set_abs_ymd_time(fd, cinfo->col_buf[col], TRUE);
762 cinfo->col_expr.col_expr[col] = "frame.time";
763 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
765 cinfo->col_data[col] = cinfo->col_buf[col];
768 static void
769 col_set_utc_ymd_time(const frame_data *fd, column_info *cinfo, const int col)
771 set_abs_ymd_time(fd, cinfo->col_buf[col], FALSE);
772 cinfo->col_expr.col_expr[col] = "frame.time";
773 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
775 cinfo->col_data[col] = cinfo->col_buf[col];
778 static void
779 set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local)
781 struct tm *tmp;
782 time_t then;
784 if (fd->flags.has_ts) {
785 then = fd->abs_ts.secs;
786 if (local)
787 tmp = localtime(&then);
788 else
789 tmp = gmtime(&then);
790 } else
791 tmp = NULL;
792 if (tmp != NULL) {
793 switch (timestamp_get_precision()) {
794 case TS_PREC_FIXED_SEC:
795 case TS_PREC_AUTO_SEC:
796 g_snprintf(buf, COL_MAX_LEN,"%04d/%03d %02d:%02d:%02d",
797 tmp->tm_year + 1900,
798 tmp->tm_yday + 1,
799 tmp->tm_hour,
800 tmp->tm_min,
801 tmp->tm_sec);
802 break;
803 case TS_PREC_FIXED_DSEC:
804 case TS_PREC_AUTO_DSEC:
805 g_snprintf(buf, COL_MAX_LEN,"%04d/%03d %02d:%02d:%02d.%01d",
806 tmp->tm_year + 1900,
807 tmp->tm_yday + 1,
808 tmp->tm_hour,
809 tmp->tm_min,
810 tmp->tm_sec,
811 fd->abs_ts.nsecs / 100000000);
812 break;
813 case TS_PREC_FIXED_CSEC:
814 case TS_PREC_AUTO_CSEC:
815 g_snprintf(buf, COL_MAX_LEN,"%04d/%03d %02d:%02d:%02d.%02d",
816 tmp->tm_year + 1900,
817 tmp->tm_yday + 1,
818 tmp->tm_hour,
819 tmp->tm_min,
820 tmp->tm_sec,
821 fd->abs_ts.nsecs / 10000000);
822 break;
823 case TS_PREC_FIXED_MSEC:
824 case TS_PREC_AUTO_MSEC:
825 g_snprintf(buf, COL_MAX_LEN, "%04d/%03d %02d:%02d:%02d.%03d",
826 tmp->tm_year + 1900,
827 tmp->tm_yday + 1,
828 tmp->tm_hour,
829 tmp->tm_min,
830 tmp->tm_sec,
831 fd->abs_ts.nsecs / 1000000);
832 break;
833 case TS_PREC_FIXED_USEC:
834 case TS_PREC_AUTO_USEC:
835 g_snprintf(buf, COL_MAX_LEN, "%04d/%03d %02d:%02d:%02d.%06d",
836 tmp->tm_year + 1900,
837 tmp->tm_yday + 1,
838 tmp->tm_hour,
839 tmp->tm_min,
840 tmp->tm_sec,
841 fd->abs_ts.nsecs / 1000);
842 break;
843 case TS_PREC_FIXED_NSEC:
844 case TS_PREC_AUTO_NSEC:
845 g_snprintf(buf, COL_MAX_LEN, "%04d/%03d %02d:%02d:%02d.%09d",
846 tmp->tm_year + 1900,
847 tmp->tm_yday + 1,
848 tmp->tm_hour,
849 tmp->tm_min,
850 tmp->tm_sec,
851 fd->abs_ts.nsecs);
852 break;
853 default:
854 g_assert_not_reached();
856 } else {
857 buf[0] = '\0';
861 static void
862 col_set_abs_ydoy_time(const frame_data *fd, column_info *cinfo, const int col)
864 set_abs_ydoy_time(fd, cinfo->col_buf[col], TRUE);
865 cinfo->col_expr.col_expr[col] = "frame.time";
866 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
868 cinfo->col_data[col] = cinfo->col_buf[col];
871 static void
872 col_set_utc_ydoy_time(const frame_data *fd, column_info *cinfo, const int col)
874 set_abs_ydoy_time(fd, cinfo->col_buf[col], FALSE);
875 cinfo->col_expr.col_expr[col] = "frame.time";
876 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
878 cinfo->col_data[col] = cinfo->col_buf[col];
881 static void
882 set_time_seconds(const nstime_t *ts, gchar *buf)
884 switch (timestamp_get_precision()) {
885 case TS_PREC_FIXED_SEC:
886 case TS_PREC_AUTO_SEC:
887 display_signed_time(buf, COL_MAX_LEN,
888 (gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
889 break;
890 case TS_PREC_FIXED_DSEC:
891 case TS_PREC_AUTO_DSEC:
892 display_signed_time(buf, COL_MAX_LEN,
893 (gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
894 break;
895 case TS_PREC_FIXED_CSEC:
896 case TS_PREC_AUTO_CSEC:
897 display_signed_time(buf, COL_MAX_LEN,
898 (gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
899 break;
900 case TS_PREC_FIXED_MSEC:
901 case TS_PREC_AUTO_MSEC:
902 display_signed_time(buf, COL_MAX_LEN,
903 (gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
904 break;
905 case TS_PREC_FIXED_USEC:
906 case TS_PREC_AUTO_USEC:
907 display_signed_time(buf, COL_MAX_LEN,
908 (gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
909 break;
910 case TS_PREC_FIXED_NSEC:
911 case TS_PREC_AUTO_NSEC:
912 display_signed_time(buf, COL_MAX_LEN,
913 (gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
914 break;
915 default:
916 g_assert_not_reached();
920 static void
921 set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
923 time_t secs = ts->secs;
924 long nsecs = (long) ts->nsecs;
925 gboolean negative = FALSE;
927 if (secs < 0) {
928 secs = -secs;
929 negative = TRUE;
931 if (nsecs < 0) {
932 nsecs = -nsecs;
933 negative = TRUE;
936 switch (timestamp_get_precision()) {
937 case TS_PREC_FIXED_SEC:
938 case TS_PREC_AUTO_SEC:
939 if (secs >= (60*60)) {
940 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2ds",
941 negative ? "- " : "",
942 (gint32) secs / (60 * 60),
943 (gint32) (secs / 60) % 60,
944 (gint32) secs % 60);
945 } else if (secs >= 60) {
946 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2ds",
947 negative ? "- " : "",
948 (gint32) secs / 60,
949 (gint32) secs % 60);
950 } else {
951 g_snprintf(buf, COL_MAX_LEN, "%s%ds",
952 negative ? "- " : "",
953 (gint32) secs);
955 break;
956 case TS_PREC_FIXED_DSEC:
957 case TS_PREC_AUTO_DSEC:
958 if (secs >= (60*60)) {
959 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%01lds",
960 negative ? "- " : "",
961 (gint32) secs / (60 * 60),
962 (gint32) (secs / 60) % 60,
963 (gint32) secs % 60,
964 nsecs / 100000000);
965 } else if (secs >= 60) {
966 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%01lds",
967 negative ? "- " : "",
968 (gint32) secs / 60,
969 (gint32) secs % 60,
970 nsecs / 100000000);
971 } else {
972 g_snprintf(buf, COL_MAX_LEN, "%s%d.%01lds",
973 negative ? "- " : "",
974 (gint32) secs,
975 nsecs / 100000000);
977 break;
978 case TS_PREC_FIXED_CSEC:
979 case TS_PREC_AUTO_CSEC:
980 if (secs >= (60*60)) {
981 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%02lds",
982 negative ? "- " : "",
983 (gint32) secs / (60 * 60),
984 (gint32) (secs / 60) % 60,
985 (gint32) secs % 60,
986 nsecs / 10000000);
987 } else if (secs >= 60) {
988 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%02lds",
989 negative ? "- " : "",
990 (gint32) secs / 60,
991 (gint32) secs % 60,
992 nsecs / 10000000);
993 } else {
994 g_snprintf(buf, COL_MAX_LEN, "%s%d.%02lds",
995 negative ? "- " : "",
996 (gint32) secs,
997 nsecs / 10000000);
999 break;
1000 case TS_PREC_FIXED_MSEC:
1001 case TS_PREC_AUTO_MSEC:
1002 if (secs >= (60*60)) {
1003 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%03lds",
1004 negative ? "- " : "",
1005 (gint32) secs / (60 * 60),
1006 (gint32) (secs / 60) % 60,
1007 (gint32) secs % 60,
1008 nsecs / 1000000);
1009 } else if (secs >= 60) {
1010 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%03lds",
1011 negative ? "- " : "",
1012 (gint32) secs / 60,
1013 (gint32) secs % 60,
1014 nsecs / 1000000);
1015 } else {
1016 g_snprintf(buf, COL_MAX_LEN, "%s%d.%03lds",
1017 negative ? "- " : "",
1018 (gint32) secs,
1019 nsecs / 1000000);
1021 break;
1022 case TS_PREC_FIXED_USEC:
1023 case TS_PREC_AUTO_USEC:
1024 if (secs >= (60*60)) {
1025 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%06lds",
1026 negative ? "- " : "",
1027 (gint32) secs / (60 * 60),
1028 (gint32) (secs / 60) % 60,
1029 (gint32) secs % 60,
1030 nsecs / 1000);
1031 } else if (secs >= 60) {
1032 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%06lds",
1033 negative ? "- " : "",
1034 (gint32) secs / 60,
1035 (gint32) secs % 60,
1036 nsecs / 1000);
1037 } else {
1038 g_snprintf(buf, COL_MAX_LEN, "%s%d.%06lds",
1039 negative ? "- " : "",
1040 (gint32) secs,
1041 nsecs / 1000);
1043 break;
1044 case TS_PREC_FIXED_NSEC:
1045 case TS_PREC_AUTO_NSEC:
1046 if (secs >= (60*60)) {
1047 g_snprintf(buf, COL_MAX_LEN, "%s%dh %2dm %2d.%09lds",
1048 negative ? "- " : "",
1049 (gint32) secs / (60 * 60),
1050 (gint32) (secs / 60) % 60,
1051 (gint32) secs % 60,
1052 nsecs);
1053 } else if (secs >= 60) {
1054 g_snprintf(buf, COL_MAX_LEN, "%s%dm %2d.%09lds",
1055 negative ? "- " : "",
1056 (gint32) secs / 60,
1057 (gint32) secs % 60,
1058 nsecs);
1059 } else {
1060 g_snprintf(buf, COL_MAX_LEN, "%s%d.%09lds",
1061 negative ? "- " : "",
1062 (gint32) secs,
1063 nsecs);
1065 break;
1066 default:
1067 g_assert_not_reached();
1071 static void
1072 col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
1074 nstime_t del_rel_ts;
1076 if (!fd->flags.has_ts) {
1077 cinfo->col_buf[col][0] = '\0';
1078 return;
1081 frame_delta_abs_time(cinfo->epan, fd, fd->frame_ref_num, &del_rel_ts);
1083 switch (timestamp_get_seconds_type()) {
1084 case TS_SECONDS_DEFAULT:
1085 set_time_seconds(&del_rel_ts, cinfo->col_buf[col]);
1086 cinfo->col_expr.col_expr[col] = "frame.time_relative";
1087 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1088 break;
1089 case TS_SECONDS_HOUR_MIN_SEC:
1090 set_time_hour_min_sec(&del_rel_ts, cinfo->col_buf[col]);
1091 cinfo->col_expr.col_expr[col] = "frame.time_relative";
1092 set_time_seconds(&del_rel_ts, cinfo->col_expr.col_expr_val[col]);
1093 break;
1094 default:
1095 g_assert_not_reached();
1097 cinfo->col_data[col] = cinfo->col_buf[col];
1100 static void
1101 col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
1103 nstime_t del_cap_ts;
1105 frame_delta_abs_time(cinfo->epan, fd, fd->num - 1, &del_cap_ts);
1107 switch (timestamp_get_seconds_type()) {
1108 case TS_SECONDS_DEFAULT:
1109 set_time_seconds(&del_cap_ts, cinfo->col_buf[col]);
1110 cinfo->col_expr.col_expr[col] = "frame.time_delta";
1111 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1112 break;
1113 case TS_SECONDS_HOUR_MIN_SEC:
1114 set_time_hour_min_sec(&del_cap_ts, cinfo->col_buf[col]);
1115 cinfo->col_expr.col_expr[col] = "frame.time_delta";
1116 set_time_seconds(&del_cap_ts, cinfo->col_expr.col_expr_val[col]);
1117 break;
1118 default:
1119 g_assert_not_reached();
1122 cinfo->col_data[col] = cinfo->col_buf[col];
1125 static void
1126 col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
1128 nstime_t del_dis_ts;
1130 if (!fd->flags.has_ts) {
1131 cinfo->col_buf[col][0] = '\0';
1132 return;
1135 frame_delta_abs_time(cinfo->epan, fd, fd->prev_dis_num, &del_dis_ts);
1137 switch (timestamp_get_seconds_type()) {
1138 case TS_SECONDS_DEFAULT:
1139 set_time_seconds(&del_dis_ts, cinfo->col_buf[col]);
1140 cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
1141 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1142 break;
1143 case TS_SECONDS_HOUR_MIN_SEC:
1144 set_time_hour_min_sec(&del_dis_ts, cinfo->col_buf[col]);
1145 cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
1146 set_time_seconds(&del_dis_ts, cinfo->col_expr.col_expr_val[col]);
1147 break;
1148 default:
1149 g_assert_not_reached();
1152 cinfo->col_data[col] = cinfo->col_buf[col];
1155 static void
1156 set_abs_time(const frame_data *fd, gchar *buf, gboolean local)
1158 struct tm *tmp;
1159 time_t then;
1161 if (fd->flags.has_ts) {
1162 then = fd->abs_ts.secs;
1163 if (local)
1164 tmp = localtime(&then);
1165 else
1166 tmp = gmtime(&then);
1167 } else
1168 tmp = NULL;
1169 if (tmp != NULL) {
1170 switch (timestamp_get_precision()) {
1171 case TS_PREC_FIXED_SEC:
1172 case TS_PREC_AUTO_SEC:
1173 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d",
1174 tmp->tm_hour,
1175 tmp->tm_min,
1176 tmp->tm_sec);
1177 break;
1178 case TS_PREC_FIXED_DSEC:
1179 case TS_PREC_AUTO_DSEC:
1180 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%01d",
1181 tmp->tm_hour,
1182 tmp->tm_min,
1183 tmp->tm_sec,
1184 fd->abs_ts.nsecs / 100000000);
1185 break;
1186 case TS_PREC_FIXED_CSEC:
1187 case TS_PREC_AUTO_CSEC:
1188 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%02d",
1189 tmp->tm_hour,
1190 tmp->tm_min,
1191 tmp->tm_sec,
1192 fd->abs_ts.nsecs / 10000000);
1193 break;
1194 case TS_PREC_FIXED_MSEC:
1195 case TS_PREC_AUTO_MSEC:
1196 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%03d",
1197 tmp->tm_hour,
1198 tmp->tm_min,
1199 tmp->tm_sec,
1200 fd->abs_ts.nsecs / 1000000);
1201 break;
1202 case TS_PREC_FIXED_USEC:
1203 case TS_PREC_AUTO_USEC:
1204 g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%06d",
1205 tmp->tm_hour,
1206 tmp->tm_min,
1207 tmp->tm_sec,
1208 fd->abs_ts.nsecs / 1000);
1209 break;
1210 case TS_PREC_FIXED_NSEC:
1211 case TS_PREC_AUTO_NSEC:
1212 g_snprintf(buf, COL_MAX_LEN, "%02d:%02d:%02d.%09d",
1213 tmp->tm_hour,
1214 tmp->tm_min,
1215 tmp->tm_sec,
1216 fd->abs_ts.nsecs);
1217 break;
1218 default:
1219 g_assert_not_reached();
1222 } else {
1223 *buf = '\0';
1227 static void
1228 col_set_abs_time(const frame_data *fd, column_info *cinfo, const int col)
1230 set_abs_time(fd, cinfo->col_buf[col], TRUE);
1231 cinfo->col_expr.col_expr[col] = "frame.time";
1232 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1234 cinfo->col_data[col] = cinfo->col_buf[col];
1237 static void
1238 col_set_utc_time(const frame_data *fd, column_info *cinfo, const int col)
1240 set_abs_time(fd, cinfo->col_buf[col], FALSE);
1241 cinfo->col_expr.col_expr[col] = "frame.time";
1242 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1244 cinfo->col_data[col] = cinfo->col_buf[col];
1247 static gboolean
1248 set_epoch_time(const frame_data *fd, gchar *buf)
1250 if (!fd->flags.has_ts) {
1251 buf[0] = '\0';
1252 return FALSE;
1254 switch (timestamp_get_precision()) {
1255 case TS_PREC_FIXED_SEC:
1256 case TS_PREC_AUTO_SEC:
1257 display_epoch_time(buf, COL_MAX_LEN,
1258 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
1259 break;
1260 case TS_PREC_FIXED_DSEC:
1261 case TS_PREC_AUTO_DSEC:
1262 display_epoch_time(buf, COL_MAX_LEN,
1263 fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
1264 break;
1265 case TS_PREC_FIXED_CSEC:
1266 case TS_PREC_AUTO_CSEC:
1267 display_epoch_time(buf, COL_MAX_LEN,
1268 fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
1269 break;
1270 case TS_PREC_FIXED_MSEC:
1271 case TS_PREC_AUTO_MSEC:
1272 display_epoch_time(buf, COL_MAX_LEN,
1273 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
1274 break;
1275 case TS_PREC_FIXED_USEC:
1276 case TS_PREC_AUTO_USEC:
1277 display_epoch_time(buf, COL_MAX_LEN,
1278 fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
1279 break;
1280 case TS_PREC_FIXED_NSEC:
1281 case TS_PREC_AUTO_NSEC:
1282 display_epoch_time(buf, COL_MAX_LEN,
1283 fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
1284 break;
1285 default:
1286 g_assert_not_reached();
1288 return TRUE;
1291 static void
1292 col_set_epoch_time(const frame_data *fd, column_info *cinfo, const int col)
1294 if (set_epoch_time(fd, cinfo->col_buf[col])) {
1295 cinfo->col_expr.col_expr[col] = "frame.time_delta";
1296 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1298 cinfo->col_data[col] = cinfo->col_buf[col];
1301 void
1302 set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
1305 switch (timestamp_get_type()) {
1306 case TS_ABSOLUTE:
1307 set_abs_time(fd, buf, TRUE);
1308 break;
1310 case TS_ABSOLUTE_WITH_YMD:
1311 set_abs_ymd_time(fd, buf, TRUE);
1312 break;
1314 case TS_ABSOLUTE_WITH_YDOY:
1315 set_abs_ydoy_time(fd, buf, TRUE);
1316 break;
1318 case TS_RELATIVE:
1319 if (fd->flags.has_ts) {
1320 nstime_t del_rel_ts;
1322 frame_delta_abs_time(epan, fd, fd->frame_ref_num, &del_rel_ts);
1324 switch (timestamp_get_seconds_type()) {
1325 case TS_SECONDS_DEFAULT:
1326 set_time_seconds(&del_rel_ts, buf);
1327 break;
1328 case TS_SECONDS_HOUR_MIN_SEC:
1329 set_time_seconds(&del_rel_ts, buf);
1330 break;
1331 default:
1332 g_assert_not_reached();
1334 } else {
1335 buf[0] = '\0';
1337 break;
1339 case TS_DELTA:
1340 if (fd->flags.has_ts) {
1341 nstime_t del_cap_ts;
1343 frame_delta_abs_time(epan, fd, fd->num - 1, &del_cap_ts);
1345 switch (timestamp_get_seconds_type()) {
1346 case TS_SECONDS_DEFAULT:
1347 set_time_seconds(&del_cap_ts, buf);
1348 break;
1349 case TS_SECONDS_HOUR_MIN_SEC:
1350 set_time_hour_min_sec(&del_cap_ts, buf);
1351 break;
1352 default:
1353 g_assert_not_reached();
1355 } else {
1356 buf[0] = '\0';
1358 break;
1360 case TS_DELTA_DIS:
1361 if (fd->flags.has_ts) {
1362 nstime_t del_dis_ts;
1364 frame_delta_abs_time(epan, fd, fd->prev_dis_num, &del_dis_ts);
1366 switch (timestamp_get_seconds_type()) {
1367 case TS_SECONDS_DEFAULT:
1368 set_time_seconds(&del_dis_ts, buf);
1369 break;
1370 case TS_SECONDS_HOUR_MIN_SEC:
1371 set_time_hour_min_sec(&del_dis_ts, buf);
1372 break;
1373 default:
1374 g_assert_not_reached();
1376 } else {
1377 buf[0] = '\0';
1379 break;
1381 case TS_EPOCH:
1382 set_epoch_time(fd, buf);
1383 break;
1385 case TS_UTC:
1386 set_abs_time(fd, buf, FALSE);
1387 break;
1389 case TS_UTC_WITH_YMD:
1390 set_abs_ymd_time(fd, buf, FALSE);
1391 break;
1393 case TS_UTC_WITH_YDOY:
1394 set_abs_ydoy_time(fd, buf, FALSE);
1395 break;
1397 case TS_NOT_SET:
1398 /* code is missing for this case, but I don't know which [jmayer20051219] */
1399 g_assert(FALSE);
1400 break;
1404 static void
1405 col_set_cls_time(const frame_data *fd, column_info *cinfo, const gint col)
1407 switch (timestamp_get_type()) {
1408 case TS_ABSOLUTE:
1409 col_set_abs_time(fd, cinfo, col);
1410 break;
1412 case TS_ABSOLUTE_WITH_YMD:
1413 col_set_abs_ymd_time(fd, cinfo, col);
1414 break;
1416 case TS_ABSOLUTE_WITH_YDOY:
1417 col_set_abs_ydoy_time(fd, cinfo, col);
1418 break;
1420 case TS_RELATIVE:
1421 col_set_rel_time(fd, cinfo, col);
1422 break;
1424 case TS_DELTA:
1425 col_set_delta_time(fd, cinfo, col);
1426 break;
1428 case TS_DELTA_DIS:
1429 col_set_delta_time_dis(fd, cinfo, col);
1430 break;
1432 case TS_EPOCH:
1433 col_set_epoch_time(fd, cinfo, col);
1434 break;
1436 case TS_UTC:
1437 col_set_utc_time(fd, cinfo, col);
1438 break;
1440 case TS_UTC_WITH_YMD:
1441 col_set_utc_ymd_time(fd, cinfo, col);
1442 break;
1444 case TS_UTC_WITH_YDOY:
1445 col_set_utc_ydoy_time(fd, cinfo, col);
1446 break;
1448 case TS_NOT_SET:
1449 /* code is missing for this case, but I don't know which [jmayer20051219] */
1450 g_assert_not_reached();
1451 break;
1455 /* Set the format of the variable time format. */
1456 static void
1457 col_set_fmt_time(const frame_data *fd, column_info *cinfo, const gint fmt, const gint col)
1459 COL_CHECK_REF_TIME(fd, cinfo->col_buf[col]);
1461 switch (fmt) {
1462 case COL_CLS_TIME:
1463 col_set_cls_time(fd, cinfo, col);
1464 break;
1466 case COL_ABS_TIME:
1467 col_set_abs_time(fd, cinfo, col);
1468 break;
1470 case COL_ABS_YMD_TIME:
1471 col_set_abs_ymd_time(fd, cinfo, col);
1472 break;
1474 case COL_ABS_YDOY_TIME:
1475 col_set_abs_ydoy_time(fd, cinfo, col);
1476 break;
1478 case COL_REL_TIME:
1479 col_set_rel_time(fd, cinfo, col);
1480 break;
1482 case COL_DELTA_TIME:
1483 col_set_delta_time(fd, cinfo, col);
1484 break;
1486 case COL_DELTA_TIME_DIS:
1487 col_set_delta_time_dis(fd, cinfo, col);
1488 break;
1490 case COL_UTC_TIME:
1491 col_set_utc_time(fd, cinfo, col);
1492 break;
1494 case COL_UTC_YMD_TIME:
1495 col_set_utc_ymd_time(fd, cinfo, col);
1496 break;
1498 case COL_UTC_YDOY_TIME:
1499 col_set_utc_ydoy_time(fd, cinfo, col);
1500 break;
1502 default:
1503 g_assert_not_reached();
1504 break;
1508 /* --------------------------- */
1509 /* Set the given (relative) time to a column element.
1511 * Used by multiple dissectors to set the time in the column
1512 * COL_DELTA_CONV_TIME
1514 * @param cinfo the current packet row
1515 * @param el the column to use, e.g. COL_INFO
1516 * @param ts the time to set in the column
1517 * @param fieldname the fieldname to use for creating a filter (when
1518 * applying/preparing/copying as filter)
1520 void
1521 col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, const char *fieldname)
1523 int col;
1525 if (!CHECK_COL(cinfo, el))
1526 return;
1528 /** @todo TODO: We don't respect fd->flags.ref_time (no way to access 'fd')
1529 COL_CHECK_REF_TIME(fd, buf);
1532 for (col = cinfo->col_first[el]; col <= cinfo->col_last[el]; col++) {
1533 if (cinfo->fmt_matx[col][el]) {
1534 switch (timestamp_get_precision()) {
1535 case TS_PREC_FIXED_SEC:
1536 case TS_PREC_AUTO_SEC:
1537 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1538 (gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
1539 break;
1540 case TS_PREC_FIXED_DSEC:
1541 case TS_PREC_AUTO_DSEC:
1542 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1543 (gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
1544 break;
1545 case TS_PREC_FIXED_CSEC:
1546 case TS_PREC_AUTO_CSEC:
1547 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1548 (gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
1549 break;
1550 case TS_PREC_FIXED_MSEC:
1551 case TS_PREC_AUTO_MSEC:
1552 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1553 (gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
1554 break;
1555 case TS_PREC_FIXED_USEC:
1556 case TS_PREC_AUTO_USEC:
1557 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1558 (gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
1559 break;
1560 case TS_PREC_FIXED_NSEC:
1561 case TS_PREC_AUTO_NSEC:
1562 display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
1563 (gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
1564 break;
1565 default:
1566 g_assert_not_reached();
1568 cinfo->col_data[col] = cinfo->col_buf[col];
1569 cinfo->col_expr.col_expr[col] = fieldname;
1570 g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
1575 static void
1576 col_set_addr(packet_info *pinfo, const int col, const address *addr, const gboolean is_src,
1577 const gboolean fill_col_exprs, const gboolean res)
1579 if (addr->type == AT_NONE) {
1580 /* No address, nothing to do */
1581 return;
1584 if (res)
1585 pinfo->cinfo->col_data[col] = se_get_addr_name(addr);
1586 else
1587 pinfo->cinfo->col_data[col] = se_address_to_str(addr);
1589 if (!fill_col_exprs)
1590 return;
1592 switch (addr->type) {
1593 case AT_AX25:
1594 if (is_src)
1595 pinfo->cinfo->col_expr.col_expr[col] = "ax25.src";
1596 else
1597 pinfo->cinfo->col_expr.col_expr[col] = "ax25.dst";
1598 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], ax25_to_str((guint8 *)addr->data), COL_MAX_LEN);
1599 break;
1601 case AT_ETHER:
1602 if (is_src)
1603 pinfo->cinfo->col_expr.col_expr[col] = "eth.src";
1604 else
1605 pinfo->cinfo->col_expr.col_expr[col] = "eth.dst";
1606 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1607 break;
1609 case AT_IPv4:
1610 if (is_src)
1611 pinfo->cinfo->col_expr.col_expr[col] = "ip.src";
1612 else
1613 pinfo->cinfo->col_expr.col_expr[col] = "ip.dst";
1614 ip_to_str_buf((guint8 *)addr->data, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1615 break;
1617 case AT_IPv6:
1618 if (is_src)
1619 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.src";
1620 else
1621 pinfo->cinfo->col_expr.col_expr[col] = "ipv6.dst";
1622 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1623 break;
1625 case AT_ATALK:
1626 if (is_src)
1627 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src";
1628 else
1629 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst";
1630 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1631 break;
1633 case AT_ARCNET:
1634 if (is_src)
1635 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.src";
1636 else
1637 pinfo->cinfo->col_expr.col_expr[col] = "arcnet.dst";
1638 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1639 break;
1641 case AT_URI:
1642 if (is_src)
1643 pinfo->cinfo->col_expr.col_expr[col] = "uri.src";
1644 else
1645 pinfo->cinfo->col_expr.col_expr[col] = "uri.dst";
1646 address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1647 break;
1649 default:
1650 break;
1653 /* Some addresses (e.g. ieee80211) use a standard format like AT_ETHER but
1654 * don't use the same hf_ value (and thus don't use the same filter string).
1655 * Such address can use the SET_ADDRESS_HF macro to pass in the specific hf_
1656 * value they use. If they did so, we overwrite the default filter string
1657 * with their specific one here. See bug #7728 for further discussion.
1658 * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7728 */
1659 if (addr->hf != -1) {
1660 pinfo->cinfo->col_expr.col_expr[col] = proto_registrar_get_nth(addr->hf)->abbrev;
1665 /* ------------------------ */
1666 static void
1667 col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gboolean is_src, const gboolean fill_col_exprs _U_)
1669 guint32 port;
1671 if (is_src)
1672 port = pinfo->srcport;
1673 else
1674 port = pinfo->destport;
1676 /* TODO: Use fill_col_exprs */
1678 switch (pinfo->ptype) {
1679 case PT_SCTP:
1680 if (is_res)
1681 g_strlcpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
1682 else
1683 guint32_to_str_buf(port, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
1684 break;
1686 case PT_TCP:
1687 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1688 if (is_res)
1689 g_strlcpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
1690 else
1691 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1692 if (is_src)
1693 pinfo->cinfo->col_expr.col_expr[col] = "tcp.srcport";
1694 else
1695 pinfo->cinfo->col_expr.col_expr[col] = "tcp.dstport";
1696 break;
1698 case PT_UDP:
1699 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1700 if (is_res)
1701 g_strlcpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
1702 else
1703 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1704 if (is_src)
1705 pinfo->cinfo->col_expr.col_expr[col] = "udp.srcport";
1706 else
1707 pinfo->cinfo->col_expr.col_expr[col] = "udp.dstport";
1708 break;
1710 case PT_DDP:
1711 if (is_src)
1712 pinfo->cinfo->col_expr.col_expr[col] = "ddp.src_socket";
1713 else
1714 pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst_socket";
1715 guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1716 g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
1717 break;
1719 case PT_IPX:
1720 /* XXX - resolve IPX socket numbers */
1721 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1722 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1723 if (is_src)
1724 pinfo->cinfo->col_expr.col_expr[col] = "ipx.src.socket";
1725 else
1726 pinfo->cinfo->col_expr.col_expr[col] = "ipx.dst.socket";
1727 break;
1729 case PT_IDP:
1730 /* XXX - resolve IDP socket numbers */
1731 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1732 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1733 if (is_src)
1734 pinfo->cinfo->col_expr.col_expr[col] = "idp.src.socket";
1735 else
1736 pinfo->cinfo->col_expr.col_expr[col] = "idp.dst.socket";
1737 break;
1739 case PT_USB:
1740 /* XXX - resolve USB endpoint numbers */
1741 g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port);
1742 g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN);
1743 if (is_src)
1744 pinfo->cinfo->col_expr.col_expr[col] = "usb.src.endpoint";
1745 else
1746 pinfo->cinfo->col_expr.col_expr[col] = "usb.dst.endpoint";
1747 break;
1749 default:
1750 break;
1752 pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1755 gboolean
1756 col_based_on_frame_data(column_info *cinfo, const gint col)
1758 g_assert(cinfo);
1759 g_assert(col < cinfo->num_cols);
1761 switch (cinfo->col_fmt[col]) {
1762 case COL_NUMBER:
1763 case COL_CLS_TIME:
1764 case COL_ABS_TIME:
1765 case COL_ABS_YMD_TIME:
1766 case COL_ABS_YDOY_TIME:
1767 case COL_UTC_TIME:
1768 case COL_UTC_YMD_TIME:
1769 case COL_UTC_YDOY_TIME:
1770 case COL_REL_TIME:
1771 case COL_DELTA_TIME:
1772 case COL_DELTA_TIME_DIS:
1773 case COL_PACKET_LENGTH:
1774 case COL_CUMULATIVE_BYTES:
1775 return TRUE;
1777 default:
1778 return FALSE;
1782 void
1783 col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, const gboolean fill_col_exprs)
1785 switch (cinfo->col_fmt[col]) {
1786 case COL_NUMBER:
1787 guint32_to_str_buf(fd->num, cinfo->col_buf[col], COL_MAX_LEN);
1788 cinfo->col_data[col] = cinfo->col_buf[col];
1789 break;
1791 case COL_CLS_TIME:
1792 case COL_ABS_TIME:
1793 case COL_ABS_YMD_TIME:
1794 case COL_ABS_YDOY_TIME:
1795 case COL_UTC_TIME:
1796 case COL_UTC_YMD_TIME:
1797 case COL_UTC_YDOY_TIME:
1798 case COL_REL_TIME:
1799 case COL_DELTA_TIME:
1800 case COL_DELTA_TIME_DIS:
1801 /* TODO: Pass on fill_col_exprs */
1802 col_set_fmt_time(fd, cinfo, cinfo->col_fmt[col], col);
1803 break;
1805 case COL_PACKET_LENGTH:
1806 guint32_to_str_buf(fd->pkt_len, cinfo->col_buf[col], COL_MAX_LEN);
1807 cinfo->col_data[col] = cinfo->col_buf[col];
1808 break;
1810 case COL_CUMULATIVE_BYTES:
1811 guint32_to_str_buf(fd->cum_bytes, cinfo->col_buf[col], COL_MAX_LEN);
1812 cinfo->col_data[col] = cinfo->col_buf[col];
1813 break;
1815 default:
1816 break;
1819 if (!fill_col_exprs)
1820 return;
1822 switch (cinfo->col_fmt[col]) {
1823 case COL_NUMBER:
1824 cinfo->col_expr.col_expr[col] = "frame.number";
1825 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1826 break;
1828 case COL_CLS_TIME:
1829 case COL_ABS_TIME:
1830 case COL_ABS_YMD_TIME:
1831 case COL_ABS_YDOY_TIME:
1832 case COL_UTC_TIME:
1833 case COL_UTC_YMD_TIME:
1834 case COL_UTC_YDOY_TIME:
1835 case COL_REL_TIME:
1836 case COL_DELTA_TIME:
1837 case COL_DELTA_TIME_DIS:
1838 /* Already handled above */
1839 break;
1841 case COL_PACKET_LENGTH:
1842 cinfo->col_expr.col_expr[col] = "frame.len";
1843 g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN);
1844 break;
1846 case COL_CUMULATIVE_BYTES:
1847 break;
1849 default:
1850 break;
1854 void
1855 col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
1857 int i;
1859 if (!pinfo->cinfo)
1860 return;
1862 for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1863 switch (pinfo->cinfo->col_fmt[i]) {
1864 case COL_NUMBER:
1865 case COL_CLS_TIME:
1866 case COL_ABS_TIME:
1867 case COL_ABS_YMD_TIME:
1868 case COL_ABS_YDOY_TIME:
1869 case COL_UTC_TIME:
1870 case COL_UTC_YMD_TIME:
1871 case COL_UTC_YDOY_TIME:
1872 case COL_REL_TIME:
1873 case COL_DELTA_TIME:
1874 case COL_DELTA_TIME_DIS:
1875 case COL_PACKET_LENGTH:
1876 case COL_CUMULATIVE_BYTES:
1877 if (fill_fd_colums)
1878 col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i, fill_col_exprs);
1879 break;
1881 case COL_DEF_SRC:
1882 case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
1883 col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs, TRUE);
1884 break;
1886 case COL_UNRES_SRC:
1887 col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs, FALSE);
1888 break;
1890 case COL_DEF_DL_SRC:
1891 case COL_RES_DL_SRC:
1892 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, fill_col_exprs, TRUE);
1893 break;
1895 case COL_UNRES_DL_SRC:
1896 col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, fill_col_exprs, FALSE);
1897 break;
1899 case COL_DEF_NET_SRC:
1900 case COL_RES_NET_SRC:
1901 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, fill_col_exprs, TRUE);
1902 break;
1904 case COL_UNRES_NET_SRC:
1905 col_set_addr(pinfo, i, &pinfo->net_src, TRUE, fill_col_exprs, FALSE);
1906 break;
1908 case COL_DEF_DST:
1909 case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
1910 col_set_addr(pinfo, i, &pinfo->dst, FALSE, fill_col_exprs, TRUE);
1911 break;
1913 case COL_UNRES_DST:
1914 col_set_addr(pinfo, i, &pinfo->dst, FALSE, fill_col_exprs, FALSE);
1915 break;
1917 case COL_DEF_DL_DST:
1918 case COL_RES_DL_DST:
1919 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, fill_col_exprs, TRUE);
1920 break;
1922 case COL_UNRES_DL_DST:
1923 col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, fill_col_exprs, FALSE);
1924 break;
1926 case COL_DEF_NET_DST:
1927 case COL_RES_NET_DST:
1928 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, fill_col_exprs, TRUE);
1929 break;
1931 case COL_UNRES_NET_DST:
1932 col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, fill_col_exprs, FALSE);
1933 break;
1935 case COL_DEF_SRC_PORT:
1936 case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1937 col_set_port(pinfo, i, TRUE, TRUE, fill_col_exprs);
1938 break;
1940 case COL_UNRES_SRC_PORT:
1941 col_set_port(pinfo, i, FALSE, TRUE, fill_col_exprs);
1942 break;
1944 case COL_DEF_DST_PORT:
1945 case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1946 col_set_port(pinfo, i, TRUE, FALSE, fill_col_exprs);
1947 break;
1949 case COL_UNRES_DST_PORT:
1950 col_set_port(pinfo, i, FALSE, FALSE, fill_col_exprs);
1951 break;
1953 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
1954 g_assert_not_reached();
1955 break;
1956 default:
1957 if (pinfo->cinfo->col_fmt[i] >= NUM_COL_FMTS) {
1958 g_assert_not_reached();
1961 * Formatting handled by col_custom_set_edt() (COL_CUSTOM), expert.c
1962 * (COL_EXPERT), or individual dissectors.
1964 break;
1970 * Fill in columns if we got an error reading the packet.
1971 * We set most columns to "???", and set the Info column to an error
1972 * message.
1974 void
1975 col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
1977 int i;
1979 if (!cinfo)
1980 return;
1982 for (i = 0; i < cinfo->num_cols; i++) {
1983 switch (cinfo->col_fmt[i]) {
1984 case COL_NUMBER:
1985 case COL_CLS_TIME:
1986 case COL_ABS_TIME:
1987 case COL_ABS_YMD_TIME:
1988 case COL_ABS_YDOY_TIME:
1989 case COL_UTC_TIME:
1990 case COL_UTC_YMD_TIME:
1991 case COL_UTC_YDOY_TIME:
1992 case COL_REL_TIME:
1993 case COL_DELTA_TIME:
1994 case COL_DELTA_TIME_DIS:
1995 case COL_PACKET_LENGTH:
1996 case COL_CUMULATIVE_BYTES:
1997 if (fill_fd_colums)
1998 col_fill_in_frame_data(fdata, cinfo, i, fill_col_exprs);
1999 break;
2001 case COL_INFO:
2002 /* XXX - say more than this */
2003 cinfo->col_data[i] = "Read error";
2004 break;
2006 case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
2007 g_assert_not_reached();
2008 break;
2009 default:
2010 if (cinfo->col_fmt[i] >= NUM_COL_FMTS) {
2011 g_assert_not_reached();
2014 * No dissection was done, and these columns are set as the
2015 * result of the dissection, so....
2017 cinfo->col_data[i] = "???";
2018 break;
2024 * Editor modelines
2026 * Local Variables:
2027 * c-basic-offset: 2
2028 * tab-width: 8
2029 * indent-tabs-mode: nil
2030 * End:
2032 * ex: set shiftwidth=2 tabstop=8 expandtab:
2033 * :indentSize=2:tabSize=8:noTabs=true: