From 8c9edf12800bc6d68894dc457e7ebaf994429da8 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 16 Jun 2013 00:20:00 +0000 Subject: 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 --- wiretap/pppdump.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'wiretap/pppdump.c') diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 9a7cc4ed9e..2993e7f8f5 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -100,7 +100,7 @@ typedef enum { static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, guint8 *pd, int len, + struct wtap_pkthdr *phdr, Buffer *buf, int len, int *err, gchar **err_info); /* @@ -339,9 +339,6 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) pppdump_t *state; pkt_id *pid; - buffer_assure_space(wth->frame_buffer, PPPD_BUF_SIZE); - buf = buffer_start_ptr(wth->frame_buffer); - state = (pppdump_t *)wth->priv; /* If we have a random stream open, allocate a structure to hold @@ -356,6 +353,9 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) } else pid = NULL; /* sequential only */ + buffer_assure_space(wth->frame_buffer, PPPD_BUF_SIZE); + buf = buffer_start_ptr(wth->frame_buffer); + if (!collate(state, wth->fh, err, err_info, buf, &num_bytes, &direction, pid, 0)) { if (pid != NULL) @@ -722,12 +722,13 @@ static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, - guint8 *pd, + Buffer *buf, int len, int *err, gchar **err_info) { int num_bytes; + guint8 *pd; direction_enum direction; pppdump_t *state; pkt_id *pid; @@ -748,6 +749,9 @@ pppdump_seek_read(wtap *wth, init_state(state->seek_state); state->seek_state->offset = pid->offset; + buffer_assure_space(buf, PPPD_BUF_SIZE); + pd = buffer_start_ptr(buf); + /* * We'll start reading at the first record containing data from * this packet; however, that doesn't mean "collate()" will -- cgit v1.2.1