wiretap: always allocate a block for a record.

Without that, you could add a comment to a record in a file format the
reading code for which doesn't allocate blocks, but the comment doesn't
get saved, as there's no block in which to save the comment option.

This simplifies some code paths, as we're either using the record's
modified block or we're using the block as read from the file, there's
no third possibility.

If we attempt to read a record, and we get an error, and a block was
allocated for the record, unreference it, so the individual file readers
don't have to worry about it.
pespin/rlcmac
Guy Harris 1 year ago
parent eb2037fda4
commit 3cb6403a4c
  1. 1
      epan/frame_data.c
  2. 1
      epan/frame_data.h
  3. 10
      epan/packet.c
  4. 2
      epan/wslua/wslua_dumper.c
  5. 7
      file.c
  6. 1
      plugins/wiretap/usbdump/usbdump.c
  7. 4
      sharkd.c
  8. 4
      sharkd_session.c
  9. 2
      ui/tap_export_pdu.c
  10. 1
      wiretap/5views.c
  11. 1
      wiretap/aethra.c
  12. 1
      wiretap/ascendtext.c
  13. 1
      wiretap/btsnoop.c
  14. 1
      wiretap/busmaster.c
  15. 1
      wiretap/camins.c
  16. 1
      wiretap/candump.c
  17. 1
      wiretap/capsa.c
  18. 1
      wiretap/catapult_dct2000.c
  19. 2
      wiretap/commview.c
  20. 1
      wiretap/cosine.c
  21. 1
      wiretap/csids.c
  22. 1
      wiretap/daintree-sna.c
  23. 1
      wiretap/dbs-etherwatch.c
  24. 1
      wiretap/dct3trace.c
  25. 4
      wiretap/dpa400.c
  26. 5
      wiretap/erf.c
  27. 1
      wiretap/eyesdn.c
  28. 1
      wiretap/hcidump.c
  29. 1
      wiretap/i4btrace.c
  30. 1
      wiretap/ipfix.c
  31. 1
      wiretap/iseries.c
  32. 1
      wiretap/k12.c
  33. 1
      wiretap/k12text.l
  34. 1
      wiretap/lanalyzer.c
  35. 1
      wiretap/libpcap.c
  36. 2
      wiretap/log3gpp.c
  37. 1
      wiretap/logcat.c
  38. 1
      wiretap/logcat_text.c
  39. 1
      wiretap/mp2t.c
  40. 1
      wiretap/mpeg.c
  41. 1
      wiretap/mplog.c
  42. 1
      wiretap/netmon.c
  43. 6
      wiretap/netscaler.c
  44. 1
      wiretap/netscreen.c
  45. 1
      wiretap/nettl.c
  46. 1
      wiretap/nettrace_3gpp_32_423.c
  47. 1
      wiretap/netxray.c
  48. 1
      wiretap/observer.c
  49. 1
      wiretap/packetlogger.c
  50. 1
      wiretap/pppdump.c
  51. 1
      wiretap/radcom.c
  52. 1
      wiretap/snoop.c
  53. 1
      wiretap/stanag4607.c
  54. 1
      wiretap/systemd_journal.c
  55. 1
      wiretap/toshiba.c
  56. 1
      wiretap/visual.c
  57. 1
      wiretap/vms.c
  58. 5
      wiretap/vwr.c
  59. 17
      wiretap/wtap.c

@ -227,7 +227,6 @@ frame_data_init(frame_data *fdata, guint32 num, const wtap_rec *rec,
ws_assert(rec->tsprec <= 0xF);
fdata->tsprec = (unsigned int)rec->tsprec;
fdata->abs_ts = rec->ts;
fdata->has_phdr_block = (rec->block != NULL);
fdata->has_modified_block = 0;
fdata->need_colorize = 0;
fdata->color_filter = NULL;

@ -84,7 +84,6 @@ typedef struct _frame_data {
unsigned int ref_time : 1; /**< 1 = marked as a reference time frame, 0 = normal */
unsigned int ignored : 1; /**< 1 = ignore this frame, 0 = normal */
unsigned int has_ts : 1; /**< 1 = has time stamp, 0 = no time stamp */
unsigned int has_phdr_block : 1; /** 1 = there's a block (possibly with options) for this packet */
unsigned int has_modified_block : 1; /** 1 = block for this packet has been modified */
unsigned int need_colorize : 1; /**< 1 = need to (re-)calculate packet color */
unsigned int tsprec : 4; /**< Time stamp precision -2^tsprec gives up to femtoseconds */

@ -605,11 +605,8 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
if (fd->has_modified_block) {
frame_dissector_data.pkt_block = epan_get_modified_block(edt->session, fd);
}
else if (fd->has_phdr_block) {
frame_dissector_data.pkt_block = rec->block;
}
else {
frame_dissector_data.pkt_block = NULL;
frame_dissector_data.pkt_block = rec->block;
}
frame_dissector_data.file_type_subtype = file_type_subtype;
frame_dissector_data.color_edt = edt; /* Used strictly for "coloring rules" */
@ -682,11 +679,8 @@ dissect_file(epan_dissect_t *edt, wtap_rec *rec,
if (fd->has_modified_block) {
file_dissector_data.pkt_block = epan_get_modified_block(edt->session, fd);
}
else if (fd->has_phdr_block) {
file_dissector_data.pkt_block = rec->block;
}
else {
file_dissector_data.pkt_block = NULL;
file_dissector_data.pkt_block = rec->block;
}
file_dissector_data.color_edt = edt; /* Used strictly for "coloring rules" */

@ -547,7 +547,7 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
if (lua_pinfo->fd->has_modified_block) {
rec.block = epan_get_modified_block(lua_pinfo->epan, lua_pinfo->fd);
rec.block_was_modified = TRUE;
} else if (lua_pinfo->fd->has_phdr_block) {
} else {
rec.block = lua_pinfo->rec->block;
}

@ -4004,13 +4004,12 @@ cf_get_packet_block(capture_file *cf, const frame_data *fd)
/* If this block has been modified, fetch the modified version */
if (fd->has_modified_block)
return wtap_block_ref(cap_file_provider_get_modified_block(&cf->provider, fd));
/* fetch phdr block */
if (fd->has_phdr_block) {
else {
wtap_rec rec; /* Record metadata */
Buffer buf; /* Record data */
wtap_block_t block;
/* fetch record block */
wtap_rec_init(&rec);
ws_buffer_init(&buf, 1514);
@ -4024,7 +4023,6 @@ cf_get_packet_block(capture_file *cf, const frame_data *fd)
ws_buffer_free(&buf);
return block;
}
return NULL;
}
/*
@ -4767,7 +4765,6 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
// XXX: This also ignores non-comment options like verdict
fdata->has_phdr_block = FALSE;
fdata->has_modified_block = FALSE;
}

@ -261,6 +261,7 @@ usbdump_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
/* Setup the per packet structure and fill it with info from this frame */
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
rec->ts.secs = (guint32)bpf_hdr[3] << 24 | (guint32)bpf_hdr[2] << 16 |
(guint32)bpf_hdr[1] << 8 | (guint32)bpf_hdr[0];

@ -729,7 +729,7 @@ sharkd_get_packet_block(const frame_data *fd)
{
if (fd->has_modified_block)
return wtap_block_ref(cap_file_provider_get_modified_block(&cfile.provider, fd));
if (fd->has_phdr_block)
else
{
wtap_rec rec; /* Record metadata */
Buffer buf; /* Record data */
@ -750,8 +750,6 @@ sharkd_get_packet_block(const frame_data *fd)
ws_buffer_free(&buf);
return block;
}
else
return wtap_block_create(WTAP_BLOCK_PACKET);
}
int

@ -1346,7 +1346,7 @@ sharkd_session_process_frames_cb(epan_dissect_t *edt, proto_tree *tree _U_,
*/
if (fdata->has_modified_block)
pkt_block = sharkd_get_modified_block(fdata);
else if (fdata->has_phdr_block)
else
pkt_block = pi->rec->block;
/*
@ -3428,7 +3428,7 @@ sharkd_session_process_frame_cb(epan_dissect_t *edt, proto_tree *tree, struct ep
if (fdata->has_modified_block)
pkt_block = sharkd_get_modified_block(fdata);
else if (fdata->has_phdr_block)
else
pkt_block = pi->rec->block;
if (pkt_block)

@ -65,7 +65,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const
if (pinfo->fd->has_modified_block) {
rec.block = epan_get_modified_block(edt->session, pinfo->fd);
rec.block_was_modified = TRUE;
} else if (pinfo->fd->has_phdr_block) {
} else {
rec.block = pinfo->rec->block;
}

@ -281,6 +281,7 @@ _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
hdr->NanoSecondes = pletoh32(&hdr->NanoSecondes);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = hdr->Utc;
rec->ts.nsecs = hdr->NanoSecondes;

@ -330,6 +330,7 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
msecs = pletoh32(hdr->timestamp);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = aethra->start + (msecs / 1000);
rec->ts.nsecs = (msecs % 1000) * 1000000;

@ -369,6 +369,7 @@ parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec, Buffer *buf,
ascend->inittime -= parser_state.secs;
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
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;

@ -203,6 +203,7 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
ts -= KUnixTimeBase;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = (guint)(ts / 1000000);
rec->ts.nsecs = (guint)((ts % 1000000) * 1000);

@ -180,6 +180,7 @@ busmaster_gen_packet(wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = has_ts ? WTAP_HAS_TS : 0;
rec->ts.secs = secs;
rec->ts.nsecs = nsecs;

@ -377,6 +377,7 @@ camins_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
offset += bytes_read;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* we may or may not have a time stamp */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DVBCI;
if (time_us) {

@ -86,6 +86,7 @@ candump_write_packet(wtap_rec *rec, Buffer *buf, const msg_t *msg)
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts = msg->ts;
rec->tsprec = WTAP_TSPREC_USEC;

@ -420,6 +420,7 @@ capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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;

@ -1278,6 +1278,7 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
guint8 *frame_buffer;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
/* Make sure all packets go to Catapult DCT2000 dissector */

@ -316,6 +316,7 @@ commview_ncf_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
tm.tm_isdst = -1;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = cv_hdr.data_len;
@ -1003,6 +1004,7 @@ commview_ncfx_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
tm.tm_isdst = -1;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
if (length_remaining > WTAP_MAX_PACKET_SIZE_STANDARD) {

@ -383,6 +383,7 @@ parse_cosine_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
tm.tm_year = yy - 1900;
tm.tm_mon = mm - 1;

@ -185,6 +185,7 @@ csids_read_packet(FILE_T fh, csids_t *csids, wtap_rec *rec,
*/
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = hdr.caplen;
rec->rec_header.packet_header.caplen = hdr.caplen;

@ -171,6 +171,7 @@ daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
} while (readLine[0] == COMMENT_LINE);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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",

@ -435,6 +435,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
p = strstr(months, mon);

@ -250,6 +250,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, wtap_rec *rec,
{
/* We've got a full packet! */
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* no time stamp, no separate "on the wire" length */
rec->ts.secs = 0;
rec->ts.nsecs = 0;

@ -106,6 +106,7 @@ static gboolean dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
get_ts(&hdr, &rec->ts);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = 0;
@ -134,6 +135,7 @@ static gboolean dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
ctr++;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = ctr;
@ -171,6 +173,7 @@ static gboolean dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = ctr;
@ -181,6 +184,7 @@ static gboolean dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
get_ts_overflow(&rec->ts);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = ctr;

@ -716,6 +716,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
/*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != file_type_subtype_erf) {*/
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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
@ -733,6 +734,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
*/
/* For now just treat all Provenance records as reports */
rec->rec_type = REC_TYPE_FT_SPECIFIC_REPORT;
rec->block = wtap_block_create(WTAP_BLOCK_FT_SPECIFIC_REPORT);
/* XXX: phdr ft_specific_record_phdr? */
}
#endif
@ -2257,9 +2259,6 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, wtap_rec *rec, union
}
if (comment) {
/* Will be freed by either wtap_sequential_close (for rec = &wth->rec) or by
* the caller of wtap_seek_read. See wtap_rec_cleanup. */
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
wtap_block_add_string_option(rec->block, OPT_COMMENT, comment, strlen(comment));
}

@ -299,6 +299,7 @@ read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = secs;
rec->ts.nsecs = usecs * 1000;

@ -47,6 +47,7 @@ static gboolean hcidump_read_packet(FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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;

@ -245,6 +245,7 @@ i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = length;

@ -155,6 +155,7 @@ ipfix_read_message(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_
*/
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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;

@ -768,6 +768,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_CAP_LEN;
/*

@ -596,6 +596,7 @@ process_packet_data(wtap_rec *rec, Buffer *target, guint8 *buffer,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
ts = pntoh64(buffer + K12_PACKET_TIMESTAMP);

@ -253,6 +253,7 @@ k12text_set_headers(wtap_rec *rec, k12text_state_t *state,
int *err, gchar **err_info)
{
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = 946681200 + (3600*state->g_h) + (60*state->g_m) + state->g_s;

@ -549,6 +549,7 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
time_low = pletoh16(&descriptor[8]);

@ -897,6 +897,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
packet_size -= phdr_len;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
/* Update the timestamp, if not already done */

@ -286,6 +286,7 @@ gboolean log3gpp_read(wtap* wth, wtap_rec* rec, Buffer* buf,
/* All packets go to 3GPP protocol stub dissector */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LOG_3GPP;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
/* Set data_offset to the beginning of the line we're returning.
@ -411,6 +412,7 @@ log3gpp_seek_read(wtap *wth, gint64 seek_off,
/* Make sure all packets go to log3gpp dissector */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LOG_3GPP;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
/* Fill in timestamp (capture base + packet offset) */

@ -198,6 +198,7 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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);

@ -224,6 +224,7 @@ static gboolean logcat_text_read_packet(FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->rec_header.packet_header.caplen = (guint32)strlen(cbuff);
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen;

@ -66,6 +66,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
return FALSE;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/* XXX - relative, not absolute, time stamps */
rec->presence_flags = WTAP_HAS_TS;

@ -173,6 +173,7 @@ mpeg_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
return FALSE;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* we may or may not have a time stamp */
if (!is_random) {

@ -175,6 +175,7 @@ static gboolean mplog_read_packet(FILE_T fh, wtap_rec *rec,
start_p[3] = pkt_bytes & 0xFF;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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));

@ -1077,6 +1077,7 @@ netmon_process_record(wtap *wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* If this is an ATM packet, the first

@ -1128,6 +1128,7 @@ static gboolean nstrace_set_start_time(wtap *wth, int file_version, int *err,
return FALSE;\
}\
(rec)->rec_type = REC_TYPE_PACKET;\
(rec)->block = wtap_block_create(WTAP_BLOCK_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);\
@ -1307,6 +1308,7 @@ static gboolean nstrace_read_v10(wtap *wth, wtap_rec *rec, Buffer *buf,
return FALSE;\
}\
(rec)->rec_type = REC_TYPE_PACKET;\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\
TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\
@ -1507,6 +1509,7 @@ static gboolean nstrace_read_v20(wtap *wth, wtap_rec *rec, Buffer *buf,
return FALSE;\
}\
(rec)->rec_type = REC_TYPE_PACKET;\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\
TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\
@ -1706,6 +1709,7 @@ static gboolean nstrace_read_v30(wtap *wth, wtap_rec *rec, Buffer *buf,
do {\
nspr_pktrace##fullpart##_v##ver##_t *type = (nspr_pktrace##fullpart##_v##ver##_t *) pd;\
(rec)->rec_type = REC_TYPE_PACKET;\
(rec)->block = wtap_block_create(WTAP_BLOCK_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);\
@ -1800,6 +1804,7 @@ static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
do {\
nspr_##structname##_t *fp= (nspr_##structname##_t*)pd;\
(rec)->rec_type = REC_TYPE_PACKET;\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\
TRACE_V##ver##_REC_LEN_OFF((rec),enumprefix,type,structname);\
@ -1924,6 +1929,7 @@ static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
do {\
nspr_##structname##_t *fp= (nspr_##structname##_t*)pd;\
(rec)->rec_type = REC_TYPE_PACKET;\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
SETETHOFFSET_##ver(rec);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\

@ -265,6 +265,7 @@ parse_netscreen_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
gchar dststr[13];
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
/* Suppress compiler warnings */
memset(cap_int, 0, sizeof(cap_int));

@ -542,6 +542,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
return FALSE;
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->rec_header.packet_header.len = length - padlen;
if (caplen < padlen) {

@ -256,6 +256,7 @@ nettrace_msg_to_packet(nettrace_3gpp_32_423_file_info_t *file_info, wtap_rec *re
prev_pos = curr_pos = input + CLEN(c_s_msg);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* start out assuming no special features */
rec->ts.secs = 0;
rec->ts.nsecs = 0;

@ -1621,6 +1621,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
if (netxray->version_major == 0) {
rec->presence_flags = WTAP_HAS_TS;
t = (double)pletoh32(&hdr.old_hdr.timelo)

@ -546,6 +546,7 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header,
{
/* set the wiretap record metadata fields */
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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) {

@ -366,6 +366,7 @@ packetlogger_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = pl_hdr.len - 8;

@ -320,6 +320,7 @@ pppdump_set_phdr(wtap_rec *rec, int num_bytes,
direction_enum direction)
{
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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;

@ -320,6 +320,7 @@ radcom_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
*/
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
tm.tm_year = pletoh16(&hdr.date.year)-1900;

@ -609,6 +609,7 @@ snoop_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_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;

@ -67,6 +67,7 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/* The next 4 bytes are the packet length */
packet_size = pntoh32(&stanag_pkt_hdr[2]);

@ -230,6 +230,7 @@ systemd_journal_read_export_entry(FILE_T fh, wtap_rec *rec, Buffer *buf, int *er
}
rec->rec_type = REC_TYPE_SYSTEMD_JOURNAL_EXPORT;
rec->block = wtap_block_create(WTAP_BLOCK_SYSTEMD_JOURNAL_EXPORT);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->rec_header.systemd_journal_export_header.record_len = (guint32) fld_end;

@ -314,6 +314,7 @@ parse_toshiba_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = hr * 3600 + min * 60 + sec;
rec->ts.nsecs = csec * 10000000;

@ -331,6 +331,7 @@ visual_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
packet_size = pletoh16(&vpkt_hdr.incl_len);
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
/* Set the packet time and length. */

@ -416,6 +416,7 @@ parse_vms_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_in
tm.tm_isdst = -1;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = mktime(&tm);
rec->ts.nsecs = csec * 10000000;

@ -1285,6 +1285,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record,
record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE;
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen);
@ -1700,6 +1701,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record,
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen);
@ -1880,6 +1882,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen);
@ -2212,6 +2215,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen);
@ -2721,6 +2725,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record,
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
/*etap_hdr.vw_ip_length = (guint16)ip_len;*/

@ -1542,6 +1542,13 @@ wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
*/
if (*err == 0)
*err = file_error(wth->fh, err_info);
if (rec->block != NULL) {
/*
* Unreference any block created for this record.
*/
wtap_block_unref(rec->block);
rec->block = NULL;
}
return FALSE; /* failure */
}
@ -1697,8 +1704,16 @@ wtap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
*err = 0;
*err_info = NULL;
if (!wth->subtype_seek_read(wth, seek_off, rec, buf, err, err_info))
if (!wth->subtype_seek_read(wth, seek_off, rec, buf, err, err_info)) {
if (rec->block != NULL) {
/*
* Unreference any block created for this record.
*/
wtap_block_unref(rec->block);
rec->block = NULL;
}
return FALSE;
}
/*
* Is this a packet record?

Loading…
Cancel
Save