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>
This commit is contained in:
Guy Harris 2019-04-04 18:56:27 -07:00
parent b572b65e51
commit 8a5b26efb1
69 changed files with 594 additions and 568 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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

View File

@ -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);

View File

@ -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);

62
file.c
View File

@ -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);

View File

@ -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 */

View File

@ -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)) {

View File

@ -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);

View File

@ -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

View File

@ -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. */

View File

@ -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:

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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,

View File

@ -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);
}

View File

@ -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;

View File

@ -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,

View File

@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -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);
}

View File

@ -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)

View File

@ -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 */

View File

@ -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 */

View File

@ -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)) {

View File

@ -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,

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
}
/*

View File

@ -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);
}

View File

@ -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;

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
PACKET_DESCRIBE(rec,buf,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);
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

View File

@ -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];

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;
/*

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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,

View File

@ -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;
}

View File

@ -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 */

View File

@ -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. */

View File

@ -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 */

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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. */
/** 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, int *err, gchar **err_info,
gint64 *data_offset);
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);