diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-06-16 00:20:00 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-06-16 00:20:00 +0000 |
commit | 8c9edf12800bc6d68894dc457e7ebaf994429da8 (patch) | |
tree | ec6efefbd4e7f8227a7b96661f721ff4ba2986c3 /wiretap/eyesdn.c | |
parent | 3846abe34d6861c6ee0bba61fcd5baa4d213885c (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 'wiretap/eyesdn.c')
-rw-r--r-- | wiretap/eyesdn.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index c32f5b86bf..c26baee94a 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -95,9 +95,9 @@ static const unsigned char eyesdn_hdr_magic[] = static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean eyesdn_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); -static gboolean parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf, +static gboolean parse_eyesdn_packet_data(FILE_T fh, int pkt_len, Buffer* buf, int *err, gchar **err_info); static int parse_eyesdn_rec_hdr(FILE_T fh, struct wtap_pkthdr *phdr, int *err, gchar **err_info); @@ -158,7 +158,6 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; - guint8 *buf; int pkt_len; /* Find the next packet */ @@ -171,12 +170,9 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, if (pkt_len == -1) return FALSE; - /* Make sure we have enough room for the packet */ - buffer_assure_space(wth->frame_buffer, EYESDN_MAX_PACKET_LEN); - buf = buffer_start_ptr(wth->frame_buffer); - /* Read the packet data */ - if (!parse_eyesdn_packet_data(wth->fh, pkt_len, buf, err, err_info)) + if (!parse_eyesdn_packet_data(wth->fh, pkt_len, wth->frame_buffer, + err, err_info)) return FALSE; *data_offset = offset; @@ -185,8 +181,8 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ static gboolean -eyesdn_seek_read (wtap *wth, gint64 seek_off,struct wtap_pkthdr *phdr, - guint8 *pd, int len, int *err, gchar **err_info) +eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, + Buffer *buf, int len, int *err, gchar **err_info) { int pkt_len; @@ -204,7 +200,7 @@ eyesdn_seek_read (wtap *wth, gint64 seek_off,struct wtap_pkthdr *phdr, return FALSE; } - return parse_eyesdn_packet_data(wth->random_fh, pkt_len, pd, err, + return parse_eyesdn_packet_data(wth->random_fh, pkt_len, buf, err, err_info); } @@ -354,13 +350,18 @@ parse_eyesdn_rec_hdr(FILE_T fh, struct wtap_pkthdr *phdr, /* read a packet */ static gboolean -parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf, int *err, +parse_eyesdn_packet_data(FILE_T fh, int pkt_len, Buffer* buf, int *err, gchar **err_info) { int bytes_read; + guint8 *pd; + + /* Make sure we have enough room for the packet */ + buffer_assure_space(buf, EYESDN_MAX_PACKET_LEN); errno = WTAP_ERR_CANT_READ; - bytes_read = esc_read(buf, pkt_len, fh); + pd = buffer_start_ptr(buf); + bytes_read = esc_read(pd, pkt_len, fh); if (bytes_read != pkt_len) { if (bytes_read == -2) { *err = file_error(fh, err_info); |