aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netscreen.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/netscreen.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/netscreen.c')
-rw-r--r--wiretap/netscreen.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index e66297d2e9..4da386e415 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -55,9 +55,9 @@ static gboolean netscreen_check_file_type(wtap *wth, int *err,
static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf,
+ wtap_rec *rec, Buffer *buf,
int *err, gchar **err_info);
-static gboolean parse_netscreen_packet(FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean parse_netscreen_packet(FILE_T fh, wtap_rec *rec,
Buffer* buf, char *line, int *err, gchar **err_info);
static int parse_single_hex_dump_line(char* rec, guint8 *buf,
guint byte_offset);
@@ -183,8 +183,8 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
return FALSE;
/* Parse the header and convert the ASCII hex dump to binary data */
- if (!parse_netscreen_packet(wth->fh, &wth->phdr,
- wth->frame_buffer, line, err, err_info))
+ if (!parse_netscreen_packet(wth->fh, &wth->rec,
+ wth->rec_data, line, err, err_info))
return FALSE;
/*
@@ -196,9 +196,9 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
* have a single encapsulation for all packets in the file.
*/
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
- wth->file_encap = wth->phdr.pkt_encap;
+ wth->file_encap = wth->rec.rec_header.packet_header.pkt_encap;
else {
- if (wth->file_encap != wth->phdr.pkt_encap)
+ if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
@@ -209,7 +209,7 @@ static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
/* Used to read packets in random-access fashion */
static gboolean
netscreen_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf,
+ wtap_rec *rec, Buffer *buf,
int *err, gchar **err_info)
{
char line[NETSCREEN_LINE_LENGTH];
@@ -226,7 +226,7 @@ netscreen_seek_read(wtap *wth, gint64 seek_off,
return FALSE;
}
- return parse_netscreen_packet(wth->random_fh, phdr, buf, line,
+ return parse_netscreen_packet(wth->random_fh, rec, buf, line,
err, err_info);
}
@@ -248,7 +248,7 @@ netscreen_seek_read(wtap *wth, gint64 seek_off,
*/
static gboolean
-parse_netscreen_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
+parse_netscreen_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
char *line, int *err, gchar **err_info)
{
int pkt_len;
@@ -264,8 +264,8 @@ parse_netscreen_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
int offset = 0;
gchar dststr[13];
- phdr->rec_type = REC_TYPE_PACKET;
- phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
+ rec->rec_type = REC_TYPE_PACKET;
+ rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
/* Suppress compiler warnings */
memset(cap_int, 0, sizeof(cap_int));
memset(cap_dst, 0, sizeof(cap_dst));
@@ -297,9 +297,9 @@ parse_netscreen_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
* otherwise it's NETSCREEN_INGRESS.
*/
- phdr->ts.secs = sec;
- phdr->ts.nsecs = dsec * 100000000;
- phdr->len = pkt_len;
+ rec->ts.secs = sec;
+ rec->ts.nsecs = dsec * 100000000;
+ rec->rec_header.packet_header.len = pkt_len;
/* Make sure we have enough room for the packet */
ws_buffer_assure_space(buf, pkt_len);
@@ -384,16 +384,16 @@ parse_netscreen_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
g_snprintf(dststr, 13, "%02x%02x%02x%02x%02x%02x",
pd[0], pd[1], pd[2], pd[3], pd[4], pd[5]);
if (strncmp(dststr, cap_dst, 12) == 0)
- phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
+ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
else
- phdr->pkt_encap = WTAP_ENCAP_PPP;
+ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_PPP;
}
else if (strncmp(cap_int, "seri", 4) == 0)
- phdr->pkt_encap = WTAP_ENCAP_PPP;
+ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_PPP;
else
- phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
+ rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
- phdr->caplen = offset;
+ rec->rec_header.packet_header.caplen = offset;
return TRUE;
}