aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/pppdump.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-02-08 16:19:12 -0800
committerGuy Harris <guy@alum.mit.edu>2018-02-09 00:29:51 +0000
commit1f5f63f8ef98bfe9c4d734674cee0df64855555d (patch)
tree133dd3563cc8d2d29dd85d4d43cd9a4636283192 /wiretap/pppdump.c
parente4c5efafb7da2d25b7d47fe2dac3b1556c0b67b0 (diff)
Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/pppdump.c')
-rw-r--r--wiretap/pppdump.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index b6ad43f1fa..67e801a30e 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -86,7 +86,7 @@ typedef enum {
static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
+ wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
/*
* Information saved about a packet, during the initial sequential pass
@@ -302,15 +302,15 @@ pppdump_open(wtap *wth, int *err, gchar **err_info)
/* Set part of the struct wtap_pkthdr. */
static void
-pppdump_set_phdr(struct wtap_pkthdr *phdr, int num_bytes,
+pppdump_set_phdr(wtap_rec *rec, int num_bytes,
direction_enum direction)
{
- phdr->rec_type = REC_TYPE_PACKET;
- phdr->len = num_bytes;
- phdr->caplen = num_bytes;
- phdr->pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR;
+ rec->rec_type = REC_TYPE_PACKET;
+ rec->rec_header.packet_header.len = num_bytes;
+ rec->rec_header.packet_header.caplen = num_bytes;
+ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR;
- phdr->pseudo_header.p2p.sent = (direction == DIRECTION_SENT ? TRUE : FALSE);
+ rec->rec_header.packet_header.pseudo_header.p2p.sent = (direction == DIRECTION_SENT ? TRUE : FALSE);
}
/* Find the next packet and parse it; called from wtap_read(). */
@@ -337,8 +337,8 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
} else
pid = NULL; /* sequential only */
- ws_buffer_assure_space(wth->frame_buffer, PPPD_BUF_SIZE);
- buf = ws_buffer_start_ptr(wth->frame_buffer);
+ ws_buffer_assure_space(wth->rec_data, PPPD_BUF_SIZE);
+ buf = ws_buffer_start_ptr(wth->rec_data);
if (!collate(state, wth->fh, err, err_info, buf, &num_bytes, &direction,
pid, 0)) {
@@ -355,10 +355,10 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*data_offset = state->pkt_cnt;
state->pkt_cnt++;
- pppdump_set_phdr(&wth->phdr, num_bytes, direction);
- wth->phdr.presence_flags = WTAP_HAS_TS;
- wth->phdr.ts.secs = state->timestamp;
- wth->phdr.ts.nsecs = state->tenths * 100000000;
+ pppdump_set_phdr(&wth->rec, num_bytes, direction);
+ wth->rec.presence_flags = WTAP_HAS_TS;
+ wth->rec.ts.secs = state->timestamp;
+ wth->rec.ts.nsecs = state->tenths * 100000000;
return TRUE;
}
@@ -712,7 +712,7 @@ done:
static gboolean
pppdump_seek_read(wtap *wth,
gint64 seek_off,
- struct wtap_pkthdr *phdr,
+ wtap_rec *rec,
Buffer *buf,
int *err,
gchar **err_info)
@@ -761,7 +761,7 @@ pppdump_seek_read(wtap *wth,
num_bytes_to_skip = 0;
} while (direction != pid->dir);
- pppdump_set_phdr(phdr, num_bytes, pid->dir);
+ pppdump_set_phdr(rec, num_bytes, pid->dir);
return TRUE;
}