aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-10-19 00:34:28 +0000
committerGuy Harris <guy@alum.mit.edu>2012-10-19 00:34:28 +0000
commitfe22586b7904e2de46bc6960480e9e6218198fd7 (patch)
treedca6cb4b1d6c9d6974c057184a3520f04b054e96 /wiretap
parent9f5431f1d9474d1450df2a4be4908221709b7a1e (diff)
Hoist the code to set the wtap_pkthdr into a routine, and call it in
both the read and the seek-read routine, now that a pointer to the wtap_pkthdr is passed to the seek-read routine. svn path=/trunk/; revision=45655
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/ber.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/wiretap/ber.c b/wiretap/ber.c
index 6e50113a6a..3dfe78b462 100644
--- a/wiretap/ber.c
+++ b/wiretap/ber.c
@@ -40,6 +40,17 @@
#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
#define BER_UNI_TAG_SET 17 /* SET, SET OF */
+static void ber_set_pkthdr(struct wtap_pkthdr *phdr, int packet_size)
+{
+ phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
+
+ phdr->caplen = packet_size;
+ phdr->len = packet_size;
+
+ phdr->ts.secs = 0;
+ phdr->ts.nsecs = 0;
+}
+
static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@@ -75,15 +86,9 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer);
- wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
-
- wth->phdr.presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
-
- wth->phdr.caplen = packet_size;
- wth->phdr.len = packet_size;
+ ber_set_pkthdr(&wth->phdr, packet_size);
- wth->phdr.ts.secs = 0;
- wth->phdr.ts.nsecs = 0;
+ wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
return TRUE;
}
@@ -102,6 +107,8 @@ static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
+ ber_set_pkthdr(phdr, packet_size);
+
wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err, err_info);
return TRUE;