forked from osmocom/wireshark
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>sylvain/gmr1
parent
b572b65e51
commit
8a5b26efb1
58
capinfos.c
58
capinfos.c
|
@ -1105,7 +1105,8 @@ process_cap_file(const char *filename, gboolean need_separator)
|
|||
gint64 bytes = 0;
|
||||
guint32 snaplen_min_inferred = 0xffffffff;
|
||||
guint32 snaplen_max_inferred = 0;
|
||||
wtap_rec *rec;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
capture_info cf_info;
|
||||
gboolean have_times = TRUE;
|
||||
nstime_t start_time;
|
||||
|
@ -1164,28 +1165,29 @@ process_cap_file(const char *filename, gboolean need_separator)
|
|||
num_decryption_secrets = 0;
|
||||
|
||||
/* Tally up data that we need to parse through the file to find */
|
||||
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
||||
rec = wtap_get_rec(wth);
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
while (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
if (rec.presence_flags & WTAP_HAS_TS) {
|
||||
prev_time = cur_time;
|
||||
cur_time = rec->ts;
|
||||
cur_time = rec.ts;
|
||||
if (packet == 0) {
|
||||
start_time = rec->ts;
|
||||
start_time_tsprec = rec->tsprec;
|
||||
stop_time = rec->ts;
|
||||
stop_time_tsprec = rec->tsprec;
|
||||
prev_time = rec->ts;
|
||||
start_time = rec.ts;
|
||||
start_time_tsprec = rec.tsprec;
|
||||
stop_time = rec.ts;
|
||||
stop_time_tsprec = rec.tsprec;
|
||||
prev_time = rec.ts;
|
||||
}
|
||||
if (nstime_cmp(&cur_time, &prev_time) < 0) {
|
||||
order = NOT_IN_ORDER;
|
||||
}
|
||||
if (nstime_cmp(&cur_time, &start_time) < 0) {
|
||||
start_time = cur_time;
|
||||
start_time_tsprec = rec->tsprec;
|
||||
start_time_tsprec = rec.tsprec;
|
||||
}
|
||||
if (nstime_cmp(&cur_time, &stop_time) > 0) {
|
||||
stop_time = cur_time;
|
||||
stop_time_tsprec = rec->tsprec;
|
||||
stop_time_tsprec = rec.tsprec;
|
||||
}
|
||||
} else {
|
||||
have_times = FALSE; /* at least one packet has no time stamp */
|
||||
|
@ -1193,33 +1195,33 @@ process_cap_file(const char *filename, gboolean need_separator)
|
|||
order = ORDER_UNKNOWN;
|
||||
}
|
||||
|
||||
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||
bytes += rec->rec_header.packet_header.len;
|
||||
if (rec.rec_type == REC_TYPE_PACKET) {
|
||||
bytes += rec.rec_header.packet_header.len;
|
||||
packet++;
|
||||
|
||||
/* If caplen < len for a rcd, then presumably */
|
||||
/* 'Limit packet capture length' was done for this rcd. */
|
||||
/* Keep track as to the min/max actual snapshot lengths */
|
||||
/* seen for this file. */
|
||||
if (rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len) {
|
||||
if (rec->rec_header.packet_header.caplen < snaplen_min_inferred)
|
||||
snaplen_min_inferred = rec->rec_header.packet_header.caplen;
|
||||
if (rec->rec_header.packet_header.caplen > snaplen_max_inferred)
|
||||
snaplen_max_inferred = rec->rec_header.packet_header.caplen;
|
||||
if (rec.rec_header.packet_header.caplen < rec.rec_header.packet_header.len) {
|
||||
if (rec.rec_header.packet_header.caplen < snaplen_min_inferred)
|
||||
snaplen_min_inferred = rec.rec_header.packet_header.caplen;
|
||||
if (rec.rec_header.packet_header.caplen > snaplen_max_inferred)
|
||||
snaplen_max_inferred = rec.rec_header.packet_header.caplen;
|
||||
}
|
||||
|
||||
if ((rec->rec_header.packet_header.pkt_encap > 0) &&
|
||||
(rec->rec_header.packet_header.pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
||||
cf_info.encap_counts[rec->rec_header.packet_header.pkt_encap] += 1;
|
||||
if ((rec.rec_header.packet_header.pkt_encap > 0) &&
|
||||
(rec.rec_header.packet_header.pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
||||
cf_info.encap_counts[rec.rec_header.packet_header.pkt_encap] += 1;
|
||||
} else {
|
||||
fprintf(stderr, "capinfos: Unknown packet encapsulation %d in frame %u of file \"%s\"\n",
|
||||
rec->rec_header.packet_header.pkt_encap, packet, filename);
|
||||
rec.rec_header.packet_header.pkt_encap, packet, filename);
|
||||
}
|
||||
|
||||
/* Packet interface_id info */
|
||||
if (rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
if (rec.presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
/* cf_info.num_interfaces is size, not index, so it's one more than max index */
|
||||
if (rec->rec_header.packet_header.interface_id >= cf_info.num_interfaces) {
|
||||
if (rec.rec_header.packet_header.interface_id >= cf_info.num_interfaces) {
|
||||
/*
|
||||
* OK, re-fetch the number of interfaces, as there might have
|
||||
* been an interface that was in the middle of packets, and
|
||||
|
@ -1234,9 +1236,9 @@ process_cap_file(const char *filename, gboolean need_separator)
|
|||
g_free(idb_info);
|
||||
idb_info = NULL;
|
||||
}
|
||||
if (rec->rec_header.packet_header.interface_id < cf_info.num_interfaces) {
|
||||
if (rec.rec_header.packet_header.interface_id < cf_info.num_interfaces) {
|
||||
g_array_index(cf_info.interface_packet_counts, guint32,
|
||||
rec->rec_header.packet_header.interface_id) += 1;
|
||||
rec.rec_header.packet_header.interface_id) += 1;
|
||||
}
|
||||
else {
|
||||
cf_info.pkt_interface_id_unknown += 1;
|
||||
|
@ -1254,6 +1256,8 @@ process_cap_file(const char *filename, gboolean need_separator)
|
|||
}
|
||||
|
||||
} /* while */
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
/*
|
||||
* Get IDB info strings.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
14
editcap.c
14
editcap.c
|
@ -1054,6 +1054,8 @@ main(int argc, char *argv[])
|
|||
guint max_packet_number = 0;
|
||||
GArray *dsb_types = NULL;
|
||||
GPtrArray *dsb_filenames = NULL;
|
||||
wtap_rec read_rec;
|
||||
Buffer read_buf;
|
||||
const wtap_rec *rec;
|
||||
wtap_rec temp_rec;
|
||||
wtap_dump_params params = WTAP_DUMP_PARAMS_INIT;
|
||||
|
@ -1566,13 +1568,15 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Read all of the packets in turn */
|
||||
while (wtap_read(wth, &read_err, &read_err_info, &data_offset)) {
|
||||
wtap_rec_init(&read_rec);
|
||||
ws_buffer_init(&read_buf, 1500);
|
||||
while (wtap_read(wth, &read_rec, &read_buf, &read_err, &read_err_info, &data_offset)) {
|
||||
if (max_packet_number <= read_count)
|
||||
break;
|
||||
|
||||
read_count++;
|
||||
|
||||
rec = wtap_get_rec(wth);
|
||||
rec = &read_rec;
|
||||
|
||||
/* Extra actions for the first packet */
|
||||
if (read_count == 1) {
|
||||
|
@ -1605,7 +1609,7 @@ main(int argc, char *argv[])
|
|||
} /* first packet only handling */
|
||||
|
||||
|
||||
buf = wtap_get_buf_ptr(wth);
|
||||
buf = ws_buffer_start_ptr(&read_buf);
|
||||
|
||||
/*
|
||||
* Not all packets have time stamps. Only process the time
|
||||
|
@ -1699,7 +1703,7 @@ main(int argc, char *argv[])
|
|||
/* We simply write it, perhaps after truncating it; we could
|
||||
* do other things, like modify it. */
|
||||
|
||||
rec = wtap_get_rec(wth);
|
||||
rec = &read_rec;
|
||||
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
/* Do we adjust timestamps to ensure strict chronological
|
||||
|
@ -2024,6 +2028,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
count++;
|
||||
}
|
||||
wtap_rec_cleanup(&read_rec);
|
||||
ws_buffer_free(&read_buf);
|
||||
|
||||
g_free(fprefix);
|
||||
g_free(fsuffix);
|
||||
|
|
|
@ -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
62
file.c
|
@ -71,8 +71,8 @@
|
|||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
static gboolean read_record(capture_file *cf, dfilter_t *dfcode,
|
||||
epan_dissect_t *edt, column_info *cinfo, gint64 offset);
|
||||
static gboolean read_record(capture_file *cf, wtap_rec *rec, Buffer *buf,
|
||||
dfilter_t *dfcode, epan_dissect_t *edt, column_info *cinfo, gint64 offset);
|
||||
|
||||
static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
|
||||
|
||||
|
@ -569,6 +569,9 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
gint64 file_pos;
|
||||
gint64 data_offset;
|
||||
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
|
||||
float progbar_val;
|
||||
gchar status_str[100];
|
||||
|
||||
|
@ -582,7 +585,10 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
|
||||
g_timer_start(prog_timer);
|
||||
|
||||
while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
while ((wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info,
|
||||
&data_offset))) {
|
||||
if (size >= 0) {
|
||||
count++;
|
||||
file_pos = wtap_read_so_far(cf->provider.wth);
|
||||
|
@ -637,8 +643,10 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
hours even on fast machines) just to see that it was the wrong file. */
|
||||
break;
|
||||
}
|
||||
read_record(cf, dfcode, &edt, cinfo, data_offset);
|
||||
read_record(cf, &rec, &buf, dfcode, &edt, cinfo, data_offset);
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
}
|
||||
CATCH(OutOfMemoryError) {
|
||||
simple_message_box(ESD_TYPE_ERROR, NULL,
|
||||
|
@ -791,15 +799,20 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
|||
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
|
||||
|
||||
TRY {
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
gint64 data_offset = 0;
|
||||
column_info *cinfo;
|
||||
|
||||
/* If any tap listeners require the columns, construct them. */
|
||||
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
while (to_read != 0) {
|
||||
wtap_cleareof(cf->provider.wth);
|
||||
if (!wtap_read(cf->provider.wth, err, &err_info, &data_offset)) {
|
||||
if (!wtap_read(cf->provider.wth, &rec, &buf, err, &err_info,
|
||||
&data_offset)) {
|
||||
break;
|
||||
}
|
||||
if (cf->state == FILE_READ_ABORTED) {
|
||||
|
@ -808,11 +821,13 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
|||
aren't any packets left to read) exit. */
|
||||
break;
|
||||
}
|
||||
if (read_record(cf, dfcode, &edt, cinfo, data_offset)) {
|
||||
if (read_record(cf, &rec, &buf, dfcode, &edt, cinfo, data_offset)) {
|
||||
newly_displayed_packets++;
|
||||
}
|
||||
to_read--;
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
}
|
||||
CATCH(OutOfMemoryError) {
|
||||
simple_message_box(ESD_TYPE_ERROR, NULL,
|
||||
|
@ -886,6 +901,8 @@ cf_read_status_t
|
|||
cf_finish_tail(capture_file *cf, int *err)
|
||||
{
|
||||
gchar *err_info;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
gint64 data_offset;
|
||||
dfilter_t *dfcode;
|
||||
column_info *cinfo;
|
||||
|
@ -934,15 +951,19 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
|
||||
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
|
||||
|
||||
while ((wtap_read(cf->provider.wth, err, &err_info, &data_offset))) {
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
while ((wtap_read(cf->provider.wth, &rec, &buf, err, &err_info, &data_offset))) {
|
||||
if (cf->state == FILE_READ_ABORTED) {
|
||||
/* Well, the user decided to abort the read. Break out of the
|
||||
loop, and let the code below (which is called even if there
|
||||
aren't any packets left to read) exit. */
|
||||
break;
|
||||
}
|
||||
read_record(cf, dfcode, &edt, cinfo, data_offset);
|
||||
read_record(cf, &rec, &buf, dfcode, &edt, cinfo, data_offset);
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
/* Cleanup and release all dfilter resources */
|
||||
dfilter_free(dfcode);
|
||||
|
@ -1218,11 +1239,9 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
|||
* FALSE otherwise.
|
||||
*/
|
||||
static gboolean
|
||||
read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
||||
column_info *cinfo, gint64 offset)
|
||||
read_record(capture_file *cf, wtap_rec *rec, Buffer *buf, dfilter_t *dfcode,
|
||||
epan_dissect_t *edt, column_info *cinfo, gint64 offset)
|
||||
{
|
||||
wtap_rec *rec = wtap_get_rec(cf->provider.wth);
|
||||
const guint8 *pd = wtap_get_buf_ptr(cf->provider.wth);
|
||||
frame_data fdlocal;
|
||||
frame_data *fdata;
|
||||
gboolean passed = TRUE;
|
||||
|
@ -1248,7 +1267,7 @@ read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
|||
epan_dissect_init(&rf_edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_with_dfilter(&rf_edt, cf->rfcode);
|
||||
epan_dissect_run(&rf_edt, cf->cd_t, rec,
|
||||
frame_tvbuff_new(&cf->provider, &fdlocal, pd),
|
||||
frame_tvbuff_new_buffer(&cf->provider, &fdlocal, buf),
|
||||
&fdlocal, NULL);
|
||||
passed = dfilter_apply_edt(cf->rfcode, &rf_edt);
|
||||
epan_dissect_cleanup(&rf_edt);
|
||||
|
@ -1269,7 +1288,7 @@ read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
|||
* This will be done once all (new) packets have been scanned. */
|
||||
if (!cf->redissecting && cf->redissection_queued == RESCAN_NONE) {
|
||||
add_packet_to_packet_list(fdata, cf, edt, dfcode,
|
||||
cinfo, rec, pd, TRUE);
|
||||
cinfo, rec, ws_buffer_start_ptr(buf), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4192,7 +4211,8 @@ cf_has_unsaved_data(capture_file *cf)
|
|||
static cf_read_status_t
|
||||
rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
||||
{
|
||||
const wtap_rec *rec;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
gchar *name_ptr;
|
||||
|
@ -4259,8 +4279,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
|||
g_get_current_time(&start_time);
|
||||
|
||||
framenum = 0;
|
||||
rec = wtap_get_rec(cf->provider.wth);
|
||||
while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
while ((wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info,
|
||||
&data_offset))) {
|
||||
framenum++;
|
||||
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
|
||||
fdata->file_off = data_offset;
|
||||
|
@ -4304,10 +4326,12 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
|||
link-layer encapsulation type, it'd be O(N^2) to read the file, but
|
||||
there are probably going to be a small number of encapsulation types
|
||||
in a file. */
|
||||
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||
cf_add_encapsulation_type(cf, rec->rec_header.packet_header.pkt_encap);
|
||||
if (rec.rec_type == REC_TYPE_PACKET) {
|
||||
cf_add_encapsulation_type(cf, rec.rec_header.packet_header.pkt_encap);
|
||||
}
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
/* Free the display name */
|
||||
g_free(name_ptr);
|
||||
|
|
|
@ -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 */
|
||||
|
|
21
reordercap.c
21
reordercap.c
|
@ -166,12 +166,11 @@ main(int argc, char *argv[])
|
|||
char *init_progfile_dir_error;
|
||||
wtap *wth = NULL;
|
||||
wtap_dumper *pdh = NULL;
|
||||
wtap_rec dump_rec;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
gint64 data_offset;
|
||||
const wtap_rec *rec;
|
||||
guint wrong_order_count = 0;
|
||||
gboolean write_output_regardless = TRUE;
|
||||
guint i;
|
||||
|
@ -284,16 +283,16 @@ main(int argc, char *argv[])
|
|||
frames = g_ptr_array_new();
|
||||
|
||||
/* Read each frame from infile */
|
||||
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
while (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
FrameRecord_t *newFrameRecord;
|
||||
|
||||
rec = wtap_get_rec(wth);
|
||||
|
||||
newFrameRecord = g_slice_new(FrameRecord_t);
|
||||
newFrameRecord->num = frames->len + 1;
|
||||
newFrameRecord->offset = data_offset;
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
newFrameRecord->frame_time = rec->ts;
|
||||
if (rec.presence_flags & WTAP_HAS_TS) {
|
||||
newFrameRecord->frame_time = rec.ts;
|
||||
} else {
|
||||
nstime_set_unset(&newFrameRecord->frame_time);
|
||||
}
|
||||
|
@ -305,6 +304,8 @@ main(int argc, char *argv[])
|
|||
g_ptr_array_add(frames, newFrameRecord);
|
||||
prevFrame = newFrameRecord;
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
if (err != 0) {
|
||||
/* Print a message noting that the read failed somewhere along the line. */
|
||||
cfile_read_failure_message("reordercap", infile, err, err_info);
|
||||
|
@ -318,18 +319,18 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Write out each sorted frame in turn */
|
||||
wtap_rec_init(&dump_rec);
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
for (i = 0; i < frames->len; i++) {
|
||||
FrameRecord_t *frame = (FrameRecord_t *)frames->pdata[i];
|
||||
|
||||
/* Avoid writing if already sorted and configured to */
|
||||
if (write_output_regardless || (wrong_order_count > 0)) {
|
||||
frame_write(frame, wth, pdh, &dump_rec, &buf, infile, outfile);
|
||||
frame_write(frame, wth, pdh, &rec, &buf, infile, outfile);
|
||||
}
|
||||
g_slice_free(FrameRecord_t, frame);
|
||||
}
|
||||
wtap_rec_cleanup(&dump_rec);
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
if (!write_output_regardless && (wrong_order_count == 0)) {
|
||||
|
|
14
sharkd.c
14
sharkd.c
|
@ -320,6 +320,8 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
int err;
|
||||
gchar *err_info = NULL;
|
||||
gint64 data_offset;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
epan_dissect_t *edt = NULL;
|
||||
|
||||
{
|
||||
|
@ -348,9 +350,12 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
|
||||
}
|
||||
|
||||
while (wtap_read(cf->provider.wth, &err, &err_info, &data_offset)) {
|
||||
if (process_packet(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
|
||||
wtap_get_buf_ptr(cf->provider.wth))) {
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
|
||||
while (wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
if (process_packet(cf, edt, data_offset, &rec,
|
||||
ws_buffer_start_ptr(&buf))) {
|
||||
/* Stop reading if we have the maximum number of packets;
|
||||
* When the -c option has not been used, max_packet_count
|
||||
* starts at 0, which practically means, never stop reading.
|
||||
|
@ -368,6 +373,9 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
edt = NULL;
|
||||
}
|
||||
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
/* Close the sequential I/O side, to free up memory it requires. */
|
||||
wtap_sequential_close(cf->provider.wth);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
61
tshark.c
61
tshark.c
|
@ -241,8 +241,8 @@ typedef enum {
|
|||
static process_file_status_t process_cap_file(capture_file *, char *, int, gboolean, int, gint64);
|
||||
|
||||
static gboolean process_packet_single_pass(capture_file *cf,
|
||||
epan_dissect_t *edt, gint64 offset, wtap_rec *rec,
|
||||
const guchar *pd, guint tap_flags);
|
||||
epan_dissect_t *edt, gint64 offset, wtap_rec *rec, Buffer *buf,
|
||||
guint tap_flags);
|
||||
static void show_print_file_io_error(int err);
|
||||
static gboolean write_preamble(capture_file *cf);
|
||||
static gboolean print_packet(capture_file *cf, epan_dissect_t *edt);
|
||||
|
@ -2702,6 +2702,8 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
|||
if (do_dissection) {
|
||||
gboolean create_proto_tree;
|
||||
epan_dissect_t *edt;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
|
||||
/*
|
||||
* Determine whether we need to create a protocol tree.
|
||||
|
@ -2734,9 +2736,12 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
|||
("packet_details" is true). */
|
||||
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
|
||||
while (to_read-- && cf->provider.wth) {
|
||||
wtap_cleareof(cf->provider.wth);
|
||||
ret = wtap_read(cf->provider.wth, &err, &err_info, &data_offset);
|
||||
ret = wtap_read(cf->provider.wth, &rec, &buf, &err, &err_info, &data_offset);
|
||||
reset_epan_mem(cf, edt, create_proto_tree, print_packet_info && print_details);
|
||||
if (ret == FALSE) {
|
||||
/* read from file failed, tell the capture child to stop */
|
||||
|
@ -2744,9 +2749,8 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
|||
wtap_close(cf->provider.wth);
|
||||
cf->provider.wth = NULL;
|
||||
} else {
|
||||
ret = process_packet_single_pass(cf, edt, data_offset,
|
||||
wtap_get_rec(cf->provider.wth),
|
||||
wtap_get_buf_ptr(cf->provider.wth), tap_flags);
|
||||
ret = process_packet_single_pass(cf, edt, data_offset, &rec, &buf,
|
||||
tap_flags);
|
||||
}
|
||||
if (ret != FALSE) {
|
||||
/* packet successfully read and gone through the "Read Filter" */
|
||||
|
@ -2756,6 +2760,9 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
|||
|
||||
epan_dissect_free(edt);
|
||||
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Dumpcap's doing all the work; we're not doing any dissection.
|
||||
|
@ -2918,8 +2925,7 @@ capture_cleanup(int signum _U_)
|
|||
|
||||
static gboolean
|
||||
process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||
gint64 offset, wtap_rec *rec,
|
||||
const guchar *pd)
|
||||
gint64 offset, wtap_rec *rec, Buffer *buf)
|
||||
{
|
||||
frame_data fdlocal;
|
||||
guint32 framenum;
|
||||
|
@ -2962,7 +2968,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
|||
}
|
||||
|
||||
epan_dissect_run(edt, cf->cd_t, rec,
|
||||
frame_tvbuff_new(&cf->provider, &fdlocal, pd),
|
||||
frame_tvbuff_new_buffer(&cf->provider, &fdlocal, buf),
|
||||
&fdlocal, NULL);
|
||||
|
||||
/* Run the read filter if we have one. */
|
||||
|
@ -3055,10 +3061,15 @@ static pass_status_t
|
|||
process_cap_file_first_pass(capture_file *cf, int max_packet_count,
|
||||
gint64 max_byte_count, int *err, gchar **err_info)
|
||||
{
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
epan_dissect_t *edt = NULL;
|
||||
gint64 data_offset;
|
||||
pass_status_t status = PASS_SUCCEEDED;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
|
||||
/* Allocate a frame_data_sequence for all the frames. */
|
||||
cf->provider.frames = new_frame_data_sequence();
|
||||
|
||||
|
@ -3088,13 +3099,12 @@ process_cap_file_first_pass(capture_file *cf, int max_packet_count,
|
|||
|
||||
tshark_debug("tshark: reading records for first pass");
|
||||
*err = 0;
|
||||
while (wtap_read(cf->provider.wth, err, err_info, &data_offset)) {
|
||||
while (wtap_read(cf->provider.wth, &rec, &buf, err, err_info, &data_offset)) {
|
||||
if (read_interrupted) {
|
||||
status = PASS_INTERRUPTED;
|
||||
break;
|
||||
}
|
||||
if (process_packet_first_pass(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
|
||||
wtap_get_buf_ptr(cf->provider.wth))) {
|
||||
if (process_packet_first_pass(cf, edt, data_offset, &rec, &buf)) {
|
||||
/* Stop reading if we have the maximum number of packets;
|
||||
* When the -c option has not been used, max_packet_count
|
||||
* starts at 0, which practically means, never stop reading.
|
||||
|
@ -3124,6 +3134,9 @@ process_cap_file_first_pass(capture_file *cf, int max_packet_count,
|
|||
cf->provider.prev_dis = NULL;
|
||||
cf->provider.prev_cap = NULL;
|
||||
|
||||
ws_buffer_free(&buf);
|
||||
wtap_rec_cleanup(&rec);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -3285,8 +3298,7 @@ process_cap_file_second_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
break;
|
||||
}
|
||||
tshark_debug("tshark: invoking process_packet_second_pass() for frame #%d", framenum);
|
||||
if (process_packet_second_pass(cf, edt, fdata, &rec, &buf,
|
||||
tap_flags)) {
|
||||
if (process_packet_second_pass(cf, edt, fdata, &rec, &buf, tap_flags)) {
|
||||
/* Either there's no read filtering or this packet passed the
|
||||
filter, so, if we're writing to a capture file, write
|
||||
this packet out. */
|
||||
|
@ -3318,6 +3330,8 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
int *err, gchar **err_info,
|
||||
volatile guint32 *err_framenum)
|
||||
{
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
gboolean create_proto_tree = FALSE;
|
||||
gboolean filtering_tap_listeners;
|
||||
guint tap_flags;
|
||||
|
@ -3326,6 +3340,9 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
gint64 data_offset;
|
||||
pass_status_t status = PASS_SUCCEEDED;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1500);
|
||||
|
||||
framenum = 0;
|
||||
|
||||
/* Do we have any tap listeners with filters? */
|
||||
|
@ -3377,7 +3394,7 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
set_resolution_synchrony(TRUE);
|
||||
|
||||
*err = 0;
|
||||
while (wtap_read(cf->provider.wth, err, err_info, &data_offset)) {
|
||||
while (wtap_read(cf->provider.wth, &rec, &buf, err, err_info, &data_offset)) {
|
||||
if (read_interrupted) {
|
||||
status = PASS_INTERRUPTED;
|
||||
break;
|
||||
|
@ -3388,15 +3405,13 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
|
||||
reset_epan_mem(cf, edt, create_proto_tree, print_packet_info && print_details);
|
||||
|
||||
if (process_packet_single_pass(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
|
||||
wtap_get_buf_ptr(cf->provider.wth), tap_flags)) {
|
||||
if (process_packet_single_pass(cf, edt, data_offset, &rec, &buf, tap_flags)) {
|
||||
/* Either there's no read filtering or this packet passed the
|
||||
filter, so, if we're writing to a capture file, write
|
||||
this packet out. */
|
||||
if (pdh != NULL) {
|
||||
tshark_debug("tshark: writing packet #%d to outfile", framenum);
|
||||
if (!wtap_dump(pdh, wtap_get_rec(cf->provider.wth),
|
||||
wtap_get_buf_ptr(cf->provider.wth), err, err_info)) {
|
||||
if (!wtap_dump(pdh, &rec, ws_buffer_start_ptr(&buf), err, err_info)) {
|
||||
/* Error writing to the output file. */
|
||||
tshark_debug("tshark: error writing to a capture file (%d)", *err);
|
||||
*err_framenum = framenum;
|
||||
|
@ -3425,6 +3440,9 @@ process_cap_file_single_pass(capture_file *cf, wtap_dumper *pdh,
|
|||
if (edt)
|
||||
epan_dissect_free(edt);
|
||||
|
||||
ws_buffer_free(&buf);
|
||||
wtap_rec_cleanup(&rec);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -3674,8 +3692,7 @@ out:
|
|||
|
||||
static gboolean
|
||||
process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||
wtap_rec *rec, const guchar *pd,
|
||||
guint tap_flags)
|
||||
wtap_rec *rec, Buffer *buf, guint tap_flags)
|
||||
{
|
||||
frame_data fdata;
|
||||
column_info *cinfo;
|
||||
|
@ -3733,7 +3750,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
|||
}
|
||||
|
||||
epan_dissect_run_with_taps(edt, cf->cd_t, rec,
|
||||
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
||||
frame_tvbuff_new_buffer(&cf->provider, &fdata, buf),
|
||||
&fdata, cinfo);
|
||||
|
||||
/* Run the filter if we have it. */
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
< |