forked from osmocom/wireshark
Pass create_proto_tree, cinfo directly to add_packet_to_packet_list
svn path=/trunk/; revision=45666
This commit is contained in:
parent
ea31ff66a0
commit
88ac0dbea2
70
file.c
70
file.c
|
@ -89,7 +89,7 @@ static gulong computed_elapsed;
|
||||||
static void cf_reset_state(capture_file *cf);
|
static void cf_reset_state(capture_file *cf);
|
||||||
|
|
||||||
static int read_packet(capture_file *cf, dfilter_t *dfcode,
|
static int read_packet(capture_file *cf, dfilter_t *dfcode,
|
||||||
gboolean filtering_tap_listeners, guint tap_flags, gint64 offset);
|
gboolean create_proto_tree, column_info *cinfo, gint64 offset);
|
||||||
|
|
||||||
static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
|
static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
|
||||||
|
|
||||||
|
@ -512,7 +512,8 @@ cf_read(capture_file *cf, gboolean reloading)
|
||||||
volatile gint64 progbar_nextstep;
|
volatile gint64 progbar_nextstep;
|
||||||
volatile gint64 progbar_quantum;
|
volatile gint64 progbar_quantum;
|
||||||
dfilter_t *dfcode;
|
dfilter_t *dfcode;
|
||||||
gboolean filtering_tap_listeners;
|
column_info *cinfo;
|
||||||
|
gboolean create_proto_tree;
|
||||||
guint tap_flags;
|
guint tap_flags;
|
||||||
volatile int count = 0;
|
volatile int count = 0;
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
|
@ -527,11 +528,11 @@ cf_read(capture_file *cf, gboolean reloading)
|
||||||
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
||||||
g_assert(!cf->dfilter || (compiled && dfcode));
|
g_assert(!cf->dfilter || (compiled && dfcode));
|
||||||
|
|
||||||
/* Do we have any tap listeners with filters? */
|
|
||||||
filtering_tap_listeners = have_filtering_tap_listeners();
|
|
||||||
|
|
||||||
/* Get the union of the flags for all tap listeners. */
|
/* Get the union of the flags for all tap listeners. */
|
||||||
tap_flags = union_of_tap_listener_flags();
|
tap_flags = union_of_tap_listener_flags();
|
||||||
|
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||||
|
create_proto_tree =
|
||||||
|
(dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||||
|
|
||||||
reset_tap_listeners();
|
reset_tap_listeners();
|
||||||
|
|
||||||
|
@ -619,7 +620,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TRY {
|
TRY {
|
||||||
read_packet(cf, dfcode, filtering_tap_listeners, tap_flags, data_offset);
|
read_packet(cf, dfcode, create_proto_tree, cinfo, data_offset);
|
||||||
}
|
}
|
||||||
CATCH(OutOfMemoryError) {
|
CATCH(OutOfMemoryError) {
|
||||||
simple_message_box(ESD_TYPE_ERROR, NULL,
|
simple_message_box(ESD_TYPE_ERROR, NULL,
|
||||||
|
@ -767,7 +768,8 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
volatile int newly_displayed_packets = 0;
|
volatile int newly_displayed_packets = 0;
|
||||||
dfilter_t *dfcode;
|
dfilter_t *dfcode;
|
||||||
gboolean filtering_tap_listeners;
|
column_info *cinfo;
|
||||||
|
gboolean create_proto_tree;
|
||||||
guint tap_flags;
|
guint tap_flags;
|
||||||
gboolean compiled;
|
gboolean compiled;
|
||||||
|
|
||||||
|
@ -778,11 +780,11 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
||||||
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
||||||
g_assert(!cf->dfilter || (compiled && dfcode));
|
g_assert(!cf->dfilter || (compiled && dfcode));
|
||||||
|
|
||||||
/* Do we have any tap listeners with filters? */
|
|
||||||
filtering_tap_listeners = have_filtering_tap_listeners();
|
|
||||||
|
|
||||||
/* Get the union of the flags for all tap listeners. */
|
/* Get the union of the flags for all tap listeners. */
|
||||||
tap_flags = union_of_tap_listener_flags();
|
tap_flags = union_of_tap_listener_flags();
|
||||||
|
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||||
|
create_proto_tree =
|
||||||
|
(dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||||
|
|
||||||
*err = 0;
|
*err = 0;
|
||||||
|
|
||||||
|
@ -804,7 +806,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TRY{
|
TRY{
|
||||||
if (read_packet(cf, dfcode, filtering_tap_listeners, tap_flags,
|
if (read_packet(cf, dfcode, create_proto_tree, cinfo,
|
||||||
data_offset) != -1) {
|
data_offset) != -1) {
|
||||||
newly_displayed_packets++;
|
newly_displayed_packets++;
|
||||||
}
|
}
|
||||||
|
@ -881,7 +883,8 @@ cf_finish_tail(capture_file *cf, int *err)
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
gint64 data_offset;
|
gint64 data_offset;
|
||||||
dfilter_t *dfcode;
|
dfilter_t *dfcode;
|
||||||
gboolean filtering_tap_listeners;
|
column_info *cinfo;
|
||||||
|
gboolean create_proto_tree;
|
||||||
guint tap_flags;
|
guint tap_flags;
|
||||||
gboolean compiled;
|
gboolean compiled;
|
||||||
|
|
||||||
|
@ -892,11 +895,11 @@ cf_finish_tail(capture_file *cf, int *err)
|
||||||
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
||||||
g_assert(!cf->dfilter || (compiled && dfcode));
|
g_assert(!cf->dfilter || (compiled && dfcode));
|
||||||
|
|
||||||
/* Do we have any tap listeners with filters? */
|
|
||||||
filtering_tap_listeners = have_filtering_tap_listeners();
|
|
||||||
|
|
||||||
/* Get the union of the flags for all tap listeners. */
|
/* Get the union of the flags for all tap listeners. */
|
||||||
tap_flags = union_of_tap_listener_flags();
|
tap_flags = union_of_tap_listener_flags();
|
||||||
|
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||||
|
create_proto_tree =
|
||||||
|
(dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||||
|
|
||||||
if (cf->wth == NULL) {
|
if (cf->wth == NULL) {
|
||||||
cf_close(cf);
|
cf_close(cf);
|
||||||
|
@ -914,7 +917,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
||||||
aren't any packets left to read) exit. */
|
aren't any packets left to read) exit. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
read_packet(cf, dfcode, filtering_tap_listeners, tap_flags, data_offset);
|
read_packet(cf, dfcode, create_proto_tree, cinfo, data_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup and release all dfilter resources */
|
/* Cleanup and release all dfilter resources */
|
||||||
|
@ -1086,33 +1089,17 @@ find_and_mark_frame_depended_upon(gpointer data, gpointer user_data)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
||||||
dfilter_t *dfcode, gboolean filtering_tap_listeners,
|
dfilter_t *dfcode, gboolean create_proto_tree, column_info *cinfo,
|
||||||
guint tap_flags,
|
|
||||||
struct wtap_pkthdr *phdr, const guchar *buf,
|
struct wtap_pkthdr *phdr, const guchar *buf,
|
||||||
gboolean add_to_packet_list)
|
gboolean add_to_packet_list)
|
||||||
{
|
{
|
||||||
gboolean create_proto_tree = FALSE;
|
|
||||||
epan_dissect_t edt;
|
epan_dissect_t edt;
|
||||||
column_info *cinfo;
|
|
||||||
gint row = -1;
|
gint row = -1;
|
||||||
|
|
||||||
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
|
||||||
|
|
||||||
frame_data_set_before_dissect(fdata, &cf->elapsed_time,
|
frame_data_set_before_dissect(fdata, &cf->elapsed_time,
|
||||||
&first_ts, prev_dis, prev_cap);
|
&first_ts, prev_dis, prev_cap);
|
||||||
prev_cap = fdata;
|
prev_cap = fdata;
|
||||||
|
|
||||||
/* If either
|
|
||||||
+ we have a display filter and are re-applying it;
|
|
||||||
+ we have tap listeners with filters;
|
|
||||||
+ we have tap listeners that require a protocol tree;
|
|
||||||
|
|
||||||
allocate a protocol tree root node, so that we'll construct
|
|
||||||
a protocol tree against which a filter expression can be
|
|
||||||
evaluated. */
|
|
||||||
if (dfcode != NULL || filtering_tap_listeners || (tap_flags & TL_REQUIRES_PROTO_TREE))
|
|
||||||
create_proto_tree = TRUE;
|
|
||||||
|
|
||||||
/* Dissect the frame. */
|
/* Dissect the frame. */
|
||||||
epan_dissect_init(&edt, create_proto_tree, FALSE);
|
epan_dissect_init(&edt, create_proto_tree, FALSE);
|
||||||
|
|
||||||
|
@ -1179,7 +1166,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
||||||
/* returns the row of the new packet in the packet list or -1 if not displayed */
|
/* returns the row of the new packet in the packet list or -1 if not displayed */
|
||||||
static int
|
static int
|
||||||
read_packet(capture_file *cf, dfilter_t *dfcode,
|
read_packet(capture_file *cf, dfilter_t *dfcode,
|
||||||
gboolean filtering_tap_listeners, guint tap_flags, gint64 offset)
|
gboolean create_proto_tree, column_info *cinfo, gint64 offset)
|
||||||
{
|
{
|
||||||
struct wtap_pkthdr *phdr = wtap_phdr(cf->wth);
|
struct wtap_pkthdr *phdr = wtap_phdr(cf->wth);
|
||||||
const guchar *buf = wtap_buf_ptr(cf->wth);
|
const guchar *buf = wtap_buf_ptr(cf->wth);
|
||||||
|
@ -1224,7 +1211,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
|
||||||
|
|
||||||
if (!cf->redissecting) {
|
if (!cf->redissecting) {
|
||||||
row = add_packet_to_packet_list(fdata, cf, dfcode,
|
row = add_packet_to_packet_list(fdata, cf, dfcode,
|
||||||
filtering_tap_listeners, tap_flags,
|
create_proto_tree, cinfo,
|
||||||
phdr, buf, TRUE);
|
phdr, buf, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1764,7 +1751,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
|
||||||
int progbar_nextstep;
|
int progbar_nextstep;
|
||||||
int progbar_quantum;
|
int progbar_quantum;
|
||||||
dfilter_t *dfcode;
|
dfilter_t *dfcode;
|
||||||
gboolean filtering_tap_listeners;
|
column_info *cinfo;
|
||||||
|
gboolean create_proto_tree;
|
||||||
guint tap_flags;
|
guint tap_flags;
|
||||||
gboolean add_to_packet_list = FALSE;
|
gboolean add_to_packet_list = FALSE;
|
||||||
gboolean compiled;
|
gboolean compiled;
|
||||||
|
@ -1777,11 +1765,11 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
|
||||||
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
compiled = dfilter_compile(cf->dfilter, &dfcode);
|
||||||
g_assert(!cf->dfilter || (compiled && dfcode));
|
g_assert(!cf->dfilter || (compiled && dfcode));
|
||||||
|
|
||||||
/* Do we have any tap listeners with filters? */
|
|
||||||
filtering_tap_listeners = have_filtering_tap_listeners();
|
|
||||||
|
|
||||||
/* Get the union of the flags for all tap listeners. */
|
/* Get the union of the flags for all tap listeners. */
|
||||||
tap_flags = union_of_tap_listener_flags();
|
tap_flags = union_of_tap_listener_flags();
|
||||||
|
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||||
|
create_proto_tree =
|
||||||
|
(dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||||
|
|
||||||
reset_tap_listeners();
|
reset_tap_listeners();
|
||||||
/* Which frame, if any, is the currently selected frame?
|
/* Which frame, if any, is the currently selected frame?
|
||||||
|
@ -1933,8 +1921,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
|
||||||
preceding_frame_num = prev_frame_num;
|
preceding_frame_num = prev_frame_num;
|
||||||
preceding_frame = prev_frame;
|
preceding_frame = prev_frame;
|
||||||
}
|
}
|
||||||
add_packet_to_packet_list(fdata, cf, dfcode, filtering_tap_listeners,
|
add_packet_to_packet_list(fdata, cf, dfcode, create_proto_tree,
|
||||||
tap_flags, &cf->phdr, cf->pd,
|
cinfo, &cf->phdr, cf->pd,
|
||||||
add_to_packet_list);
|
add_to_packet_list);
|
||||||
|
|
||||||
/* If this frame is displayed, and this is the first frame we've
|
/* If this frame is displayed, and this is the first frame we've
|
||||||
|
|
Loading…
Reference in New Issue