aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/cosine.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/cosine.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/cosine.c')
-rw-r--r--wiretap/cosine.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index 49bcb3a6db..3407ad67d7 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -152,8 +152,8 @@ static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static int parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
+ wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
+static int parse_cosine_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);
@@ -280,13 +280,13 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
*data_offset = offset;
/* Parse the header and convert the ASCII hex dump to binary data */
- return parse_cosine_packet(wth->fh, &wth->phdr, wth->frame_buffer,
+ return parse_cosine_packet(wth->fh, &wth->rec, wth->rec_data,
line, err, err_info);
}
/* Used to read packets in random-access fashion */
static gboolean
-cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
+cosine_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
Buffer *buf, int *err, gchar **err_info)
{
char line[COSINE_LINE_LENGTH];
@@ -303,7 +303,7 @@ cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
}
/* Parse the header and convert the ASCII hex dump to binary data */
- return parse_cosine_packet(wth->random_fh, phdr, buf, line, err,
+ return parse_cosine_packet(wth->random_fh, rec, buf, line, err,
err_info);
}
@@ -313,10 +313,10 @@ cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
2) output to PE without date and time
l2-tx (FR:3/7/1:1), Length:18, Pro:0, Off:0, Pri:0, RM:0, Err:0 [0x4000, 0x0] */
static gboolean
-parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
+parse_cosine_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
char *line, int *err, gchar **err_info)
{
- union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
+ union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
int num_items_scanned;
int yy, mm, dd, hr, min, sec, csec, pkt_len;
int pro, off, pri, rm, error;
@@ -372,8 +372,8 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
return FALSE;
}
- 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;
tm.tm_year = yy - 1900;
tm.tm_mon = mm - 1;
tm.tm_mday = dd;
@@ -381,9 +381,9 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
tm.tm_min = min;
tm.tm_sec = sec;
tm.tm_isdst = -1;
- phdr->ts.secs = mktime(&tm);
- phdr->ts.nsecs = csec * 10000000;
- phdr->len = pkt_len;
+ rec->ts.secs = mktime(&tm);
+ rec->ts.nsecs = csec * 10000000;
+ rec->rec_header.packet_header.len = pkt_len;
/* XXX need to handle other encapsulations like Cisco HDLC,
Frame Relay and ATM */
@@ -445,7 +445,7 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
}
caplen += n;
}
- phdr->caplen = caplen;
+ rec->rec_header.packet_header.caplen = caplen;
return TRUE;
}