forked from osmocom/wireshark
Introduces a new global gboolean variable: proto_tree_is_visible.
This is set before calling dissect_packet() to let the proto_tree routines whether or not it needs to go through the trouble of formatting strings. The use of this dramatically decreases the number of calls to vsnprintf. svn path=/trunk/; revision=583
This commit is contained in:
parent
ae356ef145
commit
8b2e03eea6
8
file.c
8
file.c
|
@ -1,7 +1,7 @@
|
||||||
/* file.c
|
/* file.c
|
||||||
* File I/O routines
|
* File I/O routines
|
||||||
*
|
*
|
||||||
* $Id: file.c,v 1.82 1999/08/25 00:03:59 gram Exp $
|
* $Id: file.c,v 1.83 1999/08/26 07:01:42 gram Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -214,6 +214,7 @@ read_cap_file(capture_file *cf) {
|
||||||
timeout = gtk_timeout_add(250, file_progress_cb, (gpointer) cf);
|
timeout = gtk_timeout_add(250, file_progress_cb, (gpointer) cf);
|
||||||
|
|
||||||
freeze_clist(cf);
|
freeze_clist(cf);
|
||||||
|
proto_tree_is_visible = FALSE;
|
||||||
success = wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf, &err);
|
success = wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf, &err);
|
||||||
wtap_close(cf->wth);
|
wtap_close(cf->wth);
|
||||||
cf->wth = NULL;
|
cf->wth = NULL;
|
||||||
|
@ -677,6 +678,8 @@ filter_packets(capture_file *cf)
|
||||||
cf->unfiltered_count = cf->count;
|
cf->unfiltered_count = cf->count;
|
||||||
cf->count = 0;
|
cf->count = 0;
|
||||||
|
|
||||||
|
proto_tree_is_visible = FALSE;
|
||||||
|
|
||||||
/* timeout = gtk_timeout_add(250, dfilter_progress_cb, cf);*/
|
/* timeout = gtk_timeout_add(250, dfilter_progress_cb, cf);*/
|
||||||
for (fd = cf->plist; fd != NULL; fd = fd->next) {
|
for (fd = cf->plist; fd != NULL; fd = fd->next) {
|
||||||
cf->count++;
|
cf->count++;
|
||||||
|
@ -746,6 +749,8 @@ print_packets(capture_file *cf, int to_file, const char *dest)
|
||||||
print_preamble(cf->print_fh);
|
print_preamble(cf->print_fh);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
proto_tree_is_visible = TRUE;
|
||||||
|
|
||||||
/* Iterate through the list of packets, printing each of them. */
|
/* Iterate through the list of packets, printing each of them. */
|
||||||
cf->count = 0;
|
cf->count = 0;
|
||||||
for (fd = cf->plist; fd != NULL; fd = fd->next) {
|
for (fd = cf->plist; fd != NULL; fd = fd->next) {
|
||||||
|
@ -900,6 +905,7 @@ select_packet(capture_file *cf, int row)
|
||||||
if (cf->protocol_tree)
|
if (cf->protocol_tree)
|
||||||
proto_tree_free(cf->protocol_tree);
|
proto_tree_free(cf->protocol_tree);
|
||||||
cf->protocol_tree = proto_tree_create_root();
|
cf->protocol_tree = proto_tree_create_root();
|
||||||
|
proto_tree_is_visible = TRUE;
|
||||||
dissect_packet(cf->pd, cf->fd, cf->protocol_tree);
|
dissect_packet(cf->pd, cf->fd, cf->protocol_tree);
|
||||||
|
|
||||||
/* Display the GUI protocol tree and hex dump. */
|
/* Display the GUI protocol tree and hex dump. */
|
||||||
|
|
14
proto.c
14
proto.c
|
@ -1,7 +1,7 @@
|
||||||
/* proto.c
|
/* proto.c
|
||||||
* Routines for protocol tree
|
* Routines for protocol tree
|
||||||
*
|
*
|
||||||
* $Id: proto.c,v 1.17 1999/08/26 06:20:50 gram Exp $
|
* $Id: proto.c,v 1.18 1999/08/26 07:01:43 gram Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -83,8 +83,6 @@ static gboolean proto_check_id(GNode *node, gpointer data);
|
||||||
|
|
||||||
static int proto_register_field_init(header_field_info *hfinfo, int parent);
|
static int proto_register_field_init(header_field_info *hfinfo, int parent);
|
||||||
|
|
||||||
void dfilter_yacc_init(void);
|
|
||||||
|
|
||||||
/* centralization of registration functions */
|
/* centralization of registration functions */
|
||||||
void proto_register_aarp(void);
|
void proto_register_aarp(void);
|
||||||
void proto_register_arp(void);
|
void proto_register_arp(void);
|
||||||
|
@ -155,6 +153,11 @@ GMemChunk *gmc_item_labels = NULL;
|
||||||
/* List which stores protocols and fields that have been registered */
|
/* List which stores protocols and fields that have been registered */
|
||||||
GPtrArray *gpa_hfinfo = NULL;
|
GPtrArray *gpa_hfinfo = NULL;
|
||||||
|
|
||||||
|
/* Is the parsing being done for a visible proto_tree or an invisible one?
|
||||||
|
* By setting this correctly, the proto_tree creation is sped up by not
|
||||||
|
* having to call vsnprintf and copy strings around.
|
||||||
|
*/
|
||||||
|
gboolean proto_tree_is_visible = TRUE;
|
||||||
|
|
||||||
/* initialize data structures and register protocols and fields */
|
/* initialize data structures and register protocols and fields */
|
||||||
void
|
void
|
||||||
|
@ -353,7 +356,10 @@ proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
|
||||||
|
|
||||||
if (!tree)
|
if (!tree)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
|
/* either visibility flag can nullify the other */
|
||||||
|
visible = proto_tree_is_visible && visible;
|
||||||
|
|
||||||
fi = g_mem_chunk_alloc(gmc_field_info);
|
fi = g_mem_chunk_alloc(gmc_field_info);
|
||||||
|
|
||||||
fi->hfinfo = find_hfinfo_record(hfindex);
|
fi->hfinfo = find_hfinfo_record(hfindex);
|
||||||
|
|
20
proto.h
20
proto.h
|
@ -1,7 +1,7 @@
|
||||||
/* proto.h
|
/* proto.h
|
||||||
* Definitions for protocol display
|
* Definitions for protocol display
|
||||||
*
|
*
|
||||||
* $Id: proto.h,v 1.7 1999/08/26 06:20:50 gram Exp $
|
* $Id: proto.h,v 1.8 1999/08/26 07:01:44 gram Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -157,12 +157,22 @@ proto_tree_add_text(proto_tree *tree, gint start, gint length, ...);
|
||||||
void
|
void
|
||||||
proto_item_fill_label(field_info *fi, gchar *label_str);
|
proto_item_fill_label(field_info *fi, gchar *label_str);
|
||||||
|
|
||||||
/* useful functions for external routines to get info about registered protos and fields */
|
/* Returns number of items (protocols or header fields) registered. */
|
||||||
int proto_registrar_n(void);
|
int proto_registrar_n(void);
|
||||||
|
|
||||||
|
/* Returns char* to abbrev for item # n (0-indexed) */
|
||||||
char* proto_registrar_get_abbrev(int n);
|
char* proto_registrar_get_abbrev(int n);
|
||||||
|
|
||||||
|
/* Returns enum ftenum for item # n */
|
||||||
int proto_registrar_get_ftype(int n);
|
int proto_registrar_get_ftype(int n);
|
||||||
|
|
||||||
|
/* Returns parent protocol for item # n.
|
||||||
|
* Returns -1 if item _is_ a protocol */
|
||||||
int proto_registrar_get_parent(int n);
|
int proto_registrar_get_parent(int n);
|
||||||
|
|
||||||
|
/* Is item #n a protocol? */
|
||||||
gboolean proto_registrar_is_protocol(int n);
|
gboolean proto_registrar_is_protocol(int n);
|
||||||
|
|
||||||
proto_item* proto_find_field(proto_tree* tree, int id);
|
proto_item* proto_find_field(proto_tree* tree, int id);
|
||||||
proto_item* proto_find_protocol(proto_tree* tree, int protocol_id);
|
proto_item* proto_find_protocol(proto_tree* tree, int protocol_id);
|
||||||
void proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func,
|
void proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func,
|
||||||
|
@ -171,4 +181,10 @@ void proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_fu
|
||||||
/* Dumps a glossary of the protocol and field registrations to STDOUT */
|
/* Dumps a glossary of the protocol and field registrations to STDOUT */
|
||||||
void proto_registrar_dump(void);
|
void proto_registrar_dump(void);
|
||||||
|
|
||||||
|
/* Is the parsing being done for a visible proto_tree or an invisible one?
|
||||||
|
* By setting this correctly, the proto_tree creation is sped up by not
|
||||||
|
* having to call vsnprintf and copy strings around.
|
||||||
|
*/
|
||||||
|
extern gboolean proto_tree_is_visible;
|
||||||
|
|
||||||
#endif /* proto.h */
|
#endif /* proto.h */
|
||||||
|
|
Loading…
Reference in New Issue