reset_elapsed();
cf->cd_t = wtap_file_type(cf->wth);
+ cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
cf->count = 0;
cf->displayed_count = 0;
cf->marked_count = 0;
return CF_ERROR;
}
+/*
+ * Add an encapsulation type to cf->linktypes.
+ */
+void
+cf_add_encapsulation_type(capture_file *cf, int encap)
+{
+ guint i;
+
+ for (i = 0; i < cf->linktypes->len; i++) {
+ if (g_array_index(cf->linktypes, gint, i) == encap)
+ return; /* it's already there */
+ }
+ /* It's not already there - add it. */
+ g_array_append_val(cf->linktypes, encap);
+}
/*
* Reset the state for the currently closed file, but don't do the
cf->current_row = 0;
cf->finfo_selected = NULL;
+ /* No frame link-layer types, either. */
+ g_array_free(cf->linktypes, TRUE);
+ cf->linktypes = NULL;
+
/* Clear the packet list. */
new_packet_list_freeze();
new_packet_list_clear();
else
cf_callback_invoke(cf_cb_file_read_started, cf);
- /* Record whether the file is compressed. */
+ /* Record whether the file is compressed.
+ XXX - do we know this at open time? */
cf->iscompressed = wtap_iscompressed(cf->wth);
/* Find the size of the file. */
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. */
+ aren't any packets left to read) exit. */
break;
}
read_packet(cf, dfcode, filtering_tap_listeners, tap_flags, data_offset);
int passed;
int row = -1;
+ /* Add this packet's link-layer encapsulation type to cf->linktypes, if
+ it's not already there.
+ XXX - yes, this is O(N), so if every packet had a different
+ 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. */
+ cf_add_encapsulation_type(cf, phdr->pkt_encap);
+
/* The frame number of this packet is one more than the count of
frames in the file so far. */
framenum = cf->count + 1;
static cf_read_status_t
rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
{
+ const struct wtap_pkthdr *phdr;
gchar *err_info;
gchar *name_ptr;
const char *errmsg;
cf->unsaved_changes = FALSE;
cf->cd_t = wtap_file_type(cf->wth);
+ cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
cf->snap = wtap_snapshot_length(cf->wth);
if (cf->snap == 0) {
cf_callback_invoke(cf_cb_file_rescan_started, cf);
- /* Record whether the file is compressed. */
+ /* Record whether the file is compressed.
+ XXX - do we know this at open time? */
cf->iscompressed = wtap_iscompressed(cf->wth);
/* Find the size of the file. */
g_get_current_time(&start_time);
framenum = 0;
+ phdr = wtap_phdr(cf->wth);
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
framenum++;
fdata = frame_data_sequence_find(cf->frames, framenum);
close the current capture. */
break;
}
+
+ /* Add this packet's link-layer encapsulation type to cf->linktypes, if
+ it's not already there.
+ XXX - yes, this is O(N), so if every packet had a different
+ 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. */
+ cf_add_encapsulation_type(cf, phdr->pkt_encap);
}
/* Free the display name */