diff options
Diffstat (limited to 'wiretap')
65 files changed, 2108 insertions, 2073 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c index 61e7bd78d3..2a94e7724d 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -87,12 +87,12 @@ typedef struct static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); +static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, + Buffer *buf, int *err, gchar **err_info); static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, - struct wtap_pkthdr *phdr, int *err, gchar **err_info); + wtap_rec *rec, int *err, gchar **err_info); -static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, int *err, gchar **err_info); +static gboolean _5views_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err); @@ -186,7 +186,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* Read record header. */ if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header, - &wth->phdr, err, err_info)) + &wth->rec, err, err_info)) return FALSE; if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) { @@ -203,23 +203,23 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) return FALSE; } while (1); - if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (wth->rec.rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u", - wth->phdr.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); + wth->rec.rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } - return wtap_read_packet_bytes(wth->fh, wth->frame_buffer, - wth->phdr.caplen, err, err_info); + return wtap_read_packet_bytes(wth->fh, wth->rec_data, + wth->rec.rec_header.packet_header.caplen, err, err_info); } static gboolean -_5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +_5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { t_5VW_TimeStamped_Header TimeStamped_Header; @@ -231,7 +231,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, * Read the header. */ if (!_5views_read_header(wth, wth->random_fh, &TimeStamped_Header, - phdr, err, err_info)) { + rec, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -240,7 +240,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, /* * Read the packet data. */ - return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, + return wtap_read_packet_bytes(wth->random_fh, buf, rec->rec_header.packet_header.caplen, err, err_info); } @@ -248,7 +248,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, on error. */ static gboolean _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, - struct wtap_pkthdr *phdr, int *err, gchar **err_info) + wtap_rec *rec, int *err, gchar **err_info) { /* Read record header. */ if (!wtap_read_bytes_or_eof(fh, hdr, (unsigned int)sizeof(t_5VW_TimeStamped_Header), @@ -268,18 +268,18 @@ _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, hdr->Utc = pletoh32(&hdr->Utc); hdr->NanoSecondes = pletoh32(&hdr->NanoSecondes); - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = hdr->Utc; - phdr->ts.nsecs = hdr->NanoSecondes; - phdr->caplen = hdr->RecSize; - phdr->len = hdr->RecSize; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = hdr->Utc; + rec->ts.nsecs = hdr->NanoSecondes; + rec->rec_header.packet_header.caplen = hdr->RecSize; + rec->rec_header.packet_header.len = hdr->RecSize; switch (wth->file_encap) { case WTAP_ENCAP_ETHERNET: /* We assume there's no FCS in this frame. */ - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; } @@ -336,20 +336,20 @@ gboolean _5views_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean _5views_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv; t_5VW_TimeStamped_Header HeaderFrame; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* Don't write out something bigger than we can read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -364,9 +364,9 @@ static gboolean _5views_dump(wtap_dumper *wdh, HeaderFrame.RecNb = GUINT32_TO_LE(1); /* record-dependent fields */ - HeaderFrame.Utc = GUINT32_TO_LE(phdr->ts.secs); - HeaderFrame.NanoSecondes = GUINT32_TO_LE(phdr->ts.nsecs); - HeaderFrame.RecSize = GUINT32_TO_LE(phdr->len); + HeaderFrame.Utc = GUINT32_TO_LE(rec->ts.secs); + HeaderFrame.NanoSecondes = GUINT32_TO_LE(rec->ts.nsecs); + HeaderFrame.RecSize = GUINT32_TO_LE(rec->rec_header.packet_header.len); HeaderFrame.RecInfo = GUINT32_TO_LE(0); /* write the record header */ @@ -375,7 +375,7 @@ static gboolean _5views_dump(wtap_dumper *wdh, return FALSE; /* write the data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; _5views->nframes ++; 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; } diff --git a/wiretap/ascend-int.h b/wiretap/ascend-int.h index 0b7af0e679..73581531b5 100644 --- a/wiretap/ascend-int.h +++ b/wiretap/ascend-int.h @@ -40,7 +40,7 @@ typedef struct { } ascend_state_t; extern int -run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd, +run_ascend_parser(FILE_T fh, wtap_rec *rec, guint8 *pd, ascend_state_t *parser_state, int *err, gchar **err_info); #endif /* ! __ASCEND_INT_H__ */ diff --git a/wiretap/ascend.y b/wiretap/ascend.y index 0b527157b3..f97ed93a3b 100644 --- a/wiretap/ascend.y +++ b/wiretap/ascend.y @@ -431,7 +431,7 @@ datagroup: dataln /* Run the parser. */ int -run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd, +run_ascend_parser(FILE_T fh, wtap_rec *rec, guint8 *pd, ascend_state_t *parser_state, int *err, gchar **err_info) { yyscan_t scanner = NULL; @@ -449,7 +449,7 @@ run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd, parser_state->ascend_parse_error = NULL; parser_state->err = 0; parser_state->err_info = NULL; - parser_state->pseudo_header = &phdr->pseudo_header.ascend; + parser_state->pseudo_header = &rec->rec_header.packet_header.pseudo_header.ascend; parser_state->pkt_data = pd; /* diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c index 94d905e57c..30e87f0f27 100644 --- a/wiretap/ascendtext.c +++ b/wiretap/ascendtext.c @@ -65,7 +65,7 @@ static const ascend_magic_string ascend_magic[] = { static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean ascend_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); /* Seeks to the beginning of the next packet, and returns the @@ -200,7 +200,7 @@ found: if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1) return -1; - wth->phdr.pseudo_header.ascend.type = type; + wth->rec.rec_header.packet_header.pseudo_header.ascend.type = type; return packet_off; } @@ -228,7 +228,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info) /* Do a trial parse of the first packet just found to see if we might really have an Ascend file. If it fails with an actual error, fail; those will be I/O errors. */ - if (run_ascend_parser(wth->fh, &wth->phdr, buf, &parser_state, err, + if (run_ascend_parser(wth->fh, &wth->rec, buf, &parser_state, err, err_info) != 0 && *err != 0) { /* An I/O error. */ return WTAP_OPEN_ERROR; @@ -249,7 +249,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info) wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND; - switch(wth->phdr.pseudo_header.ascend.type) { + switch(wth->rec.rec_header.packet_header.pseudo_header.ascend.type) { case ASCEND_PFX_ISDN_X: case ASCEND_PFX_ISDN_R: wth->file_encap = WTAP_ENCAP_ISDN; @@ -292,14 +292,14 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info) /* Parse the capture file. Returns TRUE if we got a packet, FALSE otherwise. */ static gboolean -parse_ascend(ascend_t *ascend, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec, Buffer *buf, guint length, int *err, gchar **err_info) { ascend_state_t parser_state; int retval; ws_buffer_assure_space(buf, length); - retval = run_ascend_parser(fh, phdr, ws_buffer_start_ptr(buf), &parser_state, + retval = run_ascend_parser(fh, rec, ws_buffer_start_ptr(buf), &parser_state, err, err_info); /* did we see any data (hex bytes)? if so, tip off ascend_seek() @@ -342,30 +342,30 @@ parse_ascend(ascend_t *ascend, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, if (ascend->inittime > parser_state.secs) ascend->inittime -= parser_state.secs; } - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->ts.secs = parser_state.secs + ascend->inittime; - phdr->ts.nsecs = parser_state.usecs * 1000; - phdr->caplen = parser_state.caplen; - phdr->len = parser_state.wirelen; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->ts.secs = parser_state.secs + ascend->inittime; + rec->ts.nsecs = parser_state.usecs * 1000; + rec->rec_header.packet_header.caplen = parser_state.caplen; + rec->rec_header.packet_header.len = parser_state.wirelen; /* * For these types, the encapsulation we use is not WTAP_ENCAP_ASCEND, * so set the pseudo-headers appropriately for the type (WTAP_ENCAP_ISDN * or WTAP_ENCAP_ETHERNET). */ - switch(phdr->pseudo_header.ascend.type) { + switch(rec->rec_header.packet_header.pseudo_header.ascend.type) { case ASCEND_PFX_ISDN_X: - phdr->pseudo_header.isdn.uton = TRUE; - phdr->pseudo_header.isdn.channel = 0; + rec->rec_header.packet_header.pseudo_header.isdn.uton = TRUE; + rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; break; case ASCEND_PFX_ISDN_R: - phdr->pseudo_header.isdn.uton = FALSE; - phdr->pseudo_header.isdn.channel = 0; + rec->rec_header.packet_header.pseudo_header.isdn.uton = FALSE; + rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; break; case ASCEND_PFX_ETHER: - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; } return TRUE; @@ -408,7 +408,7 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, offset = ascend_seek(wth, err, err_info); if (offset == -1) return FALSE; - if (!parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer, + if (!parse_ascend(ascend, wth->fh, &wth->rec, wth->rec_data, wth->snapshot_length, err, err_info)) return FALSE; @@ -417,14 +417,14 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, } static gboolean ascend_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { ascend_t *ascend = (ascend_t *)wth->priv; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (!parse_ascend(ascend, wth->random_fh, phdr, buf, + if (!parse_ascend(ascend, wth->random_fh, rec, buf, wth->snapshot_length, err, err_info)) return FALSE; diff --git a/wiretap/atm.c b/wiretap/atm.c index cd7d2955e8..599dbf5576 100644 --- a/wiretap/atm.c +++ b/wiretap/atm.c @@ -20,34 +20,34 @@ */ void -atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd) +atm_guess_traffic_type(wtap_rec *rec, const guint8 *pd) { /* * Start out assuming nothing other than that it's AAL5. */ - phdr->pseudo_header.atm.aal = AAL_5; - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_5; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; - if (phdr->pseudo_header.atm.vpi == 0) { + if (rec->rec_header.packet_header.pseudo_header.atm.vpi == 0) { /* * Traffic on some PVCs with a VPI of 0 and certain * VCIs is of particular types. */ - switch (phdr->pseudo_header.atm.vci) { + switch (rec->rec_header.packet_header.pseudo_header.atm.vci) { case 5: /* * Signalling AAL. */ - phdr->pseudo_header.atm.aal = AAL_SIGNALLING; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING; return; case 16: /* * ILMI. */ - phdr->pseudo_header.atm.type = TRAF_ILMI; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_ILMI; return; } } @@ -58,21 +58,21 @@ atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd) * to guess. */ - if (phdr->caplen >= 3) { + if (rec->rec_header.packet_header.caplen >= 3) { if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) { /* * Looks like a SNAP header; assume it's LLC * multiplexed RFC 1483 traffic. */ - phdr->pseudo_header.atm.type = TRAF_LLCMX; - } else if ((phdr->pseudo_header.atm.aal5t_len && phdr->pseudo_header.atm.aal5t_len < 16) || - phdr->caplen < 16) { + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LLCMX; + } else if ((rec->rec_header.packet_header.pseudo_header.atm.aal5t_len && rec->rec_header.packet_header.pseudo_header.atm.aal5t_len < 16) || + rec->rec_header.packet_header.caplen < 16) { /* * As this cannot be a LANE Ethernet frame (less * than 2 bytes of LANE header + 14 bytes of * Ethernet header) we can try it as a SSCOP frame. */ - phdr->pseudo_header.atm.aal = AAL_SIGNALLING; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING; } else if (pd[0] == 0x83 || pd[0] == 0x81) { /* * MTP3b headers often encapsulate @@ -80,32 +80,32 @@ atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd) * This should cause 0x83 or 0x81 * in the first byte. */ - phdr->pseudo_header.atm.aal = AAL_SIGNALLING; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING; } else { /* * Assume it's LANE. */ - phdr->pseudo_header.atm.type = TRAF_LANE; - atm_guess_lane_type(phdr, pd); + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LANE; + atm_guess_lane_type(rec, pd); } } else { /* * Not only VCI 5 is used for signaling. It might be * one of these VCIs. */ - phdr->pseudo_header.atm.aal = AAL_SIGNALLING; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING; } } void -atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd) +atm_guess_lane_type(wtap_rec *rec, const guint8 *pd) { - if (phdr->caplen >= 2) { + if (rec->rec_header.packet_header.caplen >= 2) { if (pd[0] == 0xff && pd[1] == 0x00) { /* * Looks like LE Control traffic. */ - phdr->pseudo_header.atm.subtype = TRAF_ST_LANE_LE_CTRL; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_LANE_LE_CTRL; } else { /* * XXX - Ethernet, or Token Ring? @@ -115,7 +115,7 @@ atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd) * still be situations where the user has to * tell us. */ - phdr->pseudo_header.atm.subtype = TRAF_ST_LANE_802_3; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_LANE_802_3; } } } diff --git a/wiretap/atm.h b/wiretap/atm.h index 287fb2fbf1..d98a112fec 100644 --- a/wiretap/atm.h +++ b/wiretap/atm.h @@ -18,9 +18,9 @@ */ extern void -atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd); +atm_guess_traffic_type(wtap_rec *rec, const guint8 *pd); extern void -atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd); +atm_guess_lane_type(wtap_rec *rec, const guint8 *pd); #endif /* __ATM_H__ */ diff --git a/wiretap/ber.c b/wiretap/ber.c index 1d0e87abf5..e32254a444 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -22,7 +22,7 @@ #define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */ #define BER_UNI_TAG_SET 17 /* SET, SET OF */ -static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean ber_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { gint64 file_size; @@ -43,14 +43,14 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->ts.secs = 0; + rec->ts.nsecs = 0; ws_buffer_assure_space(buf, packet_size); return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); @@ -70,10 +70,10 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off *data_offset = offset; - return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return ber_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } -static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +static gboolean ber_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ @@ -85,7 +85,7 @@ 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; - return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info); + return ber_read_file(wth, wth->random_fh, rec, buf, err, err_info); } wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info) diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c index 8bfb750e6c..91a09d3b3a 100644 --- a/wiretap/btsnoop.c +++ b/wiretap/btsnoop.c @@ -62,9 +62,9 @@ static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* of static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean btsnoop_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 btsnoop_read_record(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info) { @@ -141,21 +141,21 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info, { *data_offset = file_tell(wth->fh); - return btsnoop_read_record(wth, wth->fh, &wth->phdr, wth->frame_buffer, + return btsnoop_read_record(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean btsnoop_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info); + return btsnoop_read_record(wth, wth->random_fh, rec, buf, err, err_info); } static gboolean btsnoop_read_record(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct btsnooprec_hdr hdr; guint32 packet_size; @@ -185,40 +185,40 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh, ts = GINT64_FROM_BE(hdr.ts_usec); ts -= KUnixTimeBase; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->ts.secs = (guint)(ts / 1000000); - phdr->ts.nsecs = (guint)((ts % 1000000) * 1000); - phdr->caplen = packet_size; - phdr->len = orig_size; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->ts.secs = (guint)(ts / 1000000); + rec->ts.nsecs = (guint)((ts % 1000000) * 1000); + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = orig_size; if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR) { - phdr->pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; + rec->rec_header.packet_header.pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; } else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) { - phdr->pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; + rec->rec_header.packet_header.pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; if(flags & KHciLoggerCommandOrEvent) { - if(phdr->pseudo_header.bthci.sent) + if(rec->rec_header.packet_header.pseudo_header.bthci.sent) { - phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND; + rec->rec_header.packet_header.pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND; } else { - phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT; + rec->rec_header.packet_header.pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT; } } else { - phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL; + rec->rec_header.packet_header.pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL; } } else if (wth->file_encap == WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) { - phdr->pseudo_header.btmon.opcode = flags & 0xFFFF; - phdr->pseudo_header.btmon.adapter_id = flags >> 16; + rec->rec_header.packet_header.pseudo_header.btmon.opcode = flags & 0xFFFF; + rec->rec_header.packet_header.pseudo_header.btmon.adapter_id = flags >> 16; } /* Read packet data. */ - return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info); + return wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info); } /* Returns 0 if we could write the specified encapsulation type, @@ -268,7 +268,7 @@ static guint8 btsnoop_lookup_flags(guint8 hci_type, gboolean sent, guint8 *flags } static gboolean btsnoop_format_partial_rec_hdr( - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const union wtap_pseudo_header *pseudo_header, const guint8 *pd, int *err, gchar **err_info, struct btsnooprec_hdr *rec_hdr) @@ -285,8 +285,8 @@ static gboolean btsnoop_format_partial_rec_hdr( return FALSE; } - nsecs = phdr->ts.nsecs; - ts_usec = ((gint64) phdr->ts.secs * 1000000) + (nsecs / 1000); + nsecs = rec->ts.nsecs; + ts_usec = ((gint64) rec->ts.secs * 1000000) + (nsecs / 1000); ts_usec += KUnixTimeBase; rec_hdr->flags = GUINT32_TO_BE(flags); @@ -298,14 +298,14 @@ static gboolean btsnoop_format_partial_rec_hdr( /* FIXME: How do we support multiple backends?*/ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; struct btsnooprec_hdr rec_hdr; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -314,17 +314,17 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, * Don't write out anything bigger than we can read. * (This will also fail on a caplen of 0, as it should.) */ - if (phdr->caplen-1 > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen-1 > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - if (!btsnoop_format_partial_rec_hdr(phdr, pseudo_header, pd, err, err_info, + if (!btsnoop_format_partial_rec_hdr(rec, pseudo_header, pd, err, err_info, &rec_hdr)) return FALSE; - rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen-1); - rec_hdr.orig_len = GUINT32_TO_BE(phdr->len-1); + rec_hdr.incl_len = GUINT32_TO_BE(rec->rec_header.packet_header.caplen-1); + rec_hdr.orig_len = GUINT32_TO_BE(rec->rec_header.packet_header.len-1); if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err)) return FALSE; @@ -334,49 +334,49 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, /* Skip HCI packet type */ ++pd; - if (!wtap_dump_file_write(wdh, pd, phdr->caplen-1, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen-1, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen-1; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen-1; return TRUE; } static gboolean btsnoop_dump_h4(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; struct btsnooprec_hdr rec_hdr; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* Don't write out anything bigger than we can read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - if (!btsnoop_format_partial_rec_hdr(phdr, pseudo_header, pd, err, err_info, + if (!btsnoop_format_partial_rec_hdr(rec, pseudo_header, pd, err, err_info, &rec_hdr)) return FALSE; - rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen); - rec_hdr.orig_len = GUINT32_TO_BE(phdr->len); + rec_hdr.incl_len = GUINT32_TO_BE(rec->rec_header.packet_header.caplen); + rec_hdr.orig_len = GUINT32_TO_BE(rec->rec_header.packet_header.len); if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err)) return FALSE; wdh->bytes_dumped += sizeof rec_hdr; - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; return TRUE; } diff --git a/wiretap/camins.c b/wiretap/camins.c index 1b3df7b48b..7ce669b64b 100644 --- a/wiretap/camins.c +++ b/wiretap/camins.c @@ -291,7 +291,7 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len) static gboolean -camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +camins_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint8 dat_trans_type; @@ -327,11 +327,11 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; offset += bytes_read; - phdr->rec_type = REC_TYPE_PACKET; - phdr->pkt_encap = WTAP_ENCAP_DVBCI; + rec->rec_type = REC_TYPE_PACKET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DVBCI; /* timestamps aren't supported for now */ - phdr->caplen = offset; - phdr->len = offset; + rec->rec_header.packet_header.caplen = offset; + rec->rec_header.packet_header.len = offset; return TRUE; } @@ -342,19 +342,19 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - return camins_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, + return camins_read_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean -camins_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *pkthdr, Buffer *buf, int *err, gchar **err_info) +camins_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, + int *err, gchar **err_info) { if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) return FALSE; - return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info); + return camins_read_packet(wth->random_fh, rec, buf, err, err_info); } diff --git a/wiretap/capsa.c b/wiretap/capsa.c index 0ba9dc233f..a97977e601 100644 --- a/wiretap/capsa.c +++ b/wiretap/capsa.c @@ -109,8 +109,8 @@ typedef struct { static gboolean capsa_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean capsa_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static int capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); wtap_open_return_val capsa_open(wtap *wth, int *err, gchar **err_info) @@ -262,8 +262,8 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info, if (!file_seek(wth->fh, *data_offset, SEEK_SET, err)) return FALSE; - padbytes = capsa_read_packet(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + padbytes = capsa_read_packet(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); if (padbytes == -1) return FALSE; @@ -282,12 +282,12 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info, static gboolean capsa_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (capsa_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) { + if (capsa_read_packet(wth, wth->random_fh, rec, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -296,7 +296,7 @@ capsa_seek_read(wtap *wth, gint64 seek_off, } static int -capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { capsa_t *capsa = (capsa_t *)wth->priv; @@ -402,14 +402,14 @@ capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * We assume there's no FCS in this frame. * XXX - is there ever one? */ - phdr->pseudo_header.eth.fcs_len = 0; - - phdr->rec_type = REC_TYPE_PACKET; - phdr->caplen = packet_size; - phdr->len = orig_size; - phdr->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_TS; - phdr->ts.secs = (time_t)(timestamp / 1000000); - phdr->ts.nsecs = ((int)(timestamp % 1000000))*1000; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; + + rec->rec_type = REC_TYPE_PACKET; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = orig_size; + rec->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_TS; + rec->ts.secs = (time_t)(timestamp / 1000000); + rec->ts.nsecs = ((int)(timestamp % 1000000))*1000; /* * Read the packet data. diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index 81fdd908b3..0d139736b5 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -93,12 +93,12 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript"; static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static void catapult_dct2000_close(wtap *wth); -static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); @@ -120,7 +120,7 @@ static gboolean parse_line(char *linebuff, gint line_length, gchar *outhdr_name); static gboolean process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, gint64 file_offset, char *linebuff, long dollar_offset, int seconds, int useconds, @@ -379,8 +379,8 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, *data_offset = this_offset; if (!process_parsed_line(wth, file_externals, - &wth->phdr, - wth->frame_buffer, this_offset, + &wth->rec, + wth->rec_data, this_offset, linebuff, dollar_offset, seconds, useconds, timestamp_string, @@ -435,7 +435,7 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, /**************************************************/ static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { int length; @@ -484,7 +484,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, write_timestamp_string(timestamp_string, seconds, useconds/100); if (!process_parsed_line(wth, file_externals, - phdr, buf, seek_off, + rec, buf, seek_off, linebuff, dollar_offset, seconds, useconds, timestamp_string, @@ -575,10 +575,10 @@ catapult_dct2000_dump_can_write_encap(int encap) /*****************************************/ static gboolean -catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +catapult_dct2000_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; guint32 n; line_prefix_info_t *prefix = NULL; gchar time_string[16]; @@ -595,7 +595,7 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, (dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -663,15 +663,15 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, is_comment = (consecutive_slashes == 5); /* Calculate time of this packet to write, relative to start of dump */ - if (phdr->ts.nsecs >= dct2000->start_time.nsecs) { + if (rec->ts.nsecs >= dct2000->start_time.nsecs) { write_timestamp_string(time_string, - (int)(phdr->ts.secs - dct2000->start_time.secs), - (phdr->ts.nsecs - dct2000->start_time.nsecs) / 100000); + (int)(rec->ts.secs - dct2000->start_time.secs), + (rec->ts.nsecs - dct2000->start_time.nsecs) / 100000); } else { write_timestamp_string(time_string, - (int)(phdr->ts.secs - dct2000->start_time.secs-1), - ((1000000000 + (phdr->ts.nsecs / 100000)) - (dct2000->start_time.nsecs / 100000)) % 10000); + (int)(rec->ts.secs - dct2000->start_time.secs-1), + ((1000000000 + (rec->ts.nsecs / 100000)) - (dct2000->start_time.nsecs / 100000)) % 10000); } /* Write out the calculated timestamp */ @@ -734,7 +734,7 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, if (!is_comment) { /* Each binary byte is written out as 2 hex string chars */ - for (; n < phdr->len; n++) { + for (; n < rec->rec_header.packet_header.len; n++) { gchar c[2]; c[0] = char_from_hex((guint8)(pd[n] >> 4)); c[1] = char_from_hex((guint8)(pd[n] & 0x0f)); @@ -746,7 +746,7 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } } else { - for (; n < phdr->len; n++) { + for (; n < rec->rec_header.packet_header.len; n++) { char c[1]; c[0] = pd[n]; @@ -1272,7 +1272,7 @@ parse_line(gchar *linebuff, gint line_length, /***********************************/ static gboolean process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, gint64 file_offset, char *linebuff, long dollar_offset, int seconds, int useconds, gchar *timestamp_string, @@ -1288,25 +1288,25 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, gsize length; guint8 *frame_buffer; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; /* Make sure all packets go to Catapult DCT2000 dissector */ - phdr->pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000; /* Fill in timestamp (capture base + packet offset) */ - phdr->ts.secs = file_externals->start_secs + seconds; + rec->ts.secs = file_externals->start_secs + seconds; if ((file_externals->start_usecs + useconds) >= 1000000) { - phdr->ts.secs++; + rec->ts.secs++; } - phdr->ts.nsecs = + rec->ts.nsecs = ((file_externals->start_usecs + useconds) % 1000000) *1000; /* * Calculate the length of the stub info and the packet data. * The packet data length is half bytestring length. */ - phdr->caplen = (guint)strlen(context_name)+1 + /* Context name */ + rec->rec_header.packet_header.caplen = (guint)strlen(context_name)+1 + /* Context name */ 1 + /* port */ (guint)strlen(timestamp_string)+1 + /* timestamp */ (guint)strlen(variant_name)+1 + /* variant */ @@ -1315,7 +1315,7 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, 1 + /* direction */ 1 + /* encap */ (is_comment ? data_chars : (data_chars/2)); - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; return an error, * so that our caller doesn't blow up trying to allocate @@ -1323,14 +1323,14 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("catapult dct2000: File has %u-byte packet, bigger than maximum of %u", - phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD); + rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } - phdr->len = phdr->caplen; + rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen; /*****************************/ /* Get the data buffer ready */ - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen); frame_buffer = ws_buffer_start_ptr(buf); /******************************************/ @@ -1386,18 +1386,18 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, /*****************************************/ /* Set packet pseudo-header if necessary */ - phdr->pseudo_header.dct2000.seek_off = file_offset; - phdr->pseudo_header.dct2000.wth = wth; + rec->rec_header.packet_header.pseudo_header.dct2000.seek_off = file_offset; + rec->rec_header.packet_header.pseudo_header.dct2000.wth = wth; switch (encap) { case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED: - set_aal_info(&phdr->pseudo_header, direction, aal_header_chars); + set_aal_info(&rec->rec_header.packet_header.pseudo_header, direction, aal_header_chars); break; case WTAP_ENCAP_ISDN: - set_isdn_info(&phdr->pseudo_header, direction); + set_isdn_info(&rec->rec_header.packet_header.pseudo_header, direction); break; case WTAP_ENCAP_PPP: - set_ppp_info(&phdr->pseudo_header, direction); + set_ppp_info(&rec->rec_header.packet_header.pseudo_header, direction); break; default: diff --git a/wiretap/commview.c b/wiretap/commview.c index 595b889793..efd31c019c 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -75,11 +75,11 @@ typedef struct commview_header { static gboolean commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean commview_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err, gchar **err_info); -static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean commview_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info) @@ -123,7 +123,7 @@ wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info) } static int -commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +commview_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { commview_header_t cv_hdr; @@ -141,63 +141,63 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, switch(cv_hdr.flags & FLAGS_MEDIUM) { case MEDIUM_ETHERNET : - phdr->pkt_encap = WTAP_ENCAP_ETHERNET; - phdr->pseudo_header.eth.fcs_len = -1; /* Unknown */ + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1; /* Unknown */ break; case MEDIUM_WIFI : - phdr->pkt_encap = WTAP_ENCAP_IEEE_802_11_WITH_RADIO; - memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11)); - phdr->pseudo_header.ieee_802_11.fcs_len = -1; /* Unknown */ - phdr->pseudo_header.ieee_802_11.decrypted = FALSE; - phdr->pseudo_header.ieee_802_11.datapad = FALSE; - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IEEE_802_11_WITH_RADIO; + memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11)); + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = -1; /* Unknown */ + rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; switch (cv_hdr.band) { case BAND_11A: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A; - phdr->pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE; - phdr->pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type = PHDR_802_11A_TURBO_TYPE_NORMAL; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE); break; case BAND_11B: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11B; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11B; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE); break; case BAND_11G: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G; - phdr->pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE; - phdr->pseudo_header.ieee_802_11.phy_info.info_11g.mode = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.mode = PHDR_802_11G_MODE_NORMAL; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE); break; case BAND_11A_TURBO: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A; - phdr->pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE; - phdr->pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type = PHDR_802_11A_TURBO_TYPE_TURBO; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE); break; case BAND_SUPERG: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G; - phdr->pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE; - phdr->pseudo_header.ieee_802_11.phy_info.info_11g.mode = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.mode = PHDR_802_11G_MODE_SUPER_G; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE); break; case BAND_11N_5GHZ: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE); break; case BAND_11N_2_4GHZ: - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N; frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE); break; @@ -215,18 +215,18 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, break; } if (frequency != 0) { - phdr->pseudo_header.ieee_802_11.has_frequency = TRUE; - phdr->pseudo_header.ieee_802_11.frequency = frequency; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_frequency = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.frequency = frequency; } - phdr->pseudo_header.ieee_802_11.has_channel = TRUE; - phdr->pseudo_header.ieee_802_11.channel = cv_hdr.channel; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel = cv_hdr.channel; - phdr->pseudo_header.ieee_802_11.has_data_rate = TRUE; - phdr->pseudo_header.ieee_802_11.data_rate = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate = cv_hdr.rate | (cv_hdr.direction << 8); - phdr->pseudo_header.ieee_802_11.has_signal_percent = TRUE; - phdr->pseudo_header.ieee_802_11.signal_percent = cv_hdr.signal_level_percent; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent = cv_hdr.signal_level_percent; /* * XXX - these are positive in captures I've seen; does @@ -239,17 +239,17 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * value is provided. */ if (cv_hdr.signal_level_dbm != 0) { - phdr->pseudo_header.ieee_802_11.signal_dbm = -cv_hdr.signal_level_dbm; - phdr->pseudo_header.ieee_802_11.has_signal_dbm = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_dbm = -cv_hdr.signal_level_dbm; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_dbm = TRUE; } if (cv_hdr.noise_level != 0) { - phdr->pseudo_header.ieee_802_11.noise_dbm = -cv_hdr.noise_level; - phdr->pseudo_header.ieee_802_11.has_noise_dbm = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.noise_dbm = -cv_hdr.noise_level; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_noise_dbm = TRUE; } break; case MEDIUM_TOKEN_RING : - phdr->pkt_encap = WTAP_ENCAP_TOKEN_RING; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_TOKEN_RING; break; default : @@ -267,16 +267,16 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, tm.tm_sec = cv_hdr.seconds; tm.tm_isdst = -1; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; - phdr->len = cv_hdr.data_len; - phdr->caplen = cv_hdr.data_len; + rec->rec_header.packet_header.len = cv_hdr.data_len; + rec->rec_header.packet_header.caplen = cv_hdr.data_len; - phdr->ts.secs = mktime(&tm); - phdr->ts.nsecs = cv_hdr.usecs * 1000; + rec->ts.secs = mktime(&tm); + rec->ts.nsecs = cv_hdr.usecs * 1000; - return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info); + return wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info); } static gboolean @@ -284,18 +284,18 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - return commview_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, + return commview_read_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean -commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +commview_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return commview_read_packet(wth->random_fh, phdr, buf, err, err_info); + return commview_read_packet(wth->random_fh, rec, buf, err, err_info); } static gboolean @@ -381,14 +381,14 @@ gboolean commview_dump_open(wtap_dumper *wdh, int *err _U_) /* Write a record for a packet to a dump file. * Returns TRUE on success, FALSE on failure. */ static gboolean commview_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { commview_header_t cv_hdr; struct tm *tm; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -396,18 +396,18 @@ static gboolean commview_dump(wtap_dumper *wdh, /* Don't write out anything bigger than we can read. * (The length field in packet headers is 16 bits, which * imposes a hard limit.) */ - if (phdr->caplen > 65535) { + if (rec->rec_header.packet_header.caplen > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } memset(&cv_hdr, 0, sizeof(cv_hdr)); - cv_hdr.data_len = GUINT16_TO_LE((guint16)phdr->caplen); - cv_hdr.source_data_len = GUINT16_TO_LE((guint16)phdr->caplen); + cv_hdr.data_len = GUINT16_TO_LE((guint16)rec->rec_header.packet_header.caplen); + cv_hdr.source_data_len = GUINT16_TO_LE((guint16)rec->rec_header.packet_header.caplen); cv_hdr.version = 0; - tm = localtime(&phdr->ts.secs); + tm = localtime(&rec->ts.secs); if (tm != NULL) { cv_hdr.year = tm->tm_year + 1900; cv_hdr.month = tm->tm_mon + 1; @@ -415,7 +415,7 @@ static gboolean commview_dump(wtap_dumper *wdh, cv_hdr.hours = tm->tm_hour; cv_hdr.minutes = tm->tm_min; cv_hdr.seconds = tm->tm_sec; - cv_hdr.usecs = GUINT32_TO_LE(phdr->ts.nsecs / 1000); + cv_hdr.usecs = GUINT32_TO_LE(rec->ts.nsecs / 1000); } else { /* * Second before the Epoch. @@ -429,7 +429,7 @@ static gboolean commview_dump(wtap_dumper *wdh, cv_hdr.usecs = 0; } - switch(phdr->pkt_encap) { + switch(rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_ETHERNET : cv_hdr.flags |= MEDIUM_ETHERNET; @@ -442,15 +442,15 @@ static gboolean commview_dump(wtap_dumper *wdh, case WTAP_ENCAP_IEEE_802_11_WITH_RADIO : cv_hdr.flags |= MEDIUM_WIFI; - switch (phdr->pseudo_header.ieee_802_11.phy) { + switch (rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy) { case PHDR_802_11_PHY_11A: /* * If we don't know whether it's turbo, say it's * not. */ - if (!phdr->pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type || - phdr->pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type == PHDR_802_11A_TURBO_TYPE_NORMAL) + if (!rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type || + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type == PHDR_802_11A_TURBO_TYPE_NORMAL) cv_hdr.band = BAND_11A; else cv_hdr.band = BAND_11A_TURBO; @@ -465,10 +465,10 @@ static gboolean commview_dump(wtap_dumper *wdh, * If we don't know whether it's Super G, say it's * not. */ - if (!phdr->pseudo_header.ieee_802_11.phy_info.info_11g.has_mode) + if (!rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode) cv_hdr.band = BAND_11G; else { - switch (phdr->pseudo_header.ieee_802_11.phy_info.info_11g.mode) { + switch (rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.mode) { case PHDR_802_11G_MODE_NORMAL: cv_hdr.band = BAND_11G; @@ -489,8 +489,8 @@ static gboolean commview_dump(wtap_dumper *wdh, /* * Pick the band based on the frequency. */ - if (phdr->pseudo_header.ieee_802_11.has_frequency) { - if (phdr->pseudo_header.ieee_802_11.frequency > 2484) { + if (rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_frequency) { + if (rec->rec_header.packet_header.pseudo_header.ieee_802_11.frequency > 2484) { /* 5 GHz band */ cv_hdr.band = BAND_11N_5GHZ; } else { @@ -512,28 +512,28 @@ static gboolean commview_dump(wtap_dumper *wdh, break; } cv_hdr.channel = - phdr->pseudo_header.ieee_802_11.has_channel ? - phdr->pseudo_header.ieee_802_11.channel : + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel ? + rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel : 0; cv_hdr.rate = - phdr->pseudo_header.ieee_802_11.has_data_rate ? - (guint8)(phdr->pseudo_header.ieee_802_11.data_rate & 0xFF) : + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate ? + (guint8)(rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate & 0xFF) : 0; cv_hdr.direction = - phdr->pseudo_header.ieee_802_11.has_data_rate ? - (guint8)((phdr->pseudo_header.ieee_802_11.data_rate >> 8) & 0xFF) : + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate ? + (guint8)((rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate >> 8) & 0xFF) : 0; cv_hdr.signal_level_percent = - phdr->pseudo_header.ieee_802_11.has_signal_percent ? - phdr->pseudo_header.ieee_802_11.signal_percent : + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent ? + rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent : 0; cv_hdr.signal_level_dbm = - phdr->pseudo_header.ieee_802_11.has_signal_dbm ? - -phdr->pseudo_header.ieee_802_11.signal_dbm : + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_dbm ? + -rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_dbm : 0; cv_hdr.noise_level = - phdr->pseudo_header.ieee_802_11.has_noise_dbm ? - -phdr->pseudo_header.ieee_802_11.noise_dbm : + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_noise_dbm ? + -rec->rec_header.packet_header.pseudo_header.ieee_802_11.noise_dbm : 0; break; @@ -584,9 +584,9 @@ static gboolean commview_dump(wtap_dumper *wdh, return FALSE; wdh->bytes_dumped += COMMVIEW_HEADER_SIZE; - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; return TRUE; } 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; } diff --git a/wiretap/csids.c b/wiretap/csids.c index e864161572..05cc35a75d 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -33,9 +33,9 @@ typedef struct { static gboolean csids_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean csids_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 csids_read_packet(FILE_T fh, csids_t *csids, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); struct csids_header { guint32 seconds; /* seconds since epoch */ @@ -130,7 +130,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); - return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer, + return csids_read_packet( wth->fh, csids, &wth->rec, wth->rec_data, err, err_info ); } @@ -138,7 +138,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info, static gboolean csids_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) @@ -148,7 +148,7 @@ csids_seek_read(wtap *wth, if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 ) return FALSE; - if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) { + if( !csids_read_packet( wth->random_fh, csids, rec, buf, err, err_info ) ) { if( *err == 0 ) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -157,7 +157,7 @@ csids_seek_read(wtap *wth, } static gboolean -csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr, +csids_read_packet(FILE_T fh, csids_t *csids, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct csids_header hdr; @@ -173,23 +173,23 @@ csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr, * it. */ - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->len = hdr.caplen; - phdr->caplen = hdr.caplen; - phdr->ts.secs = hdr.seconds; - phdr->ts.nsecs = 0; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->rec_header.packet_header.len = hdr.caplen; + rec->rec_header.packet_header.caplen = hdr.caplen; + rec->ts.secs = hdr.seconds; + rec->ts.nsecs = 0; - if( !wtap_read_packet_bytes( fh, buf, phdr->caplen, err, err_info ) ) + if( !wtap_read_packet_bytes( fh, buf, rec->rec_header.packet_header.caplen, err, err_info ) ) return FALSE; pd = ws_buffer_start_ptr( buf ); if( csids->byteswapped ) { - if( phdr->caplen >= 2 ) { + if( rec->rec_header.packet_header.caplen >= 2 ) { PBSWAP16(pd); /* the ip len */ - if( phdr->caplen >= 4 ) { + if( rec->rec_header.packet_header.caplen >= 4 ) { PBSWAP16(pd+2); /* ip id */ - if( phdr->caplen >= 6 ) + if( rec->rec_header.packet_header.caplen >= 6 ) PBSWAP16(pd+4); /* ip flags and fragoff */ } } diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c index 853e3e4134..fd9393f9c3 100644 --- a/wiretap/daintree-sna.c +++ b/wiretap/daintree-sna.c @@ -61,9 +61,9 @@ static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean daintree_sna_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 daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); /* Open a file and determine if it's a Daintree file */ @@ -114,21 +114,21 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) *data_offset = file_tell(wth->fh); /* parse that line and the following packet data */ - return daintree_sna_read_packet(wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + return daintree_sna_read_packet(wth->fh, &wth->rec, + wth->rec_data, err, err_info); } /* Read the capture file randomly * Wireshark opens the capture file for random access when displaying user-selected packets */ static gboolean -daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +daintree_sna_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* parse that line and the following packet data */ - return daintree_sna_read_packet(wth->random_fh, phdr, buf, err, + return daintree_sna_read_packet(wth->random_fh, rec, buf, err, err_info); } @@ -137,7 +137,7 @@ daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, * sanity-check its length against what we assume is the packet length field, * and copy it into a Buffer. */ static gboolean -daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint64 seconds; @@ -157,27 +157,27 @@ daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, } } while (readLine[0] == COMMENT_LINE); - 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; if (sscanf(readLine, "%*s %18" G_GINT64_MODIFIER "u.%9d %9u %" READDATA_MAX_FIELD_SIZE "s", - &seconds, &useconds, &phdr->len, readData) != 4) { + &seconds, &useconds, &rec->rec_header.packet_header.len, readData) != 4) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("daintree_sna: invalid read record"); return FALSE; } /* Daintree doesn't store the FCS, but pads end of packet with 0xffff, which we toss */ - if (phdr->len <= FCS_LENGTH) { + if (rec->rec_header.packet_header.len <= FCS_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("daintree_sna: packet length <= %u bytes, no frame data present", FCS_LENGTH); return FALSE; } - phdr->len -= FCS_LENGTH; + rec->rec_header.packet_header.len -= FCS_LENGTH; - phdr->ts.secs = (time_t) seconds; - phdr->ts.nsecs = useconds * 1000; /* convert mS to nS */ + rec->ts.secs = (time_t) seconds; + rec->ts.nsecs = useconds * 1000; /* convert mS to nS */ /* * READDATA_BUF_SIZE is < WTAP_MAX_PACKET_SIZE_STANDARD, and is the maximum @@ -227,14 +227,14 @@ daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } bytes -= FCS_LENGTH; - if (bytes > phdr->len) { + if (bytes > rec->rec_header.packet_header.len) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("daintree_sna: capture length (%u) > packet length (%u)", - bytes, phdr->len); + bytes, rec->rec_header.packet_header.len); return FALSE; } - phdr->caplen = bytes; + rec->rec_header.packet_header.caplen = bytes; ws_buffer_assure_space(buf, bytes); memcpy(ws_buffer_start_ptr(buf), readData, bytes); diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 8e33b7cf43..bca6bfa8cc 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -73,8 +73,8 @@ static const char dbs_etherwatch_rec_magic[] = static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static gboolean parse_dbs_etherwatch_packet(wtap_rec *rec, FILE_T fh, Buffer* buf, int *err, gchar **err_info); static guint parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset); @@ -194,19 +194,19 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, *data_offset = offset; /* Parse the packet */ - return parse_dbs_etherwatch_packet(&wth->phdr, wth->fh, - wth->frame_buffer, err, err_info); + return parse_dbs_etherwatch_packet(&wth->rec, wth->fh, + wth->rec_data, err, err_info); } /* Used to read packets in random-access fashion */ static gboolean dbs_etherwatch_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) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err, + return parse_dbs_etherwatch_packet(rec, wth->random_fh, buf, err, err_info); } @@ -255,7 +255,7 @@ unnumbered. Unnumbered has length 1, numbered 2. #define CTL_UNNUMB_MASK 0x03 #define CTL_UNNUMB_VALUE 0x03 static gboolean -parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, +parse_dbs_etherwatch_packet(wtap_rec *rec, FILE_T fh, Buffer* buf, int *err, gchar **err_info) { guint8 *pd; @@ -423,8 +423,8 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, pd[length_pos+1] = (length) & 0xFF; } - 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; p = strstr(months, mon); if (p) @@ -432,12 +432,12 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, tm.tm_year -= 1900; tm.tm_isdst = -1; - phdr->ts.secs = mktime(&tm); - phdr->ts.nsecs = csec * 10000000; - phdr->caplen = eth_hdr_len + pkt_len; - phdr->len = eth_hdr_len + pkt_len; + rec->ts.secs = mktime(&tm); + rec->ts.nsecs = csec * 10000000; + rec->rec_header.packet_header.caplen = eth_hdr_len + pkt_len; + rec->rec_header.packet_header.len = eth_hdr_len + pkt_len; - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; return an error, * so that our caller doesn't blow up trying to allocate @@ -445,18 +445,18 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dbs_etherwatch: File has %u-byte packet, bigger than maximum of %u", - phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD); + rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } /* Make sure we have enough room, even for an oversized Ethernet packet */ - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen); pd = ws_buffer_start_ptr(buf); /* * We don't have an FCS in this frame. */ - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; /* Parse the hex dump */ count = 0; diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c index 4996d15327..2481f9f61f 100644 --- a/wiretap/dct3trace.c +++ b/wiretap/dct3trace.c @@ -62,7 +62,7 @@ static const char dct3trace_magic_end[] = "</dump>"; static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean dct3trace_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); /* * Following 3 functions taken from gsmdecode-0.7bis, with permission - http://wiki.thc.org/gsm @@ -211,7 +211,7 @@ wtap_open_return_val dct3trace_open(wtap *wth, int *err, gchar **err_info) } -static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean dct3trace_get_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { char line[1024]; @@ -234,18 +234,18 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, if( have_data ) { /* We've got a full packet! */ - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = 0; /* no time stamp, no separate "on the wire" length */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; - phdr->caplen = len; - phdr->len = len; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = 0; /* no time stamp, no separate "on the wire" length */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; + rec->rec_header.packet_header.caplen = len; + rec->rec_header.packet_header.len = len; *err = 0; /* Make sure we have enough room for the packet */ - ws_buffer_assure_space(buf, phdr->caplen); - memcpy( ws_buffer_start_ptr(buf), databuf, phdr->caplen ); + ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen); + memcpy( ws_buffer_start_ptr(buf), databuf, rec->rec_header.packet_header.caplen ); return TRUE; } @@ -263,38 +263,38 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, int channel, tmp; char *ptr; - phdr->pseudo_header.gsm_um.uplink = !strstr(line, "direction=\"down\""); + rec->rec_header.packet_header.pseudo_header.gsm_um.uplink = !strstr(line, "direction=\"down\""); if (!xml_get_int(&channel, line, "logicalchannel", err, err_info)) return FALSE; /* Parse downlink only fields */ - if( !phdr->pseudo_header.gsm_um.uplink ) + if( !rec->rec_header.packet_header.pseudo_header.gsm_um.uplink ) { if (!xml_get_int(&tmp, line, "physicalchannel", err, err_info)) return FALSE; - phdr->pseudo_header.gsm_um.arfcn = tmp; + rec->rec_header.packet_header.pseudo_header.gsm_um.arfcn = tmp; if (!xml_get_int(&tmp, line, "sequence", err, err_info)) return FALSE; - phdr->pseudo_header.gsm_um.tdma_frame = tmp; + rec->rec_header.packet_header.pseudo_header.gsm_um.tdma_frame = tmp; if (!xml_get_int(&tmp, line, "bsic", err, err_info)) return FALSE; - phdr->pseudo_header.gsm_um.bsic = tmp; + rec->rec_header.packet_header.pseudo_header.gsm_um.bsic = tmp; if (!xml_get_int(&tmp, line, "error", err, err_info)) return FALSE; - phdr->pseudo_header.gsm_um.error = tmp; + rec->rec_header.packet_header.pseudo_header.gsm_um.error = tmp; if (!xml_get_int(&tmp, line, "timeshift", err, err_info)) return FALSE; - phdr->pseudo_header.gsm_um.timeshift = tmp; + rec->rec_header.packet_header.pseudo_header.gsm_um.timeshift = tmp; } switch( channel ) { - case 128: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SDCCH; break; - case 112: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SACCH; break; - case 176: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_FACCH; break; - case 96: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_CCCH; break; - case 80: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_BCCH; break; - default: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_UNKNOWN; break; + case 128: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SDCCH; break; + case 112: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SACCH; break; + case 176: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_FACCH; break; + case 96: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_CCCH; break; + case 80: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_BCCH; break; + default: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_UNKNOWN; break; } /* Read data (if have it) into databuf */ @@ -306,7 +306,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, if (len == -1) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen); + *err_info = g_strdup_printf("dct3trace: record length %d too long", rec->rec_header.packet_header.caplen); return FALSE; } } @@ -329,7 +329,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, * We know we have no data already, so we know * we have enough room for the header. */ - if( phdr->pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SACCH || phdr->pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_FACCH || phdr->pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SDCCH ) + if( rec->rec_header.packet_header.pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SACCH || rec->rec_header.packet_header.pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_FACCH || rec->rec_header.packet_header.pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SDCCH ) { /* Add LAPDm B header */ memset(bufp, 0x1, 2); @@ -346,7 +346,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, if (data_len == -1) { *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen); + *err_info = g_strdup_printf("dct3trace: record length %d too long", rec->rec_header.packet_header.caplen); return FALSE; } len += data_len; @@ -371,21 +371,21 @@ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, { *data_offset = file_tell(wth->fh); - return dct3trace_get_packet(wth->fh, &wth->phdr, wth->frame_buffer, + return dct3trace_get_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info); } /* Used to read packets in random-access fashion */ static gboolean dct3trace_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { return FALSE; } - return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info); + return dct3trace_get_packet(wth->random_fh, rec, buf, err, err_info); } /* diff --git a/wiretap/erf.c b/wiretap/erf.c index 91b7a892ff..590179752a 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -70,7 +70,7 @@ static const guint erf_eth_hdr_size = (guint)sizeof(erf_eth_header_t); static gboolean erf_read_header(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, + wtap_rec *rec, erf_header_t *erf_header, int *err, gchar **err_info, @@ -80,12 +80,12 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, static gboolean erf_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean erf_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static void erf_close(wtap *wth); static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header *pseudo_header, guint32 packet_size, GPtrArray *anchor_mappings_to_update); -static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update); +static int erf_update_anchors_from_header(erf_t *erf_priv, wtap_rec *rec, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update); typedef struct { gboolean write_next_extra_meta; @@ -590,14 +590,14 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info, do { if (!erf_read_header(wth, wth->fh, - &wth->phdr, &erf_header, + &wth->rec, &erf_header, err, err_info, &bytes_read, &packet_size, anchor_mappings_to_update)) { g_ptr_array_free(anchor_mappings_to_update, TRUE); return FALSE; } - if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size, + if (!wtap_read_packet_bytes(wth->fh, wth->rec_data, packet_size, err, err_info)) { g_ptr_array_free(anchor_mappings_to_update, TRUE); return FALSE; @@ -610,7 +610,7 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info, */ if ((erf_header.type & 0x7F) == ERF_TYPE_META && packet_size > 0) { - populate_summary_info((erf_t*) wth->priv, wth, &wth->phdr.pseudo_header, packet_size, anchor_mappings_to_update); + populate_summary_info((erf_t*) wth->priv, wth, &wth->rec.rec_header.packet_header.pseudo_header, packet_size, anchor_mappings_to_update); } } while ( erf_header.type == ERF_TYPE_PAD ); @@ -621,7 +621,7 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info, } static gboolean erf_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { erf_header_t erf_header; @@ -634,7 +634,7 @@ static gboolean erf_seek_read(wtap *wth, gint64 seek_off, anchor_mappings_to_update = g_ptr_array_new_with_free_func(erf_anchor_mapping_destroy); do { - if (!erf_read_header(wth, wth->random_fh, phdr, &erf_header, + if (!erf_read_header(wth, wth->random_fh, rec, &erf_header, err, err_info, NULL, &packet_size, anchor_mappings_to_update)) { g_ptr_array_free(anchor_mappings_to_update, TRUE); return FALSE; @@ -667,7 +667,7 @@ static struct erf_anchor_mapping* erf_find_anchor_mapping(erf_t *priv, } static gboolean erf_read_header(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, + wtap_rec *rec, erf_header_t *erf_header, int *err, gchar **err_info, @@ -675,7 +675,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, guint32 *packet_size, GPtrArray *anchor_mappings_to_update) { - union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; guint8 erf_exhdr[8]; guint64 erf_exhdr_sw; guint8 type = 0; @@ -726,7 +726,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, guint64 ts = pletoh64(&erf_header->ts); /*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != WTAP_FILE_TYPE_SUBTYPE_ERF) {*/ - phdr->rec_type = REC_TYPE_PACKET; + rec->rec_type = REC_TYPE_PACKET; /* * XXX: ERF_TYPE_META records should ideally be FT_SPECIFIC for display * purposes, but currently ft_specific_record_phdr clashes with erf_mc_phdr @@ -743,18 +743,18 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, * chosen by wth->file_type_subtype? */ /* For now just treat all Provenance records as reports */ - phdr->rec_type = REC_TYPE_FT_SPECIFIC_REPORT; + rec->rec_type = REC_TYPE_FT_SPECIFIC_REPORT; /* XXX: phdr ft_specific_record_phdr? */ } #endif - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; - phdr->ts.secs = (long) (ts >> 32); + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; + rec->ts.secs = (long) (ts >> 32); ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000); ts += (ts & 0x80000000) << 1; /* rounding */ - phdr->ts.nsecs = ((int) (ts >> 32)); - if (phdr->ts.nsecs >= 1000000000) { - phdr->ts.nsecs -= 1000000000; - phdr->ts.secs += 1; + rec->ts.nsecs = ((int) (ts >> 32)); + if (rec->ts.nsecs >= 1000000000) { + rec->ts.nsecs -= 1000000000; + rec->ts.secs += 1; } if_num = erf_header->flags & 0x03; @@ -808,10 +808,10 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, } /* XXX: erf_priv pointer needs to change if used as common function for other dissectors! */ - phdr->interface_id = (guint) erf_populate_interface((erf_t*) wth->priv, wth, pseudo_header, host_id, source_id, if_num); + rec->rec_header.packet_header.interface_id = (guint) erf_populate_interface((erf_t*) wth->priv, wth, pseudo_header, host_id, source_id, if_num); /* Try to find comment links using Anchor ID. Done here after we found the first Host ID and have updated the implicit Host ID. */ - erf_update_anchors_from_header(priv, phdr, pseudo_header, host_id, anchor_mappings_to_update); + erf_update_anchors_from_header(priv, rec, pseudo_header, host_id, anchor_mappings_to_update); switch (erf_header->type & 0x7F) { case ERF_TYPE_IPV4: @@ -824,8 +824,8 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, case ERF_TYPE_OPA_9B: #if 0 { - phdr->len = g_htons(erf_header->wlen); - phdr->caplen = g_htons(erf_header->wlen); + rec->rec_header.packet_header.len = g_htons(erf_header->wlen); + rec->rec_header.packet_header.caplen = g_htons(erf_header->wlen); } return TRUE; #endif @@ -887,8 +887,8 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, } { - phdr->len = g_ntohs(erf_header->wlen); - phdr->caplen = MIN( g_ntohs(erf_header->wlen), + rec->rec_header.packet_header.len = g_ntohs(erf_header->wlen); + rec->rec_header.packet_header.caplen = MIN( g_ntohs(erf_header->wlen), g_ntohs(erf_header->rlen) - (guint32)sizeof(*erf_header) - skiplen ); } @@ -1467,7 +1467,7 @@ static gboolean erf_update_host_id_ext_hdrs_list(erf_dump_t *dump_priv, const un * @param err the error value * @return A gboolean value to indicate whether the dump was successful */ -static gboolean erf_write_anchor_meta_update_phdr(wtap_dumper *wdh, erf_dump_t *dump_priv, const struct wtap_pkthdr *phdr, union wtap_pseudo_header *mutable_hdr, int *err) { +static gboolean erf_write_anchor_meta_update_phdr(wtap_dumper *wdh, erf_dump_t *dump_priv, const wtap_rec *rec, union wtap_pseudo_header *mutable_hdr, int *err) { GArray *meta_ehdrs; GPtrArray* sections = NULL; guint8 has_more; @@ -1651,7 +1651,7 @@ static gboolean erf_write_anchor_meta_update_phdr(wtap_dumper *wdh, erf_dump_t * /* Generate the metadata payload with the packet comment */ sections = g_ptr_array_new_with_free_func(erf_meta_section_free); - erf_comment_to_sections(wdh, ERF_META_SECTION_INFO, 0x8000 /*local to record*/, phdr->opt_comment, sections); + erf_comment_to_sections(wdh, ERF_META_SECTION_INFO, 0x8000 /*local to record*/, rec->opt_comment, sections); /* Write the metadata record, but not the packet record as what we do depends * on the WTAP_ENCAP */ @@ -1770,12 +1770,12 @@ erf_dump_t *erf_dump_priv_create(void) { static gboolean erf_dump( wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; union wtap_pseudo_header other_phdr; int encap; int erf_type; @@ -1790,20 +1790,20 @@ static gboolean erf_dump( guint64 non_erf_host_id_ehdr = erf_host_id_ext_hdr(0, 1); /* Don't write anything bigger than we're willing to read. */ - if(phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if(rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } if(wdh->encap == WTAP_ENCAP_PER_PACKET){ - encap = phdr->pkt_encap; + encap = rec->rec_header.packet_header.pkt_encap; }else{ encap = wdh->encap; } if(!dump_priv->gen_time) { erf_dump_priv_init_gen_time(dump_priv); - dump_priv->first_frame_time_sec = phdr->ts.secs; + dump_priv->first_frame_time_sec = rec->ts.secs; } if (encap != WTAP_ENCAP_ERF) { @@ -1812,11 +1812,11 @@ static gboolean erf_dump( /*Non-ERF*/ - total_rlen = phdr->caplen+16; - total_wlen = phdr->len; + total_rlen = rec->rec_header.packet_header.caplen+16; + total_wlen = rec->rec_header.packet_header.len; /* We can only convert packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -1829,11 +1829,11 @@ static gboolean erf_dump( /* Generate a fake header in other_phdr using data that we know*/ memset(&other_phdr, 0, sizeof(union wtap_pseudo_header)); /* Convert time erf timestamp format*/ - other_phdr.erf.phdr.ts = ((guint64) phdr->ts.secs << 32) + (((guint64) phdr->ts.nsecs <<32) / 1000 / 1000 / 1000); + other_phdr.erf.phdr.ts = ((guint64) rec->ts.secs << 32) + (((guint64) rec->ts.nsecs <<32) / 1000 / 1000 / 1000); other_phdr.erf.phdr.type = (guint8)erf_type; /* Support up to 4 interfaces */ /* TODO: use multiple Source IDs and metadata records to support >4 interfaces */ - other_phdr.erf.phdr.flags = phdr->interface_id % ERF_MAX_INTERFACES; + other_phdr.erf.phdr.flags = rec->rec_header.packet_header.interface_id % ERF_MAX_INTERFACES; other_phdr.erf.phdr.flags |= 0x4; /*vlen flag set because we're creating variable length records*/ other_phdr.erf.phdr.lctr = 0; @@ -1847,8 +1847,8 @@ static gboolean erf_dump( (pseudo_header->eth.fcs_len = 0), or we don't know whether it has an FCS (= -1). We have to synthesize an FCS.*/ - if(!(phdr->caplen < phdr->len)){ /*don't add FCS if packet has been snapped off*/ - crc32 = crc32_ccitt_seed(pd, phdr->caplen, 0xFFFFFFFF); + if(!(rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len)){ /*don't add FCS if packet has been snapped off*/ + crc32 = crc32_ccitt_seed(pd, rec->rec_header.packet_header.caplen, 0xFFFFFFFF); total_rlen += 4; /*4 bytes for added checksum*/ total_wlen += 4; must_add_crc = TRUE; @@ -1857,8 +1857,8 @@ static gboolean erf_dump( break; case ERF_TYPE_HDLC_POS: /*we assume that it's missing a FCS checksum, make one up*/ - if(!(phdr->caplen < phdr->len)){ /*unless of course, the packet has been snapped off*/ - crc32 = crc32_ccitt_seed(pd, phdr->caplen, 0xFFFFFFFF); + if(!(rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len)){ /*unless of course, the packet has been snapped off*/ + crc32 = crc32_ccitt_seed(pd, rec->rec_header.packet_header.caplen, 0xFFFFFFFF); total_rlen += 4; /*4 bytes for added checksum*/ total_wlen += 4; must_add_crc = TRUE; /* XXX - these never have an FCS? */ @@ -1874,7 +1874,7 @@ static gboolean erf_dump( total_rlen += 8; padbytes = ERF_PADDING_TO_8(total_rlen); /*calculate how much padding will be required */ - if(phdr->caplen < phdr->len){ /*if packet has been snapped, we need to round down what we output*/ + if(rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len){ /*if packet has been snapped, we need to round down what we output*/ round_down = (8 - padbytes) % 8; total_rlen -= round_down; }else{ @@ -1921,7 +1921,7 @@ static gboolean erf_dump( } if (!erf_write_meta_record(wdh, dump_priv, dump_priv->prev_frame_ts, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE; - dump_priv->prev_inserted_time_sec = phdr->ts.secs; + dump_priv->prev_inserted_time_sec = rec->ts.secs; /*TODO: clear accumulated existing extension headers here?*/ } @@ -1932,8 +1932,8 @@ static gboolean erf_dump( * read. */ /* restart searching for next meta record to update capture comment at */ dump_priv->write_next_extra_meta = FALSE; - } else if (phdr->ts.secs > dump_priv->first_frame_time_sec + 1 - && dump_priv->prev_inserted_time_sec != phdr->ts.secs) { + } else if (rec->ts.secs > dump_priv->first_frame_time_sec + 1 + && dump_priv->prev_inserted_time_sec != rec->ts.secs) { /* For compatibility, don't insert metadata for older ERF files with no changed metadata */ if (dump_priv->write_next_extra_meta) { if (!dump_priv->periodic_sections) { @@ -1949,8 +1949,8 @@ static gboolean erf_dump( /* At second boundaries insert either the updated comment (if we've seen some metadata records * already) or the full metadata */ if (dump_priv->periodic_sections) { - if (!erf_write_meta_record(wdh, dump_priv, (guint64)(phdr->ts.secs) << 32, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE; - dump_priv->prev_inserted_time_sec = phdr->ts.secs; + if (!erf_write_meta_record(wdh, dump_priv, (guint64)(rec->ts.secs) << 32, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE; + dump_priv->prev_inserted_time_sec = rec->ts.secs; } } } @@ -1959,18 +1959,18 @@ static gboolean erf_dump( * construct a new header with additional Host ID and Anchor ID * and insert a metadata record before that frame */ /*XXX: The user may have changed the comment to cleared! */ - if(phdr->opt_comment || phdr->has_comment_changed) { + if(rec->opt_comment || rec->has_comment_changed) { if (encap == WTAP_ENCAP_ERF) { /* XXX: What about ERF-in-pcapng with existing comment (that wasn't * modified)? */ - if(phdr->has_comment_changed) { + if(rec->has_comment_changed) { memcpy(&other_phdr, pseudo_header, sizeof(union wtap_pseudo_header)); - if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, phdr, &other_phdr, err)) return FALSE; + if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, rec, &other_phdr, err)) return FALSE; pseudo_header = &other_phdr; } } else { /* Always write the comment if non-ERF */ - if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, phdr, &other_phdr, err)) return FALSE; + if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, rec, &other_phdr, err)) return FALSE; } } @@ -1979,8 +1979,8 @@ static gboolean erf_dump( if(!erf_write_phdr(wdh, WTAP_ENCAP_ERF, pseudo_header, err)) return FALSE; - if(!wtap_dump_file_write(wdh, pd, phdr->caplen - round_down, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen - round_down; + if(!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen - round_down, err)) return FALSE; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen - round_down; /*add the 4 byte CRC if necessary*/ if(must_add_crc){ @@ -2203,7 +2203,7 @@ static void erf_set_interface_descr(wtap_block_t block, guint option_id, guint64 } } -static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update) +static int erf_update_anchors_from_header(erf_t *erf_priv, wtap_rec *rec, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update) { guint8 type; guint8 has_more; @@ -2214,7 +2214,7 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *p int i = 0; gchar *comment = NULL; - if (!phdr || !pseudo_header) + if (!rec || !pseudo_header) return -1; /* Start with the first Host ID that was found on the record @@ -2279,8 +2279,8 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *p } if (comment) { - phdr->opt_comment = g_strdup(comment); - phdr->presence_flags |= WTAP_HAS_COMMENTS; + rec->opt_comment = g_strdup(comment); + rec->presence_flags |= WTAP_HAS_COMMENTS; } else { /* WTAP_HAS_COMMENT has no visible effect? * Need to set opt_comment to NULL to prevent other packets @@ -2288,7 +2288,7 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *p */ /* XXX: We cannot free the old comment because it can be for a different * frame and still in use, wiretap should be handling this better! */ - phdr->opt_comment = NULL; + rec->opt_comment = NULL; } return 0; @@ -3175,7 +3175,7 @@ static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_h } - state.tag_ptr = wth->frame_buffer->data; + state.tag_ptr = wth->rec_data->data; state.remaining_len = packet_size; /* Read until see next section tag */ diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index e2e92b596c..1a4cc73f5e 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -88,8 +88,8 @@ static const unsigned char eyesdn_hdr_magic[] = static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static int read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer* buf, int *err, gchar **err_info); /* Seeks to the beginning of the next packet, and returns the @@ -152,27 +152,27 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, *data_offset = offset; /* Parse the record */ - return read_eyesdn_rec(wth->fh, &wth->phdr, wth->frame_buffer, + return read_eyesdn_rec(wth->fh, &wth->rec, wth->rec_data, err, err_info); } /* Used to read packets in random-access fashion */ static gboolean -eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +eyesdn_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info); + return read_eyesdn_rec(wth->random_fh, rec, buf, err, err_info); } /* Parses a record. */ static gboolean -read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, +read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer *buf, 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; guint8 hdr[EYESDN_HDR_LENGTH]; time_t secs; int usecs; @@ -210,20 +210,20 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; if(channel) { /* bearer channels */ - phdr->pkt_encap = WTAP_ENCAP_ISDN; /* recognises PPP */ + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; /* recognises PPP */ pseudo_header->isdn.uton=!pseudo_header->isdn.uton; /* bug */ } else { /* D channel */ - phdr->pkt_encap = WTAP_ENCAP_ISDN; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; } break; case EYESDN_ENCAP_MSG: /* Layer 1 message */ - phdr->pkt_encap = WTAP_ENCAP_LAYER1_EVENT; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LAYER1_EVENT; pseudo_header->l1event.uton = (direction & 1); break; case EYESDN_ENCAP_LAPB: /* X.25 via LAPB */ - phdr->pkt_encap = WTAP_ENCAP_LAPB; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LAPB; pseudo_header->x25.flags = (direction & 1) ? 0 : 0x80; break; @@ -245,7 +245,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, return FALSE; if (file_seek(fh, cur_off, SEEK_SET, err) == -1) return FALSE; - phdr->pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; pseudo_header->atm.flags=ATM_RAW_CELL; pseudo_header->atm.aal=AAL_UNKNOWN; pseudo_header->atm.type=TRAF_UMTS_FP; @@ -260,31 +260,31 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, pseudo_header->mtp2.sent = direction & 1; pseudo_header->mtp2.annex_a_used = MTP2_ANNEX_A_USED_UNKNOWN; pseudo_header->mtp2.link_number = channel; - phdr->pkt_encap = WTAP_ENCAP_MTP2_WITH_PHDR; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_MTP2_WITH_PHDR; break; case EYESDN_ENCAP_DPNSS: /* DPNSS */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - phdr->pkt_encap = WTAP_ENCAP_DPNSS; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DPNSS; break; case EYESDN_ENCAP_DASS2: /* DASS2 frames */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - phdr->pkt_encap = WTAP_ENCAP_DPNSS; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DPNSS; break; case EYESDN_ENCAP_BACNET: /* BACNET async over HDLC frames */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - phdr->pkt_encap = WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR; break; case EYESDN_ENCAP_V5_EF: /* V5EF */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - phdr->pkt_encap = WTAP_ENCAP_V5_EF; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_V5_EF; break; } @@ -295,12 +295,12 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = secs; - phdr->ts.nsecs = usecs * 1000; - phdr->caplen = pkt_len; - phdr->len = pkt_len; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = secs; + rec->ts.nsecs = usecs * 1000; + rec->rec_header.packet_header.caplen = pkt_len; + rec->rec_header.packet_header.len = pkt_len; /* Make sure we have enough room for the packet */ ws_buffer_assure_space(buf, pkt_len); @@ -336,7 +336,7 @@ esc_write(wtap_dumper *wdh, const guint8 *buf, int len, int *err) } static gboolean eyesdn_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err) @@ -372,11 +372,11 @@ int eyesdn_dump_can_write_encap(int encap) /* Write a record for a packet to a dump file. * Returns TRUE on success, FALSE on failure. */ static gboolean eyesdn_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { static const guint8 start_flag = 0xff; - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; guint8 buf[EYESDN_HDR_LENGTH]; int usecs; time_t secs; @@ -386,7 +386,7 @@ static gboolean eyesdn_dump(wtap_dumper *wdh, int size; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -394,18 +394,18 @@ static gboolean eyesdn_dump(wtap_dumper *wdh, /* Don't write out anything bigger than we can read. * (The length field in packet headers is 16 bits, which * imposes a hard limit.) */ - if (phdr->caplen > 65535) { + if (rec->rec_header.packet_header.caplen > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - usecs=phdr->ts.nsecs/1000; - secs=phdr->ts.secs; - size=phdr->caplen; + usecs=rec->ts.nsecs/1000; + secs=rec->ts.secs; + size=rec->rec_header.packet_header.caplen; origin = pseudo_header->isdn.uton; channel = pseudo_header->isdn.channel; - switch(phdr->pkt_encap) { + switch(rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_ISDN: protocol=EYESDN_ENCAP_ISDN; /* set depending on decoder format and mode */ diff --git a/wiretap/file_access.c b/wiretap/file_access.c index c45270b971..2fd0c2e240 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -1096,8 +1096,8 @@ fail: return NULL; success: - wth->frame_buffer = (struct Buffer *)g_malloc(sizeof(struct Buffer)); - ws_buffer_init(wth->frame_buffer, 1500); + wth->rec_data = (struct Buffer *)g_malloc(sizeof(struct Buffer)); + ws_buffer_init(wth->rec_data, 1500); if ((wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP) || (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC)) { @@ -2538,12 +2538,12 @@ wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compress } gboolean -wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +wtap_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info) { *err = 0; *err_info = NULL; - return (wdh->subtype_write)(wdh, phdr, pd, err, err_info); + return (wdh->subtype_write)(wdh, rec, pd, err, err_info); } void diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index d0aad8f9f1..683da1d80a 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -21,7 +21,7 @@ struct dump_hdr { #define DUMP_HDR_SIZE (sizeof(struct dump_hdr)) -static gboolean hcidump_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean hcidump_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct dump_hdr dh; @@ -42,14 +42,14 @@ static gboolean hcidump_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = GUINT32_FROM_LE(dh.ts_sec); - phdr->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000; - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = GUINT32_FROM_LE(dh.ts_sec); + rec->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; - phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE); + rec->rec_header.packet_header.pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE); return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } @@ -59,17 +59,17 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info, { *data_offset = file_tell(wth->fh); - return hcidump_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, + return hcidump_read_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean hcidump_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return hcidump_read_packet(wth->random_fh, phdr, buf, err, err_info); + return hcidump_read_packet(wth->random_fh, rec, buf, err, err_info); } wtap_open_return_val hcidump_open(wtap *wth, int *err, gchar **err_info) diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 52d4faa8c3..78d50c2e27 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -23,8 +23,8 @@ typedef struct { static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static int i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); /* @@ -98,18 +98,18 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, { *data_offset = file_tell(wth->fh); - return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, + return i4b_read_rec(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean -i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +i4btrace_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) { + if (!i4b_read_rec(wth, wth->random_fh, rec, buf, err, err_info)) { /* Read error or EOF */ if (*err == 0) { /* EOF means "short read" in random-access mode */ @@ -121,7 +121,7 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, } static gboolean -i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { i4btrace_t *i4btrace = (i4btrace_t *)wth->priv; @@ -163,14 +163,14 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; - phdr->len = length; - phdr->caplen = length; + rec->rec_header.packet_header.len = length; + rec->rec_header.packet_header.caplen = length; - phdr->ts.secs = hdr.ts_sec; - phdr->ts.nsecs = hdr.ts_usec * 1000; + rec->ts.secs = hdr.ts_sec; + rec->ts.nsecs = hdr.ts_usec * 1000; switch (hdr.type) { @@ -180,35 +180,35 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * as that means it has a 4-byte AF_ type as the * encapsulation header. */ - phdr->pkt_encap = WTAP_ENCAP_NULL; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NULL; break; case TRC_CH_D: /* * D channel, so it's LAPD; set "p2p.sent". */ - phdr->pkt_encap = WTAP_ENCAP_ISDN; - phdr->pseudo_header.isdn.channel = 0; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; + rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; break; case TRC_CH_B1: /* * B channel 1. */ - phdr->pkt_encap = WTAP_ENCAP_ISDN; - phdr->pseudo_header.isdn.channel = 1; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; + rec->rec_header.packet_header.pseudo_header.isdn.channel = 1; break; case TRC_CH_B2: /* * B channel 2. */ - phdr->pkt_encap = WTAP_ENCAP_ISDN; - phdr->pseudo_header.isdn.channel = 2; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; + rec->rec_header.packet_header.pseudo_header.isdn.channel = 2; break; } - phdr->pseudo_header.isdn.uton = (hdr.dir == FROM_TE); + rec->rec_header.packet_header.pseudo_header.isdn.uton = (hdr.dir == FROM_TE); /* * Read the packet data. diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c index ffb7e86613..dc3778eb4a 100644 --- a/wiretap/ipfix.c +++ b/wiretap/ipfix.c @@ -70,7 +70,7 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean ipfix_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); #define IPFIX_VERSION 10 @@ -141,7 +141,7 @@ ipfix_read_message_header(ipfix_message_header_t *pfx_hdr, FILE_T fh, int *err, * errors (EOF is ok, since return value is still FALSE). */ static gboolean -ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +ipfix_read_message(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { ipfix_message_header_t msg_hdr; @@ -153,12 +153,12 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g * to check it. */ - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->len = msg_hdr.message_length; - phdr->caplen = msg_hdr.message_length; - phdr->ts.secs = msg_hdr.export_time_secs; - phdr->ts.nsecs = 0; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->rec_header.packet_header.len = msg_hdr.message_length; + rec->rec_header.packet_header.caplen = msg_hdr.message_length; + rec->ts.secs = msg_hdr.export_time_secs; + rec->ts.nsecs = 0; return wtap_read_packet_bytes(fh, buf, msg_hdr.message_length, err, err_info); } @@ -280,9 +280,10 @@ static gboolean ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - ipfix_debug("ipfix_read: data_offset is initially %" G_GINT64_MODIFIER "d", *data_offset); + ipfix_debug("ipfix_read: data_offset is initially %" G_GINT64_MODIFIER "d", + wth->rec.rec_header.packet_header.file_offset); - if (!ipfix_read_message(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { + if (!ipfix_read_message(wth->fh, &wth->rec, wth->rec_data, err, err_info)) { ipfix_debug("ipfix_read: couldn't read message header with code: %d\n, and error '%s'", *err, *err_info); return FALSE; @@ -294,7 +295,7 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* classic wtap: seek to file position and read packet */ static gboolean -ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +ipfix_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* seek to the right file position */ @@ -306,7 +307,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, ipfix_debug("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off); - if (!ipfix_read_message(wth->random_fh, phdr, buf, err, err_info)) { + if (!ipfix_read_message(wth->random_fh, rec, buf, err, err_info)) { ipfix_debug("ipfix_seek_read: couldn't read message header"); if (*err == 0) *err = WTAP_ERR_SHORT_READ; diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index b8d9105b98..f385c889cc 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -21,15 +21,15 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean iptrace_seek_read_1_0(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 iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean iptrace_seek_read_2_0(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 iptrace_read_rec_data(FILE_T fh, Buffer *buf, - struct wtap_pkthdr *phdr, int *err, gchar **err_info); + wtap_rec *rec, int *err, gchar **err_info); static void fill_in_pseudo_header(int encap, union wtap_pseudo_header *pseudo_header, guint8 *header); static int wtap_encap_ift(unsigned int ift); @@ -102,7 +102,7 @@ typedef struct { #define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */ static gboolean -iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +iptrace_read_rec_1_0(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint8 header[IPTRACE_1_0_PHDR_SIZE]; @@ -120,8 +120,8 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * <net/if_types.h> header file. */ pkt_hdr.if_type = header[28]; - phdr->pkt_encap = wtap_encap_ift(pkt_hdr.if_type); - if (phdr->pkt_encap == WTAP_ENCAP_UNKNOWN) { + rec->rec_header.packet_header.pkt_encap = wtap_encap_ift(pkt_hdr.if_type); + if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_UNKNOWN) { *err = WTAP_ERR_UNSUPPORTED; *err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported", pkt_hdr.if_type); @@ -146,7 +146,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * AIX appears to put 3 bytes of padding in front of FDDI * frames; strip that crap off. */ - if (phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) { + if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) { /* * The packet size is really a record size and includes * the padding. @@ -180,18 +180,18 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->len = packet_size; - phdr->caplen = packet_size; - phdr->ts.secs = pntoh32(&header[4]); - phdr->ts.nsecs = 0; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->rec_header.packet_header.len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->ts.secs = pntoh32(&header[4]); + rec->ts.nsecs = 0; /* Fill in the pseudo-header. */ - fill_in_pseudo_header(phdr->pkt_encap, &phdr->pseudo_header, header); + fill_in_pseudo_header(rec->rec_header.packet_header.pkt_encap, &rec->rec_header.packet_header.pseudo_header, header); /* Get the packet data */ - return iptrace_read_rec_data(fh, buf, phdr, err, err_info); + return iptrace_read_rec_data(fh, buf, rec, err, err_info); } /* Read the next packet */ @@ -201,7 +201,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read the packet */ - if (!iptrace_read_rec_1_0(wth->fh, &wth->phdr, wth->frame_buffer, + if (!iptrace_read_rec_1_0(wth->fh, &wth->rec, wth->rec_data, err, err_info)) { /* Read error or EOF */ return FALSE; @@ -214,9 +214,9 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, set it to WTAP_ENCAP_PER_PACKET, as this file doesn't 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; } @@ -224,13 +224,13 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, } static gboolean iptrace_seek_read_1_0(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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the packet */ - if (!iptrace_read_rec_1_0(wth->random_fh, phdr, buf, err, err_info)) { + if (!iptrace_read_rec_1_0(wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -277,7 +277,7 @@ typedef struct { #define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */ static gboolean -iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +iptrace_read_rec_2_0(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint8 header[IPTRACE_2_0_PHDR_SIZE]; @@ -295,7 +295,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * <net/if_types.h> header file. */ pkt_hdr.if_type = header[28]; - phdr->pkt_encap = wtap_encap_ift(pkt_hdr.if_type); + rec->rec_header.packet_header.pkt_encap = wtap_encap_ift(pkt_hdr.if_type); #if 0 /* * We used to error out if the interface type in iptrace was @@ -313,7 +313,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * XXX - what types are there that are used in files but * that we don't handle? */ - if (phdr->pkt_encap == WTAP_ENCAP_UNKNOWN) { + if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_UNKNOWN) { *err = WTAP_ERR_UNSUPPORTED; *err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported", pkt_hdr.if_type); @@ -339,7 +339,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * AIX appears to put 3 bytes of padding in front of FDDI * frames; strip that crap off. */ - if (phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) { + if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) { /* * The packet size is really a record size and includes * the padding. @@ -373,18 +373,18 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->len = packet_size; - phdr->caplen = packet_size; - phdr->ts.secs = pntoh32(&header[32]); - phdr->ts.nsecs = pntoh32(&header[36]); + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->rec_header.packet_header.len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->ts.secs = pntoh32(&header[32]); + rec->ts.nsecs = pntoh32(&header[36]); /* Fill in the pseudo_header. */ - fill_in_pseudo_header(phdr->pkt_encap, &phdr->pseudo_header, header); + fill_in_pseudo_header(rec->rec_header.packet_header.pkt_encap, &rec->rec_header.packet_header.pseudo_header, header); /* Get the packet data */ - return iptrace_read_rec_data(fh, buf, phdr, err, err_info); + return iptrace_read_rec_data(fh, buf, rec, err, err_info); } /* Read the next packet */ @@ -394,7 +394,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read the packet */ - if (!iptrace_read_rec_2_0(wth->fh, &wth->phdr, wth->frame_buffer, + if (!iptrace_read_rec_2_0(wth->fh, &wth->rec, wth->rec_data, err, err_info)) { /* Read error or EOF */ return FALSE; @@ -407,9 +407,9 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, set it to WTAP_ENCAP_PER_PACKET, as this file doesn't 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; } @@ -417,13 +417,13 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, } static gboolean iptrace_seek_read_2_0(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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the packet */ - if (!iptrace_read_rec_2_0(wth->random_fh, phdr, buf, err, err_info)) { + if (!iptrace_read_rec_2_0(wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -432,18 +432,18 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off, } static gboolean -iptrace_read_rec_data(FILE_T fh, Buffer *buf, struct wtap_pkthdr *phdr, +iptrace_read_rec_data(FILE_T fh, Buffer *buf, wtap_rec *rec, int *err, gchar **err_info) { - if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info)) + if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info)) return FALSE; - if (phdr->pkt_encap == WTAP_ENCAP_ATM_PDUS) { + if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_ATM_PDUS) { /* * Attempt to guess from the packet data, the VPI, * and the VCI information about the type of traffic. */ - atm_guess_traffic_type(phdr, ws_buffer_start_ptr(buf)); + atm_guess_traffic_type(rec, ws_buffer_start_ptr(buf)); } return TRUE; diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 1e26400b92..84b8ec7557 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -182,13 +182,13 @@ typedef struct { static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset); static gboolean iseries_seek_read (wtap * wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer * buf, int *err, gchar ** err_info); static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format); static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info); static gboolean iseries_parse_packet (wtap * wth, FILE_T fh, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer * buf, int *err, gchar ** err_info); static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes); static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf, @@ -391,7 +391,7 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset) /* * Parse the packet and extract the various fields */ - return iseries_parse_packet (wth, wth->fh, &wth->phdr, wth->frame_buffer, + return iseries_parse_packet (wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } @@ -463,7 +463,7 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info) * Read packets in random-access fashion */ static gboolean -iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr, +iseries_seek_read (wtap * wth, gint64 seek_off, wtap_rec *rec, Buffer * buf, int *err, gchar ** err_info) { @@ -474,7 +474,7 @@ iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr, /* * Parse the packet and extract the various fields */ - return iseries_parse_packet (wth, wth->random_fh, phdr, buf, + return iseries_parse_packet (wth, wth->random_fh, rec, buf, err, err_info); } @@ -575,7 +575,7 @@ csec_multiplier(guint32 csec) /* Parses a packet. */ static gboolean -iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, +iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { iseries_t *iseries = (iseries_t *)wth->priv; @@ -738,8 +738,8 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_CAP_LEN; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_CAP_LEN; /* * If we have Wiretap Header then populate it here @@ -749,7 +749,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, */ if (iseries->have_date) { - phdr->presence_flags |= WTAP_HAS_TS; + rec->presence_flags |= WTAP_HAS_TS; tm.tm_year = 100 + iseries->year; tm.tm_mon = iseries->month - 1; tm.tm_mday = iseries->day; @@ -757,13 +757,13 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, tm.tm_min = min; tm.tm_sec = sec; tm.tm_isdst = -1; - phdr->ts.secs = mktime (&tm); - phdr->ts.nsecs = csec * csec_multiplier(csec); + rec->ts.secs = mktime (&tm); + rec->ts.nsecs = csec * csec_multiplier(csec); } - phdr->len = pkt_len; - phdr->pkt_encap = WTAP_ENCAP_ETHERNET; - phdr->pseudo_header.eth.fcs_len = -1; + rec->rec_header.packet_header.len = pkt_len; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1; /* * Allocate a buffer big enough to hold the claimed packet length @@ -942,10 +942,10 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, * XXX - this can happen for IPv6 packets if the next header isn't the * last header. */ - phdr->caplen = ((guint32) ascii_offset)/2; + rec->rec_header.packet_header.caplen = ((guint32) ascii_offset)/2; /* Make sure we have enough room for the packet. */ - ws_buffer_assure_space (buf, phdr->caplen); + ws_buffer_assure_space (buf, rec->rec_header.packet_header.caplen); /* Convert ascii data to binary and return in the frame buffer */ iseries_parse_hex_string (ascii_buf, ws_buffer_start_ptr (buf), ascii_offset); diff --git a/wiretap/json.c b/wiretap/json.c index a61ef121a3..8f5064de47 100644 --- a/wiretap/json.c +++ b/wiretap/json.c @@ -15,7 +15,7 @@ #include "json.h" #include <wsutil/wsjsmn.h> -static gboolean json_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean json_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { gint64 file_size; @@ -36,19 +36,19 @@ static gboolean json_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->ts.secs = 0; + rec->ts.nsecs = 0; return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } -static gboolean json_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, +static gboolean json_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ @@ -60,7 +60,7 @@ static gboolean json_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *p if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return json_read_file(wth, wth->random_fh, phdr, buf, err, err_info); + return json_read_file(wth, wth->random_fh, rec, buf, err, err_info); } static gboolean json_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) @@ -77,7 +77,7 @@ static gboolean json_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of *data_offset = offset; - return json_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return json_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } wtap_open_return_val json_open(wtap *wth, int *err, gchar **err_info) diff --git a/wiretap/k12.c b/wiretap/k12.c index 784bb6734c..d84fec7646 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -562,7 +562,7 @@ memiszero(const void *ptr, size_t count) } static gboolean -process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, +process_packet_data(wtap_rec *rec, Buffer *target, guint8 *buffer, guint record_len, k12_t *k12, int *err, gchar **err_info) { guint32 type; @@ -590,15 +590,15 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; ts = pntoh64(buffer + K12_PACKET_TIMESTAMP); - phdr->ts.secs = (guint32) ((ts / 2000000) + 631152000); - phdr->ts.nsecs = (guint32) ( (ts % 2000000) * 500 ); + rec->ts.secs = (guint32) ((ts / 2000000) + 631152000); + rec->ts.nsecs = (guint32) ( (ts % 2000000) * 500 ); - phdr->len = phdr->caplen = length; + rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen = length; ws_buffer_assure_space(target, length); memcpy(ws_buffer_start_ptr(target), buffer + buffer_offset, length); @@ -608,12 +608,12 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, ws_buffer_assure_space(&(k12->extra_info), extra_len); memcpy(ws_buffer_start_ptr(&(k12->extra_info)), buffer + buffer_offset + length, extra_len); - phdr->pseudo_header.k12.extra_info = (guint8*)ws_buffer_start_ptr(&(k12->extra_info)); - phdr->pseudo_header.k12.extra_length = extra_len; + rec->rec_header.packet_header.pseudo_header.k12.extra_info = (guint8*)ws_buffer_start_ptr(&(k12->extra_info)); + rec->rec_header.packet_header.pseudo_header.k12.extra_length = extra_len; src_id = pntoh32(buffer + K12_RECORD_SRC_ID); K12_DBG(5,("process_packet_data: src_id=%.8x",src_id)); - phdr->pseudo_header.k12.input = src_id; + rec->rec_header.packet_header.pseudo_header.k12.input = src_id; if ( ! (src_desc = (k12_src_desc_t*)g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id))) ) { /* @@ -628,33 +628,33 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, if (src_desc) { K12_DBG(5,("process_packet_data: input_name='%s' stack_file='%s' type=%x",src_desc->input_name,src_desc->stack_file,src_desc->input_type)); - phdr->pseudo_header.k12.input_name = src_desc->input_name; - phdr->pseudo_header.k12.stack_file = src_desc->stack_file; - phdr->pseudo_header.k12.input_type = src_desc->input_type; + rec->rec_header.packet_header.pseudo_header.k12.input_name = src_desc->input_name; + rec->rec_header.packet_header.pseudo_header.k12.stack_file = src_desc->stack_file; + rec->rec_header.packet_header.pseudo_header.k12.input_type = src_desc->input_type; switch(src_desc->input_type) { case K12_PORT_ATMPVC: if (buffer_offset + length + K12_PACKET_OFFSET_CID < record_len) { - phdr->pseudo_header.k12.input_info.atm.vp = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VP); - phdr->pseudo_header.k12.input_info.atm.vc = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VC); - phdr->pseudo_header.k12.input_info.atm.cid = *((unsigned char*)(buffer + buffer_offset + length + K12_PACKET_OFFSET_CID)); + rec->rec_header.packet_header.pseudo_header.k12.input_info.atm.vp = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VP); + rec->rec_header.packet_header.pseudo_header.k12.input_info.atm.vc = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VC); + rec->rec_header.packet_header.pseudo_header.k12.input_info.atm.cid = *((unsigned char*)(buffer + buffer_offset + length + K12_PACKET_OFFSET_CID)); break; } /* Fall through */ default: - memcpy(&(phdr->pseudo_header.k12.input_info),&(src_desc->input_info),sizeof(src_desc->input_info)); + memcpy(&(rec->rec_header.packet_header.pseudo_header.k12.input_info),&(src_desc->input_info),sizeof(src_desc->input_info)); break; } } else { K12_DBG(5,("process_packet_data: NO SRC_RECORD FOUND")); - memset(&(phdr->pseudo_header.k12),0,sizeof(phdr->pseudo_header.k12)); - phdr->pseudo_header.k12.input_name = "unknown port"; - phdr->pseudo_header.k12.stack_file = "unknown stack file"; + memset(&(rec->rec_header.packet_header.pseudo_header.k12),0,sizeof(rec->rec_header.packet_header.pseudo_header.k12)); + rec->rec_header.packet_header.pseudo_header.k12.input_name = "unknown port"; + rec->rec_header.packet_header.pseudo_header.k12.stack_file = "unknown stack file"; } - phdr->pseudo_header.k12.input = src_id; - phdr->pseudo_header.k12.stuff = k12; + rec->rec_header.packet_header.pseudo_header.k12.input = src_id; + rec->rec_header.packet_header.pseudo_header.k12.stuff = k12; return TRUE; } @@ -721,11 +721,11 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off } while ( ((type & K12_MASK_PACKET) != K12_REC_PACKET && (type & K12_MASK_PACKET) != K12_REC_D0020) || !src_id || !src_desc ); - return process_packet_data(&wth->phdr, wth->frame_buffer, buffer, (guint)len, k12, err, err_info); + return process_packet_data(&wth->rec, wth->rec_data, buffer, (guint)len, k12, err, err_info); } -static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { +static gboolean k12_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { k12_t *k12 = (k12_t *)wth->priv; guint8* buffer; gint len; @@ -751,7 +751,7 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph buffer = k12->rand_read_buff; - status = process_packet_data(phdr, buf, buffer, (guint)len, k12, err, err_info); + status = process_packet_data(rec, buf, buffer, (guint)len, k12, err, err_info); K12_DBG(5,("k12_seek_read: DONE OK")); @@ -1247,9 +1247,9 @@ static void k12_dump_src_setting(gpointer k _U_, gpointer v, gpointer p) { k12_dump_record(wdh,len,obj.buffer, &errxxx); /* fwrite errs ignored: see k12_dump below */ } -static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean k12_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; k12_dump_t *k12 = (k12_dump_t *)wdh->priv; guint32 len; union { @@ -1269,7 +1269,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } obj; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -1283,7 +1283,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* encountered in k12_dump_src_setting). */ g_hash_table_foreach(file_data->src_by_id,k12_dump_src_setting,wdh); } - obj.record.len = 0x20 + phdr->caplen; + obj.record.len = 0x20 + rec->rec_header.packet_header.caplen; obj.record.len += (obj.record.len % 4) ? 4 - obj.record.len % 4 : 0; len = obj.record.len; @@ -1291,12 +1291,12 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, obj.record.len = g_htonl(obj.record.len); obj.record.type = g_htonl(K12_REC_PACKET); - obj.record.frame_len = g_htonl(phdr->caplen); + obj.record.frame_len = g_htonl(rec->rec_header.packet_header.caplen); obj.record.input = g_htonl(pseudo_header->k12.input); - obj.record.ts = GUINT64_TO_BE((((guint64)phdr->ts.secs - 631152000) * 2000000) + (phdr->ts.nsecs / 1000 * 2)); + obj.record.ts = GUINT64_TO_BE((((guint64)rec->ts.secs - 631152000) * 2000000) + (rec->ts.nsecs / 1000 * 2)); - memcpy(obj.record.frame,pd,phdr->caplen); + memcpy(obj.record.frame,pd,rec->rec_header.packet_header.caplen); return k12_dump_record(wdh,len,obj.buffer, err); } diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 4ffc849ba9..5451b5eff8 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -238,23 +238,23 @@ DIAG_ON(sign-compare) /* Fill in pkthdr */ static gboolean -k12text_set_headers(struct wtap_pkthdr *phdr, k12text_state_t *state, +k12text_set_headers(wtap_rec *rec, k12text_state_t *state, int *err, gchar **err_info) { - 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; - phdr->ts.secs = 946681200 + (3600*state->g_h) + (60*state->g_m) + state->g_s; - phdr->ts.nsecs = 1000000*state->g_ms + 1000*state->g_ns; + rec->ts.secs = 946681200 + (3600*state->g_h) + (60*state->g_m) + state->g_s; + rec->ts.nsecs = 1000000*state->g_ms + 1000*state->g_ns; - phdr->caplen = phdr->len = state->ii; + rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = state->ii; - phdr->pkt_encap = state->g_encap; + rec->rec_header.packet_header.pkt_encap = state->g_encap; /* The file-encap is WTAP_ENCAP_PER_PACKET */ switch(state->g_encap) { case WTAP_ENCAP_ETHERNET: - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; case WTAP_ENCAP_MTP3: case WTAP_ENCAP_CHDLC: @@ -372,19 +372,19 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset) *data_offset = k12text->next_frame_offset; /* file position for beginning of this frame */ k12text->next_frame_offset += state.file_bytes_read; /* file position after end of this frame */ - if (!k12text_set_headers(&wth->phdr, &state, err, err_info)) { + if (!k12text_set_headers(&wth->rec, &state, err, err_info)) { g_free(state.bb); return FALSE; } - ws_buffer_assure_space(wth->frame_buffer, wth->phdr.caplen); - memcpy(ws_buffer_start_ptr(wth->frame_buffer), state.bb, wth->phdr.caplen); + ws_buffer_assure_space(wth->rec_data, wth->rec.rec_header.packet_header.caplen); + memcpy(ws_buffer_start_ptr(wth->rec_data), state.bb, wth->rec.rec_header.packet_header.caplen); g_free(state.bb); return TRUE; } static gboolean -k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, char **err_info) +k12text_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, char **err_info) { k12text_state_t state; @@ -410,12 +410,12 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer * return FALSE; } - if (!k12text_set_headers(phdr, &state, err, err_info)) { + if (!k12text_set_headers(rec, &state, err, err_info)) { g_free(state.bb); return FALSE; } - ws_buffer_assure_space(buf, phdr->caplen); - memcpy(ws_buffer_start_ptr(buf), state.bb, phdr->caplen); + ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen); + memcpy(ws_buffer_start_ptr(buf), state.bb, rec->rec_header.packet_header.caplen); g_free(state.bb); return TRUE; @@ -471,7 +471,7 @@ static const struct { int e; const char* s; } encaps[] = { }; static gboolean -k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +k12text_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { #define K12BUF_SIZE 196808 char *buf; @@ -486,14 +486,14 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, struct tm *tmp; /* Don't write anything bigger than we're willing to read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } str_enc = NULL; for(i=0; encaps[i].s; i++) { - if (phdr->pkt_encap == encaps[i].e) { + if (rec->rec_header.packet_header.pkt_encap == encaps[i].e) { str_enc = encaps[i].s; break; } @@ -509,10 +509,10 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, buf = (char *)g_malloc(K12BUF_SIZE); p = buf; - ms = phdr->ts.nsecs / 1000000; - ns = (phdr->ts.nsecs - (1000000*ms))/1000; + ms = rec->ts.nsecs / 1000000; + ns = (rec->ts.nsecs - (1000000*ms))/1000; - tmp = gmtime(&phdr->ts.secs); + tmp = gmtime(&rec->ts.secs); if (tmp == NULL) g_snprintf(p, 90, "+---------+---------------+----------+\r\nXX:XX:XX,"); else @@ -525,7 +525,7 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, p += wl; left -= wl; - for(i = 0; i < phdr->caplen && left > 2; i++) { + for(i = 0; i < rec->rec_header.packet_header.caplen && left > 2; i++) { wl = g_snprintf(p, (gulong)left, "%.2x|", pd[i]); p += wl; left -= wl; diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 12fd85f4bc..00dbfa9c0c 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -261,7 +261,7 @@ typedef struct { static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean lanalyzer_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 lanalyzer_dump_finish(wtap_dumper *wdh, int *err); wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info) @@ -424,7 +424,7 @@ wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info) #define DESCRIPTOR_LEN 32 static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { char LE_record_type[2]; char LE_record_length[2]; @@ -493,8 +493,8 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh, 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; time_low = pletoh16(&descriptor[8]); time_med = pletoh16(&descriptor[10]); @@ -503,8 +503,8 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh, (((guint64)time_high) << 32); tsecs = (time_t) (t/2000000); lanalyzer = (lanalyzer_t *)wth->priv; - phdr->ts.secs = tsecs + lanalyzer->start; - phdr->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500; + rec->ts.secs = tsecs + lanalyzer->start; + rec->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500; if (true_size - 4 >= packet_size) { /* @@ -515,14 +515,14 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh, */ true_size -= 4; } - phdr->len = true_size; - phdr->caplen = packet_size; + rec->rec_header.packet_header.len = true_size; + rec->rec_header.packet_header.caplen = packet_size; switch (wth->file_encap) { case WTAP_ENCAP_ETHERNET: /* We assume there's no FCS in this frame. */ - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; } @@ -537,18 +537,18 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read the record */ - return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + return lanalyzer_read_trace_record(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); } static gboolean lanalyzer_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the record */ - if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf, + if (!lanalyzer_read_trace_record(wth, wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -622,7 +622,7 @@ static gboolean s48write(wtap_dumper *wdh, const guint64 s48, int *err) * Returns TRUE on success, FALSE on failure. *---------------------------------------------------*/ static gboolean lanalyzer_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { guint64 x; @@ -630,10 +630,10 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv); nstime_t td; - int thisSize = phdr->caplen + LA_PacketRecordSize + LA_RecordHeaderSize; + int thisSize = rec->rec_header.packet_header.caplen + LA_PacketRecordSize + LA_RecordHeaderSize; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -644,7 +644,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, return FALSE; /* and don't forget the header */ } - len = phdr->caplen + (phdr->caplen ? LA_PacketRecordSize : 0); + len = rec->rec_header.packet_header.caplen + (rec->rec_header.packet_header.caplen ? LA_PacketRecordSize : 0); /* len goes into a 16-bit field, so there's a hard limit of 65535. */ if (len > 65535) { @@ -661,7 +661,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, /* collect some information for the * finally written header */ - itmp->start = phdr->ts; + itmp->start = rec->ts; itmp->pkts = 0; itmp->init = TRUE; itmp->encap = wdh->encap; @@ -672,12 +672,12 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, return FALSE; if (!s16write(wdh, 0x0008, err)) /* pr.rx_errors */ return FALSE; - if (!s16write(wdh, (guint16) (phdr->len + 4), err)) /* pr.rx_frm_len */ + if (!s16write(wdh, (guint16) (rec->rec_header.packet_header.len + 4), err)) /* pr.rx_frm_len */ return FALSE; - if (!s16write(wdh, (guint16) phdr->caplen, err)) /* pr.rx_frm_sln */ + if (!s16write(wdh, (guint16) rec->rec_header.packet_header.caplen, err)) /* pr.rx_frm_sln */ return FALSE; - nstime_delta(&td, &phdr->ts, &itmp->start); + nstime_delta(&td, &rec->ts, &itmp->start); /* Convert to half-microseconds, rounded up. */ x = (td.nsecs + 250) / 500; /* nanoseconds -> half-microseconds, rounded */ @@ -695,7 +695,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, if (!s0write(wdh, 12, err)) return FALSE; - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; wdh->bytes_dumped += thisSize; diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 77af997c19..2a51fe12f8 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -46,10 +46,10 @@ static int libpcap_try_header(wtap *wth, FILE_T fh, int *err, gchar **err_info, static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean libpcap_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 libpcap_read_packet(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static gboolean libpcap_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info, struct pcaprec_ss990915_hdr *hdr); @@ -647,18 +647,18 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, { *data_offset = file_tell(wth->fh); - return libpcap_read_packet(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + return libpcap_read_packet(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); } static gboolean -libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +libpcap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err, + if (!libpcap_read_packet(wth, wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -668,7 +668,7 @@ libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, } static gboolean -libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +libpcap_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct pcaprec_ss990915_hdr hdr; @@ -722,7 +722,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } phdr_len = pcap_process_pseudo_header(fh, wth->file_type_subtype, - wth->file_encap, packet_size, TRUE, phdr, err, err_info); + wth->file_encap, packet_size, TRUE, rec, err, err_info); if (phdr_len < 0) return FALSE; /* error */ @@ -732,27 +732,27 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, orig_size -= phdr_len; packet_size -= phdr_len; - 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; /* Update the timestamp, if not already done */ if (wth->file_encap != WTAP_ENCAP_ERF) { - phdr->ts.secs = hdr.hdr.ts_sec; + rec->ts.secs = hdr.hdr.ts_sec; if (wth->file_tsprec == WTAP_TSPREC_NSEC) - phdr->ts.nsecs = hdr.hdr.ts_usec; + rec->ts.nsecs = hdr.hdr.ts_usec; else - phdr->ts.nsecs = hdr.hdr.ts_usec * 1000; + rec->ts.nsecs = hdr.hdr.ts_usec * 1000; } else { int interface_id; /* Set interface ID for ERF format */ - phdr->presence_flags |= WTAP_HAS_INTERFACE_ID; - if ((interface_id = erf_populate_interface_from_header((erf_t*) libpcap->encap_priv, wth, &phdr->pseudo_header)) < 0) + rec->presence_flags |= WTAP_HAS_INTERFACE_ID; + if ((interface_id = erf_populate_interface_from_header((erf_t*) libpcap->encap_priv, wth, &rec->rec_header.packet_header.pseudo_header)) < 0) return FALSE; - phdr->interface_id = (guint) interface_id; + rec->rec_header.packet_header.interface_id = (guint) interface_id; } - phdr->caplen = packet_size; - phdr->len = orig_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = orig_size; /* * Read the packet data. @@ -761,7 +761,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return FALSE; /* failed */ pcap_read_post_process(wth->file_type_subtype, wth->file_encap, - phdr, ws_buffer_start_ptr(buf), libpcap->byte_swapped, -1); + rec, ws_buffer_start_ptr(buf), libpcap->byte_swapped, -1); return TRUE; } @@ -921,10 +921,10 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean libpcap_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; struct pcaprec_ss990915_hdr rec_hdr; size_t hdr_size; int phdrsize; @@ -932,7 +932,7 @@ static gboolean libpcap_dump(wtap_dumper *wdh, phdrsize = pcap_get_phdr_size(wdh->encap, pseudo_header); /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -941,32 +941,32 @@ static gboolean libpcap_dump(wtap_dumper *wdh, * Don't write anything we're not willing to read. * (The cast is to prevent an overflow.) */ - if ((guint64)phdr->caplen + phdrsize > wtap_max_snaplen_for_encap(wdh->encap)) { + if ((guint64)rec->rec_header.packet_header.caplen + phdrsize > wtap_max_snaplen_for_encap(wdh->encap)) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - rec_hdr.hdr.incl_len = phdr->caplen + phdrsize; - rec_hdr.hdr.orig_len = phdr->len + phdrsize; + rec_hdr.hdr.incl_len = rec->rec_header.packet_header.caplen + phdrsize; + rec_hdr.hdr.orig_len = rec->rec_header.packet_header.len + phdrsize; switch (wdh->file_type_subtype) { case WTAP_FILE_TYPE_SUBTYPE_PCAP: - rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; - rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; + rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs; + rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000; hdr_size = sizeof (struct pcaprec_hdr); break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC: - rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; - rec_hdr.hdr.ts_usec = phdr->ts.nsecs; + rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs; + rec_hdr.hdr.ts_usec = rec->ts.nsecs; hdr_size = sizeof (struct pcaprec_hdr); break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417: /* modified, but with the old magic, sigh */ case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029: - rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; - rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; + rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs; + rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000; /* XXX - what should we supply here? Alexey's "libpcap" looks up the interface in the system's @@ -993,8 +993,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh, break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915: /* new magic, extra crap at the end */ - rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; - rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; + rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs; + rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000; rec_hdr.ifindex = 0; rec_hdr.protocol = 0; rec_hdr.pkt_type = 0; @@ -1004,8 +1004,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh, break; case WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA: /* old magic, extra crap at the end */ - rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; - rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; + rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs; + rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000; /* restore the "mysterious stuff" that came with the packet */ memcpy(&rec_hdr.ifindex, pseudo_header->nokia.stuff, 4); /* not written */ @@ -1031,9 +1031,9 @@ static gboolean libpcap_dump(wtap_dumper *wdh, if (!pcap_write_phdr(wdh, wdh->encap, pseudo_header, err)) return FALSE; - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; return TRUE; } diff --git a/wiretap/logcat.c b/wiretap/logcat.c index 9e7e88a959..00b0e6e581 100644 --- a/wiretap/logcat.c +++ b/wiretap/logcat.c @@ -154,7 +154,7 @@ gint logcat_exported_pdu_length(const guint8 *pd) { } static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { gint packet_size; guint16 payload_length; @@ -193,14 +193,14 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh, return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = (time_t) GINT32_FROM_LE(log_entry->sec); - phdr->ts.nsecs = GINT32_FROM_LE(log_entry->nsec); - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = (time_t) GINT32_FROM_LE(log_entry->sec); + rec->ts.nsecs = GINT32_FROM_LE(log_entry->nsec); + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; - phdr->pseudo_header.logcat.version = logcat->version; + rec->rec_header.packet_header.pseudo_header.logcat.version = logcat->version; return TRUE; } @@ -211,18 +211,18 @@ static gboolean logcat_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh, - &wth->phdr, wth->frame_buffer, err, err_info); + &wth->rec, wth->rec_data, err, err_info); } static gboolean logcat_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh, - phdr, buf, err, err_info)) { + rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -305,18 +305,18 @@ int logcat_dump_can_write_encap(int encap) } static gboolean logcat_binary_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { int caplen; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } - caplen = phdr->caplen; + caplen = rec->rec_header.packet_header.caplen; /* Skip EXPORTED_PDU*/ if (wdh->encap == WTAP_ENCAP_WIRESHARK_UPPER_PDU) { diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c index c4a5022987..3ba5ffc1e0 100644 --- a/wiretap/logcat_text.c +++ b/wiretap/logcat_text.c @@ -150,7 +150,7 @@ static gchar *logcat_log(const struct dumper_t *dumper, guint32 seconds, } -static void get_time(gchar *string, struct wtap_pkthdr *phdr) { +static void get_time(gchar *string, wtap_rec *rec) { gint ms; struct tm date; time_t seconds; @@ -160,17 +160,17 @@ static void get_time(gchar *string, struct wtap_pkthdr *phdr) { date.tm_year = 70; date.tm_mon -= 1; seconds = mktime(&date); - phdr->ts.secs = (time_t) seconds; - phdr->ts.nsecs = (int) (ms * 1e6); - phdr->presence_flags = WTAP_HAS_TS; + rec->ts.secs = (time_t) seconds; + rec->ts.nsecs = (int) (ms * 1e6); + rec->presence_flags = WTAP_HAS_TS; } else { - phdr->presence_flags = 0; - phdr->ts.secs = (time_t) 0; - phdr->ts.nsecs = (int) 0; + rec->presence_flags = 0; + rec->ts.secs = (time_t) 0; + rec->ts.nsecs = (int) 0; } } -static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean logcat_text_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, gint file_type) { gint8 *pd; gchar *cbuff; @@ -212,27 +212,27 @@ static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, g_free(lbuff); } - phdr->rec_type = REC_TYPE_PACKET; - phdr->caplen = (guint32)strlen(cbuff); - phdr->len = phdr->caplen; + rec->rec_type = REC_TYPE_PACKET; + rec->rec_header.packet_header.caplen = (guint32)strlen(cbuff); + rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen; - ws_buffer_assure_space(buf, phdr->caplen + 1); + ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen + 1); pd = ws_buffer_start_ptr(buf); if ((WTAP_FILE_TYPE_SUBTYPE_LOGCAT_TIME == file_type || WTAP_FILE_TYPE_SUBTYPE_LOGCAT_THREADTIME == file_type || WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type) && '-' != cbuff[0]) { /* the last part filters out the -- beginning of... lines */ if (WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type) { - get_time(cbuff+2, phdr); + get_time(cbuff+2, rec); } else { - get_time(cbuff, phdr); + get_time(cbuff, rec); } } else { - phdr->presence_flags = 0; - phdr->ts.secs = (time_t) 0; - phdr->ts.nsecs = (int) 0; + rec->presence_flags = 0; + rec->ts.secs = (time_t) 0; + rec->ts.nsecs = (int) 0; } - memcpy(pd, cbuff, phdr->caplen + 1); + memcpy(pd, cbuff, rec->rec_header.packet_header.caplen + 1); g_free(cbuff); return TRUE; } @@ -241,16 +241,16 @@ static gboolean logcat_text_read(wtap *wth, int *err _U_ , gchar **err_info _U_, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - return logcat_text_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, + return logcat_text_read_packet(wth->fh, &wth->rec, wth->rec_data, wth->file_type_subtype); } static gboolean logcat_text_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info _U_) { + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info _U_) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (!logcat_text_read_packet(wth->random_fh, phdr, buf, + if (!logcat_text_read_packet(wth->random_fh, rec, buf, wth->file_type_subtype)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -419,7 +419,7 @@ int logcat_text_long_dump_can_write_encap(int encap) { } static gboolean logcat_text_dump_text(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info) { gchar *buf; @@ -443,7 +443,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh, const struct dumper_t *dumper = (const struct dumper_t *) wdh->priv; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -456,7 +456,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh, skipped_length = logcat_exported_pdu_length(pd); pd += skipped_length; - if (!wtap_dump_file_write(wdh, (const gchar*) pd, phdr->caplen - skipped_length, err)) { + if (!wtap_dump_file_write(wdh, (const gchar*) pd, rec->rec_header.packet_header.caplen - skipped_length, err)) { return FALSE; } } @@ -471,7 +471,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh, logcat_version = buffered_detect_version(pd); } else { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; logcat_version = pseudo_header->logcat.version; } @@ -557,7 +557,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh, case WTAP_ENCAP_LOGCAT_THREADTIME: case WTAP_ENCAP_LOGCAT_LONG: if (dumper->type == wdh->encap) { - if (!wtap_dump_file_write(wdh, (const gchar*) pd, phdr->caplen, err)) { + if (!wtap_dump_file_write(wdh, (const gchar*) pd, rec->rec_header.packet_header.caplen, err)) { return FALSE; } } else { diff --git a/wiretap/merge.c b/wiretap/merge.c index 7d12ff4bbf..6e40758e03 100644 --- a/wiretap/merge.c +++ b/wiretap/merge.c @@ -245,7 +245,7 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[], int i; int ei = -1; nstime_t tv = { sizeof(time_t) > sizeof(int) ? LONG_MAX : INT_MAX, INT_MAX }; - struct wtap_pkthdr *phdr; + wtap_rec *rec; /* * Make sure we have a record available from each file that's not at @@ -273,21 +273,21 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[], } if (in_files[i].state == RECORD_PRESENT) { - phdr = wtap_phdr(in_files[i].wth); - if (!(phdr->presence_flags & WTAP_HAS_TS)) { + rec = wtap_get_rec(in_files[i].wth); + if (!(rec->presence_flags & WTAP_HAS_TS)) { /* * No time stamp. Pick this record, and stop looking. */ ei = i; break; } - if (is_earlier(&phdr->ts, &tv)) { + if (is_earlier(&rec->ts, &tv)) { /* * This record's time stamp is earlier than any of the * records we've seen so far. Pick it, for now, but * keep looking. */ - tv = phdr->ts; + tv = rec->ts; ei = i; } } @@ -764,7 +764,7 @@ generate_merged_idb(merge_in_file_t *in_files, const guint in_file_count, const /* * It's the same as a previous IDB, so we're going to "merge" * them into one by adding a map from its old IDB index to the new - * one. This will be used later to change the phdr interface_id. + * one. This will be used later to change the rec interface_id. */ add_idb_index_map(&in_files[i], itf_count, merged_index); } @@ -787,26 +787,26 @@ generate_merged_idb(merge_in_file_t *in_files, const guint in_file_count, const } static gboolean -map_phdr_interface_id(struct wtap_pkthdr *phdr, const merge_in_file_t *in_file) +map_rec_interface_id(wtap_rec *rec, const merge_in_file_t *in_file) { guint current_interface_id = 0; - g_assert(phdr != NULL); + g_assert(rec != NULL); g_assert(in_file != NULL); g_assert(in_file->idb_index_map != NULL); - if (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) { - current_interface_id = phdr->interface_id; + if (rec->presence_flags & WTAP_HAS_INTERFACE_ID) { + current_interface_id = rec->rec_header.packet_header.interface_id; } if (current_interface_id >= in_file->idb_index_map->len) { /* this shouldn't happen, but in a malformed input file it could */ - merge_debug("merge::map_phdr_interface_id: current_interface_id (%u) >= in_file->idb_index_map->len (%u) (ERROR?)", + merge_debug("merge::map_rec_interface_id: current_interface_id (%u) >= in_file->idb_index_map->len (%u) (ERROR?)", current_interface_id, in_file->idb_index_map->len); return FALSE; } - phdr->interface_id = g_array_index(in_file->idb_index_map, guint, current_interface_id); - phdr->presence_flags |= WTAP_HAS_INTERFACE_ID; + rec->rec_header.packet_header.interface_id = g_array_index(in_file->idb_index_map, guint, current_interface_id); + rec->presence_flags |= WTAP_HAS_INTERFACE_ID; return TRUE; } @@ -823,7 +823,7 @@ merge_process_packets(wtap_dumper *pdh, const int file_type, merge_in_file_t *in_file; int count = 0; gboolean stop_flag = FALSE; - struct wtap_pkthdr *phdr, snap_phdr; + wtap_rec *rec, snap_rec; for (;;) { *err = 0; @@ -858,21 +858,27 @@ merge_process_packets(wtap_dumper *pdh, const int file_type, break; } - phdr = wtap_phdr(in_file->wth); + rec = wtap_get_rec(in_file->wth); - if (phdr->presence_flags & WTAP_HAS_CAP_LEN) { - if (snaplen != 0 && phdr->caplen > snaplen) { - /* - * The dumper will only write up to caplen bytes out, - * so we only need to change that value, instead of - * cloning the whole packet with fewer bytes. - * - * XXX: but do we need to change the IDBs' snap_len? - */ - snap_phdr = *phdr; - snap_phdr.caplen = snaplen; - phdr = &snap_phdr; + switch (rec->rec_type) { + + case REC_TYPE_PACKET: + if (rec->presence_flags & WTAP_HAS_CAP_LEN) { + if (snaplen != 0 && + rec->rec_header.packet_header.caplen > snaplen) { + /* + * The dumper will only write up to caplen bytes out, + * so we only need to change that value, instead of + * cloning the whole packet with fewer bytes. + * + * XXX: but do we need to change the IDBs' snap_len? + */ + snap_rec = *rec; + snap_rec.rec_header.packet_header.caplen = snaplen; + rec = &snap_rec; + } } + break; } if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) { @@ -882,15 +888,15 @@ merge_process_packets(wtap_dumper *pdh, const int file_type, * now, we hardcode that, but we need to figure * out a more general way to handle this. */ - if (phdr->rec_type == REC_TYPE_PACKET) { - if (!map_phdr_interface_id(phdr, in_file)) { + if (rec->rec_type == REC_TYPE_PACKET) { + if (!map_rec_interface_id(rec, in_file)) { status = MERGE_ERR_BAD_PHDR_INTERFACE_ID; break; } } } - if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), err, err_info)) { + if (!wtap_dump(pdh, rec, wtap_get_buf_ptr(in_file->wth), err, err_info)) { status = MERGE_ERR_CANT_WRITE_OUTFILE; break; } diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c index d5133d9214..ca15314234 100644 --- a/wiretap/mime_file.c +++ b/wiretap/mime_file.c @@ -92,7 +92,7 @@ static const mime_files_t magic_files[] = { #define MAX_FILE_SIZE G_MAXINT static gboolean -mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +mime_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { gint64 file_size; @@ -113,14 +113,14 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->ts.secs = 0; + rec->ts.nsecs = 0; return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } @@ -140,11 +140,11 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) *data_offset = offset; - return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return mime_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean -mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +mime_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ if (seek_off > 0) { @@ -155,7 +155,7 @@ mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info); + return mime_read_file(wth, wth->random_fh, rec, buf, err, err_info); } wtap_open_return_val diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c index 840fe34283..5d01b8f2e9 100644 --- a/wiretap/mp2t.c +++ b/wiretap/mp2t.c @@ -50,7 +50,7 @@ typedef struct { static gboolean mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint64 tmp; @@ -63,10 +63,10 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset, if (!wtap_read_bytes_or_eof(fh, ws_buffer_start_ptr(buf), MP2T_SIZE, err, err_info)) return FALSE; - phdr->rec_type = REC_TYPE_PACKET; + rec->rec_type = REC_TYPE_PACKET; /* XXX - relative, not absolute, time stamps */ - phdr->presence_flags = WTAP_HAS_TS; + rec->presence_flags = WTAP_HAS_TS; /* * Every packet in an MPEG2-TS stream is has a fixed size of @@ -83,11 +83,11 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset, * doesn't get the right answer. */ tmp = ((guint64)(offset - mp2t->start_offset) * 8); /* offset, in bits */ - phdr->ts.secs = (time_t)(tmp / mp2t->bitrate); - phdr->ts.nsecs = (int)((tmp % mp2t->bitrate) * 1000000000 / mp2t->bitrate); + rec->ts.secs = (time_t)(tmp / mp2t->bitrate); + rec->ts.nsecs = (int)((tmp % mp2t->bitrate) * 1000000000 / mp2t->bitrate); - phdr->caplen = MP2T_SIZE; - phdr->len = MP2T_SIZE; + rec->rec_header.packet_header.caplen = MP2T_SIZE; + rec->rec_header.packet_header.len = MP2T_SIZE; return TRUE; } @@ -101,8 +101,8 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) *data_offset = file_tell(wth->fh); - if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, &wth->phdr, - wth->frame_buffer, err, err_info)) { + if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, &wth->rec, + wth->rec_data, err, err_info)) { return FALSE; } @@ -117,7 +117,7 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) } static gboolean -mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +mp2t_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { mp2t_filetype_t *mp2t; @@ -128,7 +128,7 @@ mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, mp2t = (mp2t_filetype_t*) wth->priv; - if (!mp2t_read_packet(mp2t, wth->random_fh, seek_off, phdr, buf, + if (!mp2t_read_packet(mp2t, wth->random_fh, seek_off, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c index a00e0fbab2..ed14e44615 100644 --- a/wiretap/mpeg.c +++ b/wiretap/mpeg.c @@ -61,7 +61,7 @@ mpeg_resync(FILE_T fh, int *err) #define SCRHZ 27000000 static gboolean -mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +mpeg_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, gboolean is_random, int *err, gchar **err_info) { mpeg_t *mpeg = (mpeg_t *)wth->priv; @@ -170,15 +170,15 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) return FALSE; - phdr->rec_type = REC_TYPE_PACKET; + rec->rec_type = REC_TYPE_PACKET; /* XXX - relative, not absolute, time stamps */ if (!is_random) { - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts = ts; + rec->presence_flags = WTAP_HAS_TS; + rec->ts = ts; } - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; return TRUE; } @@ -188,19 +188,19 @@ mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, + return mpeg_read_packet(wth, wth->fh, &wth->rec, wth->rec_data, FALSE, err, err_info); } static gboolean mpeg_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err, + if (!mpeg_read_packet(wth, wth->random_fh, rec, buf, TRUE, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; diff --git a/wiretap/mplog.c b/wiretap/mplog.c index 0f63963332..22e537f600 100644 --- a/wiretap/mplog.c +++ b/wiretap/mplog.c @@ -86,7 +86,7 @@ - if two blocks of our packet's block type are more than 200us apart, we treat this as a packet boundary as described above */ -static gboolean mplog_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean mplog_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint8 *p, *start_p; @@ -169,13 +169,13 @@ static gboolean mplog_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, start_p[2] = pkt_bytes >> 8; start_p[3] = pkt_bytes & 0xFF; - phdr->rec_type = REC_TYPE_PACKET; - phdr->pkt_encap = WTAP_ENCAP_ISO14443; - phdr->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN; - phdr->ts.secs = (time_t)((pkt_ctr*10)/(1000*1000*1000)); - phdr->ts.nsecs = (int)((pkt_ctr*10)%(1000*1000*1000)); - phdr->caplen = ISO14443_PSEUDO_HDR_LEN + pkt_bytes; - phdr->len = phdr->caplen; + rec->rec_type = REC_TYPE_PACKET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISO14443; + rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN; + rec->ts.secs = (time_t)((pkt_ctr*10)/(1000*1000*1000)); + rec->ts.nsecs = (int)((pkt_ctr*10)%(1000*1000*1000)); + rec->rec_header.packet_header.caplen = ISO14443_PSEUDO_HDR_LEN + pkt_bytes; + rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen; return TRUE; } @@ -187,18 +187,18 @@ mplog_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) *data_offset = file_tell(wth->fh); return mplog_read_packet( - wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean -mplog_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *pkthdr, - Buffer *buf, int *err, gchar **err_info) +mplog_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, + int *err, gchar **err_info) { if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) return FALSE; - if (!mplog_read_packet(wth->random_fh, pkthdr, buf, err, err_info)) { + if (!mplog_read_packet(wth->random_fh, rec, buf, err, err_info)) { /* Even if we got an immediate EOF, that's an error. */ if (*err == 0) *err = WTAP_ERR_SHORT_READ; diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 0359fcd12f..6d365263a3 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -201,11 +201,11 @@ static const int netmon_encap[] = { static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean netmon_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 netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); static void netmon_close(wtap *wth); -static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean netmon_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gboolean netmon_dump_finish(wtap_dumper *wdh, int *err); @@ -763,23 +763,23 @@ wtap_open_return_val netmon_open(wtap *wth, int *err, gchar **err_info) } static void -netmon_set_pseudo_header_info(struct wtap_pkthdr *phdr, Buffer *buf) +netmon_set_pseudo_header_info(wtap_rec *rec, Buffer *buf) { - switch (phdr->pkt_encap) { + switch (rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_ATM_PDUS: /* * Attempt to guess from the packet data, the VPI, and * the VCI information about the type of traffic. */ - atm_guess_traffic_type(phdr, ws_buffer_start_ptr(buf)); + atm_guess_traffic_type(rec, ws_buffer_start_ptr(buf)); break; case WTAP_ENCAP_ETHERNET: /* * We assume there's no FCS in this frame. */ - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; case WTAP_ENCAP_IEEE_802_11_NETMON: @@ -794,11 +794,11 @@ netmon_set_pseudo_header_info(struct wtap_pkthdr *phdr, Buffer *buf) * do not have an FCS). * An "FCS length" of -2 means "NetMon weirdness". */ - memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11)); - phdr->pseudo_header.ieee_802_11.fcs_len = -2; - phdr->pseudo_header.ieee_802_11.decrypted = FALSE; - phdr->pseudo_header.ieee_802_11.datapad = FALSE; - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; + memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11)); + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = -2; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; break; } } @@ -810,7 +810,7 @@ typedef enum { } process_record_retval; static process_record_retval -netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +netmon_process_record(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { netmon_t *netmon = (netmon_t *)wth->priv; @@ -872,7 +872,7 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return FAILURE; } - phdr->rec_type = REC_TYPE_PACKET; + rec->rec_type = REC_TYPE_PACKET; /* * If this is an ATM packet, the first @@ -894,7 +894,7 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, packet_size); return FAILURE; } - if (!netmon_read_atm_pseudoheader(fh, &phdr->pseudo_header, + if (!netmon_read_atm_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return FAILURE; /* Read error */ @@ -976,16 +976,16 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } secs += (time_t)(t/1000000000); nsecs = (int)(t%1000000000); - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->ts.secs = netmon->start_secs + secs; - phdr->ts.nsecs = nsecs; - phdr->caplen = packet_size; - phdr->len = orig_size; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->ts.secs = netmon->start_secs + secs; + rec->ts.nsecs = nsecs; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = orig_size; /* * Read the packet data. */ - if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info)) + if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info)) return FAILURE; /* @@ -1144,7 +1144,7 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } } - phdr->pkt_encap = pkt_encap; + rec->rec_header.packet_header.pkt_encap = pkt_encap; if (netmon->version_major > 2 || netmon->version_minor > 2) { guint64 d; @@ -1155,7 +1155,7 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * and overwrite the time stamp obtained * from the record header. */ - if (!filetime_to_nstime(&phdr->ts, d)) { + if (!filetime_to_nstime(&rec->ts, d)) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("netmon: time stamp outside supported range"); return FAILURE; @@ -1163,7 +1163,7 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } } - netmon_set_pseudo_header_info(phdr, buf); + netmon_set_pseudo_header_info(rec, buf); /* If any header specific information is present, set it as pseudo header data * and set the encapsulation type, so it can be handled to the netmon_header @@ -1179,45 +1179,45 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, /* These are the current encapsulation types that NetMon uses. * Save them off so they can be copied to the NetMon pseudoheader */ - switch (phdr->pkt_encap) + switch (rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_ATM_PDUS: - memcpy(&temp_header.atm, &phdr->pseudo_header.atm, sizeof(temp_header.atm)); + memcpy(&temp_header.atm, &rec->rec_header.packet_header.pseudo_header.atm, sizeof(temp_header.atm)); break; case WTAP_ENCAP_ETHERNET: - memcpy(&temp_header.eth, &phdr->pseudo_header.eth, sizeof(temp_header.eth)); + memcpy(&temp_header.eth, &rec->rec_header.packet_header.pseudo_header.eth, sizeof(temp_header.eth)); break; case WTAP_ENCAP_IEEE_802_11_NETMON: - memcpy(&temp_header.ieee_802_11, &phdr->pseudo_header.ieee_802_11, sizeof(temp_header.ieee_802_11)); + memcpy(&temp_header.ieee_802_11, &rec->rec_header.packet_header.pseudo_header.ieee_802_11, sizeof(temp_header.ieee_802_11)); break; } - memset(&phdr->pseudo_header.netmon, 0, sizeof(phdr->pseudo_header.netmon)); + memset(&rec->rec_header.packet_header.pseudo_header.netmon, 0, sizeof(rec->rec_header.packet_header.pseudo_header.netmon)); /* Save the current encapsulation type to the NetMon pseudoheader */ - phdr->pseudo_header.netmon.sub_encap = phdr->pkt_encap; + rec->rec_header.packet_header.pseudo_header.netmon.sub_encap = rec->rec_header.packet_header.pkt_encap; /* Copy the comment data */ - phdr->pseudo_header.netmon.titleLength = comment_rec->titleLength; - phdr->pseudo_header.netmon.title = comment_rec->title; - phdr->pseudo_header.netmon.descLength = comment_rec->descLength; - phdr->pseudo_header.netmon.description = comment_rec->description; + rec->rec_header.packet_header.pseudo_header.netmon.titleLength = comment_rec->titleLength; + rec->rec_header.packet_header.pseudo_header.netmon.title = comment_rec->title; + rec->rec_header.packet_header.pseudo_header.netmon.descLength = comment_rec->descLength; + rec->rec_header.packet_header.pseudo_header.netmon.description = comment_rec->description; /* Copy the saved pseudoheaders to the netmon pseudoheader structure */ - switch (phdr->pkt_encap) + switch (rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_ATM_PDUS: - memcpy(&phdr->pseudo_header.netmon.subheader.atm, &temp_header.atm, sizeof(temp_header.atm)); + memcpy(&rec->rec_header.packet_header.pseudo_header.netmon.subheader.atm, &temp_header.atm, sizeof(temp_header.atm)); break; case WTAP_ENCAP_ETHERNET: - memcpy(&phdr->pseudo_header.netmon.subheader.eth, &temp_header.eth, sizeof(temp_header.eth)); + memcpy(&rec->rec_header.packet_header.pseudo_header.netmon.subheader.eth, &temp_header.eth, sizeof(temp_header.eth)); break; case WTAP_ENCAP_IEEE_802_11_NETMON: - memcpy(&phdr->pseudo_header.netmon.subheader.ieee_802_11, &temp_header.ieee_802_11, sizeof(temp_header.ieee_802_11)); + memcpy(&rec->rec_header.packet_header.pseudo_header.netmon.subheader.ieee_802_11, &temp_header.ieee_802_11, sizeof(temp_header.ieee_802_11)); break; } /* Encapsulation type is now something that can be passed to netmon_header dissector */ - phdr->pkt_encap = WTAP_ENCAP_NETMON_HEADER; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETMON_HEADER; } return SUCCESS; @@ -1256,8 +1256,8 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); - switch (netmon_process_record(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info)) { + switch (netmon_process_record(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info)) { case RETRY: continue; @@ -1273,12 +1273,12 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, static gboolean netmon_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - switch (netmon_process_record(wth, wth->random_fh, phdr, buf, err, + switch (netmon_process_record(wth, wth->random_fh, rec, buf, err, err_info)) { default: @@ -1434,10 +1434,10 @@ gboolean netmon_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ -static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean netmon_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv; struct netmonrec_1_x_hdr rec_1_x_hdr; struct netmonrec_2_x_hdr rec_2_x_hdr; @@ -1451,7 +1451,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, gint32 nsecs; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -1463,7 +1463,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, * The length fields are 16-bit, so there's a hard limit * of 65535. */ - if (phdr->caplen > 65535) { + if (rec->rec_header.packet_header.caplen > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -1471,7 +1471,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, case WTAP_FILE_TYPE_SUBTYPE_NETMON_2_x: /* Don't write anything we're not willing to read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -1488,9 +1488,9 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* * Is this network type supported? */ - if (phdr->pkt_encap < 0 || - (unsigned) phdr->pkt_encap >= NUM_WTAP_ENCAPS || - wtap_encap[phdr->pkt_encap] == -1) { + if (rec->rec_header.packet_header.pkt_encap < 0 || + (unsigned) rec->rec_header.packet_header.pkt_encap >= NUM_WTAP_ENCAPS || + wtap_encap[rec->rec_header.packet_header.pkt_encap] == -1) { /* * No. Fail. */ @@ -1501,7 +1501,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* * Fill in the trailer with the network type. */ - phtoles(rec_2_x_trlr.network, wtap_encap[phdr->pkt_encap]); + phtoles(rec_2_x_trlr.network, wtap_encap[rec->rec_header.packet_header.pkt_encap]); } /* @@ -1527,9 +1527,9 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, * sub-millisecond part of the time stamp off. */ if (!netmon->got_first_record_time) { - netmon->first_record_time.secs = phdr->ts.secs; + netmon->first_record_time.secs = rec->ts.secs; netmon->first_record_time.nsecs = - (phdr->ts.nsecs/1000000)*1000000; + (rec->ts.nsecs/1000000)*1000000; netmon->got_first_record_time = TRUE; } @@ -1537,8 +1537,8 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, atm_hdrsize = sizeof (struct netmon_atm_hdr); else atm_hdrsize = 0; - secs = (gint64)(phdr->ts.secs - netmon->first_record_time.secs); - nsecs = phdr->ts.nsecs - netmon->first_record_time.nsecs; + secs = (gint64)(rec->ts.secs - netmon->first_record_time.secs); + nsecs = rec->ts.nsecs - netmon->first_record_time.nsecs; while (nsecs < 0) { /* * Propagate a borrow into the seconds. @@ -1568,16 +1568,16 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, case WTAP_FILE_TYPE_SUBTYPE_NETMON_1_x: rec_1_x_hdr.ts_delta = GUINT32_TO_LE(secs*1000 + (nsecs + 500000)/1000000); - rec_1_x_hdr.orig_len = GUINT16_TO_LE(phdr->len + atm_hdrsize); - rec_1_x_hdr.incl_len = GUINT16_TO_LE(phdr->caplen + atm_hdrsize); + rec_1_x_hdr.orig_len = GUINT16_TO_LE(rec->rec_header.packet_header.len + atm_hdrsize); + rec_1_x_hdr.incl_len = GUINT16_TO_LE(rec->rec_header.packet_header.caplen + atm_hdrsize); hdrp = &rec_1_x_hdr; hdr_size = sizeof rec_1_x_hdr; break; case WTAP_FILE_TYPE_SUBTYPE_NETMON_2_x: rec_2_x_hdr.ts_delta = GUINT64_TO_LE(secs*1000000 + (nsecs + 500)/1000); - rec_2_x_hdr.orig_len = GUINT32_TO_LE(phdr->len + atm_hdrsize); - rec_2_x_hdr.incl_len = GUINT32_TO_LE(phdr->caplen + atm_hdrsize); + rec_2_x_hdr.orig_len = GUINT32_TO_LE(rec->rec_header.packet_header.len + atm_hdrsize); + rec_2_x_hdr.incl_len = GUINT32_TO_LE(rec->rec_header.packet_header.caplen + atm_hdrsize); hdrp = &rec_2_x_hdr; hdr_size = sizeof rec_2_x_hdr; break; @@ -1613,9 +1613,9 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, rec_size += sizeof atm_hdr; } - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - rec_size += phdr->caplen; + rec_size += rec->rec_header.packet_header.caplen; if (wdh->encap == WTAP_ENCAP_PER_PACKET) { /* diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c index bf10ab6ce8..c8feb1bbcb 100644 --- a/wiretap/netscaler.c +++ b/wiretap/netscaler.c @@ -479,71 +479,71 @@ typedef struct nspr_pktracepart_v26 } nspr_pktracepart_v26_t; #define nspr_pktracepart_v26_s ((guint32)(sizeof(nspr_pktracepart_v26_t))) -#define __TNDO(phdr,enumprefix,structname,hdrname)\ +#define __TNDO(rec,enumprefix,structname,hdrname)\ static const guint8 enumprefix##_##hdrname##_offset = (guint8)sizeof(nspr_##structname##_t); -#define __TNO(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ +#define __TNO(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ static const guint8 enumprefix##_##hdrname##_offset = (guint8)GPOINTER_TO_INT(offsetof(nspr_##structname##_t,structprefix##_##structfieldname)); -#define __TNL(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ +#define __TNL(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ static const guint8 enumprefix##_##hdrname##_len = (guint8)sizeof(((nspr_##structname##_t*)0)->structprefix##_##structfieldname); -#define __TNV1O(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ +#define __TNV1O(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ static const guint8 enumprefix##_##hdrname##_offset = (guint8)GPOINTER_TO_INT(offsetof(nspr_##structname##_t,structfieldname)); -#define __TNV1L(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ +#define __TNV1L(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ static const guint8 enumprefix##_##hdrname##_len = (guint8)sizeof(((nspr_##structname##_t*)0)->structfieldname); -#define TRACE_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - __TNV1O(phdr,enumprefix,structprefix,structname,dir,phd.ph_RecordType)\ - __TNV1L(phdr,enumprefix,structprefix,structname,dir,phd.ph_RecordType)\ - __TNV1O(phdr,enumprefix,structprefix,structname,nicno,phd.ph_DevNo)\ - __TNV1L(phdr,enumprefix,structprefix,structname,nicno,phd.ph_DevNo)\ - __TNDO(phdr,enumprefix,structname,eth) - -#define TRACE_V20_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - __TNO(phdr,enumprefix,structprefix,structname,dir,RecordType)\ - __TNL(phdr,enumprefix,structprefix,structname,dir,RecordType)\ - __TNO(phdr,enumprefix,structprefix,structname,nicno,DevNo)\ - __TNL(phdr,enumprefix,structprefix,structname,nicno,DevNo)\ - __TNDO(phdr,enumprefix,structname,eth) - -#define TRACE_V21_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - TRACE_V20_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNO(phdr,enumprefix,structprefix,structname,pcb,PcbDevNo)\ - __TNO(phdr,enumprefix,structprefix,structname,l_pcb,lPcbDevNo) - -#define TRACE_V22_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - TRACE_V21_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNO(phdr,enumprefix,structprefix,structname,vlantag,VlanTag) - -#define TRACE_V23_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - TRACE_V22_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNO(phdr,enumprefix,structprefix,structname,coreid,Coreid) - -#define TRACE_V24_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - TRACE_V23_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNO(phdr,enumprefix,structprefix,structname,srcnodeid,srcNodeId)\ - __TNO(phdr,enumprefix,structprefix,structname,destnodeid,destNodeId)\ - __TNO(phdr,enumprefix,structprefix,structname,clflags,clFlags) - -#define TRACE_V25_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - TRACE_V24_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNO(phdr,enumprefix,structprefix,structname,src_vmname_len,src_vmname_len)\ - __TNO(phdr,enumprefix,structprefix,structname,dst_vmname_len,dst_vmname_len)\ - __TNDO(phdr,enumprefix,structname,data) - -#define TRACE_V26_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ - TRACE_V25_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNO(phdr,enumprefix,structprefix,structname,ns_activity,ns_activity)\ - -#define TRACE_V30_REC_LEN_OFF(phdr, enumprefix, structprefix, structname) \ - TRACE_V26_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - -#define TRACE_V35_REC_LEN_OFF(phdr, enumprefix, structprefix, structname) \ - TRACE_V23_REC_LEN_OFF(phdr,enumprefix,structprefix,structname)\ - __TNDO(phdr,enumprefix,structname,data)\ - __TNO(phdr,enumprefix,structprefix,structname,ns_activity,ns_activity) +#define TRACE_V10_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + __TNV1O(rec,enumprefix,structprefix,structname,dir,phd.ph_RecordType)\ + __TNV1L(rec,enumprefix,structprefix,structname,dir,phd.ph_RecordType)\ + __TNV1O(rec,enumprefix,structprefix,structname,nicno,phd.ph_DevNo)\ + __TNV1L(rec,enumprefix,structprefix,structname,nicno,phd.ph_DevNo)\ + __TNDO(rec,enumprefix,structname,eth) + +#define TRACE_V20_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + __TNO(rec,enumprefix,structprefix,structname,dir,RecordType)\ + __TNL(rec,enumprefix,structprefix,structname,dir,RecordType)\ + __TNO(rec,enumprefix,structprefix,structname,nicno,DevNo)\ + __TNL(rec,enumprefix,structprefix,structname,nicno,DevNo)\ + __TNDO(rec,enumprefix,structname,eth) + +#define TRACE_V21_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + TRACE_V20_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNO(rec,enumprefix,structprefix,structname,pcb,PcbDevNo)\ + __TNO(rec,enumprefix,structprefix,structname,l_pcb,lPcbDevNo) + +#define TRACE_V22_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + TRACE_V21_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNO(rec,enumprefix,structprefix,structname,vlantag,VlanTag) + +#define TRACE_V23_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + TRACE_V22_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNO(rec,enumprefix,structprefix,structname,coreid,Coreid) + +#define TRACE_V24_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + TRACE_V23_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNO(rec,enumprefix,structprefix,structname,srcnodeid,srcNodeId)\ + __TNO(rec,enumprefix,structprefix,structname,destnodeid,destNodeId)\ + __TNO(rec,enumprefix,structprefix,structname,clflags,clFlags) + +#define TRACE_V25_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + TRACE_V24_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNO(rec,enumprefix,structprefix,structname,src_vmname_len,src_vmname_len)\ + __TNO(rec,enumprefix,structprefix,structname,dst_vmname_len,dst_vmname_len)\ + __TNDO(rec,enumprefix,structname,data) + +#define TRACE_V26_REC_LEN_OFF(rec,enumprefix,structprefix,structname) \ + TRACE_V25_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNO(rec,enumprefix,structprefix,structname,ns_activity,ns_activity)\ + +#define TRACE_V30_REC_LEN_OFF(rec, enumprefix, structprefix, structname) \ + TRACE_V26_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + +#define TRACE_V35_REC_LEN_OFF(rec, enumprefix, structprefix, structname) \ + TRACE_V23_REC_LEN_OFF(rec,enumprefix,structprefix,structname)\ + __TNDO(rec,enumprefix,structname,data)\ + __TNO(rec,enumprefix,structprefix,structname,ns_activity,ns_activity) TRACE_V10_REC_LEN_OFF(NULL,v10_part,pp,pktracepart_v10) TRACE_V10_REC_LEN_OFF(NULL,v10_full,fp,pktracefull_v10) @@ -610,15 +610,15 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static void nstrace_close(wtap *wth); @@ -630,7 +630,7 @@ static gboolean nstrace_set_start_time_v20(wtap *wth, int *err, static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info); static guint64 ns_hrtime2nsec(guint32 tm); -static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean nstrace_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); @@ -803,8 +803,8 @@ wtap_open_return_val nstrace_open(wtap *wth, int *err, gchar **err_info) } wth->file_tsprec = WTAP_TSPREC_NSEC; - wth->phdr.ts.secs = nstrace->nspm_curtime; - wth->phdr.ts.nsecs = 0; + wth->rec.ts.secs = nstrace->nspm_curtime; + wth->rec.ts.nsecs = 0; *err = 0; return WTAP_OPEN_MINE; @@ -941,20 +941,20 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info) return FALSE; } -#define __TNDO(phdr,enumprefix,structname,hdrname)\ - (phdr)->pseudo_header.nstr.hdrname##_offset = enumprefix##_##hdrname##_offset; +#define __TNDO(rec,enumprefix,structname,hdrname)\ + (rec)->rec_header.packet_header.pseudo_header.nstr.hdrname##_offset = enumprefix##_##hdrname##_offset; -#define __TNO(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ - (phdr)->pseudo_header.nstr.hdrname##_offset = enumprefix##_##hdrname##_offset; +#define __TNO(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ + (rec)->rec_header.packet_header.pseudo_header.nstr.hdrname##_offset = enumprefix##_##hdrname##_offset; -#define __TNL(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ - (phdr)->pseudo_header.nstr.hdrname##_len = enumprefix##_##hdrname##_len; +#define __TNL(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ + (rec)->rec_header.packet_header.pseudo_header.nstr.hdrname##_len = enumprefix##_##hdrname##_len; -#define __TNV1O(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ - __TNO(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) +#define __TNV1O(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ + __TNO(rec,enumprefix,structprefix,structname,hdrname,structfieldname) -#define __TNV1L(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) \ - __TNL(phdr,enumprefix,structprefix,structname,hdrname,structfieldname) +#define __TNV1L(rec,enumprefix,structprefix,structname,hdrname,structfieldname) \ + __TNL(rec,enumprefix,structprefix,structname,hdrname,structfieldname) @@ -964,28 +964,28 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info) ** The maximum value of the record data size is 65535, which is less than ** WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it. */ -#define TIMEDEFV10(phdr,fp,type) \ +#define TIMEDEFV10(rec,fp,type) \ do {\ - (phdr)->presence_flags = WTAP_HAS_TS;\ + (rec)->presence_flags = WTAP_HAS_TS;\ nsg_creltime += ns_hrtime2nsec(pletoh32(&type->type##_RelTimeHr));\ - (phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ - (phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ + (rec)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ + (rec)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ }while(0) -#define PARTSIZEDEFV10(phdr,pp,ver) \ +#define PARTSIZEDEFV10(rec,pp,ver) \ do {\ - (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ - (phdr)->len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v##ver##_s;\ - (phdr)->caplen = pletoh16(&pp->nsprRecordSize);\ + (rec)->presence_flags |= WTAP_HAS_CAP_LEN;\ + (rec)->rec_header.packet_header.len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v##ver##_s;\ + (rec)->rec_header.packet_header.caplen = pletoh16(&pp->nsprRecordSize);\ }while(0) -#define FULLSIZEDEFV10(phdr,fp,ver) \ +#define FULLSIZEDEFV10(rec,fp,ver) \ do {\ - (phdr)->len = pletoh16(&(fp)->nsprRecordSize);\ - (phdr)->caplen = (phdr)->len;\ + (rec)->rec_header.packet_header.len = pletoh16(&(fp)->nsprRecordSize);\ + (rec)->rec_header.packet_header.caplen = (rec)->rec_header.packet_header.len;\ }while(0) -#define PACKET_DESCRIBE(phdr,FULLPART,fullpart,ver,type,HEADERVER) \ +#define PACKET_DESCRIBE(rec,FULLPART,fullpart,ver,type,HEADERVER) \ do {\ nspr_pktrace##fullpart##_v##ver##_t *type = (nspr_pktrace##fullpart##_v##ver##_t *) &nstrace_buf[nstrace_buf_offset];\ /* Make sure the record header is entirely contained in the page */\ @@ -1000,20 +1000,20 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info) *err_info = g_strdup("nstrace: record size is less than record header size");\ return FALSE;\ }\ - (phdr)->rec_type = REC_TYPE_PACKET;\ - TIMEDEFV##ver((phdr),fp,type);\ - FULLPART##SIZEDEFV##ver((phdr),type,ver);\ - TRACE_V##ver##_REC_LEN_OFF((phdr),v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\ + (rec)->rec_type = REC_TYPE_PACKET;\ + TIMEDEFV##ver((rec),fp,type);\ + FULLPART##SIZEDEFV##ver((rec),type,ver);\ + TRACE_V##ver##_REC_LEN_OFF((rec),v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\ /* Make sure the record is entirely contained in the page */\ - if ((nstrace_buflen - nstrace_buf_offset) < (phdr)->caplen) {\ + if ((nstrace_buflen - nstrace_buf_offset) < (rec)->rec_header.packet_header.caplen) {\ *err = WTAP_ERR_BAD_FILE;\ *err_info = g_strdup("nstrace: record crosses page boundary");\ return FALSE;\ }\ - ws_buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\ - memcpy(ws_buffer_start_ptr(wth->frame_buffer), type, (phdr)->caplen);\ + ws_buffer_assure_space(wth->rec_data, (rec)->rec_header.packet_header.caplen);\ + memcpy(ws_buffer_start_ptr(wth->rec_data), type, (rec)->rec_header.packet_header.caplen);\ *data_offset = nstrace->xxx_offset + nstrace_buf_offset;\ - nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->caplen;\ + nstrace->nstrace_buf_offset = nstrace_buf_offset + (rec)->rec_header.packet_header.caplen;\ nstrace->nstrace_buflen = nstrace_buflen;\ nstrace->nsg_creltime = nsg_creltime;\ return TRUE;\ @@ -1021,6 +1021,7 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info) static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { + wtap_rec *rec = &wth->rec; nstrace_t *nstrace = (nstrace_t *)wth->priv; guint64 nsg_creltime = nstrace->nsg_creltime; gchar *nstrace_buf = nstrace->pnstrace_buf; @@ -1035,22 +1036,22 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * ((nstrace_buflen - nstrace_buf_offset) >= ((gint32)sizeof((( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType)))) { -#define GENERATE_CASE_FULL(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,full,ver,fp,HEADERVER); + PACKET_DESCRIBE(rec,FULL,full,ver,fp,HEADERVER); -#define GENERATE_CASE_PART(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_PART(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEPARTTX_V##ver:\ case NSPR_PDPKTRACEPARTTXB_V##ver:\ case NSPR_PDPKTRACEPARTRX_V##ver:\ - PACKET_DESCRIBE(phdr,PART,part,ver,pp,HEADERVER); + PACKET_DESCRIBE(rec,PART,part,ver,pp,HEADERVER); switch (pletoh16(&(( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType)) { - GENERATE_CASE_FULL(&wth->phdr,10,100) - GENERATE_CASE_PART(&wth->phdr,10,100) + GENERATE_CASE_FULL(rec,10,100) + GENERATE_CASE_PART(rec,10,100) #undef GENERATE_CASE_FULL #undef GENERATE_CASE_PART @@ -1109,61 +1110,61 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * #undef PACKET_DESCRIBE -#define TIMEDEFV20(phdr,fp,type) \ +#define TIMEDEFV20(rec,fp,type) \ do {\ - (phdr)->presence_flags = WTAP_HAS_TS;\ + (rec)->presence_flags = WTAP_HAS_TS;\ nsg_creltime += ns_hrtime2nsec(pletoh32(fp->type##_RelTimeHr));\ - (phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ - (phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ + (rec)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ + (rec)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ }while(0) -#define TIMEDEFV23(phdr,fp,type) \ +#define TIMEDEFV23(rec,fp,type) \ do {\ - (phdr)->presence_flags = WTAP_HAS_TS;\ + (rec)->presence_flags = WTAP_HAS_TS;\ /* access _AbsTimeHr as a 64bit value */\ nsg_creltime = pletoh64(fp->type##_AbsTimeHr);\ - (phdr)->ts.secs = (guint32) (nsg_creltime / 1000000000);\ - (phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ + (rec)->ts.secs = (guint32) (nsg_creltime / 1000000000);\ + (rec)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ }while(0) -#define TIMEDEFV21(phdr,fp,type) TIMEDEFV20(phdr,fp,type) -#define TIMEDEFV22(phdr,fp,type) TIMEDEFV20(phdr,fp,type) -#define TIMEDEFV24(phdr,fp,type) TIMEDEFV23(phdr,fp,type) -#define TIMEDEFV25(phdr,fp,type) TIMEDEFV24(phdr,fp,type) -#define TIMEDEFV26(phdr,fp,type) TIMEDEFV24(phdr,fp,type) +#define TIMEDEFV21(rec,fp,type) TIMEDEFV20(rec,fp,type) +#define TIMEDEFV22(rec,fp,type) TIMEDEFV20(rec,fp,type) +#define TIMEDEFV24(rec,fp,type) TIMEDEFV23(rec,fp,type) +#define TIMEDEFV25(rec,fp,type) TIMEDEFV24(rec,fp,type) +#define TIMEDEFV26(rec,fp,type) TIMEDEFV24(rec,fp,type) /* ** The maximum value of the record data size is 65535, which is less than ** WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it. */ -#define PARTSIZEDEFV20(phdr,pp,ver) \ +#define PARTSIZEDEFV20(rec,pp,ver) \ do {\ - (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ - (phdr)->len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v##ver##_s;\ - (phdr)->caplen = nspr_getv20recordsize((nspr_hd_v20_t *)pp);\ + (rec)->presence_flags |= WTAP_HAS_CAP_LEN;\ + (rec)->rec_header.packet_header.len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v##ver##_s;\ + (rec)->rec_header.packet_header.caplen = nspr_getv20recordsize((nspr_hd_v20_t *)pp);\ }while(0) -#define PARTSIZEDEFV21(phdr,pp,ver) PARTSIZEDEFV20(phdr,pp,ver) -#define PARTSIZEDEFV22(phdr,pp,ver) PARTSIZEDEFV20(phdr,pp,ver) -#define PARTSIZEDEFV23(phdr,pp,ver) PARTSIZEDEFV20(phdr,pp,ver) -#define PARTSIZEDEFV24(phdr,pp,ver) PARTSIZEDEFV20(phdr,pp,ver) -#define PARTSIZEDEFV25(phdr,pp,ver) PARTSIZEDEFV20(phdr,pp,ver) -#define PARTSIZEDEFV26(phdr,pp,ver) PARTSIZEDEFV20(phdr,pp,ver) +#define PARTSIZEDEFV21(rec,pp,ver) PARTSIZEDEFV20(rec,pp,ver) +#define PARTSIZEDEFV22(rec,pp,ver) PARTSIZEDEFV20(rec,pp,ver) +#define PARTSIZEDEFV23(rec,pp,ver) PARTSIZEDEFV20(rec,pp,ver) +#define PARTSIZEDEFV24(rec,pp,ver) PARTSIZEDEFV20(rec,pp,ver) +#define PARTSIZEDEFV25(rec,pp,ver) PARTSIZEDEFV20(rec,pp,ver) +#define PARTSIZEDEFV26(rec,pp,ver) PARTSIZEDEFV20(rec,pp,ver) -#define FULLSIZEDEFV20(phdr,fp,ver)\ +#define FULLSIZEDEFV20(rec,fp,ver)\ do {\ - (phdr)->len = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ - (phdr)->caplen = (phdr)->len;\ + (rec)->rec_header.packet_header.len = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ + (rec)->rec_header.packet_header.caplen = (rec)->rec_header.packet_header.len;\ }while(0) -#define FULLSIZEDEFV21(phdr,fp,ver) FULLSIZEDEFV20(phdr,fp,ver) -#define FULLSIZEDEFV22(phdr,fp,ver) FULLSIZEDEFV20(phdr,fp,ver) -#define FULLSIZEDEFV23(phdr,fp,ver) FULLSIZEDEFV20(phdr,fp,ver) -#define FULLSIZEDEFV24(phdr,fp,ver) FULLSIZEDEFV20(phdr,fp,ver) -#define FULLSIZEDEFV25(phdr,fp,ver) FULLSIZEDEFV20(phdr,fp,ver) -#define FULLSIZEDEFV26(phdr,fp,ver) FULLSIZEDEFV20(phdr,fp,ver) +#define FULLSIZEDEFV21(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver) +#define FULLSIZEDEFV22(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver) +#define FULLSIZEDEFV23(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver) +#define FULLSIZEDEFV24(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver) +#define FULLSIZEDEFV25(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver) +#define FULLSIZEDEFV26(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver) -#define PACKET_DESCRIBE(phdr,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ +#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ do {\ nspr_##structname##_t *fp= (nspr_##structname##_t*)&nstrace_buf[nstrace_buf_offset];\ /* Make sure the record header is entirely contained in the page */\ @@ -1178,19 +1179,19 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * *err_info = g_strdup("nstrace: record size is less than record header size");\ return FALSE;\ }\ - (phdr)->rec_type = REC_TYPE_PACKET;\ - TIMEDEFV##ver((phdr),fp,type);\ - FULLPART##SIZEDEFV##ver((phdr),fp,ver);\ - TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\ - (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ + (rec)->rec_type = REC_TYPE_PACKET;\ + TIMEDEFV##ver((rec),fp,type);\ + FULLPART##SIZEDEFV##ver((rec),fp,ver);\ + TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\ + (rec)->rec_header.packet_header.pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ /* Make sure the record is entirely contained in the page */\ - if ((nstrace_buflen - nstrace_buf_offset) < (phdr)->caplen) {\ + if ((nstrace_buflen - nstrace_buf_offset) < (rec)->rec_header.packet_header.caplen) {\ *err = WTAP_ERR_BAD_FILE;\ *err_info = g_strdup("nstrace: record crosses page boundary");\ return FALSE;\ }\ - ws_buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\ - memcpy(ws_buffer_start_ptr(wth->frame_buffer), fp, (phdr)->caplen);\ + ws_buffer_assure_space(wth->rec_data, (rec)->rec_header.packet_header.caplen);\ + memcpy(ws_buffer_start_ptr(wth->rec_data), fp, (rec)->rec_header.packet_header.caplen);\ *data_offset = nstrace->xxx_offset + nstrace_buf_offset;\ nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ nstrace->nstrace_buflen = nstrace_buflen;\ @@ -1200,6 +1201,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { + wtap_rec *rec = &wth->rec; nstrace_t *nstrace = (nstrace_t *)wth->priv; guint64 nsg_creltime = nstrace->nsg_creltime; gchar *nstrace_buf = nstrace->pnstrace_buf; @@ -1216,46 +1218,46 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 * switch ((( nspr_hd_v20_t*)&nstrace_buf[nstrace_buf_offset])->phd_RecordType) { -#define GENERATE_CASE_FULL(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); -#define GENERATE_CASE_FULL_V25(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL_V25(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ case NSPR_PDPKTRACEFULLNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); -#define GENERATE_CASE_PART(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_PART(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEPARTTX_V##ver:\ case NSPR_PDPKTRACEPARTTXB_V##ver:\ case NSPR_PDPKTRACEPARTRX_V##ver:\ - PACKET_DESCRIBE(phdr,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); -#define GENERATE_CASE_PART_V25(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_PART_V25(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEPARTTX_V##ver:\ case NSPR_PDPKTRACEPARTTXB_V##ver:\ case NSPR_PDPKTRACEPARTRX_V##ver:\ case NSPR_PDPKTRACEPARTNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); - - GENERATE_CASE_FULL(&wth->phdr,20,200); - GENERATE_CASE_PART(&wth->phdr,20,200); - GENERATE_CASE_FULL(&wth->phdr,21,201); - GENERATE_CASE_PART(&wth->phdr,21,201); - GENERATE_CASE_FULL(&wth->phdr,22,202); - GENERATE_CASE_PART(&wth->phdr,22,202); - GENERATE_CASE_FULL(&wth->phdr,23,203); - GENERATE_CASE_PART(&wth->phdr,23,203); - GENERATE_CASE_FULL_V25(&wth->phdr,24,204); - GENERATE_CASE_PART_V25(&wth->phdr,24,204); - GENERATE_CASE_FULL_V25(&wth->phdr,25,205); - GENERATE_CASE_PART_V25(&wth->phdr,25,205); - GENERATE_CASE_FULL_V25(&wth->phdr,26,206); - GENERATE_CASE_PART_V25(&wth->phdr,26,206); + PACKET_DESCRIBE(rec,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); + + GENERATE_CASE_FULL(rec,20,200); + GENERATE_CASE_PART(rec,20,200); + GENERATE_CASE_FULL(rec,21,201); + GENERATE_CASE_PART(rec,21,201); + GENERATE_CASE_FULL(rec,22,202); + GENERATE_CASE_PART(rec,22,202); + GENERATE_CASE_FULL(rec,23,203); + GENERATE_CASE_PART(rec,23,203); + GENERATE_CASE_FULL_V25(rec,24,204); + GENERATE_CASE_PART_V25(rec,24,204); + GENERATE_CASE_FULL_V25(rec,25,205); + GENERATE_CASE_PART_V25(rec,25,205); + GENERATE_CASE_FULL_V25(rec,26,206); + GENERATE_CASE_PART_V25(rec,26,206); #undef GENERATE_CASE_FULL #undef GENERATE_CASE_FULL_V25 @@ -1321,18 +1323,18 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 * #undef PACKET_DESCRIBE -#define SETETHOFFSET_35(phdr)\ - (phdr)->pseudo_header.nstr.eth_offset = pletoh16(&fp->fp_headerlen);\ +#define SETETHOFFSET_35(rec)\ + (rec)->rec_header.packet_header.pseudo_header.nstr.eth_offset = pletoh16(&fp->fp_headerlen);\ -#define SETETHOFFSET_30(phdr) ;\ +#define SETETHOFFSET_30(rec) ;\ -#define TIMEDEFV30(phdr,fp,type) \ +#define TIMEDEFV30(rec,fp,type) \ do {\ - (phdr)->presence_flags = WTAP_HAS_TS;\ + (rec)->presence_flags = WTAP_HAS_TS;\ /* access _AbsTimeHr as a 64bit value */\ nsg_creltime = pletoh64(fp->type##_AbsTimeHr);\ - (phdr)->ts.secs = (guint32) (nsg_creltime / 1000000000);\ - (phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ + (rec)->ts.secs = (guint32) (nsg_creltime / 1000000000);\ + (rec)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\ }while(0) #define TIMEDEFV35 TIMEDEFV30 @@ -1341,21 +1343,21 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 * ** The maximum value of the record data size is 65535, which is less than ** WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it. */ -#define FULLSIZEDEFV30(phdr,fp,ver)\ +#define FULLSIZEDEFV30(rec,fp,ver)\ do {\ - (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ - (phdr)->len = pletoh16(&fp->fp_PktSizeOrg) + nspr_pktracefull_v##ver##_s + fp->fp_src_vmname_len + fp->fp_dst_vmname_len;\ - (phdr)->caplen = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ + (rec)->presence_flags |= WTAP_HAS_CAP_LEN;\ + (rec)->rec_header.packet_header.len = pletoh16(&fp->fp_PktSizeOrg) + nspr_pktracefull_v##ver##_s + fp->fp_src_vmname_len + fp->fp_dst_vmname_len;\ + (rec)->rec_header.packet_header.caplen = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ }while(0) -#define FULLSIZEDEFV35(phdr,fp,ver)\ +#define FULLSIZEDEFV35(rec,fp,ver)\ do {\ - (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ - (phdr)->len = pletoh16(&fp->fp_PktSizeOrg) + pletoh16(&fp->fp_headerlen);\ - (phdr)->caplen = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ + (rec)->presence_flags |= WTAP_HAS_CAP_LEN;\ + (rec)->rec_header.packet_header.len = pletoh16(&fp->fp_PktSizeOrg) + pletoh16(&fp->fp_headerlen);\ + (rec)->rec_header.packet_header.caplen = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ }while(0) -#define PACKET_DESCRIBE(phdr,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ +#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ do {\ nspr_##structname##_t *fp = (nspr_##structname##_t *) &nstrace_buf[nstrace_buf_offset];\ /* Make sure the record header is entirely contained in the page */\ @@ -1365,20 +1367,20 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 * g_free(nstrace_tmpbuff);\ return FALSE;\ }\ - (phdr)->rec_type = REC_TYPE_PACKET;\ - TIMEDEFV##ver((phdr),fp,type);\ - FULLPART##SIZEDEFV##ver((phdr),fp,ver);\ - TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\ - SETETHOFFSET_##ver(phdr)\ - (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ + (rec)->rec_type = REC_TYPE_PACKET;\ + TIMEDEFV##ver((rec),fp,type);\ + FULLPART##SIZEDEFV##ver((rec),fp,ver);\ + TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\ + SETETHOFFSET_##ver(rec)\ + (rec)->rec_header.packet_header.pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ /* Check sanity of record size */\ - if ((phdr)->caplen < sizeof *fp) {\ + if ((rec)->rec_header.packet_header.caplen < sizeof *fp) {\ *err = WTAP_ERR_BAD_FILE;\ *err_info = g_strdup("nstrace: record size is less than record header size");\ g_free(nstrace_tmpbuff);\ return FALSE;\ }\ - ws_buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\ + ws_buffer_assure_space(wth->rec_data, (rec)->rec_header.packet_header.caplen);\ *data_offset = nstrace->xxx_offset + nstrace_buf_offset;\ /* Copy record header */\ while (nstrace_tmpbuff_off < nspr_##structname##_s) {\ @@ -1413,7 +1415,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 * while (nstrace_tmpbuff_off < nst_dataSize) {\ nstrace_tmpbuff[nstrace_tmpbuff_off++] = nstrace_buf[nstrace_buf_offset++];\ }\ - memcpy(ws_buffer_start_ptr(wth->frame_buffer), nstrace_tmpbuff, (phdr)->caplen);\ + memcpy(ws_buffer_start_ptr(wth->rec_data), nstrace_tmpbuff, (rec)->rec_header.packet_header.caplen);\ nstrace->nstrace_buf_offset = nstrace_buf_offset;\ nstrace->nstrace_buflen = nstrace_buflen;\ nstrace->nsg_creltime = nsg_creltime;\ @@ -1423,6 +1425,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 * static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { + wtap_rec *rec = &wth->rec; nstrace_t *nstrace = (nstrace_t *)wth->priv; guint64 nsg_creltime; gchar *nstrace_buf = nstrace->pnstrace_buf; @@ -1432,6 +1435,7 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 * guint32 nstrace_tmpbuff_off=0,nst_dataSize=0,rec_size=0,nsg_nextPageOffset=0; nspr_hd_v20_t *hdp; int bytes_read = 0; + *err = 0; *err_info = NULL; if(nstrace_buflen == 0){ @@ -1461,24 +1465,24 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 * switch (hdp->phd_RecordType) { -#define GENERATE_CASE_FULL_V30(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL_V30(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ case NSPR_PDPKTRACEFULLNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); - GENERATE_CASE_FULL_V30(&wth->phdr,30,300); + GENERATE_CASE_FULL_V30(rec,30,300); #undef GENERATE_CASE_FULL_V30 -#define GENERATE_CASE_FULL_V35(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL_V35(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ case NSPR_PDPKTRACEFULLNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); - GENERATE_CASE_FULL_V35(&wth->phdr,35,350); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + GENERATE_CASE_FULL_V35(rec,35,350); #undef GENERATE_CASE_FULL_V35 @@ -1523,23 +1527,23 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 * * routine, because the time stamps are relative. */ #undef TIMEDEFV10 -#define TIMEDEFV10(phdr,fp,type) \ +#define TIMEDEFV10(rec,fp,type) \ do {\ - (phdr)->presence_flags = 0;\ + (rec)->presence_flags = 0;\ }while(0) -#define PACKET_DESCRIBE(phdr,FULLPART,fullpart,ver,type,HEADERVER) \ +#define PACKET_DESCRIBE(rec,FULLPART,fullpart,ver,type,HEADERVER) \ do {\ nspr_pktrace##fullpart##_v##ver##_t *type = (nspr_pktrace##fullpart##_v##ver##_t *) pd;\ - (phdr)->rec_type = REC_TYPE_PACKET;\ - TIMEDEFV##ver((phdr),fp,type);\ - FULLPART##SIZEDEFV##ver((phdr),type,ver);\ - TRACE_V##ver##_REC_LEN_OFF(phdr,v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\ - (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ + (rec)->rec_type = REC_TYPE_PACKET;\ + TIMEDEFV##ver((rec),fp,type);\ + FULLPART##SIZEDEFV##ver((rec),type,ver);\ + TRACE_V##ver##_REC_LEN_OFF(rec,v##ver##_##fullpart,type,pktrace##fullpart##_v##ver);\ + (rec)->rec_header.packet_header.pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ }while(0) static gboolean nstrace_seek_read_v10(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) { nspr_hd_v10_t hdr; guint record_length; @@ -1579,24 +1583,24 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off, /* ** Fill in what part of the struct wtap_pkthdr we can. */ -#define GENERATE_CASE_FULL(phdr,type,HEADERVER) \ +#define GENERATE_CASE_FULL(rec,type,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##type:\ case NSPR_PDPKTRACEFULLTXB_V##type:\ case NSPR_PDPKTRACEFULLRX_V##type:\ - PACKET_DESCRIBE(phdr,FULL,full,type,fp,HEADERVER);\ + PACKET_DESCRIBE(rec,FULL,full,type,fp,HEADERVER);\ break; -#define GENERATE_CASE_PART(phdr,type,HEADERVER) \ +#define GENERATE_CASE_PART(rec,type,HEADERVER) \ case NSPR_PDPKTRACEPARTTX_V##type:\ case NSPR_PDPKTRACEPARTTXB_V##type:\ case NSPR_PDPKTRACEPARTRX_V##type:\ - PACKET_DESCRIBE(phdr,PART,part,type,pp,HEADERVER);\ + PACKET_DESCRIBE(rec,PART,part,type,pp,HEADERVER);\ break; switch (pletoh16(&(( nspr_header_v10_t*)pd)->ph_RecordType)) { - GENERATE_CASE_FULL(phdr,10,100) - GENERATE_CASE_PART(phdr,10,100) + GENERATE_CASE_FULL(rec,10,100) + GENERATE_CASE_PART(rec,10,100) } #undef GENERATE_CASE_FULL @@ -1612,29 +1616,29 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off, * routine, because the time stamps are relative. */ #undef TIMEDEFV20 -#define TIMEDEFV20(phdr,fp,type) \ +#define TIMEDEFV20(rec,fp,type) \ do {\ - (phdr)->presence_flags = 0;\ + (rec)->presence_flags = 0;\ }while(0) #undef TIMEDEFV21 #undef TIMEDEFV22 -#define TIMEDEFV21(phdr,fp,type) TIMEDEFV20(phdr,fp,type) -#define TIMEDEFV22(phdr,fp,type) TIMEDEFV20(phdr,fp,type) +#define TIMEDEFV21(rec,fp,type) TIMEDEFV20(rec,fp,type) +#define TIMEDEFV22(rec,fp,type) TIMEDEFV20(rec,fp,type) -#define PACKET_DESCRIBE(phdr,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ +#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ do {\ nspr_##structname##_t *fp= (nspr_##structname##_t*)pd;\ - (phdr)->rec_type = REC_TYPE_PACKET;\ - TIMEDEFV##ver((phdr),fp,type);\ - FULLPART##SIZEDEFV##ver((phdr),fp,ver);\ - TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\ - (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ + (rec)->rec_type = REC_TYPE_PACKET;\ + TIMEDEFV##ver((rec),fp,type);\ + FULLPART##SIZEDEFV##ver((rec),fp,ver);\ + TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\ + (rec)->rec_header.packet_header.pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ return TRUE;\ }while(0) static gboolean nstrace_seek_read_v20(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) { nspr_hd_v20_t hdr; guint record_length; @@ -1683,48 +1687,48 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off, return FALSE; } -#define GENERATE_CASE_FULL(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); -#define GENERATE_CASE_FULL_V25(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_FULL_V25(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ case NSPR_PDPKTRACEFULLNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); -#define GENERATE_CASE_PART(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_PART(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEPARTTX_V##ver:\ case NSPR_PDPKTRACEPARTTXB_V##ver:\ case NSPR_PDPKTRACEPARTRX_V##ver:\ - PACKET_DESCRIBE(phdr,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); -#define GENERATE_CASE_PART_V25(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_PART_V25(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEPARTTX_V##ver:\ case NSPR_PDPKTRACEPARTTXB_V##ver:\ case NSPR_PDPKTRACEPARTRX_V##ver:\ case NSPR_PDPKTRACEPARTNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER); switch ((( nspr_hd_v20_t*)pd)->phd_RecordType) { - GENERATE_CASE_FULL(phdr,20,200) - GENERATE_CASE_PART(phdr,20,200) - GENERATE_CASE_FULL(phdr,21,201) - GENERATE_CASE_PART(phdr,21,201) - GENERATE_CASE_FULL(phdr,22,202) - GENERATE_CASE_PART(phdr,22,202) - GENERATE_CASE_FULL(phdr,23,203) - GENERATE_CASE_PART(phdr,23,203) - GENERATE_CASE_FULL_V25(phdr,24,204) - GENERATE_CASE_PART_V25(phdr,24,204) - GENERATE_CASE_FULL_V25(phdr,25,205) - GENERATE_CASE_PART_V25(phdr,25,205) - GENERATE_CASE_FULL_V25(phdr,26,206) - GENERATE_CASE_PART_V25(phdr,26,206) + GENERATE_CASE_FULL(rec,20,200) + GENERATE_CASE_PART(rec,20,200) + GENERATE_CASE_FULL(rec,21,201) + GENERATE_CASE_PART(rec,21,201) + GENERATE_CASE_FULL(rec,22,202) + GENERATE_CASE_PART(rec,22,202) + GENERATE_CASE_FULL(rec,23,203) + GENERATE_CASE_PART(rec,23,203) + GENERATE_CASE_FULL_V25(rec,24,204) + GENERATE_CASE_PART_V25(rec,24,204) + GENERATE_CASE_FULL_V25(rec,25,205) + GENERATE_CASE_PART_V25(rec,25,205) + GENERATE_CASE_FULL_V25(rec,26,206) + GENERATE_CASE_PART_V25(rec,26,206) } #undef GENERATE_CASE_FULL @@ -1739,27 +1743,27 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off, #undef SETETHOFFSET_35 #undef SETETHOFFSET_30 -#define SETETHOFFSET_35(phdr)\ +#define SETETHOFFSET_35(rec)\ {\ - (phdr)->pseudo_header.nstr.eth_offset = pletoh16(&fp->fp_headerlen);\ + (rec)->rec_header.packet_header.pseudo_header.nstr.eth_offset = pletoh16(&fp->fp_headerlen);\ } -#define SETETHOFFSET_30(phdr) ;\ +#define SETETHOFFSET_30(rec) ;\ -#define PACKET_DESCRIBE(phdr,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ +#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\ do {\ nspr_##structname##_t *fp= (nspr_##structname##_t*)pd;\ - (phdr)->rec_type = REC_TYPE_PACKET;\ - TIMEDEFV##ver((phdr),fp,type);\ - SETETHOFFSET_##ver(phdr);\ - FULLPART##SIZEDEFV##ver((phdr),fp,ver);\ - TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\ - (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ + (rec)->rec_type = REC_TYPE_PACKET;\ + TIMEDEFV##ver((rec),fp,type);\ + SETETHOFFSET_##ver(rec);\ + FULLPART##SIZEDEFV##ver((rec),fp,ver);\ + TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\ + (rec)->rec_header.packet_header.pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##HEADERVER;\ return TRUE;\ }while(0) static gboolean nstrace_seek_read_v30(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) { nspr_hd_v20_t hdr; guint record_length; @@ -1809,19 +1813,19 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off, return FALSE; } - (phdr)->caplen = (phdr)->len = record_length; + (rec)->rec_header.packet_header.caplen = (rec)->rec_header.packet_header.len = record_length; -#define GENERATE_CASE_V30(phdr,ver,HEADERVER) \ +#define GENERATE_CASE_V30(rec,ver,HEADERVER) \ case NSPR_PDPKTRACEFULLTX_V##ver:\ case NSPR_PDPKTRACEFULLTXB_V##ver:\ case NSPR_PDPKTRACEFULLRX_V##ver:\ case NSPR_PDPKTRACEFULLNEWRX_V##ver:\ - PACKET_DESCRIBE(phdr,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); + PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER); switch ((( nspr_hd_v20_t*)pd)->phd_RecordType) { - GENERATE_CASE_V30(phdr,30, 300); - GENERATE_CASE_V30(phdr,35, 350); + GENERATE_CASE_V30(rec,30, 300); + GENERATE_CASE_V30(rec,35, 350); } return TRUE; @@ -1993,7 +1997,7 @@ static gboolean nstrace_add_signature(wtap_dumper *wdh, int *err) static gboolean -nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +nstrace_add_abstime(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err) { nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv; @@ -2016,7 +2020,7 @@ nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, nsg_creltime = ns_hrtime2nsec(reltime); memset(abs10.abs_RelTime, 0, sizeof abs10.abs_RelTime); - abstime = GUINT32_TO_LE((guint32)phdr->ts.secs - (guint32)(nsg_creltime/1000000000)); + abstime = GUINT32_TO_LE((guint32)rec->ts.secs - (guint32)(nsg_creltime/1000000000)); memcpy(abs10.abs_Time, &abstime, sizeof abs10.abs_Time); /* Write the record into the file */ @@ -2040,7 +2044,7 @@ nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, nsg_creltime = ns_hrtime2nsec(reltime); memset(abs20.abs_RelTime, 0, sizeof abs20.abs_RelTime); - abstime = GUINT32_TO_LE((guint32)phdr->ts.secs - (guint32)(nsg_creltime/1000000000)); + abstime = GUINT32_TO_LE((guint32)rec->ts.secs - (guint32)(nsg_creltime/1000000000)); memcpy(abs20.abs_RelTime, &abstime, sizeof abs20.abs_RelTime); /* Write the record into the file */ @@ -2062,13 +2066,13 @@ nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ -static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean nstrace_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -2080,18 +2084,18 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_1_0) { if (!nstrace_add_signature(wdh, err) || - !nstrace_add_abstime(wdh, phdr, pd, err)) + !nstrace_add_abstime(wdh, rec, pd, err)) return FALSE; } else if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0) { if (!nstrace_add_signature(wdh, err) || - !nstrace_add_abstime(wdh, phdr, pd, err)) + !nstrace_add_abstime(wdh, rec, pd, err)) return FALSE; } else if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_0 || wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_5 ) { if (!nstrace_add_signature(wdh, err) || - !nstrace_add_abstime(wdh, phdr, pd, err)) + !nstrace_add_abstime(wdh, rec, pd, err)) return FALSE; } else { @@ -2100,13 +2104,13 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } } - switch (phdr->pseudo_header.nstr.rec_type) + switch (rec->rec_header.packet_header.pseudo_header.nstr.rec_type) { case NSPR_HEADER_VERSION100: if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_1_0) { - if (nstrace->page_offset + phdr->caplen >= nstrace->page_len) + if (nstrace->page_offset + rec->rec_header.packet_header.caplen >= nstrace->page_len) { /* Start on the next page */ if (wtap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1) @@ -2120,10 +2124,10 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } /* Write the actual record as is */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - nstrace->page_offset += (guint16) phdr->caplen; + nstrace->page_offset += (guint16) rec->rec_header.packet_header.caplen; } else if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0) { *err = WTAP_ERR_UNWRITABLE_FILE_TYPE; @@ -2145,7 +2149,7 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, return FALSE; } else if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0) { - if (nstrace->page_offset + phdr->caplen >= nstrace->page_len) + if (nstrace->page_offset + rec->rec_header.packet_header.caplen >= nstrace->page_len) { /* Start on the next page */ if (wtap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1) @@ -2159,10 +2163,10 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } /* Write the actual record as is */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - nstrace->page_offset += (guint16) phdr->caplen; + nstrace->page_offset += (guint16) rec->rec_header.packet_header.caplen; } break; @@ -2179,7 +2183,7 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, return FALSE; } else if (wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_0 || wdh->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_5) { - if (nstrace->page_offset + phdr->caplen >= nstrace->page_len) + if (nstrace->page_offset + rec->rec_header.packet_header.caplen >= nstrace->page_len) { /* Start on the next page */ if (wtap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1) @@ -2193,10 +2197,10 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } /* Write the actual record as is */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - nstrace->page_offset += (guint16) phdr->caplen; + nstrace->page_offset += (guint16) rec->rec_header.packet_header.caplen; } else { g_assert_not_reached(); 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; } diff --git a/wiretap/nettl.c b/wiretap/nettl.c index d8ba4be23b..870a151f8f 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -164,11 +164,11 @@ typedef struct { static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean nettl_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 nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean nettl_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); -static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean nettl_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); wtap_open_return_val nettl_open(wtap *wth, int *err, gchar **err_info) @@ -265,7 +265,7 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, { /* Read record. */ *data_offset = file_tell(wth->fh); - if (!nettl_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, + if (!nettl_read_rec(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info)) { /* Read error or EOF */ return FALSE; @@ -280,9 +280,9 @@ static gboolean nettl_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; } @@ -290,14 +290,14 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, } static gboolean -nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +nettl_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read record. */ - if (!nettl_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) { + if (!nettl_read_rec(wth, wth->random_fh, rec, buf, err, err_info)) { /* Read error or EOF */ if (*err == 0) { /* EOF means "short read" in random-access mode */ @@ -309,10 +309,10 @@ nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, } static gboolean -nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +nettl_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, 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; nettl_t *nettl = (nettl_t *)wth->priv; gboolean fddihack = FALSE; struct nettlrec_hdr rec_hdr; @@ -347,7 +347,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, if ( (pntoh32(&rec_hdr.kind) & NETTL_HDR_PDU_MASK) == 0 ) { /* not actually a data packet (PDU) trace record */ - phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_IP; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_RAW_IP; length = pntoh32(&rec_hdr.length); caplen = pntoh32(&rec_hdr.caplen); padlen = 0; @@ -394,23 +394,23 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, || (subsys == NETTL_SUBSYS_NS_LS_TCP) || (subsys == NETTL_SUBSYS_NS_LS_SCTP) || (subsys == NETTL_SUBSYS_NS_LS_IPV6)) { - phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_IP; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_RAW_IP; } else if (subsys == NETTL_SUBSYS_NS_LS_ICMP) { - phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_ICMP; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_RAW_ICMP; } else if (subsys == NETTL_SUBSYS_NS_LS_ICMPV6) { - phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_ICMPV6; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_RAW_ICMPV6; } else if (subsys == NETTL_SUBSYS_NS_LS_TELNET) { - phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_TELNET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_RAW_TELNET; } else if( (subsys == NETTL_SUBSYS_HPPB_FDDI) || (subsys == NETTL_SUBSYS_EISA_FDDI) || (subsys == NETTL_SUBSYS_PCI_FDDI) || (subsys == NETTL_SUBSYS_HSC_FDDI) ) { - phdr->pkt_encap = WTAP_ENCAP_NETTL_FDDI; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_FDDI; } else if( (subsys == NETTL_SUBSYS_PCI_TR) || (subsys == NETTL_SUBSYS_TOKEN) ) { - phdr->pkt_encap = WTAP_ENCAP_NETTL_TOKEN_RING; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_TOKEN_RING; } else { - phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; } length = pntoh32(&rec_hdr.length); @@ -470,7 +470,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, /* XXX we don't know how to identify this as ethernet frames, so we assume everything is. We will crash and burn for anything else */ /* for encapsulated 100baseT we do this */ - phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; if (!wtap_read_bytes(fh, &drv_eth_hdr, NS_LS_DRV_ETH_HDR_LEN, err, err_info)) return FALSE; @@ -511,7 +511,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * * And is "from_dce" at xxa[0] in the nettlrec_hdr structure? */ - phdr->pkt_encap = WTAP_ENCAP_NETTL_X25; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_X25; length = pntoh32(&rec_hdr.length); caplen = pntoh32(&rec_hdr.caplen); padlen = 24; /* sizeof (struct nettlrec_sx25l2_hdr) - NETTL_REC_HDR_LEN + 4 */ @@ -523,7 +523,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, /* We're going to assume it's ethernet if we don't recognize the subsystem -- We'll probably spew junks and core if it isn't... */ wth->file_encap = WTAP_ENCAP_PER_PACKET; - phdr->pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_ETHERNET; length = pntoh32(&rec_hdr.length); caplen = pntoh32(&rec_hdr.caplen); padlen = 0; @@ -536,9 +536,9 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, length, padlen); return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->len = length - padlen; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->rec_header.packet_header.len = length - padlen; if (caplen < padlen) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("nettl: captured length %u in record header too short, less than %u", @@ -546,9 +546,9 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } datalen = caplen - padlen; - phdr->caplen = datalen; - phdr->ts.secs = pntoh32(&rec_hdr.sec); - phdr->ts.nsecs = pntoh32(&rec_hdr.usec) * 1000; + rec->rec_header.packet_header.caplen = datalen; + rec->ts.secs = pntoh32(&rec_hdr.sec); + rec->ts.nsecs = pntoh32(&rec_hdr.usec) * 1000; pseudo_header->nettl.subsys = subsys; pseudo_header->nettl.devid = pntoh32(&rec_hdr.devid); @@ -556,14 +556,14 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, pseudo_header->nettl.pid = pntoh32(&rec_hdr.pid); pseudo_header->nettl.uid = pntoh16(&rec_hdr.uid); - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("nettl: File has %u-byte packet, bigger than maximum of %u", - phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD); + rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } @@ -668,21 +668,21 @@ gboolean nettl_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean nettl_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; struct nettlrec_hdr rec_hdr; guint8 dummyc[24]; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* Don't write anything we're not willing to read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -691,20 +691,20 @@ static gboolean nettl_dump(wtap_dumper *wdh, /* HP-UX 11.X header should be 68 bytes */ rec_hdr.hdr_len = g_htons(sizeof(rec_hdr) + 4); rec_hdr.kind = g_htonl(NETTL_HDR_PDUIN); - rec_hdr.sec = g_htonl(phdr->ts.secs); - rec_hdr.usec = g_htonl(phdr->ts.nsecs/1000); - rec_hdr.caplen = g_htonl(phdr->caplen); - rec_hdr.length = g_htonl(phdr->len); + rec_hdr.sec = g_htonl(rec->ts.secs); + rec_hdr.usec = g_htonl(rec->ts.nsecs/1000); + rec_hdr.caplen = g_htonl(rec->rec_header.packet_header.caplen); + rec_hdr.length = g_htonl(rec->rec_header.packet_header.len); rec_hdr.devid = -1; rec_hdr.pid = -1; rec_hdr.uid = -1; - switch (phdr->pkt_encap) { + switch (rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_NETTL_FDDI: /* account for pad bytes */ - rec_hdr.caplen = g_htonl(phdr->caplen + 3); - rec_hdr.length = g_htonl(phdr->len + 3); + rec_hdr.caplen = g_htonl(rec->rec_header.packet_header.caplen + 3); + rec_hdr.length = g_htonl(rec->rec_header.packet_header.len + 3); /* fall through and fill the rest of the fields */ /* FALL THROUGH */ case WTAP_ENCAP_NETTL_ETHERNET: @@ -732,8 +732,8 @@ static gboolean nettl_dump(wtap_dumper *wdh, case WTAP_ENCAP_FDDI_BITSWAPPED: rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_FDDI); /* account for pad bytes */ - rec_hdr.caplen = g_htonl(phdr->caplen + 3); - rec_hdr.length = g_htonl(phdr->len + 3); + rec_hdr.caplen = g_htonl(rec->rec_header.packet_header.caplen + 3); + rec_hdr.length = g_htonl(rec->rec_header.packet_header.len + 3); break; case WTAP_ENCAP_TOKEN_RING: @@ -741,8 +741,8 @@ static gboolean nettl_dump(wtap_dumper *wdh, break; #if 0 case WTAP_ENCAP_NETTL_X25: - rec_hdr.caplen = g_htonl(phdr->caplen + 24); - rec_hdr.length = g_htonl(phdr->len + 24); + rec_hdr.caplen = g_htonl(rec->rec_header.packet_header.caplen + 24); + rec_hdr.length = g_htonl(rec->rec_header.packet_header.len + 24); rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys); rec_hdr.devid = g_htonl(pseudo_header->nettl.devid); rec_hdr.kind = g_htonl(pseudo_header->nettl.kind); @@ -768,15 +768,15 @@ static gboolean nettl_dump(wtap_dumper *wdh, return FALSE; wdh->bytes_dumped += 4; - if ((phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) || - (phdr->pkt_encap == WTAP_ENCAP_NETTL_FDDI)) { + if ((rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) || + (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_NETTL_FDDI)) { /* add those weird 3 bytes of padding */ if (!wtap_dump_file_write(wdh, dummyc, 3, err)) return FALSE; wdh->bytes_dumped += 3; } /* - } else if (phdr->pkt_encap == WTAP_ENCAP_NETTL_X25) { + } else if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_NETTL_X25) { if (!wtap_dump_file_write(wdh, dummyc, 24, err)) return FALSE; wdh->bytes_dumped += 24; @@ -785,9 +785,9 @@ static gboolean nettl_dump(wtap_dumper *wdh, /* write actual PDU data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; return TRUE; } diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c index e923475800..12cefccb88 100644 --- a/wiretap/nettrace_3gpp_32_423.c +++ b/wiretap/nettrace_3gpp_32_423.c @@ -157,41 +157,40 @@ nettrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) nettrace_3gpp_32_423_file_info_t *file_info = (nettrace_3gpp_32_423_file_info_t *)wth->priv; - frame_buffer_saved = file_info->wth_tmp_file->frame_buffer; - file_info->wth_tmp_file->frame_buffer = wth->frame_buffer; + frame_buffer_saved = file_info->wth_tmp_file->rec_data; + file_info->wth_tmp_file->rec_data = wth->rec_data; /* we read the created pcapng file instead */ result = wtap_read(file_info->wth_tmp_file, err, err_info, data_offset); - file_info->wth_tmp_file->frame_buffer = frame_buffer_saved; + file_info->wth_tmp_file->rec_data = frame_buffer_saved; if (!result) return result; - wth->phdr.rec_type = file_info->wth_tmp_file->phdr.rec_type; - wth->phdr.presence_flags = file_info->wth_tmp_file->phdr.presence_flags; - wth->phdr.ts = file_info->wth_tmp_file->phdr.ts; - wth->phdr.caplen = file_info->wth_tmp_file->phdr.caplen; - wth->phdr.len = file_info->wth_tmp_file->phdr.len; - wth->phdr.pkt_encap = file_info->wth_tmp_file->phdr.pkt_encap; - wth->phdr.pkt_tsprec = file_info->wth_tmp_file->phdr.pkt_tsprec; - wth->phdr.interface_id = file_info->wth_tmp_file->phdr.interface_id; - wth->phdr.opt_comment = file_info->wth_tmp_file->phdr.opt_comment; - wth->phdr.drop_count = file_info->wth_tmp_file->phdr.drop_count; - wth->phdr.pack_flags = file_info->wth_tmp_file->phdr.pack_flags; - wth->phdr.ft_specific_data = file_info->wth_tmp_file->phdr.ft_specific_data; + wth->rec.rec_type = file_info->wth_tmp_file->rec.rec_type; + wth->rec.presence_flags = file_info->wth_tmp_file->rec.presence_flags; + wth->rec.ts = file_info->wth_tmp_file->rec.ts; + wth->rec.rec_header.packet_header.caplen = file_info->wth_tmp_file->rec.rec_header.packet_header.caplen; + wth->rec.rec_header.packet_header.len = file_info->wth_tmp_file->rec.rec_header.packet_header.len; + wth->rec.rec_header.packet_header.pkt_encap = file_info->wth_tmp_file->rec.rec_header.packet_header.pkt_encap; + wth->rec.tsprec = file_info->wth_tmp_file->rec.tsprec; + wth->rec.rec_header.packet_header.interface_id = file_info->wth_tmp_file->rec.rec_header.packet_header.interface_id; + wth->rec.opt_comment = file_info->wth_tmp_file->rec.opt_comment; + wth->rec.rec_header.packet_header.drop_count = file_info->wth_tmp_file->rec.rec_header.packet_header.drop_count; + wth->rec.rec_header.packet_header.pack_flags = file_info->wth_tmp_file->rec.rec_header.packet_header.pack_flags; return result; } static gboolean -nettrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +nettrace_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct Buffer *frame_buffer_saved; gboolean result; nettrace_3gpp_32_423_file_info_t *file_info = (nettrace_3gpp_32_423_file_info_t *)wth->priv; - frame_buffer_saved = file_info->wth_tmp_file->frame_buffer; - file_info->wth_tmp_file->frame_buffer = wth->frame_buffer; + frame_buffer_saved = file_info->wth_tmp_file->rec_data; + file_info->wth_tmp_file->rec_data = wth->rec_data; - result = wtap_seek_read(file_info->wth_tmp_file, seek_off, phdr, buf, err, err_info); - file_info->wth_tmp_file->frame_buffer = frame_buffer_saved; + result = wtap_seek_read(file_info->wth_tmp_file, seek_off, rec, buf, err, err_info); + file_info->wth_tmp_file->rec_data = frame_buffer_saved; return result; } @@ -219,7 +218,7 @@ nettrace_close(wtap *wth) #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) static guint8* -nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) +nettrace_parse_begin_time(guint8 *curr_pos, wtap_rec *rec) { /* Time vars*/ guint year, month, day, hour, minute, second, ms; @@ -244,7 +243,7 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) scan_found = sscanf(curr_pos, "%4u-%2u-%2uT%2u:%2u:%2u%3d:%2u", &year, &month, &day, &hour, &minute, &second, &UTCdiffh, &UTCdiffm); - phdr->ts.nsecs = 0; + rec->ts.nsecs = 0; if (scan_found != 8) { /* Found this format in a file: * beginTime="2013-09-11T15:45:00,666+02:00"/> @@ -253,13 +252,13 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) &year, &month, &day, &hour, &minute, &second, &ms, &UTCdiffh, &UTCdiffm); if (scan_found == 9) { - phdr->ts.nsecs = ms * 1000; + rec->ts.nsecs = ms * 1000; /* Use the code below to set the time stamp */ scan_found = 8; } else { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse second time format, scan_found %u", scan_found); */ return curr_pos; } @@ -270,34 +269,34 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) /* Fill in remaining fields and return it in a time_t */ tm.tm_year = year - 1900; if (month < 1 || month > 12) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, month is %u", month); */ return curr_pos; } tm.tm_mon = month - 1; /* Zero count*/ if (day > ((month == 2 && isleap(year)) ? 29 : days_in_month[month - 1])) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, %u-%02u-%2u is not a valid day", year, month, day); */ return curr_pos; } tm.tm_mday = day; if (hour > 23) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, hour is %u", hour); */ return curr_pos; } tm.tm_hour = hour; if (minute > 59) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, minute is %u", minute); */ return curr_pos; } @@ -307,9 +306,9 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) * Yes, 60, for leap seconds - POSIX's and Windows' * refusal to believe in them nonwithstanding. */ - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, second is %u", second); */ return curr_pos; } @@ -317,21 +316,21 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) tm.tm_isdst = -1; /* daylight saving time info not known */ /* Get seconds from this time */ - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = mktime(&tm); + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = mktime(&tm); UTCdiffsec = (abs(UTCdiffh) * 60 * 60) + (UTCdiffm * 60); if (UTCdiffh < 0) { - phdr->ts.secs = phdr->ts.secs - UTCdiffsec; + rec->ts.secs = rec->ts.secs - UTCdiffsec; } else { - phdr->ts.secs = phdr->ts.secs + UTCdiffsec; + rec->ts.secs = rec->ts.secs + UTCdiffsec; } } else { /* g_warning("Failed to parse time, only %u fields", scan_found); */ - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; } return curr_pos; @@ -344,7 +343,7 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) * </rawMsg> */ static wtap_open_return_val -write_packet_data(wtap_dumper *wdh, struct wtap_pkthdr *phdr, int *err, gchar **err_info, guint8 *file_buf, time_t start_time, int ms, exported_pdu_info_t *exported_pdu_info, char name_str[64]) +write_packet_data(wtap_dumper *wdh, wtap_rec *rec, int *err, gchar **err_info, guint8 *file_buf, time_t start_time, int ms, exported_pdu_info_t *exported_pdu_info, char name_str[64]) { char *curr_pos, *next_pos; char proto_name_str[16]; @@ -653,22 +652,22 @@ write_packet_data(wtap_dumper *wdh, struct wtap_pkthdr *phdr, int *err, gchar ** curr_pos++; } /* Construct the phdr */ - memset(phdr, 0, sizeof(struct wtap_pkthdr)); - phdr->rec_type = REC_TYPE_PACKET; + memset(rec, 0, sizeof *rec); + rec->rec_type = REC_TYPE_PACKET; if (start_time == 0) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; } else { - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = start_time; - phdr->ts.nsecs = ms * 1000000; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = start_time; + rec->ts.nsecs = ms * 1000000; } - phdr->caplen = pkt_data_len + exp_pdu_tags_len; - phdr->len = pkt_data_len + exp_pdu_tags_len; + rec->rec_header.packet_header.caplen = pkt_data_len + exp_pdu_tags_len; + rec->rec_header.packet_header.len = pkt_data_len + exp_pdu_tags_len; - if (!wtap_dump(wdh, phdr, packet_buf, err, err_info)) { + if (!wtap_dump(wdh, rec, packet_buf, err, err_info)) { switch (*err) { case WTAP_ERR_UNWRITABLE_REC_DATA: @@ -711,7 +710,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ guint8 *packet_buf = NULL; int wrt_err; gchar *wrt_err_info = NULL; - struct wtap_pkthdr phdr; + wtap_rec rec; time_t start_time; int scan_found; unsigned second, ms; @@ -842,8 +841,8 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ /* Null-terminate buffer; we'll be processing it as a string. */ packet_buf[packet_size + 12] = '\0'; - /* Create the packet header */ - memset(&phdr, 0, sizeof(struct wtap_pkthdr)); + /* Create the record header */ + memset(&rec, 0, sizeof rec); /* Read the file header of the input file, currently we only need the beginTime*/ @@ -857,18 +856,18 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ curr_pos = strstr(curr_pos, "<traceCollec beginTime=\""); curr_pos = curr_pos + 24; - curr_pos = nettrace_parse_begin_time(curr_pos, &phdr); + curr_pos = nettrace_parse_begin_time(curr_pos, &rec); - start_time = phdr.ts.secs; + start_time = rec.ts.secs; - /* set rest of the pkt hdr data */ - phdr.rec_type = REC_TYPE_PACKET; + /* set rest of the record hdr data */ + rec.rec_type = REC_TYPE_PACKET; - phdr.caplen = packet_size + 12; - phdr.len = packet_size + 12; + rec.rec_header.packet_header.caplen = packet_size + 12; + rec.rec_header.packet_header.len = packet_size + 12; /* XXX: report errors! */ - if (!wtap_dump(wdh_exp_pdu, &phdr, packet_buf, &wrt_err, &wrt_err_info)) { + if (!wtap_dump(wdh_exp_pdu, &rec, packet_buf, &wrt_err, &wrt_err_info)) { switch (wrt_err) { case WTAP_ERR_UNWRITABLE_REC_DATA: @@ -1035,7 +1034,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ } curr_pos = curr_pos + 7; /* Add the raw msg*/ - temp_val = write_packet_data(wdh_exp_pdu, &phdr, &wrt_err, &wrt_err_info, curr_pos, start_time, ms, &exported_pdu_info, name_str); + temp_val = write_packet_data(wdh_exp_pdu, &rec, &wrt_err, &wrt_err_info, curr_pos, start_time, ms, &exported_pdu_info, name_str); if (temp_val != WTAP_OPEN_MINE){ result = temp_val; goto end; diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index c0d24138c3..8e495c9c43 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -104,17 +104,17 @@ static const char *init_gmt_to_localtime_offset(void) static gboolean observer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean observer_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 int read_packet_header(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header, packet_entry_header *packet_header, int *err, gchar **err_info); static gboolean process_packet_header(wtap *wth, - packet_entry_header *packet_header, struct wtap_pkthdr *phdr, int *err, + packet_entry_header *packet_header, wtap_rec *rec, int *err, gchar **err_info); static int read_packet_data(FILE_T fh, int offset_to_frame, int current_offset_from_packet_header, Buffer *buf, int length, int *err, char **err_info); static gboolean skip_to_next_packet(wtap *wth, int offset_to_next_packet, int current_offset_from_packet_header, int *err, char **err_info); -static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean observer_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gint observer_to_wtap_encap(int observer_encap); static gint wtap_to_observer_encap(int wtap_encap); @@ -273,7 +273,7 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* process the packet header, including TLVs */ - header_bytes_consumed = read_packet_header(wth, wth->fh, &wth->phdr.pseudo_header, &packet_header, err, + header_bytes_consumed = read_packet_header(wth, wth->fh, &wth->rec.rec_header.packet_header.pseudo_header, &packet_header, err, err_info); if (header_bytes_consumed <= 0) return FALSE; /* EOF or error */ @@ -288,13 +288,13 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, } } - if (!process_packet_header(wth, &packet_header, &wth->phdr, err, err_info)) + if (!process_packet_header(wth, &packet_header, &wth->rec, err, err_info)) return FALSE; /* read the frame data */ data_bytes_consumed = read_packet_data(wth->fh, packet_header.offset_to_frame, - header_bytes_consumed, wth->frame_buffer, - wth->phdr.caplen, err, err_info); + header_bytes_consumed, wth->rec_data, + wth->rec.rec_header.packet_header.caplen, err, err_info); if (data_bytes_consumed < 0) { return FALSE; } @@ -310,9 +310,9 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, /* Reads a packet at an offset. */ static gboolean observer_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) { - union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; packet_entry_header packet_header; int offset; int data_bytes_consumed; @@ -326,12 +326,12 @@ static gboolean observer_seek_read(wtap *wth, gint64 seek_off, if (offset <= 0) return FALSE; /* EOF or error */ - if (!process_packet_header(wth, &packet_header, phdr, err, err_info)) + if (!process_packet_header(wth, &packet_header, rec, err, err_info)) return FALSE; /* read the frame data */ data_bytes_consumed = read_packet_data(wth->random_fh, packet_header.offset_to_frame, - offset, buf, phdr->caplen, err, err_info); + offset, buf, rec->rec_header.packet_header.caplen, err, err_info); if (data_bytes_consumed < 0) { return FALSE; } @@ -451,15 +451,15 @@ read_packet_header(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header static gboolean process_packet_header(wtap *wth, packet_entry_header *packet_header, - struct wtap_pkthdr *phdr, int *err, gchar **err_info) + wtap_rec *rec, int *err, gchar **err_info) { - /* set the wiretap packet header fields */ - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->pkt_encap = observer_to_wtap_encap(packet_header->network_type); + /* set the wiretap record metadata fields */ + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->rec_header.packet_header.pkt_encap = observer_to_wtap_encap(packet_header->network_type); if(wth->file_encap == WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS) { - phdr->len = packet_header->network_size; - phdr->caplen = packet_header->captured_size; + rec->rec_header.packet_header.len = packet_header->network_size; + rec->rec_header.packet_header.caplen = packet_header->captured_size; } else { /* * XXX - what are those 4 bytes? @@ -488,8 +488,8 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header, return FALSE; } - phdr->len = packet_header->network_size - 4; - phdr->caplen = MIN(packet_header->captured_size, phdr->len); + rec->rec_header.packet_header.len = packet_header->network_size - 4; + rec->rec_header.packet_header.caplen = MIN(packet_header->captured_size, rec->rec_header.packet_header.len); } /* * The maximum value of packet_header->captured_size is 65535, which @@ -498,8 +498,8 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header, */ /* set the wiretap timestamp, assuming for the moment that Observer encoded it in GMT */ - phdr->ts.secs = (time_t) ((packet_header->nano_seconds_since_2000 / 1000000000) + ansi_to_observer_epoch_offset); - phdr->ts.nsecs = (int) (packet_header->nano_seconds_since_2000 % 1000000000); + rec->ts.secs = (time_t) ((packet_header->nano_seconds_since_2000 / 1000000000) + ansi_to_observer_epoch_offset); + rec->ts.nsecs = (int) (packet_header->nano_seconds_since_2000 % 1000000000); /* adjust to local time, if necessary, also accounting for DST if the frame was captured while it was in effect */ @@ -512,17 +512,17 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header, /* the Observer timestamp was encoded as local time, so add a correction from local time to GMT */ - phdr->ts.secs += gmt_to_localtime_offset; + rec->ts.secs += gmt_to_localtime_offset; /* perform a DST adjustment if necessary */ - tm = localtime(&phdr->ts.secs); + tm = localtime(&rec->ts.secs); if (tm != NULL) { standard_tm = *tm; if (standard_tm.tm_isdst > 0) { daylight_tm = standard_tm; standard_tm.tm_isdst = 0; dst_offset = mktime(&standard_tm) - mktime(&daylight_tm); - phdr->ts.secs -= dst_offset; + rec->ts.secs -= dst_offset; } } } @@ -700,7 +700,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ -static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean observer_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { @@ -709,28 +709,28 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, guint64 seconds_since_2000; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* The captured size field is 16 bits, so there's a hard limit of 65535. */ - if (phdr->caplen > 65535) { + if (rec->rec_header.packet_header.caplen > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } /* convert the number of seconds since epoch from ANSI-relative to Observer-relative */ - if (phdr->ts.secs < ansi_to_observer_epoch_offset) { - if(phdr->ts.secs > (time_t) 0) { - seconds_since_2000 = phdr->ts.secs; + if (rec->ts.secs < ansi_to_observer_epoch_offset) { + if(rec->ts.secs > (time_t) 0) { + seconds_since_2000 = rec->ts.secs; } else { seconds_since_2000 = (time_t) 0; } } else { - seconds_since_2000 = phdr->ts.secs - ansi_to_observer_epoch_offset; + seconds_since_2000 = rec->ts.secs - ansi_to_observer_epoch_offset; } /* populate the fields of the packet header */ @@ -739,18 +739,18 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, memset(&packet_header, 0x00, sizeof(packet_header)); packet_header.packet_magic = observer_packet_magic; packet_header.network_speed = 1000000; - packet_header.captured_size = (guint16) phdr->caplen; - packet_header.network_size = (guint16) (phdr->len + 4); + packet_header.captured_size = (guint16) rec->rec_header.packet_header.caplen; + packet_header.network_size = (guint16) (rec->rec_header.packet_header.len + 4); packet_header.offset_to_frame = sizeof(packet_header); /* XXX - what if this doesn't fit in 16 bits? It's not guaranteed to... */ - packet_header.offset_to_next_packet = (guint16)sizeof(packet_header) + phdr->caplen; + packet_header.offset_to_next_packet = (guint16)sizeof(packet_header) + rec->rec_header.packet_header.caplen; packet_header.network_type = private_state->network_type; packet_header.flags = 0x00; packet_header.number_of_information_elements = 0; packet_header.packet_type = PACKET_TYPE_DATA_PACKET; packet_header.packet_number = private_state->packet_count; packet_header.original_packet_number = packet_header.packet_number; - packet_header.nano_seconds_since_2000 = seconds_since_2000 * 1000000000 + phdr->ts.nsecs; + packet_header.nano_seconds_since_2000 = seconds_since_2000 * 1000000000 + rec->ts.nsecs; private_state->packet_count++; @@ -762,10 +762,10 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, wdh->bytes_dumped += sizeof(packet_header); /* write the packet data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) { + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) { return FALSE; } - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; return TRUE; } diff --git a/wiretap/netxray.c b/wiretap/netxray.c index baaf7533ea..af2c5f3109 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -392,17 +392,17 @@ typedef struct { static gboolean netxray_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean netxray_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 int netxray_process_rec_header(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, int *err, gchar **err_info); -static void netxray_guess_atm_type(wtap *wth, struct wtap_pkthdr *phdr, + wtap_rec *rec, int *err, gchar **err_info); +static void netxray_guess_atm_type(wtap *wth, wtap_rec *rec, Buffer *buf); static gboolean netxray_dump_1_1(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gboolean netxray_dump_finish_1_1(wtap_dumper *wdh, int *err); static gboolean netxray_dump_2_0(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gboolean netxray_dump_finish_2_0(wtap_dumper *wdh, int *err); @@ -988,7 +988,7 @@ reread: } /* Read and process record header. */ - padding = netxray_process_rec_header(wth, wth->fh, &wth->phdr, err, + padding = netxray_process_rec_header(wth, wth->fh, &wth->rec, err, err_info); if (padding < 0) { /* @@ -1042,8 +1042,8 @@ reread: /* * Read the packet data. */ - if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, - wth->phdr.caplen, err, err_info)) + if (!wtap_read_packet_bytes(wth->fh, wth->rec_data, + wth->rec.rec_header.packet_header.caplen, err, err_info)) return FALSE; /* @@ -1057,19 +1057,19 @@ reread: * from the packet header to determine its type or subtype, * attempt to guess them from the packet data. */ - netxray_guess_atm_type(wth, &wth->phdr, wth->frame_buffer); + netxray_guess_atm_type(wth, &wth->rec, wth->rec_data); return TRUE; } static gboolean netxray_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (netxray_process_rec_header(wth, wth->random_fh, phdr, err, + if (netxray_process_rec_header(wth, wth->random_fh, rec, err, err_info) == -1) { if (*err == 0) { /* @@ -1085,7 +1085,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off, /* * Read the packet data. */ - if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, + if (!wtap_read_packet_bytes(wth->random_fh, buf, rec->rec_header.packet_header.caplen, err, err_info)) return FALSE; @@ -1094,12 +1094,12 @@ netxray_seek_read(wtap *wth, gint64 seek_off, * from the packet header to determine its type or subtype, * attempt to guess them from the packet data. */ - netxray_guess_atm_type(wth, phdr, buf); + netxray_guess_atm_type(wth, rec, buf); return TRUE; } static int -netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +netxray_process_rec_header(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, gchar **err_info) { netxray_t *netxray = (netxray_t *)wth->priv; @@ -1156,7 +1156,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * * For now, we just say "no FCS". */ - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; } break; @@ -1187,7 +1187,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, /* * FCS. */ - phdr->pseudo_header.eth.fcs_len = 4; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 4; } else { /* * Junk. @@ -1195,7 +1195,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, padding = 4; } } else - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; case WTAP_ENCAP_IEEE_802_11_WITH_RADIO: @@ -1218,7 +1218,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * Ken also says that xxx[11] is 0x5 when the * packet is WEP-encrypted. */ - memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11)); + memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11)); if (hdr.hdr_2_x.xxx[2] == 0xff && hdr.hdr_2_x.xxx[3] == 0xff) { /* @@ -1229,7 +1229,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, /* * FCS. */ - phdr->pseudo_header.ieee_802_11.fcs_len = 4; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = 4; } else { /* * Junk. @@ -1237,27 +1237,27 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, padding = 4; } } else - phdr->pseudo_header.ieee_802_11.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = 0; - phdr->pseudo_header.ieee_802_11.decrypted = FALSE; - phdr->pseudo_header.ieee_802_11.datapad = FALSE; - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; /* * XXX - any other information, such as PHY * type, frequency, 11n/11ac information, * etc.? */ - phdr->pseudo_header.ieee_802_11.has_channel = TRUE; - phdr->pseudo_header.ieee_802_11.channel = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel = hdr.hdr_2_x.xxx[12]; - phdr->pseudo_header.ieee_802_11.has_data_rate = TRUE; - phdr->pseudo_header.ieee_802_11.data_rate = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate = hdr.hdr_2_x.xxx[13]; - phdr->pseudo_header.ieee_802_11.has_signal_percent = TRUE; - phdr->pseudo_header.ieee_802_11.signal_percent = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent = hdr.hdr_2_x.xxx[14]; /* @@ -1267,8 +1267,8 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * from 0x00 to 0x7F for 0 to 100%. */ if (hdr.hdr_2_x.xxx[15] != 0xFF) { - phdr->pseudo_header.ieee_802_11.has_noise_percent = TRUE; - phdr->pseudo_header.ieee_802_11.noise_percent = + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_noise_percent = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.noise_percent = hdr.hdr_2_x.xxx[15]*100/127; } break; @@ -1285,9 +1285,9 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * required for PRI. (Is it really just the time * slot?) */ - phdr->pseudo_header.isdn.uton = + rec->rec_header.packet_header.pseudo_header.isdn.uton = (hdr.hdr_2_x.xxx[12] & 0x01); - phdr->pseudo_header.isdn.channel = + rec->rec_header.packet_header.pseudo_header.isdn.channel = hdr.hdr_2_x.xxx[13] & 0x1F; switch (netxray->isdn_type) { @@ -1299,10 +1299,10 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * numbers 17 through 31 are B16 through * B31. */ - if (phdr->pseudo_header.isdn.channel == 16) - phdr->pseudo_header.isdn.channel = 0; - else if (phdr->pseudo_header.isdn.channel > 16) - phdr->pseudo_header.isdn.channel -= 1; + if (rec->rec_header.packet_header.pseudo_header.isdn.channel == 16) + rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; + else if (rec->rec_header.packet_header.pseudo_header.isdn.channel > 16) + rec->rec_header.packet_header.pseudo_header.isdn.channel -= 1; break; case 2: @@ -1311,10 +1311,10 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * are the D channel; channel numbers 1 * through 23 are B1 through B23. */ - if (phdr->pseudo_header.isdn.channel == 24) - phdr->pseudo_header.isdn.channel = 0; - else if (phdr->pseudo_header.isdn.channel > 24) - phdr->pseudo_header.isdn.channel -= 1; + if (rec->rec_header.packet_header.pseudo_header.isdn.channel == 24) + rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; + else if (rec->rec_header.packet_header.pseudo_header.isdn.channel > 24) + rec->rec_header.packet_header.pseudo_header.isdn.channel -= 1; break; } @@ -1350,7 +1350,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * is the direction flag. (Probably true for other * HDLC encapsulations as well.) */ - phdr->pseudo_header.x25.flags = + rec->rec_header.packet_header.pseudo_header.x25.flags = (hdr.hdr_2_x.xxx[12] & 0x01) ? 0x00 : FROM_DCE; /* @@ -1379,7 +1379,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, case WTAP_ENCAP_PPP_WITH_PHDR: case WTAP_ENCAP_SDLC: case WTAP_ENCAP_CHDLC_WITH_PHDR: - phdr->pseudo_header.p2p.sent = + rec->rec_header.packet_header.pseudo_header.p2p.sent = (hdr.hdr_2_x.xxx[12] & 0x01) ? TRUE : FALSE; break; @@ -1426,9 +1426,9 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * What happens if a reassembly fails because * a cell is bad? */ - phdr->pseudo_header.atm.flags = 0; + rec->rec_header.packet_header.pseudo_header.atm.flags = 0; if (hdr.hdr_2_x.xxx[8] & 0x01) - phdr->pseudo_header.atm.flags |= ATM_REASSEMBLY_ERROR; + rec->rec_header.packet_header.pseudo_header.atm.flags |= ATM_REASSEMBLY_ERROR; /* * XXX - is 0x08 an "OAM cell" flag? * Are the 0x01 and 0x02 bits error indications? @@ -1448,12 +1448,12 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * flag field? */ if (hdr.hdr_2_x.xxx[9] & 0x04) - phdr->pseudo_header.atm.flags |= ATM_RAW_CELL; - phdr->pseudo_header.atm.vpi = hdr.hdr_2_x.xxx[11]; - phdr->pseudo_header.atm.vci = pletoh16(&hdr.hdr_2_x.xxx[12]); - phdr->pseudo_header.atm.channel = + rec->rec_header.packet_header.pseudo_header.atm.flags |= ATM_RAW_CELL; + rec->rec_header.packet_header.pseudo_header.atm.vpi = hdr.hdr_2_x.xxx[11]; + rec->rec_header.packet_header.pseudo_header.atm.vci = pletoh16(&hdr.hdr_2_x.xxx[12]); + rec->rec_header.packet_header.pseudo_header.atm.channel = (hdr.hdr_2_x.xxx[15] & 0x10)? 1 : 0; - phdr->pseudo_header.atm.cells = 0; + rec->rec_header.packet_header.pseudo_header.atm.cells = 0; /* * XXX - the uppermost bit of hdr_2_xxx[0] @@ -1464,34 +1464,34 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, switch (hdr.hdr_2_x.xxx[0] & 0x70) { case 0x00: /* Unknown */ - phdr->pseudo_header.atm.aal = AAL_UNKNOWN; - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x10: /* XXX - AAL1? */ - phdr->pseudo_header.atm.aal = AAL_UNKNOWN; - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x20: /* XXX - AAL2? */ - phdr->pseudo_header.atm.aal = AAL_UNKNOWN; - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x40: /* XXX - AAL3/4? */ - phdr->pseudo_header.atm.aal = AAL_UNKNOWN; - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x30: /* XXX - AAL5 cells seen with this */ case 0x50: /* AAL5 (including signalling) */ case 0x60: /* XXX - AAL5 cells seen with this */ case 0x70: /* XXX - AAL5 cells seen with this */ - phdr->pseudo_header.atm.aal = AAL_5; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_5; /* * XXX - is the 0x08 bit of hdr_2_x.xxx[0] * a flag? I've not yet seen a case where @@ -1501,14 +1501,14 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, case 0x01: case 0x02: /* Signalling traffic */ - phdr->pseudo_header.atm.aal = AAL_SIGNALLING; - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x03: /* ILMI */ - phdr->pseudo_header.atm.type = TRAF_ILMI; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_ILMI; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x00: @@ -1557,18 +1557,18 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * with type 0x70 and subtype 0x00, * both of which were LANE 802.3. */ - phdr->pseudo_header.atm.type = TRAF_LANE; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LANE; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x06: /* XXX - not seen yet */ - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; break; case 0x07: /* LLC multiplexed */ - phdr->pseudo_header.atm.type = TRAF_LLCMX; /* XXX */ - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; /* XXX */ + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LLCMX; /* XXX */ + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; /* XXX */ break; } break; @@ -1578,66 +1578,66 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, break; } - phdr->rec_type = REC_TYPE_PACKET; + rec->rec_type = REC_TYPE_PACKET; if (netxray->version_major == 0) { - phdr->presence_flags = WTAP_HAS_TS; + rec->presence_flags = WTAP_HAS_TS; t = (double)pletoh32(&hdr.old_hdr.timelo) + (double)pletoh32(&hdr.old_hdr.timehi)*4294967296.0; t /= netxray->ticks_per_sec; t -= netxray->start_timestamp; - phdr->ts.secs = netxray->start_time + (long)t; - phdr->ts.nsecs = (int)((t-(double)(unsigned long)(t)) + rec->ts.secs = netxray->start_time + (long)t; + rec->ts.nsecs = (int)((t-(double)(unsigned long)(t)) *1.0e9); /* * We subtract the padding from the packet size, so our caller * doesn't see it. */ packet_size = pletoh16(&hdr.old_hdr.len); - phdr->caplen = packet_size - padding; - phdr->len = phdr->caplen; + rec->rec_header.packet_header.caplen = packet_size - padding; + rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen; } else { - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; t = (double)pletoh32(&hdr.hdr_1_x.timelo) + (double)pletoh32(&hdr.hdr_1_x.timehi)*4294967296.0; t /= netxray->ticks_per_sec; t -= netxray->start_timestamp; - phdr->ts.secs = netxray->start_time + (time_t)t; - phdr->ts.nsecs = (int)((t-(double)(unsigned long)(t)) + rec->ts.secs = netxray->start_time + (time_t)t; + rec->ts.nsecs = (int)((t-(double)(unsigned long)(t)) *1.0e9); /* * We subtract the padding from the packet size, so our caller * doesn't see it. */ packet_size = pletoh16(&hdr.hdr_1_x.incl_len); - phdr->caplen = packet_size - padding; - phdr->len = pletoh16(&hdr.hdr_1_x.orig_len) - padding; + rec->rec_header.packet_header.caplen = packet_size - padding; + rec->rec_header.packet_header.len = pletoh16(&hdr.hdr_1_x.orig_len) - padding; } return padding; } static void -netxray_guess_atm_type(wtap *wth, struct wtap_pkthdr *phdr, Buffer *buf) +netxray_guess_atm_type(wtap *wth, wtap_rec *rec, Buffer *buf) { const guint8 *pd; if (wth->file_encap == WTAP_ENCAP_ATM_PDUS_UNTRUNCATED && - !(phdr->pseudo_header.atm.flags & ATM_REASSEMBLY_ERROR)) { - if (phdr->pseudo_header.atm.aal == AAL_UNKNOWN) { + !(rec->rec_header.packet_header.pseudo_header.atm.flags & ATM_REASSEMBLY_ERROR)) { + if (rec->rec_header.packet_header.pseudo_header.atm.aal == AAL_UNKNOWN) { /* * Try to guess the type and subtype based * on the VPI/VCI and packet contents. */ pd = ws_buffer_start_ptr(buf); - atm_guess_traffic_type(phdr, pd); - } else if (phdr->pseudo_header.atm.aal == AAL_5 && - phdr->pseudo_header.atm.type == TRAF_LANE) { + atm_guess_traffic_type(rec, pd); + } else if (rec->rec_header.packet_header.pseudo_header.atm.aal == AAL_5 && + rec->rec_header.packet_header.pseudo_header.atm.type == TRAF_LANE) { /* * Try to guess the subtype based on the * packet contents. */ pd = ws_buffer_start_ptr(buf); - atm_guess_lane_type(phdr, pd); + atm_guess_lane_type(rec, pd); } } } @@ -1719,7 +1719,7 @@ netxray_dump_open_1_1(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean netxray_dump_1_1(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv; @@ -1728,14 +1728,14 @@ netxray_dump_1_1(wtap_dumper *wdh, struct netxrayrec_1_x_hdr rec_hdr; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* The captured length field is 16 bits, so there's a hard limit of 65535. */ - if (phdr->caplen > 65535) { + if (rec->rec_header.packet_header.caplen > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -1752,28 +1752,28 @@ netxray_dump_1_1(wtap_dumper *wdh, the stamp of the first packet with the microseconds part 0. */ if (netxray->first_frame) { netxray->first_frame = FALSE; - netxray->start = phdr->ts; + netxray->start = rec->ts; } /* build the header for each packet */ memset(&rec_hdr, '\0', sizeof(rec_hdr)); - timestamp = ((guint64)phdr->ts.secs - (guint64)netxray->start.secs)*1000000 - + ((guint64)phdr->ts.nsecs)/1000; + timestamp = ((guint64)rec->ts.secs - (guint64)netxray->start.secs)*1000000 + + ((guint64)rec->ts.nsecs)/1000; t32 = (guint32)(timestamp%G_GINT64_CONSTANT(4294967296)); rec_hdr.timelo = GUINT32_TO_LE(t32); t32 = (guint32)(timestamp/G_GINT64_CONSTANT(4294967296)); rec_hdr.timehi = GUINT32_TO_LE(t32); - rec_hdr.orig_len = GUINT16_TO_LE(phdr->len); - rec_hdr.incl_len = GUINT16_TO_LE(phdr->caplen); + rec_hdr.orig_len = GUINT16_TO_LE(rec->rec_header.packet_header.len); + rec_hdr.incl_len = GUINT16_TO_LE(rec->rec_header.packet_header.caplen); if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof(rec_hdr), err)) return FALSE; wdh->bytes_dumped += sizeof(rec_hdr); /* write the packet data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; netxray->nframes++; @@ -1897,23 +1897,23 @@ netxray_dump_open_2_0(wtap_dumper *wdh, int *err) Returns TRUE on success, FALSE on failure. */ static gboolean netxray_dump_2_0(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv; guint64 timestamp; guint32 t32; struct netxrayrec_2_x_hdr rec_hdr; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* Don't write anything we're not willing to read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -1930,21 +1930,21 @@ netxray_dump_2_0(wtap_dumper *wdh, the stamp of the first packet with the microseconds part 0. */ if (netxray->first_frame) { netxray->first_frame = FALSE; - netxray->start = phdr->ts; + netxray->start = rec->ts; } /* build the header for each packet */ memset(&rec_hdr, '\0', sizeof(rec_hdr)); - timestamp = ((guint64)phdr->ts.secs - (guint64)netxray->start.secs)*1000000 - + ((guint64)phdr->ts.nsecs)/1000; + timestamp = ((guint64)rec->ts.secs - (guint64)netxray->start.secs)*1000000 + + ((guint64)rec->ts.nsecs)/1000; t32 = (guint32)(timestamp%G_GINT64_CONSTANT(4294967296)); rec_hdr.timelo = GUINT32_TO_LE(t32); t32 = (guint32)(timestamp/G_GINT64_CONSTANT(4294967296)); rec_hdr.timehi = GUINT32_TO_LE(t32); - rec_hdr.orig_len = GUINT16_TO_LE(phdr->len); - rec_hdr.incl_len = GUINT16_TO_LE(phdr->caplen); + rec_hdr.orig_len = GUINT16_TO_LE(rec->rec_header.packet_header.len); + rec_hdr.incl_len = GUINT16_TO_LE(rec->rec_header.packet_header.caplen); - switch (phdr->pkt_encap) { + switch (rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_IEEE_802_11_WITH_RADIO: rec_hdr.xxx[12] = @@ -1980,9 +1980,9 @@ netxray_dump_2_0(wtap_dumper *wdh, wdh->bytes_dumped += sizeof(rec_hdr); /* write the packet data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; netxray->nframes++; diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index fa28d13dce..a7f9f3261e 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -498,9 +498,9 @@ static int process_rec_header2_v145(wtap *wth, unsigned char *buffer, static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean ngsniffer_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 int ngsniffer_process_record(wtap *wth, gboolean is_random, - guint *padding, struct wtap_pkthdr *phdr, Buffer *buf, int *err, + guint *padding, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static void set_pseudo_header_frame2(wtap *wth, union wtap_pseudo_header *pseudo_header, struct frame2_rec *frame2); @@ -513,7 +513,7 @@ static int fix_pseudo_header(int encap, Buffer *buf, int len, union wtap_pseudo_header *pseudo_header); static void ngsniffer_sequential_close(wtap *wth); static void ngsniffer_close(wtap *wth); -static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean ngsniffer_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gboolean ngsniffer_dump_finish(wtap_dumper *wdh, int *err); static int SnifferDecompress( unsigned char * inbuf, size_t inlen, @@ -1025,7 +1025,7 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) * Process the record. */ ret = ngsniffer_process_record(wth, FALSE, &padding, - &wth->phdr, wth->frame_buffer, err, err_info); + &wth->rec, wth->rec_data, err, err_info); if (ret < 0) { /* Read error or short read */ return FALSE; @@ -1076,14 +1076,14 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) static gboolean ngsniffer_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) { int ret; if (!ng_file_seek_rand(wth, seek_off, err, err_info)) return FALSE; - ret = ngsniffer_process_record(wth, TRUE, NULL, phdr, buf, err, err_info); + ret = ngsniffer_process_record(wth, TRUE, NULL, rec, buf, err, err_info); if (ret < 0) { /* Read error or short read */ return FALSE; @@ -1118,7 +1118,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off, */ static int ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { ngsniffer_t *ngsniffer; char record_type[2]; @@ -1179,7 +1179,7 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, rec_length_remaining -= (guint)sizeof frame2; /* we already read that much */ - set_pseudo_header_frame2(wth, &phdr->pseudo_header, &frame2); + set_pseudo_header_frame2(wth, &rec->rec_header.packet_header.pseudo_header, &frame2); break; case REC_FRAME4: @@ -1223,7 +1223,7 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, rec_length_remaining -= (guint)sizeof frame4; /* we already read that much */ - set_pseudo_header_frame4(&phdr->pseudo_header, &frame4); + set_pseudo_header_frame4(&rec->rec_header.packet_header.pseudo_header, &frame4); break; case REC_FRAME6: @@ -1247,7 +1247,7 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, rec_length_remaining -= (guint)sizeof frame6; /* we already read that much */ - set_pseudo_header_frame6(wth, &phdr->pseudo_header, &frame6); + set_pseudo_header_frame6(wth, &rec->rec_header.packet_header.pseudo_header, &frame6); break; case REC_EOF: @@ -1300,10 +1300,10 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, *padding = rec_length_remaining - size; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = true_size ? WTAP_HAS_TS|WTAP_HAS_CAP_LEN : WTAP_HAS_TS; - phdr->len = true_size ? true_size : size; - phdr->caplen = size; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = true_size ? WTAP_HAS_TS|WTAP_HAS_CAP_LEN : WTAP_HAS_TS; + rec->rec_header.packet_header.len = true_size ? true_size : size; + rec->rec_header.packet_header.caplen = size; /* * Read the packet data. @@ -1313,8 +1313,8 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, err, err_info)) return -1; - phdr->pkt_encap = fix_pseudo_header(wth->file_encap, - buf, size, &phdr->pseudo_header); + rec->rec_header.packet_header.pkt_encap = fix_pseudo_header(wth->file_encap, + buf, size, &rec->rec_header.packet_header.pseudo_header); /* * 40-bit time stamp, in units of timeunit picoseconds. @@ -1344,8 +1344,8 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, */ tsecs += ngsniffer->start; - phdr->ts.secs = (time_t)tsecs; - phdr->ts.nsecs = (int)(tpsecs/1000); /* psecs to nsecs */ + rec->ts.secs = (time_t)tsecs; + rec->ts.nsecs = (int)(tpsecs/1000); /* psecs to nsecs */ return rec_type; /* success */ } @@ -2004,10 +2004,10 @@ ngsniffer_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean -ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +ngsniffer_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; ngsniffer_dump_t *ngsniffer = (ngsniffer_dump_t *)wdh->priv; struct frame2_rec rec_hdr; char buf[6]; @@ -2021,14 +2021,14 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, struct tm *tm; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* The captured length field is 16 bits, so there's a hard limit of 65535. */ - if (phdr->caplen > 65535) { + if (rec->rec_header.packet_header.caplen > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -2039,13 +2039,13 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, date. */ if (ngsniffer->first_frame) { ngsniffer->first_frame=FALSE; - tm = localtime(&phdr->ts.secs); + tm = localtime(&rec->ts.secs); if (tm != NULL && tm->tm_year >= DOS_YEAR_OFFSET) { start_date = (tm->tm_year - DOS_YEAR_OFFSET) << DOS_YEAR_SHIFT; start_date |= (tm->tm_mon - DOS_MONTH_OFFSET) << DOS_MONTH_SHIFT; start_date |= tm->tm_mday << DOS_DAY_SHIFT; /* record the start date, not the start time */ - ngsniffer->start = phdr->ts.secs - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec); + ngsniffer->start = rec->ts.secs - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec); } else { start_date = 0; ngsniffer->start = 0; @@ -2072,20 +2072,20 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, buf[0] = REC_FRAME2; buf[1] = 0x00; - buf[2] = (char)((phdr->caplen + sizeof(struct frame2_rec))%256); - buf[3] = (char)((phdr->caplen + sizeof(struct frame2_rec))/256); + buf[2] = (char)((rec->rec_header.packet_header.caplen + sizeof(struct frame2_rec))%256); + buf[3] = (char)((rec->rec_header.packet_header.caplen + sizeof(struct frame2_rec))/256); buf[4] = 0x00; buf[5] = 0x00; if (!wtap_dump_file_write(wdh, buf, 6, err)) return FALSE; /* Seconds since the start of the capture */ - tsecs = phdr->ts.secs - ngsniffer->start; + tsecs = rec->ts.secs - ngsniffer->start; /* Extract the number of days since the start of the capture */ rec_hdr.time_day = (guint8)(tsecs / 86400); /* # days of capture - 86400 secs/day */ tsecs -= rec_hdr.time_day * 86400; /* time within day */ /* Convert to picoseconds */ t = tsecs*G_GUINT64_CONSTANT(1000000000000) + - phdr->ts.nsecs*G_GUINT64_CONSTANT(1000); + rec->ts.nsecs*G_GUINT64_CONSTANT(1000); /* Convert to units of timeunit = 1 */ t /= Psec[1]; t_low = (guint16)((t >> 0) & 0xFFFF); @@ -2094,7 +2094,7 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, rec_hdr.time_low = GUINT16_TO_LE(t_low); rec_hdr.time_med = GUINT16_TO_LE(t_med); rec_hdr.time_high = t_high; - rec_hdr.size = GUINT16_TO_LE(phdr->caplen); + rec_hdr.size = GUINT16_TO_LE(rec->rec_header.packet_header.caplen); switch (wdh->encap) { case WTAP_ENCAP_LAPB: @@ -2130,11 +2130,11 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, break; } rec_hdr.flags = 0; - rec_hdr.true_size = phdr->len != phdr->caplen ? GUINT16_TO_LE(phdr->len) : 0; + rec_hdr.true_size = rec->rec_header.packet_header.len != rec->rec_header.packet_header.caplen ? GUINT16_TO_LE(rec->rec_header.packet_header.len) : 0; rec_hdr.rsvd = 0; if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err)) return FALSE; - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; return TRUE; } diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c index e262f3ae0c..aca3bc40ee 100644 --- a/wiretap/packetlogger.c +++ b/wiretap/packetlogger.c @@ -34,12 +34,12 @@ typedef struct packetlogger_header { static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, gboolean little_endian, int *err, gchar **err_info); -static gboolean packetlogger_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean packetlogger_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); @@ -108,18 +108,18 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); - return packetlogger_read_packet(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + return packetlogger_read_packet(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); } static gboolean -packetlogger_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +packetlogger_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if(!packetlogger_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) { + if(!packetlogger_read_packet(wth, wth->random_fh, rec, buf, err, err_info)) { if(*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -154,7 +154,7 @@ packetlogger_read_header(packetlogger_header_t *pl_hdr, FILE_T fh, } static gboolean -packetlogger_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +packetlogger_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { packetlogger_t *packetlogger = (packetlogger_t *)wth->priv; @@ -180,16 +180,16 @@ packetlogger_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; - phdr->len = pl_hdr.len - 8; - phdr->caplen = pl_hdr.len - 8; + rec->rec_header.packet_header.len = pl_hdr.len - 8; + rec->rec_header.packet_header.caplen = pl_hdr.len - 8; - phdr->ts.secs = (time_t)pl_hdr.ts_secs; - phdr->ts.nsecs = (int)(pl_hdr.ts_usecs * 1000); + rec->ts.secs = (time_t)pl_hdr.ts_secs; + rec->ts.nsecs = (int)(pl_hdr.ts_usecs * 1000); - return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info); + return wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info); } /* diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index 894c33fb4e..d0aedb3e68 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -1233,7 +1233,7 @@ struct can_socketcan_hdr { }; static void -pcap_byteswap_linux_sll_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) +pcap_byteswap_linux_sll_pseudoheader(wtap_rec *rec, guint8 *pd) { guint packet_size; guint16 protocol; @@ -1244,9 +1244,9 @@ pcap_byteswap_linux_sll_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) * actual length < the captured length, which Should Never * Happen). */ - packet_size = phdr->caplen; - if (packet_size > phdr->len) - packet_size = phdr->len; + packet_size = rec->rec_header.packet_header.caplen; + if (packet_size > rec->rec_header.packet_header.len) + packet_size = rec->rec_header.packet_header.len; if (packet_size < LINUX_SLL_LEN) { /* Not enough data to have the protocol */ @@ -1276,7 +1276,7 @@ pcap_byteswap_linux_sll_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) } static void -pcap_byteswap_linux_usb_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd, +pcap_byteswap_linux_usb_pseudoheader(wtap_rec *rec, guint8 *pd, gboolean header_len_64_bytes) { guint packet_size; @@ -1289,9 +1289,9 @@ pcap_byteswap_linux_usb_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd, * actual length < the captured length, which Should Never * Happen). */ - packet_size = phdr->caplen; - if (packet_size > phdr->len) - packet_size = phdr->len; + packet_size = rec->rec_header.packet_header.caplen; + if (packet_size > rec->rec_header.packet_header.len) + packet_size = rec->rec_header.packet_header.len; /* * Greasy hack, but we never directly dereference any of @@ -1370,7 +1370,7 @@ struct nflog_tlv { }; static void -pcap_byteswap_nflog_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) +pcap_byteswap_nflog_pseudoheader(wtap_rec *rec, guint8 *pd) { guint packet_size; guint8 *p; @@ -1383,9 +1383,9 @@ pcap_byteswap_nflog_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) * actual length < the captured length, which Should Never * Happen). */ - packet_size = phdr->caplen; - if (packet_size > phdr->len) - packet_size = phdr->len; + packet_size = rec->rec_header.packet_header.caplen; + if (packet_size > rec->rec_header.packet_header.len) + packet_size = rec->rec_header.packet_header.len; if (packet_size < sizeof(struct nflog_hdr)) { /* Not enough data to have any TLVs. */ @@ -1517,7 +1517,7 @@ pcap_read_ppp_pseudoheader(FILE_T fh, } static gboolean -pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr, +pcap_read_erf_pseudoheader(FILE_T fh, wtap_rec *rec, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) { guint8 erf_hdr[sizeof(struct erf_phdr)]; @@ -1534,15 +1534,15 @@ pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr, /* The high 32 bits of the timestamp contain the integer number of seconds * while the lower 32 bits contain the binary fraction of the second. * This allows an ultimate resolution of 1/(2^32) seconds, or approximately 233 picoseconds */ - if (whdr) { + if (rec) { guint64 ts = pseudo_header->erf.phdr.ts; - whdr->ts.secs = (guint32) (ts >> 32); + rec->ts.secs = (guint32) (ts >> 32); ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000); ts += (ts & 0x80000000) << 1; /* rounding */ - whdr->ts.nsecs = ((guint32) (ts >> 32)); - if ( whdr->ts.nsecs >= 1000000000) { - whdr->ts.nsecs -= 1000000000; - whdr->ts.secs += 1; + rec->ts.nsecs = ((guint32) (ts >> 32)); + if ( rec->ts.nsecs >= 1000000000) { + rec->ts.nsecs -= 1000000000; + rec->ts.secs += 1; } } return TRUE; @@ -1643,7 +1643,7 @@ pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, i int pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, guint packet_size, gboolean check_packet_size, - struct wtap_pkthdr *phdr, int *err, gchar **err_info) + wtap_rec *rec, int *err, gchar **err_info) { int phdr_len = 0; guint size; @@ -1666,7 +1666,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; } if (!pcap_read_nokiaatm_pseudoheader(fh, - &phdr->pseudo_header, err, err_info)) + &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = NOKIAATM_LEN; @@ -1685,7 +1685,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; } if (!pcap_read_sunatm_pseudoheader(fh, - &phdr->pseudo_header, err, err_info)) + &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = SUNATM_LEN; @@ -1698,14 +1698,14 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, * Nokia IPSO. Psuedo header has already been read, but it's not considered * part of the packet size, so reread it to store the data for later (when saving) */ - if (!pcap_read_nokia_pseudoheader(fh, &phdr->pseudo_header, err, err_info)) + if (!pcap_read_nokia_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ } /* * We don't know whether there's an FCS in this frame or not. */ - phdr->pseudo_header.eth.fcs_len = -1; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1; break; case WTAP_ENCAP_IEEE_802_11: @@ -1720,10 +1720,10 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, * XXX - in pcapng, there *could* be a packet option * indicating the FCS length. */ - memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11)); - phdr->pseudo_header.ieee_802_11.fcs_len = -1; - phdr->pseudo_header.ieee_802_11.decrypted = FALSE; - phdr->pseudo_header.ieee_802_11.datapad = FALSE; + memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11)); + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = -1; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE; break; case WTAP_ENCAP_IRDA: @@ -1737,7 +1737,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, packet_size); return -1; } - if (!pcap_read_irda_pseudoheader(fh, &phdr->pseudo_header, + if (!pcap_read_irda_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ @@ -1755,7 +1755,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, packet_size); return -1; } - if (!pcap_read_mtp2_pseudoheader(fh, &phdr->pseudo_header, + if (!pcap_read_mtp2_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ @@ -1773,7 +1773,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, packet_size); return -1; } - if (!pcap_read_lapd_pseudoheader(fh, &phdr->pseudo_header, + if (!pcap_read_lapd_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ @@ -1791,7 +1791,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, packet_size); return -1; } - if (!pcap_read_sita_pseudoheader(fh, &phdr->pseudo_header, + if (!pcap_read_sita_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ @@ -1800,7 +1800,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, case WTAP_ENCAP_BLUETOOTH_H4: /* We don't have pseudoheader, so just pretend we received everything. */ - phdr->pseudo_header.p2p.sent = FALSE; + rec->rec_header.packet_header.pseudo_header.p2p.sent = FALSE; break; case WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR: @@ -1816,7 +1816,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; } if (!pcap_read_bt_pseudoheader(fh, - &phdr->pseudo_header, err, err_info)) + &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = (int)sizeof (struct libpcap_bt_phdr); @@ -1835,7 +1835,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; } if (!pcap_read_bt_monitor_pseudoheader(fh, - &phdr->pseudo_header, err, err_info)) + &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = (int)sizeof (struct libpcap_bt_monitor_phdr); @@ -1847,7 +1847,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, *err_info = g_strdup("pcap: libpcap llcp file too short"); return -1; } - if (!pcap_read_llcp_pseudoheader(fh, &phdr->pseudo_header, err, err_info)) + if (!pcap_read_llcp_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = LLCP_HEADER_LEN; break; @@ -1865,7 +1865,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; } if (!pcap_read_ppp_pseudoheader(fh, - &phdr->pseudo_header, err, err_info)) + &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = (int)sizeof (struct libpcap_ppp_phdr); @@ -1884,21 +1884,21 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, return -1; } - if (!pcap_read_erf_pseudoheader(fh, phdr, &phdr->pseudo_header, + if (!pcap_read_erf_pseudoheader(fh, rec, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ phdr_len = (int)sizeof(struct erf_phdr); /* check the optional Extension header */ - if (!pcap_read_erf_exheader(fh, &phdr->pseudo_header, err, err_info, + if (!pcap_read_erf_exheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info, &size)) return -1; /* Read error */ phdr_len += size; /* check the optional Multi Channel header */ - if (!pcap_read_erf_subheader(fh, &phdr->pseudo_header, err, err_info, + if (!pcap_read_erf_subheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info, &size)) return -1; /* Read error */ @@ -1929,7 +1929,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, packet_size); return -1; } - if (!pcap_read_i2c_pseudoheader(fh, &phdr->pseudo_header, + if (!pcap_read_i2c_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ @@ -1945,7 +1945,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, void pcap_read_post_process(int file_type, int wtap_encap, - struct wtap_pkthdr *phdr, guint8 *pd, gboolean bytes_swapped, int fcs_len) + wtap_rec *rec, guint8 *pd, gboolean bytes_swapped, int fcs_len) { switch (wtap_encap) { @@ -1957,7 +1957,7 @@ pcap_read_post_process(int file_type, int wtap_encap, * Guess the traffic type based on the packet * contents. */ - atm_guess_traffic_type(phdr, pd); + atm_guess_traffic_type(rec, pd); } else { /* * SunATM. @@ -1966,28 +1966,28 @@ pcap_read_post_process(int file_type, int wtap_encap, * type of LANE traffic it is based on the packet * contents. */ - if (phdr->pseudo_header.atm.type == TRAF_LANE) - atm_guess_lane_type(phdr, pd); + if (rec->rec_header.packet_header.pseudo_header.atm.type == TRAF_LANE) + atm_guess_lane_type(rec, pd); } break; case WTAP_ENCAP_ETHERNET: - phdr->pseudo_header.eth.fcs_len = fcs_len; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = fcs_len; break; case WTAP_ENCAP_SLL: if (bytes_swapped) - pcap_byteswap_linux_sll_pseudoheader(phdr, pd); + pcap_byteswap_linux_sll_pseudoheader(rec, pd); break; case WTAP_ENCAP_USB_LINUX: if (bytes_swapped) - pcap_byteswap_linux_usb_pseudoheader(phdr, pd, FALSE); + pcap_byteswap_linux_usb_pseudoheader(rec, pd, FALSE); break; case WTAP_ENCAP_USB_LINUX_MMAPPED: if (bytes_swapped) - pcap_byteswap_linux_usb_pseudoheader(phdr, pd, TRUE); + pcap_byteswap_linux_usb_pseudoheader(rec, pd, TRUE); break; case WTAP_ENCAP_NETANALYZER: @@ -1996,12 +1996,12 @@ pcap_read_post_process(int file_type, int wtap_encap, * dissector calls the "Ethernet with FCS" * dissector, but we might as well set it. */ - phdr->pseudo_header.eth.fcs_len = 4; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 4; break; case WTAP_ENCAP_NFLOG: if (bytes_swapped) - pcap_byteswap_nflog_pseudoheader(phdr, pd); + pcap_byteswap_nflog_pseudoheader(rec, pd); break; case WTAP_ENCAP_ERF: @@ -2010,8 +2010,8 @@ pcap_read_post_process(int file_type, int wtap_encap, * Captured length is minimum of wlen and previously calculated * caplen (which would have included padding but not phdr). */ - phdr->len = phdr->pseudo_header.erf.phdr.wlen; - phdr->caplen = MIN(phdr->len, phdr->caplen); + rec->rec_header.packet_header.len = rec->rec_header.packet_header.pseudo_header.erf.phdr.wlen; + rec->rec_header.packet_header.caplen = MIN(rec->rec_header.packet_header.len, rec->rec_header.packet_header.caplen); break; default: @@ -2105,7 +2105,7 @@ pcap_get_phdr_size(int encap, const union wtap_pseudo_header *pseudo_header) case WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR: hdrsize = (int)sizeof (struct libpcap_bt_monitor_phdr); - break; + break; default: hdrsize = 0; @@ -2245,11 +2245,12 @@ pcap_write_phdr(wtap_dumper *wdh, int encap, const union wtap_pseudo_header *pse * Recalculate rlen as padding (and maybe extension headers) * have been stripped from caplen. * - * XXX: Since we don't have phdr->caplen here, assume caplen was - * calculated correctly and recalculate from wlen. + * XXX: Since we don't have rec->rec_header.packet_header.caplen + * here, assume caplen was calculated correctly and + * recalculate from wlen. */ phtons(&erf_hdr[10], - MIN(pseudo_header->erf.phdr.rlen, pseudo_header->erf.phdr.wlen + pcap_get_phdr_size(WTAP_ENCAP_ERF, pseudo_header))); + MIN(pseudo_header->erf.phdr.rlen, pseudo_header->erf.phdr.wlen + pcap_get_phdr_size(WTAP_ENCAP_ERF, pseudo_header))); phtons(&erf_hdr[12], pseudo_header->erf.phdr.lctr); phtons(&erf_hdr[14], pseudo_header->erf.phdr.wlen); diff --git a/wiretap/pcap-common.h b/wiretap/pcap-common.h index c376d435bb..df36bb68d6 100644 --- a/wiretap/pcap-common.h +++ b/wiretap/pcap-common.h @@ -21,10 +21,10 @@ extern guint wtap_max_snaplen_for_encap(int wtap_encap); extern int pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, guint packet_size, gboolean check_packet_size, - struct wtap_pkthdr *phdr, int *err, gchar **err_info); + wtap_rec *rec, int *err, gchar **err_info); extern void pcap_read_post_process(int file_type, int wtap_encap, - struct wtap_pkthdr *phdr, guint8 *pd, gboolean bytes_swapped, int fcs_len); + wtap_rec *rec, guint8 *pd, gboolean bytes_swapped, int fcs_len); extern int pcap_get_phdr_size(int encap, const union wtap_pseudo_header *pseudo_header); diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 72398e8db3..1e51bb144a 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -40,7 +40,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean pcapng_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 void pcapng_close(wtap *wth); @@ -1221,41 +1221,41 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta return FALSE; } - wblock->packet_header->rec_type = REC_TYPE_PACKET; - wblock->packet_header->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; + wblock->rec->rec_type = REC_TYPE_PACKET; + wblock->rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; pcapng_debug("pcapng_read_packet_block: encapsulation = %d (%s), pseudo header size = %d.", iface_info.wtap_encap, wtap_encap_string(iface_info.wtap_encap), - pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header)); - wblock->packet_header->interface_id = packet.interface_id; - wblock->packet_header->pkt_encap = iface_info.wtap_encap; - wblock->packet_header->pkt_tsprec = iface_info.tsprecision; + pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)); + wblock->rec->rec_header.packet_header.interface_id = packet.interface_id; + wblock->rec->rec_header.packet_header.pkt_encap = iface_info.wtap_encap; + wblock->rec->tsprec = iface_info.tsprecision; - memset((void *)&wblock->packet_header->pseudo_header, 0, sizeof(union wtap_pseudo_header)); + memset((void *)&wblock->rec->rec_header.packet_header.pseudo_header, 0, sizeof(union wtap_pseudo_header)); pseudo_header_len = pcap_process_pseudo_header(fh, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, iface_info.wtap_encap, packet.cap_len, TRUE, - wblock->packet_header, + wblock->rec, err, err_info); if (pseudo_header_len < 0) { return FALSE; } block_read += pseudo_header_len; - if (pseudo_header_len != pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header)) { + if (pseudo_header_len != pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)) { pcapng_debug("pcapng_read_packet_block: Could only read %d bytes for pseudo header.", pseudo_header_len); } - wblock->packet_header->caplen = packet.cap_len - pseudo_header_len; - wblock->packet_header->len = packet.packet_len - pseudo_header_len; + wblock->rec->rec_header.packet_header.caplen = packet.cap_len - pseudo_header_len; + wblock->rec->rec_header.packet_header.len = packet.packet_len - pseudo_header_len; /* Combine the two 32-bit pieces of the timestamp into one 64-bit value */ ts = (((guint64)packet.ts_high) << 32) | ((guint64)packet.ts_low); - wblock->packet_header->ts.secs = (time_t)(ts / iface_info.time_units_per_second); - wblock->packet_header->ts.nsecs = (int)(((ts % iface_info.time_units_per_second) * 1000000000) / iface_info.time_units_per_second); + wblock->rec->ts.secs = (time_t)(ts / iface_info.time_units_per_second); + wblock->rec->ts.nsecs = (int)(((ts % iface_info.time_units_per_second) * 1000000000) / iface_info.time_units_per_second); /* "(Enhanced) Packet Block" read capture data */ if (!wtap_read_packet_bytes(fh, wblock->frame_buffer, @@ -1271,9 +1271,9 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta } /* Option defaults */ - wblock->packet_header->opt_comment = NULL; - wblock->packet_header->drop_count = -1; - wblock->packet_header->pack_flags = 0; + wblock->rec->opt_comment = NULL; + wblock->rec->rec_header.packet_header.drop_count = -1; + wblock->rec->rec_header.packet_header.pack_flags = 0; /* FCS length default */ fcslen = pn->if_fcslen; @@ -1291,8 +1291,8 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta /* Allocate enough memory to hold all options */ opt_cont_buf_len = to_read; - ws_buffer_assure_space(&wblock->packet_header->ft_specific_data, opt_cont_buf_len); - opt_ptr = ws_buffer_start_ptr(&wblock->packet_header->ft_specific_data); + ws_buffer_assure_space(&wblock->rec->ft_specific_data, opt_cont_buf_len); + opt_ptr = ws_buffer_start_ptr(&wblock->rec->ft_specific_data); while (to_read != 0) { /* read option */ @@ -1318,9 +1318,9 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta break; case(OPT_COMMENT): if (oh->option_length > 0 && oh->option_length < opt_cont_buf_len) { - wblock->packet_header->presence_flags |= WTAP_HAS_COMMENTS; - wblock->packet_header->opt_comment = g_strndup((char *)option_content, oh->option_length); - pcapng_debug("pcapng_read_packet_block: length %u opt_comment '%s'", oh->option_length, wblock->packet_header->opt_comment); + wblock->rec->presence_flags |= WTAP_HAS_COMMENTS; + wblock->rec->opt_comment = g_strndup((char *)option_content, oh->option_length); + pcapng_debug("pcapng_read_packet_block: length %u opt_comment '%s'", oh->option_length, wblock->rec->opt_comment); } else { pcapng_debug("pcapng_read_packet_block: opt_comment length %u seems strange", oh->option_length); } @@ -1337,17 +1337,17 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta * guint8 * may not point to something that's * aligned correctly. */ - wblock->packet_header->presence_flags |= WTAP_HAS_PACK_FLAGS; - memcpy(&wblock->packet_header->pack_flags, option_content, sizeof(guint32)); + wblock->rec->presence_flags |= WTAP_HAS_PACK_FLAGS; + memcpy(&wblock->rec->rec_header.packet_header.pack_flags, option_content, sizeof(guint32)); if (pn->byte_swapped) { - wblock->packet_header->pack_flags = GUINT32_SWAP_LE_BE(wblock->packet_header->pack_flags); - memcpy(option_content, &wblock->packet_header->pack_flags, sizeof(guint32)); + wblock->rec->rec_header.packet_header.pack_flags = GUINT32_SWAP_LE_BE(wblock->rec->rec_header.packet_header.pack_flags); + memcpy(option_content, &wblock->rec->rec_header.packet_header.pack_flags, sizeof(guint32)); } - if (wblock->packet_header->pack_flags & 0x000001E0) { + if (wblock->rec->rec_header.packet_header.pack_flags & 0x000001E0) { /* The FCS length is present */ - fcslen = (wblock->packet_header->pack_flags & 0x000001E0) >> 5; + fcslen = (wblock->rec->rec_header.packet_header.pack_flags & 0x000001E0) >> 5; } - pcapng_debug("pcapng_read_packet_block: pack_flags %u (ignored)", wblock->packet_header->pack_flags); + pcapng_debug("pcapng_read_packet_block: pack_flags %u (ignored)", wblock->rec->rec_header.packet_header.pack_flags); break; case(OPT_EPB_HASH): pcapng_debug("pcapng_read_packet_block: epb_hash %u currently not handled - ignoring %u bytes", @@ -1365,14 +1365,14 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta * guint8 * may not point to something that's * aligned correctly. */ - wblock->packet_header->presence_flags |= WTAP_HAS_DROP_COUNT; - memcpy(&wblock->packet_header->drop_count, option_content, sizeof(guint64)); + wblock->rec->presence_flags |= WTAP_HAS_DROP_COUNT; + memcpy(&wblock->rec->rec_header.packet_header.drop_count, option_content, sizeof(guint64)); if (pn->byte_swapped) { - wblock->packet_header->drop_count = GUINT64_SWAP_LE_BE(wblock->packet_header->drop_count); - memcpy(option_content, &wblock->packet_header->drop_count, sizeof(guint64)); + wblock->rec->rec_header.packet_header.drop_count = GUINT64_SWAP_LE_BE(wblock->rec->rec_header.packet_header.drop_count); + memcpy(option_content, &wblock->rec->rec_header.packet_header.drop_count, sizeof(guint64)); } - pcapng_debug("pcapng_read_packet_block: drop_count %" G_GINT64_MODIFIER "u", wblock->packet_header->drop_count); + pcapng_debug("pcapng_read_packet_block: drop_count %" G_GINT64_MODIFIER "u", wblock->rec->rec_header.packet_header.drop_count); break; default: #ifdef HAVE_PLUGINS @@ -1397,7 +1397,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta } pcap_read_post_process(WTAP_FILE_TYPE_SUBTYPE_PCAPNG, iface_info.wtap_encap, - wblock->packet_header, ws_buffer_start_ptr(wblock->frame_buffer), + wblock->rec, ws_buffer_start_ptr(wblock->frame_buffer), pn->byte_swapped, fcslen); /* @@ -1520,41 +1520,41 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t * simple_packet.packet_len); pcapng_debug("pcapng_read_simple_packet_block: Need to read pseudo header of size %d", - pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header)); + pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)); /* No time stamp in a simple packet block; no options, either */ - wblock->packet_header->rec_type = REC_TYPE_PACKET; - wblock->packet_header->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; - wblock->packet_header->interface_id = 0; - wblock->packet_header->pkt_encap = iface_info.wtap_encap; - wblock->packet_header->pkt_tsprec = iface_info.tsprecision; - wblock->packet_header->ts.secs = 0; - wblock->packet_header->ts.nsecs = 0; - wblock->packet_header->interface_id = 0; - wblock->packet_header->opt_comment = NULL; - wblock->packet_header->drop_count = 0; - wblock->packet_header->pack_flags = 0; - - memset((void *)&wblock->packet_header->pseudo_header, 0, sizeof(union wtap_pseudo_header)); + wblock->rec->rec_type = REC_TYPE_PACKET; + wblock->rec->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; + wblock->rec->rec_header.packet_header.interface_id = 0; + wblock->rec->rec_header.packet_header.pkt_encap = iface_info.wtap_encap; + wblock->rec->tsprec = iface_info.tsprecision; + wblock->rec->ts.secs = 0; + wblock->rec->ts.nsecs = 0; + wblock->rec->rec_header.packet_header.interface_id = 0; + wblock->rec->opt_comment = NULL; + wblock->rec->rec_header.packet_header.drop_count = 0; + wblock->rec->rec_header.packet_header.pack_flags = 0; + + memset((void *)&wblock->rec->rec_header.packet_header.pseudo_header, 0, sizeof(union wtap_pseudo_header)); pseudo_header_len = pcap_process_pseudo_header(fh, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, iface_info.wtap_encap, simple_packet.cap_len, TRUE, - wblock->packet_header, + wblock->rec, err, err_info); if (pseudo_header_len < 0) { return FALSE; } - wblock->packet_header->caplen = simple_packet.cap_len - pseudo_header_len; - wblock->packet_header->len = simple_packet.packet_len - pseudo_header_len; - if (pseudo_header_len != pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header)) { + wblock->rec->rec_header.packet_header.caplen = simple_packet.cap_len - pseudo_header_len; + wblock->rec->rec_header.packet_header.len = simple_packet.packet_len - pseudo_header_len; + if (pseudo_header_len != pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header)) { pcapng_debug("pcapng_read_simple_packet_block: Could only read %d bytes for pseudo header.", pseudo_header_len); } - memset((void *)&wblock->packet_header->pseudo_header, 0, sizeof(union wtap_pseudo_header)); + memset((void *)&wblock->rec->rec_header.packet_header.pseudo_header, 0, sizeof(union wtap_pseudo_header)); /* "Simple Packet Block" read capture data */ if (!wtap_read_packet_bytes(fh, wblock->frame_buffer, @@ -1568,7 +1568,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t * } pcap_read_post_process(WTAP_FILE_TYPE_SUBTYPE_PCAPNG, iface_info.wtap_encap, - wblock->packet_header, ws_buffer_start_ptr(wblock->frame_buffer), + wblock->rec, ws_buffer_start_ptr(wblock->frame_buffer), pn->byte_swapped, pn->if_fcslen); /* @@ -2224,10 +2224,10 @@ pcapng_read_sysdig_event_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *p pcapng_debug("pcapng_read_sysdig_event_block: block_total_length %u", bh->block_total_length); - wblock->packet_header->rec_type = REC_TYPE_SYSCALL; - wblock->packet_header->pseudo_header.sysdig_event.record_type = BLOCK_TYPE_SYSDIG_EVENT; - wblock->packet_header->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN /*|WTAP_HAS_INTERFACE_ID */; - wblock->packet_header->pkt_tsprec = WTAP_TSPREC_NSEC; + wblock->rec->rec_type = REC_TYPE_SYSCALL; + wblock->rec->rec_header.syscall_header.record_type = BLOCK_TYPE_SYSDIG_EVENT; + wblock->rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN /*|WTAP_HAS_INTERFACE_ID */; + wblock->rec->tsprec = WTAP_TSPREC_NSEC; block_read = block_total_length; @@ -2253,34 +2253,34 @@ pcapng_read_sysdig_event_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *p } block_read -= MIN_SYSDIG_EVENT_SIZE; - wblock->packet_header->pseudo_header.sysdig_event.byte_order = G_BYTE_ORDER; + wblock->rec->rec_header.syscall_header.byte_order = G_BYTE_ORDER; /* XXX Use Gxxx_FROM_LE macros instead? */ if (pn->byte_swapped) { - wblock->packet_header->pseudo_header.sysdig_event.byte_order = + wblock->rec->rec_header.syscall_header.byte_order = #if G_BYTE_ORDER == G_LITTLE_ENDIAN G_BIG_ENDIAN; #else G_LITTLE_ENDIAN; #endif - wblock->packet_header->pseudo_header.sysdig_event.cpu_id = GUINT16_SWAP_LE_BE(cpu_id); + wblock->rec->rec_header.syscall_header.cpu_id = GUINT16_SWAP_LE_BE(cpu_id); ts = GUINT64_SWAP_LE_BE(wire_ts); - wblock->packet_header->pseudo_header.sysdig_event.thread_id = GUINT64_SWAP_LE_BE(thread_id); - wblock->packet_header->pseudo_header.sysdig_event.event_len = GUINT32_SWAP_LE_BE(event_len); - wblock->packet_header->pseudo_header.sysdig_event.event_type = GUINT16_SWAP_LE_BE(event_type); + wblock->rec->rec_header.syscall_header.thread_id = GUINT64_SWAP_LE_BE(thread_id); + wblock->rec->rec_header.syscall_header.event_len = GUINT32_SWAP_LE_BE(event_len); + wblock->rec->rec_header.syscall_header.event_type = GUINT16_SWAP_LE_BE(event_type); } else { - wblock->packet_header->pseudo_header.sysdig_event.cpu_id = cpu_id; + wblock->rec->rec_header.syscall_header.cpu_id = cpu_id; ts = wire_ts; - wblock->packet_header->pseudo_header.sysdig_event.thread_id = thread_id; - wblock->packet_header->pseudo_header.sysdig_event.event_len = event_len; - wblock->packet_header->pseudo_header.sysdig_event.event_type = event_type; + wblock->rec->rec_header.syscall_header.thread_id = thread_id; + wblock->rec->rec_header.syscall_header.event_len = event_len; + wblock->rec->rec_header.syscall_header.event_type = event_type; } - wblock->packet_header->ts.secs = (time_t) (ts / 1000000000); - wblock->packet_header->ts.nsecs = (int) (ts % 1000000000); + wblock->rec->ts.secs = (time_t) (ts / 1000000000); + wblock->rec->ts.nsecs = (int) (ts % 1000000000); - wblock->packet_header->caplen = block_read; - wblock->packet_header->len = wblock->packet_header->pseudo_header.sysdig_event.event_len; + wblock->rec->rec_header.syscall_header.caplen = block_read; + wblock->rec->rec_header.syscall_header.len = wblock->rec->rec_header.syscall_header.event_len; /* "Sysdig Event Block" read event data */ if (!wtap_read_packet_bytes(fh, wblock->frame_buffer, @@ -2541,7 +2541,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) /* we don't expect any packet blocks yet */ wblock.frame_buffer = NULL; - wblock.packet_header = NULL; + wblock.rec = NULL; pcapng_debug("pcapng_open: opening file"); /* read first block */ @@ -2657,8 +2657,8 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wtapng_if_stats_mandatory_t *if_stats_mand_block, *if_stats_mand; wtapng_if_descr_mandatory_t *wtapng_if_descr_mand; - wblock.frame_buffer = wth->frame_buffer; - wblock.packet_header = &wth->phdr; + wblock.frame_buffer = wth->rec_data; + wblock.rec = &wth->rec; pcapng->add_new_ipv4 = wth->add_new_ipv4; pcapng->add_new_ipv6 = wth->add_new_ipv6; @@ -2763,7 +2763,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) } } - /*pcapng_debug("Read length: %u Packet length: %u", bytes_read, wth->phdr.caplen);*/ + /*pcapng_debug("Read length: %u Packet length: %u", bytes_read, wth->rec.rec_header.packet_header.caplen);*/ pcapng_debug("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset); return TRUE; @@ -2773,7 +2773,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) /* classic wtap: seek to file position and read packet */ static gboolean pcapng_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { pcapng_t *pcapng = (pcapng_t *)wth->priv; @@ -2787,7 +2787,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off, pcapng_debug("pcapng_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off); wblock.frame_buffer = buf; - wblock.packet_header = phdr; + wblock.rec = rec; /* read the block */ if (pcapng_read_block(wth, wth->random_fh, pcapng, &wblock, err, err_info) != PCAPNG_BLOCK_OK) { @@ -3031,10 +3031,10 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err) } static gboolean -pcapng_write_enhanced_packet_block(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, - const union wtap_pseudo_header *pseudo_header, const guint8 *pd, int *err) +pcapng_write_enhanced_packet_block(wtap_dumper *wdh, const wtap_rec *rec, + const guint8 *pd, int *err) { + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; pcapng_block_header_t bh; pcapng_enhanced_packet_block_t epb; guint64 ts; @@ -3049,22 +3049,22 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, wtapng_if_descr_mandatory_t *int_data_mand; /* Don't write anything we're not willing to read. */ - if (phdr->caplen > wtap_max_snaplen_for_encap(wdh->encap)) { + if (rec->rec_header.packet_header.caplen > wtap_max_snaplen_for_encap(wdh->encap)) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - phdr_len = (guint32)pcap_get_phdr_size(phdr->pkt_encap, pseudo_header); - if ((phdr_len + phdr->caplen) % 4) { - pad_len = 4 - ((phdr_len + phdr->caplen) % 4); + phdr_len = (guint32)pcap_get_phdr_size(rec->rec_header.packet_header.pkt_encap, pseudo_header); + if ((phdr_len + rec->rec_header.packet_header.caplen) % 4) { + pad_len = 4 - ((phdr_len + rec->rec_header.packet_header.caplen) % 4); } else { pad_len = 0; } /* Check if we should write comment option */ - if (phdr->opt_comment) { + if (rec->opt_comment) { have_options = TRUE; - comment_len = (guint32)strlen(phdr->opt_comment) & 0xffff; + comment_len = (guint32)strlen(rec->opt_comment) & 0xffff; if ((comment_len % 4)) { comment_pad_len = 4 - (comment_len % 4); } else { @@ -3072,7 +3072,7 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, } options_total_length = options_total_length + comment_len + comment_pad_len + 4 /* comment options tag */ ; } - if (phdr->presence_flags & WTAP_HAS_PACK_FLAGS) { + if (rec->presence_flags & WTAP_HAS_PACK_FLAGS) { have_options = TRUE; options_total_length = options_total_length + 8; } @@ -3083,15 +3083,15 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, /* write (enhanced) packet block header */ bh.block_type = BLOCK_TYPE_EPB; - bh.block_total_length = (guint32)sizeof(bh) + (guint32)sizeof(epb) + phdr_len + phdr->caplen + pad_len + options_total_length + 4; + bh.block_total_length = (guint32)sizeof(bh) + (guint32)sizeof(epb) + phdr_len + rec->rec_header.packet_header.caplen + pad_len + options_total_length + 4; if (!wtap_dump_file_write(wdh, &bh, sizeof bh, err)) return FALSE; wdh->bytes_dumped += sizeof bh; /* write block fixed content */ - if (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) - epb.interface_id = phdr->interface_id; + if (rec->presence_flags & WTAP_HAS_INTERFACE_ID) + epb.interface_id = rec->rec_header.packet_header.interface_id; else { /* * XXX - we should support writing WTAP_ENCAP_PER_PACKET @@ -3114,27 +3114,27 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, int_data = g_array_index(wdh->interface_data, wtap_block_t, epb.interface_id); int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data); - ts = ((guint64)phdr->ts.secs) * int_data_mand->time_units_per_second + - (((guint64)phdr->ts.nsecs) * int_data_mand->time_units_per_second) / 1000000000; + ts = ((guint64)rec->ts.secs) * int_data_mand->time_units_per_second + + (((guint64)rec->ts.nsecs) * int_data_mand->time_units_per_second) / 1000000000; epb.timestamp_high = (guint32)(ts >> 32); epb.timestamp_low = (guint32)ts; - epb.captured_len = phdr->caplen + phdr_len; - epb.packet_len = phdr->len + phdr_len; + epb.captured_len = rec->rec_header.packet_header.caplen + phdr_len; + epb.packet_len = rec->rec_header.packet_header.len + phdr_len; if (!wtap_dump_file_write(wdh, &epb, sizeof epb, err)) return FALSE; wdh->bytes_dumped += sizeof epb; /* write pseudo header */ - if (!pcap_write_phdr(wdh, phdr->pkt_encap, pseudo_header, err)) { + if (!pcap_write_phdr(wdh, rec->rec_header.packet_header.pkt_encap, pseudo_header, err)) { return FALSE; } wdh->bytes_dumped += phdr_len; /* write packet data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.packet_header.caplen; /* write padding (if any) */ if (pad_len != 0) { @@ -3164,7 +3164,7 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, * between this packet and the preceding one. * opt_endofopt 0 0 It delimits the end of the optional fields. This block cannot be repeated within a given list of options. */ - if (phdr->opt_comment) { + if (rec->opt_comment) { option_hdr.type = OPT_COMMENT; option_hdr.value_length = comment_len; if (!wtap_dump_file_write(wdh, &option_hdr, 4, err)) @@ -3172,8 +3172,8 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, wdh->bytes_dumped += 4; /* Write the comments string */ - pcapng_debug("pcapng_write_enhanced_packet_block, comment:'%s' comment_len %u comment_pad_len %u" , phdr->opt_comment, comment_len, comment_pad_len); - if (!wtap_dump_file_write(wdh, phdr->opt_comment, comment_len, err)) + pcapng_debug("pcapng_write_enhanced_packet_block, comment:'%s' comment_len %u comment_pad_len %u" , rec->opt_comment, comment_len, comment_pad_len); + if (!wtap_dump_file_write(wdh, rec->opt_comment, comment_len, err)) return FALSE; wdh->bytes_dumped += comment_len; @@ -3188,16 +3188,16 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, comment_len, comment_pad_len); } - if (phdr->presence_flags & WTAP_HAS_PACK_FLAGS) { + if (rec->presence_flags & WTAP_HAS_PACK_FLAGS) { option_hdr.type = OPT_EPB_FLAGS; option_hdr.value_length = 4; if (!wtap_dump_file_write(wdh, &option_hdr, 4, err)) return FALSE; wdh->bytes_dumped += 4; - if (!wtap_dump_file_write(wdh, &phdr->pack_flags, 4, err)) + if (!wtap_dump_file_write(wdh, &rec->rec_header.packet_header.pack_flags, 4, err)) return FALSE; wdh->bytes_dumped += 4; - pcapng_debug("pcapng_write_enhanced_packet_block: Wrote Options packet flags: %x", phdr->pack_flags); + pcapng_debug("pcapng_write_enhanced_packet_block: Wrote Options packet flags: %x", rec->rec_header.packet_header.pack_flags); } /* Write end of options if we have options */ if (have_options) { @@ -3216,14 +3216,12 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh, } static gboolean -pcapng_write_sysdig_event_block(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, - const union wtap_pseudo_header *pseudo_header, const guint8 *pd, int *err) +pcapng_write_sysdig_event_block(wtap_dumper *wdh, const wtap_rec *rec, + const guint8 *pd, int *err) { pcapng_block_header_t bh; const guint32 zero_pad = 0; guint32 pad_len; - guint32 phdr_len; #if 0 gboolean have_options = FALSE; struct option option_hdr; @@ -3238,23 +3236,22 @@ pcapng_write_sysdig_event_block(wtap_dumper *wdh, guint16 event_type; /* Don't write anything we're not willing to read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.syscall_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - phdr_len = (guint32)pcap_get_phdr_size(phdr->pkt_encap, pseudo_header); - if ((phdr_len + phdr->caplen) % 4) { - pad_len = 4 - ((phdr_len + phdr->caplen) % 4); + if (rec->rec_header.syscall_header.caplen % 4) { + pad_len = 4 - (rec->rec_header.syscall_header.caplen % 4); } else { pad_len = 0; } #if 0 /* Check if we should write comment option */ - if (phdr->opt_comment) { + if (rec->opt_comment) { have_options = TRUE; - comment_len = (guint32)strlen(phdr->opt_comment) & 0xffff; + comment_len = (guint32)strlen(rec->opt_comment) & 0xffff; if ((comment_len % 4)) { comment_pad_len = 4 - (comment_len % 4); } else { @@ -3270,19 +3267,19 @@ pcapng_write_sysdig_event_block(wtap_dumper *wdh, /* write sysdig event block header */ bh.block_type = BLOCK_TYPE_SYSDIG_EVENT; - bh.block_total_length = (guint32)sizeof(bh) + SYSDIG_EVENT_HEADER_SIZE + phdr_len + phdr->caplen + pad_len + options_total_length + 4; + bh.block_total_length = (guint32)sizeof(bh) + SYSDIG_EVENT_HEADER_SIZE + rec->rec_header.syscall_header.caplen + pad_len + options_total_length + 4; if (!wtap_dump_file_write(wdh, &bh, sizeof bh, err)) return FALSE; wdh->bytes_dumped += sizeof bh; /* Sysdig is always LE? */ - cpu_id = GUINT16_TO_LE(pseudo_header->sysdig_event.cpu_id); - hdr_ts = (((guint64)phdr->ts.secs) * 1000000000) + phdr->ts.nsecs; + cpu_id = GUINT16_TO_LE(rec->rec_header.syscall_header.cpu_id); + hdr_ts = (((guint64)rec->ts.secs) * 1000000000) + rec->ts.nsecs; ts = GUINT64_TO_LE(hdr_ts); - thread_id = GUINT64_TO_LE(pseudo_header->sysdig_event.thread_id); - event_len = GUINT32_TO_LE(pseudo_header->sysdig_event.event_len); - event_type = GUINT16_TO_LE(pseudo_header->sysdig_event.event_type); + thread_id = GUINT64_TO_LE(rec->rec_header.syscall_header.thread_id); + event_len = GUINT32_TO_LE(rec->rec_header.syscall_header.event_len); + event_type = GUINT16_TO_LE(rec->rec_header.syscall_header.event_type); if (!wtap_dump_file_write(wdh, &cpu_id, sizeof cpu_id, err)) return FALSE; @@ -3305,9 +3302,9 @@ pcapng_write_sysdig_event_block(wtap_dumper *wdh, wdh->bytes_dumped += sizeof event_type; /* write event data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.syscall_header.caplen, err)) return FALSE; - wdh->bytes_dumped += phdr->caplen; + wdh->bytes_dumped += rec->rec_header.syscall_header.caplen; /* write padding (if any) */ if (pad_len != 0) { @@ -4137,22 +4134,26 @@ pcapng_write_if_descr_block(wtap_dumper *wdh, wtap_block_t int_data, int *err) } static gboolean pcapng_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; #ifdef HAVE_PLUGINS block_handler *handler; #endif pcapng_debug("pcapng_dump: encap = %d (%s)", - phdr->pkt_encap, - wtap_encap_string(phdr->pkt_encap)); + rec->rec_header.packet_header.pkt_encap, + wtap_encap_string(rec->rec_header.packet_header.pkt_encap)); - switch (phdr->rec_type) { + switch (rec->rec_type) { case REC_TYPE_PACKET: - if (!pcapng_write_enhanced_packet_block(wdh, phdr, pseudo_header, pd, err)) { + /* + * XXX - write a Simple Packet Block if there's no time + * stamp or other information that doesn't appear in an + * SPB? + */ + if (!pcapng_write_enhanced_packet_block(wdh, rec, pd, err)) { return FALSE; } break; @@ -4165,9 +4166,9 @@ static gboolean pcapng_dump(wtap_dumper *wdh, */ if (block_handlers != NULL && (handler = (block_handler *)g_hash_table_lookup(block_handlers, - GUINT_TO_POINTER(pseudo_header->ftsrec.record_type))) != NULL) { + GUINT_TO_POINTER(rec->rec_header.ft_specific_header.record_type))) != NULL) { /* Yes. Call it to write out this record. */ - if (!handler->writer(wdh, phdr, pd, err)) + if (!handler->writer(wdh, rec, pd, err)) return FALSE; } else #endif @@ -4179,7 +4180,7 @@ static gboolean pcapng_dump(wtap_dumper *wdh, break; case REC_TYPE_SYSCALL: - if (!pcapng_write_sysdig_event_block(wdh, phdr, pseudo_header, pd, err)) { + if (!pcapng_write_sysdig_event_block(wdh, rec, pd, err)) { return FALSE; } break; diff --git a/wiretap/pcapng_module.h b/wiretap/pcapng_module.h index 9a869b8b67..cf914ceeab 100644 --- a/wiretap/pcapng_module.h +++ b/wiretap/pcapng_module.h @@ -39,11 +39,11 @@ /* Block data to be passed between functions during reading */ typedef struct wtapng_block_s { - guint32 type; /* block_type as defined by pcapng */ - gboolean internal; /* TRUE if this block type shouldn't be returned from pcapng_read() */ - wtap_block_t block; - struct wtap_pkthdr *packet_header; - Buffer *frame_buffer; + guint32 type; /* block_type as defined by pcapng */ + gboolean internal; /* TRUE if this block type shouldn't be returned from pcapng_read() */ + wtap_block_t block; + wtap_rec *rec; + Buffer *frame_buffer; } wtapng_block_t; /* @@ -51,7 +51,7 @@ typedef struct wtapng_block_s { */ typedef gboolean (*block_reader)(FILE_T, guint32, gboolean, wtapng_block_t *, int *, gchar **); -typedef gboolean (*block_writer)(wtap_dumper *, const struct wtap_pkthdr *, +typedef gboolean (*block_writer)(wtap_dumper *, const wtap_rec *, const guint8 *, int *); /* diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index ba6836fe0f..c30beb7cdf 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -127,15 +127,15 @@ typedef struct { static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean peekclassic_seek_read_v7(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 int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean peekclassic_seek_read_v56(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 peekclassic_read_packet_v56(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info) { @@ -345,14 +345,14 @@ static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read the packet. */ - sliceLength = peekclassic_read_packet_v7(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + sliceLength = peekclassic_read_packet_v7(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); if (sliceLength < 0) return FALSE; /* Skip extra ignored data at the end of the packet. */ - if ((guint32)sliceLength > wth->phdr.caplen) { - if (!wtap_read_bytes(wth->fh, NULL, sliceLength - wth->phdr.caplen, + if ((guint32)sliceLength > wth->rec.rec_header.packet_header.caplen) { + if (!wtap_read_bytes(wth->fh, NULL, sliceLength - wth->rec.rec_header.packet_header.caplen, err, err_info)) return FALSE; } @@ -368,13 +368,13 @@ static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, } static gboolean peekclassic_seek_read_v7(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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the packet. */ - if (peekclassic_read_packet_v7(wth, wth->random_fh, phdr, buf, + if (peekclassic_read_packet_v7(wth, wth->random_fh, rec, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -386,7 +386,7 @@ static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off, #define RADIO_INFO_SIZE 4 static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { guint8 ep_pkt[PEEKCLASSIC_V7_PKT_SIZE]; #if 0 @@ -429,23 +429,23 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, */ /* fill in packet header values */ - 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; tsecs = (time_t) (timestamp/1000000); tusecs = (guint32) (timestamp - tsecs*1000000); - phdr->ts.secs = tsecs - mac2unix; - phdr->ts.nsecs = tusecs * 1000; - phdr->len = length; - phdr->caplen = sliceLength; + rec->ts.secs = tsecs - mac2unix; + rec->ts.nsecs = tusecs * 1000; + rec->rec_header.packet_header.len = length; + rec->rec_header.packet_header.caplen = sliceLength; switch (wth->file_encap) { case WTAP_ENCAP_IEEE_802_11_WITH_RADIO: - memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11)); - phdr->pseudo_header.ieee_802_11.fcs_len = 0; /* no FCS */ - phdr->pseudo_header.ieee_802_11.decrypted = FALSE; - phdr->pseudo_header.ieee_802_11.datapad = FALSE; - phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; + memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11)); + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = 0; /* no FCS */ + rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN; /* * Now process the radio information pseudo-header. @@ -467,27 +467,27 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, * * 1 byte of unknown content (padding?). */ - if (phdr->len < RADIO_INFO_SIZE || phdr->caplen < RADIO_INFO_SIZE) { + if (rec->rec_header.packet_header.len < RADIO_INFO_SIZE || rec->rec_header.packet_header.caplen < RADIO_INFO_SIZE) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("peekclassic: 802.11 packet has length < 4"); return -1; } - phdr->len -= RADIO_INFO_SIZE; - phdr->caplen -= RADIO_INFO_SIZE; + rec->rec_header.packet_header.len -= RADIO_INFO_SIZE; + rec->rec_header.packet_header.caplen -= RADIO_INFO_SIZE; sliceLength -= RADIO_INFO_SIZE; /* read the pseudo-header */ if (!wtap_read_bytes(fh, radio_info, RADIO_INFO_SIZE, err, err_info)) return -1; - phdr->pseudo_header.ieee_802_11.has_data_rate = TRUE; - phdr->pseudo_header.ieee_802_11.data_rate = radio_info[0]; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate = radio_info[0]; - phdr->pseudo_header.ieee_802_11.has_channel = TRUE; - phdr->pseudo_header.ieee_802_11.channel = radio_info[1]; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel = radio_info[1]; - phdr->pseudo_header.ieee_802_11.has_signal_percent = TRUE; - phdr->pseudo_header.ieee_802_11.signal_percent = radio_info[2]; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent = TRUE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent = radio_info[2]; /* * The last 4 bytes appear to be random data - the length @@ -497,25 +497,25 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, * of junk at the end you get in Wireless Sniffer * captures. */ - if (phdr->len < 4 || phdr->caplen < 4) { + if (rec->rec_header.packet_header.len < 4 || rec->rec_header.packet_header.caplen < 4) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("peekclassic: 802.11 packet has length < 8"); return -1; } - phdr->len -= 4; - phdr->caplen -= 4; + rec->rec_header.packet_header.len -= 4; + rec->rec_header.packet_header.caplen -= 4; break; case WTAP_ENCAP_ETHERNET: /* XXX - it appears that if the low-order bit of "status" is 0, there's an FCS in this frame, and if it's 1, there's 4 bytes of 0. */ - phdr->pseudo_header.eth.fcs_len = (status & 0x01) ? 0 : 4; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = (status & 0x01) ? 0 : 4; break; } /* read the packet data */ - if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info)) + if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info)) return -1; return sliceLength; @@ -527,8 +527,8 @@ static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* read the packet */ - if (!peekclassic_read_packet_v56(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info)) + if (!peekclassic_read_packet_v56(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info)) return FALSE; /* @@ -539,13 +539,13 @@ static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info, } static gboolean peekclassic_seek_read_v56(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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* read the packet */ - if (!peekclassic_read_packet_v56(wth, wth->random_fh, phdr, buf, + if (!peekclassic_read_packet_v56(wth, wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; @@ -555,7 +555,7 @@ static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off, } static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { peekclassic_t *peekclassic = (peekclassic_t *)wth->priv; guint8 ep_pkt[PEEKCLASSIC_V56_PKT_SIZE]; @@ -613,26 +613,26 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, */ /* fill in packet header values */ - 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; /* timestamp is in milliseconds since reference_time */ - phdr->ts.secs = peekclassic->reference_time + (timestamp / 1000); - phdr->ts.nsecs = 1000 * (timestamp % 1000) * 1000; - phdr->len = length; - phdr->caplen = sliceLength; + rec->ts.secs = peekclassic->reference_time + (timestamp / 1000); + rec->ts.nsecs = 1000 * (timestamp % 1000) * 1000; + rec->rec_header.packet_header.len = length; + rec->rec_header.packet_header.caplen = sliceLength; - phdr->pkt_encap = WTAP_ENCAP_UNKNOWN; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_UNKNOWN; for (i=0; i<NUM_PEEKCLASSIC_ENCAPS; i++) { if (peekclassic_encap[i].protoNum == protoNum) { - phdr->pkt_encap = peekclassic_encap[i].encap; + rec->rec_header.packet_header.pkt_encap = peekclassic_encap[i].encap; } } - switch (phdr->pkt_encap) { + switch (rec->rec_header.packet_header.pkt_encap) { case WTAP_ENCAP_ETHERNET: /* We assume there's no FCS in this frame. */ - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; } diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c index 4368a90988..d40086fe08 100644 --- a/wiretap/peektagged.c +++ b/wiretap/peektagged.c @@ -153,7 +153,7 @@ typedef struct { static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean peektagged_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 int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err, gchar **err_info) @@ -404,7 +404,7 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info) * are present. */ static int -peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { peektagged_t *peektagged = (peektagged_t *)wth->priv; @@ -713,14 +713,14 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return -1; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->len = length; - phdr->caplen = sliceLength; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->rec_header.packet_header.len = length; + rec->rec_header.packet_header.caplen = sliceLength; /* calculate and fill in packet time stamp */ t = (((guint64) timestamp.upper) << 32) + timestamp.lower; - if (!nsfiletime_to_nstime(&phdr->ts, t)) { + if (!nsfiletime_to_nstime(&rec->ts, t)) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("peektagged: time stamp outside supported range"); return -1; @@ -783,22 +783,22 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, ieee_802_11.frequency = frequency; } } - phdr->pseudo_header.ieee_802_11 = ieee_802_11; + rec->rec_header.packet_header.pseudo_header.ieee_802_11 = ieee_802_11; if (peektagged->has_fcs) - phdr->pseudo_header.ieee_802_11.fcs_len = 4; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = 4; else { - if (phdr->len < 4 || phdr->caplen < 4) { + if (rec->rec_header.packet_header.len < 4 || rec->rec_header.packet_header.caplen < 4) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("peektagged: 802.11 packet has length < 4"); return FALSE; } - phdr->pseudo_header.ieee_802_11.fcs_len = 0; - phdr->len -= 4; - phdr->caplen -= 4; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = 0; + rec->rec_header.packet_header.len -= 4; + rec->rec_header.packet_header.caplen -= 4; skip_len = 4; } - phdr->pseudo_header.ieee_802_11.decrypted = FALSE; - phdr->pseudo_header.ieee_802_11.datapad = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE; + rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE; break; case WTAP_ENCAP_ETHERNET: @@ -806,20 +806,20 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * The last 4 bytes appear to be 0 in the captures I've seen; * are there any captures where it's an FCS? */ - if (phdr->len < 4 || phdr->caplen < 4) { + if (rec->rec_header.packet_header.len < 4 || rec->rec_header.packet_header.caplen < 4) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("peektagged: Ethernet packet has length < 4"); return FALSE; } - phdr->pseudo_header.eth.fcs_len = 0; - phdr->len -= 4; - phdr->caplen -= 4; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.len -= 4; + rec->rec_header.packet_header.caplen -= 4; skip_len = 4; break; } /* Read the packet data. */ - if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info)) + if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info)) return -1; return skip_len; @@ -833,8 +833,8 @@ static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read the packet. */ - skip_len = peektagged_read_packet(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + skip_len = peektagged_read_packet(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); if (skip_len == -1) return FALSE; @@ -849,13 +849,13 @@ static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info, static gboolean peektagged_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the packet. */ - if (peektagged_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) { + if (peektagged_read_packet(wth, wth->random_fh, rec, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; 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; } diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 8583ef55a6..797627228c 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -74,8 +74,8 @@ struct radcomrec_hdr { static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean radcom_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static gboolean radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static gboolean radcom_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); wtap_open_return_val radcom_open(wtap *wth, int *err, gchar **err_info) @@ -238,7 +238,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); /* Read record. */ - if (!radcom_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, + if (!radcom_read_rec(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info)) { /* Read error or EOF */ return FALSE; @@ -258,14 +258,14 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, static gboolean radcom_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read record. */ - if (!radcom_read_rec(wth, wth->random_fh, phdr, buf, err, + if (!radcom_read_rec(wth, wth->random_fh, rec, buf, err, err_info)) { /* Read error or EOF */ if (*err == 0) { @@ -278,7 +278,7 @@ radcom_seek_read(wtap *wth, gint64 seek_off, } static gboolean -radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +radcom_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct radcomrec_hdr hdr; @@ -308,8 +308,8 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, * it. */ - 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 = pletoh16(&hdr.date.year)-1900; tm.tm_mon = (hdr.date.month&0x0f)-1; @@ -319,18 +319,18 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, tm.tm_min = (sec%3600)/60; tm.tm_sec = sec%60; tm.tm_isdst = -1; - phdr->ts.secs = mktime(&tm); - phdr->ts.nsecs = pletoh32(&hdr.date.usec) * 1000; + rec->ts.secs = mktime(&tm); + rec->ts.nsecs = pletoh32(&hdr.date.usec) * 1000; switch (wth->file_encap) { case WTAP_ENCAP_ETHERNET: /* XXX - is there an FCS? */ - phdr->pseudo_header.eth.fcs_len = -1; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1; break; case WTAP_ENCAP_LAPB: - phdr->pseudo_header.x25.flags = (hdr.dce & 0x1) ? + rec->rec_header.packet_header.pseudo_header.x25.flags = (hdr.dce & 0x1) ? 0x00 : FROM_DCE; length -= 2; /* FCS */ real_length -= 2; @@ -349,8 +349,8 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, break; } - phdr->len = real_length; - phdr->caplen = length; + rec->rec_header.packet_header.len = real_length; + rec->rec_header.packet_header.caplen = length; /* * Read the packet data. diff --git a/wiretap/snoop.c b/wiretap/snoop.c index dee9cc8b88..4d1e37c680 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -74,15 +74,15 @@ struct shomiti_trailer { static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean snoop_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static int snoop_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); static gboolean snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); static gboolean snoop_read_shomiti_wireless_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info, int *header_size); -static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean snoop_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); /* @@ -424,8 +424,8 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); - padbytes = snoop_read_packet(wth, wth->fh, &wth->phdr, - wth->frame_buffer, err, err_info); + padbytes = snoop_read_packet(wth, wth->fh, &wth->rec, + wth->rec_data, err, err_info); if (padbytes == -1) return FALSE; @@ -442,12 +442,12 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, static gboolean snoop_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) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - if (snoop_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) { + if (snoop_read_packet(wth, wth->random_fh, rec, buf, err, err_info) == -1) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -456,7 +456,7 @@ snoop_seek_read(wtap *wth, gint64 seek_off, } static int -snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +snoop_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct snooprec_hdr hdr; @@ -521,7 +521,7 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, packet_size); return -1; } - if (!snoop_read_atm_pseudoheader(fh, &phdr->pseudo_header, + if (!snoop_read_atm_pseudoheader(fh, &rec->rec_header.packet_header.pseudo_header, err, err_info)) return -1; /* Read error */ @@ -540,9 +540,9 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * is. (XXX - or should we treat it a "maybe"?) */ if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_SHOMITI) - phdr->pseudo_header.eth.fcs_len = 4; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 4; else - phdr->pseudo_header.eth.fcs_len = 0; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0; break; case WTAP_ENCAP_IEEE_802_11_WITH_RADIO: @@ -557,7 +557,7 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return -1; } if (!snoop_read_shomiti_wireless_pseudoheader(fh, - &phdr->pseudo_header, err, err_info, &header_size)) + &rec->rec_header.packet_header.pseudo_header, err, err_info, &header_size)) return -1; /* Read error */ /* @@ -569,12 +569,12 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, break; } - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; - phdr->ts.secs = g_ntohl(hdr.ts_sec); - phdr->ts.nsecs = g_ntohl(hdr.ts_usec) * 1000; - phdr->caplen = packet_size; - phdr->len = orig_size; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->ts.secs = g_ntohl(hdr.ts_sec); + rec->ts.nsecs = g_ntohl(hdr.ts_usec) * 1000; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = orig_size; if (rec_size < (sizeof hdr + packet_size)) { /* @@ -597,8 +597,8 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * traffic it is based on the packet contents. */ if (wth->file_encap == WTAP_ENCAP_ATM_PDUS && - phdr->pseudo_header.atm.type == TRAF_LANE) { - atm_guess_lane_type(phdr, ws_buffer_start_ptr(buf)); + rec->rec_header.packet_header.pseudo_header.atm.type == TRAF_LANE) { + atm_guess_lane_type(rec, ws_buffer_start_ptr(buf)); } return rec_size - ((guint)sizeof hdr + packet_size); @@ -801,10 +801,10 @@ gboolean snoop_dump_open(wtap_dumper *wdh, int *err) /* Write a record for a packet to a dump file. Returns TRUE on success, FALSE on failure. */ static gboolean snoop_dump(wtap_dumper *wdh, - const struct wtap_pkthdr *phdr, + const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; struct snooprec_hdr rec_hdr; int reclen; guint padlen; @@ -813,7 +813,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, int atm_hdrsize; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } @@ -824,7 +824,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, atm_hdrsize = 0; /* Record length = header length plus data length... */ - reclen = (int)sizeof rec_hdr + phdr->caplen + atm_hdrsize; + reclen = (int)sizeof rec_hdr + rec->rec_header.packet_header.caplen + atm_hdrsize; /* ... plus enough bytes to pad it to a 4-byte boundary. */ @@ -832,17 +832,17 @@ static gboolean snoop_dump(wtap_dumper *wdh, reclen += padlen; /* Don't write anything we're not willing to read. */ - if (phdr->caplen + atm_hdrsize > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen + atm_hdrsize > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } - rec_hdr.orig_len = g_htonl(phdr->len + atm_hdrsize); - rec_hdr.incl_len = g_htonl(phdr->caplen + atm_hdrsize); + rec_hdr.orig_len = g_htonl(rec->rec_header.packet_header.len + atm_hdrsize); + rec_hdr.incl_len = g_htonl(rec->rec_header.packet_header.caplen + atm_hdrsize); rec_hdr.rec_len = g_htonl(reclen); rec_hdr.cum_drops = 0; - rec_hdr.ts_sec = g_htonl(phdr->ts.secs); - rec_hdr.ts_usec = g_htonl(phdr->ts.nsecs / 1000); + rec_hdr.ts_sec = g_htonl(rec->ts.secs); + rec_hdr.ts_usec = g_htonl(rec->ts.nsecs / 1000); if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err)) return FALSE; @@ -885,7 +885,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, return FALSE; } - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; /* Now write the padding. */ diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c index a89cd7daed..85693a9260 100644 --- a/wiretap/stanag4607.c +++ b/wiretap/stanag4607.c @@ -38,7 +38,7 @@ static gboolean is_valid_id(guint16 version_id) return TRUE; } -static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { stanag4607_t *stanag4607 = (stanag4607_t *)wth->priv; @@ -60,7 +60,7 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p return FALSE; } - phdr->rec_type = REC_TYPE_PACKET; + rec->rec_type = REC_TYPE_PACKET; /* The next 4 bytes are the packet length */ packet_size = pntoh32(&stanag_pkt_hdr[2]); @@ -84,16 +84,16 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p "smaller than minimum of %u", packet_size, PKT_HDR_SIZE+SEG_HDR_SIZE); return FALSE; } - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; /* Sadly, the header doesn't contain times; but some segments do */ /* So, get the segment header, which is just past the 32-byte header. */ - phdr->presence_flags = WTAP_HAS_TS; + rec->presence_flags = WTAP_HAS_TS; /* If no time specified, it's the last baseline time */ - phdr->ts.secs = stanag4607->base_secs; - phdr->ts.nsecs = 0; + rec->ts.secs = stanag4607->base_secs; + rec->ts.nsecs = 0; millisecs = 0; #define MISSION_SEGMENT 1 @@ -116,7 +116,7 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p tm.tm_sec = 0; tm.tm_isdst = -1; stanag4607->base_secs = mktime(&tm); - phdr->ts.secs = stanag4607->base_secs; + rec->ts.secs = stanag4607->base_secs; } else if (PLATFORM_LOCATION_SEGMENT == stanag_pkt_hdr[32]) { if (!wtap_read_bytes(fh, &millisecs, sizeof millisecs, err, err_info)) @@ -134,8 +134,8 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p if (0 != millisecs) { secs = millisecs/1000; nsecs = (millisecs - 1000 * secs) * 1000000; - phdr->ts.secs = stanag4607->base_secs + secs; - phdr->ts.nsecs = nsecs; + rec->ts.secs = stanag4607->base_secs + secs; + rec->ts.nsecs = nsecs; } /* wind back to the start of the packet ... */ @@ -155,17 +155,17 @@ static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *d *data_offset = offset; - return stanag4607_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return stanag4607_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info); + return stanag4607_read_file(wth, wth->random_fh, rec, buf, err, err_info); } wtap_open_return_val stanag4607_open(wtap *wth, int *err, gchar **err_info) diff --git a/wiretap/tnef.c b/wiretap/tnef.c index 03720773b8..224fbe2809 100644 --- a/wiretap/tnef.c +++ b/wiretap/tnef.c @@ -14,7 +14,7 @@ #include <wsutil/buffer.h> #include "tnef.h" -static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean tnef_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { gint64 file_size; @@ -35,14 +35,14 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->caplen = packet_size; - phdr->len = packet_size; + rec->rec_header.packet_header.caplen = packet_size; + rec->rec_header.packet_header.len = packet_size; - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->ts.secs = 0; + rec->ts.nsecs = 0; return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info); } @@ -61,11 +61,11 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of *data_offset = offset; - return tnef_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return tnef_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } static gboolean tnef_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { /* there is only one packet */ @@ -77,7 +77,7 @@ static gboolean tnef_seek_read(wtap *wth, gint64 seek_off, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return tnef_read_file(wth, wth->random_fh, phdr, buf, err, err_info); + return tnef_read_file(wth, wth->random_fh, rec, buf, err, err_info); } wtap_open_return_val tnef_open(wtap *wth, int *err, gchar **err_info) diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 8f824ec51c..af3b47b758 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -89,10 +89,10 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' }; static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean toshiba_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 parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset); -static gboolean parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean parse_toshiba_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); /* Seeks to the beginning of the next packet, and returns the @@ -207,20 +207,20 @@ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, *data_offset = offset; /* Parse the packet */ - return parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer, + return parse_toshiba_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info); } /* Used to read packets in random-access fashion */ static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - if (!parse_toshiba_packet(wth->random_fh, phdr, buf, err, err_info)) { + if (!parse_toshiba_packet(wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -230,10 +230,10 @@ toshiba_seek_read(wtap *wth, gint64 seek_off, /* Parses a packet. */ static gboolean -parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, +parse_toshiba_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, 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; char line[TOSHIBA_LINE_LENGTH]; int num_items_scanned; int pkt_len, pktnum, hr, min, sec, csec; @@ -310,29 +310,29 @@ parse_toshiba_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; - phdr->ts.secs = hr * 3600 + min * 60 + sec; - phdr->ts.nsecs = csec * 10000000; - phdr->caplen = pkt_len; - phdr->len = pkt_len; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; + rec->ts.secs = hr * 3600 + min * 60 + sec; + rec->ts.nsecs = csec * 10000000; + rec->rec_header.packet_header.caplen = pkt_len; + rec->rec_header.packet_header.len = pkt_len; switch (channel[0]) { case 'B': - phdr->pkt_encap = WTAP_ENCAP_ISDN; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; pseudo_header->isdn.uton = (direction[0] == 'T'); pseudo_header->isdn.channel = (guint8) strtol(&channel[1], NULL, 10); break; case 'D': - phdr->pkt_encap = WTAP_ENCAP_ISDN; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; pseudo_header->isdn.uton = (direction[0] == 'T'); pseudo_header->isdn.channel = 0; break; default: - phdr->pkt_encap = WTAP_ENCAP_ETHERNET; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET; /* XXX - is there an FCS in the frame? */ pseudo_header->eth.fcs_len = -1; break; diff --git a/wiretap/visual.c b/wiretap/visual.c index 58f714240f..433ca684f6 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -148,10 +148,10 @@ struct visual_write_info static gboolean visual_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean visual_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 visual_read_packet(wtap *wth, FILE_T fh, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, + wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static gboolean visual_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info); static gboolean visual_dump_finish(wtap_dumper *wdh, int *err); static void visual_dump_free(wtap_dumper *wdh); @@ -276,20 +276,20 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, *data_offset = file_tell(wth->fh); - return visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, + return visual_read_packet(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info); } /* Read packet header and data for random access. */ static gboolean visual_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) { /* Seek to the packet header */ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the packet. */ - if (!visual_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) { + if (!visual_read_packet(wth, wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -298,7 +298,7 @@ static gboolean visual_seek_read(wtap *wth, gint64 seek_off, } static gboolean -visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, +visual_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct visual_read_info *visual = (struct visual_read_info *)wth->priv; @@ -318,15 +318,15 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, /* Get the included length of data. This includes extra headers + payload */ packet_size = pletoh16(&vpkt_hdr.incl_len); - 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; /* Set the packet time and length. */ relmsecs = pletoh32(&vpkt_hdr.ts_delta); - phdr->ts.secs = visual->start_time + relmsecs/1000; - phdr->ts.nsecs = (relmsecs % 1000)*1000000; + rec->ts.secs = visual->start_time + relmsecs/1000; + rec->ts.nsecs = (relmsecs % 1000)*1000000; - phdr->len = pletoh16(&vpkt_hdr.orig_len); + rec->rec_header.packet_header.len = pletoh16(&vpkt_hdr.orig_len); packet_status = pletoh32(&vpkt_hdr.status); @@ -353,68 +353,68 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, { case WTAP_ENCAP_ETHERNET: /* Ethernet has a 4-byte FCS. */ - if (phdr->len < 4) + if (rec->rec_header.packet_header.len < 4) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("visual: Ethernet packet has %u-byte original packet, less than the FCS length", - phdr->len); + rec->rec_header.packet_header.len); return FALSE; } - phdr->len -= 4; + rec->rec_header.packet_header.len -= 4; /* XXX - the above implies that there's never an FCS; should this set the FCS length to 0? */ - phdr->pseudo_header.eth.fcs_len = -1; + rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1; break; case WTAP_ENCAP_CHDLC_WITH_PHDR: /* This has a 2-byte FCS. */ - if (phdr->len < 2) + if (rec->rec_header.packet_header.len < 2) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("visual: Cisco HDLC packet has %u-byte original packet, less than the FCS length", - phdr->len); + rec->rec_header.packet_header.len); return FALSE; } - phdr->len -= 2; + rec->rec_header.packet_header.len -= 2; - phdr->pseudo_header.p2p.sent = (packet_status & PS_SENT) ? TRUE : FALSE; + rec->rec_header.packet_header.pseudo_header.p2p.sent = (packet_status & PS_SENT) ? TRUE : FALSE; break; case WTAP_ENCAP_PPP_WITH_PHDR: /* No FCS. XXX - true? Note that PPP can negotiate no FCS, a 2-byte FCS, or a 4-byte FCS. */ - phdr->pseudo_header.p2p.sent = (packet_status & PS_SENT) ? TRUE : FALSE; + rec->rec_header.packet_header.pseudo_header.p2p.sent = (packet_status & PS_SENT) ? TRUE : FALSE; break; case WTAP_ENCAP_FRELAY_WITH_PHDR: /* This has a 2-byte FCS. */ - if (phdr->len < 2) + if (rec->rec_header.packet_header.len < 2) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("visual: Frame Relay packet has %u-byte original packet, less than the FCS length", - phdr->len); + rec->rec_header.packet_header.len); return FALSE; } - phdr->len -= 2; + rec->rec_header.packet_header.len -= 2; - phdr->pseudo_header.x25.flags = + rec->rec_header.packet_header.pseudo_header.x25.flags = (packet_status & PS_SENT) ? 0x00 : FROM_DCE; break; case WTAP_ENCAP_LAPB: /* This has a 2-byte FCS. */ - if (phdr->len < 2) + if (rec->rec_header.packet_header.len < 2) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("visual: Frame Relay packet has %u-byte original packet, less than the FCS length", - phdr->len); + rec->rec_header.packet_header.len); return FALSE; } - phdr->len -= 2; + rec->rec_header.packet_header.len -= 2; - phdr->pseudo_header.x25.flags = + rec->rec_header.packet_header.pseudo_header.x25.flags = (packet_status & PS_SENT) ? 0x00 : FROM_DCE; break; @@ -435,38 +435,38 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, packet_size -= (guint32)sizeof vatm_hdr; /* Set defaults */ - phdr->pseudo_header.atm.type = TRAF_UNKNOWN; - phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; - phdr->pseudo_header.atm.aal5t_len = 0; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal5t_len = 0; /* Next two items not supported. Defaulting to zero */ - phdr->pseudo_header.atm.aal5t_u2u = 0; - phdr->pseudo_header.atm.aal5t_chksum = 0; + rec->rec_header.packet_header.pseudo_header.atm.aal5t_u2u = 0; + rec->rec_header.packet_header.pseudo_header.atm.aal5t_chksum = 0; /* Flags appear only to convey that packet is a raw cell. Set to 0 */ - phdr->pseudo_header.atm.flags = 0; + rec->rec_header.packet_header.pseudo_header.atm.flags = 0; /* Not supported. Defaulting to zero */ - phdr->pseudo_header.atm.aal2_cid = 0; + rec->rec_header.packet_header.pseudo_header.atm.aal2_cid = 0; switch(vatm_hdr.category & VN_CAT_TYPE_MASK ) { case VN_AAL1: - phdr->pseudo_header.atm.aal = AAL_1; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_1; break; case VN_AAL2: - phdr->pseudo_header.atm.aal = AAL_2; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_2; break; case VN_AAL34: - phdr->pseudo_header.atm.aal = AAL_3_4; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_3_4; break; case VN_AAL5: - phdr->pseudo_header.atm.aal = AAL_5; - phdr->pseudo_header.atm.type = TRAF_LLCMX; - phdr->pseudo_header.atm.aal5t_len = pntoh32(&vatm_hdr.data_length); + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_5; + rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LLCMX; + rec->rec_header.packet_header.pseudo_header.atm.aal5t_len = pntoh32(&vatm_hdr.data_length); break; case VN_OAM: @@ -474,20 +474,20 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, case VN_O191: case VN_IDLE: case VN_RM: - phdr->pseudo_header.atm.aal = AAL_OAMCELL; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_OAMCELL; break; case VN_UNKNOWN: default: - phdr->pseudo_header.atm.aal = AAL_UNKNOWN; + rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_UNKNOWN; break; } - phdr->pseudo_header.atm.vpi = pntoh16(&vatm_hdr.vpi) & 0x0FFF; - phdr->pseudo_header.atm.vci = pntoh16(&vatm_hdr.vci); - phdr->pseudo_header.atm.cells = pntoh16(&vatm_hdr.cell_count); + rec->rec_header.packet_header.pseudo_header.atm.vpi = pntoh16(&vatm_hdr.vpi) & 0x0FFF; + rec->rec_header.packet_header.pseudo_header.atm.vci = pntoh16(&vatm_hdr.vci); + rec->rec_header.packet_header.pseudo_header.atm.cells = pntoh16(&vatm_hdr.cell_count); /* Using bit value of 1 (DCE -> DTE) to indicate From Network */ - phdr->pseudo_header.atm.channel = vatm_hdr.info & FROM_NETWORK; + rec->rec_header.packet_header.pseudo_header.atm.channel = vatm_hdr.info & FROM_NETWORK; break; /* Not sure about token ring. Just leaving alone for now. */ @@ -496,7 +496,7 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, break; } - phdr->caplen = packet_size; + rec->rec_header.packet_header.caplen = packet_size; /* Check for too-large packet. */ if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) @@ -542,12 +542,12 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, (0xfe == pd[0]) && (0xfe == pd[1]) && (0x03 == pd[2])) { /* It is actually LLC encapsulated PPP */ - phdr->pkt_encap = WTAP_ENCAP_ATM_RFC1483; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ATM_RFC1483; } else { /* It is actually PPP */ - phdr->pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; } } else @@ -557,7 +557,7 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, if (packet_size >= 2 && (0xff == pd[0]) && (0x03 == pd[1])) { /* It is actually PPP */ - phdr->pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; + rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; } } } @@ -623,10 +623,10 @@ gboolean visual_dump_open(wtap_dumper *wdh, int *err) /* Write a packet to a Visual dump file. Returns TRUE on success, FALSE on failure. */ -static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, +static gboolean visual_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info _U_) { - const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; + const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header; struct visual_write_info * visual = (struct visual_write_info *)wdh->priv; struct visual_pkt_hdr vpkt_hdr; size_t hdr_size = sizeof vpkt_hdr; @@ -634,13 +634,13 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, guint32 packet_status; /* We can only write packet records. */ - if (phdr->rec_type != REC_TYPE_PACKET) { + if (rec->rec_type != REC_TYPE_PACKET) { *err = WTAP_ERR_UNWRITABLE_REC_TYPE; return FALSE; } /* Don't write anything we're not willing to read. */ - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; } @@ -660,7 +660,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, if (visual->index_table_index == 0) { /* This is the first packet. Save its start time as the file time. */ - visual->start_time = phdr->ts.secs; + visual->start_time = rec->ts.secs; /* Initialize the index table */ visual->index_table = (guint32 *)g_malloc(1024 * sizeof *visual->index_table); @@ -668,13 +668,13 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } /* Calculate milliseconds since capture start. */ - delta_msec = phdr->ts.nsecs / 1000000; - delta_msec += (guint32)((phdr->ts.secs - visual->start_time) * 1000); + delta_msec = rec->ts.nsecs / 1000000; + delta_msec += (guint32)((rec->ts.secs - visual->start_time) * 1000); vpkt_hdr.ts_delta = GUINT32_TO_LE(delta_msec); /* Fill in the length fields. */ - vpkt_hdr.orig_len = GUINT16_TO_LE(phdr->len); - vpkt_hdr.incl_len = GUINT16_TO_LE(phdr->caplen); + vpkt_hdr.orig_len = GUINT16_TO_LE(rec->rec_header.packet_header.len); + vpkt_hdr.incl_len = GUINT16_TO_LE(rec->rec_header.packet_header.caplen); /* Fill in the encapsulation hint for the file's media type. */ switch (wdh->encap) @@ -725,7 +725,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, return FALSE; /* Write the packet data */ - if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) + if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err)) return FALSE; /* Store the frame offset in the index table. */ @@ -740,7 +740,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* Update the table index and offset for the next frame. */ visual->index_table_index++; - visual->next_offset += (guint32) hdr_size + phdr->caplen; + visual->next_offset += (guint32) hdr_size + rec->rec_header.packet_header.caplen; return TRUE; } diff --git a/wiretap/vms.c b/wiretap/vms.c index 6242d0cfbd..5dee35fab6 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -129,10 +129,10 @@ to handle them. static gboolean vms_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean vms_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 parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset, int in_off, int remaining_bytes); -static gboolean parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, +static gboolean parse_vms_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); #ifdef TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE @@ -260,18 +260,18 @@ static gboolean vms_read(wtap *wth, int *err, gchar **err_info, *data_offset = offset; /* Parse the packet */ - return parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); + return parse_vms_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info); } /* Used to read packets in random-access fashion */ static gboolean -vms_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, +vms_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - if (!parse_vms_packet(wth->random_fh, phdr, buf, err, err_info)) { + if (!parse_vms_packet(wth->random_fh, rec, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; @@ -306,7 +306,7 @@ isdumpline( gchar *line ) /* Parses a packet record. */ static gboolean -parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +parse_vms_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { char line[VMS_LINE_LENGTH + 1]; int num_items_scanned; @@ -403,12 +403,12 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch tm.tm_year -= 1900; tm.tm_isdst = -1; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = mktime(&tm); - phdr->ts.nsecs = csec * 10000000; - phdr->caplen = pkt_len; - phdr->len = pkt_len; + rec->rec_type = REC_TYPE_PACKET; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = mktime(&tm); + rec->ts.nsecs = csec * 10000000; + rec->rec_header.packet_header.caplen = pkt_len; + rec->rec_header.packet_header.len = pkt_len; /* Make sure we have enough room for the packet */ ws_buffer_assure_space(buf, pkt_len); diff --git a/wiretap/vwr.c b/wiretap/vwr.c index 180a01418f..8725ba9c3c 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -771,27 +771,27 @@ static guint8 get_cck_rate(const guint8 *plcp); static void setup_defaults(vwr_t *, guint16); static gboolean vwr_read(wtap *, int *, gchar **, gint64 *); -static gboolean vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr, +static gboolean vwr_seek_read(wtap *, gint64, wtap_rec *rec, Buffer *, int *, gchar **); static gboolean vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, int *, gchar **); static gboolean vwr_process_rec_data(FILE_T fh, int rec_size, - struct wtap_pkthdr *phdr, Buffer *buf, + wtap_rec *rec, Buffer *buf, vwr_t *vwr, int IS_TX, int log_mode, int *err, gchar **err_info); static int vwr_get_fpga_version(wtap *, int *, gchar **); -static gboolean vwr_read_s1_W_rec(vwr_t *, struct wtap_pkthdr *, Buffer *, +static gboolean vwr_read_s1_W_rec(vwr_t *, wtap_rec *, Buffer *, const guint8 *, int, int *, gchar **); -static gboolean vwr_read_s2_W_rec(vwr_t *, struct wtap_pkthdr *, Buffer *, +static gboolean vwr_read_s2_W_rec(vwr_t *, wtap_rec *, Buffer *, const guint8 *, int, int, int *, gchar **); /* For FPGA version >= 48 (OCTO Platform), following function will be used */ -static gboolean vwr_read_s3_W_rec(vwr_t *, struct wtap_pkthdr *, Buffer *, +static gboolean vwr_read_s3_W_rec(vwr_t *, wtap_rec *, Buffer *, const guint8 *, int, int, int, int *, gchar **); -static gboolean vwr_read_rec_data_ethernet(vwr_t *, struct wtap_pkthdr *, +static gboolean vwr_read_rec_data_ethernet(vwr_t *, wtap_rec *, Buffer *, const guint8 *, int, int, int *, gchar **); @@ -867,8 +867,8 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off *data_offset = (file_tell(wth->fh) - VW_RECORD_HEADER_LENGTH); /* got a frame record; read and process it */ - if (!vwr_process_rec_data(wth->fh, rec_size, &wth->phdr, - wth->frame_buffer, vwr, IS_TX, log_mode, err, err_info)) + if (!vwr_process_rec_data(wth->fh, rec_size, &wth->rec, + wth->rec_data, vwr, IS_TX, log_mode, err, err_info)) return FALSE; /* If the per-file encapsulation isn't known, set it to this packet's encapsulation. */ @@ -876,9 +876,9 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off /* WTAP_ENCAP_PER_PACKET, as this file doesn't 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; } @@ -888,7 +888,7 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off /* read a random record in the middle of a file; the start of the record is @ seek_off */ static gboolean vwr_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) + wtap_rec *record, Buffer *buf, int *err, gchar **err_info) { vwr_t *vwr = (vwr_t *)wth->priv; int rec_size, IS_TX, log_mode; @@ -901,7 +901,7 @@ static gboolean vwr_seek_read(wtap *wth, gint64 seek_off, if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, &log_mode, err, err_info)) return FALSE; /* Read error or EOF */ - return vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf, + return vwr_process_rec_data(wth->random_fh, rec_size, record, buf, vwr, IS_TX, log_mode, err, err_info); } @@ -1123,7 +1123,7 @@ static int vwr_get_fpga_version(wtap *wth, int *err, gchar **err_info) /* The packet is constructed as a 38-byte VeriWave metadata header plus the raw */ /* MAC octets. */ -static gboolean vwr_read_s1_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, +static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, Buffer *buf, const guint8 *rec, int rec_size, int *err, gchar **err_info) { @@ -1272,17 +1272,17 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, * adding the lengths of the metadata headers, is less than * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it. */ - phdr->len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; - phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; + record->rec_header.packet_header.len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; + record->rec_header.packet_header.caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; - phdr->ts.secs = (time_t)s_sec; - phdr->ts.nsecs = (int)(s_usec * 1000); - phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + record->ts.secs = (time_t)s_sec; + record->ts.nsecs = (int)(s_usec * 1000); + record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + record->rec_type = REC_TYPE_PACKET; + record->presence_flags = WTAP_HAS_TS; - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen); data_ptr = ws_buffer_start_ptr(buf); /* @@ -1399,7 +1399,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, } -static gboolean vwr_read_s2_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, +static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, Buffer *buf, const guint8 *rec, int rec_size, int IS_TX, int *err, gchar **err_info) { @@ -1688,17 +1688,17 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, * adding the lengths of the metadata headers, is less than * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it. */ - phdr->len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; - phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; + record->rec_header.packet_header.len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; + record->rec_header.packet_header.caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets; - phdr->ts.secs = (time_t)s_sec; - phdr->ts.nsecs = (int)(s_usec * 1000); - phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + record->ts.secs = (time_t)s_sec; + record->ts.nsecs = (int)(s_usec * 1000); + record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + record->rec_type = REC_TYPE_PACKET; + record->presence_flags = WTAP_HAS_TS; - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen); data_ptr = ws_buffer_start_ptr(buf); /* @@ -1815,7 +1815,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, return TRUE; } -static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, +static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, Buffer *buf, const guint8 *rec, int rec_size, int IS_TX, int log_mode, int *err, gchar **err_info) @@ -1869,17 +1869,17 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, * OCTO_MODIFIED_RF_LEN + 1 is less than WTAP_MAX_PACKET_SIZE_STANDARD will * ever be, so we don't need to check it. */ - phdr->len = OCTO_MODIFIED_RF_LEN + 1; /* 1st octet is reserved for detecting type of frame while displaying in wireshark */ - phdr->caplen = OCTO_MODIFIED_RF_LEN + 1; + record->rec_header.packet_header.len = OCTO_MODIFIED_RF_LEN + 1; /* 1st octet is reserved for detecting type of frame while displaying in wireshark */ + record->rec_header.packet_header.caplen = OCTO_MODIFIED_RF_LEN + 1; - phdr->ts.secs = (time_t)s_sec; - phdr->ts.nsecs = (int)(s_usec * 1000); - phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + record->ts.secs = (time_t)s_sec; + record->ts.nsecs = (int)(s_usec * 1000); + record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + record->rec_type = REC_TYPE_PACKET; + record->presence_flags = WTAP_HAS_TS; - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen); data_ptr = ws_buffer_start_ptr(buf); port_type = IS_TX << 4; @@ -2186,32 +2186,32 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, * We include the length of the metadata headers in the packet lengths. */ if (IS_TX == 4) { - phdr->len = OCTO_MODIFIED_RF_LEN + OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; - phdr->caplen = OCTO_MODIFIED_RF_LEN + OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; + record->rec_header.packet_header.len = OCTO_MODIFIED_RF_LEN + OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; + record->rec_header.packet_header.caplen = OCTO_MODIFIED_RF_LEN + OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; } else { - phdr->len = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; - phdr->caplen = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; + record->rec_header.packet_header.len = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; + record->rec_header.packet_header.caplen = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets; } - if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { + if (record->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; return an error, * so that our caller doesn't blow up trying to allocate * space for an immensely-large packet. */ *err_info = g_strdup_printf("vwr: File has %u-byte packet, bigger than maximum of %u", - phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD); + record->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); *err = WTAP_ERR_BAD_FILE; return FALSE; } - phdr->ts.secs = (time_t)s_sec; - phdr->ts.nsecs = (int)(s_usec * 1000); - phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + record->ts.secs = (time_t)s_sec; + record->ts.nsecs = (int)(s_usec * 1000); + record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + record->rec_type = REC_TYPE_PACKET; + record->presence_flags = WTAP_HAS_TS; - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen); data_ptr = ws_buffer_start_ptr(buf); } @@ -2533,7 +2533,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, /* Copy the actual packet data from the capture file into the target data block. */ /* The packet is constructed as a 38-byte VeriWave-extended Radiotap header plus the raw */ /* MAC octets. */ -static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, struct wtap_pkthdr *phdr, +static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, Buffer *buf, const guint8 *rec, int rec_size, int IS_TX, int *err, gchar **err_info) @@ -2711,19 +2711,19 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, struct wtap_pkthdr *phdr, * adding the lengths of the metadata headers, is less than * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it. */ - phdr->len = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets; - phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets; + record->rec_header.packet_header.len = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets; + record->rec_header.packet_header.caplen = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets; - phdr->ts.secs = (time_t)s_sec; - phdr->ts.nsecs = (int)(s_usec * 1000); - phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + record->ts.secs = (time_t)s_sec; + record->ts.nsecs = (int)(s_usec * 1000); + record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE; - phdr->rec_type = REC_TYPE_PACKET; - phdr->presence_flags = WTAP_HAS_TS; + record->rec_type = REC_TYPE_PACKET; + record->presence_flags = WTAP_HAS_TS; /*etap_hdr.vw_ip_length = (guint16)ip_len;*/ - ws_buffer_assure_space(buf, phdr->caplen); + ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen); data_ptr = ws_buffer_start_ptr(buf); /* @@ -3327,7 +3327,7 @@ get_vht_rate(guint8 mcs_index, guint16 rflags, guint8 nss) static gboolean vwr_process_rec_data(FILE_T fh, int rec_size, - struct wtap_pkthdr *phdr, Buffer *buf, vwr_t *vwr, + wtap_rec *record, Buffer *buf, vwr_t *vwr, int IS_TX, int log_mode, int *err, gchar **err_info) { guint8* rec; /* local buffer (holds input record) */ @@ -3347,17 +3347,17 @@ vwr_process_rec_data(FILE_T fh, int rec_size, switch (vwr->FPGA_VERSION) { case S1_W_FPGA: - ret = vwr_read_s1_W_rec(vwr, phdr, buf, rec, rec_size, err, err_info); + ret = vwr_read_s1_W_rec(vwr, record, buf, rec, rec_size, err, err_info); break; case S2_W_FPGA: - ret = vwr_read_s2_W_rec(vwr, phdr, buf, rec, rec_size, IS_TX, err, err_info); + ret = vwr_read_s2_W_rec(vwr, record, buf, rec, rec_size, IS_TX, err, err_info); break; case S3_W_FPGA: - ret = vwr_read_s3_W_rec(vwr, phdr, buf, rec, rec_size, IS_TX, log_mode, err, err_info); + ret = vwr_read_s3_W_rec(vwr, record, buf, rec, rec_size, IS_TX, log_mode, err, err_info); break; case vVW510012_E_FPGA: case vVW510024_E_FPGA: - ret = vwr_read_rec_data_ethernet(vwr, phdr, buf, rec, rec_size, IS_TX, err, err_info); + ret = vwr_read_rec_data_ethernet(vwr, record, buf, rec, rec_size, IS_TX, err, err_info); break; default: g_free(rec); diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 0bf6279f0d..fb8d78e471 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -25,9 +25,8 @@ WS_DLL_PUBLIC int wtap_fstat(wtap *wth, ws_statb64 *statb, int *err); typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*); -typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, - struct wtap_pkthdr *, Buffer *buf, - int *, char **); +typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, wtap_rec *, + Buffer *, int *, char **); /** * Struct holding data of the currently read file. @@ -38,8 +37,8 @@ struct wtap { gboolean ispipe; /**< TRUE if the file is a pipe */ int file_type_subtype; guint snapshot_length; - struct Buffer *frame_buffer; - struct wtap_pkthdr phdr; + wtap_rec rec; + Buffer *rec_data; GArray *shb_hdrs; GArray *interface_data; /**< An array holding the interface data from pcapng IDB:s or equivalent(?)*/ GArray *nrb_hdrs; /**< holds the Name Res Block's comment/custom_opts, or NULL */ @@ -80,7 +79,7 @@ struct wtap_dumper; typedef void *WFILE_T; typedef gboolean (*subtype_write_func)(struct wtap_dumper*, - const struct wtap_pkthdr*, + const wtap_rec *rec, const guint8*, int*, gchar**); typedef gboolean (*subtype_finish_func)(struct wtap_dumper*, int*); diff --git a/wiretap/wtap.c b/wiretap/wtap.c index addc800095..896e66e62a 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1140,10 +1140,10 @@ wtap_sequential_close(wtap *wth) wth->fh = NULL; } - if (wth->frame_buffer) { - ws_buffer_free(wth->frame_buffer); - g_free(wth->frame_buffer); - wth->frame_buffer = NULL; + if (wth->rec_data) { + ws_buffer_free(wth->rec_data); + g_free(wth->rec_data); + wth->rec_data = NULL; } } @@ -1222,8 +1222,8 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) * * Do the same for the packet time stamp resolution. */ - wth->phdr.pkt_encap = wth->file_encap; - wth->phdr.pkt_tsprec = wth->file_tsprec; + wth->rec.rec_header.packet_header.pkt_encap = wth->file_encap; + wth->rec.tsprec = wth->file_tsprec; *err = 0; *err_info = NULL; @@ -1243,19 +1243,24 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) } /* - * It makes no sense for the captured data length to be bigger - * than the actual data length. + * Is this a packet record? */ - if (wth->phdr.caplen > wth->phdr.len) - wth->phdr.caplen = wth->phdr.len; + if (wth->rec.rec_type == REC_TYPE_PACKET) { + /* + * It makes no sense for the captured data length + * to be bigger than the actual data length. + */ + if (wth->rec.rec_header.packet_header.caplen > wth->rec.rec_header.packet_header.len) + wth->rec.rec_header.packet_header.caplen = wth->rec.rec_header.packet_header.len; - /* - * Make sure that it's not WTAP_ENCAP_PER_PACKET, as that - * probably means the file has that encapsulation type - * but the read routine didn't set this packet's - * encapsulation type. - */ - g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET); + /* + * Make sure that it's not WTAP_ENCAP_PER_PACKET, as that + * probably means the file has that encapsulation type + * but the read routine didn't set this packet's + * encapsulation type. + */ + g_assert(wth->rec.rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET); + } return TRUE; /* success */ } @@ -1349,34 +1354,34 @@ wtap_read_so_far(wtap *wth) return file_tell_raw(wth->fh); } -struct wtap_pkthdr * -wtap_phdr(wtap *wth) +wtap_rec * +wtap_get_rec(wtap *wth) { - return &wth->phdr; + return &wth->rec; } guint8 * -wtap_buf_ptr(wtap *wth) +wtap_get_buf_ptr(wtap *wth) { - return ws_buffer_start_ptr(wth->frame_buffer); + return ws_buffer_start_ptr(wth->rec_data); } void -wtap_phdr_init(struct wtap_pkthdr *phdr) +wtap_rec_init(wtap_rec *rec) { - memset(phdr, 0, sizeof(struct wtap_pkthdr)); - ws_buffer_init(&phdr->ft_specific_data, 0); + memset(rec, 0, sizeof *rec); + ws_buffer_init(&rec->ft_specific_data, 0); } void -wtap_phdr_cleanup(struct wtap_pkthdr *phdr) +wtap_rec_cleanup(wtap_rec *rec) { - ws_buffer_free(&phdr->ft_specific_data); + ws_buffer_free(&rec->ft_specific_data); } gboolean -wtap_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +wtap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, + int *err, gchar **err_info) { /* * Set the packet encapsulation to the file's encapsulation @@ -1388,28 +1393,33 @@ wtap_seek_read(wtap *wth, gint64 seek_off, * * Do the same for the packet time stamp resolution. */ - phdr->pkt_encap = wth->file_encap; - phdr->pkt_tsprec = wth->file_tsprec; + rec->rec_header.packet_header.pkt_encap = wth->file_encap; + rec->tsprec = wth->file_tsprec; *err = 0; *err_info = NULL; - if (!wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info)) + if (!wth->subtype_seek_read(wth, seek_off, rec, buf, err, err_info)) return FALSE; /* - * It makes no sense for the captured data length to be bigger - * than the actual data length. + * Is this a packet record? */ - if (phdr->caplen > phdr->len) - phdr->caplen = phdr->len; + if (rec->rec_type == REC_TYPE_PACKET) { + /* + * It makes no sense for the captured data length + * to be bigger than the actual data length. + */ + if (rec->rec_header.packet_header.caplen > rec->rec_header.packet_header.len) + rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len; - /* - * Make sure that it's not WTAP_ENCAP_PER_PACKET, as that - * probably means the file has that encapsulation type - * but the read routine didn't set this packet's - * encapsulation type. - */ - g_assert(phdr->pkt_encap != WTAP_ENCAP_PER_PACKET); + /* + * Make sure that it's not WTAP_ENCAP_PER_PACKET, as that + * probably means the file has that encapsulation type + * but the read routine didn't set this packet's + * encapsulation type. + */ + g_assert(rec->rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET); + } return TRUE; } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index ea33b1d42b..4ba654637c 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1137,20 +1137,6 @@ struct logcat_phdr { gint version; }; -/* Packet "pseudo-header" information for Sysdig events. */ - -struct sysdig_event_phdr { - guint record_type; /* XXX match ft_specific_record_phdr so that we chain off of packet-pcapng_block for now. */ - int byte_order; - guint16 cpu_id; - /* guint32 sentinel; */ - guint64 timestamp; /* ns since epoch */ - guint64 thread_id; - guint32 event_len; /* XXX dup of wtap_pkthdr.len */ - guint16 event_type; - /* ... Event ... */ -}; - /* Packet "pseudo-header" information for header data from NetMon files. */ struct netmon_phdr { @@ -1166,11 +1152,6 @@ struct netmon_phdr { } subheader; }; -/* Pseudo-header for file-type-specific records */ -struct ft_specific_record_phdr { - guint record_type; /* the type of record this is */ -}; - union wtap_pseudo_header { struct eth_phdr eth; struct x25_phdr x25; @@ -1197,9 +1178,7 @@ union wtap_pseudo_header { struct nokia_phdr nokia; struct llcp_phdr llcp; struct logcat_phdr logcat; - struct sysdig_event_phdr sysdig_event; struct netmon_phdr netmon; - struct ft_specific_record_phdr ftsrec; }; /* @@ -1259,27 +1238,59 @@ union wtap_pseudo_header { #define REC_TYPE_FT_SPECIFIC_REPORT 2 /**< file-type-specific report */ #define REC_TYPE_SYSCALL 3 /**< system call */ -struct wtap_pkthdr { - guint rec_type; /* what type of record is this? */ - guint32 presence_flags; /* what stuff do we have? */ - nstime_t ts; /* time stamp */ +typedef struct { guint32 caplen; /* data length in the file */ guint32 len; /* data length on the wire */ int pkt_encap; /* WTAP_ENCAP_ value for this packet */ - int pkt_tsprec; /* WTAP_TSPREC_ value for this packet */ /* pcapng variables */ guint32 interface_id; /* identifier of the interface. */ /* options */ - gchar *opt_comment; /* NULL if not available */ - gboolean has_comment_changed; /* TRUE if the comment has been changed. Currently only valid while dumping. */ - guint64 drop_count; /* number of packets lost (by the interface and the operating system) between this packet and the preceding one. */ guint32 pack_flags; /* XXX - 0 for now (any value for "we don't have it"?) */ - Buffer ft_specific_data; /* file-type specific data */ union wtap_pseudo_header pseudo_header; -}; +} wtap_packet_header; + +typedef struct { + guint record_type; /* the type of record this is - file type-specific value */ +} wtap_ft_specific_header; + +typedef struct { + guint record_type; /* XXX match ft_specific_record_phdr so that we chain off of packet-pcapng_block for now. */ + guint32 caplen; /* data length in the file */ + guint32 len; /* data length on the wire */ + int byte_order; + guint16 cpu_id; + /* guint32 sentinel; */ + guint64 timestamp; /* ns since epoch */ + guint64 thread_id; + guint32 event_len; /* XXX dup of wtap_pkthdr.len */ + guint16 event_type; + /* ... Event ... */ +} wtap_syscall_header; + +typedef struct { + guint rec_type; /* what type of record is this? */ + guint32 presence_flags; /* what stuff do we have? */ + nstime_t ts; /* time stamp */ + int tsprec; /* WTAP_TSPREC_ value for this record */ + union { + wtap_packet_header packet_header; + wtap_ft_specific_header ft_specific_header; + wtap_syscall_header syscall_header; + } rec_header; + /* + * XXX - this should become a full set of options. + */ + gchar *opt_comment; /* NULL if not available */ + gboolean has_comment_changed; /* TRUE if the comment has been changed. Currently only valid while dumping. */ + + /* + * XXX - what is this used for? + */ + Buffer ft_specific_data; /* file-type specific data */ +} wtap_rec; /* * Bits in presence_flags, indicating which of the fields we have. @@ -1300,6 +1311,8 @@ struct wtap_pkthdr { * There could be a presence flag for the packet encapsulation - if it's * absent, use the file encapsulation - but it's not clear that's useful; * we currently do that in the module for the file format. + * + * Only WTAP_HAS_TS applies to all record types. */ #define WTAP_HAS_TS 0x00000001 /**< time stamp */ #define WTAP_HAS_CAP_LEN 0x00000002 /**< captured length separate from on-the-network length */ @@ -1617,22 +1630,23 @@ gboolean wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); WS_DLL_PUBLIC -gboolean wtap_seek_read (wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); +gboolean wtap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, + Buffer *buf, int *err, gchar **err_info); -/*** get various information snippets about the current packet ***/ +/*** get various information snippets about the current record ***/ WS_DLL_PUBLIC -struct wtap_pkthdr *wtap_phdr(wtap *wth); +wtap_rec *wtap_get_rec(wtap *wth); + WS_DLL_PUBLIC -guint8 *wtap_buf_ptr(wtap *wth); +guint8 *wtap_get_buf_ptr(wtap *wth); -/*** initialize a wtap_pkthdr structure ***/ +/*** initialize a wtap_rec structure ***/ WS_DLL_PUBLIC -void wtap_phdr_init(struct wtap_pkthdr *phdr); +void wtap_rec_init(wtap_rec *rec); -/*** clean up a wtap_pkthdr structure, freeing what wtap_phdr_init() allocated */ +/*** clean up a wtap_rec structure, freeing what wtap_rec_init() allocated */ WS_DLL_PUBLIC -void wtap_phdr_cleanup(struct wtap_pkthdr *phdr); +void wtap_rec_cleanup(wtap_rec *rec); /*** get various information snippets about the current file ***/ @@ -1929,7 +1943,7 @@ wtap_dumper* wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snap GArray* nrb_hdrs, int *err); WS_DLL_PUBLIC -gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *, const guint8 *, +gboolean wtap_dump(wtap_dumper *, const wtap_rec *, const guint8 *, int *err, gchar **err_info); WS_DLL_PUBLIC void wtap_dump_flush(wtap_dumper *); |