Allow wtap_read() and wtap_seek_read() to return non-packet records.
authorGuy Harris <guy@alum.mit.edu>
Fri, 23 May 2014 03:01:31 +0000 (20:01 -0700)
committerGuy Harris <guy@alum.mit.edu>
Fri, 23 May 2014 03:02:32 +0000 (03:02 +0000)
This is the first step towards implementing the mechanisms requestd in
bug 8590; currently, we don't return any records other than packet
records from libwiretap, and just ignore non-packet records in the rest
of Wireshark, but this at least gets the ball rolling.

Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574
Reviewed-on: https://code.wireshark.org/review/1736
Reviewed-by: Guy Harris <guy@alum.mit.edu>
78 files changed:
capinfos.c
capture.c
capture_info.c
capture_info.h
capture_sync.c
capture_sync.h
editcap.c
file.c
file.h
frame_tvbuff.c
proto_hier_stats.c
reordercap.c
tfshark.c
tshark.c
ui/gtk/capture_file_dlg.c
ui/gtk/iax2_analysis.c
ui/gtk/main.c
ui/gtk/packet_list_store.c
ui/gtk/packet_win.c
ui/gtk/rlc_lte_graph.c
ui/gtk/rtp_analysis.c
ui/gtk/sctp_assoc_analyse.c
ui/qt/capture_file_dialog.cpp
ui/qt/packet_list.cpp
ui/qt/packet_list_model.cpp
ui/tap-tcp-stream.c
ui/win32/file_dlg_win32.c
wiretap/5views.c
wiretap/aethra.c
wiretap/ascendtext.c
wiretap/ber.c
wiretap/btsnoop.c
wiretap/camins.c
wiretap/catapult_dct2000.c
wiretap/commview.c
wiretap/cosine.c
wiretap/csids.c
wiretap/daintree-sna.c
wiretap/dbs-etherwatch.c
wiretap/dct3trace.c
wiretap/erf.c
wiretap/eyesdn.c
wiretap/hcidump.c
wiretap/i4btrace.c
wiretap/ipfix.c
wiretap/iptrace.c
wiretap/iseries.c
wiretap/k12.c
wiretap/k12text.l
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/logcat.c
wiretap/mime_file.c
wiretap/mp2t.c
wiretap/mpeg.c
wiretap/netmon.c
wiretap/netscaler.c
wiretap/netscreen.c
wiretap/nettl.c
wiretap/network_instruments.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/packetlogger.c
wiretap/pcapng.c
wiretap/peekclassic.c
wiretap/peektagged.c
wiretap/pppdump.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/stanag4607.c
wiretap/tnef.c
wiretap/toshiba.c
wiretap/visual.c
wiretap/vms.c
wiretap/vwr.c
wiretap/wtap-int.h
wiretap/wtap.c
wiretap/wtap.h

index bad557e2ddad8cc001d9cf864e96ec933ef08bfa..a24a6ae5a203910c5fc140a9a02fcd75cf83fad2 100644 (file)
@@ -803,6 +803,7 @@ static int
 process_cap_file(wtap *wth, const char *filename)
 {
   int                   status = 0;
+  int                   rec_type;
   int                   err;
   gchar                *err_info;
   gint64                size;
@@ -828,51 +829,53 @@ process_cap_file(wtap *wth, const char *filename)
   cf_info.encap_counts = g_new0(int,WTAP_NUM_ENCAP_TYPES);
 
   /* Tally up data that we need to parse through the file to find */
-  while (wtap_read(wth, &err, &err_info, &data_offset))  {
-    phdr = wtap_phdr(wth);
-    if (phdr->presence_flags & WTAP_HAS_TS) {
-      prev_time = cur_time;
-      cur_time = nstime_to_sec(&phdr->ts);
-      if (packet == 0) {
-        start_time = cur_time;
-        stop_time  = cur_time;
-        prev_time  = cur_time;
-      }
-      if (cur_time < prev_time) {
-        order = NOT_IN_ORDER;
-      }
-      if (cur_time < start_time) {
-        start_time = cur_time;
-      }
-      if (cur_time > stop_time) {
-        stop_time = cur_time;
+  while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1)  {
+    if (rec_type == REC_TYPE_PACKET) {
+      phdr = wtap_phdr(wth);
+      if (phdr->presence_flags & WTAP_HAS_TS) {
+        prev_time = cur_time;
+        cur_time = nstime_to_sec(&phdr->ts);
+        if (packet == 0) {
+          start_time = cur_time;
+          stop_time  = cur_time;
+          prev_time  = cur_time;
+        }
+        if (cur_time < prev_time) {
+          order = NOT_IN_ORDER;
+        }
+        if (cur_time < start_time) {
+          start_time = cur_time;
+        }
+        if (cur_time > stop_time) {
+          stop_time = cur_time;
+        }
+      } else {
+        have_times = FALSE; /* at least one packet has no time stamp */
+        if (order != NOT_IN_ORDER)
+          order = ORDER_UNKNOWN;
       }
-    } else {
-      have_times = FALSE; /* at least one packet has no time stamp */
-      if (order != NOT_IN_ORDER)
-        order = ORDER_UNKNOWN;
-    }
 
-    bytes+=phdr->len;
-    packet++;
-
-    /* If caplen < len for a rcd, then presumably           */
-    /* 'Limit packet capture length' was done for this rcd. */
-    /* Keep track as to the min/max actual snapshot lengths */
-    /*  seen for this file.                                 */
-    if (phdr->caplen < phdr->len) {
-      if (phdr->caplen < snaplen_min_inferred)
-        snaplen_min_inferred = phdr->caplen;
-      if (phdr->caplen > snaplen_max_inferred)
-        snaplen_max_inferred = phdr->caplen;
-    }
+      bytes+=phdr->len;
+      packet++;
+
+      /* If caplen < len for a rcd, then presumably           */
+      /* 'Limit packet capture length' was done for this rcd. */
+      /* Keep track as to the min/max actual snapshot lengths */
+      /*  seen for this file.                                 */
+      if (phdr->caplen < phdr->len) {
+        if (phdr->caplen < snaplen_min_inferred)
+          snaplen_min_inferred = phdr->caplen;
+        if (phdr->caplen > snaplen_max_inferred)
+          snaplen_max_inferred = phdr->caplen;
+      }
 
-    /* Per-packet encapsulation */
-    if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
-      if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
-        cf_info.encap_counts[phdr->pkt_encap] += 1;
-      } else {
-        fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
+      /* Per-packet encapsulation */
+      if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
+        if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
+          cf_info.encap_counts[phdr->pkt_encap] += 1;
+        } else {
+          fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
+        }
       }
     }
 
index c308727096c309d9603e90e586be0586918263d8..c7f9ebf99505fb1d4a4285989b7ea293c23b3412 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -390,9 +390,9 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
 }
 
 
-/* capture child tells us we have new packets to read */
+/* capture child tells us we have new records to read */
 void
-capture_input_new_packets(capture_session *cap_session, int to_read)
+capture_input_new_records(capture_session *cap_session, int to_read)
 {
   capture_options *capture_opts = cap_session->capture_opts;
   int  err;
@@ -435,7 +435,7 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
 #endif
 
   if(capture_opts->show_info)
-    capture_info_new_packets(to_read);
+    capture_info_new_records(to_read);
 }
 
 
index 3ef12df504da1434b085c0c260045a5996d48e40..c3c232816c27d9ccaed1f645c5bc14fda2417d67 100644 (file)
@@ -232,9 +232,11 @@ gboolean capture_info_new_file(const char *new_filename)
 }
 
 
-/* new packets arrived */
-void capture_info_new_packets(int to_read)
+/* new records arrived */
+void capture_info_new_records(int to_read)
 {
+    int rec_type;
+    int packets_read = 0;
     int err;
     gchar *err_info;
     gint64 data_offset;
@@ -244,25 +246,27 @@ void capture_info_new_packets(int to_read)
     const guchar *buf;
 
 
-    info_data.ui.new_packets = to_read;
-
     /*g_warning("new packets: %u", to_read);*/
 
     while (to_read > 0) {
         wtap_cleareof(info_data.wtap);
-        if (wtap_read(info_data.wtap, &err, &err_info, &data_offset)) {
-            phdr = wtap_phdr(info_data.wtap);
-            pseudo_header = &phdr->pseudo_header;
-            wtap_linktype = phdr->pkt_encap;
-            buf = wtap_buf_ptr(info_data.wtap);
+        if ((rec_type = wtap_read(info_data.wtap, &err, &err_info, &data_offset)) != -1) {
+            if (rec_type == REC_TYPE_PACKET) {
+                phdr = wtap_phdr(info_data.wtap);
+                pseudo_header = &phdr->pseudo_header;
+                wtap_linktype = phdr->pkt_encap;
+                buf = wtap_buf_ptr(info_data.wtap);
 
-            capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
+                capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
+                packets_read++;
 
-            /*g_warning("new packet");*/
+                /*g_warning("new packet");*/
+            }
             to_read--;
         }
     }
 
+    info_data.ui.new_packets = packets_read;
     capture_info_ui_update(&info_data.ui);
 }
 
index 3e5845ac6cf9a6f54f9434799517f9847bd544d2..286dce12c09b36cbf996eff67b7445e467f87787 100644 (file)
@@ -43,8 +43,8 @@ extern void capture_info_open(capture_session *cap_session);
 /* new file arrived - (eventually close old wtap), open wtap */
 extern gboolean capture_info_new_file(const char *new_filename);
 
-/* new packets arrived - read from wtap, count */
-extern void capture_info_new_packets(int to_read);
+/* new records arrived - read from wtap, count */
+extern void capture_info_new_records(int to_read);
 
 /* close the info - close wtap, destroy dialog */
 extern void capture_info_close(void);
index 2f9d2cc62ef37e706a69407b914e820946d99a03..0b374e877c296633657fa647434dc2f88ca24472 100644 (file)
@@ -1776,7 +1776,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
     case SP_PACKET_COUNT:
         npackets = atoi(buffer);
         g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
-        capture_input_new_packets(cap_session, npackets);
+        capture_input_new_records(cap_session, npackets);
         break;
     case SP_ERROR_MSG:
         /* convert primary message */
index 2c4bb639af5bd1dfd5579b34bff42058de1a999b..27326905730ab819dd9919bce5f1702021dd5643 100644 (file)
@@ -99,10 +99,10 @@ extern gboolean
 capture_input_new_file(capture_session *cap_session, gchar *new_file);
 
 /**
- * Capture child told us we have new packets to read.
+ * Capture child told us we have new records to read.
  */
 extern void
-capture_input_new_packets(capture_session *cap_session, int to_read);
+capture_input_new_records(capture_session *cap_session, int to_read);
 
 /**
  * Capture child told us how many dropped packets it counted.
index 70dfd0859a73aaa4c7c5d6085c18c59416915b87..415e2e481e453115a445e5e417f9a504cc3a5429 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -842,7 +842,7 @@ main(int argc, char *argv[])
     int           i, j, err;
     gchar        *err_info;
     int           opt;
-
+    int           rec_type;
     char         *p;
     guint32       snaplen            = 0; /* No limit               */
     chop_t        chop               = {0, 0, 0, 0, 0, 0}; /* No chop */
@@ -1192,60 +1192,30 @@ main(int argc, char *argv[])
             }
         }
 
-        while (wtap_read(wth, &err, &err_info, &data_offset)) {
-            read_count++;
-
-            phdr = wtap_phdr(wth);
-            buf = wtap_buf_ptr(wth);
-
-            if (nstime_is_unset(&block_start)) {  /* should only be the first packet */
-                block_start.secs = phdr->ts.secs;
-                block_start.nsecs = phdr->ts.nsecs;
-
-                if (split_packet_count > 0 || secs_per_block > 0) {
-                    if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
-                        exit(2);
-
-                    filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
-                } else {
-                    filename = g_strdup(argv[optind+1]);
-                }
+        while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
+            if (rec_type == REC_TYPE_PACKET) {
+                read_count++;
 
-                /* If we don't have an application name add Editcap */
-                if (shb_hdr->shb_user_appl == NULL) {
-                    shb_hdr->shb_user_appl = "Editcap " VERSION;
-                }
-
-                pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
-                                        snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
-                                        FALSE /* compressed */, shb_hdr, idb_inf, &err);
-
-                if (pdh == NULL) {
-                    fprintf(stderr, "editcap: Can't open or create %s: %s\n",
-                            filename, wtap_strerror(err));
-                    exit(2);
-                }
-            }
+                phdr = wtap_phdr(wth);
+                buf = wtap_buf_ptr(wth);
 
-            g_assert(filename);
+                if (nstime_is_unset(&block_start)) {  /* should only be the first packet */
+                    block_start.secs = phdr->ts.secs;
+                    block_start.nsecs = phdr->ts.nsecs;
 
-            if (secs_per_block > 0) {
-                while ((phdr->ts.secs - block_start.secs >  secs_per_block)
-                       || (phdr->ts.secs - block_start.secs == secs_per_block
-                           && phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
+                    if (split_packet_count > 0 || secs_per_block > 0) {
+                        if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
+                            exit(2);
 
-                    if (!wtap_dump_close(pdh, &err)) {
-                        fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                                filename, wtap_strerror(err));
-                        exit(2);
+                        filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
+                    } else {
+                        filename = g_strdup(argv[optind+1]);
                     }
-                    block_start.secs = block_start.secs +  secs_per_block; /* reset for next interval */
-                    g_free(filename);
-                    filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
-                    g_assert(filename);
 
-                    if (verbose)
-                        fprintf(stderr, "Continuing writing in file %s\n", filename);
+                    /* If we don't have an application name add Editcap */
+                    if (shb_hdr->shb_user_appl == NULL) {
+                        shb_hdr->shb_user_appl = "Editcap " VERSION;
+                    }
 
                     pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
                                             snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
@@ -1257,89 +1227,138 @@ main(int argc, char *argv[])
                         exit(2);
                     }
                 }
-            }
-
-            if (split_packet_count > 0) {
-                /* time for the next file? */
-                if (written_count > 0 && written_count % split_packet_count == 0) {
-                    if (!wtap_dump_close(pdh, &err)) {
-                        fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                                filename, wtap_strerror(err));
-                        exit(2);
-                    }
 
-                    g_free(filename);
-                    filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
-                    g_assert(filename);
+                g_assert(filename);
 
-                    if (verbose)
-                        fprintf(stderr, "Continuing writing in file %s\n", filename);
+                if (secs_per_block > 0) {
+                    while ((phdr->ts.secs - block_start.secs >  secs_per_block)
+                           || (phdr->ts.secs - block_start.secs == secs_per_block
+                               && phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
 
-                    pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
-                                            snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
-                                            FALSE /* compressed */, shb_hdr, idb_inf, &err);
-                    if (pdh == NULL) {
-                        fprintf(stderr, "editcap: Can't open or create %s: %s\n",
-                                filename, wtap_strerror(err));
-                        exit(2);
+                        if (!wtap_dump_close(pdh, &err)) {
+                            fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                                    filename, wtap_strerror(err));
+                            exit(2);
+                        }
+                        block_start.secs = block_start.secs +  secs_per_block; /* reset for next interval */
+                        g_free(filename);
+                        filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
+                        g_assert(filename);
+
+                        if (verbose)
+                            fprintf(stderr, "Continuing writing in file %s\n", filename);
+
+                        pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
+                                                snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
+                                                FALSE /* compressed */, shb_hdr, idb_inf, &err);
+
+                        if (pdh == NULL) {
+                            fprintf(stderr, "editcap: Can't open or create %s: %s\n",
+                                    filename, wtap_strerror(err));
+                            exit(2);
+                        }
                     }
                 }
-            }
-
-            if (check_startstop)
-                ts_okay = check_timestamp(wth);
-
-            if (ts_okay && ((!selected(count) && !keep_em)
-                            || (selected(count) && keep_em))) {
 
-                if (verbose && !dup_detect && !dup_detect_by_time)
-                    fprintf(stderr, "Packet: %u\n", count);
+                if (split_packet_count > 0) {
+                    /* time for the next file? */
+                    if (written_count > 0 && written_count % split_packet_count == 0) {
+                        if (!wtap_dump_close(pdh, &err)) {
+                            fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                                    filename, wtap_strerror(err));
+                            exit(2);
+                        }
 
-                /* We simply write it, perhaps after truncating it; we could
-                 * do other things, like modify it. */
+                        g_free(filename);
+                        filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
+                        g_assert(filename);
 
-                phdr = wtap_phdr(wth);
+                        if (verbose)
+                            fprintf(stderr, "Continuing writing in file %s\n", filename);
 
-                if (snaplen != 0) {
-                    if (phdr->caplen > snaplen) {
-                        snap_phdr = *phdr;
-                        snap_phdr.caplen = snaplen;
-                        phdr = &snap_phdr;
-                    }
-                    if (adjlen && phdr->len > snaplen) {
-                        snap_phdr = *phdr;
-                        snap_phdr.len = snaplen;
-                        phdr = &snap_phdr;
+                        pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
+                                                snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
+                                                FALSE /* compressed */, shb_hdr, idb_inf, &err);
+                        if (pdh == NULL) {
+                            fprintf(stderr, "editcap: Can't open or create %s: %s\n",
+                                    filename, wtap_strerror(err));
+                            exit(2);
+                        }
                     }
                 }
 
-                /* CHOP */
-                snap_phdr = *phdr;
-                handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen);
-                phdr = &snap_phdr;
+                if (check_startstop)
+                    ts_okay = check_timestamp(wth);
+
+                if (ts_okay && ((!selected(count) && !keep_em)
+                                || (selected(count) && keep_em))) {
+
+                    if (verbose && !dup_detect && !dup_detect_by_time)
+                        fprintf(stderr, "Packet: %u\n", count);
+
+                    /* We simply write it, perhaps after truncating it; we could
+                     * do other things, like modify it. */
 
-                /* Do we adjust timestamps to ensure strict chronological
-                 * order? */
-                if (do_strict_time_adjustment) {
-                    if (previous_time.secs || previous_time.nsecs) {
-                        if (!strict_time_adj.is_negative) {
-                            nstime_t current;
-                            nstime_t delta;
+                    phdr = wtap_phdr(wth);
 
-                            current.secs = phdr->ts.secs;
-                            current.nsecs = phdr->ts.nsecs;
+                    if (snaplen != 0) {
+                        if (phdr->caplen > snaplen) {
+                            snap_phdr = *phdr;
+                            snap_phdr.caplen = snaplen;
+                            phdr = &snap_phdr;
+                        }
+                        if (adjlen && phdr->len > snaplen) {
+                            snap_phdr = *phdr;
+                            snap_phdr.len = snaplen;
+                            phdr = &snap_phdr;
+                        }
+                    }
 
-                            nstime_delta(&delta, &current, &previous_time);
+                    /* CHOP */
+                    snap_phdr = *phdr;
+                    handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen);
+                    phdr = &snap_phdr;
 
-                            if (delta.secs < 0 || delta.nsecs < 0) {
+                    /* Do we adjust timestamps to ensure strict chronological
+                     * order? */
+                    if (do_strict_time_adjustment) {
+                        if (previous_time.secs || previous_time.nsecs) {
+                            if (!strict_time_adj.is_negative) {
+                                nstime_t current;
+                                nstime_t delta;
+
+                                current.secs = phdr->ts.secs;
+                                current.nsecs = phdr->ts.nsecs;
+
+                                nstime_delta(&delta, &current, &previous_time);
+
+                                if (delta.secs < 0 || delta.nsecs < 0) {
+                                    /*
+                                     * A negative delta indicates that the current packet
+                                     * has an absolute timestamp less than the previous packet
+                                     * that it is being compared to.  This is NOT a normal
+                                     * situation since trace files usually have packets in
+                                     * chronological order (oldest to newest).
+                                     */
+                                    /* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
+                                    snap_phdr = *phdr;
+                                    snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
+                                    snap_phdr.ts.nsecs = previous_time.nsecs;
+                                    if (snap_phdr.ts.nsecs + strict_time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
+                                        /* carry */
+                                        snap_phdr.ts.secs++;
+                                        snap_phdr.ts.nsecs += (strict_time_adj.tv.tv_usec - ONE_MILLION) * 1000;
+                                    } else {
+                                        snap_phdr.ts.nsecs += strict_time_adj.tv.tv_usec * 1000;
+                                    }
+                                    phdr = &snap_phdr;
+                                }
+                            } else {
                                 /*
-                                 * A negative delta indicates that the current packet
-                                 * has an absolute timestamp less than the previous packet
-                                 * that it is being compared to.  This is NOT a normal
-                                 * situation since trace files usually have packets in
-                                 * chronological order (oldest to newest).
+                                 * A negative strict time adjustment is requested.
+                                 * Unconditionally set each timestamp to previous
+                                 * packet's timestamp plus delta.
                                  */
-                                /* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
                                 snap_phdr = *phdr;
                                 snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
                                 snap_phdr.ts.nsecs = previous_time.nsecs;
@@ -1352,207 +1371,190 @@ main(int argc, char *argv[])
                                 }
                                 phdr = &snap_phdr;
                             }
-                        } else {
-                            /*
-                             * A negative strict time adjustment is requested.
-                             * Unconditionally set each timestamp to previous
-                             * packet's timestamp plus delta.
-                             */
-                            snap_phdr = *phdr;
-                            snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
-                            snap_phdr.ts.nsecs = previous_time.nsecs;
-                            if (snap_phdr.ts.nsecs + strict_time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
+                        }
+                        previous_time.secs = phdr->ts.secs;
+                        previous_time.nsecs = phdr->ts.nsecs;
+                    }
+
+                    /* assume that if the frame's tv_sec is 0, then
+                     * the timestamp isn't supported */
+                    if (phdr->ts.secs > 0 && time_adj.tv.tv_sec != 0) {
+                        snap_phdr = *phdr;
+                        if (time_adj.is_negative)
+                            snap_phdr.ts.secs -= time_adj.tv.tv_sec;
+                        else
+                            snap_phdr.ts.secs += time_adj.tv.tv_sec;
+                         phdr = &snap_phdr;
+                    }
+
+                    /* assume that if the frame's tv_sec is 0, then
+                     * the timestamp isn't supported */
+                    if (phdr->ts.secs > 0 && time_adj.tv.tv_usec != 0) {
+                        snap_phdr = *phdr;
+                        if (time_adj.is_negative) { /* subtract */
+                            if (snap_phdr.ts.nsecs/1000 < time_adj.tv.tv_usec) { /* borrow */
+                                snap_phdr.ts.secs--;
+                                snap_phdr.ts.nsecs += ONE_MILLION * 1000;
+                            }
+                            snap_phdr.ts.nsecs -= time_adj.tv.tv_usec * 1000;
+                        } else {                  /* add */
+                            if (snap_phdr.ts.nsecs + time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
                                 /* carry */
                                 snap_phdr.ts.secs++;
-                                snap_phdr.ts.nsecs += (strict_time_adj.tv.tv_usec - ONE_MILLION) * 1000;
+                                snap_phdr.ts.nsecs += (time_adj.tv.tv_usec - ONE_MILLION) * 1000;
                             } else {
-                                snap_phdr.ts.nsecs += strict_time_adj.tv.tv_usec * 1000;
+                                snap_phdr.ts.nsecs += time_adj.tv.tv_usec * 1000;
                             }
-                            phdr = &snap_phdr;
                         }
+                        phdr = &snap_phdr;
                     }
-                    previous_time.secs = phdr->ts.secs;
-                    previous_time.nsecs = phdr->ts.nsecs;
-                }
-
-                /* assume that if the frame's tv_sec is 0, then
-                 * the timestamp isn't supported */
-                if (phdr->ts.secs > 0 && time_adj.tv.tv_sec != 0) {
-                    snap_phdr = *phdr;
-                    if (time_adj.is_negative)
-                        snap_phdr.ts.secs -= time_adj.tv.tv_sec;
-                    else
-                        snap_phdr.ts.secs += time_adj.tv.tv_sec;
-                    phdr = &snap_phdr;
-                }
 
-                /* assume that if the frame's tv_sec is 0, then
-                 * the timestamp isn't supported */
-                if (phdr->ts.secs > 0 && time_adj.tv.tv_usec != 0) {
-                    snap_phdr = *phdr;
-                    if (time_adj.is_negative) { /* subtract */
-                        if (snap_phdr.ts.nsecs/1000 < time_adj.tv.tv_usec) { /* borrow */
-                            snap_phdr.ts.secs--;
-                            snap_phdr.ts.nsecs += ONE_MILLION * 1000;
-                        }
-                        snap_phdr.ts.nsecs -= time_adj.tv.tv_usec * 1000;
-                    } else {                  /* add */
-                        if (snap_phdr.ts.nsecs + time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
-                            /* carry */
-                            snap_phdr.ts.secs++;
-                            snap_phdr.ts.nsecs += (time_adj.tv.tv_usec - ONE_MILLION) * 1000;
+                    /* suppress duplicates by packet window */
+                    if (dup_detect) {
+                        if (is_duplicate(buf, phdr->caplen)) {
+                            if (verbose) {
+                                fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
+                                        count, phdr->caplen);
+                                for (i = 0; i < 16; i++)
+                                    fprintf(stderr, "%02x",
+                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                                fprintf(stderr, "\n");
+                            }
+                            duplicate_count++;
+                            count++;
+                            continue;
                         } else {
-                            snap_phdr.ts.nsecs += time_adj.tv.tv_usec * 1000;
-                        }
-                    }
-                    phdr = &snap_phdr;
-                }
-
-                /* suppress duplicates by packet window */
-                if (dup_detect) {
-                    if (is_duplicate(buf, phdr->caplen)) {
-                        if (verbose) {
-                            fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
-                                    count, phdr->caplen);
-                            for (i = 0; i < 16; i++)
-                                fprintf(stderr, "%02x",
-                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                            fprintf(stderr, "\n");
-                        }
-                        duplicate_count++;
-                        count++;
-                        continue;
-                    } else {
-                        if (verbose) {
-                            fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
-                                    count, phdr->caplen);
-                            for (i = 0; i < 16; i++)
-                                fprintf(stderr, "%02x",
-                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                            fprintf(stderr, "\n");
+                            if (verbose) {
+                                fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
+                                        count, phdr->caplen);
+                                for (i = 0; i < 16; i++)
+                                    fprintf(stderr, "%02x",
+                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                                fprintf(stderr, "\n");
+                            }
                         }
                     }
-                }
 
-                /* suppress duplicates by time window */
-                if (dup_detect_by_time) {
-                    nstime_t current;
-
-                    current.secs  = phdr->ts.secs;
-                    current.nsecs = phdr->ts.nsecs;
-
-                    if (is_duplicate_rel_time(buf, phdr->caplen, &current)) {
-                        if (verbose) {
-                            fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
-                                    count, phdr->caplen);
-                            for (i = 0; i < 16; i++)
-                                fprintf(stderr, "%02x",
-                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                            fprintf(stderr, "\n");
-                        }
-                        duplicate_count++;
-                        count++;
-                        continue;
-                    } else {
-                        if (verbose) {
-                            fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
-                                    count, phdr->caplen);
-                            for (i = 0; i < 16; i++)
-                                fprintf(stderr, "%02x",
-                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                            fprintf(stderr, "\n");
+                    /* suppress duplicates by time window */
+                    if (dup_detect_by_time) {
+                        nstime_t current;
+
+                        current.secs  = phdr->ts.secs;
+                        current.nsecs = phdr->ts.nsecs;
+
+                        if (is_duplicate_rel_time(buf, phdr->caplen, &current)) {
+                            if (verbose) {
+                                fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
+                                        count, phdr->caplen);
+                                for (i = 0; i < 16; i++)
+                                    fprintf(stderr, "%02x",
+                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                                fprintf(stderr, "\n");
+                            }
+                            duplicate_count++;
+                            count++;
+                            continue;
+                        } else {
+                            if (verbose) {
+                                fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
+                                        count, phdr->caplen);
+                                for (i = 0; i < 16; i++)
+                                    fprintf(stderr, "%02x",
+                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                                fprintf(stderr, "\n");
+                            }
                         }
                     }
-                }
 
-                /* Random error mutation */
-                if (err_prob > 0.0) {
-                    int real_data_start = 0;
+                    /* Random error mutation */
+                    if (err_prob > 0.0) {
+                        int real_data_start = 0;
 
-                    /* Protect non-protocol data */
-                    if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
-                        real_data_start = find_dct2000_real_data(buf);
+                        /* Protect non-protocol data */
+                        if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
+                            real_data_start = find_dct2000_real_data(buf);
 
-                    for (i = real_data_start; i < (int) phdr->caplen; i++) {
-                        if (rand() <= err_prob * RAND_MAX) {
-                            err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
+                        for (i = real_data_start; i < (int) phdr->caplen; i++) {
+                            if (rand() <= err_prob * RAND_MAX) {
+                                err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
 
-                            if (err_type < ERR_WT_BIT) {
-                                buf[i] ^= 1 << (rand() / (RAND_MAX / 8 + 1));
-                                err_type = ERR_WT_TOTAL;
-                            } else {
-                                err_type -= ERR_WT_BYTE;
-                            }
+                                if (err_type < ERR_WT_BIT) {
+                                    buf[i] ^= 1 << (rand() / (RAND_MAX / 8 + 1));
+                                    err_type = ERR_WT_TOTAL;
+                                } else {
+                                    err_type -= ERR_WT_BYTE;
+                                }
 
-                            if (err_type < ERR_WT_BYTE) {
-                                buf[i] = rand() / (RAND_MAX / 255 + 1);
-                                err_type = ERR_WT_TOTAL;
-                            } else {
-                                err_type -= ERR_WT_BYTE;
-                            }
+                                if (err_type < ERR_WT_BYTE) {
+                                    buf[i] = rand() / (RAND_MAX / 255 + 1);
+                                    err_type = ERR_WT_TOTAL;
+                                } else {
+                                    err_type -= ERR_WT_BYTE;
+                                }
 
-                            if (err_type < ERR_WT_ALNUM) {
-                                buf[i] = ALNUM_CHARS[rand() / (RAND_MAX / ALNUM_LEN + 1)];
-                                err_type = ERR_WT_TOTAL;
-                            } else {
-                                err_type -= ERR_WT_ALNUM;
-                            }
+                                if (err_type < ERR_WT_ALNUM) {
+                                    buf[i] = ALNUM_CHARS[rand() / (RAND_MAX / ALNUM_LEN + 1)];
+                                    err_type = ERR_WT_TOTAL;
+                                } else {
+                                    err_type -= ERR_WT_ALNUM;
+                                }
 
-                            if (err_type < ERR_WT_FMT) {
-                                if ((unsigned int)i < phdr->caplen - 2)
-                                    g_strlcpy((char*) &buf[i], "%s", 2);
-                                err_type = ERR_WT_TOTAL;
-                            } else {
-                                err_type -= ERR_WT_FMT;
-                            }
+                                if (err_type < ERR_WT_FMT) {
+                                    if ((unsigned int)i < phdr->caplen - 2)
+                                        g_strlcpy((char*) &buf[i], "%s", 2);
+                                    err_type = ERR_WT_TOTAL;
+                                } else {
+                                    err_type -= ERR_WT_FMT;
+                                }
 
-                            if (err_type < ERR_WT_AA) {
-                                for (j = i; j < (int) phdr->caplen; j++)
-                                    buf[j] = 0xAA;
-                                i = phdr->caplen;
+                                if (err_type < ERR_WT_AA) {
+                                    for (j = i; j < (int) phdr->caplen; j++)
+                                        buf[j] = 0xAA;
+                                    i = phdr->caplen;
+                                }
                             }
                         }
                     }
-                }
 
-                if (!wtap_dump(pdh, phdr, buf, &err)) {
-                    switch (err) {
-                    case WTAP_ERR_UNSUPPORTED_ENCAP:
-                        /*
-                         * This is a problem with the particular frame we're
-                         * writing and the file type and subtype we're
-                         * writing; note that, and report the frame number
-                         * and file type/subtype.
-                         */
-                        fprintf(stderr,
-                                "editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.",
-                                read_count, argv[optind],
-                                wtap_file_type_subtype_string(out_file_type_subtype));
-                        break;
-
-                    case WTAP_ERR_PACKET_TOO_LARGE:
-                        /*
-                         * This is a problem with the particular frame we're
-                         * writing and the file type and subtype we're
-                         * writing; note that, and report the frame number
-                         * and file type/subtype.
-                         */
-                        fprintf(stderr,
-                                "editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.",
-                                read_count, argv[optind],
-                                wtap_file_type_subtype_string(out_file_type_subtype));
-                        break;
-
-                    default:
-                        fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                                filename, wtap_strerror(err));
-                        break;
+                    if (!wtap_dump(pdh, phdr, buf, &err)) {
+                        switch (err) {
+                        case WTAP_ERR_UNSUPPORTED_ENCAP:
+                            /*
+                             * This is a problem with the particular frame we're
+                             * writing and the file type and subtype we're
+                             * writing; note that, and report the frame number
+                             * and file type/subtype.
+                             */
+                            fprintf(stderr,
+                                    "editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.",
+                                    read_count, argv[optind],
+                                    wtap_file_type_subtype_string(out_file_type_subtype));
+                            break;
+
+                        case WTAP_ERR_PACKET_TOO_LARGE:
+                            /*
+                             * This is a problem with the particular frame we're
+                             * writing and the file type and subtype we're
+                             * writing; note that, and report the frame number
+                             * and file type/subtype.
+                             */
+                            fprintf(stderr,
+                                    "editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.",
+                                    read_count, argv[optind],
+                                    wtap_file_type_subtype_string(out_file_type_subtype));
+                            break;
+
+                        default:
+                            fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                                    filename, wtap_strerror(err));
+                            break;
+                        }
+                        exit(2);
                     }
-                    exit(2);
+                    written_count++;
                 }
-                written_count++;
+                count++;
             }
-            count++;
         }
 
         g_free(fprefix);
diff --git a/file.c b/file.c
index e75a78d4f9791e0b5c708a0b7cf3b465291a70d1..c54188b550b55c57c70f6415ce7086b78d01cddb 100644 (file)
--- a/file.c
+++ b/file.c
@@ -575,6 +575,7 @@ cf_read(capture_file *cf, gboolean reloading)
 {
   int                  err;
   gchar               *err_info;
+  int                  rec_type;
   gchar               *name_ptr;
   progdlg_t           *progbar        = NULL;
   gboolean             stop_flag;
@@ -651,7 +652,7 @@ cf_read(capture_file *cf, gboolean reloading)
     }else
       progbar_quantum = 0;
 
-    while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
+    while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
       if (size >= 0) {
         count++;
         file_pos = wtap_read_so_far(cf->wth);
@@ -701,7 +702,9 @@ cf_read(capture_file *cf, gboolean reloading)
            hours even on fast machines) just to see that it was the wrong file. */
         break;
       }
-      read_packet(cf, dfcode, &edt, cinfo, data_offset);
+
+      if (rec_type == REC_TYPE_PACKET)
+          read_packet(cf, dfcode, &edt, cinfo, data_offset);
     }
   }
   CATCH(OutOfMemoryError) {
@@ -837,6 +840,7 @@ cf_read(capture_file *cf, gboolean reloading)
 cf_read_status_t
 cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
 {
+  int               rec_type;
   gchar            *err_info;
   volatile int      newly_displayed_packets = 0;
   dfilter_t        *dfcode;
@@ -875,7 +879,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
 
     while (to_read != 0) {
       wtap_cleareof(cf->wth);
-      if (!wtap_read(cf->wth, err, &err_info, &data_offset)) {
+      if ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) == -1) {
         break;
       }
       if (cf->state == FILE_READ_ABORTED) {
@@ -884,8 +888,10 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
            aren't any packets left to read) exit. */
         break;
       }
-      if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
-        newly_displayed_packets++;
+      if (rec_type == REC_TYPE_PACKET) {
+        if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
+          newly_displayed_packets++;
+        }
       }
       to_read--;
     }
@@ -959,6 +965,7 @@ cf_fake_continue_tail(capture_file *cf) {
 cf_read_status_t
 cf_finish_tail(capture_file *cf, int *err)
 {
+  int        rec_type;
   gchar     *err_info;
   gint64     data_offset;
   dfilter_t *dfcode;
@@ -992,14 +999,15 @@ cf_finish_tail(capture_file *cf, int *err)
 
   epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
 
-  while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
+  while ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) != -1) {
     if (cf->state == FILE_READ_ABORTED) {
       /* Well, the user decided to abort the read.  Break out of the
          loop, and let the code below (which is called even if there
          aren't any packets left to read) exit. */
       break;
     }
-    read_packet(cf, dfcode, &edt, cinfo, data_offset);
+    if (rec_type == REC_TYPE_PACKET)
+      read_packet(cf, dfcode, &edt, cinfo, data_offset);
   }
 
   /* Cleanup and release all dfilter resources */
@@ -1753,10 +1761,11 @@ cf_redissect_packets(capture_file *cf)
   }
 }
 
-gboolean
+int
 cf_read_frame_r(capture_file *cf, const frame_data *fdata,
                 struct wtap_pkthdr *phdr, Buffer *buf)
 {
+  int    rec_type;
   int    err;
   gchar *err_info;
   gchar *display_basename;
@@ -1768,17 +1777,19 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
 
     if (!frame) {
       simple_error_message_box("fdata->file_off == -1, but can't find modified frame!");
-      return FALSE;
+      return -1;
     }
 
     *phdr = frame->phdr;
     buffer_assure_space(buf, frame->phdr.caplen);
     memcpy(buffer_start_ptr(buf), frame->pd, frame->phdr.caplen);
-    return TRUE;
+    /* XXX - what if this isn't a packet? */
+    return REC_TYPE_PACKET;
   }
 #endif
 
-  if (!wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info)) {
+  rec_type = wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info);
+  if (rec_type == -1) {
     display_basename = g_filename_display_basename(cf->filename);
     switch (err) {
 
@@ -1801,12 +1812,12 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
       break;
     }
     g_free(display_basename);
-    return FALSE;
+    return -1;
   }
-  return TRUE;
+  return rec_type;
 }
 
-gboolean
+int
 cf_read_frame(capture_file *cf, frame_data *fdata)
 {
   return cf_read_frame_r(cf, fdata, &cf->phdr, &cf->buf);
@@ -2005,7 +2016,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
     /* Frame dependencies from the previous dissection/filtering are no longer valid. */
     fdata->flags.dependent_of_displayed = 0;
 
-    if (!cf_read_frame(cf, fdata))
+    if (cf_read_frame(cf, fdata) == -1)
       break; /* error reading the frame */
 
     /* If the previous frame is displayed, and we haven't yet seen the
@@ -2332,7 +2343,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
     }
 
     /* Get the packet */
-    if (!cf_read_frame_r(cf, fdata, &phdr, &buf)) {
+    if (cf_read_frame_r(cf, fdata, &phdr, &buf) == -1) {
       /* Attempt to get the packet failed. */
       ret = PSP_FAILED;
       break;
@@ -3109,7 +3120,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
   epan_dissect_t  edt;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3213,7 +3224,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
   size_t          c_match    = 0;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3311,7 +3322,7 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match    = 0;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3359,7 +3370,7 @@ match_narrow(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match    = 0;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3406,7 +3417,7 @@ match_wide(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match    = 0;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3452,7 +3463,7 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match     = 0;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3522,7 +3533,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
   match_result    result;
 
   /* Load the frame's data. */
-  if (!cf_read_frame(cf, fdata)) {
+  if (cf_read_frame(cf, fdata) == -1) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3848,7 +3859,7 @@ cf_select_packet(capture_file *cf, int row)
   }
 
   /* Get the data in that frame. */
-  if (!cf_read_frame (cf, fdata)) {
+  if (cf_read_frame (cf, fdata) == -1) {
     return;
   }
 
@@ -4028,7 +4039,7 @@ cf_get_comment(capture_file *cf, const frame_data *fd)
     memset(&phdr, 0, sizeof(struct wtap_pkthdr));
 
     buffer_init(&buf, 1500);
-    if (!cf_read_frame_r(cf, fd, &phdr, &buf))
+    if (cf_read_frame_r(cf, fd, &phdr, &buf) == -1)
       { /* XXX, what we can do here? */ }
 
     buffer_free(&buf);
@@ -4322,6 +4333,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 {
   const struct wtap_pkthdr *phdr;
   gchar               *err_info;
+  int                  rec_type;
   gchar               *name_ptr;
   gint64               data_offset;
   gint64               file_pos;
@@ -4408,10 +4420,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 
   framenum = 0;
   phdr = wtap_phdr(cf->wth);
-  while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
-    framenum++;
-    fdata = frame_data_sequence_find(cf->frames, framenum);
-    fdata->file_off = data_offset;
+  while ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) != -1) {
     if (size >= 0) {
       count++;
       file_pos = wtap_read_so_far(cf->wth);
@@ -4455,13 +4464,19 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
       break;
     }
 
-    /* Add this packet's link-layer encapsulation type to cf->linktypes, if
-       it's not already there.
-       XXX - yes, this is O(N), so if every packet had a different
-       link-layer encapsulation type, it'd be O(N^2) to read the file, but
-       there are probably going to be a small number of encapsulation types
-       in a file. */
-    cf_add_encapsulation_type(cf, phdr->pkt_encap);
+    if (rec_type == REC_TYPE_PACKET) {
+      framenum++;
+      fdata = frame_data_sequence_find(cf->frames, framenum);
+      fdata->file_off = data_offset;
+
+      /* Add this packet's link-layer encapsulation type to cf->linktypes, if
+         it's not already there.
+         XXX - yes, this is O(N), so if every packet had a different
+         link-layer encapsulation type, it'd be O(N^2) to read the file, but
+         there are probably going to be a small number of encapsulation types
+         in a file. */
+      cf_add_encapsulation_type(cf, phdr->pkt_encap);
+    }
   }
 
   /* Free the display name */
diff --git a/file.h b/file.h
index 79df1cfd68c33754e3390ff2993cd32ee3f31869..ed12f57044fba1a20833cafd97006c27c2579bfe 100644 (file)
--- a/file.h
+++ b/file.h
@@ -137,29 +137,30 @@ void cf_reload(capture_file *cf);
 cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
 
 /**
- * Read the pseudo-header and raw data for a packet.  It will pop
- * up an alert box if there's an error.
+ * Read a record from a capture file.  It will pop up an alert box
+ * if there's an error.
  *
- * @param cf the capture file from which to read the packet
- * @param fdata the frame_data structure for the packet in question
+ * @param cf the capture file from which to read the record
+ * @param fdata the frame_data structure for the record in question
  * @param phdr pointer to a wtap_pkthdr structure to contain the
- * packet's pseudo-header and other metadata
- * @param buf a Buffer into which to read the packet's raw data
- * @return TRUE if the read succeeded, FALSE if there was an error
+ * packet's pseudo-header and other metadata, if the record is a
+ * packet
+ * @param buf a Buffer into which to read the record's data
+ * @return record type if the read succeeded, -1 if there was an error
  */
-gboolean cf_read_frame_r(capture_file *cf, const frame_data *fdata,
-                         struct wtap_pkthdr *phdr, Buffer *buf);
+int cf_read_frame_r(capture_file *cf, const frame_data *fdata,
+                    struct wtap_pkthdr *phdr, Buffer *buf);
 
 /**
- * Read the pseudo-header and raw data for a packet into a
- * capture_file structure's pseudo_header and buf members.
+ * Read a record from a capture file into a capture_file structure's
+ * pseudo_header and buf members.
  * It will pop up an alert box if there's an error.
  *
- * @param cf the capture file from which to read the packet
- * @param fdata the frame_data structure for the packet in question
- * @return TRUE if the read succeeded, FALSE if there was an error
+ * @param cf the capture file from which to read the record
+ * @param fdata the frame_data structure for the record in question
+ * @return record type if the read succeeded, -1 if there was an error
  */
-gboolean cf_read_frame(capture_file *cf, frame_data *fdata);
+int cf_read_frame(capture_file *cf, frame_data *fdata);
 
 /**
  * Read packets from the "end" of a capture file.
index b47d206f07bbc4426421d13f02707d9f85acc857..e9321926bbc658ba9da667a424e32a46cbfc7e6a 100644 (file)
@@ -57,7 +57,7 @@ frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf)
        /* XXX, what if phdr->caplen isn't equal to
         * frame_tvb->tvb.length + frame_tvb->offset?
         */
-       if (!wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) {
+       if (wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info) == -1) {
                switch (err) {
                        case WTAP_ERR_UNSUPPORTED_ENCAP:
                        case WTAP_ERR_BAD_FILE:
index 68eaaa1eac83913bc5266688a90215b61ca627de..ae0ee5035010d4bcfdaea861839c33676af1fa5d 100644 (file)
@@ -147,7 +147,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
 
        /* Load the frame from the capture file */
        buffer_init(&buf, 1500);
-       if (!cf_read_frame_r(&cfile, frame, &phdr, &buf))
+       if (cf_read_frame_r(&cfile, frame, &phdr, &buf) == -1)
                return FALSE;   /* failure */
 
        /* Dissect the frame   tree  not visible */
index 4b363b84b149b7329d0c47c86e956514ba9a279e..df46d7c166f6ba0519566ce4409fad5591a168cc 100644 (file)
@@ -103,7 +103,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, Buffer *buf,
 
 
     /* Re-read the first frame from the stored location */
-    if (!wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info)) {
+    if (wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info) == -1) {
         if (err != 0) {
             /* Print a message noting that the read failed somewhere along the line. */
             fprintf(stderr,
@@ -176,6 +176,7 @@ int main(int argc, char *argv[])
 {
     wtap *wth = NULL;
     wtap_dumper *pdh = NULL;
+    int rec_type;
     Buffer buf;
     int err;
     gchar *err_info;
@@ -261,22 +262,24 @@ int main(int argc, char *argv[])
     frames = g_ptr_array_new();
 
     /* Read each frame from infile */
-    while (wtap_read(wth, &err, &err_info, &data_offset)) {
-        FrameRecord_t *newFrameRecord;
+    while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
+        if (rec_type == REC_TYPE_PACKET) {
+            FrameRecord_t *newFrameRecord;
 
-        phdr = wtap_phdr(wth);
+            phdr = wtap_phdr(wth);
 
-        newFrameRecord = g_slice_new(FrameRecord_t);
-        newFrameRecord->num = frames->len + 1;
-        newFrameRecord->offset = data_offset;
-        newFrameRecord->time = phdr->ts;
+            newFrameRecord = g_slice_new(FrameRecord_t);
+            newFrameRecord->num = frames->len + 1;
+            newFrameRecord->offset = data_offset;
+            newFrameRecord->time = phdr->ts;
 
-        if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {
-           wrong_order_count++;
-        }
+            if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {
+               wrong_order_count++;
+            }
 
-        g_ptr_array_add(frames, newFrameRecord);
-        prevFrame = newFrameRecord;
+            g_ptr_array_add(frames, newFrameRecord);
+            prevFrame = newFrameRecord;
+        }
     }
     if (err != 0) {
       /* Print a message noting that the read failed somewhere along the line. */
index e62350400f8a59d592f60bca267811d919040f98..6de68cd53c8da311f72ccc46c458cc4c184afb02 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -1857,7 +1857,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
     for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
       fdata = frame_data_sequence_find(cf->frames, framenum);
 #if 0
-      if (wtap_seek_read(cf->wth, fdata->file_off,
+      if (local_wtap_seek_read(cf->wth, fdata->file_off,
           &buf, fdata->cap_len, &err, &err_info)) {
         process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf, tap_flags);
       }
index f52b00502f883f40e863bf09b6f033c31131b431..afbf6310ac600750843846ebbe99ede220b6fd7d 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -2651,11 +2651,11 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
 }
 
 
-/* capture child tells us we have new packets to read */
+/* capture child tells us we have new records to read */
 void
-capture_input_new_packets(capture_session *cap_session, int to_read)
+capture_input_new_records(capture_session *cap_session, int to_read)
 {
-  gboolean      ret;
+  int           rec_type;
   int           err;
   gchar        *err_info;
   gint64        data_offset;
@@ -2696,20 +2696,21 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
 
     while (to_read-- && cf->wth) {
       wtap_cleareof(cf->wth);
-      ret = wtap_read(cf->wth, &err, &err_info, &data_offset);
-      if (ret == FALSE) {
+      rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset);
+      if (rec_type == -1) {
         /* read from file failed, tell the capture child to stop */
         sync_pipe_stop(cap_session);
         wtap_close(cf->wth);
         cf->wth = NULL;
       } else {
-        ret = process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
+       if (rec_type == REC_TYPE_PACKET) {
+          if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
                              wtap_buf_ptr(cf->wth),
-                             tap_flags);
-      }
-      if (ret != FALSE) {
-        /* packet successfully read and gone through the "Read Filter" */
-        packet_count++;
+                             tap_flags)) {
+            /* packet successfully read and gone through the "Read Filter" */
+            packet_count++;
+          }
+        }
       }
     }
 
@@ -3062,9 +3063,11 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
   int          snapshot_length;
   wtap_dumper *pdh;
   guint32      framenum;
+  int          rec_type;
   int          err;
   gchar       *err_info = NULL;
   gint64       data_offset;
+  gboolean     packet_count_reached = FALSE;
   char        *save_file_string = NULL;
   gboolean     filtering_tap_listeners;
   guint        tap_flags;
@@ -3191,17 +3194,19 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
       edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
     }
 
-    while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
-      if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
-                         wtap_buf_ptr(cf->wth))) {
-        /* Stop reading if we have the maximum number of packets;
-         * When the -c option has not been used, max_packet_count
-         * starts at 0, which practically means, never stop reading.
-         * (unless we roll over max_packet_count ?)
-         */
-        if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
-          err = 0; /* This is not an error */
-          break;
+    while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
+      if (rec_type == REC_TYPE_PACKET) {
+        if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
+                                      wtap_buf_ptr(cf->wth))) {
+          /* Stop reading if we have the maximum number of packets;
+           * When the -c option has not been used, max_packet_count
+           * starts at 0, which practically means, never stop reading.
+           * (unless we roll over max_packet_count ?)
+           */
+          if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
+            err = 0; /* This is not an error */
+            break;
+          }
         }
       }
     }
@@ -3240,15 +3245,101 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
 
     for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
       fdata = frame_data_sequence_find(cf->frames, framenum);
-      if (wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
-                         &err_info)) {
-        if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
-                                       tap_flags)) {
+      if ((rec_type = wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
+                                     &err_info)) == -1) {
+        if (rec_type == REC_TYPE_PACKET) {
+          if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
+                                         tap_flags)) {
+            /* Either there's no read filtering or this packet passed the
+               filter, so, if we're writing to a capture file, write
+               this packet out. */
+            if (pdh != NULL) {
+              if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
+                /* Error writing to a capture file */
+                switch (err) {
+
+                case WTAP_ERR_UNSUPPORTED_ENCAP:
+                  /*
+                   * This is a problem with the particular frame we're writing
+                   * and the file type and subtype we're writing; note that,
+                   * and report the frame number and file type/subtype.
+                   *
+                   * XXX - framenum is not necessarily the frame number in
+                   * the input file if there was a read filter.
+                   */
+                  fprintf(stderr,
+                          "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
+                          framenum, cf->filename,
+                          wtap_file_type_subtype_short_string(out_file_type));
+                  break;
+
+                case WTAP_ERR_PACKET_TOO_LARGE:
+                  /*
+                   * This is a problem with the particular frame we're writing
+                   * and the file type and subtype we're writing; note that,
+                   * and report the frame number and file type/subtype.
+                   *
+                   * XXX - framenum is not necessarily the frame number in
+                   * the input file if there was a read filter.
+                   */
+                  fprintf(stderr,
+                          "Frame %u of \"%s\" is too large for a \"%s\" file.\n",
+                          framenum, cf->filename,
+                          wtap_file_type_subtype_short_string(out_file_type));
+                  break;
+
+                default:
+                  show_capture_file_io_error(save_file, err, FALSE);
+                  break;
+                }
+                wtap_dump_close(pdh, &err);
+                g_free(shb_hdr);
+                exit(2);
+              }
+            }
+          }
+        }
+      }
+    }
+
+    if (edt) {
+      epan_dissect_free(edt);
+      edt = NULL;
+    }
+
+    buffer_free(&buf);
+  }
+  else {
+    framenum = 0;
+
+    if (do_dissection) {
+      gboolean create_proto_tree;
+
+      if (cf->rfcode || cf->dfcode || print_details || filtering_tap_listeners ||
+          (tap_flags & TL_REQUIRES_PROTO_TREE) || have_custom_cols(&cf->cinfo))
+        create_proto_tree = TRUE;
+      else
+        create_proto_tree = FALSE;
+
+      /* The protocol tree will be "visible", i.e., printed, only if we're
+         printing packet details, which is true if we're printing stuff
+         ("print_packet_info" is true) and we're in verbose mode
+         ("packet_details" is true). */
+      edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
+    }
+
+    while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
+      if (rec_type == REC_TYPE_PACKET) {
+        framenum++;
+
+        if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
+                           wtap_buf_ptr(cf->wth),
+                           tap_flags)) {
           /* Either there's no read filtering or this packet passed the
              filter, so, if we're writing to a capture file, write
              this packet out. */
           if (pdh != NULL) {
-            if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
+            if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
               /* Error writing to a capture file */
               switch (err) {
 
@@ -3257,9 +3348,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
                  * This is a problem with the particular frame we're writing
                  * and the file type and subtype we're writing; note that,
                  * and report the frame number and file type/subtype.
-                 *
-                 * XXX - framenum is not necessarily the frame number in
-                 * the input file if there was a read filter.
                  */
                 fprintf(stderr,
                         "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
@@ -3272,9 +3360,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
                  * This is a problem with the particular frame we're writing
                  * and the file type and subtype we're writing; note that,
                  * and report the frame number and file type/subtype.
-                 *
-                 * XXX - framenum is not necessarily the frame number in
-                 * the input file if there was a read filter.
                  */
                 fprintf(stderr,
                         "Frame %u of \"%s\" is too large for a \"%s\" file.\n",
@@ -3292,89 +3377,23 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
             }
           }
         }
-      }
-    }
-
-    if (edt) {
-      epan_dissect_free(edt);
-      edt = NULL;
-    }
-
-    buffer_free(&buf);
-  }
-  else {
-    framenum = 0;
-
-    if (do_dissection) {
-      gboolean create_proto_tree;
 
-      if (cf->rfcode || cf->dfcode || print_details || filtering_tap_listeners ||
-          (tap_flags & TL_REQUIRES_PROTO_TREE) || have_custom_cols(&cf->cinfo))
-        create_proto_tree = TRUE;
-      else
-        create_proto_tree = FALSE;
-
-      /* The protocol tree will be "visible", i.e., printed, only if we're
-         printing packet details, which is true if we're printing stuff
-         ("print_packet_info" is true) and we're in verbose mode
-         ("packet_details" is true). */
-      edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
-    }
-
-    while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
-      framenum++;
-
-      if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
-                         wtap_buf_ptr(cf->wth),
-                         tap_flags)) {
-        /* Either there's no read filtering or this packet passed the
-           filter, so, if we're writing to a capture file, write
-           this packet out. */
-        if (pdh != NULL) {
-          if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
-            /* Error writing to a capture file */
-            switch (err) {
-
-            case WTAP_ERR_UNSUPPORTED_ENCAP:
-              /*
-               * This is a problem with the particular frame we're writing
-               * and the file type and subtype we're writing; note that,
-               * and report the frame number and file type/subtype.
-               */
-              fprintf(stderr,
-                      "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
-                      framenum, cf->filename,
-                      wtap_file_type_subtype_short_string(out_file_type));
-              break;
-
-            case WTAP_ERR_PACKET_TOO_LARGE:
-              /*
-               * This is a problem with the particular frame we're writing
-               * and the file type and subtype we're writing; note that,
-               * and report the frame number and file type/subtype.
-               */
-              fprintf(stderr,
-                      "Frame %u of \"%s\" is too large for a \"%s\" file.\n",
-                      framenum, cf->filename,
-                      wtap_file_type_subtype_short_string(out_file_type));
-              break;
-
-            default:
-              show_capture_file_io_error(save_file, err, FALSE);
-              break;
-            }
-            wtap_dump_close(pdh, &err);
-            g_free(shb_hdr);
-            exit(2);
-          }
+        /* If we're supposed to stop after max_packet_count packets,
+         * count this packet. 
+         * When the -c option has not been used, max_packet_count
+         * starts at 0.
+         */
+        if (max_packet_count != 0) {
+          max_packet_count--;
+          if (max_packet_count == 0)
+            packet_count_reached = TRUE;
         }
       }
-      /* Stop reading if we have the maximum number of packets;
-       * When the -c option has not been used, max_packet_count
-       * starts at 0, which practically means, never stop reading.
-       * (unless we roll over max_packet_count ?)
+
+      /* Stop reading if we have the maximum number of packets or the
+       * maximum file size.
        */
-      if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
+      if ( packet_count_reached || (max_byte_count != 0 && data_offset >= max_byte_count)) {
         err = 0; /* This is not an error */
         break;
       }
index baef2baed97aacf21bb91613229bc537187bf292..74f35d6748155e875a6c46353984eacf28861947 100644 (file)
@@ -173,6 +173,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
 static void
 preview_do(GtkWidget *prev, wtap *wth)
 {
+  int           rec_type;
   GtkWidget    *label;
   unsigned int  elapsed_time;
   time_t        time_preview;
@@ -183,6 +184,7 @@ preview_do(GtkWidget *prev, wtap *wth)
   double        start_time   = 0; /* seconds, with nsec resolution */
   double        stop_time    = 0; /* seconds, with nsec resolution */
   double        cur_time;
+  unsigned int  records    = 0;
   unsigned int  packets    = 0;
   gboolean      is_breaked = FALSE;
   gchar         string_buff[PREVIEW_STR_MAX];
@@ -192,22 +194,25 @@ preview_do(GtkWidget *prev, wtap *wth)
 
 
   time(&time_preview);
-  while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
-    phdr = wtap_phdr(wth);
-    cur_time = nstime_to_sec(&phdr->ts);
-    if (packets == 0) {
-      start_time = cur_time;
-      stop_time = cur_time;
-    }
-    if (cur_time < start_time) {
-      start_time = cur_time;
-    }
-    if (cur_time > stop_time) {
-      stop_time = cur_time;
-    }
+  while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
+    if (rec_type == REC_TYPE_PACKET) {
+      phdr = wtap_phdr(wth);
+      cur_time = nstime_to_sec(&phdr->ts);
+      if (packets == 0) {
+        start_time = cur_time;
+        stop_time = cur_time;
+      }
+      if (cur_time < start_time) {
+        start_time = cur_time;
+      }
+      if (cur_time > stop_time) {
+        stop_time = cur_time;
+      }
 
-    packets++;
-    if (packets%1000 == 0) {
+      packets++;
+    }
+    records++;
+    if (records%1000 == 0) {
       /* do we have a timeout? */
       time(&time_current);
       if (time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
index 6f7fe77c730777a21fd9433fddf7ea4ff2e87dd9..d756b3a58b241fb8383ac82fb843eb056cb2c89b 100644 (file)
@@ -3711,7 +3711,7 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
                return; /* if we exit here it's an error */
 
        /* dissect the current frame */
-       if (!cf_read_frame(cf, fdata))
+       if (cf_read_frame(cf, fdata) == -1)
                return; /* error reading the frame */
        epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
        epan_dissect_prime_dfilter(&edt, sfcode);
index e49e0531a0131263a19f134588b49127a9230958..a3140b18e12453595e2a1631ff2c742d1608ca5a 100644 (file)
@@ -543,7 +543,7 @@ get_ip_address_list_from_packet_list_row(gpointer data)
     if (fdata != NULL) {
         epan_dissect_t edt;
 
-        if (!cf_read_frame (&cfile, fdata))
+        if (cf_read_frame (&cfile, fdata) == -1)
             return NULL; /* error reading the frame */
 
         epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
@@ -584,7 +584,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
     if (fdata != NULL) {
         epan_dissect_t edt;
 
-        if (!cf_read_frame(&cfile, fdata))
+        if (cf_read_frame(&cfile, fdata) == -1)
             return NULL; /* error reading the frame */
         /* proto tree, visible. We need a proto tree if there's custom columns */
         epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);
index dd904b58be1be1216a425283798145a165aa69c2..efb8e44ea15aa8294ef2c4c24ceed0183df55ffe 100644 (file)
@@ -1117,7 +1117,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
                cinfo = NULL;
 
        buffer_init(&buf, 1500);
-       if (!cf_read_frame_r(&cfile, fdata, &phdr, &buf)) {
+       if (cf_read_frame_r(&cfile, fdata, &phdr, &buf) == -1) {
                /*
                 * Error reading the frame.
                 *
index c25d62b48aac29ae51cdb644bc0fd3a863c202d7..67fb5fddd2594ed4c32c9671e4daa07627b7ca60 100644 (file)
@@ -961,7 +961,7 @@ void new_packet_window(GtkWidget *w _U_, gboolean reference, gboolean editable _
        }
 
        /* With the new packetlists "lazy columns" it's necessary to reread the frame */
-       if (!cf_read_frame(&cfile, fd)) {
+       if (cf_read_frame(&cfile, fd) == -1) {
                /* error reading the frame */
                return;
        }
index aeb5b9996ba810e7f871c7986d0670f2f77ff3b5..eb9e2635f105be7334289a1c5bce2a7ef6f77f09 100644 (file)
@@ -903,7 +903,7 @@ static rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct segment
     }
 
     /* dissect the current frame */
-    if (!cf_read_frame(cf, fdata)) {
+    if (cf_read_frame(cf, fdata) == -1) {
         return NULL;  /* error reading the frame */
     }
 
index 0305b0a26afe09215ce159b0eaaa03a8d0975823..66c2406658d87406943a75b4ae821ee1f22192c3 100644 (file)
@@ -3946,7 +3946,7 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
                return; /* if we exit here it's an error */
 
        /* dissect the current frame */
-       if (!cf_read_frame(cf, fdata))
+       if (cf_read_frame(cf, fdata) == -1)
                return; /* error reading the frame */
        epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
        epan_dissect_prime_dfilter(&edt, sfcode);
index 2b751f7135d5f1d1b8fc53f75b15b78b02414a02..927be97b0e0c4bb078845caf2cb65b540e17b125 100644 (file)
@@ -975,7 +975,7 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext)
                return; /* if we exit here it's an error */
 
        /* dissect the current frame */
-       if (!cf_read_frame(cf, fdata))
+       if (cf_read_frame(cf, fdata) == -1)
                return; /* error reading the frame */
 
        epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
index 03d48924114be569b82a4ede56f7089e605ba113..3e123dc34b9e9c96c54abdb45b44b72680a2f54a 100644 (file)
@@ -736,11 +736,13 @@ void CaptureFileDialog::preview(const QString & path)
     wtap        *wth;
     int          err = 0;
     gchar       *err_info;
+    int          rec_type;
     gint64       data_offset;
     const struct wtap_pkthdr *phdr;
     double       start_time = 0; /* seconds, with nsec resolution */
     double       stop_time = 0;  /* seconds, with nsec resolution */
     double       cur_time;
+    unsigned int records = 0;
     unsigned int packets = 0;
     bool         timed_out = FALSE;
     time_t       time_preview;
@@ -792,22 +794,25 @@ void CaptureFileDialog::preview(const QString & path)
     preview_size_.setText(QString(tr("%1 bytes")).arg(wtap_file_size(wth, &err)));
 
     time(&time_preview);
-    while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
-        phdr = wtap_phdr(wth);
-        cur_time = nstime_to_sec(&phdr->ts);
-        if(packets == 0) {
-            start_time = cur_time;
-            stop_time = cur_time;
-        }
-        if (cur_time < start_time) {
-            start_time = cur_time;
-        }
-        if (cur_time > stop_time){
-            stop_time = cur_time;
-        }
+    while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
+        if (rec_type == REC_TYPE_PACKET) {
+            phdr = wtap_phdr(wth);
+            cur_time = nstime_to_sec(&phdr->ts);
+            if(packets == 0) {
+                start_time = cur_time;
+                stop_time = cur_time;
+            }
+            if (cur_time < start_time) {
+                start_time = cur_time;
+            }
+            if (cur_time > stop_time){
+                stop_time = cur_time;
+            }
 
-        packets++;
-        if(packets%1000 == 0) {
+            packets++;
+        }
+        records++;
+        if(records%1000 == 0) {
             /* do we have a timeout? */
             time(&time_current);
             if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
index 7e9ff9413220ab3c5c40c7ececa7d5bbc70af775..2388c6b380f04524bf7e25afac92b2678bf38263 100644 (file)
@@ -655,7 +655,7 @@ QString &PacketList::getFilterFromRowAndColumn()
     if (fdata != NULL) {
         epan_dissect_t edt;
 
-        if (!cf_read_frame(cap_file_, fdata))
+        if (cf_read_frame(cap_file_, fdata) == -1)
             return filter; /* error reading the frame */
         /* proto tree, visible. We need a proto tree if there's custom columns */
         epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);
index a6b68f51bdec3a2aa3379332cc55784d9dbb5764..805da14c8f0c490eb9568f37b4881c610f69705c 100644 (file)
@@ -221,7 +221,7 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const
     memset(&phdr, 0, sizeof(struct wtap_pkthdr));
 
     buffer_init(&buf, 1500);
-    if (!cap_file_ || !cf_read_frame_r(cap_file_, fdata, &phdr, &buf)) {
+    if (!cap_file_ || cf_read_frame_r(cap_file_, fdata, &phdr, &buf) == -1) {
         /*
          * Error reading the frame.
          *
index 9dd1e46381712aae5677fd038fa8982a94c53852..8ba41c22cc16aa93c45827116df26646a2109b20 100644 (file)
@@ -305,7 +305,7 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
     }
 
     /* dissect the current frame */
-    if (!cf_read_frame(cf, fdata))
+    if (cf_read_frame(cf, fdata) == -1)
         return NULL;    /* error reading the frame */
 
 
index a65aaf4d0fd5bc3264b2412ffecb69e198b42685..47cf06cd4c0be6253383bbbd7bd1e08b4070a28f 100644 (file)
@@ -1119,8 +1119,10 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
     int         err = 0;
     gchar      *err_info;
     TCHAR       string_buff[PREVIEW_STR_MAX];
+    int         rec_type;
     gint64      data_offset;
-    guint       packet = 0;
+    guint       records = 0;
+    guint       packets = 0;
     gint64      filesize;
     time_t      ti_time;
     struct tm  *ti_tm;
@@ -1186,21 +1188,24 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
     SetWindowText(cur_ctrl, string_buff);
 
     time(&time_preview);
-    while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
-        phdr = wtap_phdr(wth);
-        cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts );
-        if(packet == 0) {
-            start_time  = cur_time;
-            stop_time = cur_time;
-        }
-        if (cur_time < start_time) {
-            start_time = cur_time;
-        }
-        if (cur_time > stop_time){
-            stop_time = cur_time;
+    while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
+        if (rec_type == REC_TYPE_PACKET) {
+            phdr = wtap_phdr(wth);
+            cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts );
+            if(packets == 0) {
+                start_time  = cur_time;
+                stop_time = cur_time;
+            }
+            if (cur_time < start_time) {
+                start_time = cur_time;
+            }
+            if (cur_time > stop_time){
+                stop_time = cur_time;
+            }
+            packets++;
         }
-        packet++;
-        if(packet%100 == 0) {
+        records++;
+        if(records%100 == 0) {
             time(&time_current);
             if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
                 is_breaked = TRUE;
@@ -1210,7 +1215,7 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
     }
 
     if(err != 0) {
-        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet);
+        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packets);
         cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
         SetWindowText(cur_ctrl, string_buff);
         wtap_close(wth);
@@ -1219,9 +1224,9 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
 
     /* Packets */
     if(is_breaked) {
-        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet);
+        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packets);
     } else {
-        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
+        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packets);
     }
     cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
     SetWindowText(cur_ctrl, string_buff);
index db377b15702a02de27dfd843573f6aeff2f39a21..fed60d05ec5a5bcd8dd6a7c84c8d052613c08960 100644 (file)
@@ -99,9 +99,9 @@ typedef struct
 #define CST_5VW_CAPTURES_RECORD                (CST_5VW_SECTION_CAPTURES << 28)        /* 0x80000000 */
 #define CST_5VW_SYSTEM_RECORD          0x00000000U
 
-static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
+static int _5views_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean _5views_seek_read(wtap *wth, gint64 seek_off,
+static int _5views_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
@@ -191,7 +191,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static gboolean
+static int
 _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        t_5VW_TimeStamped_Header TimeStamped_Header;
@@ -207,7 +207,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                /* Read record header. */
                if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header,
                    &wth->phdr, err, err_info))
-                       return FALSE;
+                       return -1;
 
                if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) {
                        /*
@@ -220,7 +220,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                 * Not a packet - skip to the next record.
                 */
                if (file_seek(wth->fh, TimeStamped_Header.RecSize, SEEK_CUR, err) == -1)
-                       return FALSE;
+                       return -1;
        } while (1);
 
        if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE) {
@@ -231,11 +231,13 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u",
                    wth->phdr.caplen, WTAP_MAX_PACKET_SIZE);
-               return FALSE;
+               return -1;
        }
 
-       return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
-           wth->phdr.caplen, err, err_info);
+       if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
+           wth->phdr.caplen, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
@@ -245,7 +247,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        t_5VW_TimeStamped_Header TimeStamped_Header;
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /*
         * Read the header.
@@ -254,14 +256,16 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
            phdr, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
 
        /*
         * Read the packet data.
         */
-       return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
-           err, err_info);
+       if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
+           err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
 /* Read the header of the next packet.  Return TRUE on success, FALSE
index a0b783b3495872e0788d62f22bfe5d4fc417d8f3..bab0091fb0fd0428e1451e59418937cdf2c254c1 100644 (file)
@@ -112,9 +112,9 @@ typedef struct {
        time_t  start;
 } aethra_t;
 
-static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
+static int aethra_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
+static int aethra_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
@@ -182,7 +182,7 @@ static guint packet = 0;
 #endif
 
 /* Read the next packet */
-static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
+static int aethra_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        struct aethrarec_hdr hdr;
@@ -196,7 +196,7 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
 
                /* Read record header. */
                if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->phdr, err, err_info))
-                       return FALSE;
+                       return -1;
 
                /*
                 * XXX - if this is big, we might waste memory by
@@ -205,7 +205,7 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
                if (wth->phdr.caplen != 0) {
                        if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
                            wth->phdr.caplen, err, err_info))
-                               return FALSE;   /* Read error */
+                               return -1;      /* Read error */
                }
 #if 0
 packet++;
@@ -270,32 +270,32 @@ packet, hdr.rec_type, wth->phdr.caplen, hdr.flags);
        }
 
 found:
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        struct aethrarec_hdr hdr;
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err,
            err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
 
        /*
         * Read the packet data.
         */
        if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info))
-               return FALSE;   /* failed */
+               return -1;      /* failed */
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
index 32d4d494184c65c34d7a6903ddfdacfd5f9b230f..58ea2fbea6321d7d2e2c77d4da71d30febb723ac 100644 (file)
@@ -74,9 +74,9 @@ static const ascend_magic_string ascend_magic[] = {
   { ASCEND_PFX_ETHER,  "ETHER" },
 };
 
-static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
+static int ascend_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
+static int ascend_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info);
 
@@ -237,36 +237,36 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
      packet's header because we might mistake part of it for a new header. */
   if (file_seek(wth->fh, ascend->next_packet_seek_start,
                 SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
 
   offset = ascend_seek(wth, err, err_info);
   if (offset == -1)
-    return FALSE;
+    return -1;
   if (parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer,
                    wth->snapshot_length) != PARSED_RECORD) {
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
-    return FALSE;
+    return -1;
   }
 
   *data_offset = offset;
-  return TRUE;
+  return REC_TYPE_PACKET;
 }
 
-static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
+static int ascend_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info)
 {
   ascend_t *ascend = (ascend_t *)wth->priv;
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
   if (parse_ascend(ascend, wth->random_fh, phdr, buf,
                    wth->snapshot_length) != PARSED_RECORD) {
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
-    return FALSE;
+    return -1;
   }
 
-  return TRUE;
+  return REC_TYPE_PACKET;
 }
index 59e7e28f3964a1d9f0ed82ce7d54ae5cbe445781..1a3f4e6bf6065879e66d8d791490a2c19adf5454 100644 (file)
 #define BER_UNI_TAG_SEQ        16      /* SEQUENCE, SEQUENCE OF */
 #define BER_UNI_TAG_SET        17      /* SET, SET OF */
 
-static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
-                              Buffer *buf, int *err, gchar **err_info)
+static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+                         Buffer *buf, int *err, gchar **err_info)
 {
   gint64 file_size;
   int packet_size;
 
   if ((file_size = wtap_file_size(wth, err)) == -1)
-    return FALSE;
+    return -1;
 
   if (file_size > WTAP_MAX_PACKET_SIZE) {
     /*
@@ -55,7 +55,7 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("ber: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
                                file_size, WTAP_MAX_PACKET_SIZE);
-    return FALSE;
+    return -1;
   }
   packet_size = (int)file_size;
 
@@ -67,10 +67,12 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
   phdr->ts.secs = 0;
   phdr->ts.nsecs = 0;
 
-  return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+  if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
+    return -1;
+  return REC_TYPE_PACKET;
 }
 
-static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
   gint64 offset;
 
@@ -80,24 +82,24 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
 
   /* there is only ever one packet */
   if (offset != 0)
-    return FALSE;
+    return -1;
 
   *data_offset = offset;
 
   return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
-                             Buffer *buf, int *err, gchar **err_info)
+static int ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
+                        Buffer *buf, int *err, gchar **err_info)
 {
   /* there is only one packet */
   if(seek_off > 0) {
     *err = 0;
-    return FALSE;
+    return -1;
   }
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
 
   return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index b7c0b4c5c55168d304d13f1a06be568b447485c9..c1e5a9881ee63c05bc66015db6c903d2ea5eace7 100644 (file)
@@ -73,11 +73,11 @@ struct btsnooprec_hdr {
 
 static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */
 
-static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
+static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
+static int btsnoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
+static int btsnoop_read_record(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 int btsnoop_open(wtap *wth, int *err, gchar **err_info)
@@ -160,7 +160,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
        return 1;
 }
 
-static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
+static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -169,16 +169,16 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
            err, err_info);
 }
 
-static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
+static int btsnoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
 }
 
-static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
+static int btsnoop_read_record(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        int     bytes_read;
@@ -196,7 +196,7 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
                *err = file_error(fh, err_info);
                if (*err == 0 && bytes_read != 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
 
        packet_size = g_ntohl(hdr.incl_len);
@@ -210,7 +210,7 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("btsnoop: File has %u-byte packet, bigger than maximum of %u",
                    packet_size, WTAP_MAX_PACKET_SIZE);
-               return FALSE;
+               return -1;
        }
 
        ts = GINT64_FROM_BE(hdr.ts_usec);
@@ -248,7 +248,9 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
 
 
        /* Read packet data. */
-       return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
+       if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
 /* Returns 0 if we could write the specified encapsulation type,
index ccc618498aa1b55a14e6187a8223457f53fa7ce7..d49cf96b805d079388c3843aea57b837100ca150 100644 (file)
@@ -256,7 +256,7 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len)
 }
 
 
-static gboolean
+static int
 camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
 {
@@ -266,7 +266,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     gint        offset, bytes_read;
 
     if (!find_next_pkt_dat_type_len(fh, &dat_trans_type, &dat_len, err, err_info))
-        return FALSE;
+        return -1;
 
     buffer_assure_space(buf, DVB_CI_PSEUDO_HDR_LEN+dat_len);
     p = buffer_start_ptr(buf);
@@ -276,7 +276,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
         /* shouldn't happen, all invalid packets must be detected by
            find_next_pkt_dat_type_len() */
         *err = WTAP_ERR_INTERNAL;
-        return FALSE;
+        return -1;
     }
 
     bytes_read = read_packet_data(fh, dat_trans_type,
@@ -284,7 +284,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     /* 0<=bytes_read<=dat_len is very likely a corrupted packet
        we let the dissector handle this */
     if (bytes_read < 0)
-        return FALSE;
+        return -1;
     offset += bytes_read;
 
     phdr->pkt_encap = WTAP_ENCAP_DVBCI;
@@ -292,11 +292,11 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     phdr->caplen = offset;
     phdr->len = offset;
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
-static gboolean
+static int
 camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     *data_offset = file_tell(wth->fh);
@@ -306,12 +306,12 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 }
 
 
-static gboolean
+static int
 camins_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *pkthdr, Buffer *buf, int *err, gchar **err_info)
 {
     if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
-        return FALSE;
+        return -1;
 
     return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info);
 }
index 8b29a23880a2bf049b967712660549621f1adbfc..aece8e75fd6ef95c01c708f064e9dc0ceb1b412a 100644 (file)
@@ -103,12 +103,12 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript";
 
 /************************************************************/
 /* Functions called from wiretap core                       */
-static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
-                                      gint64 *data_offset);
-static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
-                                           struct wtap_pkthdr *phdr,
-                                           Buffer *buf, int *err,
-                                           gchar **err_info);
+static int catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
+                                 gint64 *data_offset);
+static int catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
+                                      struct wtap_pkthdr *phdr,
+                                      Buffer *buf, int *err,
+                                      gchar **err_info);
 static void catapult_dct2000_close(wtap *wth);
 
 static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
@@ -331,9 +331,9 @@ static void write_timestamp_string(char *timestamp_string, int secs, int tenthou
 /**************************************************/
 /* Read packet function.                          */
 /* Look for and read the next usable packet       */
-/* - return TRUE and details if found             */
+/* - return REC_TYPE_PACKET and details if found  */
 /**************************************************/
-static gboolean
+static int
 catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
                       gint64 *data_offset)
 {
@@ -370,7 +370,7 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
         if (!read_new_line(wth->fh, &offset, &line_length, linebuff,
                            sizeof linebuff, err, err_info)) {
             if (*err != 0)
-                return FALSE;  /* error */
+                return -1;  /* error */
             /* No more lines can be read, so quit. */
             break;
         }
@@ -434,19 +434,19 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
             g_hash_table_insert(file_externals->packet_prefix_table, pkey, line_prefix_info);
 
             /* OK, we have packet details to return */
-            return TRUE;
+            return REC_TYPE_PACKET;
         }
     }
 
     /* No packet details to return... */
-    return FALSE;
+    return -1;
 }
 
 
 /**************************************************/
 /* Read & seek function.                          */
 /**************************************************/
-static gboolean
+static int
 catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
                            struct wtap_pkthdr *phdr, Buffer *buf,
                            int *err, gchar **err_info)
@@ -476,13 +476,13 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
 
     /* Seek to beginning of packet */
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
-        return FALSE;
+        return -1;
     }
 
     /* Re-read whole line (this really should succeed) */
     if (!read_new_line(wth->random_fh, &offset, &length, linebuff,
                       sizeof linebuff, err, err_info)) {
-        return FALSE;
+        return -1;
     }
 
     /* Try to parse this line again (should succeed as re-reading...) */
@@ -508,7 +508,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
                             is_comment, data_chars);
 
         *err = errno = 0;
-        return TRUE;
+        return REC_TYPE_PACKET;
     }
 
     /* If get here, must have failed */
@@ -516,7 +516,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
     *err_info = g_strdup_printf("catapult dct2000: seek_read failed to read/parse "
                                 "line at position %" G_GINT64_MODIFIER "d",
                                 seek_off);
-    return FALSE;
+    return -1;
 }
 
 
index e2a868a6b27c0cb80122c2dcdfa08bcf29632095..fa7660bbff566f7ab7b010224d26625d8a184ab1 100644 (file)
@@ -78,11 +78,11 @@ typedef struct commview_header {
 #define MEDIUM_WIFI            1
 #define MEDIUM_TOKEN_RING      2
 
-static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
-                             gint64 *data_offset);
-static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
-                                  struct wtap_pkthdr *phdr,
-                                  Buffer *buf, int *err, gchar **err_info);
+static int commview_read(wtap *wth, int *err, gchar **err_info,
+                        gint64 *data_offset);
+static int commview_seek_read(wtap *wth, gint64 seek_off,
+                             struct wtap_pkthdr *phdr,
+                             Buffer *buf, int *err, gchar **err_info);
 static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
                                     int *err, gchar **err_info);
 static gboolean commview_dump(wtap_dumper *wdh,        const struct wtap_pkthdr *phdr,
@@ -136,7 +136,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        struct tm tm;
 
        if(!commview_read_header(&cv_hdr, fh, err, err_info))
-               return FALSE;
+               return -1;
 
        switch(cv_hdr.flags & FLAGS_MEDIUM) {
 
@@ -162,7 +162,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("commview: unsupported encap: %u",
                                            cv_hdr.flags & FLAGS_MEDIUM);
-               return FALSE;
+               return -1;
        }
 
        tm.tm_year = cv_hdr.year - 1900;
@@ -181,10 +181,12 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        phdr->ts.secs = mktime(&tm);
        phdr->ts.nsecs = cv_hdr.usecs * 1000;
 
-       return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
+       if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -193,12 +195,12 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
            err_info);
 }
 
-static gboolean
+static int
 commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                   Buffer *buf, int *err, gchar **err_info)
 {
        if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        return commview_read_packet(wth->random_fh, phdr, buf, err, err_info);
 }
index d9370187968385bf4e7988f26928f2b975223971..18b2065287e445075c0e374a257f76dd439ffea1 100644 (file)
@@ -166,13 +166,13 @@ static gboolean empty_line(const gchar *line);
 static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
        char *hdr);
 static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
-static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
+static int cosine_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
+static int cosine_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
        int *err, gchar **err_info);
-static gboolean parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr,
+static int parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr,
        int pkt_len, Buffer* buf, int *err, gchar **err_info);
 static int parse_single_hex_dump_line(char* rec, guint8 *buf,
        guint byte_offset);
@@ -286,7 +286,7 @@ int cosine_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
+static int cosine_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -296,13 +296,13 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = cosine_seek_next_packet(wth, err, err_info, line);
        if (offset < 0)
-               return FALSE;
+               return -1;
        *data_offset = offset;
 
        /* Parse the header */
        pkt_len = parse_cosine_rec_hdr(&wth->phdr, line, err, err_info);
        if (pkt_len == -1)
-               return FALSE;
+               return -1;
 
        /* Convert the ASCII hex dump to binary data */
        return parse_cosine_hex_dump(wth->fh, &wth->phdr, pkt_len,
@@ -310,7 +310,7 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
 }
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
@@ -435,9 +435,9 @@ parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
        return pkt_len;
 }
 
-/* Converts ASCII hex dump to binary data. Returns TRUE on success,
-   FALSE if any error is encountered. */
-static gboolean
+/* Converts ASCII hex dump to binary data. Returns REC_TYPE_PACKET on success,
+   -1 if any error is encountered. */
+static int
 parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len,
     Buffer* buf, int *err, gchar **err_info)
 {
@@ -459,7 +459,7 @@ parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len,
                        if (*err == 0) {
                                *err = WTAP_ERR_SHORT_READ;
                        }
-                       return FALSE;
+                       return -1;
                }
                if (empty_line(line)) {
                        break;
@@ -467,12 +467,12 @@ parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len,
                if ((n = parse_single_hex_dump_line(line, pd, i*16)) == -1) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("cosine: hex dump line doesn't have 16 numbers");
-                       return FALSE;
+                       return -1;
                }
                caplen += n;
        }
        phdr->caplen = caplen;
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 
index bc640f639d1e87d794d18b6b0e29c38e05d2ebc6..7145b62749df0b1cac3d8b9697ce597f7ff1f4a1 100644 (file)
@@ -44,9 +44,9 @@ typedef struct {
        gboolean byteswapped;
 } csids_t;
 
-static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
+static int csids_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
+static int csids_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean csids_read_packet(FILE_T fh, csids_t *csids,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
@@ -144,19 +144,21 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
+static int csids_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
   csids_t *csids = (csids_t *)wth->priv;
 
   *data_offset = file_tell(wth->fh);
 
-  return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
-                            err, err_info );
+  if (!csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
+                          err, err_info ))
+    return -1;
+  return REC_TYPE_PACKET;
 }
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 csids_seek_read(wtap *wth,
                 gint64 seek_off,
                 struct wtap_pkthdr *phdr,
@@ -167,14 +169,14 @@ csids_seek_read(wtap *wth,
   csids_t *csids = (csids_t *)wth->priv;
 
   if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
-    return FALSE;
+    return -1;
 
   if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) {
     if( *err == 0 )
       *err = WTAP_ERR_SHORT_READ;
-    return FALSE;
+    return -1;
   }
-  return TRUE;
+  return REC_TYPE_PACKET;
 }
 
 static gboolean
index 23785548d27d27703c84fa997fc88f89cbc96b2b..bb25611fd887fb6a923b8a24638d09ef71ba6ba9 100644 (file)
@@ -77,16 +77,16 @@ static const char daintree_magic_text[] =
 
 #define COMMENT_LINE daintree_magic_text[0]
 
-static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
+static int daintree_sna_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
 
-static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
+static int daintree_sna_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 static gboolean daintree_sna_scan_header(struct wtap_pkthdr *phdr,
        char *readLine, char *readData, int *err, gchar **err_info);
 
-static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
+static int daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
        Buffer *buf, char *readData, int *err, gchar **err_info);
 
 /* Open a file and determine if it's a Daintree file */
@@ -134,7 +134,7 @@ int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
 
 /* Read the capture file sequentially
  * Wireshark scans the file with sequential reads during preview and initial display. */
-static gboolean
+static int
 daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        char readLine[DAINTREE_MAX_LINE_SIZE];
@@ -147,14 +147,14 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
        do {
                if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) {
                        *err = file_error(wth->fh, err_info);
-                       return FALSE; /* all done */
+                       return -1; /* all done */
                }
        } while (readLine[0] == COMMENT_LINE);
 
        /* parse one line of capture data */
        if (!daintree_sna_scan_header(&wth->phdr, readLine, readData,
            err, err_info))
-               return FALSE;
+               return -1;
 
        /* process packet data */
        return daintree_sna_process_hex_data(&wth->phdr, wth->frame_buffer,
@@ -163,7 +163,7 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
 /* Read the capture file randomly
  * Wireshark opens the capture file for random access when displaying user-selected packets */
-static gboolean
+static int
 daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
@@ -171,20 +171,20 @@ daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        char readData[READDATA_BUF_SIZE];
 
        if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* It appears only file header lines start with '#', but
         * if we find any others, we toss them */
        do {
                if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) {
                        *err = file_error(wth->random_fh, err_info);
-                       return FALSE; /* all done */
+                       return -1; /* all done */
                }
        } while (readLine[0] == COMMENT_LINE);
 
        /* parse one line of capture data */
        if (!daintree_sna_scan_header(phdr, readLine, readData, err, err_info))
-               return FALSE;
+               return -1;
 
        /* process packet data */
        return daintree_sna_process_hex_data(phdr, buf, readData, err,
@@ -226,7 +226,7 @@ daintree_sna_scan_header(struct wtap_pkthdr *phdr, char *readLine,
 /* Convert packet data from ASCII hex string to binary in place,
  * sanity-check its length against what we assume is the packet length field,
  * and copy it into a Buffer */
-static gboolean
+static int
 daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
     char *readData, int *err, gchar **err_info)
 {
@@ -242,7 +242,7 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
                if (!isxdigit((guchar)*str)) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("daintree_sna: non-hex digit in hex data");
-                       return FALSE;
+                       return -1;
                }
                if(isdigit((guchar)*str)) {
                        *p = (*str - '0') << 4;
@@ -255,7 +255,7 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
                if (!isxdigit((guchar)*str)) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("daintree_sna: non-hex digit in hex data");
-                       return FALSE;
+                       return -1;
                }
                if(isdigit((guchar)*str)) {
                        *p += *str - '0';
@@ -274,19 +274,19 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("daintree_sna: Only %u bytes of packet data",
                    bytes);
-               return FALSE;
+               return -1;
        }
        bytes -= FCS_LENGTH;
        if (bytes > phdr->len) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("daintree_sna: capture length (%u) > packet length (%u)",
                    bytes, phdr->len);
-               return FALSE;
+               return -1;
        }
 
        phdr->caplen = bytes;
 
        buffer_assure_space(buf, bytes);
        memcpy(buffer_start_ptr(buf), readData, bytes);
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
index 0a3e9f57e12e110cdceb14b9e916c5d8e58cff82..31fa9af6306a76e8379e5482cc8ea93b08654865 100644 (file)
@@ -84,11 +84,11 @@ static const char dbs_etherwatch_rec_magic[]  =
  */
 #define DBS_ETHERWATCH_MAX_PACKET_LEN  16384
 
-static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
+static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
+static int dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
+static int parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
        Buffer* buf, int *err, gchar **err_info);
 static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
        int byte_offset);
@@ -196,7 +196,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
+static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -204,7 +204,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
        if (offset < 1)
-               return FALSE;
+               return -1;
        *data_offset = offset;
 
        /* Parse the packet */
@@ -213,12 +213,12 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
 }
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err,
            err_info);
@@ -268,7 +268,7 @@ unnumbered. Unnumbered has length 1, numbered 2.
 */
 #define CTL_UNNUMB_MASK                0x03
 #define CTL_UNNUMB_VALUE       0x03
-static gboolean
+static int
 parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
     int *err, gchar **err_info)
 {
@@ -298,7 +298,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                if (*err == 0) {
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return FALSE;
+               return -1;
        }
 
        /* Get the destination address */
@@ -306,14 +306,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
        if(!p) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: destination address not found");
-               return FALSE;
+               return -1;
        }
        p += strlen(DEST_MAC_PREFIX);
        if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END)
                                != MAC_ADDR_LENGTH) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: destination address not valid");
-               return FALSE;
+               return -1;
        }
        eth_hdr_len += MAC_ADDR_LENGTH;
 
@@ -331,7 +331,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                HEX_HDR_END) != MAC_ADDR_LENGTH) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: source address not valid");
-               return FALSE;
+               return -1;
        }
        eth_hdr_len += MAC_ADDR_LENGTH;
 
@@ -341,14 +341,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                if (*err == 0) {
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return FALSE;
+               return -1;
        }
 
        /* Check the lines is as least as long as the length position */
        if(strlen(line) < LENGTH_POS) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: line too short");
-               return FALSE;
+               return -1;
        }
 
        num_items_scanned = sscanf(line + LENGTH_POS,
@@ -361,7 +361,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
        if (num_items_scanned != 8) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: header line not valid");
-               return FALSE;
+               return -1;
        }
 
        /* Determine whether it is Ethernet II or IEEE 802 */
@@ -373,7 +373,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                        HEX_HDR_END) != PROTOCOL_LENGTH) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid");
-                       return FALSE;
+                       return -1;
                }
                eth_hdr_len += PROTOCOL_LENGTH;
        } else {
@@ -389,7 +389,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                        HEX_HDR_END) != SAP_LENGTH) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid");
-                       return FALSE;
+                       return -1;
                }
                eth_hdr_len += SAP_LENGTH;
                /* Get the (first part of the) control field */
@@ -397,7 +397,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                        HEX_HDR_END) != CTL_UNNUMB_LENGTH) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid");
-                       return FALSE;
+                       return -1;
                }
                /* Determine whether the control is numbered, and thus longer */
                if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) {
@@ -407,7 +407,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                                HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) {
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid");
-                               return FALSE;
+                               return -1;
                        }
                        eth_hdr_len += CTL_NUMB_LENGTH;
                } else {
@@ -421,7 +421,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                                HEX_PID_END) != PID_LENGTH) {
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid");
-                               return FALSE;
+                               return -1;
                        }
                        eth_hdr_len += PID_LENGTH;
                }
@@ -457,22 +457,22 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                        if (*err == 0) {
                                *err = WTAP_ERR_SHORT_READ;
                        }
-                       return FALSE;
+                       return -1;
                }
                if (!(line_count = parse_single_hex_dump_line(line,
                                &pd[eth_hdr_len + count], count))) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: packet data value not valid");
-                       return FALSE;
+                       return -1;
                }
                count += line_count;
                if (count > pkt_len) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes");
-                       return FALSE;
+                       return -1;
                }
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /* Parse a hex dump line */
index 2a0eb9103ac4d3738ad09471fc2787ae6a04e506..032df310a28442184e40d7486862f130623ff208 100644 (file)
@@ -73,9 +73,9 @@ static const char dct3trace_magic_end[]  = "</dump>";
 
 #define MAX_PACKET_LEN 23
 
-static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
+static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
+static int dct3trace_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 /*
@@ -187,7 +187,7 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info)
 }
 
 
-static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
+static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
        char line[1024];
@@ -202,7 +202,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                {
                        /* Return on end of file </dump> */
                        *err = 0;
-                       return FALSE;
+                       return -1;
                }
                else if( memcmp(dct3trace_magic_record_end, line, strlen(dct3trace_magic_record_end)) == 0 )
                {
@@ -222,14 +222,14 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                                buffer_assure_space(buf, phdr->caplen);
                                memcpy( buffer_start_ptr(buf), databuf, phdr->caplen );
 
-                               return TRUE;
+                               return REC_TYPE_PACKET;
                        }
                        else
                        {
                                /* If not got any data return error */
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup_printf("dct3trace: record without data");
-                               return FALSE;
+                               return -1;
                        }
                }
                else if( memcmp(dct3trace_magic_record_start, line, strlen(dct3trace_magic_record_start)) == 0 )
@@ -282,7 +282,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                                {
                                        *err = WTAP_ERR_BAD_FILE;
                                        *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen);
-                                       return FALSE;
+                                       return -1;
                                }
                        }
                }
@@ -322,7 +322,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                        {
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen);
-                               return FALSE;
+                               return -1;
                        }
                        len += data_len;
 
@@ -336,17 +336,17 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
        {
                *err = WTAP_ERR_SHORT_READ;
        }
-       return FALSE;
+       return -1;
 
 baddata:
        *err = WTAP_ERR_BAD_FILE;
        *err_info = g_strdup_printf("dct3trace: record missing mandatory attributes");
-       return FALSE;
+       return -1;
 }
 
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
+static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -357,12 +357,12 @@ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
 
 
 /* Used to read packets in random-access fashion */
-static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
+static int dct3trace_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
        {
-               return FALSE;
+               return -1;
        }
 
        return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info);
index 67b7ccab1d522087056296e12bb16c1ca3a38e84..3513642121806835397aabaa8bf69fc6499779c2 100644 (file)
@@ -64,11 +64,11 @@ static int erf_read_header(FILE_T fh,
                            gchar **err_info,
                            guint32 *bytes_read,
                            guint32 *packet_size);
-static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
-                         gint64 *data_offset);
-static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
-                              struct wtap_pkthdr *phdr, Buffer *buf,
-                              int *err, gchar **err_info);
+static int erf_read(wtap *wth, int *err, gchar **err_info,
+                    gint64 *data_offset);
+static int erf_seek_read(wtap *wth, gint64 seek_off,
+                         struct wtap_pkthdr *phdr, Buffer *buf,
+                         int *err, gchar **err_info);
 
 static const struct {
   int erf_encap_value;
@@ -280,7 +280,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
+static int erf_read(wtap *wth, int *err, gchar **err_info,
                          gint64 *data_offset)
 {
   erf_header_t erf_header;
@@ -292,36 +292,38 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
     if (!erf_read_header(wth->fh,
                          &wth->phdr, &erf_header,
                          err, err_info, &bytes_read, &packet_size)) {
-      return FALSE;
+      return -1;
     }
 
     if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size,
                                 err, err_info))
-      return FALSE;
+      return -1;
 
   } while ( erf_header.type == ERF_TYPE_PAD );
 
-  return TRUE;
+  return REC_TYPE_PACKET;
 }
 
-static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
-                              struct wtap_pkthdr *phdr, Buffer *buf,
-                              int *err, gchar **err_info)
+static int erf_seek_read(wtap *wth, gint64 seek_off,
+                         struct wtap_pkthdr *phdr, Buffer *buf,
+                         int *err, gchar **err_info)
 {
   erf_header_t erf_header;
   guint32      packet_size;
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
 
   do {
     if (!erf_read_header(wth->random_fh, phdr, &erf_header,
                          err, err_info, NULL, &packet_size))
-      return FALSE;
+      return -1;
   } while ( erf_header.type == ERF_TYPE_PAD );
 
-  return wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
-                                err, err_info);
+  if (!wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
+                              err, err_info))
+    return -1;
+  return REC_TYPE_PACKET;
 }
 
 static int erf_read_header(FILE_T fh,
index 8bd32c224970cb4607d404147965f4de12526539..4444b0d9f5df5b2cfc51471f717318ca7fd2aa26 100644 (file)
@@ -90,9 +90,9 @@ static const unsigned char eyesdn_hdr_magic[]  =
  */
 #define EYESDN_MAX_PACKET_LEN  16384
 
-static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
+static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
+static int eyesdn_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
        int *err, gchar **err_info);
@@ -149,7 +149,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
+static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -157,7 +157,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next record */
        offset = eyesdn_seek_next_packet(wth, err, err_info);
        if (offset < 1)
-               return FALSE;
+               return -1;
        *data_offset = offset;
 
        /* Parse the record */
@@ -166,18 +166,18 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
 }
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info);
 }
 
 /* Parses a record. */
-static gboolean
+static int
 read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
     gchar **err_info)
 {
@@ -198,7 +198,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                *err = file_error(fh, err_info);
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
 
         /* extract information from header */
@@ -251,7 +251,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                        *err_info = g_strdup_printf(
                            "eyesdn: ATM cell has a length != 53 (%u)",
                            pkt_len);
-                       return FALSE;
+                       return -1;
                }
 
                cur_off = file_tell(fh);
@@ -259,10 +259,10 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                        *err = file_error(fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
-                       return FALSE;
+                       return -1;
                }
                if (file_seek(fh, cur_off, SEEK_SET, err) == -1)
-                       return FALSE;
+                       return -1;
                phdr->pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED;
                pseudo_header->atm.flags=ATM_RAW_CELL;
                pseudo_header->atm.aal=AAL_UNKNOWN;
@@ -310,7 +310,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("eyesdn: File has %u-byte packet, bigger than maximum of %u",
                    pkt_len, EYESDN_MAX_PACKET_LEN);
-               return FALSE;
+               return -1;
        }
 
        phdr->presence_flags = WTAP_HAS_TS;
@@ -335,9 +335,9 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                        *err_info = g_strdup("eyesdn: No flag character seen in frame");
                } else
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;;
 }
 
 
index cc38a621544104ee802c7cb586b6eba8bb19d22f..22483b7d6ad123f5a595a98d820dfd5157c67eb4 100644 (file)
@@ -34,7 +34,7 @@ struct dump_hdr {
 
 #define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
 
-static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
+static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        struct dump_hdr dh;
@@ -45,7 +45,7 @@ static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                *err = file_error(fh, err_info);
                if (*err == 0 && bytes_read != 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
 
        packet_size = GUINT16_FROM_LE(dh.len);
@@ -57,7 +57,7 @@ static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u",
                        packet_size, WTAP_MAX_PACKET_SIZE);
-               return FALSE;
+               return -1;
        }
 
        phdr->presence_flags = WTAP_HAS_TS;
@@ -68,10 +68,12 @@ static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
 
        phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);
 
-       return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+       if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
+static int hcidump_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -80,11 +82,11 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
            err, err_info);
 }
 
-static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
+static int hcidump_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        return hcidump_process_packet(wth->random_fh, phdr, buf, err, err_info);
 }
index d474ec2c8f9e8d66b808ddcc84ecce1d13bc362e..00cf9e876c0fd7ea59ea220da115ee7f779ff4b2 100644 (file)
@@ -33,11 +33,11 @@ typedef struct {
        gboolean byte_swapped;
 } i4btrace_t;
 
-static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
+static int i4btrace_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
+static int i4btrace_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info);
 
 /*
@@ -110,21 +110,23 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
+static int i4btrace_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
-           err, err_info);
+       if (!i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+           err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
                /* Read error or EOF */
@@ -132,12 +134,12 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                        /* EOF means "short read" in random-access mode */
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static int
+static gboolean
 i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
 {
index 061a53d79cd41b47a6ff512666c826606b3bc234..87de43359991eef0a7c6a93befea81f97d863da8 100644 (file)
 
 #define RECORDS_FOR_IPFIX_CHECK 20
 
-static gboolean
+static int
 ipfix_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean
+static int
 ipfix_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static void
@@ -280,7 +280,7 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
 
 
 /* classic wtap: read packet */
-static gboolean
+static int
 ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     *data_offset = file_tell(wth->fh);
@@ -289,15 +289,15 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
     if (!ipfix_read_message(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) {
         ipfix_debug2("ipfix_read: couldn't read message header with code: %d\n, and error '%s'",
                      *err, *err_info);
-        return FALSE;
+        return -1;
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
 /* classic wtap: seek to file position and read packet */
-static gboolean
+static int
 ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
@@ -305,7 +305,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
         ipfix_debug2("ipfix_seek_read: couldn't read message header with code: %d\n, and error '%s'",
                      *err, *err_info);
-        return FALSE;   /* Seek error */
+        return -1;   /* Seek error */
     }
 
     ipfix_debug1("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
@@ -314,9 +314,9 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
         ipfix_debug0("ipfix_seek_read: couldn't read message header");
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
index 67e8e65806ad4551a94fd9f2a01604a8a72c6195..3f128fe2050ed4ff21e346cee5cbe5bbdb6f3580 100644 (file)
@@ -214,7 +214,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
 }
 
 /* Read the next packet */
-static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
+static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -223,7 +223,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
        if (!iptrace_read_rec_1_0(wth->fh, &wth->phdr, wth->frame_buffer,
            err, err_info)) {
                /* Read error or EOF */
-               return FALSE;
+               return -1;
        }
 
        /* If the per-file encapsulation isn't known, set it to this
@@ -239,22 +239,22 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
                        wth->file_encap = WTAP_ENCAP_PER_PACKET;
        }
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
+static int iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* Read the packet */
        if (!iptrace_read_rec_1_0(wth->random_fh, phdr, buf, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /***********************************************************
@@ -409,7 +409,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
 }
 
 /* Read the next packet */
-static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
+static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -418,7 +418,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
        if (!iptrace_read_rec_2_0(wth->fh, &wth->phdr, wth->frame_buffer,
            err, err_info)) {
                /* Read error or EOF */
-               return FALSE;
+               return -1;
        }
 
        /* If the per-file encapsulation isn't known, set it to this
@@ -434,22 +434,22 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
                        wth->file_encap = WTAP_ENCAP_PER_PACKET;
        }
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
+static int iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* Read the packet */
        if (!iptrace_read_rec_2_0(wth->random_fh, phdr, buf, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static int
index 0a171a63410cce8ca7cf18714534e23090370bb1..4c42fb45020abd25b7eb9a7cb4344b638f0734d4 100644 (file)
@@ -187,9 +187,9 @@ static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
 static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
                                          int format);
 static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
-static gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
-                                      struct wtap_pkthdr *phdr,
-                                      Buffer * buf, int *err, gchar ** err_info);
+static int iseries_parse_packet (wtap * wth, FILE_T fh,
+                                 struct wtap_pkthdr *phdr,
+                                 Buffer * buf, int *err, gchar ** err_info);
 static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
 static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
                                           size_t len);
@@ -370,7 +370,7 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
 /*
  * Find the next packet and parse it; called from wtap_read().
  */
-static gboolean
+static int
 iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
 {
   gint64 offset;
@@ -457,14 +457,14 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
 /*
  * Read packets in random-access fashion
  */
-static gboolean
+static int
 iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                    Buffer * buf, int *err, gchar ** err_info)
 {
 
   /* seek to packet location */
   if (file_seek (wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
 
   /*
    * Parse the packet and extract the various fields
@@ -554,7 +554,7 @@ done:
 }
 
 /* Parses a packet. */
-static gboolean
+static int
 iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
                       Buffer *buf, int *err, gchar **err_info)
 {
@@ -581,7 +581,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
       if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
         {
           *err = file_error (fh, err_info);
-          return FALSE;
+          return -1;
         }
       /* Convert UNICODE data to ASCII */
       if (iseries->format == ISERIES_FORMAT_UNICODE)
@@ -615,7 +615,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
     {
       *err = WTAP_ERR_BAD_FILE;
       *err_info = g_strdup ("iseries: packet header isn't valid");
-      return FALSE;
+      return -1;
     }
 
   phdr->presence_flags = WTAP_HAS_CAP_LEN;
@@ -747,7 +747,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
               if (ascii_offset == -1)
                 {
                   /* Bad line. */
-                  return FALSE;
+                  return -1;
                 }
               continue;
             }
@@ -769,7 +769,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
               if (ascii_offset == -1)
                 {
                   /* Bad line. */
-                  return FALSE;
+                  return -1;
                 }
               continue;
             }
@@ -792,7 +792,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
           if (ascii_offset == -1)
             {
               /* Bad line. */
-              return FALSE;
+              return -1;
             }
           continue;
         }
@@ -842,11 +842,11 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
   /* free buffer allocs and return */
   *err = 0;
   g_free (ascii_buf);
-  return TRUE;
+  return REC_TYPE_PACKET;
 
 errxit:
   g_free (ascii_buf);
-  return FALSE;
+  return -1;
 }
 
 /*
index cd1bbe61041dd9dee11e44a103893806f12b47dc..013c19e6f672d2ee990d628087305b17d67e3506 100644 (file)
@@ -623,7 +623,7 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
     phdr->pseudo_header.k12.stuff = k12;
 }
 
-static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
+static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
     k12_t *k12 = (k12_t *)wth->priv;
     k12_src_desc_t* src_desc;
     guint8* buffer;
@@ -644,16 +644,16 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
 
         if (len < 0) {
             /* read error */
-            return FALSE;
+            return -1;
         } else if (len == 0) {
             /* EOF */
             *err = 0;
-            return FALSE;
+            return -1;
         } else if (len < K12_RECORD_SRC_ID + 4) {
             /* Record not large enough to contain a src ID */
             *err = WTAP_ERR_BAD_FILE;
             *err_info = g_strdup_printf("data record length %d too short", len);
-            return FALSE;
+            return -1;
         }
 
         buffer = k12->seq_read_buff;
@@ -681,11 +681,11 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
 
     process_packet_data(&wth->phdr, wth->frame_buffer, buffer, len, k12);
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
-static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
+static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
     k12_t *k12 = (k12_t *)wth->priv;
     guint8* buffer;
     gint len;
@@ -694,18 +694,18 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
 
     if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
         K12_DBG(5,("k12_seek_read: SEEK ERROR"));
-        return FALSE;
+        return -1;
     }
 
     len = get_record(k12, wth->random_fh, seek_off, TRUE, err, err_info);
     if (len < 0) {
         K12_DBG(5,("k12_seek_read: READ ERROR"));
-        return FALSE;
+        return -1;
     } else if (len < K12_RECORD_SRC_ID + 4) {
         /* Record not large enough to contain a src ID */
         K12_DBG(5,("k12_seek_read: SHORT READ"));
         *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
 
     buffer = k12->rand_read_buff;
@@ -714,7 +714,7 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
 
     K12_DBG(5,("k12_seek_read: DONE OK"));
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
index 42de8e68756ec3ee4314e83e59277b2f28bd35f3..8db5c673c8a69704fbef13a088c089660e387ac9 100644 (file)
@@ -244,7 +244,7 @@ k12text_reset(FILE_T fh)
        ii=0;
 }
 
-static gboolean
+static int
 k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
 {
        k12text_t *k12text = (k12text_t *)wth->priv;
@@ -259,7 +259,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
         */
 
        if ( file_seek(wth->fh, k12text->next_frame_offset, SEEK_SET, err) == -1) {
-               return FALSE;
+               return -1;
        }
        k12text_reset(wth->fh);         /* init lexer buffer and vars set by lexer */
 
@@ -274,7 +274,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = error_str;
                }
-               return FALSE;
+               return -1;
        }
 
        *data_offset = k12text->next_frame_offset;       /* file position for beginning of this frame   */
@@ -285,14 +285,14 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
        buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
        memcpy(buffer_start_ptr(wth->frame_buffer), bb, wth->phdr.caplen);
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, char **err_info)
 {
        if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
-               return FALSE;
+               return -1;
        }
        k12text_reset(wth->random_fh);          /* init lexer buffer and vars set by lexer */
 
@@ -307,7 +307,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
                } else {
                        *err_info = error_str;
                }
-               return FALSE;
+               return -1;
        }
 
        k12text_set_headers(phdr);
@@ -315,7 +315,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
        buffer_assure_space(buf, phdr->caplen);
        memcpy(buffer_start_ptr(buf), bb, phdr->caplen);
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 int
index 8c2ce348a1426bebd2977cf5266c0f87183ea7f8..5c4942b10ec7c951067ff8fb3c0db0dfec09e32f 100644 (file)
@@ -270,9 +270,9 @@ typedef struct {
        time_t  start;
 } lanalyzer_t;
 
-static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
+static int lanalyzer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
+static int lanalyzer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
 
@@ -560,30 +560,32 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
 }
 
 /* Read the next packet */
-static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
+static int lanalyzer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
        /* Read the record  */
-       return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
-           wth->frame_buffer, err, err_info);
+       if (!lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
+           wth->frame_buffer, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
+static int lanalyzer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* Read the record  */
        if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
            err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /*---------------------------------------------------
index fe9c111261bb43f1732c3e1de59108a61ea6789c..7d467cb06c6108028feb47a15fa9fad7930a7b64 100644 (file)
@@ -63,9 +63,9 @@ typedef enum {
 } libpcap_try_t;
 static libpcap_try_t libpcap_try(wtap *wth, int *err);
 
-static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
+static int libpcap_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
+static int libpcap_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
     struct pcaprec_ss990915_hdr *hdr);
@@ -590,13 +590,15 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err)
 }
 
 /* Read the next packet */
-static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
+static int libpcap_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       return libpcap_read_packet(wth, wth->fh, &wth->phdr,
-           wth->frame_buffer, err, err_info);
+       if (!libpcap_read_packet(wth, wth->fh, &wth->phdr,
+           wth->frame_buffer, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
@@ -604,15 +606,15 @@ libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err,
            err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
index a1a41c0689b0aea88010fc6a46e05838d60bb104..022b6a230841643dd302fb03dc2af866ebd3ae5b 100644 (file)
@@ -214,29 +214,31 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
     return TRUE;
 }
 
-static gboolean logcat_read(wtap *wth, int *err, gchar **err_info,
+static int logcat_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     *data_offset = file_tell(wth->fh);
 
-    return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
-        &wth->phdr, wth->frame_buffer, err, err_info);
+    if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
+        &wth->phdr, wth->frame_buffer, err, err_info))
+        return -1;
+    return REC_TYPE_PACKET;
 }
 
-static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
+static int logcat_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh,
          phdr, buf, err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 int logcat_open(wtap *wth, int *err, gchar **err_info _U_)
index 2a7d8be0e4eac46443a3e00ed9bc2a80981c2206..0f8934a28e61d4fefe41ce699d71f7d4344c7147 100644 (file)
@@ -94,7 +94,7 @@ static const mime_files_t magic_files[] = {
  */
 #define MAX_FILE_SIZE  (16*1024*1024)
 
-static gboolean
+static int
 mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
@@ -102,7 +102,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        int packet_size;
 
        if ((file_size = wtap_file_size(wth, err)) == -1)
-               return FALSE;
+               return -1;
 
        if (file_size > MAX_FILE_SIZE) {
                /*
@@ -112,7 +112,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("mime_file: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
                                file_size, MAX_FILE_SIZE);
-               return FALSE;
+               return -1;
        }
        packet_size = (int)file_size;
 
@@ -124,10 +124,12 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        phdr->ts.secs = 0;
        phdr->ts.nsecs = 0;
 
-       return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+       if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        gint64 offset;
@@ -138,24 +140,24 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
        /* there is only ever one packet */
        if (offset != 0)
-               return FALSE;
+               return -1;
 
        *data_offset = offset;
 
        return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static gboolean
+static int
 mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        /* there is only one packet */
        if (seek_off > 0) {
                *err = 0;
-               return FALSE;
+               return -1;
        }
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index 844fb40a1362108a9404e7d192961b8412b934a0..8b44a1bd4c7029de12cd4cb950c0930ef112e4b5 100644 (file)
@@ -102,7 +102,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
     return TRUE;
 }
 
-static gboolean
+static int
 mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     mp2t_filetype_t *mp2t;
@@ -113,27 +113,27 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
     if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, &wth->phdr,
                           wth->frame_buffer, err, err_info)) {
-        return FALSE;
+        return -1;
     }
 
     /* if there's a trailer, skip it and go to the start of the next packet */
     if (mp2t->trailer_len!=0) {
         if (-1 == file_seek(wth->fh, mp2t->trailer_len, SEEK_CUR, err)) {
-            return FALSE;
+            return -1;
         }
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
         Buffer *buf, int *err, gchar **err_info)
 {
     mp2t_filetype_t *mp2t;
 
     if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) {
-        return FALSE;
+        return -1;
     }
 
     mp2t = (mp2t_filetype_t*) wth->priv;
@@ -142,9 +142,9 @@ mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                           err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 int
index abe87a37fe19788aebc932e2b01d5fd165183ec8..2f4998ebb3f408326b390bca32c9f99b5482f5d2 100644 (file)
@@ -220,30 +220,32 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        return TRUE;
 }
 
-static gboolean
+static int
 mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
-           FALSE, err, err_info);
+       if (!mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+           FALSE, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 mpeg_seek_read(wtap *wth, gint64 seek_off,
                struct wtap_pkthdr *phdr, Buffer *buf,
                int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err,
            err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 struct _mpeg_magic {
index f12bf43a87cd91471d5092665dd5fa6bb40ad432..85f3234121b977919135711c1e7e31df0f340b59 100644 (file)
@@ -175,9 +175,9 @@ static const int netmon_encap[] = {
 #define NETMON_NET_DNS_CACHE           0xFFFE
 #define NETMON_NET_NETMON_FILTER       0xFFFF
 
-static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
+static int netmon_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
+static int netmon_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
     union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
@@ -677,7 +677,7 @@ static process_trailer_retval netmon_process_rec_trailer(netmon_t *netmon,
 }
 
 /* Read the next packet */
-static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
+static int netmon_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        netmon_t *netmon = (netmon_t *)wth->priv;
@@ -691,7 +691,7 @@ again:
                g_free(netmon->frame_table);
                netmon->frame_table = NULL;
                *err = 0;       /* it's just an EOF, not an error */
-               return FALSE;
+               return -1;
        }
 
        /* Seek to the beginning of the current record, if we're
@@ -707,7 +707,7 @@ again:
        rec_offset = netmon->frame_table[netmon->current_frame];
        if (file_tell(wth->fh) != rec_offset) {
                if (file_seek(wth->fh, rec_offset, SEEK_SET, err) == -1)
-                       return FALSE;
+                       return -1;
        }
        netmon->current_frame++;
 
@@ -715,11 +715,11 @@ again:
 
        if (!netmon_process_rec_header(wth, wth->fh, &wth->phdr,
            err, err_info))
-               return FALSE;
+               return -1;
 
        if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
            wth->phdr.caplen, err, err_info))
-               return FALSE;   /* Read error */
+               return -1;      /* Read error */
 
        /*
         * For version 2.1 and later, there's additional information
@@ -735,33 +735,33 @@ again:
                break;
 
        case FAILURE:
-               return FALSE;
+               return -1;
        }
 
        netmon_set_pseudo_header_info(wth->phdr.pkt_encap, &wth->phdr,
            wth->frame_buffer);
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 netmon_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        netmon_t *netmon = (netmon_t *)wth->priv;
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (!netmon_process_rec_header(wth, wth->random_fh, phdr,
            err, err_info))
-               return FALSE;
+               return -1;
 
        /*
         * Read the packet data.
         */
        if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
            err_info))
-               return FALSE;
+               return -1;
 
        /*
         * For version 2.1 and later, there's additional information
@@ -776,18 +776,18 @@ netmon_seek_read(wtap *wth, gint64 seek_off,
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("netmon: saw metadata in netmon_seek_read");
-               return FALSE;
+               return -1;
 
        case SUCCESS:
                break;
 
        case FAILURE:
-               return FALSE;
+               return -1;
        }
 
        netmon_set_pseudo_header_info(phdr->pkt_encap, phdr, buf);
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
index 9772567ae7c724a6b1649e950a26960ed9f51099..71e835a584b2dc0245f3192e675f140599f39edc 100644 (file)
@@ -613,24 +613,24 @@ typedef struct {
 } nstrace_t;
 
 static guint32 nspm_signature_version(wtap*, gchar*, gint32);
-static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info,
-                                 gint64 *data_offset);
-static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
-                                 gint64 *data_offset);
-static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info,
-                                 gint64 *data_offset);
-static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
-                                      struct wtap_pkthdr *phdr,
-                                      Buffer *buf,
-                                      int *err, gchar **err_info);
-static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
-                                      struct wtap_pkthdr *phdr,
-                                      Buffer *buf,
-                                      int *err, gchar **err_info);
-static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
-                                      struct wtap_pkthdr *phdr,
-                                      Buffer *buf,
-                                      int *err, gchar **err_info);
+static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info,
+                            gint64 *data_offset);
+static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
+                            gint64 *data_offset);
+static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info,
+                            gint64 *data_offset);
+static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
+                                 struct wtap_pkthdr *phdr,
+                                 Buffer *buf,
+                                 int *err, gchar **err_info);
+static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
+                                 struct wtap_pkthdr *phdr,
+                                 Buffer *buf,
+                                 int *err, gchar **err_info);
+static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
+                                 struct wtap_pkthdr *phdr,
+                                 Buffer *buf,
+                                 int *err, gchar **err_info);
 static void nstrace_close(wtap *wth);
 
 static gboolean nstrace_set_start_time_v10(wtap *wth);
@@ -925,7 +925,7 @@ static gboolean nstrace_set_start_time(wtap *wth)
 /*
 ** Netscaler trace format read routines.
 */
-static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     nstrace_t *nstrace = (nstrace_t *)wth->priv;
     guint64 nsg_creltime = nstrace->nsg_creltime;
@@ -965,7 +965,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
             nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->len;\
             nstrace->nstrace_buflen = nstrace_buflen;\
             nstrace->nsg_creltime = nsg_creltime;\
-            return TRUE;
+            return REC_TYPE_PACKET;
 
 #define GENERATE_CASE_PART(phdr,type,acttype) \
         case NSPR_PDPKTRACEPARTTX_V##type:\
@@ -988,7 +988,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
             nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->caplen;\
             nstrace->nsg_creltime = nsg_creltime;\
             nstrace->nstrace_buflen = nstrace_buflen;\
-            return TRUE;\
+            return REC_TYPE_PACKET;\
 
             switch (pletoh16(&(( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType))
             {
@@ -1030,7 +1030,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
         nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));
     }while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
 
-    return FALSE;
+    return -1;
 }
 
 #define TIMEDEFV20(fp,type) \
@@ -1112,10 +1112,10 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
         nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
         nstrace->nstrace_buflen = nstrace_buflen;\
         nstrace->nsg_creltime = nsg_creltime;\
-        return TRUE;\
+        return REC_TYPE_PACKET;\
     }while(0)
 
-static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     nstrace_t *nstrace = (nstrace_t *)wth->priv;
     guint64 nsg_creltime = nstrace->nsg_creltime;
@@ -1219,7 +1219,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
         nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));
     }while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
 
-    return FALSE;
+    return -1;
 }
 
 #undef PACKET_DESCRIBE
@@ -1248,7 +1248,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
         nstrace->xxx_offset += nstrace_buflen;\
         bytes_read = file_read(nstrace_buf, NSPR_PAGESIZE_TRACE, wth->fh);\
         if (bytes_read != NSPR_PAGESIZE_TRACE) {\
-            return FALSE;\
+            return -1;\
         } else {\
             nstrace_buf_offset = 0;\
         }\
@@ -1263,10 +1263,10 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
     nstrace->nstrace_buf_offset = nstrace_buf_offset;\
     nstrace->nstrace_buflen = nstrace_buflen = ((gint32)NSPR_PAGESIZE_TRACE);\
     nstrace->nsg_creltime = nsg_creltime;\
-    return TRUE;\
+    return REC_TYPE_PACKET;\
 } while(0)
 
-static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     nstrace_t *nstrace = (nstrace_t *)wth->priv;
     guint64 nsg_creltime = nstrace->nsg_creltime;
@@ -1324,12 +1324,12 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *
         nstrace_buflen = NSPR_PAGESIZE_TRACE;
     } while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
 
-    return FALSE;
+    return -1;
 }
 
 #undef PACKET_DESCRIBE
 
-static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
+static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     nspr_hd_v10_t hdr;
@@ -1343,7 +1343,7 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
     *err = 0;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     /*
     ** Read the record header.
@@ -1353,7 +1353,7 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
         *err = file_error(wth->random_fh, err_info);
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
 
     /*
@@ -1374,7 +1374,7 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return FALSE;
+            return -1;
         }
     }
 
@@ -1408,7 +1408,7 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
 #undef GENERATE_CASE_FULL
 #undef GENERATE_CASE_PART
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 #define PACKET_DESCRIBE(phdr,FPTIMEDEF,SIZEDEF,ver,enumprefix,type,structname,TYPE)\
@@ -1417,10 +1417,10 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
         SIZEDEF##ver((phdr),fp,ver);\
         TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\
         (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\
-        return TRUE;\
+        return REC_TYPE_PACKET;\
     }while(0)
 
-static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
+static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     nspr_hd_v20_t hdr;
@@ -1433,7 +1433,7 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
     *err = 0;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     /*
     ** Read the first 2 bytes of the record header.
@@ -1443,7 +1443,7 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
         *err = file_error(wth->random_fh, err_info);
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
     hdrlen = 2;
 
@@ -1456,7 +1456,7 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return FALSE;
+            return -1;
         }
         hdrlen = 3;
     }
@@ -1479,7 +1479,7 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return FALSE;
+            return -1;
         }
     }
 
@@ -1532,11 +1532,11 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
 #undef GENERATE_CASE_PART
 #undef GENERATE_CASE_PART_V25
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
-static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
+static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     nspr_hd_v20_t hdr;
@@ -1549,7 +1549,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
     *err = 0;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
     /*
     ** Read the first 2 bytes of the record header.
     */
@@ -1558,7 +1558,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
         *err = file_error(wth->random_fh, err_info);
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
     hdrlen = 2;
 
@@ -1571,7 +1571,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return FALSE;
+            return -1;
         }
         hdrlen = 3;
     }
@@ -1594,7 +1594,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return FALSE;
+            return -1;
         }
     }
 
@@ -1612,7 +1612,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
             GENERATE_CASE_V30(phdr,30, 300);
         }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 
index bbb4a535e96f576cf0913cdeab0ea1df864c3537..91c82c796d07b7ac1e9733962d1bc0739060bb34 100644 (file)
@@ -67,9 +67,9 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
        char *hdr);
 static gboolean netscreen_check_file_type(wtap *wth, int *err,
        gchar **err_info);
-static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
+static int netscreen_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
+static int netscreen_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info);
 static int parse_netscreen_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
@@ -190,7 +190,7 @@ int netscreen_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
+static int netscreen_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64          offset;
@@ -203,19 +203,19 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = netscreen_seek_next_packet(wth, err, err_info, line);
        if (offset < 0)
-               return FALSE;
+               return -1;
 
        /* Parse the header */
        pkt_len = parse_netscreen_rec_hdr(&wth->phdr, line, cap_int, &cap_dir,
            cap_dst, err, err_info);
        if (pkt_len == -1)
-               return FALSE;
+               return -1;
 
        /* Convert the ASCII hex dump to binary data, and fill in some
           struct wtap_pkthdr fields */
        if (!parse_netscreen_hex_dump(wth->fh, pkt_len, cap_int,
            cap_dst, &wth->phdr, wth->frame_buffer, err, err_info))
-               return FALSE;
+               return -1;
 
        /*
         * If the per-file encapsulation isn't known, set it to this
@@ -233,11 +233,11 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
        }
 
        *data_offset = offset;
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 netscreen_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info)
@@ -249,7 +249,7 @@ netscreen_seek_read(wtap *wth, gint64 seek_off,
        char            cap_dst[13];
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
-               return FALSE;
+               return -1;
        }
 
        if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) {
@@ -257,18 +257,18 @@ netscreen_seek_read(wtap *wth, gint64 seek_off,
                if (*err == 0) {
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return FALSE;
+               return -1;
        }
 
        pkt_len = parse_netscreen_rec_hdr(phdr, line, cap_int, &cap_dir,
            cap_dst, err, err_info);
        if (pkt_len == -1)
-               return FALSE;
+               return -1;
 
        if (!parse_netscreen_hex_dump(wth->random_fh, pkt_len, cap_int,
            cap_dst, phdr, buf, err, err_info))
-               return FALSE;
-       return TRUE;
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
 /* Parses a packet record header. There are a few possible formats:
index 0c6898bbdbce2984a604aa32fc29d44a41f88f44..0e3c9a9f97ec6aeaf38cce10862c9beedd8cba4a 100644 (file)
@@ -175,9 +175,9 @@ typedef struct {
        gboolean is_hpux_11;
 } nettl_t;
 
-static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
+static int nettl_read(wtap *wth, int *err, gchar **err_info,
                gint64 *data_offset);
-static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
+static int nettl_seek_read(wtap *wth, gint64 seek_off,
                struct wtap_pkthdr *phdr, Buffer *buf,
                int *err, gchar **err_info);
 static gboolean nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
@@ -287,7 +287,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
+static int nettl_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     /* Read record header. */
@@ -295,7 +295,7 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
     if (!nettl_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
         err, err_info)) {
        /* Read error or EOF */
-       return FALSE;
+       return -1;
     }
 
     /*
@@ -313,15 +313,15 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
            wth->file_encap = WTAP_ENCAP_PER_PACKET;
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                Buffer *buf, int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-       return FALSE;
+       return -1;
 
     /* Read record header. */
     if (!nettl_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
@@ -330,9 +330,9 @@ nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
            /* EOF means "short read" in random-access mode */
            *err = WTAP_ERR_SHORT_READ;
        }
-       return FALSE;
+       return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 static gboolean
index 38abfab2cdaa2812ec3ef01cbabbfdb2ff709762..01ed983932711dcd6c8e752f6ec8225f487818a6 100644 (file)
@@ -94,9 +94,9 @@ static void init_gmt_to_localtime_offset(void)
     }
 }
 
-static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
+static int observer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
+static int observer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int read_packet_header(FILE_T fh, union wtap_pseudo_header *pseudo_header,
     packet_entry_header *packet_header, int *err, gchar **err_info);
@@ -258,7 +258,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Reads the next packet. */
-static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
+static int observer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     int header_bytes_consumed;
@@ -273,7 +273,7 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
         header_bytes_consumed = read_packet_header(wth->fh, &wth->phdr.pseudo_header, &packet_header, err,
             err_info);
         if (header_bytes_consumed <= 0)
-            return FALSE;    /* EOF or error */
+            return -1;    /* EOF or error */
 
         if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET)
             break;
@@ -281,32 +281,32 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
         /* skip to next packet */
         if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
                 header_bytes_consumed, err, err_info)) {
-            return FALSE;    /* EOF or error */
+            return -1;    /* EOF or error */
         }
     }
 
     if (!process_packet_header(wth, &packet_header, &wth->phdr, err, err_info))
-        return FALSE;
+        return -1;
 
     /* read the frame data */
     data_bytes_consumed = read_packet_data(wth->fh, packet_header.offset_to_frame,
             header_bytes_consumed, wth->frame_buffer,
             wth->phdr.caplen, err, err_info);
     if (data_bytes_consumed < 0) {
-        return FALSE;
+        return -1;
     }
 
     /* skip over any extra bytes following the frame data */
     if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
             header_bytes_consumed + data_bytes_consumed, err, err_info)) {
-        return FALSE;
+        return -1;
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 /* Reads a packet at an offset. */
-static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
+static int observer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
@@ -315,25 +315,25 @@ static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
     int data_bytes_consumed;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     /* process the packet header, including TLVs */
     offset = read_packet_header(wth->random_fh, pseudo_header, &packet_header, err,
         err_info);
     if (offset <= 0)
-        return FALSE;    /* EOF or error */
+        return -1;    /* EOF or error */
 
     if (!process_packet_header(wth, &packet_header, phdr, err, err_info))
-        return FALSE;
+        return -1;
 
     /* read the frame data */
     data_bytes_consumed = read_packet_data(wth->random_fh, packet_header.offset_to_frame,
         offset, buf, phdr->caplen, err, err_info);
     if (data_bytes_consumed < 0) {
-        return FALSE;
+        return -1;
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 static int
index e6dd704bb3c3d12f078b7d505ef170924efd5f9a..782918c92149f652e3be0394584a03d0a4775217 100644 (file)
@@ -402,9 +402,9 @@ typedef struct {
        guint           isdn_type;      /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
 } netxray_t;
 
-static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
+static int netxray_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
+static int netxray_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int netxray_process_rec_header(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
@@ -989,7 +989,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static gboolean
+static int
 netxray_read(wtap *wth, int *err, gchar **err_info,
             gint64 *data_offset)
 {
@@ -1007,7 +1007,7 @@ reread:
        if (*data_offset == netxray->end_offset) {
                /* Yes. */
                *err = 0;       /* it's just an EOF, not an error */
-               return FALSE;
+               return -1;
        }
 
        /* Read and process record header. */
@@ -1021,7 +1021,7 @@ reread:
                        /*
                         * Error of some sort; give up.
                         */
-                       return FALSE;
+                       return -1;
                }
 
                /* We're at EOF.  Wrap?
@@ -1046,7 +1046,7 @@ reread:
                 */
                if (netxray->start_offset < netxray->end_offset) {
                        *err = WTAP_ERR_SHORT_READ;
-                       return FALSE;
+                       return -1;
                }
 
                if (!netxray->wrapped) {
@@ -1054,12 +1054,12 @@ reread:
                        netxray->wrapped = TRUE;
                        if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE,
                            SEEK_SET, err) == -1)
-                               return FALSE;
+                               return -1;
                        goto reread;
                }
 
                /* We've already wrapped - don't wrap again. */
-               return FALSE;
+               return -1;
        }
 
        /*
@@ -1067,13 +1067,13 @@ reread:
         */
        if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
            wth->phdr.caplen, err, err_info))
-               return FALSE;
+               return -1;
 
        /*
         * If there's extra stuff at the end of the record, skip it.
         */
        if (file_seek(wth->fh, padding, SEEK_CUR, err) == -1)
-               return FALSE;
+               return -1;
 
        /*
         * If it's an ATM packet, and we don't have enough information
@@ -1081,16 +1081,16 @@ reread:
         * attempt to guess them from the packet data.
         */
        netxray_guess_atm_type(wth, &wth->phdr, wth->frame_buffer);
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 netxray_seek_read(wtap *wth, gint64 seek_off,
                  struct wtap_pkthdr *phdr, Buffer *buf,
                  int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (netxray_process_rec_header(wth, wth->random_fh, phdr, err,
            err_info) == -1) {
@@ -1102,7 +1102,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
                         */
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return FALSE;
+               return -1;
        }
 
        /*
@@ -1110,7 +1110,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
         */
        if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
            err_info))
-               return FALSE;
+               return -1;
 
        /*
         * If it's an ATM packet, and we don't have enough information
@@ -1118,7 +1118,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
         * attempt to guess them from the packet data.
         */
        netxray_guess_atm_type(wth, phdr, buf);
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static int
index 8138a31f448a50c54aab657e93fa9477679b6f6c..1eafa3f15094c31f01be10fe06c5b91f5a669155 100644 (file)
@@ -509,9 +509,9 @@ static int process_rec_header2_v2(wtap *wth, unsigned char *buffer,
     guint16 length, int *err, gchar **err_info);
 static int process_rec_header2_v145(wtap *wth, unsigned char *buffer,
     guint16 length, gint16 maj_vers, int *err, gchar **err_info);
-static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
+static int ngsniffer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
+static int ngsniffer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int ngsniffer_process_record(wtap *wth, gboolean is_random,
     guint *padding, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
@@ -1053,7 +1053,7 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
 }
 
 /* Read the next packet */
-static gboolean
+static int
 ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        ngsniffer_t *ngsniffer;
@@ -1075,7 +1075,7 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                    &wth->phdr, wth->frame_buffer, err, err_info);
                if (ret < 0) {
                        /* Read error or short read */
-                       return FALSE;
+                       return -1;
                }
 
                /*
@@ -1093,16 +1093,16 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                        if (padding != 0) {
                                if (!ng_file_skip_seq(wth, padding, err,
                                    err_info))
-                                       return FALSE;
+                                       return -1;
                        }
-                       return TRUE;
+                       return REC_TYPE_PACKET;
 
                case REC_EOF:
                        /*
                         * End of file.  Return an EOF indication.
                         */
                        *err = 0;       /* EOF, not error */
-                       return FALSE;
+                       return -1;
 
                default:
                        /*
@@ -1114,26 +1114,26 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                        if (padding != 0) {
                                if (!ng_file_skip_seq(wth, padding, err,
                                    err_info))
-                                       return FALSE;
+                                       return -1;
                        }
                        break;
                }
        }
 }
 
-static gboolean
+static int
 ngsniffer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        int     ret;
 
        if (!ng_file_seek_rand(wth, seek_off, err, err_info))
-               return FALSE;
+               return -1;
 
        ret = ngsniffer_process_record(wth, TRUE, NULL, phdr, buf, err, err_info);
        if (ret < 0) {
                /* Read error or short read */
-               return FALSE;
+               return -1;
        }
 
        /*
@@ -1152,10 +1152,10 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
                 * "Can't happen".
                 */
                g_assert_not_reached();
-               return FALSE;
+               return -1;
        }
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /*
index 313cf3e5b8ca349963423505b7f9a0b4550d0dd0..5970b00d2083d0684d2e7940d68b43fad38c0522 100644 (file)
@@ -44,11 +44,11 @@ typedef struct packetlogger_header {
        guint64 ts;
 } packetlogger_header_t;
 
-static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info,
-                                 gint64 *data_offset);
-static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off,
-                                      struct wtap_pkthdr *phdr,
-                                      Buffer *buf, int *err, gchar **err_info);
+static int packetlogger_read(wtap *wth, int *err, gchar **err_info,
+                            gint64 *data_offset);
+static int packetlogger_seek_read(wtap *wth, gint64 seek_off,
+                                 struct wtap_pkthdr *phdr,
+                                 Buffer *buf, int *err, gchar **err_info);
 static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr,
                                         FILE_T fh, int *err, gchar **err_info);
 static gboolean packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
@@ -93,29 +93,31 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info)
        return 1; /* Our kind of file */
 }
 
-static gboolean
+static int
 packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       return packetlogger_read_packet(wth->fh, &wth->phdr,
-           wth->frame_buffer, err, err_info);
+       if (!packetlogger_read_packet(wth->fh, &wth->phdr,
+           wth->frame_buffer, err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 packetlogger_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                       Buffer *buf, int *err, gchar **err_info)
 {
        if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if(!packetlogger_read_packet(wth->random_fh, phdr, buf, err, err_info)) {
                if(*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
 
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
index a0be4a9eaac2660254bcf699ba5d73c8ac72ba2e..2132858770020f32f0f7c4b17db01908c03ae980 100644 (file)
@@ -2257,7 +2257,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
 
 
 /* classic wtap: read packet */
-static gboolean
+static int
 pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
         pcapng_t *pcapng = (pcapng_t *)wth->priv;
@@ -2282,7 +2282,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                 if (bytes_read <= 0) {
                         pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset);
                         pcapng_debug0("pcapng_read: couldn't read packet block");
-                        return FALSE;
+                        return -1;
                 }
 
                 switch (wblock.type) {
@@ -2292,7 +2292,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                         wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
                         *err = WTAP_ERR_UNSUPPORTED;
                         *err_info = g_strdup_printf("pcapng: multi-section files not currently supported");
-                        return FALSE;
+                        return -1;
 
                 case(BLOCK_TYPE_PB):
                 case(BLOCK_TYPE_SPB):
@@ -2361,12 +2361,12 @@ got_packet:
         /*pcapng_debug2("Read length: %u Packet length: %u", bytes_read, wth->phdr.caplen);*/
         pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset + bytes_read);
 
-        return TRUE;
+        return REC_TYPE_PACKET;
 }
 
 
 /* classic wtap: seek to file position and read packet */
-static gboolean
+static int
 pcapng_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
@@ -2380,7 +2380,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
         /* seek to the right file position */
         bytes_read64 = file_seek(wth->random_fh, seek_off, SEEK_SET, err);
         if (bytes_read64 <= 0) {
-                return FALSE;   /* Seek error */
+                return -1;   /* Seek error */
         }
         pcapng_debug1("pcapng_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
 
@@ -2393,7 +2393,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
         if (bytes_read <= 0) {
                 pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",
                               *err, errno, bytes_read);
-                return FALSE;
+                return -1;
         }
 
         /* block must be a "Packet Block", an "Enhanced Packet Block",
@@ -2404,7 +2404,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
                 return FALSE;
         }
 
-        return TRUE;
+        return REC_TYPE_PACKET;
 }
 
 
index a10ae66fd5aa07f31e52f11095bfd2944f0b84a4..3d9e8dc0862c15e0d6a60dfa00f960397372db27 100644 (file)
@@ -358,7 +358,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
        return 1;
 }
 
-static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
+static int peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        int sliceLength;
@@ -369,38 +369,38 @@ static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
        sliceLength = peekclassic_read_packet_v7(wth, wth->fh, &wth->phdr,
            wth->frame_buffer, err, err_info);
        if (sliceLength < 0)
-               return FALSE;
+               return -1;
 
        /* Skip extra ignored data at the end of the packet. */
        if ((guint32)sliceLength > wth->phdr.caplen) {
                if (!file_skip(wth->fh, sliceLength - wth->phdr.caplen, err))
-                       return FALSE;
+                       return -1;
        }
 
        /* Records are padded to an even length, so if the slice length
           is odd, read the padding byte. */
        if (sliceLength & 0x01) {
                if (!file_skip(wth->fh, 1, err))
-                       return FALSE;
+                       return -1;
        }
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
+static int peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* Read the packet. */
        if (peekclassic_read_packet_v7(wth, wth->random_fh, phdr, buf,
            err, err_info) == -1) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
@@ -493,7 +493,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
        return sliceLength;
 }
 
-static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
+static int peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -501,29 +501,29 @@ static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
        /* read the packet */
        if (!peekclassic_read_packet_v56(wth, wth->fh, &wth->phdr,
            wth->frame_buffer, err, err_info))
-               return FALSE;
+               return -1;
 
        /*
         * XXX - is the captured packet data padded to a multiple
         * of 2 bytes?
         */
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* read the packet */
        if (!peekclassic_read_packet_v56(wth, wth->random_fh, phdr, buf,
            err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
index 05dc8beaefde4e237e1a0a47bda1ddcd12413516..3007bdf99a63c4e0c633a2d312951de2983e8698 100644 (file)
@@ -123,9 +123,9 @@ typedef struct {
        gboolean        has_fcs;
 } peektagged_t;
 
-static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
+static int peektagged_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off,
+static int peektagged_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err,
@@ -633,7 +633,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     return skip_len;
 }
 
-static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
+static int peektagged_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     int skip_len;
@@ -644,29 +644,29 @@ static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
     skip_len = peektagged_read_packet(wth, wth->fh, &wth->phdr,
                                       wth->frame_buffer, err, err_info);
     if (skip_len == -1)
-       return FALSE;
+       return -1;
 
     if (skip_len != 0) {
        /* Skip extra junk at the end of the packet data. */
         if (!file_skip(wth->fh, skip_len, err))
-           return FALSE;
+           return -1;
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 peektagged_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-       return FALSE;
+       return -1;
 
     /* Read the packet. */
     if (peektagged_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-       return FALSE;
+       return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
index 6ba142485bbdc009e3fd35bc0adb5c75ddba999f..319ada0feb968118a0c0c47a71c688a5a811e9e0 100644 (file)
@@ -95,9 +95,9 @@ typedef enum {
        DIRECTION_RECV
 } direction_enum;
 
-static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info,
+static int pppdump_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off,
+static int pppdump_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 /*
@@ -327,7 +327,7 @@ pppdump_set_phdr(struct wtap_pkthdr *phdr, int num_bytes,
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean
+static int
 pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        int             num_bytes;
@@ -344,7 +344,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                pid = g_new(pkt_id, 1);
                if (!pid) {
                        *err = errno;   /* assume a malloc failed and set "errno" */
-                       return FALSE;
+                       return -1;
                }
                pid->offset = 0;
        } else
@@ -357,7 +357,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
            pid, 0)) {
                if (pid != NULL)
                        g_free(pid);
-               return FALSE;
+               return -1;
        }
 
        if (pid != NULL)
@@ -374,7 +374,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
        wth->phdr.ts.nsecs      = state->tenths * 100000000;
        pppdump_set_phdr(&wth->phdr, num_bytes, direction);
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /* Returns number of bytes copied for record, -1 if failure.
@@ -715,7 +715,7 @@ done:
 
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 pppdump_seek_read(wtap *wth,
                 gint64 seek_off,
                 struct wtap_pkthdr *phdr,
@@ -736,11 +736,11 @@ pppdump_seek_read(wtap *wth,
        if (!pid) {
                *err = WTAP_ERR_BAD_FILE;       /* XXX - better error? */
                *err_info = g_strdup("pppdump: PID not found for record");
-               return FALSE;
+               return -1;
        }
 
        if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        init_state(state->seek_state);
        state->seek_state->offset = pid->offset;
@@ -763,13 +763,13 @@ pppdump_seek_read(wtap *wth,
        do {
                if (!collate(state->seek_state, wth->random_fh, err, err_info,
                    pd, &num_bytes, &direction, NULL, num_bytes_to_skip))
-                       return FALSE;
+                       return -1;
                num_bytes_to_skip = 0;
        } while (direction != pid->dir);
 
        pppdump_set_phdr(phdr, num_bytes, pid->dir);
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static void
index e056cdd69171f0b27eba1806009383b1b92d2a9c..16df1397e7d22f86ca99c08ad224c8cc431bccd5 100644 (file)
@@ -84,9 +84,9 @@ struct radcomrec_hdr {
        char    xxw[9];         /* unknown */
 };
 
-static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
+static int radcom_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean radcom_seek_read(wtap *wth, gint64 seek_off,
+static int radcom_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info);
@@ -252,8 +252,8 @@ read_error:
 }
 
 /* Read the next packet */
-static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
-                           gint64 *data_offset)
+static int radcom_read(wtap *wth, int *err, gchar **err_info,
+                      gint64 *data_offset)
 {
        int     bytes_read;
        char    fcs[2];
@@ -264,7 +264,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
        if (!radcom_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
            err, err_info)) {
                /* Read error or EOF */
-               return FALSE;
+               return -1;
        }
 
        if (wth->file_encap == WTAP_ENCAP_LAPB) {
@@ -278,20 +278,20 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
                        *err = file_error(wth->fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
-                       return FALSE;
+                       return -1;
                }
        }
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 radcom_seek_read(wtap *wth, gint64 seek_off,
                 struct wtap_pkthdr *phdr, Buffer *buf,
                 int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        /* Read record. */
        if (!radcom_read_rec(wth, wth->random_fh, phdr, buf, err,
@@ -301,9 +301,9 @@ radcom_seek_read(wtap *wth, gint64 seek_off,
                        /* EOF means "short read" in random-access mode */
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static gboolean
index 265d23f4a29dbf802d887f38543641737e76e908..8001ddf58c6167ac83cae9e3b830621f7e8fa5a3 100644 (file)
@@ -84,9 +84,9 @@ struct shomiti_trailer {
 #define RX_STATUS_FIFO_ERROR           0x0080  /* receive FIFO error */
 #define RX_STATUS_TRIGGERED            0x0001  /* frame did trigger */
 
-static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
+static int snoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean snoop_seek_read(wtap *wth, gint64 seek_off,
+static int snoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info);
@@ -447,7 +447,7 @@ typedef struct {
 
 
 /* Read the next packet */
-static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
+static int snoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        int     padbytes;
@@ -460,7 +460,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
        padbytes = snoop_read_packet(wth, wth->fh, &wth->phdr,
            wth->frame_buffer, err, err_info);
        if (padbytes == -1)
-               return FALSE;
+               return -1;
 
        /*
         * Skip over the padding (don't "fseek()", as the standard
@@ -482,27 +482,27 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
                        *err = file_error(wth->fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
-                       return FALSE;
+                       return -1;
                }
                padbytes -= bytes_read;
        }
 
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
-static gboolean
+static int
 snoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (snoop_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 static int
index 12bc05885c96d07cd2462613845bf578b2c2b625..8c0625c74fea61536f97a9ab28e18e357ee25af7 100644 (file)
@@ -48,8 +48,8 @@ static gboolean is_valid_id(guint16 version_id)
   return TRUE;
 }
 
-static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
-                               Buffer *buf, int *err, gchar **err_info)
+static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+                                Buffer *buf, int *err, gchar **err_info)
 {
   stanag4607_t *stanag4607 = (stanag4607_t *)wth->priv;
   guint32 millisecs, secs, nsecs;
@@ -69,7 +69,7 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p
   if (!is_valid_id(pntoh16(&stanag_pkt_hdr[0]))) {
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup("Bad version number");
-    return FALSE;
+    return -1;
   }
 
   /* The next 4 bytes are the packet length */
@@ -133,16 +133,19 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p
 
   /* wind back to the start of the packet ... */
   if (file_seek(fh, - offset, SEEK_CUR, err) == -1)
-    goto fail;
+    return -1;
 
-  return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+  if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
+    return -1;
+
+  return REC_TYPE_PACKET;
 
 fail:
   *err = file_error(wth->fh, err_info);
-  return FALSE;
+  return -1;
 }
 
-static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
   gint64 offset;
 
@@ -155,12 +158,12 @@ static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *d
   return stanag4607_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off,
-                               struct wtap_pkthdr *phdr,
-                               Buffer *buf, int *err, gchar **err_info)
+static int stanag4607_seek_read(wtap *wth, gint64 seek_off,
+                                struct wtap_pkthdr *phdr,
+                                Buffer *buf, int *err, gchar **err_info)
 {
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
 
   return stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index 5bd2fa1463fd57811249b2324bb640c9421f3028..a08d42fb2cf6b70159a45b2e566b42654d35542f 100644 (file)
 #include "buffer.h"
 #include "tnef.h"
 
-static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
-                               Buffer *buf, int *err, gchar **err_info)
+static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+                          Buffer *buf, int *err, gchar **err_info)
 {
   gint64 file_size;
   int packet_size;
 
   if ((file_size = wtap_file_size(wth, err)) == -1)
-    return FALSE;
+    return -1;
 
   if (file_size > WTAP_MAX_PACKET_SIZE) {
     /*
@@ -47,7 +47,7 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("tnef: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
                                file_size, WTAP_MAX_PACKET_SIZE);
-    return FALSE;
+    return -1;
   }
   packet_size = (int)file_size;
 
@@ -59,10 +59,12 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
   phdr->ts.secs = 0;
   phdr->ts.nsecs = 0;
 
-  return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+  if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
+    return -1;
+  return REC_TYPE_PACKET;
 }
 
-static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
   gint64 offset;
 
@@ -72,25 +74,25 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
 
   /* there is only ever one packet */
   if (offset)
-    return FALSE;
+    return -1;
 
   *data_offset = offset;
 
   return tnef_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
-                               struct wtap_pkthdr *phdr,
-                               Buffer *buf, int *err, gchar **err_info)
+static int tnef_seek_read(wtap *wth, gint64 seek_off,
+                          struct wtap_pkthdr *phdr,
+                          Buffer *buf, int *err, gchar **err_info)
 {
   /* there is only one packet */
   if(seek_off > 0) {
     *err = 0;
-    return FALSE;
+    return -1;
   }
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return FALSE;
+    return -1;
 
   return tnef_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index 6fcf40270bd2c33cfd9f18f99325f6a9cc45d6a6..6e8ab1a1781a4b1a870c2902cd0dac7ba867e076 100644 (file)
@@ -105,9 +105,9 @@ static const char toshiba_rec_magic[]  = { '[', 'N', 'o', '.' };
  */
 #define TOSHIBA_MAX_PACKET_LEN 16384
 
-static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
+static int toshiba_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off,
+static int toshiba_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
        guint byte_offset);
@@ -214,7 +214,7 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
+static int toshiba_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -222,29 +222,31 @@ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = toshiba_seek_next_packet(wth, err, err_info);
        if (offset < 1)
-               return FALSE;
+               return -1;
        *data_offset = offset;
 
        /* Parse the packet */
-       return parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
-           err, err_info);
+       if (!parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
+           err, err_info))
+               return -1;
+       return REC_TYPE_PACKET;
 }
 
 /* Used to read packets in random-access fashion */
-static gboolean
+static int
 toshiba_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-               return FALSE;
+               return -1;
 
        if (!parse_toshiba_packet(wth->random_fh, phdr, buf, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return FALSE;
+               return -1;
        }
-       return TRUE;
+       return REC_TYPE_PACKET;
 }
 
 /* Parses a packet. */
index cfa03bceacc9571a7951c0b1bb37674ba5c07ac4..67a7d481f9e609ddbfd708d96c32347161ff5333 100644 (file)
@@ -158,9 +158,9 @@ struct visual_write_info
 
 
 /* Local functions to handle file reads and writes */
-static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
+static int visual_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
+static int visual_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean visual_read_packet(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
@@ -281,7 +281,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
    in a loop to sequentially read the entire file one time.  After
    the file has been read once, any Future access to the packets is
    done through seek_read. */
-static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
+static int visual_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     struct visual_read_info *visual = (struct visual_read_info *)wth->priv;
@@ -292,31 +292,33 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
     if (visual->current_pkt > visual->num_pkts)
     {
         *err = 0;   /* it's just an EOF, not an error */
-        return FALSE;
+        return -1;
     }
     visual->current_pkt++;
 
     *data_offset = file_tell(wth->fh);
 
-    return visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
-            err, err_info);
+    if (!visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+            err, err_info))
+        return -1;
+    return REC_TYPE_PACKET;
 }
 
 /* Read packet header and data for random access. */
-static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
+static int visual_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     /* Seek to the packet header */
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     /* Read the packet. */
     if (!visual_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 static gboolean
index 3684c3bbbe41c7a5319c576dd86d19a5c10d0d89..90d5e24acc6ca3cad6a766bdee3c5616afc2b38d 100644 (file)
@@ -139,9 +139,9 @@ to handle them.
 #define VMS_HEADER_LINES_TO_CHECK    200
 #define VMS_LINE_LENGTH              240
 
-static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
+static int vms_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static gboolean vms_seek_read(wtap *wth, gint64 seek_off,
+static int vms_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
     long byte_offset, int in_off, int remaining_bytes);
@@ -255,7 +255,7 @@ int vms_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
+static int vms_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     gint64   offset = 0;
@@ -268,12 +268,14 @@ static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
 #endif
     if (offset < 1) {
         *err = file_error(wth->fh, err_info);
-        return FALSE;
+        return -1;
     }
     *data_offset = offset;
 
     /* Parse the packet */
-    return parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
+    if (!parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info))
+        return -1;
+    return REC_TYPE_PACKET;
 }
 
 /* Used to read packets in random-access fashion */
@@ -282,14 +284,14 @@ vms_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     if (!parse_vms_packet(wth->random_fh, phdr, buf, err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return FALSE;
+        return -1;
     }
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 /* isdumpline assumes that dump lines start with some non-alphanumerics
index 7d0b291c625b8d44057428956a8787fc01ee45cd..518ebaf46cbbc3576855d754e9d821459eb29851 100644 (file)
@@ -496,8 +496,8 @@ static guint8       get_ofdm_rate(const guint8 *);
 static guint8       get_cck_rate(const guint8 *plcp);
 static void         setup_defaults(vwr_t *, guint16);
 
-static gboolean     vwr_read(wtap *, int *, gchar **, gint64 *);
-static gboolean     vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr,
+static int          vwr_read(wtap *, int *, gchar **, gint64 *);
+static int          vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr,
                                   Buffer *, int *, gchar **);
 
 static gboolean     vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, gchar **);
@@ -571,14 +571,14 @@ int vwr_open(wtap *wth, int *err, gchar **err_info)
 /*  frame, and a 64-byte statistics block trailer.                                         */
 /* The PLCP frame consists of a 4-byte or 6-byte PLCP header, followed by the MAC frame    */
 
-static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     vwr_t *vwr      = (vwr_t *)wth->priv;
     int    rec_size = 0, IS_TX;
 
     /* read the next frame record header in the capture file; if no more frames, return */
     if (!vwr_read_rec_header(vwr, wth->fh, &rec_size, &IS_TX, err, err_info))
-        return FALSE;                                   /* Read error or EOF */
+        return -1;                                   /* Read error or EOF */
 
     /*
      * We're past the header; return the offset of the header, not of
@@ -589,7 +589,7 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
     /* got a frame record; read and process it */
     if (!vwr_process_rec_data(wth->fh, rec_size, &wth->phdr,
                               wth->frame_buffer, vwr, IS_TX, err, err_info))
-       return FALSE;
+       return -1;
 
     /* If the per-file encapsulation isn't known, set it to this packet's encapsulation. */
     /* If it *is* known, and it isn't this packet's encapsulation, set it to             */
@@ -602,12 +602,12 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
             wth->file_encap = WTAP_ENCAP_PER_PACKET;
     }
 
-    return TRUE;
+    return REC_TYPE_PACKET;
 }
 
 /* read a random record in the middle of a file; the start of the record is @ seek_off */
 
-static gboolean vwr_seek_read(wtap *wth, gint64 seek_off,
+static int vwr_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     vwr_t *vwr = (vwr_t *)wth->priv;
@@ -615,14 +615,17 @@ static gboolean vwr_seek_read(wtap *wth, gint64 seek_off,
 
     /* first seek to the indicated record header */
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return FALSE;
+        return -1;
 
     /* read in the record header */
     if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, err, err_info))
-        return FALSE;                                  /* Read error or EOF */
+        return -1;                                  /* Read error or EOF */
+
+    if (!vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf,
+                              vwr, IS_TX, err, err_info))
+        return -1;
 
-    return vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf,
-                                vwr, IS_TX, err, err_info);
+    return REC_TYPE_PACKET;
 }
 
 /* Scan down in the input capture file to find the next frame header.       */
index dfa3441835e58a54f0df77899f2fb774c2192afb..8291609b733166f0520935627d3a5208b07a6e46 100644 (file)
 WS_DLL_PUBLIC
 int wtap_fstat(wtap *wth, ws_statb64 *statb, int *err);
 
-typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
-typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64,
-                                           struct wtap_pkthdr *, Buffer *buf,
-                                           int *, char **);
+typedef int (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
+typedef int (*subtype_seek_read_func)(struct wtap*, gint64,
+                                      struct wtap_pkthdr *, Buffer *,
+                                      int *, char **);
 /**
  * Struct holding data of the currently read file.
  */
index c32524be8055ca99f235e41b4fdcd7218c02a381..f03900cfbf09bed1f3e3ccae0e83546ab4fe7111 100644 (file)
@@ -975,9 +975,11 @@ void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6) {
                wth->add_new_ipv6 = add_new_ipv6;
 }
 
-gboolean
+int
 wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
+       int rectype;
+
        /*
         * Set the packet encapsulation to the file's encapsulation
         * value; if that's not WTAP_ENCAP_PER_PACKET, it's the
@@ -988,7 +990,8 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
         */
        wth->phdr.pkt_encap = wth->file_encap;
 
-       if (!wth->subtype_read(wth, err, err_info, data_offset)) {
+       rectype = wth->subtype_read(wth, err, err_info, data_offset);
+       if (rectype == -1) {
                /*
                 * If we didn't get an error indication, we read
                 * the last packet.  See if there's any deferred
@@ -1000,7 +1003,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                 */
                if (*err == 0)
                        *err = file_error(wth->fh, err_info);
-               return FALSE;   /* failure */
+               return rectype; /* failure */
        }
 
        /*
@@ -1018,7 +1021,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
         */
        g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET);
 
-       return TRUE;    /* success */
+       return rectype;
 }
 
 /*
@@ -1071,12 +1074,15 @@ wtap_buf_ptr(wtap *wth)
        return buffer_start_ptr(wth->frame_buffer);
 }
 
-gboolean
+int
 wtap_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
-       if (!wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info))
-               return FALSE;
+       int rectype;
+
+       rectype = wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info);
+       if (rectype == -1)
+               return rectype;
 
        /*
         * It makes no sense for the captured data length to be bigger
@@ -1093,5 +1099,5 @@ wtap_seek_read(wtap *wth, gint64 seek_off,
         */
        g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET);
 
-       return TRUE;
+       return rectype;
 }
index 005d74830462428ab3609c90e7a99eb41aa69660..3e47b3c8dc49f965eed4310d3251c13ffb7ee469 100644 (file)
@@ -1349,15 +1349,24 @@ typedef void (*wtap_new_ipv6_callback_t) (const void *addrp, const gchar *name);
 WS_DLL_PUBLIC
 void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6);
 
-/** Returns TRUE if read was successful. FALSE if failure. data_offset is
- * set to the offset in the file where the data for the read packet is
- * located. */
+/*
+ * Values returned by wtap_read() and wtap_seek_read().  They indicate the
+ * type of record read by that routine.
+ *
+ * This list will expand over time, so don't assume everything will be a
+ * file-type-specific record or a packet record.
+ */
+#define REC_TYPE_FILE_TYPE_SPECIFIC   0    /* file-type-specific record */
+#define REC_TYPE_PACKET               1    /* packet */
+
+/** Returns a REC_TYPE_ value if read was successful, -1 if it failed.
+ * *data_offset is set to the offset in the file where the data for
+ * the read packet is located. */
 WS_DLL_PUBLIC
-gboolean wtap_read(wtap *wth, int *err, gchar **err_info,
-    gint64 *data_offset);
+int wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset);
 
 WS_DLL_PUBLIC
-gboolean wtap_seek_read (wtap *wth, gint64 seek_off,
+int wtap_seek_read (wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 /*** get various information snippets about the current packet ***/