diff options
author | Guy Harris <guy@alum.mit.edu> | 2020-05-01 14:31:19 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2020-05-01 22:07:17 +0000 |
commit | e548eceeac8a3b57e7f656de89cad2a9913ffd44 (patch) | |
tree | 9213650611bf30648d98f886fd0b16d6afed30a2 /wiretap | |
parent | d5fc969e578a1e3a3eccb03b1586cbadd58107a5 (diff) |
wiretap: combine common code into a common routine.
Change-Id: I7329bea02e2264ffb70515b681609bff91575267
Reviewed-on: https://code.wireshark.org/review/37012
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/wtap.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 3fae62170d..3d9ebb44af 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1307,9 +1307,8 @@ wtapng_process_dsb(wtap *wth, wtap_block_t dsb) wth->add_new_secrets(dsb_mand->secrets_type, dsb_mand->secrets_data, dsb_mand->secrets_len); } -gboolean -wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, - gchar **err_info, gint64 *offset) +static void +wtap_init_rec(wtap *wth, wtap_rec *rec) { /* * Set the packet encapsulation to the file's encapsulation @@ -1323,6 +1322,16 @@ wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, */ rec->rec_header.packet_header.pkt_encap = wth->file_encap; rec->tsprec = wth->file_tsprec; +} + +gboolean +wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, + gchar **err_info, gint64 *offset) +{ + /* + * Initialize the record to default values. + */ + wtap_init_rec(wth, rec); *err = 0; *err_info = NULL; @@ -1473,17 +1482,9 @@ wtap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* - * Set the packet encapsulation to the file's encapsulation - * value; if that's not WTAP_ENCAP_PER_PACKET, it's the - * right answer (and means that the read routine for this - * capture file type doesn't have to set it), and if it - * *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it - * anyway. - * - * Do the same for the packet time stamp resolution. + * Initialize the record to default values. */ - rec->rec_header.packet_header.pkt_encap = wth->file_encap; - rec->tsprec = wth->file_tsprec; + wtap_init_rec(wth, rec); *err = 0; *err_info = NULL; |