aboutsummaryrefslogtreecommitdiffstats
path: root/reordercap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-05-22 20:01:31 -0700
committerGuy Harris <guy@alum.mit.edu>2014-05-23 03:02:32 +0000
commitc0c480d08c175eed4524ea9e73ec86298f468cf4 (patch)
tree1234cd09094dcc8447e3fb2b13671f12aba5ae69 /reordercap.c
parent6287efb9c05482531ea675bb5a3d23b03b5715ab (diff)
Allow wtap_read() and wtap_seek_read() to return non-packet records.
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>
Diffstat (limited to 'reordercap.c')
-rw-r--r--reordercap.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/reordercap.c b/reordercap.c
index 4b363b84b1..df46d7c166 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -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. */