Update to V9.0.0 (2009-12)
[obnox/wireshark/wip.git] / rawshark.c
index ca61afe0a13e97a38139bdb346554f7722962edc..9b99b3a92b40686469b4a024a9f1e9f2c61caadb 100644 (file)
 #include "strerror.h"
 #endif
 
-#ifdef NEED_GETOPT_H
-#include "getopt.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "wsgetopt.h"
 #endif
 
 #include <glib.h>
  */
 static const gchar decode_as_arg_template[] = "<layer_type>==<selector>,<decode_as_protocol>";
 
-static guint32 cum_bytes = 0;
+static guint32 cum_bytes;
 static nstime_t first_ts;
 static nstime_t prev_dis_ts;
 static nstime_t prev_cap_ts;
@@ -428,7 +430,6 @@ main(int argc, char *argv[])
 {
   char                *init_progfile_dir_error;
   int                  opt, i;
-  extern char         *optarg;
   gboolean             arg_error = FALSE;
 
 #ifdef _WIN32
@@ -580,7 +581,7 @@ main(int argc, char *argv[])
   load_wpcap();
 #endif
 
-  init_cap_file(&cfile);
+  cap_file_init(&cfile);
 
   /* Print format defaults to this. */
   print_format = PR_FMT_TEXT;
@@ -902,7 +903,6 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, gchar **err_info,
     ptr += bytes_read;
   }
 
-  bytes_read = 0;
   phdr->ts.secs = hdr.ts_sec;
   phdr->ts.nsecs = hdr.ts_usec * 1000;
   phdr->caplen = bytes_needed = hdr.incl_len;
@@ -1021,8 +1021,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
   /* If we're going to print packet information, or we're going to
      run a read filter, or we're going to process taps, set up to
      do a dissection and do so. */
-  frame_data_init(&fdata, cf->count, &cf->elapsed_time, whdr, offset,
-                  &cum_bytes, &first_ts, &prev_dis_ts, &prev_cap_ts);
+  frame_data_init(&fdata, cf->count, whdr, offset, cum_bytes);
 
   passed = TRUE;
   create_proto_tree = TRUE;
@@ -1042,7 +1041,10 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
 
   tap_queue_init(&edt);
 
-  printf("%lu", (unsigned long int)cf->count);
+  printf("%lu", (unsigned long int) cf->count);
+
+  frame_data_set_before_dissect(&fdata, &cf->elapsed_time,
+                                &first_ts, &prev_dis_ts, &prev_cap_ts);
 
   /* We only need the columns if we're printing packet info but we're
      *not* verbose; in verbose mode, we print the protocol tree, not
@@ -1051,6 +1053,8 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
 
   tap_push_tapped_queue(&edt);
 
+  frame_data_set_after_dissect(&fdata, &cum_bytes, &prev_dis_ts);
+
   for(i = 0; i < n_rfilters; i++) {
     /* Run the read filter if we have one. */
     if (rfcodes[i])
@@ -1185,7 +1189,19 @@ char* ftenum_to_string(header_field_info *hfi)
        };
 }
 
-char* base_display_e_to_string(base_display_e bd)
+static char* absolute_time_display_e_to_string(absolute_time_display_e atd)
+{
+       switch(atd) {
+       case ABSOLUTE_TIME_LOCAL:
+                       return "ABSOLUTE_TIME_LOCAL";
+       case ABSOLUTE_TIME_UTC:
+                       return "ABSOLUTE_TIME_UTC";
+       default:
+                       return "n.a.";
+       }
+}
+
+static char* base_display_e_to_string(base_display_e bd)
 {
        switch(bd) {
        case BASE_NONE:
@@ -1369,10 +1385,23 @@ protocolinfo_init(char *field)
                exit(1);
        }
 
-       printf("%u %s %s - ",
-               g_cmd_line_index,
-               ftenum_to_string(hfi),
-               base_display_e_to_string(hfi->display));
+       switch (hfi->type) {
+
+       case FT_ABSOLUTE_TIME:
+               printf("%u %s %s - ",
+                       g_cmd_line_index,
+                       ftenum_to_string(hfi),
+                       absolute_time_display_e_to_string(hfi->display));
+               break;
+               break;
+
+       default:
+               printf("%u %s %s - ",
+                       g_cmd_line_index,
+                       ftenum_to_string(hfi),
+                       base_display_e_to_string(hfi->display));
+               break;
+       }
 
        rs=g_malloc(sizeof(pci_t));
        rs->hf_index=hfi->id;