aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-12-07 19:31:43 -0800
committerGuy Harris <guy@alum.mit.edu>2017-12-08 03:32:25 +0000
commit797d2f6a87607b146a2ef62e1ff501031dce8212 (patch)
tree7c18adbd5b86d5f2843dd760f6fa492f7c05fef4 /file.c
parent0baa4458c5780b143ad4479d387202ddf4add06f (diff)
Move the frame_set stuff back into the capture_file structure.
libwireshark now expects an epan_t to be created with a pointer to a "packet provider" structure; that structure is opaque within libwireshark, and a pointer to it is passed to the callbacks that provide interface names, interface, descriptions, user comments, and packet time stamps, and that set user comments. The code that calls epan_new() is expected to provide those callbacks, and to define the structure, which can be used by the providers. If none of the callbacks need that extra information, the "packet provider" structure can be null. Have a "file" packet provider for all the programs that provide packets from a file. Change-Id: I4b5709a3dd7b098ebd7d2a7d95bcdd7b5903c1a0 Reviewed-on: https://code.wireshark.org/review/24731 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'file.c')
-rw-r--r--file.c215
1 files changed, 107 insertions, 108 deletions
diff --git a/file.c b/file.c
index 5c38ee029b..7fda336642 100644
--- a/file.c
+++ b/file.c
@@ -223,16 +223,16 @@ static void compute_elapsed(capture_file *cf, GTimeVal *start_time)
}
static const nstime_t *
-ws_get_frame_ts(frame_set *fs, guint32 frame_num)
+ws_get_frame_ts(struct packet_provider *prov, guint32 frame_num)
{
- if (fs->prev_dis && fs->prev_dis->num == frame_num)
- return &fs->prev_dis->abs_ts;
+ if (prov->prev_dis && prov->prev_dis->num == frame_num)
+ return &prov->prev_dis->abs_ts;
- if (fs->prev_cap && fs->prev_cap->num == frame_num)
- return &fs->prev_cap->abs_ts;
+ if (prov->prev_cap && prov->prev_cap->num == frame_num)
+ return &prov->prev_cap->abs_ts;
- if (fs->frames) {
- frame_data *fd = frame_data_sequence_find(fs->frames, frame_num);
+ if (prov->frames) {
+ frame_data *fd = frame_data_sequence_find(prov->frames, frame_num);
return (fd) ? &fd->abs_ts : NULL;
}
@@ -243,13 +243,12 @@ ws_get_frame_ts(frame_set *fs, guint32 frame_num)
static epan_t *
ws_epan_new(capture_file *cf)
{
- epan_t *epan = epan_new();
+ epan_t *epan = epan_new(&cf->provider);
- epan->fs = &cf->frame_set_info;
epan->get_frame_ts = ws_get_frame_ts;
- epan->get_interface_name = frame_set_get_interface_name;
- epan->get_interface_description = frame_set_get_interface_description;
- epan->get_user_comment = frame_set_get_user_comment;
+ epan->get_interface_name = cap_file_provider_get_interface_name;
+ epan->get_interface_description = cap_file_provider_get_interface_description;
+ epan->get_user_comment = cap_file_provider_get_user_comment;
return epan;
}
@@ -283,7 +282,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
/* We're about to start reading the file. */
cf->state = FILE_READ_IN_PROGRESS;
- cf->frame_set_info.wth = wth;
+ cf->provider.wth = wth;
cf->f_datalen = 0;
/* Set the file name because we need it to set the follow stream filter.
@@ -299,7 +298,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
cf->computed_elapsed = 0;
- cf->cd_t = wtap_file_type_subtype(cf->frame_set_info.wth);
+ cf->cd_t = wtap_file_type_subtype(cf->provider.wth);
cf->open_type = type;
cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
cf->count = 0;
@@ -310,15 +309,15 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
cf->ref_time_count = 0;
cf->drops_known = FALSE;
cf->drops = 0;
- cf->snap = wtap_snapshot_length(cf->frame_set_info.wth);
+ cf->snap = wtap_snapshot_length(cf->provider.wth);
/* Allocate a frame_data_sequence for the frames in this file */
- cf->frame_set_info.frames = new_frame_data_sequence();
+ cf->provider.frames = new_frame_data_sequence();
nstime_set_zero(&cf->elapsed_time);
- cf->frame_set_info.ref = NULL;
- cf->frame_set_info.prev_dis = NULL;
- cf->frame_set_info.prev_cap = NULL;
+ cf->provider.ref = NULL;
+ cf->provider.prev_dis = NULL;
+ cf->provider.prev_cap = NULL;
cf->cum_bytes = 0;
packet_list_queue_draw();
@@ -329,8 +328,8 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
ber_set_filename(cf->filename);
}
- wtap_set_cb_new_ipv4(cf->frame_set_info.wth, add_ipv4_name);
- wtap_set_cb_new_ipv6(cf->frame_set_info.wth, (wtap_new_ipv6_callback_t) add_ipv6_name);
+ wtap_set_cb_new_ipv4(cf->provider.wth, add_ipv4_name);
+ wtap_set_cb_new_ipv6(cf->provider.wth, (wtap_new_ipv6_callback_t) add_ipv6_name);
return CF_OK;
@@ -371,9 +370,9 @@ cf_close(capture_file *cf)
/* close things, if not already closed before */
color_filters_cleanup();
- if (cf->frame_set_info.wth) {
- wtap_close(cf->frame_set_info.wth);
- cf->frame_set_info.wth = NULL;
+ if (cf->provider.wth) {
+ wtap_close(cf->provider.wth);
+ cf->provider.wth = NULL;
}
/* We have no file open... */
if (cf->filename != NULL) {
@@ -397,13 +396,13 @@ cf_close(capture_file *cf)
dfilter_free(cf->rfcode);
cf->rfcode = NULL;
- if (cf->frame_set_info.frames != NULL) {
- free_frame_data_sequence(cf->frame_set_info.frames);
- cf->frame_set_info.frames = NULL;
+ if (cf->provider.frames != NULL) {
+ free_frame_data_sequence(cf->provider.frames);
+ cf->provider.frames = NULL;
}
- if (cf->frame_set_info.frames_user_comments) {
- g_tree_destroy(cf->frame_set_info.frames_user_comments);
- cf->frame_set_info.frames_user_comments = NULL;
+ if (cf->provider.frames_user_comments) {
+ g_tree_destroy(cf->provider.frames_user_comments);
+ cf->provider.frames_user_comments = NULL;
}
cf_unselect_packet(cf); /* nothing to select */
cf->first_displayed = 0;
@@ -469,7 +468,7 @@ calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos, gchar *status_s
/* The file probably grew while we were reading it.
* Update file size, and try again.
*/
- size = wtap_file_size(cf->frame_set_info.wth, NULL);
+ size = wtap_file_size(cf->provider.wth, NULL);
if (size >= 0)
progbar_val = (gfloat) file_pos / (gfloat) size;
@@ -544,7 +543,7 @@ cf_read(capture_file *cf, gboolean reloading)
/* Record whether the file is compressed.
XXX - do we know this at open time? */
- cf->iscompressed = wtap_iscompressed(cf->frame_set_info.wth);
+ cf->iscompressed = wtap_iscompressed(cf->provider.wth);
/* The packet list window will be empty until the file is completly loaded */
packet_list_freeze();
@@ -570,14 +569,14 @@ cf_read(capture_file *cf, gboolean reloading)
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
/* Find the size of the file. */
- size = wtap_file_size(cf->frame_set_info.wth, NULL);
+ size = wtap_file_size(cf->provider.wth, NULL);
g_timer_start(prog_timer);
- while ((wtap_read(cf->frame_set_info.wth, &err, &err_info, &data_offset))) {
+ while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
if (size >= 0) {
count++;
- file_pos = wtap_read_so_far(cf->frame_set_info.wth);
+ file_pos = wtap_read_so_far(cf->provider.wth);
/* Create the progress bar if necessary. */
if (progress_is_slow(progbar, prog_timer, size, file_pos)) {
@@ -657,7 +656,7 @@ cf_read(capture_file *cf, gboolean reloading)
cf->state = FILE_READ_DONE;
/* Close the sequential I/O side, to free up memory it requires. */
- wtap_sequential_close(cf->frame_set_info.wth);
+ wtap_sequential_close(cf->provider.wth);
/* Allow the protocol dissectors to free up memory that they
* don't need after the sequential run-through of the packets. */
@@ -670,9 +669,9 @@ cf_read(capture_file *cf, gboolean reloading)
we've looked at all the packets, as we don't know until then whether
there's more than one type (and thus whether it's
WTAP_ENCAP_PER_PACKET). */
- cf->lnk_t = wtap_file_encap(cf->frame_set_info.wth);
+ cf->lnk_t = wtap_file_encap(cf->provider.wth);
- cf->current_frame = frame_data_sequence_find(cf->frame_set_info.frames, cf->first_displayed);
+ cf->current_frame = frame_data_sequence_find(cf->provider.frames, cf->first_displayed);
cf->current_row = 0;
packet_list_thaw();
@@ -774,8 +773,8 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
while (to_read != 0) {
- wtap_cleareof(cf->frame_set_info.wth);
- if (!wtap_read(cf->frame_set_info.wth, err, &err_info, &data_offset)) {
+ wtap_cleareof(cf->provider.wth);
+ if (!wtap_read(cf->provider.wth, err, &err_info, &data_offset)) {
break;
}
if (cf->state == FILE_READ_ABORTED) {
@@ -807,7 +806,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
/* Update the file encapsulation; it might have changed based on the
packets we've read. */
- cf->lnk_t = wtap_file_encap(cf->frame_set_info.wth);
+ cf->lnk_t = wtap_file_encap(cf->provider.wth);
/* Cleanup and release all dfilter resources */
dfilter_free(dfcode);
@@ -900,7 +899,7 @@ cf_finish_tail(capture_file *cf, int *err)
(dfcode != NULL || have_filtering_tap_listeners() ||
(tap_flags & TL_REQUIRES_PROTO_TREE) || postdissectors_want_hfids());
- if (cf->frame_set_info.wth == NULL) {
+ if (cf->provider.wth == NULL) {
cf_close(cf);
return CF_READ_ERROR;
}
@@ -911,7 +910,7 @@ cf_finish_tail(capture_file *cf, int *err)
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
- while ((wtap_read(cf->frame_set_info.wth, err, &err_info, &data_offset))) {
+ while ((wtap_read(cf->provider.wth, 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
@@ -947,7 +946,7 @@ cf_finish_tail(capture_file *cf, int *err)
/* We're done reading sequentially through the file; close the
sequential I/O side, to free up memory it requires. */
- wtap_sequential_close(cf->frame_set_info.wth);
+ wtap_sequential_close(cf->provider.wth);
/* Allow the protocol dissectors to free up memory that they
* don't need after the sequential run-through of the packets. */
@@ -955,7 +954,7 @@ cf_finish_tail(capture_file *cf, int *err)
/* Update the file encapsulation; it might have changed based on the
packets we've read. */
- cf->lnk_t = wtap_file_encap(cf->frame_set_info.wth);
+ cf->lnk_t = wtap_file_encap(cf->provider.wth);
/* Update the details in the file-set dialog, as the capture file
* has likely grown since we first stat-ed it */
@@ -1082,8 +1081,8 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
gint row = -1;
frame_data_set_before_dissect(fdata, &cf->elapsed_time,
- &cf->frame_set_info.ref, cf->frame_set_info.prev_dis);
- cf->frame_set_info.prev_cap = fdata;
+ &cf->provider.ref, cf->provider.prev_dis);
+ cf->provider.prev_cap = fdata;
if (dfcode != NULL) {
epan_dissect_prime_with_dfilter(edt, dfcode);
@@ -1116,7 +1115,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
* (potentially not displayed) frames. Find those frames and mark them
* as depended upon.
*/
- g_slist_foreach(edt->pi.dependent_frames, find_and_mark_frame_depended_upon, cf->frame_set_info.frames);
+ g_slist_foreach(edt->pi.dependent_frames, find_and_mark_frame_depended_upon, cf->provider.frames);
}
} else
fdata->flags.passed_dfilter = 1;
@@ -1132,7 +1131,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
if (fdata->flags.passed_dfilter || fdata->flags.ref_time)
{
frame_data_set_after_dissect(fdata, &cf->cum_bytes);
- cf->frame_set_info.prev_dis = fdata;
+ cf->provider.prev_dis = fdata;
/* If we haven't yet seen the first frame, this is it. */
if (cf->first_displayed == 0)
@@ -1152,8 +1151,8 @@ static int
read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
column_info *cinfo, gint64 offset)
{
- struct wtap_pkthdr *phdr = wtap_phdr(cf->frame_set_info.wth);
- const guint8 *buf = wtap_buf_ptr(cf->frame_set_info.wth);
+ struct wtap_pkthdr *phdr = wtap_phdr(cf->provider.wth);
+ const guint8 *buf = wtap_buf_ptr(cf->provider.wth);
frame_data fdlocal;
guint32 framenum;
frame_data *fdata;
@@ -1186,7 +1185,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
if (passed) {
/* This does a shallow copy of fdlocal, which is good enough. */
- fdata = frame_data_sequence_add(cf->frame_set_info.frames, &fdlocal);
+ fdata = frame_data_sequence_add(cf->provider.frames, &fdlocal);
cf->count++;
if (phdr->opt_comment != NULL)
@@ -1479,7 +1478,7 @@ cf_read_record_r(capture_file *cf, const frame_data *fdata,
int err;
gchar *err_info;
- if (!wtap_seek_read(cf->frame_set_info.wth, fdata->file_off, phdr, buf, &err, &err_info)) {
+ if (!wtap_seek_read(cf->provider.wth, fdata->file_off, phdr, buf, &err, &err_info)) {
cfile_read_failure_alert_box(cf->filename, err, err_info);
return FALSE;
}
@@ -1616,9 +1615,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
/* Iterate through the list of frames. Call a routine for each frame
to check whether it should be displayed and, if so, add it to
the display list. */
- cf->frame_set_info.ref = NULL;
- cf->frame_set_info.prev_dis = NULL;
- cf->frame_set_info.prev_cap = NULL;
+ cf->provider.ref = NULL;
+ cf->provider.prev_dis = NULL;
+ cf->provider.prev_cap = NULL;
cf->cum_bytes = 0;
cf_callback_invoke(cf_cb_file_rescan_started, cf);
@@ -1648,7 +1647,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
for (framenum = 1; framenum <= frames_count; framenum++) {
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
/* Create the progress bar if necessary.
We check on every iteration of the loop, so that it takes no
@@ -1766,7 +1765,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
would leave the user stuck with an Wireshark grinding on
until it finishes. Should we just stick them with that? */
for (; framenum <= frames_count; framenum++) {
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
frame_data_reset(fdata);
}
}
@@ -1864,12 +1863,12 @@ ref_time_packets(capture_file *cf)
frame_data *fdata;
nstime_t rel_ts;
- cf->frame_set_info.ref = NULL;
- cf->frame_set_info.prev_dis = NULL;
+ cf->provider.ref = NULL;
+ cf->provider.prev_dis = NULL;
cf->cum_bytes = 0;
for (framenum = 1; framenum <= cf->count; framenum++) {
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
/* just add some value here until we know if it is being displayed or not */
fdata->cum_bytes = cf->cum_bytes + fdata->pkt_len;
@@ -1881,24 +1880,24 @@ ref_time_packets(capture_file *cf)
/* If we don't have the time stamp of the first packet in the
capture, it's because this is the first packet. Save the time
stamp of this packet as the time stamp of the first packet. */
- if (cf->frame_set_info.ref == NULL)
- cf->frame_set_info.ref = fdata;
+ if (cf->provider.ref == NULL)
+ cf->provider.ref = fdata;
/* if this frames is marked as a reference time frame, reset
firstsec and firstusec to this frame */
if (fdata->flags.ref_time)
- cf->frame_set_info.ref = fdata;
+ cf->provider.ref = fdata;
/* If we don't have the time stamp of the previous displayed packet,
it's because this is the first displayed packet. Save the time
stamp of this packet as the time stamp of the previous displayed
packet. */
- if (cf->frame_set_info.prev_dis == NULL) {
- cf->frame_set_info.prev_dis = fdata;
+ if (cf->provider.prev_dis == NULL) {
+ cf->provider.prev_dis = fdata;
}
/* Get the time elapsed between the first packet and this packet. */
- fdata->frame_ref_num = (fdata != cf->frame_set_info.ref) ? cf->frame_set_info.ref->num : 0;
- nstime_delta(&rel_ts, &fdata->abs_ts, &cf->frame_set_info.ref->abs_ts);
+ fdata->frame_ref_num = (fdata != cf->provider.ref) ? cf->provider.ref->num : 0;
+ nstime_delta(&rel_ts, &fdata->abs_ts, &cf->provider.ref->abs_ts);
/* If it's greater than the current elapsed time, set the elapsed time
to it (we check for "greater than" so as not to be confused by
@@ -1911,8 +1910,8 @@ ref_time_packets(capture_file *cf)
/* If this frame is displayed, get the time elapsed between the
previous displayed packet and this packet. */
if ( fdata->flags.passed_dfilter ) {
- fdata->prev_dis_num = cf->frame_set_info.prev_dis->num;
- cf->frame_set_info.prev_dis = fdata;
+ fdata->prev_dis_num = cf->provider.prev_dis->num;
+ cf->provider.prev_dis = fdata;
}
/*
@@ -1980,7 +1979,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
/* Iterate through all the packets, printing the packets that
were selected by the current display filter. */
for (framenum = 1; framenum <= cf->count; framenum++) {
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
/* Create the progress bar if necessary.
We check on every iteration of the loop, so that it takes no
@@ -3505,7 +3504,7 @@ find_packet(capture_file *cf,
} else
framenum++;
}
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
count++;
@@ -3565,13 +3564,13 @@ cf_goto_frame(capture_file *cf, guint fnumber)
{
frame_data *fdata;
- if (cf == NULL || cf->frame_set_info.frames == NULL) {
+ if (cf == NULL || cf->provider.frames == NULL) {
/* we don't have a loaded capture file - fix for bugs 11810 & 11989 */
statusbar_push_temporary_msg("There is no file loaded");
return FALSE; /* we failed to go to that packet */
}
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, fnumber);
+ fdata = frame_data_sequence_find(cf->provider.frames, fnumber);
if (fdata == NULL) {
/* we didn't find a packet with that packet number */
@@ -3754,7 +3753,7 @@ cf_read_section_comment(capture_file *cf)
/* Get the SHB. */
/* XXX - support multiple SHBs */
- shb_inf = wtap_file_get_shb(cf->frame_set_info.wth);
+ shb_inf = wtap_file_get_shb(cf->provider.wth);
/* Get the first comment from the SHB. */
/* XXX - support multiple comments */
@@ -3774,7 +3773,7 @@ cf_update_section_comment(capture_file *cf, gchar *comment)
/* Get the SHB. */
/* XXX - support multiple SHBs */
- shb_inf = wtap_file_get_shb(cf->frame_set_info.wth);
+ shb_inf = wtap_file_get_shb(cf->provider.wth);
/* Get the first comment from the SHB. */
/* XXX - support multiple comments */
@@ -3807,7 +3806,7 @@ cf_get_packet_comment(capture_file *cf, const frame_data *fd)
/* fetch user comment */
if (fd->flags.has_user_comment)
- return g_strdup(frame_set_get_user_comment(&cf->frame_set_info, fd));
+ return g_strdup(cap_file_provider_get_user_comment(&cf->provider, fd));
/* fetch phdr comment */
if (fd->flags.has_phdr_comment) {
@@ -3849,7 +3848,7 @@ cf_set_user_packet_comment(capture_file *cf, frame_data *fd, const gchar *new_co
if (new_comment)
cf->packet_comment_count++;
- frame_set_set_user_comment(&cf->frame_set_info, fd, new_comment);
+ cap_file_provider_set_user_comment(&cf->provider, fd, new_comment);
expert_update_comment_count(cf->packet_comment_count);
@@ -3916,7 +3915,7 @@ save_record(capture_file *cf, frame_data *fdata,
const char *pkt_comment;
if (fdata->flags.has_user_comment)
- pkt_comment = frame_set_get_user_comment(&cf->frame_set_info, fdata);
+ pkt_comment = cap_file_provider_get_user_comment(&cf->provider, fdata);
else
pkt_comment = phdr->opt_comment;
@@ -4096,7 +4095,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
int count = 0;
/* Close the old handle. */
- wtap_close(cf->frame_set_info.wth);
+ wtap_close(cf->provider.wth);
/* Open the new file. */
/* XXX: this will go through all open_routines for a matching one. But right
@@ -4104,8 +4103,8 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
format than the original, and the user is not given a choice of which
reader to use (only which format to save it in), so doing this makes
sense for now. */
- cf->frame_set_info.wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
- if (cf->frame_set_info.wth == NULL) {
+ cf->provider.wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
+ if (cf->provider.wth == NULL) {
cfile_open_failure_alert_box(fname, err, err_info);
return CF_READ_ERROR;
}
@@ -4125,10 +4124,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
/* No user changes yet. */
cf->unsaved_changes = FALSE;
- cf->cd_t = wtap_file_type_subtype(cf->frame_set_info.wth);
+ cf->cd_t = wtap_file_type_subtype(cf->provider.wth);
cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
- cf->snap = wtap_snapshot_length(cf->frame_set_info.wth);
+ cf->snap = wtap_snapshot_length(cf->provider.wth);
name_ptr = g_filename_display_basename(cf->filename);
@@ -4136,10 +4135,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
/* Record whether the file is compressed.
XXX - do we know this at open time? */
- cf->iscompressed = wtap_iscompressed(cf->frame_set_info.wth);
+ cf->iscompressed = wtap_iscompressed(cf->provider.wth);
/* Find the size of the file. */
- size = wtap_file_size(cf->frame_set_info.wth, NULL);
+ size = wtap_file_size(cf->provider.wth, NULL);
g_timer_start(prog_timer);
@@ -4147,14 +4146,14 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
g_get_current_time(&start_time);
framenum = 0;
- phdr = wtap_phdr(cf->frame_set_info.wth);
- while ((wtap_read(cf->frame_set_info.wth, &err, &err_info, &data_offset))) {
+ phdr = wtap_phdr(cf->provider.wth);
+ while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
framenum++;
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
fdata->file_off = data_offset;
if (size >= 0) {
count++;
- cf->f_datalen = wtap_read_so_far(cf->frame_set_info.wth);
+ cf->f_datalen = wtap_read_so_far(cf->provider.wth);
/* Create the progress bar if necessary. */
if (progress_is_slow(progbar, prog_timer, size, cf->f_datalen)) {
@@ -4207,7 +4206,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
cf->state = FILE_READ_DONE;
/* Close the sequential I/O side, to free up memory it requires. */
- wtap_sequential_close(cf->frame_set_info.wth);
+ wtap_sequential_close(cf->provider.wth);
/* compute the time it took to load the file */
compute_elapsed(cf, &start_time);
@@ -4216,7 +4215,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
we've looked at all the packets, as we don't know until then whether
there's more than one type (and thus whether it's
WTAP_ENCAP_PER_PACKET). */
- cf->lnk_t = wtap_file_encap(cf->frame_set_info.wth);
+ cf->lnk_t = wtap_file_encap(cf->provider.wth);
cf_callback_invoke(cf_cb_file_rescan_finished, cf);
@@ -4350,9 +4349,9 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
int encap;
/* XXX: what free's this shb_hdr? */
- shb_hdrs = wtap_file_get_shb_for_new_file(cf->frame_set_info.wth);
- idb_inf = wtap_file_get_idb_info(cf->frame_set_info.wth);
- nrb_hdrs = wtap_file_get_nrb_for_new_file(cf->frame_set_info.wth);
+ shb_hdrs = wtap_file_get_shb_for_new_file(cf->provider.wth);
+ idb_inf = wtap_file_get_idb_info(cf->provider.wth);
+ nrb_hdrs = wtap_file_get_nrb_for_new_file(cf->provider.wth);
/* Determine what file encapsulation type we should use. */
encap = wtap_dump_file_encap_type(cf->linktypes);
@@ -4430,7 +4429,7 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
on Windows. However, on Windows, we first need to close whatever
file descriptors we have open for fname. */
#ifdef _WIN32
- wtap_fdclose(cf->frame_set_info.wth);
+ wtap_fdclose(cf->provider.wth);
#endif
/* Now do the rename. */
if (ws_rename(fname_new, fname) == -1) {
@@ -4440,7 +4439,7 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
/* Attempt to reopen the random file descriptor using the
current file's filename. (At this point, the sequential
file descriptor is closed.) */
- if (!wtap_fdreopen(cf->frame_set_info.wth, cf->filename, &err)) {
+ if (!wtap_fdreopen(cf->provider.wth, cf->filename, &err)) {
/* Oh, well, we're screwed. */
display_basename = g_filename_display_basename(cf->filename);
simple_error_message_box(
@@ -4473,13 +4472,13 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
/* We just copied the file, s all the information other than
the wtap structure, the filename, and the "is temporary"
status applies to the new file; just update that. */
- wtap_close(cf->frame_set_info.wth);
+ wtap_close(cf->provider.wth);
/* Although we're just "copying" and then opening the copy, it will
try all open_routine readers to open the copy, so we need to
reset the cfile's open_type. */
cf->open_type = WTAP_TYPE_AUTO;
- cf->frame_set_info.wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
- if (cf->frame_set_info.wth == NULL) {
+ cf->provider.wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
+ if (cf->provider.wth == NULL) {
cfile_open_failure_alert_box(fname, err, err_info);
cf_close(cf);
} else {
@@ -4542,19 +4541,19 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
/* If we were told to discard the comments, do so. */
if (discard_comments) {
/* Remove SHB comment, if any. */
- wtap_write_shb_comment(cf->frame_set_info.wth, NULL);
+ wtap_write_shb_comment(cf->provider.wth, NULL);
/* remove all user comments */
for (framenum = 1; framenum <= cf->count; framenum++) {
- fdata = frame_data_sequence_find(cf->frame_set_info.frames, framenum);
+ fdata = frame_data_sequence_find(cf->provider.frames, framenum);
fdata->flags.has_phdr_comment = FALSE;
fdata->flags.has_user_comment = FALSE;
}
- if (cf->frame_set_info.frames_user_comments) {
- g_tree_destroy(cf->frame_set_info.frames_user_comments);
- cf->frame_set_info.frames_user_comments = NULL;
+ if (cf->provider.frames_user_comments) {
+ g_tree_destroy(cf->provider.frames_user_comments);
+ cf->provider.frames_user_comments = NULL;
}
cf->packet_comment_count = 0;
@@ -4601,9 +4600,9 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
and then write it out if it's one of the specified ones. */
/* XXX: what free's this shb_hdr? */
- shb_hdrs = wtap_file_get_shb_for_new_file(cf->frame_set_info.wth);
- idb_inf = wtap_file_get_idb_info(cf->frame_set_info.wth);
- nrb_hdrs = wtap_file_get_nrb_for_new_file(cf->frame_set_info.wth);
+ shb_hdrs = wtap_file_get_shb_for_new_file(cf->provider.wth);
+ idb_inf = wtap_file_get_idb_info(cf->provider.wth);
+ nrb_hdrs = wtap_file_get_nrb_for_new_file(cf->provider.wth);
/* Determine what file encapsulation type we should use. */
encap = wtap_dump_file_encap_type(cf->linktypes);