aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-04-04 18:56:27 -0700
committerGuy Harris <guy@alum.mit.edu>2019-04-05 02:49:43 +0000
commit8a5b26efb14b7f8f5375383436f03108d52d9aed (patch)
treeeb57791fc53deab1c618b259e11092f122a8ee97
parentb572b65e518937f43b630991c07369d8e0c79f53 (diff)
Have wtap_read() fill in a wtap_rec and Buffer.
That makes it - and the routines that implement it - work more like the seek-read routine. Change-Id: I0cace2d0e4c9ebfc21ac98fd1af1ec70f60a240d Reviewed-on: https://code.wireshark.org/review/32727 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--capinfos.c58
-rw-r--r--capture_info.c24
-rw-r--r--debian/libwiretap0.symbols2
-rw-r--r--editcap.c14
-rw-r--r--epan/wslua/wslua_file_handler.c18
-rw-r--r--file.c62
-rw-r--r--plugins/wiretap/usbdump/usbdump.c9
-rw-r--r--reordercap.c21
-rw-r--r--sharkd.c14
-rw-r--r--tfshark.c3
-rw-r--r--tshark.c61
-rw-r--r--ui/file_dialog.c12
-rw-r--r--wiretap/5views.c17
-rw-r--r--wiretap/aethra.c20
-rw-r--r--wiretap/ascendtext.c18
-rw-r--r--wiretap/btsnoop.c13
-rw-r--r--wiretap/camins.c7
-rw-r--r--wiretap/capsa.c11
-rw-r--r--wiretap/catapult_dct2000.c10
-rw-r--r--wiretap/commview.c10
-rw-r--r--wiretap/cosine.c11
-rw-r--r--wiretap/csids.c11
-rw-r--r--wiretap/daintree-sna.c10
-rw-r--r--wiretap/dbs-etherwatch.c11
-rw-r--r--wiretap/dct3trace.c11
-rw-r--r--wiretap/dpa400.c7
-rw-r--r--wiretap/erf.c22
-rw-r--r--wiretap/eyesdn.c13
-rw-r--r--wiretap/file_access.c5
-rw-r--r--wiretap/hcidump.c7
-rw-r--r--wiretap/i4btrace.c11
-rw-r--r--wiretap/ipfix.c12
-rw-r--r--wiretap/iptrace.c30
-rw-r--r--wiretap/iseries.c10
-rw-r--r--wiretap/k12.c4
-rw-r--r--wiretap/k12text.l8
-rw-r--r--wiretap/lanalyzer.c12
-rw-r--r--wiretap/libpcap.c11
-rw-r--r--wiretap/logcat.c6
-rw-r--r--wiretap/logcat_text.c7
-rw-r--r--wiretap/merge.c20
-rw-r--r--wiretap/merge.h2
-rw-r--r--wiretap/mp2t.c7
-rw-r--r--wiretap/mpeg.c6
-rw-r--r--wiretap/mplog.c6
-rw-r--r--wiretap/netmon.c12
-rw-r--r--wiretap/netscaler.c111
-rw-r--r--wiretap/netscreen.c21
-rw-r--r--wiretap/nettl.c15
-rw-r--r--wiretap/nettrace_3gpp_32_423.c38
-rw-r--r--wiretap/network_instruments.c16
-rw-r--r--wiretap/netxray.c17
-rw-r--r--wiretap/ngsniffer.c9
-rw-r--r--wiretap/packetlogger.c9
-rw-r--r--wiretap/pcapng.c13
-rw-r--r--wiretap/peekclassic.c28
-rw-r--r--wiretap/peektagged.c11
-rw-r--r--wiretap/pppdump.c24
-rw-r--r--wiretap/radcom.c11
-rw-r--r--wiretap/snoop.c11
-rw-r--r--wiretap/stanag4607.c5
-rw-r--r--wiretap/systemd_journal.c10
-rw-r--r--wiretap/toshiba.c11
-rw-r--r--wiretap/visual.c11
-rw-r--r--wiretap/vms.c10
-rw-r--r--wiretap/vwr.c12
-rw-r--r--wiretap/wtap-int.h8
-rw-r--r--wiretap/wtap.c42
-rw-r--r--wiretap/wtap.h49
69 files changed, 597 insertions, 571 deletions
diff --git a/capinfos.c b/capinfos.c
index 76d9a3b261..8a85276ba3 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -1105,7 +1105,8 @@ process_cap_file(const char *filename, gboolean need_separator)
gint64 bytes = 0;
guint32 snaplen_min_inferred = 0xffffffff;
guint32 snaplen_max_inferred = 0;
- wtap_rec *rec;
+ wtap_rec rec;
+ Buffer buf;
capture_info cf_info;
gboolean have_times = TRUE;
nstime_t start_time;
@@ -1164,28 +1165,29 @@ process_cap_file(const char *filename, gboolean need_separator)
num_decryption_secrets = 0;
/* Tally up data that we need to parse through the file to find */
- while (wtap_read(wth, &err, &err_info, &data_offset)) {
- rec = wtap_get_rec(wth);
- if (rec->presence_flags & WTAP_HAS_TS) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ while (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
+ if (rec.presence_flags & WTAP_HAS_TS) {
prev_time = cur_time;
- cur_time = rec->ts;
+ cur_time = rec.ts;
if (packet == 0) {
- start_time = rec->ts;
- start_time_tsprec = rec->tsprec;
- stop_time = rec->ts;
- stop_time_tsprec = rec->tsprec;
- prev_time = rec->ts;
+ start_time = rec.ts;
+ start_time_tsprec = rec.tsprec;
+ stop_time = rec.ts;
+ stop_time_tsprec = rec.tsprec;
+ prev_time = rec.ts;
}
if (nstime_cmp(&cur_time, &prev_time) < 0) {
order = NOT_IN_ORDER;
}
if (nstime_cmp(&cur_time, &start_time) < 0) {
start_time = cur_time;
- start_time_tsprec = rec->tsprec;
+ start_time_tsprec = rec.tsprec;
}
if (nstime_cmp(&cur_time, &stop_time) > 0) {
stop_time = cur_time;
- stop_time_tsprec = rec->tsprec;
+ stop_time_tsprec = rec.tsprec;
}
} else {
have_times = FALSE; /* at least one packet has no time stamp */
@@ -1193,33 +1195,33 @@ process_cap_file(const char *filename, gboolean need_separator)
order = ORDER_UNKNOWN;
}
- if (rec->rec_type == REC_TYPE_PACKET) {
- bytes += rec->rec_header.packet_header.len;
+ if (rec.rec_type == REC_TYPE_PACKET) {
+ bytes += rec.rec_header.packet_header.len;
packet++;
/* If caplen < len for a rcd, then presumably */
/* 'Limit packet capture length' was done for this rcd. */
/* Keep track as to the min/max actual snapshot lengths */
/* seen for this file. */
- if (rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len) {
- if (rec->rec_header.packet_header.caplen < snaplen_min_inferred)
- snaplen_min_inferred = rec->rec_header.packet_header.caplen;
- if (rec->rec_header.packet_header.caplen > snaplen_max_inferred)
- snaplen_max_inferred = rec->rec_header.packet_header.caplen;
+ if (rec.rec_header.packet_header.caplen < rec.rec_header.packet_header.len) {
+ if (rec.rec_header.packet_header.caplen < snaplen_min_inferred)
+ snaplen_min_inferred = rec.rec_header.packet_header.caplen;
+ if (rec.rec_header.packet_header.caplen > snaplen_max_inferred)
+ snaplen_max_inferred = rec.rec_header.packet_header.caplen;
}
- if ((rec->rec_header.packet_header.pkt_encap > 0) &&
- (rec->rec_header.packet_header.pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
- cf_info.encap_counts[rec->rec_header.packet_header.pkt_encap] += 1;
+ if ((rec.rec_header.packet_header.pkt_encap > 0) &&
+ (rec.rec_header.packet_header.pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
+ cf_info.encap_counts[rec.rec_header.packet_header.pkt_encap] += 1;
} else {
fprintf(stderr, "capinfos: Unknown packet encapsulation %d in frame %u of file \"%s\"\n",
- rec->rec_header.packet_header.pkt_encap, packet, filename);
+ rec.rec_header.packet_header.pkt_encap, packet, filename);
}
/* Packet interface_id info */
- if (rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
+ if (rec.presence_flags & WTAP_HAS_INTERFACE_ID) {
/* cf_info.num_interfaces is size, not index, so it's one more than max index */
- if (rec->rec_header.packet_header.interface_id >= cf_info.num_interfaces) {
+ if (rec.rec_header.packet_header.interface_id >= cf_info.num_interfaces) {
/*
* OK, re-fetch the number of interfaces, as there might have
* been an interface that was in the middle of packets, and
@@ -1234,9 +1236,9 @@ process_cap_file(const char *filename, gboolean need_separator)
g_free(idb_info);
idb_info = NULL;
}
- if (rec->rec_header.packet_header.interface_id < cf_info.num_interfaces) {
+ if (rec.rec_header.packet_header.interface_id < cf_info.num_interfaces) {
g_array_index(cf_info.interface_packet_counts, guint32,
- rec->rec_header.packet_header.interface_id) += 1;
+ rec.rec_header.packet_header.interface_id) += 1;
}
else {
cf_info.pkt_interface_id_unknown += 1;
@@ -1254,6 +1256,8 @@ process_cap_file(const char *filename, gboolean need_separator)
}
} /* while */
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
/*
* Get IDB info strings.
diff --git a/capture_info.c b/capture_info.c
index f51f3a3fe7..7e7fab6d4c 100644
--- a/capture_info.c
+++ b/capture_info.c
@@ -40,32 +40,36 @@ void capture_info_new_packets(int to_read, info_data_t* cap_info)
int err;
gchar *err_info;
gint64 data_offset;
- wtap_rec *rec;
+ wtap_rec rec;
+ Buffer buf;
union wtap_pseudo_header *pseudo_header;
int wtap_linktype;
- const guchar *buf;
-
cap_info->ui.new_packets = to_read;
/*g_warning("new packets: %u", to_read);*/
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
while (to_read > 0) {
wtap_cleareof(cap_info->wtap);
- if (wtap_read(cap_info->wtap, &err, &err_info, &data_offset)) {
- rec = wtap_get_rec(cap_info->wtap);
- if (rec->rec_type == REC_TYPE_PACKET) {
- pseudo_header = &rec->rec_header.packet_header.pseudo_header;
- wtap_linktype = rec->rec_header.packet_header.pkt_encap;
- buf = wtap_get_buf_ptr(cap_info->wtap);
+ if (wtap_read(cap_info->wtap, &rec, &buf, &err, &err_info, &data_offset)) {
+ if (rec.rec_type == REC_TYPE_PACKET) {
+ pseudo_header = &rec.rec_header.packet_header.pseudo_header;
+ wtap_linktype = rec.rec_header.packet_header.pkt_encap;
- capture_info_packet(cap_info, wtap_linktype, buf, rec->rec_header.packet_header.caplen, pseudo_header);
+ capture_info_packet(cap_info, wtap_linktype,
+ ws_buffer_start_ptr(&buf),
+ rec.rec_header.packet_header.caplen,
+ pseudo_header);
/*g_warning("new packet");*/
to_read--;
}
}
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
capture_info_ui_update(&cap_info->ui);
}
diff --git a/debian/libwiretap0.symbols b/debian/libwiretap0.symbols
index 932b74e4fb..cb6074d8df 100644
--- a/debian/libwiretap0.symbols
+++ b/debian/libwiretap0.symbols
@@ -102,7 +102,6 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_get_all_capture_file_extensions_list@Base 2.3.0
wtap_get_all_compression_type_extensions_list@Base 2.9.0
wtap_get_all_file_extensions_list@Base 2.6.2
- wtap_get_buf_ptr@Base 2.5.1
wtap_get_bytes_dumped@Base 1.9.1
wtap_get_compression_type@Base 2.9.0
wtap_get_debug_if_descr@Base 1.99.9
@@ -112,7 +111,6 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_get_num_encap_types@Base 1.9.1
wtap_get_num_file_type_extensions@Base 1.12.0~rc1
wtap_get_num_file_types_subtypes@Base 1.12.0~rc1
- wtap_get_rec@Base 2.5.1
wtap_get_savable_file_types_subtypes@Base 1.12.0~rc1
wtap_has_open_info@Base 1.12.0~rc1
wtap_init@Base 2.3.0
diff --git a/editcap.c b/editcap.c
index 5d6564a582..e53e4bed3b 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1054,6 +1054,8 @@ main(int argc, char *argv[])
guint max_packet_number = 0;
GArray *dsb_types = NULL;
GPtrArray *dsb_filenames = NULL;
+ wtap_rec read_rec;
+ Buffer read_buf;
const wtap_rec *rec;
wtap_rec temp_rec;
wtap_dump_params params = WTAP_DUMP_PARAMS_INIT;
@@ -1566,13 +1568,15 @@ main(int argc, char *argv[])
}
/* Read all of the packets in turn */
- while (wtap_read(wth, &read_err, &read_err_info, &data_offset)) {
+ wtap_rec_init(&read_rec);
+ ws_buffer_init(&read_buf, 1500);
+ while (wtap_read(wth, &read_rec, &read_buf, &read_err, &read_err_info, &data_offset)) {
if (max_packet_number <= read_count)
break;
read_count++;
- rec = wtap_get_rec(wth);
+ rec = &read_rec;
/* Extra actions for the first packet */
if (read_count == 1) {
@@ -1605,7 +1609,7 @@ main(int argc, char *argv[])
} /* first packet only handling */
- buf = wtap_get_buf_ptr(wth);
+ buf = ws_buffer_start_ptr(&read_buf);
/*
* Not all packets have time stamps. Only process the time
@@ -1699,7 +1703,7 @@ main(int argc, char *argv[])
/* We simply write it, perhaps after truncating it; we could
* do other things, like modify it. */
- rec = wtap_get_rec(wth);
+ rec = &read_rec;
if (rec->presence_flags & WTAP_HAS_TS) {
/* Do we adjust timestamps to ensure strict chronological
@@ -2024,6 +2028,8 @@ main(int argc, char *argv[])
}
count++;
}
+ wtap_rec_cleanup(&read_rec);
+ ws_buffer_free(&read_buf);
g_free(fprefix);
g_free(fsuffix);
diff --git a/epan/wslua/wslua_file_handler.c b/epan/wslua/wslua_file_handler.c
index f9bf5edebb..11f90994f7 100644
--- a/epan/wslua/wslua_file_handler.c
+++ b/epan/wslua/wslua_file_handler.c
@@ -130,8 +130,8 @@ static gboolean in_routine = FALSE;
/* some declarations */
static gboolean
-wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+wslua_filehandler_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *offset);
static gboolean
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf,
@@ -245,8 +245,8 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
* This will be the seek_off parameter when this frame is re-read.
*/
static gboolean
-wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+wslua_filehandler_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *offset)
{
FileHandler fh = (FileHandler)(wth->wslua_data);
int retval = -1;
@@ -262,12 +262,12 @@ wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
*err = errno = 0;
}
- g_free(wth->rec.opt_comment);
- wth->rec.opt_comment = NULL;
+ g_free(rec->opt_comment);
+ rec->opt_comment = NULL;
fp = push_File(L, wth->fh);
fc = push_CaptureInfo(L, wth, FALSE);
- fi = push_FrameInfo(L, &wth->rec, wth->rec_data);
+ fi = push_FrameInfo(L, rec, buf);
switch ( lua_pcall(L,3,1,1) ) {
case 0:
@@ -279,7 +279,7 @@ wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
* succeed without advancing data offset. Should it fail instead?
*/
if (lua_type(L, -1) == LUA_TNUMBER) {
- *data_offset = wslua_togint64(L, -1);
+ *offset = wslua_togint64(L, -1);
retval = 1;
break;
}
@@ -320,7 +320,7 @@ wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
*err = errno = 0;
}
- g_free(wth->rec.opt_comment);
+ g_free(rec->opt_comment);
rec->opt_comment = NULL;
fp = push_File(L, wth->random_fh);
diff --git a/file.c b/file.c
index b73b75dd9a..bc00708a7a 100644
--- a/file.c
+++ b/file.c
@@ -71,8 +71,8 @@
# include <ws2tcpip.h>
#endif
-static gboolean read_record(capture_file *cf, dfilter_t *dfcode,
- epan_dissect_t *edt, column_info *cinfo, gint64 offset);
+static gboolean read_record(capture_file *cf, wtap_rec *rec, Buffer *buf,
+ dfilter_t *dfcode, epan_dissect_t *edt, column_info *cinfo, gint64 offset);
static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
@@ -569,6 +569,9 @@ cf_read(capture_file *cf, gboolean reloading)
gint64 file_pos;
gint64 data_offset;
+ wtap_rec rec;
+ Buffer buf;
+
float progbar_val;
gchar status_str[100];
@@ -582,7 +585,10 @@ cf_read(capture_file *cf, gboolean reloading)
g_timer_start(prog_timer);
- while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ while ((wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info,
+ &data_offset))) {
if (size >= 0) {
count++;
file_pos = wtap_read_so_far(cf->provider.wth);
@@ -637,8 +643,10 @@ cf_read(capture_file *cf, gboolean reloading)
hours even on fast machines) just to see that it was the wrong file. */
break;
}
- read_record(cf, dfcode, &edt, cinfo, data_offset);
+ read_record(cf, &rec, &buf, dfcode, &edt, cinfo, data_offset);
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
}
CATCH(OutOfMemoryError) {
simple_message_box(ESD_TYPE_ERROR, NULL,
@@ -791,15 +799,20 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
TRY {
+ wtap_rec rec;
+ Buffer buf;
gint64 data_offset = 0;
column_info *cinfo;
/* If any tap listeners require the columns, construct them. */
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
while (to_read != 0) {
wtap_cleareof(cf->provider.wth);
- if (!wtap_read(cf->provider.wth, err, &err_info, &data_offset)) {
+ if (!wtap_read(cf->provider.wth, &rec, &buf, err, &err_info,
+ &data_offset)) {
break;
}
if (cf->state == FILE_READ_ABORTED) {
@@ -808,11 +821,13 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
aren't any packets left to read) exit. */
break;
}
- if (read_record(cf, dfcode, &edt, cinfo, data_offset)) {
+ if (read_record(cf, &rec, &buf, dfcode, &edt, cinfo, data_offset)) {
newly_displayed_packets++;
}
to_read--;
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
}
CATCH(OutOfMemoryError) {
simple_message_box(ESD_TYPE_ERROR, NULL,
@@ -886,6 +901,8 @@ cf_read_status_t
cf_finish_tail(capture_file *cf, int *err)
{
gchar *err_info;
+ wtap_rec rec;
+ Buffer buf;
gint64 data_offset;
dfilter_t *dfcode;
column_info *cinfo;
@@ -934,15 +951,19 @@ cf_finish_tail(capture_file *cf, int *err)
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
- while ((wtap_read(cf->provider.wth, err, &err_info, &data_offset))) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ while ((wtap_read(cf->provider.wth, &rec, &buf, err, &err_info, &data_offset))) {
if (cf->state == FILE_READ_ABORTED) {
/* Well, the user decided to abort the read. Break out of the
loop, and let the code below (which is called even if there
aren't any packets left to read) exit. */
break;
}
- read_record(cf, dfcode, &edt, cinfo, data_offset);
+ read_record(cf, &rec, &buf, dfcode, &edt, cinfo, data_offset);
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
/* Cleanup and release all dfilter resources */
dfilter_free(dfcode);
@@ -1218,11 +1239,9 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
* FALSE otherwise.
*/
static gboolean
-read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
- column_info *cinfo, gint64 offset)
+read_record(capture_file *cf, wtap_rec *rec, Buffer *buf, dfilter_t *dfcode,
+ epan_dissect_t *edt, column_info *cinfo, gint64 offset)
{
- wtap_rec *rec = wtap_get_rec(cf->provider.wth);
- const guint8 *pd = wtap_get_buf_ptr(cf->provider.wth);
frame_data fdlocal;
frame_data *fdata;
gboolean passed = TRUE;
@@ -1248,7 +1267,7 @@ read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
epan_dissect_init(&rf_edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&rf_edt, cf->rfcode);
epan_dissect_run(&rf_edt, cf->cd_t, rec,
- frame_tvbuff_new(&cf->provider, &fdlocal, pd),
+ frame_tvbuff_new_buffer(&cf->provider, &fdlocal, buf),
&fdlocal, NULL);
passed = dfilter_apply_edt(cf->rfcode, &rf_edt);
epan_dissect_cleanup(&rf_edt);
@@ -1269,7 +1288,7 @@ read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
* This will be done once all (new) packets have been scanned. */
if (!cf->redissecting && cf->redissection_queued == RESCAN_NONE) {
add_packet_to_packet_list(fdata, cf, edt, dfcode,
- cinfo, rec, pd, TRUE);
+ cinfo, rec, ws_buffer_start_ptr(buf), TRUE);
}
}
@@ -4192,7 +4211,8 @@ cf_has_unsaved_data(capture_file *cf)
static cf_read_status_t
rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
{
- const wtap_rec *rec;
+ wtap_rec rec;
+ Buffer buf;
int err;
gchar *err_info;
gchar *name_ptr;
@@ -4259,8 +4279,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
g_get_current_time(&start_time);
framenum = 0;
- rec = wtap_get_rec(cf->provider.wth);
- while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ while ((wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info,
+ &data_offset))) {
framenum++;
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
fdata->file_off = data_offset;
@@ -4304,10 +4326,12 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
link-layer encapsulation type, it'd be O(N^2) to read the file, but
there are probably going to be a small number of encapsulation types
in a file. */
- if (rec->rec_type == REC_TYPE_PACKET) {
- cf_add_encapsulation_type(cf, rec->rec_header.packet_header.pkt_encap);
+ if (rec.rec_type == REC_TYPE_PACKET) {
+ cf_add_encapsulation_type(cf, rec.rec_header.packet_header.pkt_encap);
}
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
/* Free the display name */
g_free(name_ptr);
diff --git a/plugins/wiretap/usbdump/usbdump.c b/plugins/wiretap/usbdump/usbdump.c
index 2730602466..402667f3b1 100644
--- a/plugins/wiretap/usbdump/usbdump.c
+++ b/plugins/wiretap/usbdump/usbdump.c
@@ -63,7 +63,8 @@ typedef struct {
} usbdump_info_t;
-static gboolean usbdump_read(wtap *wth, int *err, gchar **err_info,
+static gboolean usbdump_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info,
gint64 *data_offset);
static gboolean usbdump_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf,
@@ -159,7 +160,8 @@ usbdump_open(wtap *wth, int *err, char **err_info)
* support subsequent random access read.
*/
static gboolean
-usbdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+usbdump_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info,
+ gint64 *data_offset)
{
usbdump_info_t *usbdump_info = (usbdump_info_t *)wth->priv;
@@ -167,8 +169,7 @@ usbdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*data_offset = file_tell(wth->fh);
/* Try to read a packet worth of data */
- if (!usbdump_read_packet(wth, wth->fh, &wth->rec, wth->rec_data,
- err, err_info))
+ if (!usbdump_read_packet(wth, wth->fh, rec, buf, err, err_info))
return FALSE;
/* Check if we overrun the multiframe during the last read */
diff --git a/reordercap.c b/reordercap.c
index 7f3463d89b..c72e082a2c 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -166,12 +166,11 @@ main(int argc, char *argv[])
char *init_progfile_dir_error;
wtap *wth = NULL;
wtap_dumper *pdh = NULL;
- wtap_rec dump_rec;
+ wtap_rec rec;
Buffer buf;
int err;
gchar *err_info;
gint64 data_offset;
- const wtap_rec *rec;
guint wrong_order_count = 0;
gboolean write_output_regardless = TRUE;
guint i;
@@ -284,16 +283,16 @@ main(int argc, char *argv[])
frames = g_ptr_array_new();
/* Read each frame from infile */
- while (wtap_read(wth, &err, &err_info, &data_offset)) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ while (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
FrameRecord_t *newFrameRecord;
- rec = wtap_get_rec(wth);
-
newFrameRecord = g_slice_new(FrameRecord_t);
newFrameRecord->num = frames->len + 1;
newFrameRecord->offset = data_offset;
- if (rec->presence_flags & WTAP_HAS_TS) {
- newFrameRecord->frame_time = rec->ts;
+ if (rec.presence_flags & WTAP_HAS_TS) {
+ newFrameRecord->frame_time = rec.ts;
} else {
nstime_set_unset(&newFrameRecord->frame_time);
}
@@ -305,6 +304,8 @@ main(int argc, char *argv[])
g_ptr_array_add(frames, newFrameRecord);
prevFrame = newFrameRecord;
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
if (err != 0) {
/* Print a message noting that the read failed somewhere along the line. */
cfile_read_failure_message("reordercap", infile, err, err_info);
@@ -318,18 +319,18 @@ main(int argc, char *argv[])
}
/* Write out each sorted frame in turn */
- wtap_rec_init(&dump_rec);
+ wtap_rec_init(&rec);
ws_buffer_init(&buf, 1500);
for (i = 0; i < frames->len; i++) {
FrameRecord_t *frame = (FrameRecord_t *)frames->pdata[i];
/* Avoid writing if already sorted and configured to */
if (write_output_regardless || (wrong_order_count > 0)) {
- frame_write(frame, wth, pdh, &dump_rec, &buf, infile, outfile);
+ frame_write(frame, wth, pdh, &rec, &buf, infile, outfile);
}
g_slice_free(FrameRecord_t, frame);
}
- wtap_rec_cleanup(&dump_rec);
+ wtap_rec_cleanup(&rec);
ws_buffer_free(&buf);
if (!write_output_regardless && (wrong_order_count == 0)) {
diff --git a/sharkd.c b/sharkd.c
index 7388df61b2..21d74f8d32 100644
--- a/sharkd.c
+++ b/sharkd.c
@@ -320,6 +320,8 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
int err;
gchar *err_info = NULL;
gint64 data_offset;
+ wtap_rec rec;
+ Buffer buf;
epan_dissect_t *edt = NULL;
{
@@ -348,9 +350,12 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
}
- while (wtap_read(cf->provider.wth, &err, &err_info, &data_offset)) {
- if (process_packet(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
- wtap_get_buf_ptr(cf->provider.wth))) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
+ while (wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info, &data_offset)) {
+ if (process_packet(cf, edt, data_offset, &rec,
+ ws_buffer_start_ptr(&buf))) {
/* Stop reading if we have the maximum number of packets;
* When the -c option has not been used, max_packet_count
* starts at 0, which practically means, never stop reading.
@@ -368,6 +373,9 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
edt = NULL;
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
+
/* Close the sequential I/O side, to free up memory it requires. */
wtap_sequential_close(cf->provider.wth);
diff --git a/tfshark.c b/tfshark.c
index 5269f61ef6..86b0121482 100644
--- a/tfshark.c
+++ b/tfshark.c
@@ -1307,8 +1307,7 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
}
while (local_wtap_read(cf, &file_rec, &err, &err_info, &data_offset, &raw_data)) {
- if (process_packet_first_pass(cf, edt, data_offset, &file_rec/*wtap_get_rec(cf->provider.wth)*/,
- wtap_get_buf_ptr(cf->provider.wth))) {
+ if (process_packet_first_pass(cf, edt, data_offset, &file_rec, raw_data)) {
/* Stop reading if we have the maximum number of packets;
* When the -c option has not been used, max_packet_count
diff --git a/tshark.c b/tshark.c
index 786790a1ff..dd3849f484 100644
--- a/tshark.c
+++ b/tshark.c
@@ -241,8 +241,8 @@ typedef enum {
static process_file_status_t process_cap_file(capture_file *, char *, int, gboolean, int, gint64);
static gboolean process_packet_single_pass(capture_file *cf,
- epan_dissect_t *edt, gint64 offset, wtap_rec *rec,
- const guchar *pd, guint tap_flags);
+ epan_dissect_t *edt, gint64 offset, wtap_rec *rec, Buffer *buf,
+ guint tap_flags);
static void show_print_file_io_error(int err);
static gboolean write_preamble(capture_file *cf);
static gboolean print_packet(capture_file *cf, epan_dissect_t *edt);
@@ -2702,6 +2702,8 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
if (do_dissection) {
gboolean create_proto_tree;
epan_dissect_t *edt;
+ wtap_rec rec;
+ Buffer buf;
/*
* Determine whether we need to create a protocol tree.
@@ -2734,9 +2736,12 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
("packet_details" is true). */
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
while (to_read-- && cf->provider.wth) {
wtap_cleareof(cf->provider.wth);
- ret = wtap_read(cf->provider.wth, &err, &err_info, &data_offset);
+ ret = wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info, &data_offset);
reset_epan_mem(cf, edt, create_proto_tree, print_packet_info && print_details);
if (ret == FALSE) {
/* read from file failed, tell the capture child to stop */
@@ -2744,9 +2749,8 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
wtap_close(cf->provider.wth);
cf->provider.wth = NULL;
} else {
- ret = process_packet_single_pass(cf, edt, data_offset,
- wtap_get_rec(cf->provider.wth),
- wtap_get_buf_ptr(cf->provider.wth), tap_flags);
+ ret = process_packet_single_pass(cf, edt, data_offset, &rec, &buf,
+ tap_flags);
}
if (ret != FALSE) {
/* packet successfully read and gone through the "Read Filter" */
@@ -2756,6 +2760,9 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
epan_dissect_free(edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
+
} else {
/*
* Dumpcap's doing all the work; we're not doing any dissection.
@@ -2918,8 +2925,7 @@ capture_cleanup(int signum _U_)
static gboolean
process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
- gint64 offset, wtap_rec *rec,
- const guchar *pd)
+ gint64 offset, wtap_rec *rec, Buffer *buf)
{
frame_data fdlocal;
guint32 framenum;
@@ -2962,7 +2968,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
}
epan_dissect_run(edt, cf->cd_t, rec,
- frame_tvbuff_new(&cf->provider, &fdlocal, pd),
+ frame_tvbuff_new_buffer(&cf->provider, &fdlocal, buf),
&fdlocal, NULL);
/* Run the read filter if we have one. */
@@ -3055,10 +3061,15 @@ static pass_status_t
process_cap_file_first_pass(capture_file *cf, int max_packet_count,
gint64 max_byte_count, int *err, gchar **err_info)
{
+ wtap_rec rec;
+ Buffer buf;
epan_dissect_t *edt = NULL;
gint64 data_offset;
pass_status_t status = PASS_SUCCEEDED;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
/* Allocate a frame_data_sequence for all the frames. */
cf->provider.frames = new_frame_data_sequence();
@@ -3088,13 +3099,12 @@ process_cap_file_first_pass(capture_file *cf, int max_packet_count,
tshark_debug("tshark: reading records for first pass");
*err = 0;
- while (wtap_read(cf->provider.wth, err, err_info, &data_offset)) {
+ while (wtap_read(cf->provider.wth, &rec, &buf, err, err_info, &data_offset)) {
if (read_interrupted) {
status = PASS_INTERRUPTED;
break;
}
- if (process_packet_first_pass(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
- wtap_get_buf_ptr(cf->provider.wth))) {
+ if (process_packet_first_pass(cf, edt, data_offset, &rec, &buf)) {
/* Stop reading if we have the maximum number of packets;
* When the -c option has not been used, max_packet_count
* starts at 0, which practically means, never stop reading.
@@ -3124,6 +3134,9 @@ process_cap_file_first_pass(capture_file *cf, int max_packet_count,
cf->provider.prev_dis = NULL;
cf->provider.prev_cap = NULL;
+ ws_buffer_free(&buf);
+ wtap_rec_cleanup(&rec);
+
return status;
}
@@ -3285,8 +3298,7 @@ process_cap_file_second_pass(capture_file *cf, wtap_dumper *pdh,
break;
}
tshark_debug("tshark: invoking process_packet_second_pass() for frame #%d", framenum);
- if (process_packet_second_pass(cf, edt, fdata, &rec, &buf,
- tap_flags)) {
+ if (process_packet_second_pass(cf, edt, fdata, &rec, &buf, tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
@@ -3318,6 +3330,8 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
int *err, gchar **err_info,
volatile guint32 *err_framenum)
{
+ wtap_rec rec;
+ Buffer buf;
gboolean create_proto_tree = FALSE;
gboolean filtering_tap_listeners;
guint tap_flags;
@@ -3326,6 +3340,9 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
gint64 data_offset;
pass_status_t status = PASS_SUCCEEDED;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
framenum = 0;
/* Do we have any tap listeners with filters? */
@@ -3377,7 +3394,7 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
set_resolution_synchrony(TRUE);
*err = 0;
- while (wtap_read(cf->provider.wth, err, err_info, &data_offset)) {
+ while (wtap_read(cf->provider.wth, &rec, &buf, err, err_info, &data_offset)) {
if (read_interrupted) {
status = PASS_INTERRUPTED;
break;
@@ -3388,15 +3405,13 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
reset_epan_mem(cf, edt, create_proto_tree, print_packet_info && print_details);
- if (process_packet_single_pass(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
- wtap_get_buf_ptr(cf->provider.wth), tap_flags)) {
+ if (process_packet_single_pass(cf, edt, data_offset, &rec, &buf, tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
if (pdh != NULL) {
tshark_debug("tshark: writing packet #%d to outfile", framenum);
- if (!wtap_dump(pdh, wtap_get_rec(cf->provider.wth),
- wtap_get_buf_ptr(cf->provider.wth), err, err_info)) {
+ if (!wtap_dump(pdh, &rec, ws_buffer_start_ptr(&buf), err, err_info)) {
/* Error writing to the output file. */
tshark_debug("tshark: error writing to a capture file (%d)", *err);
*err_framenum = framenum;
@@ -3425,6 +3440,9 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
if (edt)
epan_dissect_free(edt);
+ ws_buffer_free(&buf);
+ wtap_rec_cleanup(&rec);
+
return status;
}
@@ -3674,8 +3692,7 @@ out:
static gboolean
process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
- wtap_rec *rec, const guchar *pd,
- guint tap_flags)
+ wtap_rec *rec, Buffer *buf, guint tap_flags)
{
frame_data fdata;
column_info *cinfo;
@@ -3733,7 +3750,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
}
epan_dissect_run_with_taps(edt, cf->cd_t, rec,
- frame_tvbuff_new(&cf->provider, &fdata, pd),
+ frame_tvbuff_new_buffer(&cf->provider, &fdata, buf),
&fdata, cinfo);
/* Run the filter if we have it. */
diff --git a/ui/file_dialog.c b/ui/file_dialog.c
index 34c71c349d..b80fba4cd3 100644
--- a/ui/file_dialog.c
+++ b/ui/file_dialog.c
@@ -27,7 +27,8 @@ get_stats_for_preview(wtap *wth, ws_file_preview_stats *stats,
int *err, gchar **err_info)
{
gint64 data_offset;
- const wtap_rec *rec;
+ wtap_rec rec;
+ Buffer buf;
guint32 records;
guint32 data_records;
double start_time;
@@ -44,10 +45,9 @@ get_stats_for_preview(wtap *wth, ws_file_preview_stats *stats,
data_records = 0;
timed_out = FALSE;
time(&time_preview);
- while ((wtap_read(wth, err, err_info, &data_offset))) {
- rec = wtap_get_rec(wth);
- if (rec->presence_flags & WTAP_HAS_TS) {
- cur_time = nstime_to_sec(&rec->ts);
+ while ((wtap_read(wth, &rec, &buf, err, err_info, &data_offset))) {
+ if (rec.presence_flags & WTAP_HAS_TS) {
+ cur_time = nstime_to_sec(&rec.ts);
if (!have_times) {
start_time = cur_time;
stop_time = cur_time;
@@ -61,7 +61,7 @@ get_stats_for_preview(wtap *wth, ws_file_preview_stats *stats,
}
}
- switch (rec->rec_type) {
+ switch (rec.rec_type) {
case REC_TYPE_PACKET:
case REC_TYPE_FT_SPECIFIC_EVENT:
diff --git a/wiretap/5views.c b/wiretap/5views.c
index 55fab4a668..a90337fdae 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -85,8 +85,8 @@ typedef struct
#define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */
#define CST_5VW_SYSTEM_RECORD 0x00000000U
-static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean _5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset);
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,
@@ -172,7 +172,8 @@ _5views_open(wtap *wth, int *err, gchar **err_info)
/* Read the next packet */
static gboolean
-_5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+_5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
t_5VW_TimeStamped_Header TimeStamped_Header;
@@ -186,7 +187,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->rec, err, err_info))
+ rec, err, err_info))
return FALSE;
if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) {
@@ -203,19 +204,19 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
return FALSE;
} while (1);
- if (wth->rec.rec_header.packet_header.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("5views: File has %u-byte packet, bigger than maximum of %u",
- wth->rec.rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
+ rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
return FALSE;
}
- return wtap_read_packet_bytes(wth->fh, wth->rec_data,
- wth->rec.rec_header.packet_header.caplen, err, err_info);
+ return wtap_read_packet_bytes(wth->fh, buf,
+ rec->rec_header.packet_header.caplen, err, err_info);
}
static gboolean
diff --git a/wiretap/aethra.c b/wiretap/aethra.c
index 0faba8a49d..e1d4511913 100644
--- a/wiretap/aethra.c
+++ b/wiretap/aethra.c
@@ -102,8 +102,8 @@ typedef struct {
time_t start;
} aethra_t;
-static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean aethra_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset);
static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
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,
@@ -163,8 +163,8 @@ static guint packet = 0;
#endif
/* Read the next packet */
-static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean aethra_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
struct aethrarec_hdr hdr;
@@ -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->rec, err, err_info))
+ if (!aethra_read_rec_header(wth, wth->fh, &hdr, rec, err, err_info))
return FALSE;
/*
* XXX - if this is big, we might waste memory by
* growing the buffer to handle it.
*/
- 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))
+ if (rec->rec_header.packet_header.caplen != 0) {
+ if (!wtap_read_packet_bytes(wth->fh, buf,
+ 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->rec.rec_header.packet_header.caplen, hdr.flags & AETHRA_U_TO_N);
+hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, 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->rec.rec_header.packet_header.caplen,
default:
#if 0
fprintf(stderr, "Packet %u: type 0x%02x, packet_size %u, flags 0x%02x\n",
-packet, hdr.rec_type, wth->rec.rec_header.packet_header.caplen, hdr.flags);
+packet, hdr.rec_type, rec->rec_header.packet_header.caplen, hdr.flags);
#endif
break;
}
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index bc2b699913..469308a19d 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -62,8 +62,8 @@ static const ascend_magic_string ascend_magic[] = {
#define ASCEND_DATE "Date:"
-static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean ascend_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf,
int *err, gchar **err_info);
@@ -209,6 +209,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
ascend_state_t parser_state;
ws_statb64 statbuf;
ascend_t *ascend;
+ wtap_rec rec;
/* We haven't yet allocated a data structure for our private stuff;
set the pointer to null, so that "ascend_find_next_packet()" knows
@@ -225,7 +226,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->rec, buf, &parser_state, err,
+ if (run_ascend_parser(wth->fh, &rec, buf, &parser_state, err,
err_info) != 0 && *err != 0) {
/* An I/O error. */
return WTAP_OPEN_ERROR;
@@ -246,7 +247,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->rec.rec_header.packet_header.pseudo_header.ascend.type) {
+ switch(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;
@@ -399,8 +400,8 @@ parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec, Buffer *buf,
}
/* Read the next packet; called from wtap_read(). */
-static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean ascend_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
ascend_t *ascend = (ascend_t *)wth->priv;
gint64 offset;
@@ -416,9 +417,8 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
offset = ascend_find_next_packet(wth, err, err_info);
if (offset == -1)
return FALSE;
- if (!parse_ascend(ascend, wth->fh, &wth->rec, wth->rec_data,
- wth->snapshot_length, &ascend->next_packet_seek_start,
- err, err_info))
+ if (!parse_ascend(ascend, wth->fh, rec, buf, wth->snapshot_length,
+ &ascend->next_packet_seek_start, err, err_info))
return FALSE;
/* Flex might have gotten an EOF and caused *err to be set to
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index 215f7d68fb..0dd7986406 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -59,8 +59,8 @@ struct btsnooprec_hdr {
static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */
-static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean btsnoop_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *offset);
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
@@ -136,13 +136,12 @@ wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
-static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean btsnoop_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *offset)
{
- *data_offset = file_tell(wth->fh);
+ *offset = file_tell(wth->fh);
- return btsnoop_read_record(wth, wth->fh, &wth->rec, wth->rec_data,
- err, err_info);
+ return btsnoop_read_record(wth, wth->fh, rec, buf, err, err_info);
}
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
diff --git a/wiretap/camins.c b/wiretap/camins.c
index 0afcf3e550..75a011548f 100644
--- a/wiretap/camins.c
+++ b/wiretap/camins.c
@@ -385,12 +385,13 @@ camins_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
static gboolean
-camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+camins_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return camins_read_packet(wth->fh, &wth->rec, wth->rec_data,
- (guint64 *)(wth->priv), err, err_info);
+ return camins_read_packet(wth->fh, rec, buf, (guint64 *)(wth->priv),
+ err, err_info);
}
diff --git a/wiretap/capsa.c b/wiretap/capsa.c
index a97977e601..8cc6e58e0d 100644
--- a/wiretap/capsa.c
+++ b/wiretap/capsa.c
@@ -106,8 +106,8 @@ typedef struct {
guint32 record_offsets[N_RECORDS_PER_GROUP];
} capsa_t;
-static gboolean capsa_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean capsa_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean capsa_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
@@ -217,8 +217,8 @@ wtap_open_return_val capsa_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean capsa_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean capsa_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
capsa_t *capsa = (capsa_t *)wth->priv;
guint32 frame_within_block;
@@ -262,8 +262,7 @@ 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->rec,
- wth->rec_data, err, err_info);
+ padbytes = capsa_read_packet(wth, wth->fh, rec, buf, err, err_info);
if (padbytes == -1)
return FALSE;
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 60a5b1ad13..e0d96bd81e 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -85,7 +85,8 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript";
/************************************************************/
/* Functions called from wiretap core */
-static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
+static gboolean catapult_dct2000_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec,
@@ -323,8 +324,8 @@ static void write_timestamp_string(char *timestamp_string, int secs, int tenthou
/* - return TRUE and details if found */
/**************************************************/
static gboolean
-catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+catapult_dct2000_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
long dollar_offset, before_time_offset, after_time_offset;
packet_direction_t direction;
@@ -380,8 +381,7 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
*data_offset = this_offset;
if (!process_parsed_line(wth, file_externals,
- &wth->rec,
- wth->rec_data, this_offset,
+ rec, buf, this_offset,
linebuff, dollar_offset,
seconds, useconds,
timestamp_string,
diff --git a/wiretap/commview.c b/wiretap/commview.c
index 6e3de48e37..bf8f06d50a 100644
--- a/wiretap/commview.c
+++ b/wiretap/commview.c
@@ -79,8 +79,8 @@ typedef struct commview_header {
#define MEDIUM_WIFI 1
#define MEDIUM_TOKEN_RING 2
-static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean commview_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec,
Buffer *buf, int *err, gchar **err_info);
@@ -287,12 +287,12 @@ commview_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
}
static gboolean
-commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+commview_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return commview_read_packet(wth->fh, &wth->rec, wth->rec_data, err,
- err_info);
+ return commview_read_packet(wth->fh, rec, buf, err, err_info);
}
static gboolean
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index d2c2fae9e4..26641b156b 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -149,8 +149,8 @@ static gboolean empty_line(const gchar *line);
static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr);
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_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int parse_cosine_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
@@ -266,8 +266,8 @@ wtap_open_return_val cosine_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean cosine_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
char line[COSINE_LINE_LENGTH];
@@ -279,8 +279,7 @@ 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->rec, wth->rec_data,
- line, err, err_info);
+ return parse_cosine_packet(wth->fh, rec, buf, line, err, err_info);
}
/* Used to read packets in random-access fashion */
diff --git a/wiretap/csids.c b/wiretap/csids.c
index 05cc35a75d..3a5d7f160b 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -30,8 +30,8 @@ typedef struct {
gboolean byteswapped;
} csids_t;
-static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean csids_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean csids_read_packet(FILE_T fh, csids_t *csids,
@@ -123,15 +123,14 @@ wtap_open_return_val csids_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean csids_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
csids_t *csids = (csids_t *)wth->priv;
*data_offset = file_tell(wth->fh);
- return csids_read_packet( wth->fh, csids, &wth->rec, wth->rec_data,
- err, err_info );
+ return csids_read_packet( wth->fh, csids, rec, buf, err, err_info );
}
/* Used to read packets in random-access fashion */
diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c
index b4e32ae066..03a782bc30 100644
--- a/wiretap/daintree-sna.c
+++ b/wiretap/daintree-sna.c
@@ -58,8 +58,8 @@ static const char daintree_magic_text[] = "#Format=";
#define COMMENT_LINE daintree_magic_text[0]
-static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean daintree_sna_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -110,13 +110,13 @@ wtap_open_return_val daintree_sna_open(wtap *wth, int *err, gchar **err_info)
/* Read the capture file sequentially
* Wireshark scans the file with sequential reads during preview and initial display. */
static gboolean
-daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+daintree_sna_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ 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->rec,
- wth->rec_data, err, err_info);
+ return daintree_sna_read_packet(wth->fh, rec, buf, err, err_info);
}
/* Read the capture file randomly
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index 010747e0d1..601a5bf429 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -70,8 +70,8 @@ static const char dbs_etherwatch_rec_magic[] =
*/
#define DBS_ETHERWATCH_MAX_ETHERNET_PACKET_LEN 1514
-static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec,
@@ -182,8 +182,8 @@ wtap_open_return_val dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@@ -194,8 +194,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
*data_offset = offset;
/* Parse the packet */
- return parse_dbs_etherwatch_packet(wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ return parse_dbs_etherwatch_packet(wth->fh, rec, buf, err, err_info);
}
/* Used to read packets in random-access fashion */
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c
index 9c7b81cfe7..1f8e0f3a1e 100644
--- a/wiretap/dct3trace.c
+++ b/wiretap/dct3trace.c
@@ -60,8 +60,8 @@ static const char dct3trace_magic_end[] = "</dump>";
#define MAX_PACKET_LEN 23
-static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean dct3trace_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -367,13 +367,12 @@ static gboolean dct3trace_get_packet(FILE_T fh, wtap_rec *rec,
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean dct3trace_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return dct3trace_get_packet(wth->fh, &wth->rec, wth->rec_data,
- err, err_info);
+ return dct3trace_get_packet(wth->fh, rec, buf, err, err_info);
}
diff --git a/wiretap/dpa400.c b/wiretap/dpa400.c
index 32d4d1b264..bd709aa10a 100644
--- a/wiretap/dpa400.c
+++ b/wiretap/dpa400.c
@@ -192,7 +192,7 @@ static gboolean dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
return TRUE;
}
-static gboolean dpa400_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
+static gboolean dpa400_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)
@@ -201,11 +201,12 @@ static gboolean dpa400_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buff
return dpa400_read_packet(wth, wth->random_fh, rec, buf, err, err_info);
}
-static gboolean dpa400_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean dpa400_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return dpa400_read_packet(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info);
+ return dpa400_read_packet(wth, wth->fh, rec, buf, err, err_info);
}
wtap_open_return_val dpa400_open(wtap *wth, int *err, gchar **err_info)
diff --git a/wiretap/erf.c b/wiretap/erf.c
index 05f123ddec..83df62153e 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -54,14 +54,14 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
guint32 *bytes_read,
guint32 *packet_size,
GPtrArray *anchor_mappings_to_update);
-static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean erf_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
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 populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header *pseudo_header, Buffer *buf, guint32 packet_size, 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 {
@@ -554,8 +554,8 @@ extern wtap_open_return_val erf_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean erf_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
erf_header_t erf_header;
guint32 packet_size, bytes_read;
@@ -566,16 +566,14 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
anchor_mappings_to_update = g_ptr_array_new_with_free_func(erf_anchor_mapping_destroy);
do {
- if (!erf_read_header(wth, wth->fh,
- &wth->rec, &erf_header,
+ if (!erf_read_header(wth, wth->fh, 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->rec_data, packet_size,
- err, err_info)) {
+ if (!wtap_read_packet_bytes(wth->fh, buf, packet_size, err, err_info)) {
g_ptr_array_free(anchor_mappings_to_update, TRUE);
return FALSE;
}
@@ -587,7 +585,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->rec.rec_header.packet_header.pseudo_header, packet_size, anchor_mappings_to_update);
+ populate_summary_info((erf_t*) wth->priv, wth, &rec->rec_header.packet_header.pseudo_header, buf, packet_size, anchor_mappings_to_update);
}
} while ( erf_header.type == ERF_TYPE_PAD );
@@ -3122,7 +3120,7 @@ static int populate_anchor_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_he
}
/* Populates the capture and interface information for display on the Capture File Properties */
-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 populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header *pseudo_header, Buffer *buf, guint32 packet_size, GPtrArray *anchor_mappings_to_update)
{
struct erf_meta_read_state state;
struct erf_meta_read_state *state_post = NULL;
@@ -3155,7 +3153,7 @@ static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_h
}
- state.tag_ptr = wth->rec_data->data;
+ state.tag_ptr = buf->data;
state.remaining_len = packet_size;
/* Read until see next section tag */
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c
index 0c5a8e268c..80758fde64 100644
--- a/wiretap/eyesdn.c
+++ b/wiretap/eyesdn.c
@@ -85,8 +85,8 @@ static const unsigned char eyesdn_hdr_magic[] =
/* Size of a record header */
#define EYESDN_HDR_LENGTH 12
-static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean eyesdn_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer* buf,
@@ -139,9 +139,9 @@ wtap_open_return_val eyesdn_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
-/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+/* Find the next record and parse it; called from wtap_read(). */
+static gboolean eyesdn_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@@ -152,8 +152,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
*data_offset = offset;
/* Parse the record */
- return read_eyesdn_rec(wth->fh, &wth->rec, wth->rec_data,
- err, err_info);
+ return read_eyesdn_rec(wth->fh, rec, buf, err, err_info);
}
/* Used to read packets in random-access fashion */
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index f99821998e..1c7231e943 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1128,11 +1128,6 @@ fail:
return NULL;
success:
- /* wth->rec_data is used for the sequential read and will be freed by
- * wtap_sequential_close (which is also called by wtap_close). */
- wth->rec_data = g_new(struct Buffer, 1);
- 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)) {
diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c
index 683da1d80a..14d5fc725a 100644
--- a/wiretap/hcidump.c
+++ b/wiretap/hcidump.c
@@ -54,13 +54,12 @@ static gboolean hcidump_read_packet(FILE_T fh, wtap_rec *rec,
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
-static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean hcidump_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return hcidump_read_packet(wth->fh, &wth->rec, wth->rec_data,
- err, err_info);
+ return hcidump_read_packet(wth->fh, rec, buf, err, err_info);
}
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 78d50c2e27..282924b95c 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -20,8 +20,8 @@ typedef struct {
gboolean byte_swapped;
} i4btrace_t;
-static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean i4btrace_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *offset);
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec,
@@ -93,13 +93,12 @@ wtap_open_return_val i4btrace_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean i4btrace_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return i4b_read_rec(wth, wth->fh, &wth->rec, wth->rec_data,
- err, err_info);
+ return i4b_read_rec(wth, wth->fh, rec, buf, err, err_info);
}
static gboolean
diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c
index dc3778eb4a..9db6fe5b02 100644
--- a/wiretap/ipfix.c
+++ b/wiretap/ipfix.c
@@ -66,8 +66,8 @@
#define RECORDS_FOR_IPFIX_CHECK 20
static gboolean
-ipfix_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+ipfix_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset);
static gboolean
ipfix_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -277,13 +277,13 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
/* classic wtap: read packet */
static gboolean
-ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+ipfix_read(wtap *wth, wtap_rec *rec, Buffer *buf, 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",
- wth->rec.rec_header.packet_header.file_offset);
+ ipfix_debug("ipfix_read: offset is initially %" G_GINT64_MODIFIER "d", *data_offset);
- if (!ipfix_read_message(wth->fh, &wth->rec, wth->rec_data, err, err_info)) {
+ if (!ipfix_read_message(wth->fh, rec, buf, err, err_info)) {
ipfix_debug("ipfix_read: couldn't read message header with code: %d\n, and error '%s'",
*err, *err_info);
return FALSE;
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index f385c889cc..dcf2e397e6 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -18,13 +18,13 @@
#define IPTRACE_IFT_HF 0x3d /* Support for PERCS IP-HFI*/
#define IPTRACE_IFT_IB 0xc7 /* IP over Infiniband. Number by IANA */
-static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean iptrace_read_1_0(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
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_read_2_0(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -195,14 +195,13 @@ iptrace_read_rec_1_0(FILE_T fh, wtap_rec *rec, Buffer *buf,
}
/* Read the next packet */
-static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean iptrace_read_1_0(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
/* Read the packet */
- if (!iptrace_read_rec_1_0(wth->fh, &wth->rec, wth->rec_data,
- err, err_info)) {
+ if (!iptrace_read_rec_1_0(wth->fh, rec, buf, err, err_info)) {
/* Read error or EOF */
return FALSE;
}
@@ -214,9 +213,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->rec.rec_header.packet_header.pkt_encap;
+ wth->file_encap = rec->rec_header.packet_header.pkt_encap;
else {
- if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
+ if (wth->file_encap != rec->rec_header.packet_header.pkt_encap)
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
@@ -388,14 +387,13 @@ iptrace_read_rec_2_0(FILE_T fh, wtap_rec *rec, Buffer *buf,
}
/* Read the next packet */
-static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean iptrace_read_2_0(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
/* Read the packet */
- if (!iptrace_read_rec_2_0(wth->fh, &wth->rec, wth->rec_data,
- err, err_info)) {
+ if (!iptrace_read_rec_2_0(wth->fh, rec, buf, err, err_info)) {
/* Read error or EOF */
return FALSE;
}
@@ -407,9 +405,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->rec.rec_header.packet_header.pkt_encap;
+ wth->file_encap = rec->rec_header.packet_header.pkt_encap;
else {
- if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
+ if (wth->file_encap != rec->rec_header.packet_header.pkt_encap)
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
diff --git a/wiretap/iseries.c b/wiretap/iseries.c
index 3a53e6495a..53ee9f09e8 100644
--- a/wiretap/iseries.c
+++ b/wiretap/iseries.c
@@ -179,8 +179,8 @@ typedef struct {
int format; /* Trace format type */
} iseries_t;
-static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info,
- gint64 *data_offset);
+static gboolean iseries_read (wtap * wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar ** err_info, gint64 *data_offset);
static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
wtap_rec *rec,
Buffer * buf, int *err, gchar ** err_info);
@@ -376,7 +376,8 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
* Find the next packet and parse it; called from wtap_read().
*/
static gboolean
-iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
+iseries_read (wtap * wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar ** err_info, gint64 *data_offset)
{
gint64 offset;
@@ -391,8 +392,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->rec, wth->rec_data,
- err, err_info);
+ return iseries_parse_packet (wth, wth->fh, rec, buf, err, err_info);
}
/*
diff --git a/wiretap/k12.c b/wiretap/k12.c
index 9e7c42bc8e..7bc0bc93aa 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -658,7 +658,7 @@ process_packet_data(wtap_rec *rec, Buffer *target, guint8 *buffer,
return TRUE;
}
-static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
+static gboolean k12_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info, gint64 *data_offset) {
k12_t *k12 = (k12_t *)wth->priv;
k12_src_desc_t* src_desc;
guint8* buffer;
@@ -721,7 +721,7 @@ 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->rec, wth->rec_data, buffer, (guint)len, k12, err, err_info);
+ return process_packet_data(rec, buf, buffer, (guint)len, k12, err, err_info);
}
diff --git a/wiretap/k12text.l b/wiretap/k12text.l
index 546030dda9..23cf390452 100644
--- a/wiretap/k12text.l
+++ b/wiretap/k12text.l
@@ -340,7 +340,7 @@ k12text_run_scanner(k12text_state_t *state, FILE_T fh, int start_state,
}
static gboolean
-k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
+k12text_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, char ** err_info, gint64 *data_offset)
{
k12text_t *k12text = (k12text_t *)wth->priv;
k12text_state_t state;
@@ -379,12 +379,12 @@ 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->rec, &state, err, err_info)) {
+ if (!k12text_set_headers(rec, &state, err, err_info)) {
g_free(state.bb);
return FALSE;
}
- 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);
+ 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;
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 5f5f573386..dd2d31bc7a 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -258,8 +258,8 @@ typedef struct {
time_t start;
} lanalyzer_t;
-static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean lanalyzer_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean lanalyzer_dump_finish(wtap_dumper *wdh, int *err);
@@ -531,14 +531,14 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
}
/* Read the next packet */
-static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean lanalyzer_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
/* Read the record */
- return lanalyzer_read_trace_record(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ return lanalyzer_read_trace_record(wth, wth->fh, rec, buf, err,
+ err_info);
}
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index ff3f6056ae..105c646544 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -42,8 +42,8 @@ typedef struct {
static int libpcap_try(wtap *wth, int *err, gchar **err_info);
static int libpcap_try_record(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_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean libpcap_read_packet(wtap *wth, FILE_T fh,
@@ -714,13 +714,12 @@ static int libpcap_try_record(wtap *wth, FILE_T fh, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean libpcap_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return libpcap_read_packet(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ return libpcap_read_packet(wth, wth->fh, rec, buf, err, err_info);
}
static gboolean
diff --git a/wiretap/logcat.c b/wiretap/logcat.c
index 9b372b08fe..4bd27d578c 100644
--- a/wiretap/logcat.c
+++ b/wiretap/logcat.c
@@ -205,13 +205,13 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
return TRUE;
}
-static gboolean logcat_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean logcat_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
- &wth->rec, wth->rec_data, err, err_info);
+ rec, buf, err, err_info);
}
static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c
index 69554e7866..3b78cc6eec 100644
--- a/wiretap/logcat_text.c
+++ b/wiretap/logcat_text.c
@@ -238,12 +238,11 @@ static gboolean logcat_text_read_packet(FILE_T fh, wtap_rec *rec,
return TRUE;
}
-static gboolean logcat_text_read(wtap *wth, int *err _U_ , gchar **err_info _U_,
- gint64 *data_offset) {
+static gboolean logcat_text_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err _U_ , gchar **err_info _U_, gint64 *data_offset) {
*data_offset = file_tell(wth->fh);
- return logcat_text_read_packet(wth->fh, &wth->rec, wth->rec_data,
- wth->file_type_subtype);
+ return logcat_text_read_packet(wth->fh, rec, buf, wth->file_type_subtype);
}
static gboolean logcat_text_seek_read(wtap *wth, gint64 seek_off,
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 42aa35507d..2c3fdfcbf3 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -81,6 +81,9 @@ cleanup_in_file(merge_in_file_t *in_file)
g_array_free(in_file->idb_index_map, TRUE);
in_file->idb_index_map = NULL;
+
+ wtap_rec_cleanup(&in_file->rec);
+ ws_buffer_free(&in_file->frame_buffer);
}
static void
@@ -145,6 +148,8 @@ merge_open_in_files(guint in_file_count, const char *const *in_file_names,
*err_fileno = i;
return FALSE;
}
+ wtap_rec_init(&files[i].rec);
+ ws_buffer_init(&files[i].frame_buffer, 1500);
files[i].size = size;
files[i].idb_index_map = g_array_new(FALSE, FALSE, sizeof(guint));
}
@@ -264,7 +269,9 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[],
* No packet available, and we haven't seen an error or EOF yet,
* so try to read the next packet.
*/
- if (!wtap_read(in_files[i].wth, err, err_info, &data_offset)) {
+ if (!wtap_read(in_files[i].wth, &in_files[i].rec,
+ &in_files[i].frame_buffer, err, err_info,
+ &data_offset)) {
if (*err != 0) {
in_files[i].state = GOT_ERROR;
return &in_files[i];
@@ -275,7 +282,7 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[],
}
if (in_files[i].state == RECORD_PRESENT) {
- rec = wtap_get_rec(in_files[i].wth);
+ rec = &in_files[i].rec;
if (!(rec->presence_flags & WTAP_HAS_TS)) {
/*
* No time stamp. Pick this record, and stop looking.
@@ -348,7 +355,9 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
for (i = 0; i < in_file_count; i++) {
if (in_files[i].state == AT_EOF)
continue; /* This file is already at EOF */
- if (wtap_read(in_files[i].wth, err, err_info, &data_offset))
+ if (wtap_read(in_files[i].wth, &in_files[i].rec,
+ &in_files[i].frame_buffer, err, err_info,
+ &data_offset))
break; /* We have a packet */
if (*err != 0) {
/* Read error - quit immediately. */
@@ -876,7 +885,7 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
break;
}
- rec = wtap_get_rec(in_file->wth);
+ rec = &in_file->rec;
switch (rec->rec_type) {
@@ -926,7 +935,8 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
}
}
- if (!wtap_dump(pdh, rec, wtap_get_buf_ptr(in_file->wth), err, err_info)) {
+ if (!wtap_dump(pdh, rec, ws_buffer_start_ptr(&in_file->frame_buffer),
+ err, err_info)) {
status = MERGE_ERR_CANT_WRITE_OUTFILE;
break;
}
diff --git a/wiretap/merge.h b/wiretap/merge.h
index 8a14c483a3..bbc6e53ee7 100644
--- a/wiretap/merge.h
+++ b/wiretap/merge.h
@@ -30,6 +30,8 @@ typedef enum {
typedef struct merge_in_file_s {
const char *filename;
wtap *wth;
+ wtap_rec rec;
+ Buffer frame_buffer;
in_file_state_e state;
guint32 packet_num; /* current packet number */
gint64 size; /* file size */
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index d374be8beb..ce91325629 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -91,7 +91,8 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
}
static gboolean
-mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+mp2t_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
mp2t_filetype_t *mp2t;
@@ -99,8 +100,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->rec,
- wth->rec_data, err, err_info)) {
+ if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, rec, buf, err,
+ err_info)) {
return FALSE;
}
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index 2e2c47556d..8524766d02 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -182,12 +182,12 @@ mpeg_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
}
static gboolean
-mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+mpeg_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return mpeg_read_packet(wth, wth->fh, &wth->rec, wth->rec_data,
- FALSE, err, err_info);
+ return mpeg_read_packet(wth, wth->fh, rec, buf, FALSE, err, err_info);
}
static gboolean
diff --git a/wiretap/mplog.c b/wiretap/mplog.c
index 4992e9eb1c..7a9521adc9 100644
--- a/wiretap/mplog.c
+++ b/wiretap/mplog.c
@@ -183,12 +183,12 @@ static gboolean mplog_read_packet(FILE_T fh, wtap_rec *rec,
static gboolean
-mplog_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+mplog_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return mplog_read_packet(
- wth->fh, &wth->rec, wth->rec_data, err, err_info);
+ return mplog_read_packet(wth->fh, rec, buf, err, err_info);
}
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 20f189aa93..4a3af2b4d8 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -215,8 +215,8 @@ static const int netmon_encap[] = {
#define NETMON_NET_DNS_CACHE 0xFFFE
#define NETMON_NET_NETMON_FILTER 0xFFFF
-static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean netmon_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
@@ -1430,8 +1430,8 @@ netmon_process_record(wtap *wth, FILE_T fh, wtap_rec *rec,
}
/* Read the next packet */
-static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean netmon_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
netmon_t *netmon = (netmon_t *)wth->priv;
gint64 rec_offset;
@@ -1462,8 +1462,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->rec,
- wth->rec_data, err, err_info)) {
+ switch (netmon_process_record(wth, wth->fh, rec, buf, err,
+ err_info)) {
case RETRY:
continue;
diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c
index 19d577d82e..fd2db29391 100644
--- a/wiretap/netscaler.c
+++ b/wiretap/netscaler.c
@@ -603,11 +603,14 @@ typedef struct {
} nstrace_t;
static guint32 nspm_signature_version(gchar*, gint32);
-static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info,
+static gboolean nstrace_read_v10(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
+static gboolean nstrace_read_v20(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info,
gint64 *data_offset);
-static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info,
+static gboolean nstrace_read_v30(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info,
gint64 *data_offset);
static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
wtap_rec *rec,
@@ -836,8 +839,6 @@ wtap_open_return_val nstrace_open(wtap *wth, int *err, gchar **err_info)
}
wth->file_tsprec = WTAP_TSPREC_NSEC;
- wth->rec.ts.secs = nstrace->nspm_curtime;
- wth->rec.ts.nsecs = 0;
*err = 0;
return WTAP_OPEN_MINE;
@@ -1078,7 +1079,7 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info)
(rec)->rec_header.packet_header.caplen = (rec)->rec_header.packet_header.len;\
}while(0)
-#define PACKET_DESCRIBE(rec,FULLPART,fullpart,ver,type,HEADERVER) \
+#define PACKET_DESCRIBE(rec,buf,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 */\
@@ -1103,8 +1104,8 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup("nstrace: record crosses page boundary");\
return FALSE;\
}\
- 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);\
+ ws_buffer_assure_space((buf), (rec)->rec_header.packet_header.caplen);\
+ memcpy(ws_buffer_start_ptr((buf)), type, (rec)->rec_header.packet_header.caplen);\
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
nstrace->nstrace_buf_offset = nstrace_buf_offset + (rec)->rec_header.packet_header.caplen;\
nstrace->nstrace_buflen = nstrace_buflen;\
@@ -1112,9 +1113,9 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info)
return TRUE;\
}while(0)
-static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean nstrace_read_v10(wtap *wth, wtap_rec *rec, Buffer *buf,
+ 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;
@@ -1129,22 +1130,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(rec,ver,HEADERVER) \
+#define GENERATE_CASE_FULL(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEFULLTX_V##ver:\
case NSPR_PDPKTRACEFULLTXB_V##ver:\
case NSPR_PDPKTRACEFULLRX_V##ver:\
- PACKET_DESCRIBE(rec,FULL,full,ver,fp,HEADERVER);
+ PACKET_DESCRIBE(rec,buf,FULL,full,ver,fp,HEADERVER);
-#define GENERATE_CASE_PART(rec,ver,HEADERVER) \
+#define GENERATE_CASE_PART(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEPARTTX_V##ver:\
case NSPR_PDPKTRACEPARTTXB_V##ver:\
case NSPR_PDPKTRACEPARTRX_V##ver:\
- PACKET_DESCRIBE(rec,PART,part,ver,pp,HEADERVER);
+ PACKET_DESCRIBE(rec,buf,PART,part,ver,pp,HEADERVER);
switch (pletoh16(&(( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType))
{
- GENERATE_CASE_FULL(rec,10,100)
- GENERATE_CASE_PART(rec,10,100)
+ GENERATE_CASE_FULL(rec,buf,10,100)
+ GENERATE_CASE_PART(rec,buf,10,100)
#undef GENERATE_CASE_FULL
#undef GENERATE_CASE_PART
@@ -1257,7 +1258,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
#define FULLSIZEDEFV25(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver)
#define FULLSIZEDEFV26(rec,fp,ver) FULLSIZEDEFV20(rec,fp,ver)
-#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\
+#define PACKET_DESCRIBE(rec,buf,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 */\
@@ -1283,8 +1284,8 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
*err_info = g_strdup("nstrace: record crosses page boundary");\
return FALSE;\
}\
- 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);\
+ ws_buffer_assure_space((buf), (rec)->rec_header.packet_header.caplen);\
+ memcpy(ws_buffer_start_ptr((buf)), 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;\
@@ -1292,9 +1293,9 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
return TRUE;\
}while(0)
-static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean nstrace_read_v20(wtap *wth, wtap_rec *rec, Buffer *buf,
+ 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;
@@ -1311,46 +1312,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(rec,ver,HEADERVER) \
+#define GENERATE_CASE_FULL(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEFULLTX_V##ver:\
case NSPR_PDPKTRACEFULLTXB_V##ver:\
case NSPR_PDPKTRACEFULLRX_V##ver:\
- PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
+ PACKET_DESCRIBE(rec,buf,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
-#define GENERATE_CASE_FULL_V25(rec,ver,HEADERVER) \
+#define GENERATE_CASE_FULL_V25(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEFULLTX_V##ver:\
case NSPR_PDPKTRACEFULLTXB_V##ver:\
case NSPR_PDPKTRACEFULLRX_V##ver:\
case NSPR_PDPKTRACEFULLNEWRX_V##ver:\
- PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
+ PACKET_DESCRIBE(rec,buf,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
-#define GENERATE_CASE_PART(rec,ver,HEADERVER) \
+#define GENERATE_CASE_PART(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEPARTTX_V##ver:\
case NSPR_PDPKTRACEPARTTXB_V##ver:\
case NSPR_PDPKTRACEPARTRX_V##ver:\
- PACKET_DESCRIBE(rec,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER);
+ PACKET_DESCRIBE(rec,buf,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER);
-#define GENERATE_CASE_PART_V25(rec,ver,HEADERVER) \
+#define GENERATE_CASE_PART_V25(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEPARTTX_V##ver:\
case NSPR_PDPKTRACEPARTTXB_V##ver:\
case NSPR_PDPKTRACEPARTRX_V##ver:\
case NSPR_PDPKTRACEPARTNEWRX_V##ver:\
- 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);
+ PACKET_DESCRIBE(rec,buf,PART,ver,v##ver##_part,pp,pktracepart_v##ver,HEADERVER);
+
+ GENERATE_CASE_FULL(rec,buf,20,200);
+ GENERATE_CASE_PART(rec,buf,20,200);
+ GENERATE_CASE_FULL(rec,buf,21,201);
+ GENERATE_CASE_PART(rec,buf,21,201);
+ GENERATE_CASE_FULL(rec,buf,22,202);
+ GENERATE_CASE_PART(rec,buf,22,202);
+ GENERATE_CASE_FULL(rec,buf,23,203);
+ GENERATE_CASE_PART(rec,buf,23,203);
+ GENERATE_CASE_FULL_V25(rec,buf,24,204);
+ GENERATE_CASE_PART_V25(rec,buf,24,204);
+ GENERATE_CASE_FULL_V25(rec,buf,25,205);
+ GENERATE_CASE_PART_V25(rec,buf,25,205);
+ GENERATE_CASE_FULL_V25(rec,buf,26,206);
+ GENERATE_CASE_PART_V25(rec,buf,26,206);
#undef GENERATE_CASE_FULL
#undef GENERATE_CASE_FULL_V25
@@ -1462,7 +1463,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
(rec)->rec_header.packet_header.caplen = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
}while(0)
-#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\
+#define PACKET_DESCRIBE(rec,buf,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 */\
@@ -1485,7 +1486,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
g_free(nstrace_tmpbuff);\
return FALSE;\
}\
- ws_buffer_assure_space(wth->rec_data, (rec)->rec_header.packet_header.caplen);\
+ ws_buffer_assure_space((buf), (rec)->rec_header.packet_header.caplen);\
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
/* Copy record header */\
while (nstrace_tmpbuff_off < nspr_##structname##_s) {\
@@ -1526,7 +1527,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->rec_data), nstrace_tmpbuff, (rec)->rec_header.packet_header.caplen);\
+ memcpy(ws_buffer_start_ptr((buf)), 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;\
@@ -1534,9 +1535,9 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
return TRUE;\
} while(0)
-static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean nstrace_read_v30(wtap *wth, wtap_rec *rec, Buffer *buf,
+ 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;
@@ -1589,24 +1590,24 @@ static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *
switch (hdp->phd_RecordType)
{
-#define GENERATE_CASE_FULL_V30(rec,ver,HEADERVER) \
+#define GENERATE_CASE_FULL_V30(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEFULLTX_V##ver:\
case NSPR_PDPKTRACEFULLTXB_V##ver:\
case NSPR_PDPKTRACEFULLRX_V##ver:\
case NSPR_PDPKTRACEFULLNEWRX_V##ver:\
- PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
+ PACKET_DESCRIBE(rec,buf,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
- GENERATE_CASE_FULL_V30(rec,30,300);
+ GENERATE_CASE_FULL_V30(rec,buf,30,300);
#undef GENERATE_CASE_FULL_V30
-#define GENERATE_CASE_FULL_V35(rec,ver,HEADERVER) \
+#define GENERATE_CASE_FULL_V35(rec,buf,ver,HEADERVER) \
case NSPR_PDPKTRACEFULLTX_V##ver:\
case NSPR_PDPKTRACEFULLTXB_V##ver:\
case NSPR_PDPKTRACEFULLRX_V##ver:\
case NSPR_PDPKTRACEFULLNEWRX_V##ver:\
- PACKET_DESCRIBE(rec,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
- GENERATE_CASE_FULL_V35(rec,35,350);
+ PACKET_DESCRIBE(rec,buf,FULL,ver,v##ver##_full,fp,pktracefull_v##ver,HEADERVER);
+ GENERATE_CASE_FULL_V35(rec,buf,35,350);
#undef GENERATE_CASE_FULL_V35
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index d954089dfc..927f13f6e7 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -52,11 +52,10 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr);
static gboolean netscreen_check_file_type(wtap *wth, int *err,
gchar **err_info);
-static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean netscreen_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
- wtap_rec *rec, Buffer *buf,
- int *err, gchar **err_info);
+ wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
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,
@@ -170,8 +169,8 @@ wtap_open_return_val netscreen_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean netscreen_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
char line[NETSCREEN_LINE_LENGTH];
@@ -182,8 +181,7 @@ 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->rec,
- wth->rec_data, line, err, err_info))
+ if (!parse_netscreen_packet(wth->fh, rec, buf, line, err, err_info))
return FALSE;
/*
@@ -195,9 +193,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->rec.rec_header.packet_header.pkt_encap;
+ wth->file_encap = rec->rec_header.packet_header.pkt_encap;
else {
- if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
+ if (wth->file_encap != rec->rec_header.packet_header.pkt_encap)
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
@@ -207,8 +205,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,
- wtap_rec *rec, Buffer *buf,
+netscreen_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
int *err, gchar **err_info)
{
char line[NETSCREEN_LINE_LENGTH];
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 57bf441e31..9aa5c004e2 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -162,8 +162,8 @@ typedef struct {
gboolean is_hpux_11;
} nettl_t;
-static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean nettl_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf,
int *err, gchar **err_info);
@@ -261,13 +261,12 @@ wtap_open_return_val nettl_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean nettl_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
/* Read record. */
*data_offset = file_tell(wth->fh);
- if (!nettl_read_rec(wth, wth->fh, &wth->rec, wth->rec_data,
- err, err_info)) {
+ if (!nettl_read_rec(wth, wth->fh, rec, buf, err, err_info)) {
/* Read error or EOF */
return FALSE;
}
@@ -281,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->rec.rec_header.packet_header.pkt_encap;
+ wth->file_encap = rec->rec_header.packet_header.pkt_encap;
else {
- if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
+ if (wth->file_encap != rec->rec_header.packet_header.pkt_encap)
wth->file_encap = WTAP_ENCAP_PER_PACKET;
}
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c
index 1bc2c15490..c5ed37b99e 100644
--- a/wiretap/nettrace_3gpp_32_423.c
+++ b/wiretap/nettrace_3gpp_32_423.c
@@ -149,51 +149,21 @@ typedef struct exported_pdu_info {
static gboolean
-nettrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+nettrace_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info, gint64 *data_offset)
{
- 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->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->rec_data = frame_buffer_saved;
- if (!result)
- return result;
- 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;
- /* Steal memory from the pcapng wth. */
- wth->rec.opt_comment = file_info->wth_tmp_file->rec.opt_comment;
- file_info->wth_tmp_file->rec.opt_comment = NULL;
- 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;
+ return wtap_read(file_info->wth_tmp_file, rec, buf, err, err_info, data_offset);
}
static gboolean
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->rec_data;
- file_info->wth_tmp_file->rec_data = wth->rec_data;
-
- 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;
+ /* we read the created pcapng file instead */
+ return wtap_seek_read(file_info->wth_tmp_file, seek_off, rec, buf, err, err_info);
}
/* classic wtap: close capture file */
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index 949e7b3a4f..51680b7ba7 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -98,8 +98,8 @@ static const char *init_gmt_to_localtime_offset(void)
return NULL;
}
-static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean observer_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
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,
@@ -315,8 +315,8 @@ wtap_open_return_val network_instruments_open(wtap *wth, int *err, gchar **err_i
}
/* Reads the next packet. */
-static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean observer_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
int header_bytes_consumed;
int data_bytes_consumed;
@@ -327,7 +327,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->rec.rec_header.packet_header.pseudo_header, &packet_header, err,
+ header_bytes_consumed = read_packet_header(wth, wth->fh, &rec->rec_header.packet_header.pseudo_header, &packet_header, err,
err_info);
if (header_bytes_consumed <= 0)
return FALSE; /* EOF or error */
@@ -342,13 +342,13 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
}
}
- if (!process_packet_header(wth, &packet_header, &wth->rec, 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->fh, packet_header.offset_to_frame,
- header_bytes_consumed, wth->rec_data,
- wth->rec.rec_header.packet_header.caplen, err, err_info);
+ header_bytes_consumed, buf, rec->rec_header.packet_header.caplen,
+ err, err_info);
if (data_bytes_consumed < 0) {
return FALSE;
}
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index 806ca1fd34..36875341b0 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -389,8 +389,8 @@ typedef struct {
guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
} netxray_t;
-static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean netxray_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int netxray_process_rec_header(wtap *wth, FILE_T fh,
@@ -967,8 +967,8 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
/* Read the next packet */
static gboolean
-netxray_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+netxray_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
netxray_t *netxray = (netxray_t *)wth->priv;
int padding;
@@ -988,8 +988,7 @@ reread:
}
/* Read and process record header. */
- padding = netxray_process_rec_header(wth, wth->fh, &wth->rec, err,
- err_info);
+ padding = netxray_process_rec_header(wth, wth->fh, rec, err, err_info);
if (padding < 0) {
/*
* Error or EOF.
@@ -1042,8 +1041,8 @@ reread:
/*
* Read the packet data.
*/
- if (!wtap_read_packet_bytes(wth->fh, wth->rec_data,
- wth->rec.rec_header.packet_header.caplen, err, err_info))
+ if (!wtap_read_packet_bytes(wth->fh, buf,
+ rec->rec_header.packet_header.caplen, err, err_info))
return FALSE;
/*
@@ -1057,7 +1056,7 @@ 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->rec, wth->rec_data);
+ netxray_guess_atm_type(wth, rec, buf);
return TRUE;
}
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index a4b11f7dd4..0201993742 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -495,8 +495,8 @@ static int process_rec_header2_v2(wtap *wth, unsigned char *buffer,
guint16 length, int *err, gchar **err_info);
static int process_rec_header2_v145(wtap *wth, unsigned char *buffer,
guint16 length, gint16 maj_vers, int *err, gchar **err_info);
-static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean ngsniffer_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int ngsniffer_process_record(wtap *wth, gboolean is_random,
@@ -1007,7 +1007,8 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
/* Read the next packet */
static gboolean
-ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+ngsniffer_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
ngsniffer_t *ngsniffer;
int ret;
@@ -1025,7 +1026,7 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
* Process the record.
*/
ret = ngsniffer_process_record(wth, FALSE, &padding,
- &wth->rec, wth->rec_data, err, err_info);
+ rec, buf, err, err_info);
if (ret < 0) {
/* Read error or short read */
return FALSE;
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c
index 048299629e..6c481c93c8 100644
--- a/wiretap/packetlogger.c
+++ b/wiretap/packetlogger.c
@@ -32,7 +32,8 @@ typedef struct packetlogger_header {
guint32 ts_usecs;
} packetlogger_header_t;
-static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info,
+static gboolean packetlogger_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info,
gint64 *data_offset);
static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec,
@@ -105,12 +106,12 @@ wtap_open_return_val packetlogger_open(wtap *wth, int *err, gchar **err_info)
}
static gboolean
-packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+packetlogger_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return packetlogger_read_packet(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ return packetlogger_read_packet(wth, wth->fh, rec, buf, err, err_info);
}
static gboolean
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 7eaafcdd79..1627bede61 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -38,8 +38,8 @@
#endif
static gboolean
-pcapng_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset);
static gboolean
pcapng_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -2790,7 +2790,8 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
/* classic wtap: read packet */
static gboolean
-pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *data_offset)
{
pcapng_t *pcapng = (pcapng_t *)wth->priv;
wtapng_block_t wblock;
@@ -2799,8 +2800,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->rec_data;
- wblock.rec = &wth->rec;
+ wblock.frame_buffer = buf;
+ wblock.rec = rec;
pcapng->add_new_ipv4 = wth->add_new_ipv4;
pcapng->add_new_ipv6 = wth->add_new_ipv6;
@@ -2912,7 +2913,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
}
}
- /*pcapng_debug("Read length: %u Packet length: %u", bytes_read, wth->rec.rec_header.packet_header.caplen);*/
+ /*pcapng_debug("Read length: %u Packet length: %u", bytes_read, rec->rec_header.packet_header.caplen);*/
pcapng_debug("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset);
return TRUE;
diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c
index 374d96bc76..24cf512abc 100644
--- a/wiretap/peekclassic.c
+++ b/wiretap/peekclassic.c
@@ -136,14 +136,14 @@ typedef struct {
time_t reference_time;
} peekclassic_t;
-static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean peekclassic_read_v7(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
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_read_v56(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
@@ -344,22 +344,22 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
-static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean peekclassic_read_v7(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
int sliceLength;
*data_offset = file_tell(wth->fh);
/* Read the packet. */
- sliceLength = peekclassic_read_packet_v7(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ sliceLength = peekclassic_read_packet_v7(wth, wth->fh, rec, buf,
+ err, err_info);
if (sliceLength < 0)
return FALSE;
/* Skip extra ignored data at the end of the packet. */
- 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,
+ if ((guint32)sliceLength > rec->rec_header.packet_header.caplen) {
+ if (!wtap_read_bytes(wth->fh, NULL, sliceLength - rec->rec_header.packet_header.caplen,
err, err_info))
return FALSE;
}
@@ -528,14 +528,14 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
return sliceLength;
}
-static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean peekclassic_read_v56(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
/* read the packet */
- if (!peekclassic_read_packet_v56(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info))
+ if (!peekclassic_read_packet_v56(wth, wth->fh, rec, buf,
+ err, err_info))
return FALSE;
/*
diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c
index 0187d10e41..c45580ccd8 100644
--- a/wiretap/peektagged.c
+++ b/wiretap/peektagged.c
@@ -153,8 +153,8 @@ typedef struct {
gboolean has_fcs;
} peektagged_t;
-static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean peektagged_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -828,16 +828,15 @@ peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
return skip_len;
}
-static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean peektagged_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
int skip_len;
*data_offset = file_tell(wth->fh);
/* Read the packet. */
- skip_len = peektagged_read_packet(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ skip_len = peektagged_read_packet(wth, wth->fh, rec, buf, err, err_info);
if (skip_len == -1)
return FALSE;
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index 7c2b28160c..50cfd98ede 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -83,8 +83,8 @@ typedef enum {
DIRECTION_RECV
} direction_enum;
-static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean pppdump_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
@@ -315,11 +315,11 @@ pppdump_set_phdr(wtap_rec *rec, int num_bytes,
/* Find the next packet and parse it; called from wtap_read(). */
static gboolean
-pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+pppdump_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info,
+ gint64 *data_offset)
{
int num_bytes;
direction_enum direction;
- guint8 *buf;
pppdump_t *state;
pkt_id *pid;
@@ -337,11 +337,9 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
} else
pid = NULL; /* sequential only */
- 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)) {
+ ws_buffer_assure_space(buf, PPPD_BUF_SIZE);
+ if (!collate(state, wth->fh, err, err_info, ws_buffer_start_ptr(buf),
+ &num_bytes, &direction, pid, 0)) {
g_free(pid);
return FALSE;
}
@@ -355,10 +353,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->rec, num_bytes, direction);
- wth->rec.presence_flags = WTAP_HAS_TS;
- wth->rec.ts.secs = state->timestamp;
- wth->rec.ts.nsecs = state->tenths * 100000000;
+ pppdump_set_phdr(rec, num_bytes, direction);
+ rec->presence_flags = WTAP_HAS_TS;
+ rec->ts.secs = state->timestamp;
+ rec->ts.nsecs = state->tenths * 100000000;
return TRUE;
}
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index 2b651d6662..579d3b2244 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -71,8 +71,8 @@ struct radcomrec_hdr {
char xxw[9]; /* unknown */
};
-static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean radcom_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean radcom_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean radcom_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec,
@@ -230,16 +230,15 @@ wtap_open_return_val radcom_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean radcom_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
char fcs[2];
*data_offset = file_tell(wth->fh);
/* Read record. */
- if (!radcom_read_rec(wth, wth->fh, &wth->rec, wth->rec_data,
- err, err_info)) {
+ if (!radcom_read_rec(wth, wth->fh, rec, buf, err, err_info)) {
/* Read error or EOF */
return FALSE;
}
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index 95aaa7d9f9..bc2785b938 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -71,8 +71,8 @@ struct shomiti_trailer {
#define RX_STATUS_FIFO_ERROR 0x0080 /* receive FIFO error */
#define RX_STATUS_TRIGGERED 0x0001 /* frame did trigger */
-static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean snoop_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean snoop_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static int snoop_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
@@ -417,15 +417,14 @@ typedef struct {
/* Read the next packet */
-static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean snoop_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
int padbytes;
*data_offset = file_tell(wth->fh);
- padbytes = snoop_read_packet(wth, wth->fh, &wth->rec,
- wth->rec_data, err, err_info);
+ padbytes = snoop_read_packet(wth, wth->fh, rec, buf, err, err_info);
if (padbytes == -1)
return FALSE;
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c
index 5b57b6ef20..d2578b9164 100644
--- a/wiretap/stanag4607.c
+++ b/wiretap/stanag4607.c
@@ -145,11 +145,12 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, wtap_rec *rec,
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
-static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean stanag4607_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
- return stanag4607_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info);
+ return stanag4607_read_file(wth, wth->fh, rec, buf, err, err_info);
}
static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off,
diff --git a/wiretap/systemd_journal.c b/wiretap/systemd_journal.c
index cda48b01c8..30fdd0cab9 100644
--- a/wiretap/systemd_journal.c
+++ b/wiretap/systemd_journal.c
@@ -41,8 +41,8 @@
// SYSLOG_IDENTIFIER=kernel
// MESSAGE=Initializing cgroup subsys cpuset
-static gboolean systemd_journal_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean systemd_journal_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean systemd_journal_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean systemd_journal_read_export_entry(FILE_T fh, wtap_rec *rec,
@@ -101,13 +101,13 @@ wtap_open_return_val systemd_journal_open(wtap *wth, int *err _U_, gchar **err_i
}
/* Read the next packet */
-static gboolean systemd_journal_read(wtap *wth, int *err _U_, gchar **err_info,
- gint64 *data_offset)
+static gboolean systemd_journal_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
*data_offset = file_tell(wth->fh);
/* Read record. */
- if (!systemd_journal_read_export_entry(wth->fh, &wth->rec, wth->rec_data, err, err_info)) {
+ if (!systemd_journal_read_export_entry(wth->fh, rec, buf, err, err_info)) {
/* Read error or EOF */
return FALSE;
}
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index af3b47b758..1bb1c0067e 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -86,8 +86,8 @@ static const char toshiba_hdr_magic[] =
static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' };
#define TOSHIBA_REC_MAGIC_SIZE (sizeof toshiba_rec_magic / sizeof toshiba_rec_magic[0])
-static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean toshiba_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
@@ -195,8 +195,8 @@ wtap_open_return_val toshiba_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean toshiba_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset;
@@ -207,8 +207,7 @@ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
*data_offset = offset;
/* Parse the packet */
- return parse_toshiba_packet(wth->fh, &wth->rec, wth->rec_data,
- err, err_info);
+ return parse_toshiba_packet(wth->fh, rec, buf, err, err_info);
}
/* Used to read packets in random-access fashion */
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 788e5ce00a..19921597eb 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -145,8 +145,8 @@ struct visual_write_info
/* Local functions to handle file reads and writes */
-static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean visual_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean visual_read_packet(wtap *wth, FILE_T fh,
@@ -259,8 +259,8 @@ wtap_open_return_val visual_open(wtap *wth, int *err, gchar **err_info)
in a loop to sequentially read the entire file one time. After
the file has been read once, any Future access to the packets is
done through seek_read. */
-static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean visual_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
struct visual_read_info *visual = (struct visual_read_info *)wth->priv;
@@ -276,8 +276,7 @@ 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->rec, wth->rec_data,
- err, err_info);
+ return visual_read_packet(wth, wth->fh, rec, buf, err, err_info);
}
/* Read packet header and data for random access. */
diff --git a/wiretap/vms.c b/wiretap/vms.c
index 978a4e53e0..06723a5613 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -126,8 +126,8 @@ to handle them.
#define VMS_HEADER_LINES_TO_CHECK 200
#define VMS_LINE_LENGTH 240
-static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+static gboolean vms_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
static gboolean vms_seek_read(wtap *wth, gint64 seek_off,
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
@@ -242,8 +242,8 @@ wtap_open_return_val vms_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+static gboolean vms_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset = 0;
@@ -260,7 +260,7 @@ static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
*data_offset = offset;
/* Parse the packet */
- return parse_vms_packet(wth->fh, &wth->rec, wth->rec_data, err, err_info);
+ return parse_vms_packet(wth->fh, rec, buf, err, err_info);
}
/* Used to read packets in random-access fashion */
diff --git a/wiretap/vwr.c b/wiretap/vwr.c
index c4e455cf84..1ad72c7aa6 100644
--- a/wiretap/vwr.c
+++ b/wiretap/vwr.c
@@ -770,8 +770,9 @@ static guint8 get_ofdm_rate(const guint8 *);
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, wtap_rec *record,
+static gboolean vwr_read(wtap *, wtap_rec *, Buffer *, int *,
+ gchar **, gint64 *);
+static gboolean vwr_seek_read(wtap *, gint64, wtap_rec *,
Buffer *, int *, gchar **);
static gboolean vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, int *, gchar **);
@@ -851,7 +852,8 @@ wtap_open_return_val vwr_open(wtap *wth, int *err, gchar **err_info)
/* frame, and a 64-byte statistics block trailer. */
/* The PLCP frame consists of a 4-byte or 6-byte PLCP header, followed by the MAC frame */
-static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean vwr_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
vwr_t *vwr = (vwr_t *)wth->priv;
int rec_size = 0, IS_TX = 0, log_mode = 0;
@@ -867,8 +869,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->rec,
- wth->rec_data, vwr, IS_TX, log_mode, err, err_info))
+ if (!vwr_process_rec_data(wth->fh, rec_size, rec, buf, vwr, IS_TX,
+ log_mode, err, err_info))
return FALSE;
return TRUE;
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index 486b03685f..11cf310809 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -24,7 +24,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_read_func)(struct wtap*, wtap_rec *,
+ Buffer *, int *, char **, gint64 *);
typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, wtap_rec *,
Buffer *, int *, char **);
@@ -37,8 +38,6 @@ struct wtap {
gboolean ispipe; /**< TRUE if the file is a pipe */
int file_type_subtype;
guint snapshot_length;
- 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 */
@@ -318,7 +317,8 @@ wtap_read_packet_bytes(FILE_T fh, Buffer *buf, guint length, int *err,
* as a single packet.
*/
gboolean
-wtap_full_file_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset);
+wtap_full_file_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset);
/*
* Implementation of wth->subtype_seek_read that reads the full file contents
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 26bea65313..1e04868886 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1204,14 +1204,6 @@ wtap_sequential_close(wtap *wth)
file_close(wth->fh);
wth->fh = NULL;
}
-
- wtap_rec_cleanup(&wth->rec);
-
- if (wth->rec_data) {
- ws_buffer_free(wth->rec_data);
- g_free(wth->rec_data);
- wth->rec_data = NULL;
- }
}
static void
@@ -1304,7 +1296,8 @@ wtapng_process_dsb(wtap *wth, wtap_block_t dsb)
}
gboolean
-wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *offset)
{
/*
* Set the packet encapsulation to the file's encapsulation
@@ -1316,12 +1309,12 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*
* Do the same for the packet time stamp resolution.
*/
- wth->rec.rec_header.packet_header.pkt_encap = wth->file_encap;
- wth->rec.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_read(wth, err, err_info, data_offset)) {
+ if (!wth->subtype_read(wth, rec, buf, err, err_info, offset)) {
/*
* If we didn't get an error indication, we read
* the last packet. See if there's any deferred
@@ -1339,13 +1332,13 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
/*
* Is this a packet record?
*/
- if (wth->rec.rec_type == REC_TYPE_PACKET) {
+ 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 (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;
+ 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
@@ -1353,7 +1346,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
* 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);
+ g_assert(rec->rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
}
return TRUE; /* success */
@@ -1448,18 +1441,6 @@ wtap_read_so_far(wtap *wth)
return file_tell_raw(wth->fh);
}
-wtap_rec *
-wtap_get_rec(wtap *wth)
-{
- return &wth->rec;
-}
-
-guint8 *
-wtap_get_buf_ptr(wtap *wth)
-{
- return ws_buffer_start_ptr(wth->rec_data);
-}
-
void
wtap_rec_init(wtap_rec *rec)
{
@@ -1580,7 +1561,8 @@ wtap_full_file_read_file(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *
}
gboolean
-wtap_full_file_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+wtap_full_file_read(wtap *wth, wtap_rec *rec, Buffer *buf,
+ int *err, gchar **err_info, gint64 *data_offset)
{
gint64 offset = file_tell(wth->fh);
@@ -1591,7 +1573,7 @@ wtap_full_file_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
}
*data_offset = offset;
- return wtap_full_file_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info);
+ return wtap_full_file_read_file(wth, wth->fh, rec, buf, err, err_info);
}
gboolean
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 39eb7cae19..0b3342eb16 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1762,24 +1762,45 @@ typedef void (*wtap_new_secrets_callback_t)(guint32 secrets_type, const void *se
WS_DLL_PUBLIC
void wtap_set_cb_new_secrets(wtap *wth, wtap_new_secrets_callback_t add_new_secrets);
-/** Returns TRUE if read was successful. FALSE if failure. data_offset is
- * set to the offset in the file where the data for the read packet is
- * located. */
-WS_DLL_PUBLIC
-gboolean wtap_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
-
+/** Read the next record in the file, filling in *phdr and *buf.
+ *
+ * @wth a wtap * returned by a call that opened a file for reading.
+ * @rec a pointer to a wtap_rec, filled in with information about the
+ * record.
+ * @buf a pointer to a Buffer, filled in with data from the record.
+ * @param err a positive "errno" value, or a negative number indicating
+ * the type of error, if the read failed.
+ * @param err_info for some errors, a string giving more details of
+ * the error
+ * @param offset a pointer to a gint64, set to the offset in the file
+ * that should be used on calls to wtap_seek_read() to reread that record,
+ * if the read succeeded.
+ * @return TRUE on success, FALSE on failure.
+ */
+WS_DLL_PUBLIC
+gboolean wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ gchar **err_info, gint64 *offset);
+
+/** Read the record at a specified offset in a capture file, filling in
+ * *phdr and *buf.
+ *
+ * @wth a wtap * returned by a call that opened a file for random-access
+ * reading.
+ * @seek_off a gint64 giving an offset value returned by a previous
+ * wtap_read() call.
+ * @phdr a pointer to a struct wtap_pkthdr, filled in with information
+ * about the record.
+ * @buf a pointer to a Buffer, filled in with data from the record.
+ * @param err a positive "errno" value, or a negative number indicating
+ * the type of error, if the read failed.
+ * @param err_info for some errors, a string giving more details of
+ * the error
+ * @return TRUE on success, FALSE on failure.
+ */
WS_DLL_PUBLIC
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 record ***/
-WS_DLL_PUBLIC
-wtap_rec *wtap_get_rec(wtap *wth);
-
-WS_DLL_PUBLIC
-guint8 *wtap_get_buf_ptr(wtap *wth);
-
/*** initialize a wtap_rec structure ***/
WS_DLL_PUBLIC
void wtap_rec_init(wtap_rec *rec);