aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/btsnoop.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-17 21:18:47 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-17 21:18:47 +0000
commit32b95570df10da14e9662ac91974e89156221e10 (patch)
treed2de0f4835972269368035a2da153ed500a61444 /wiretap/btsnoop.c
parent20de5f1a9a7d245887fa0e95bd9ef3dfbb8166bc (diff)
Merge "read record header" and "read packet data" routines into a single
routine, used both by read and seek-read routines. svn path=/trunk/; revision=49988
Diffstat (limited to 'wiretap/btsnoop.c')
-rw-r--r--wiretap/btsnoop.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index cb44f4e51a..ce16c2fa6d 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -76,8 +76,8 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int length,
int *err, gchar **err_info);
-static gboolean btsnoop_read_record_header(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, int *err, gchar **err_info);
+static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
int btsnoop_open(wtap *wth, int *err, gchar **err_info)
{
@@ -157,33 +157,22 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
{
*data_offset = file_tell(wth->fh);
- /* Read record header. */
- if (!btsnoop_read_record_header(wth, wth->fh, &wth->phdr, err, err_info))
- return FALSE;
-
- /* Read packet data. */
- return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
- wth->phdr.caplen, err, err_info);
+ return btsnoop_read_record(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+ err, err_info);
}
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int length,
+ struct wtap_pkthdr *phdr, Buffer *buf, int length _U_,
int *err, gchar **err_info)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- /* Read record header. */
- if (!btsnoop_read_record_header(wth, wth->random_fh, phdr, err, err_info))
- return FALSE;
-
- /* Read packet data. */
- return wtap_read_packet_bytes(wth->random_fh, buf, length, err,
- err_info);
+ return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
}
-static gboolean btsnoop_read_record_header(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, int *err, gchar **err_info)
+static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
int bytes_read;
struct btsnooprec_hdr hdr;
@@ -192,6 +181,8 @@ static gboolean btsnoop_read_record_header(wtap *wth, FILE_T fh,
guint32 orig_size;
gint64 ts;
+ /* Read record header. */
+
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, sizeof hdr, fh);
if (bytes_read != sizeof hdr) {
@@ -246,7 +237,10 @@ static gboolean btsnoop_read_record_header(wtap *wth, FILE_T fh,
phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL;
}
}
- return TRUE;
+
+
+ /* Read packet data. */
+ return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
}
/* Returns 0 if we could write the specified encapsulation type,