aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/dct3trace.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 /wiretap/dct3trace.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 'wiretap/dct3trace.c')
-rw-r--r--wiretap/dct3trace.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c
index 2346cba611..f49c2d1e76 100644
--- a/wiretap/dct3trace.c
+++ b/wiretap/dct3trace.c
@@ -76,7 +76,7 @@ static const char dct3trace_magic_end[] = "</dump>";
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean dct3trace_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);
/*
@@ -347,17 +347,17 @@ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
/* Used to read packets in random-access fashion */
static gboolean dct3trace_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)
{
- unsigned char buf[MAX_PACKET_LEN];
+ unsigned char databuf[MAX_PACKET_LEN];
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
{
return FALSE;
}
- if( !dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info) )
+ if( !dct3trace_get_packet(wth->random_fh, phdr, databuf, err, err_info) )
{
return FALSE;
}
@@ -377,6 +377,8 @@ static gboolean dct3trace_seek_read (wtap *wth, gint64 seek_off,
return FALSE;
}
- memcpy( pd, buf, phdr->caplen );
+ /* Make sure we have enough room for the packet */
+ buffer_assure_space(buf, phdr->caplen);
+ memcpy( buffer_start_ptr(buf), databuf, phdr->caplen );
return TRUE;
}