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:
Gilbert Ramirez 1999-08-26 07:01:44 +00:00
parent ae356ef145
commit 8b2e03eea6
3 changed files with 35 additions and 7 deletions

8
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* 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
* 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);
freeze_clist(cf);
proto_tree_is_visible = FALSE;
success = wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf, &err);
wtap_close(cf->wth);
cf->wth = NULL;
@ -677,6 +678,8 @@ filter_packets(capture_file *cf)
cf->unfiltered_count = cf->count;
cf->count = 0;
proto_tree_is_visible = FALSE;
/* timeout = gtk_timeout_add(250, dfilter_progress_cb, cf);*/
for (fd = cf->plist; fd != NULL; fd = fd->next) {
cf->count++;
@ -746,6 +749,8 @@ print_packets(capture_file *cf, int to_file, const char *dest)
print_preamble(cf->print_fh);
#endif
proto_tree_is_visible = TRUE;
/* Iterate through the list of packets, printing each of them. */
cf->count = 0;
for (fd = cf->plist; fd != NULL; fd = fd->next) {
@ -900,6 +905,7 @@ select_packet(capture_file *cf, int row)
if (cf->protocol_tree)
proto_tree_free(cf->protocol_tree);
cf->protocol_tree = proto_tree_create_root();
proto_tree_is_visible = TRUE;
dissect_packet(cf->pd, cf->fd, cf->protocol_tree);
/* Display the GUI protocol tree and hex dump. */

14
proto.c
View File

@ -1,7 +1,7 @@
/* proto.c
* 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
* 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);
void dfilter_yacc_init(void);
/* centralization of registration functions */
void proto_register_aarp(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 */
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 */
void
@ -353,7 +356,10 @@ proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
if (!tree)
return(NULL);
/* either visibility flag can nullify the other */
visible = proto_tree_is_visible && visible;
fi = g_mem_chunk_alloc(gmc_field_info);
fi->hfinfo = find_hfinfo_record(hfindex);

20
proto.h
View File

@ -1,7 +1,7 @@
/* proto.h
* 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
* By Gerald Combs <gerald@zing.org>
@ -157,12 +157,22 @@ proto_tree_add_text(proto_tree *tree, gint start, gint length, ...);
void
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);
/* Returns char* to abbrev for item # n (0-indexed) */
char* proto_registrar_get_abbrev(int n);
/* Returns enum ftenum for item # 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);
/* Is item #n a protocol? */
gboolean proto_registrar_is_protocol(int n);
proto_item* proto_find_field(proto_tree* tree, int id);
proto_item* proto_find_protocol(proto_tree* tree, int protocol_id);
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 */
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 */