2793119609049b556ded7c46a79c66a24bb2bc3f
[obnox/wireshark/wip.git] / epan / column-utils.c
1 /* column-utils.c
2  * Routines for column utilities.
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <string.h>
30 #include <time.h>
31
32 #include "column-utils.h"
33 #include "timestamp.h"
34 #include "sna-utils.h"
35 #include "atalk-utils.h"
36 #include "to_str.h"
37 #include "packet_info.h"
38 #include "pint.h"
39 #include "addr_resolv.h"
40 #include "ipv6-utils.h"
41 #include "osi-utils.h"
42 #include "value_string.h"
43
44 /* Allocate all the data structures for constructing column data, given
45    the number of columns. */
46 void
47 col_setup(column_info *cinfo, gint num_cols)
48 {
49   int i;
50
51   cinfo->num_cols       = num_cols;
52   cinfo->col_fmt        = (gint *) g_malloc(sizeof(gint) * num_cols);
53   cinfo->fmt_matx       = (gboolean **) g_malloc(sizeof(gboolean *) * num_cols);
54   cinfo->col_first      = (int *) g_malloc(sizeof(int) * (NUM_COL_FMTS));
55   cinfo->col_last       = (int *) g_malloc(sizeof(int) * (NUM_COL_FMTS));
56   cinfo->col_title      = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
57   cinfo->col_data       = (const gchar **) g_malloc(sizeof(gchar *) * num_cols);
58   cinfo->col_buf        = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
59   cinfo->col_fence      = (int *) g_malloc(sizeof(int) * num_cols);
60   cinfo->col_expr       = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
61   cinfo->col_expr_val = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
62
63   for (i = 0; i < NUM_COL_FMTS; i++) {
64     cinfo->col_first[i] = -1;
65     cinfo->col_last[i] = -1;
66   }
67 }
68
69 /* Initialize the data structures for constructing column data. */
70 void
71 col_init(column_info *cinfo)
72 {
73   int i;
74
75   for (i = 0; i < cinfo->num_cols; i++) {
76     cinfo->col_buf[i][0] = '\0';
77     cinfo->col_data[i] = cinfo->col_buf[i];
78     cinfo->col_fence[i] = 0;
79     cinfo->col_expr[i][0] = '\0';
80     cinfo->col_expr_val[i][0] = '\0';
81   }
82   cinfo->writable = TRUE;
83 }
84
85 gboolean
86 col_get_writable(column_info *cinfo)
87 {
88         return (cinfo ? cinfo->writable : FALSE);
89 }
90
91 void
92 col_set_writable(column_info *cinfo, gboolean writable)
93 {
94         if (cinfo)
95                 cinfo->writable = writable;
96 }
97
98 /* Checks to see if a particular packet information element is needed for
99    the packet list */
100 gint
101 check_col(column_info *cinfo, gint el) {
102
103   if (cinfo && cinfo->writable) {
104     /* We are constructing columns, and they're writable */
105     if (cinfo->col_first[el] >= 0) {
106       /* There is at least one column in that format */
107       return TRUE;
108     }
109   }
110   return FALSE;
111 }
112
113 /* Sets the fence for a column to be at the end of the column. */
114 void
115 col_set_fence(column_info *cinfo, gint el)
116 {
117   int i;
118
119   if (cinfo && cinfo->writable) {
120     /* We are constructing columns, and they're writable */
121     if (cinfo->col_first[el] >= 0) {
122       /* There is at least one column in that format */
123       for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
124         if (cinfo->fmt_matx[i][el]) {
125           cinfo->col_fence[i] = strlen(cinfo->col_data[i]);
126         }
127       }
128     }
129   }
130 }
131
132 /* Use this to clear out a column, especially if you're going to be
133    appending to it later; at least on some platforms, it's more
134    efficient than using "col_add_str()" with a null string, and
135    more efficient than "col_set_str()" with a null string if you
136    later append to it, as the later append will cause a string
137    copy to be done. */
138 void
139 col_clear(column_info *cinfo, gint el)
140 {
141   int    i;
142   int    fence;
143
144   g_assert(cinfo->col_first[el] >= 0);
145   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
146     if (cinfo->fmt_matx[i][el]) {
147       /*
148        * At this point, either
149        *
150        *   1) col_data[i] is equal to col_buf[i], in which case we
151        *      don't have to worry about copying col_data[i] to
152        *      col_buf[i];
153        *
154        *   2) col_data[i] isn't equal to col_buf[i], in which case
155        *      the only thing that's been done to the column is
156        *      "col_set_str()" calls and possibly "col_set_fence()"
157        *      calls, in which case the fence is either unset and
158        *      at the beginning of the string or set and at the end
159        *      of the string - if it's at the beginning, we're just
160        *      going to clear the column, and if it's at the end,
161        *      we don't do anything.
162        */
163       fence = cinfo->col_fence[i];
164       if (fence == 0 || cinfo->col_buf[i] == cinfo->col_data[i]) {
165         /*
166          * The fence isn't at the end of the column, or the column wasn't
167          * last set with "col_set_str()", so clear the column out.
168          */
169         cinfo->col_buf[i][fence] = '\0';
170         cinfo->col_data[i] = cinfo->col_buf[i];
171       }
172       cinfo->col_expr[i][0] = '\0';
173       cinfo->col_expr_val[i][0] = '\0';
174     }
175   }
176 }
177
178 #define COL_CHECK_APPEND(cinfo, i, max_len) \
179   if (cinfo->col_data[i] != cinfo->col_buf[i]) {                \
180     /* This was set with "col_set_str()"; copy the string they  \
181        set it to into the buffer, so we can append to it. */    \
182     strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len);    \
183     cinfo->col_buf[i][max_len - 1] = '\0';                      \
184     cinfo->col_data[i] = cinfo->col_buf[i];                     \
185   }
186
187 #define COL_CHECK_REF_TIME(fd, cinfo, col)      \
188   if(fd->flags.ref_time){                                       \
189     g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "*REF*");      \
190     cinfo->col_data[col] = cinfo->col_buf[col];                 \
191     return;                                                     \
192   }
193
194 /* Use this if "str" points to something that will stay around (and thus
195    needn't be copied). */
196 void
197 col_set_str(column_info *cinfo, gint el, const gchar* str)
198 {
199   int i;
200   int fence;
201   size_t max_len;
202
203   if (el == COL_INFO)
204         max_len = COL_MAX_INFO_LEN;
205   else
206         max_len = COL_MAX_LEN;
207
208   g_assert(cinfo->col_first[el] >= 0);
209   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
210     if (cinfo->fmt_matx[i][el]) {
211       fence = cinfo->col_fence[i];
212       if (fence != 0) {
213         /*
214          * We will append the string after the fence.
215          * First arrange that we can append, if necessary.
216          */
217         COL_CHECK_APPEND(cinfo, i, max_len);
218
219         strncpy(&cinfo->col_buf[i][fence], str, max_len - fence);
220         cinfo->col_buf[i][max_len - 1] = 0;
221       } else {
222         /*
223          * There's no fence, so we can just set the column to point
224          * to the string.
225          */
226         cinfo->col_data[i] = str;
227       }
228     }
229   }
230 }
231
232 /* Adds a vararg list to a packet info string. */
233 void
234 col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) {
235   va_list ap;
236   int     i;
237   int     fence;
238   size_t  max_len;
239
240   g_assert(cinfo->col_first[el] >= 0);
241   if (el == COL_INFO)
242         max_len = COL_MAX_INFO_LEN;
243   else
244         max_len = COL_MAX_LEN;
245
246   va_start(ap, format);
247   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
248     if (cinfo->fmt_matx[i][el]) {
249       fence = cinfo->col_fence[i];
250       if (fence != 0) {
251         /*
252          * We will append the string after the fence.
253          * First arrange that we can append, if necessary.
254          */
255         COL_CHECK_APPEND(cinfo, i, max_len);
256       } else {
257         /*
258          * There's no fence, so we can just write to the string.
259          */
260         cinfo->col_data[i] = cinfo->col_buf[i];
261       }
262       g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
263       cinfo->col_buf[i][max_len - 1] = '\0';
264     }
265   }
266   va_end(ap);
267 }
268
269 static void
270 col_do_append_sep_va_fstr(column_info *cinfo, gint el, const gchar *separator,
271                           const gchar *format, va_list ap)
272 {
273   int     i;
274   size_t  len, max_len, sep_len;
275
276   g_assert(cinfo->col_first[el] >= 0);
277   if (el == COL_INFO)
278         max_len = COL_MAX_INFO_LEN;
279   else
280         max_len = COL_MAX_LEN;
281
282   if (separator == NULL)
283     sep_len = 0;
284   else
285     sep_len = strlen(separator);
286   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
287     if (cinfo->fmt_matx[i][el]) {
288       /*
289        * First arrange that we can append, if necessary.
290        */
291       COL_CHECK_APPEND(cinfo, i, max_len);
292
293       len = strlen(cinfo->col_buf[i]);
294
295       /*
296        * If we have a separator, append it if the column isn't empty.
297        */
298       if (separator != NULL) {
299         if (len != 0) {
300           strncat(cinfo->col_buf[i], separator, max_len - len);
301           len += sep_len;
302         }
303       }
304       g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
305       cinfo->col_buf[i][max_len-1] = 0;
306     }
307   }
308 }
309
310 /* Appends a vararg list to a packet info string. */
311 void
312 col_append_fstr(column_info *cinfo, gint el, const gchar *format, ...)
313 {
314   va_list ap;
315
316   va_start(ap, format);
317   col_do_append_sep_va_fstr(cinfo, el, NULL, format, ap);
318   va_end(ap);
319 }
320
321 /* Appends a vararg list to a packet info string.
322  * Prefixes it with the given separator if the column is not empty. */
323 void
324 col_append_sep_fstr(column_info *cinfo, gint el, const gchar *separator,
325                 const gchar *format, ...)
326 {
327   va_list ap;
328
329   if (separator == NULL)
330     separator = ", ";    /* default */
331   va_start(ap, format);
332   col_do_append_sep_va_fstr(cinfo, el, separator, format, ap);
333   va_end(ap);
334 }
335
336
337
338 /* Prepends a vararg list to a packet info string. */
339 #define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
340         (COL_MAX_INFO_LEN) : (COL_MAX_LEN))
341 void
342 col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
343 {
344   va_list     ap;
345   int         i;
346   char        orig_buf[COL_BUF_MAX_LEN];
347   const char *orig;
348   size_t      max_len;
349
350   g_assert(cinfo->col_first[el] >= 0);
351   if (el == COL_INFO)
352         max_len = COL_MAX_INFO_LEN;
353   else
354         max_len = COL_MAX_LEN;
355
356   va_start(ap, format);
357   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
358     if (cinfo->fmt_matx[i][el]) {
359       if (cinfo->col_data[i] != cinfo->col_buf[i]) {
360         /* This was set with "col_set_str()"; which is effectively const */
361         orig = cinfo->col_data[i];
362       } else {
363         strncpy(orig_buf, cinfo->col_buf[i], max_len);
364         orig_buf[max_len - 1] = '\0';
365         orig = orig_buf;
366       }
367       g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
368       cinfo->col_buf[i][max_len - 1] = '\0';
369
370       /*
371        * Move the fence, unless it's at the beginning of the string.
372        */
373       if (cinfo->col_fence[i] > 0)
374         cinfo->col_fence[i] += strlen(cinfo->col_buf[i]);
375
376       strncat(cinfo->col_buf[i], orig, max_len);
377       cinfo->col_buf[i][max_len - 1] = '\0';
378       cinfo->col_data[i] = cinfo->col_buf[i];
379     }
380   }
381   va_end(ap);
382 }
383 void
384 col_prepend_fence_fstr(column_info *cinfo, gint el, const gchar *format, ...)
385 {
386   va_list     ap;
387   int         i;
388   char        orig_buf[COL_BUF_MAX_LEN];
389   const char *orig;
390   size_t      max_len;
391
392   g_assert(cinfo->col_first[el] >= 0);
393   if (el == COL_INFO)
394         max_len = COL_MAX_INFO_LEN;
395   else
396         max_len = COL_MAX_LEN;
397
398   va_start(ap, format);
399   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
400     if (cinfo->fmt_matx[i][el]) {
401       if (cinfo->col_data[i] != cinfo->col_buf[i]) {
402         /* This was set with "col_set_str()"; which is effectively const */
403         orig = cinfo->col_data[i];
404       } else {
405         strncpy(orig_buf, cinfo->col_buf[i], max_len);
406         orig_buf[max_len - 1] = '\0';
407         orig = orig_buf;
408       }
409       g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
410       cinfo->col_buf[i][max_len - 1] = '\0';
411
412       /*
413        * Move the fence if it exists, else create a new fence at the
414        * end of the prepended data.
415        */
416       if (cinfo->col_fence[i] > 0) {
417         cinfo->col_fence[i] += strlen(cinfo->col_buf[i]);
418       } else {
419         cinfo->col_fence[i]  = strlen(cinfo->col_buf[i]);
420       }
421       strncat(cinfo->col_buf[i], orig, max_len);
422       cinfo->col_buf[i][max_len - 1] = '\0';
423       cinfo->col_data[i] = cinfo->col_buf[i];
424     }
425   }
426   va_end(ap);
427 }
428
429 /* Use this if "str" points to something that won't stay around (and
430    must thus be copied). */
431 void
432 col_add_str(column_info *cinfo, gint el, const gchar* str)
433 {
434   int    i;
435   int    fence;
436   size_t max_len;
437
438   g_assert(cinfo->col_first[el] >= 0);
439   if (el == COL_INFO)
440         max_len = COL_MAX_INFO_LEN;
441   else
442         max_len = COL_MAX_LEN;
443
444   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
445     if (cinfo->fmt_matx[i][el]) {
446       fence = cinfo->col_fence[i];
447       if (fence != 0) {
448         /*
449          * We will append the string after the fence.
450          * First arrange that we can append, if necessary.
451          */
452         COL_CHECK_APPEND(cinfo, i, max_len);
453       } else {
454         /*
455          * There's no fence, so we can just write to the string.
456          */
457         cinfo->col_data[i] = cinfo->col_buf[i];
458       }
459       strncpy(&cinfo->col_buf[i][fence], str, max_len - fence);
460       cinfo->col_buf[i][max_len - 1] = 0;
461     }
462   }
463 }
464
465 static void
466 col_do_append_str(column_info *cinfo, gint el, const gchar* separator,
467     const gchar* str)
468 {
469   int    i;
470   size_t len, max_len, sep_len;
471
472   g_assert(cinfo->col_first[el] >= 0);
473   if (el == COL_INFO)
474         max_len = COL_MAX_INFO_LEN;
475   else
476         max_len = COL_MAX_LEN;
477
478   if (separator == NULL)
479     sep_len = 0;
480   else
481     sep_len = strlen(separator);
482
483   for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
484     if (cinfo->fmt_matx[i][el]) {
485       /*
486        * First arrange that we can append, if necessary.
487        */
488       COL_CHECK_APPEND(cinfo, i, max_len);
489
490       len = strlen(cinfo->col_buf[i]);
491
492       /*
493        * If we have a separator, append it if the column isn't empty.
494        */
495       if (separator != NULL) {
496         if (len != 0) {
497           strncat(cinfo->col_buf[i], separator, max_len - len);
498           len += sep_len;
499         }
500       }
501       strncat(cinfo->col_buf[i], str, max_len - len);
502       cinfo->col_buf[i][max_len - 1] = 0;
503     }
504   }
505 }
506
507 void
508 col_append_str(column_info *cinfo, gint el, const gchar* str)
509 {
510   col_do_append_str(cinfo, el, NULL, str);
511 }
512
513 void
514 col_append_sep_str(column_info *cinfo, gint el, const gchar* separator,
515     const gchar* str)
516 {
517   if (separator == NULL)
518     separator = ", ";    /* default */
519   col_do_append_str(cinfo, el, separator, str);
520 }
521
522 static void
523 col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
524 {
525   struct tm *tmp;
526   time_t then;
527
528   COL_CHECK_REF_TIME(fd, cinfo, col);
529
530   then = fd->abs_ts.secs;
531   tmp = localtime(&then);
532   if (tmp != NULL) {
533           switch(timestamp_get_precision()) {
534           case(TS_PREC_FIXED_SEC):
535           case(TS_PREC_AUTO_SEC):
536                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
537              "%04d-%02d-%02d %02d:%02d:%02d",
538              tmp->tm_year + 1900,
539              tmp->tm_mon + 1,
540              tmp->tm_mday,
541              tmp->tm_hour,
542              tmp->tm_min,
543              tmp->tm_sec);
544                   break;
545           case(TS_PREC_FIXED_DSEC):
546           case(TS_PREC_AUTO_DSEC):
547                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
548              "%04d-%02d-%02d %02d:%02d:%02d.%01ld",
549              tmp->tm_year + 1900,
550              tmp->tm_mon + 1,
551              tmp->tm_mday,
552              tmp->tm_hour,
553              tmp->tm_min,
554              tmp->tm_sec,
555              (long)fd->abs_ts.nsecs / 100000000);
556                   break;
557           case(TS_PREC_FIXED_CSEC):
558           case(TS_PREC_AUTO_CSEC):
559                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
560              "%04d-%02d-%02d %02d:%02d:%02d.%02ld",
561              tmp->tm_year + 1900,
562              tmp->tm_mon + 1,
563              tmp->tm_mday,
564              tmp->tm_hour,
565              tmp->tm_min,
566              tmp->tm_sec,
567              (long)fd->abs_ts.nsecs / 10000000);
568                   break;
569           case(TS_PREC_FIXED_MSEC):
570           case(TS_PREC_AUTO_MSEC):
571                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
572              "%04d-%02d-%02d %02d:%02d:%02d.%03ld",
573              tmp->tm_year + 1900,
574              tmp->tm_mon + 1,
575              tmp->tm_mday,
576              tmp->tm_hour,
577              tmp->tm_min,
578              tmp->tm_sec,
579              (long)fd->abs_ts.nsecs / 1000000);
580                   break;
581           case(TS_PREC_FIXED_USEC):
582           case(TS_PREC_AUTO_USEC):
583                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
584              "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
585              tmp->tm_year + 1900,
586              tmp->tm_mon + 1,
587              tmp->tm_mday,
588              tmp->tm_hour,
589              tmp->tm_min,
590              tmp->tm_sec,
591              (long)fd->abs_ts.nsecs / 1000);
592                   break;
593           case(TS_PREC_FIXED_NSEC):
594           case(TS_PREC_AUTO_NSEC):
595                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
596              "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
597              tmp->tm_year + 1900,
598              tmp->tm_mon + 1,
599              tmp->tm_mday,
600              tmp->tm_hour,
601              tmp->tm_min,
602              tmp->tm_sec,
603              (long)fd->abs_ts.nsecs);
604                   break;
605           default:
606                   g_assert_not_reached();
607           }
608   } else {
609     cinfo->col_buf[col][0] = '\0';
610   }
611   cinfo->col_data[col] = cinfo->col_buf[col];
612   strcpy(cinfo->col_expr[col],"frame.time");
613   strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
614 }
615
616 static void
617 col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
618 {
619   COL_CHECK_REF_TIME(fd, cinfo, col);
620
621   switch(timestamp_get_precision()) {
622           case(TS_PREC_FIXED_SEC):
623           case(TS_PREC_AUTO_SEC):
624                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
625                         (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000000, SECS);
626                   break;
627           case(TS_PREC_FIXED_DSEC):
628           case(TS_PREC_AUTO_DSEC):
629                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
630                         (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 100000000, DSECS);
631                   break;
632           case(TS_PREC_FIXED_CSEC):
633           case(TS_PREC_AUTO_CSEC):
634                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
635                         (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 10000000, CSECS);
636                   break;
637           case(TS_PREC_FIXED_MSEC):
638           case(TS_PREC_AUTO_MSEC):
639                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
640                         (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000, MSECS);
641                   break;
642           case(TS_PREC_FIXED_USEC):
643           case(TS_PREC_AUTO_USEC):
644                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
645                         (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS);
646                   break;
647           case(TS_PREC_FIXED_NSEC):
648           case(TS_PREC_AUTO_NSEC):
649                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
650                         (gint32) fd->rel_ts.secs, fd->rel_ts.nsecs, NSECS);
651                   break;
652           default:
653                   g_assert_not_reached();
654   }
655   cinfo->col_data[col] = cinfo->col_buf[col];
656   strcpy(cinfo->col_expr[col],"frame.time_relative");
657   strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
658 }
659
660 static void
661 col_set_delta_time(frame_data *fd, column_info *cinfo, int col)
662 {
663   COL_CHECK_REF_TIME(fd, cinfo, col);
664
665   switch(timestamp_get_precision()) {
666           case(TS_PREC_FIXED_SEC):
667           case(TS_PREC_AUTO_SEC):
668                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
669                         (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000000, SECS);
670                   break;
671           case(TS_PREC_FIXED_DSEC):
672           case(TS_PREC_AUTO_DSEC):
673                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
674                         (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 100000000, DSECS);
675                   break;
676           case(TS_PREC_FIXED_CSEC):
677           case(TS_PREC_AUTO_CSEC):
678                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
679                         (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 10000000, CSECS);
680                   break;
681           case(TS_PREC_FIXED_MSEC):
682           case(TS_PREC_AUTO_MSEC):
683                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
684                         (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000, MSECS);
685                   break;
686           case(TS_PREC_FIXED_USEC):
687           case(TS_PREC_AUTO_USEC):
688                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
689                         (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000, USECS);
690                   break;
691           case(TS_PREC_FIXED_NSEC):
692           case(TS_PREC_AUTO_NSEC):
693                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
694                         (gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs, NSECS);
695                   break;
696           default:
697                   g_assert_not_reached();
698   }
699   cinfo->col_data[col] = cinfo->col_buf[col];
700   strcpy(cinfo->col_expr[col],"frame.time_delta");
701   strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
702 }
703
704 static void
705 col_set_delta_time_dis(frame_data *fd, column_info *cinfo, int col)
706 {
707   COL_CHECK_REF_TIME(fd, cinfo, col);
708
709   switch(timestamp_get_precision()) {
710           case(TS_PREC_FIXED_SEC):
711           case(TS_PREC_AUTO_SEC):
712                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
713                         fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000000, SECS);
714                   break;
715           case(TS_PREC_FIXED_DSEC):
716           case(TS_PREC_AUTO_DSEC):
717                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
718                         fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 100000000, DSECS);
719                   break;
720           case(TS_PREC_FIXED_CSEC):
721           case(TS_PREC_AUTO_CSEC):
722                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
723                         fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 10000000, CSECS);
724                   break;
725           case(TS_PREC_FIXED_MSEC):
726           case(TS_PREC_AUTO_MSEC):
727                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
728                         fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000, MSECS);
729                   break;
730           case(TS_PREC_FIXED_USEC):
731           case(TS_PREC_AUTO_USEC):
732                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
733                         fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000, USECS);
734                   break;
735           case(TS_PREC_FIXED_NSEC):
736           case(TS_PREC_AUTO_NSEC):
737                   display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
738                         fd->del_dis_ts.secs, fd->del_dis_ts.nsecs, NSECS);
739                   break;
740           default:
741                   g_assert_not_reached();
742   }
743   cinfo->col_data[col] = cinfo->col_buf[col];
744   strcpy(cinfo->col_expr[col],"frame.time_delta_displayed");
745   strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
746 }
747
748 /* To do: Add check_col checks to the col_add* routines */
749
750 static void
751 col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
752 {
753   struct tm *tmp;
754   time_t then;
755
756   COL_CHECK_REF_TIME(fd, cinfo, col);
757
758   then = fd->abs_ts.secs;
759   tmp = localtime(&then);
760   if (tmp != NULL) {
761           switch(timestamp_get_precision()) {
762           case(TS_PREC_FIXED_SEC):
763           case(TS_PREC_AUTO_SEC):
764                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
765              "%02d:%02d:%02d",
766              tmp->tm_hour,
767              tmp->tm_min,
768              tmp->tm_sec);
769                   break;
770           case(TS_PREC_FIXED_DSEC):
771           case(TS_PREC_AUTO_DSEC):
772                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
773              "%02d:%02d:%02d.%01ld",
774              tmp->tm_hour,
775              tmp->tm_min,
776              tmp->tm_sec,
777              (long)fd->abs_ts.nsecs / 100000000);
778                   break;
779           case(TS_PREC_FIXED_CSEC):
780           case(TS_PREC_AUTO_CSEC):
781                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
782              "%02d:%02d:%02d.%02ld",
783              tmp->tm_hour,
784              tmp->tm_min,
785              tmp->tm_sec,
786              (long)fd->abs_ts.nsecs / 10000000);
787                   break;
788           case(TS_PREC_FIXED_MSEC):
789           case(TS_PREC_AUTO_MSEC):
790                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
791              "%02d:%02d:%02d.%03ld",
792              tmp->tm_hour,
793              tmp->tm_min,
794              tmp->tm_sec,
795              (long)fd->abs_ts.nsecs / 1000000);
796                   break;
797           case(TS_PREC_FIXED_USEC):
798           case(TS_PREC_AUTO_USEC):
799                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
800              "%02d:%02d:%02d.%06ld",
801              tmp->tm_hour,
802              tmp->tm_min,
803              tmp->tm_sec,
804              (long)fd->abs_ts.nsecs / 1000);
805                   break;
806           case(TS_PREC_FIXED_NSEC):
807           case(TS_PREC_AUTO_NSEC):
808                   g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
809              "%02d:%02d:%02d.%09ld",
810              tmp->tm_hour,
811              tmp->tm_min,
812              tmp->tm_sec,
813              (long)fd->abs_ts.nsecs);
814                   break;
815           default:
816                   g_assert_not_reached();
817           }
818   } else {
819     cinfo->col_buf[col][0] = '\0';
820   }
821   cinfo->col_data[col] = cinfo->col_buf[col];
822   strcpy(cinfo->col_expr[col],"frame.time");
823   strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
824 }
825
826 static void
827 col_set_epoch_time(frame_data *fd, column_info *cinfo, int col)
828 {
829
830   COL_CHECK_REF_TIME(fd, cinfo, col);
831
832   switch(timestamp_get_precision()) {
833           case(TS_PREC_FIXED_SEC):
834           case(TS_PREC_AUTO_SEC):
835                   display_epoch_time(cinfo->col_buf[col], COL_MAX_LEN,
836                         fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, SECS);
837                   break;
838           case(TS_PREC_FIXED_DSEC):
839           case(TS_PREC_AUTO_DSEC):
840                   display_epoch_time(cinfo->col_buf[col], COL_MAX_LEN,
841                         fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, DSECS);
842                   break;
843           case(TS_PREC_FIXED_CSEC):
844           case(TS_PREC_AUTO_CSEC):
845                   display_epoch_time(cinfo->col_buf[col], COL_MAX_LEN,
846                         fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, CSECS);
847                   break;
848           case(TS_PREC_FIXED_MSEC):
849           case(TS_PREC_AUTO_MSEC):
850                   display_epoch_time(cinfo->col_buf[col], COL_MAX_LEN,
851                         fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, MSECS);
852                   break;
853           case(TS_PREC_FIXED_USEC):
854           case(TS_PREC_AUTO_USEC):
855                   display_epoch_time(cinfo->col_buf[col], COL_MAX_LEN,
856                         fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, USECS);
857                   break;
858           case(TS_PREC_FIXED_NSEC):
859           case(TS_PREC_AUTO_NSEC):
860                   display_epoch_time(cinfo->col_buf[col], COL_MAX_LEN,
861                         fd->abs_ts.secs, fd->abs_ts.nsecs, NSECS);
862                   break;
863           default:
864                   g_assert_not_reached();
865   }
866   cinfo->col_data[col] = cinfo->col_buf[col];
867   strcpy(cinfo->col_expr[col],"frame.time_delta");
868   strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
869 }
870 /* Set the format of the variable time format.
871    XXX - this is called from "file.c" when the user changes the time
872    format they want for "command-line-specified" time; it's a bit ugly
873    that we have to export it, but if we go to a CList-like widget that
874    invokes callbacks to get the text for the columns rather than
875    requiring us to stuff the text into the widget from outside, we
876    might be able to clean this up. */
877 void
878 col_set_cls_time(frame_data *fd, column_info *cinfo, gint col)
879 {
880   switch (timestamp_get_type()) {
881     case TS_ABSOLUTE:
882       col_set_abs_time(fd, cinfo, col);
883       break;
884
885     case TS_ABSOLUTE_WITH_DATE:
886       col_set_abs_date_time(fd, cinfo, col);
887       break;
888
889     case TS_RELATIVE:
890       col_set_rel_time(fd, cinfo, col);
891       break;
892
893     case TS_DELTA:
894       col_set_delta_time(fd, cinfo, col);
895       break;
896
897     case TS_DELTA_DIS:
898       col_set_delta_time_dis(fd, cinfo, col);
899       break;
900
901     case TS_EPOCH:
902       col_set_epoch_time(fd, cinfo, col);
903       break;
904
905     case TS_NOT_SET:
906         /* code is missing for this case, but I don't know which [jmayer20051219] */
907         g_assert(FALSE);
908         break;
909   }
910 }
911
912 static void
913 col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res,
914              gboolean is_src)
915 {
916   struct e_in6_addr ipv6_addr;
917
918   pinfo->cinfo->col_expr[col][0] = '\0';
919   pinfo->cinfo->col_expr_val[col][0] = '\0';
920   
921   if (addr->type == AT_NONE)
922     return;     /* no address, nothing to do */
923   
924   if (is_res) {
925     get_addr_name_buf(addr, pinfo->cinfo->col_buf[col],COL_MAX_LEN-1);
926   } else {
927     switch (addr->type) {
928
929     case AT_STRINGZ:
930       /* XXX - should be done in "address_to_str_buf()", but that routine
931          doesn't know COL_MAX_LEN; it should be changed to take the
932          maximum length as an argument. */
933       strncpy(pinfo->cinfo->col_buf[col], addr->data, COL_MAX_LEN);
934       pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
935       break;
936
937     default:
938       address_to_str_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN);
939       break;
940     }
941   }
942   pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
943
944   switch (addr->type) {
945
946   case AT_ETHER:
947     if (is_src)
948       strcpy(pinfo->cinfo->col_expr[col], "eth.src");
949     else
950       strcpy(pinfo->cinfo->col_expr[col], "eth.dst");
951     strncpy(pinfo->cinfo->col_expr_val[col], ether_to_str(addr->data), COL_MAX_LEN);
952     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
953     break;
954
955   case AT_IPv4:
956     if (is_src)
957       strcpy(pinfo->cinfo->col_expr[col], "ip.src");
958     else
959       strcpy(pinfo->cinfo->col_expr[col], "ip.dst");
960     strncpy(pinfo->cinfo->col_expr_val[col], ip_to_str(addr->data), COL_MAX_LEN);
961     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
962     break;
963
964   case AT_IPv6:
965     if (is_src)
966       strcpy(pinfo->cinfo->col_expr[col], "ipv6.src");
967     else
968       strcpy(pinfo->cinfo->col_expr[col], "ipv6.dst");
969     strncpy(pinfo->cinfo->col_expr_val[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN);
970     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
971     break;
972
973   case AT_ATALK:
974     if (is_src)
975       strcpy(pinfo->cinfo->col_expr[col], "ddp.src");
976     else
977       strcpy(pinfo->cinfo->col_expr[col], "ddp.dst");
978     strcpy(pinfo->cinfo->col_expr_val[col], pinfo->cinfo->col_buf[col]);
979     break;
980
981   case AT_ARCNET:
982     if (is_src)
983       strcpy(pinfo->cinfo->col_expr[col], "arcnet.src");
984     else
985       strcpy(pinfo->cinfo->col_expr[col], "arcnet.dst");
986     strcpy(pinfo->cinfo->col_expr_val[col], pinfo->cinfo->col_buf[col]);
987     break;
988
989   default:
990     break;
991   }
992 }
993
994 static void
995 col_set_port(packet_info *pinfo, int col, gboolean is_res, gboolean is_src)
996 {
997   guint32 port;
998
999   if (is_src)
1000     port = pinfo->srcport;
1001   else
1002     port = pinfo->destport;
1003   pinfo->cinfo->col_expr[col][0] = '\0';
1004   pinfo->cinfo->col_expr_val[col][0] = '\0';
1005   switch (pinfo->ptype) {
1006
1007   case PT_SCTP:
1008     if (is_res)
1009       strncpy(pinfo->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
1010     else
1011       g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
1012     break;
1013
1014   case PT_TCP:
1015     if (is_res)
1016       strncpy(pinfo->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
1017     else
1018       g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
1019     if (is_src)
1020       strcpy(pinfo->cinfo->col_expr[col], "tcp.srcport");
1021     else
1022       strcpy(pinfo->cinfo->col_expr[col], "tcp.dstport");
1023     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
1024     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1025     break;
1026
1027   case PT_UDP:
1028     if (is_res)
1029       strncpy(pinfo->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
1030     else
1031       g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
1032     if (is_src)
1033       strcpy(pinfo->cinfo->col_expr[col], "udp.srcport");
1034     else
1035       strcpy(pinfo->cinfo->col_expr[col], "udp.dstport");
1036     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
1037     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1038     break;
1039
1040   case PT_DDP:
1041     if (is_src)
1042       strcpy(pinfo->cinfo->col_expr[col], "ddp.src_socket");
1043     else
1044       strcpy(pinfo->cinfo->col_expr[col], "ddp.dst_socket");
1045     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
1046     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", port);
1047     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1048     break;
1049
1050   case PT_IPX:
1051     /* XXX - resolve IPX socket numbers */
1052     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1053     if (is_src)
1054       strcpy(pinfo->cinfo->col_expr[col], "ipx.src.socket");
1055     else
1056       strcpy(pinfo->cinfo->col_expr[col], "ipx.dst.socket");
1057     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
1058     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1059     break;
1060
1061   case PT_IDP:
1062     /* XXX - resolve IDP socket numbers */
1063     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port);
1064     if (is_src)
1065       strcpy(pinfo->cinfo->col_expr[col], "idp.src.socket");
1066     else
1067       strcpy(pinfo->cinfo->col_expr[col], "idp.dst.socket");
1068     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%04x", port);
1069     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1070     break;
1071
1072   case PT_USB:
1073     /* XXX - resolve USB endpoint numbers */
1074     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port);
1075     if (is_src)
1076       strcpy(pinfo->cinfo->col_expr[col], "usb.src.endpoint");
1077     else
1078       strcpy(pinfo->cinfo->col_expr[col], "usb.dst.endpoint");
1079     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "0x%08x", port);
1080     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1081     break;
1082
1083   default:
1084     break;
1085   }
1086   pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
1087   pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1088 }
1089
1090 /*
1091  * XXX - this should be in some common code in the epan directory, shared
1092  * by this code and packet-isdn.c.
1093  */
1094 static const value_string channel_vals[] = {
1095         { 0,    "D" },
1096         { 1,    "B1" },
1097         { 2,    "B2" },
1098         { 3,    "B3" },
1099         { 4,    "B4" },
1100         { 5,    "B5" },
1101         { 6,    "B6" },
1102         { 7,    "B7" },
1103         { 8,    "B8" },
1104         { 9,    "B9" },
1105         { 10,   "B10" },
1106         { 11,   "B11" },
1107         { 12,   "B12" },
1108         { 13,   "B13" },
1109         { 14,   "B14" },
1110         { 15,   "B15" },
1111         { 16,   "B16" },
1112         { 17,   "B17" },
1113         { 18,   "B19" },
1114         { 19,   "B19" },
1115         { 20,   "B20" },
1116         { 21,   "B21" },
1117         { 22,   "B22" },
1118         { 23,   "B23" },
1119         { 24,   "B24" },
1120         { 25,   "B25" },
1121         { 26,   "B26" },
1122         { 27,   "B27" },
1123         { 28,   "B29" },
1124         { 29,   "B29" },
1125         { 30,   "B30" },
1126         { 0,    NULL }
1127 };
1128
1129 static void
1130 col_set_circuit_id(packet_info *pinfo, int col)
1131 {
1132   pinfo->cinfo->col_expr[col][0] = '\0';
1133   pinfo->cinfo->col_expr_val[col][0] = '\0';
1134   switch (pinfo->ctype) {
1135
1136   case CT_DLCI:
1137     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1138     strcpy(pinfo->cinfo->col_expr[col], "fr.dlci");
1139     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1140     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1141     break;
1142
1143   case CT_ISDN:
1144     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%s",
1145              val_to_str(pinfo->circuit_id, channel_vals, "Unknown (%u)"));
1146     strcpy(pinfo->cinfo->col_expr[col], "isdn.channel");
1147     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1148     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1149     break;
1150
1151   case CT_X25:
1152     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1153     break;
1154
1155   case CT_ISUP:
1156     g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1157     strcpy(pinfo->cinfo->col_expr[col], "isup.cic");
1158     g_snprintf(pinfo->cinfo->col_expr_val[col], COL_MAX_LEN, "%u", pinfo->circuit_id);
1159     pinfo->cinfo->col_expr_val[col][COL_MAX_LEN - 1] = '\0';
1160     break;
1161
1162   default:
1163     break;
1164   }
1165   pinfo->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
1166   pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col];
1167 }
1168
1169 void
1170 col_fill_in(packet_info *pinfo)
1171 {
1172   int i;
1173
1174   for (i = 0; i < pinfo->cinfo->num_cols; i++) {
1175     switch (pinfo->cinfo->col_fmt[i]) {
1176
1177     case COL_NUMBER:
1178       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->num);
1179       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1180       strcpy(pinfo->cinfo->col_expr[i], "frame.number");
1181       strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]);
1182       break;
1183
1184     case COL_CLS_TIME:
1185        col_set_cls_time(pinfo->fd, pinfo->cinfo, i);
1186       break;
1187
1188     case COL_ABS_TIME:
1189       col_set_abs_time(pinfo->fd, pinfo->cinfo, i);
1190       break;
1191
1192     case COL_ABS_DATE_TIME:
1193       col_set_abs_date_time(pinfo->fd, pinfo->cinfo, i);
1194       break;
1195
1196     case COL_REL_TIME:
1197       col_set_rel_time(pinfo->fd, pinfo->cinfo, i);
1198       break;
1199
1200     case COL_DELTA_TIME:
1201       col_set_delta_time(pinfo->fd, pinfo->cinfo, i);
1202       break;
1203
1204     case COL_DELTA_TIME_DIS:
1205       col_set_delta_time_dis(pinfo->fd, pinfo->cinfo, i);
1206       break;
1207
1208     case COL_DEF_SRC:
1209     case COL_RES_SRC:   /* COL_DEF_SRC is currently just like COL_RES_SRC */
1210       col_set_addr(pinfo, i, &pinfo->src, TRUE, TRUE);
1211       break;
1212
1213     case COL_UNRES_SRC:
1214       col_set_addr(pinfo, i, &pinfo->src, FALSE, TRUE);
1215       break;
1216
1217     case COL_DEF_DL_SRC:
1218     case COL_RES_DL_SRC:
1219       col_set_addr(pinfo, i, &pinfo->dl_src, TRUE, TRUE);
1220       break;
1221
1222     case COL_UNRES_DL_SRC:
1223       col_set_addr(pinfo, i, &pinfo->dl_src, FALSE, TRUE);
1224       break;
1225
1226     case COL_DEF_NET_SRC:
1227     case COL_RES_NET_SRC:
1228       col_set_addr(pinfo, i, &pinfo->net_src, TRUE, TRUE);
1229       break;
1230
1231     case COL_UNRES_NET_SRC:
1232       col_set_addr(pinfo, i, &pinfo->net_src, FALSE, TRUE);
1233       break;
1234
1235     case COL_DEF_DST:
1236     case COL_RES_DST:   /* COL_DEF_DST is currently just like COL_RES_DST */
1237       col_set_addr(pinfo, i, &pinfo->dst, TRUE, FALSE);
1238       break;
1239
1240     case COL_UNRES_DST:
1241       col_set_addr(pinfo, i, &pinfo->dst, FALSE, FALSE);
1242       break;
1243
1244     case COL_DEF_DL_DST:
1245     case COL_RES_DL_DST:
1246       col_set_addr(pinfo, i, &pinfo->dl_dst, TRUE, FALSE);
1247       break;
1248
1249     case COL_UNRES_DL_DST:
1250       col_set_addr(pinfo, i, &pinfo->dl_dst, FALSE, FALSE);
1251       break;
1252
1253     case COL_DEF_NET_DST:
1254     case COL_RES_NET_DST:
1255       col_set_addr(pinfo, i, &pinfo->net_dst, TRUE, FALSE);
1256       break;
1257
1258     case COL_UNRES_NET_DST:
1259       col_set_addr(pinfo, i, &pinfo->net_dst, FALSE, FALSE);
1260       break;
1261
1262     case COL_DEF_SRC_PORT:
1263     case COL_RES_SRC_PORT:      /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
1264       col_set_port(pinfo, i, TRUE, TRUE);
1265       break;
1266
1267     case COL_UNRES_SRC_PORT:
1268       col_set_port(pinfo, i, FALSE, TRUE);
1269       break;
1270
1271     case COL_DEF_DST_PORT:
1272     case COL_RES_DST_PORT:      /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
1273       col_set_port(pinfo, i, TRUE, FALSE);
1274       break;
1275
1276     case COL_UNRES_DST_PORT:
1277       col_set_port(pinfo, i, FALSE, FALSE);
1278       break;
1279
1280     case COL_PROTOCOL:  /* currently done by dissectors */
1281     case COL_INFO:      /* currently done by dissectors */
1282       break;
1283
1284     case COL_PACKET_LENGTH:
1285       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->pkt_len);
1286       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1287       strcpy(pinfo->cinfo->col_expr[i], "frame.pkt_len");
1288       strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]);
1289       break;
1290
1291     case COL_CUMULATIVE_BYTES:
1292       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->cum_bytes);
1293       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1294       break;
1295
1296     case COL_OXID:
1297       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->oxid);
1298       pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1299       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1300       break;
1301
1302     case COL_RXID:
1303       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->rxid);
1304       pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1305       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1306       break;
1307
1308     case COL_IF_DIR:    /* currently done by dissectors */
1309       break;
1310
1311     case COL_CIRCUIT_ID:
1312       col_set_circuit_id(pinfo, i);
1313       break;
1314
1315     case COL_SRCIDX:
1316       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->src_idx);
1317       pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1318       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1319       break;
1320
1321     case COL_DSTIDX:
1322       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->dst_idx);
1323       pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1324       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1325       break;
1326
1327     case COL_VSAN:
1328       g_snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->vsan);
1329       pinfo->cinfo->col_buf[i][COL_MAX_LEN - 1] = '\0';
1330       pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i];
1331       break;
1332         
1333     case COL_HPUX_SUBSYS: /* done by nettl disector */
1334     case COL_HPUX_DEVID:  /* done by nettl disector */
1335       break;
1336         
1337     case COL_DCE_CALL:  /* done by dcerpc */
1338       break;
1339
1340     case COL_DCE_CTX:   /* done by dcerpc */
1341       break;
1342
1343     case COL_8021Q_VLAN_ID:
1344         break;
1345     
1346     case COL_DSCP_VALUE:        /* done by packet-ip.c */
1347         break;
1348
1349     case COL_COS_VALUE:         /* done by packet-vlan.c */
1350         break;
1351
1352     case COL_FR_DLCI:   /* done by packet-fr.c */
1353     case COL_BSSGP_TLLI: /* done by packet-bssgp.c */
1354         break;
1355
1356     case NUM_COL_FMTS:  /* keep compiler happy - shouldn't get here */
1357       g_assert_not_reached();
1358       break;
1359     }
1360   }
1361 }