diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-06-17 21:18:47 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-06-17 21:18:47 +0000 |
commit | 32b95570df10da14e9662ac91974e89156221e10 (patch) | |
tree | d2de0f4835972269368035a2da153ed500a61444 /wiretap/packetlogger.c | |
parent | 20de5f1a9a7d245887fa0e95bd9ef3dfbb8166bc (diff) | |
download | wireshark-32b95570df10da14e9662ac91974e89156221e10.tar.gz |
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/packetlogger.c')
-rw-r--r-- | wiretap/packetlogger.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c index f72ece74d7..93e050d34f 100644 --- a/wiretap/packetlogger.c +++ b/wiretap/packetlogger.c @@ -54,8 +54,9 @@ static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off, gchar **err_info); static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err, gchar **err_info); -static gboolean packetlogger_process_header(FILE_T fh, struct wtap_pkthdr *phdr, - int *err, gchar **err_info); +static gboolean packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, + Buffer *buf, int *err, + gchar **err_info); int packetlogger_open(wtap *wth, int *err, gchar **err_info) { @@ -100,35 +101,24 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - if(!packetlogger_process_header(wth->fh, &wth->phdr, err, err_info)) - return FALSE; - - return wtap_read_packet_bytes(wth->fh, wth->frame_buffer, - wth->phdr.caplen, err, err_info); + return packetlogger_read_packet(wth->fh, &wth->phdr, + wth->frame_buffer, err, err_info); } static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, - Buffer *buf, int length, int *err, gchar **err_info) + Buffer *buf, int length _U_, int *err, gchar **err_info) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if(!packetlogger_process_header(wth->random_fh, phdr, err, err_info)) { + if(!packetlogger_read_packet(wth->random_fh, phdr, buf, err, err_info)) { if(*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; } - - if((guint32)length != phdr->caplen) { - *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("packetlogger: record length %u doesn't match requested length %d", phdr->caplen, length); - return FALSE; - } - - return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, - err, err_info); + return TRUE; } static gboolean @@ -146,8 +136,8 @@ packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, int *err, } static gboolean -packetlogger_process_header(FILE_T fh, struct wtap_pkthdr *phdr, - int *err, gchar **err_info) +packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, + int *err, gchar **err_info) { packetlogger_header_t pl_hdr; @@ -178,5 +168,5 @@ packetlogger_process_header(FILE_T fh, struct wtap_pkthdr *phdr, phdr->ts.secs = (time_t) (pl_hdr.ts >> 32); phdr->ts.nsecs = (int)((pl_hdr.ts & 0xFFFFFFFF) * 1000); - return TRUE; + return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info); } |