diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-02-08 16:19:12 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-02-09 00:29:51 +0000 |
commit | 1f5f63f8ef98bfe9c4d734674cee0df64855555d (patch) | |
tree | 133dd3563cc8d2d29dd85d4d43cd9a4636283192 /wiretap/aethra.c | |
parent | e4c5efafb7da2d25b7d47fe2dac3b1556c0b67b0 (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/aethra.c')
-rw-r--r-- | wiretap/aethra.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/wiretap/aethra.c b/wiretap/aethra.c index bfe02042a2..0faba8a49d 100644 --- a/wiretap/aethra.c +++ b/wiretap/aethra.c @@ -105,9 +105,9 @@ typedef struct { static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean aethra_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); static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr, - struct wtap_pkthdr *phdr, int *err, gchar **err_info); + wtap_rec *rec, int *err, gchar **err_info); wtap_open_return_val aethra_open(wtap *wth, int *err, gchar **err_info) { @@ -176,16 +176,16 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read record header. */ - if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->phdr, err, err_info)) + if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->rec, err, err_info)) return FALSE; /* * XXX - if this is big, we might waste memory by * growing the buffer to handle it. */ - if (wth->phdr.caplen != 0) { - if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, - wth->phdr.caplen, err, err_info)) + if (wth->rec.rec_header.packet_header.caplen != 0) { + if (!wtap_read_packet_bytes(wth->fh, wth->rec_data, + wth->rec.rec_header.packet_header.caplen, err, err_info)) return FALSE; /* Read error */ } #if 0 @@ -235,7 +235,7 @@ fprintf(stderr, " subtype 0x%02x (AETHRA_ISDN_LINK_ALL_ALARMS_CLEARED)\n", hd default: #if 0 fprintf(stderr, " subtype 0x%02x, packet_size %u, direction 0x%02x\n", -hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, wth->phdr.caplen, hdr.flags & AETHRA_U_TO_N); +hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, wth->rec.rec_header.packet_header.caplen, hdr.flags & AETHRA_U_TO_N); #endif break; } @@ -244,7 +244,7 @@ hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, wth->phdr.caplen, hdr.flags & AETHRA_U_TO_ default: #if 0 fprintf(stderr, "Packet %u: type 0x%02x, packet_size %u, flags 0x%02x\n", -packet, hdr.rec_type, wth->phdr.caplen, hdr.flags); +packet, hdr.rec_type, wth->rec.rec_header.packet_header.caplen, hdr.flags); #endif break; } @@ -255,7 +255,7 @@ found: } static gboolean -aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +aethra_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct aethrarec_hdr hdr; @@ -263,7 +263,7 @@ aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err, + if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, rec, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -273,7 +273,7 @@ aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, /* * Read the packet data. */ - if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info)) + if (!wtap_read_packet_bytes(wth->random_fh, buf, rec->rec_header.packet_header.caplen, err, err_info)) return FALSE; /* failed */ return TRUE; @@ -281,7 +281,7 @@ aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr, - struct wtap_pkthdr *phdr, int *err, gchar **err_info) + wtap_rec *rec, int *err, gchar **err_info) { aethra_t *aethra = (aethra_t *)wth->priv; guint32 rec_size; @@ -316,14 +316,14 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr, packet_size = rec_size - (guint32)(sizeof *hdr - sizeof hdr->rec_size); msecs = pletoh32(hdr->timestamp); - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = aethra->start + (msecs / 1000); - phdr->ts.nsecs = (msecs % 1000) * 1000000; - phdr->caplen = packet_size; - phdr->len = packet_size; - phdr->pseudo_header.isdn.uton = (hdr->flags & AETHRA_U_TO_N); - phdr->pseudo_header.isdn.channel = 0; /* XXX - D channel */ + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = aethra->start + (msecs / 1000); + rec->ts.nsecs = (msecs % 1000) * 1000000; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; + rec->rec_header.packet_header.pseudo_header.isdn.uton = (hdr->flags & AETHRA_U_TO_N); + rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; /* XXX - D channel */ return TRUE; } |