aboutsummaryrefslogtreecommitdiffstats
path: root/reordercap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-02-08 16:19:12 -0800
committerGuy Harris <guy@alum.mit.edu>2018-02-09 00:29:51 +0000
commit1f5f63f8ef98bfe9c4d734674cee0df64855555d (patch)
tree133dd3563cc8d2d29dd85d4d43cd9a4636283192 /reordercap.c
parente4c5efafb7da2d25b7d47fe2dac3b1556c0b67b0 (diff)
Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'reordercap.c')
-rw-r--r--reordercap.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/reordercap.c b/reordercap.c
index c4b9dfd02b..7cbdea2ed8 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -82,7 +82,7 @@ typedef struct FrameRecord_t {
static void
frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
- struct wtap_pkthdr *phdr, Buffer *buf, const char *infile,
+ wtap_rec *rec, Buffer *buf, const char *infile,
const char *outfile)
{
int err;
@@ -93,7 +93,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
/* Re-read the frame from the stored location */
- if (!wtap_seek_read(wth, frame->offset, phdr, buf, &err, &err_info)) {
+ if (!wtap_seek_read(wth, frame->offset, rec, buf, &err, &err_info)) {
if (err != 0) {
/* Print a message noting that the read failed somewhere along the line. */
fprintf(stderr,
@@ -105,12 +105,12 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
}
/* Copy, and set length and timestamp from item. */
- /* TODO: remove when wtap_seek_read() fills in phdr,
+ /* TODO: remove when wtap_seek_read() fills in rec,
including time stamps, for all file types */
- phdr->ts = frame->frame_time;
+ rec->ts = frame->frame_time;
/* Dump frame to outfile */
- if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err, &err_info)) {
+ if (!wtap_dump(pdh, rec, ws_buffer_start_ptr(buf), &err, &err_info)) {
cfile_write_failure_message("reordercap", infile, outfile, err,
err_info, frame->num,
wtap_file_type_subtype(wth));
@@ -168,12 +168,12 @@ main(int argc, char *argv[])
char *init_progfile_dir_error;
wtap *wth = NULL;
wtap_dumper *pdh = NULL;
- struct wtap_pkthdr dump_phdr;
+ wtap_rec dump_rec;
Buffer buf;
int err;
gchar *err_info;
gint64 data_offset;
- const struct wtap_pkthdr *phdr;
+ const wtap_rec *rec;
guint wrong_order_count = 0;
gboolean write_output_regardless = TRUE;
guint i;
@@ -316,13 +316,13 @@ main(int argc, char *argv[])
while (wtap_read(wth, &err, &err_info, &data_offset)) {
FrameRecord_t *newFrameRecord;
- phdr = wtap_phdr(wth);
+ rec = wtap_get_rec(wth);
newFrameRecord = g_slice_new(FrameRecord_t);
newFrameRecord->num = frames->len + 1;
newFrameRecord->offset = data_offset;
- if (phdr->presence_flags & WTAP_HAS_TS) {
- newFrameRecord->frame_time = phdr->ts;
+ if (rec->presence_flags & WTAP_HAS_TS) {
+ newFrameRecord->frame_time = rec->ts;
} else {
nstime_set_unset(&newFrameRecord->frame_time);
}
@@ -347,18 +347,18 @@ main(int argc, char *argv[])
}
/* Write out each sorted frame in turn */
- wtap_phdr_init(&dump_phdr);
+ wtap_rec_init(&dump_rec);
ws_buffer_init(&buf, 1500);
for (i = 0; i < frames->len; i++) {
FrameRecord_t *frame = (FrameRecord_t *)frames->pdata[i];
/* Avoid writing if already sorted and configured to */
if (write_output_regardless || (wrong_order_count > 0)) {
- frame_write(frame, wth, pdh, &dump_phdr, &buf, infile, outfile);
+ frame_write(frame, wth, pdh, &dump_rec, &buf, infile, outfile);
}
g_slice_free(FrameRecord_t, frame);
}
- wtap_phdr_cleanup(&dump_phdr);
+ wtap_rec_cleanup(&dump_rec);
ws_buffer_free(&buf);
if (!write_output_regardless && (wrong_order_count == 0)) {