diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-05-16 22:01:44 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-05-16 22:01:44 +0000 |
commit | 13262726bc3eb6a8efdee9dc028a59719b6f7cd9 (patch) | |
tree | e375fd0b93329515be736859b927dd6d07a5504a /wiretap/camins.c | |
parent | 609dac2f9e41d6a566c3123770ce2d476f6171c5 (diff) |
Pull the code to set the wtap_pkthdr into a common routine, so it's done
for read and seek-read.
Clarify a comment. (wtap_open_offline() only rewinds the file before
calling each open routine; once one of those routines has decided the
file belongs to it, the seek offset belongs to it, so it needs to do all
the seeking necessary - files with a file header *don't* want a rewind,
they want to leave the seek offset positioned *past* the file header so
it can read the records that follow the file header.)
svn path=/trunk/; revision=49347
Diffstat (limited to 'wiretap/camins.c')
-rw-r--r-- | wiretap/camins.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/wiretap/camins.c b/wiretap/camins.c index 879b68da37..b3b481ff6b 100644 --- a/wiretap/camins.c +++ b/wiretap/camins.c @@ -258,6 +258,16 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len) } +static void +fill_in_phdr(struct wtap_pkthdr *phdr, gint offset) +{ + phdr->pkt_encap = WTAP_ENCAP_DVBCI; + /* timestamps aren't supported for now */ + phdr->caplen = offset; + phdr->len = offset; +} + + static gboolean camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { @@ -293,11 +303,7 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) return FALSE; offset += bytes_read; - wth->phdr.pkt_encap = WTAP_ENCAP_DVBCI; - wth->phdr.ts.secs = 0; /* timestamps aren't supported for now */ - wth->phdr.ts.nsecs = 0; - wth->phdr.caplen = offset; - wth->phdr.len = offset; + fill_in_phdr(&wth->phdr, offset); return TRUE; } @@ -305,7 +311,7 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) static gboolean camins_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *pkthdr _U_, guint8 *pd, int length, + struct wtap_pkthdr *pkthdr, guint8 *pd, int length, int *err, gchar **err_info) { guint8 dat_trans_type; @@ -337,6 +343,9 @@ camins_seek_read(wtap *wth, gint64 seek_off, /* see comment in camins_read() */ if (bytes_read < 0) return FALSE; + offset += bytes_read; + + fill_in_phdr(pkthdr, offset); return TRUE; } @@ -366,7 +375,7 @@ int camins_open(wtap *wth, int *err, gchar **err_info _U_) if (found_start_blocks < 2) return 0; /* no CAM Inspector file */ - /* wtap_open_offline() does not rewind the fh, let's do it ourselves */ + /* rewind the fh so we re-read from the beginning */ if (-1 == file_seek(wth->fh, 0, SEEK_SET, err)) return -1; |