It appears that the octet in the record header after the record length
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 26 Oct 2011 03:14:21 +0000 (03:14 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 26 Oct 2011 03:14:21 +0000 (03:14 +0000)
might be a record type, with 0 being a "Stop Monitor" record and 1 being
a packet.  Ignore records other than packet records.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39590 f5534014-38df-0310-8fa8-9805f1628bb7

wiretap/aethra.c

index ad1ee31ffc9a5df008999884874651bdaf4bd17c..8a1b4d856123f5c967846a1758219e989949063e 100644 (file)
@@ -44,11 +44,17 @@ struct aethra_hdr {
    All multi-byte fields are little-endian. */
 struct aethrarec_hdr {
        guint8 rec_size[2];     /* record length, not counting the length itself */
-       guint8 unknown1;
+       guint8 rec_type;        /* record type */
        guint8 timestamp[4];    /* milliseconds since start of capture */
        guint8 flags;           /* low-order bit: 0 = N->U, 1 = U->N */
 };
 
+/*
+ * Record types.
+ */
+#define AETHRA_STOP_MONITOR    0       /* end of capture */
+#define AETHRA_PACKET          1       /* packet */
+
 /*
  * Flags.
  */
@@ -118,32 +124,41 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
        guint32 packet_size;
        guint32 msecs;
 
-       *data_offset = wth->data_offset;
-
-       /* Read record header. */
-       if (!aethra_read_rec_header(wth->fh, &hdr, &wth->pseudo_header, err,
-           err_info))
-               return FALSE;
-
-       rec_size = pletohs(hdr.rec_size);
-       if (rec_size < (sizeof hdr - sizeof hdr.rec_size)) {
-               /* The record is shorter than a record header. */
-               *err = WTAP_ERR_BAD_RECORD;
-               *err_info = g_strdup_printf("aethra: File has %u-byte record, less than minimum of %u",
-                   rec_size, (unsigned int)(sizeof hdr - sizeof hdr.rec_size));
-               return FALSE;
-       }
-
-       wth->data_offset += sizeof hdr;
-
-       packet_size = rec_size - (sizeof hdr - sizeof hdr.rec_size);
-       if (packet_size != 0) {
-               buffer_assure_space(wth->frame_buffer, packet_size);
-               if (!aethra_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
-                   packet_size, err, err_info))
-                       return FALSE;   /* Read error */
-               wth->data_offset += packet_size;
-       }
+       /*
+        * Keep reading until we see an AETHRA_PACKET record or get
+        * an end-of-file.
+        */
+       do {
+               *data_offset = wth->data_offset;
+
+               /* Read record header. */
+               if (!aethra_read_rec_header(wth->fh, &hdr, &wth->pseudo_header,
+                   err, err_info))
+                       return FALSE;
+
+               rec_size = pletohs(hdr.rec_size);
+               if (rec_size < (sizeof hdr - sizeof hdr.rec_size)) {
+                       /* The record is shorter than a record header. */
+                       *err = WTAP_ERR_BAD_RECORD;
+                       *err_info = g_strdup_printf("aethra: File has %u-byte record, less than minimum of %u",
+                           rec_size, (unsigned int)(sizeof hdr - sizeof hdr.rec_size));
+                       return FALSE;
+               }
+               wth->data_offset += sizeof hdr;
+
+               /*
+                * XXX - if this is big, we might waste memory by
+                * growing the buffer to handle it.
+                */
+               packet_size = rec_size - (sizeof hdr - sizeof hdr.rec_size);
+               if (packet_size != 0) {
+                       buffer_assure_space(wth->frame_buffer, packet_size);
+                       if (!aethra_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
+                           packet_size, err, err_info))
+                               return FALSE;   /* Read error */
+                       wth->data_offset += packet_size;
+               }
+       } while (hdr.rec_type != AETHRA_PACKET);
 
        /*
         * XXX - need to find start time in file header.