aboutsummaryrefslogtreecommitdiffstats
path: root/reordercap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-16 00:20:00 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-16 00:20:00 +0000
commit8c9edf12800bc6d68894dc457e7ebaf994429da8 (patch)
treeec6efefbd4e7f8227a7b96661f721ff4ba2986c3 /reordercap.c
parent3846abe34d6861c6ee0bba61fcd5baa4d213885c (diff)
Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument. This lets more of the libwiretap code be common between the read and seek-read code paths, and also allows for more flexibility in the "fill in the data" path - we can expand the buffer as needed in both cases. svn path=/trunk/; revision=49949
Diffstat (limited to 'reordercap.c')
-rw-r--r--reordercap.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/reordercap.c b/reordercap.c
index 7bd0c8962d..4ac1affed7 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -82,16 +82,16 @@ typedef struct FrameRecord_t {
static void
-frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh)
+frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, Buffer *buf)
{
int err;
gchar *errinfo;
struct wtap_pkthdr phdr;
- guint8 buf[65535];
DEBUG_PRINT("\nDumping frame (offset=%" G_GINT64_MODIFIER "u, length=%u)\n",
frame->offset, frame->length);
+
/* Re-read the first frame from the stored location */
wtap_seek_read(wth,
frame->offset,
@@ -107,7 +107,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh)
phdr.ts = frame->time;
/* Dump frame to outfile */
- if (!wtap_dump(pdh, &phdr, buf, &err)) {
+ if (!wtap_dump(pdh, &phdr, buffer_start_ptr(buf), &err)) {
printf("Error (%s) writing frame to outfile\n", wtap_strerror(err));
exit(1);
}
@@ -155,6 +155,7 @@ int main(int argc, char *argv[])
{
wtap *wth = NULL;
wtap_dumper *pdh = NULL;
+ Buffer buf;
int err;
gchar *err_info;
gint64 data_offset;
@@ -239,15 +240,17 @@ int main(int argc, char *argv[])
}
/* Write out each sorted frame in turn */
+ 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);
+ frame_write(frame, wth, pdh, &buf);
}
g_slice_free(FrameRecord_t, frame);
}
+ buffer_free(&buf);
if (!write_output_regardless && (wrong_order_count == 0)) {
printf("Not writing output file because input file is already in order!\n");