diff options
author | Bill Meier <wmeier@newsguy.com> | 2010-11-01 18:38:13 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2010-11-01 18:38:13 +0000 |
commit | 2f8ab638582a8ecbcabb50362cd559a02be0ffba (patch) | |
tree | 43a0cecce979fa59468295f87900179665f792b2 | |
parent | 5227ad988a17c3400caa02a60944428b750a994d (diff) |
Compile (over 100) dfilters only if needed rather than at every Wireshark startup;
Also: Minor whitespace cleanup.
svn path=/trunk/; revision=34747
-rw-r--r-- | epan/dissectors/packet-ncp2222.inc | 28 | ||||
-rwxr-xr-x | tools/ncp2222.py | 41 |
2 files changed, 37 insertions, 32 deletions
diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc index 93a9ffa0ab..e575b9ed77 100644 --- a/epan/dissectors/packet-ncp2222.inc +++ b/epan/dissectors/packet-ncp2222.inc @@ -7512,12 +7512,29 @@ nds_defrag(tvbuff_t *tvb, packet_info *pinfo, guint32 nw_connection, guint8 sequ } } else - { + { dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap); } } } +static gboolean ncp2222_dfilters_compiled = FALSE; + +static void +ncp2222_compile_dfilters(void) +{ + int i; + + for (i = 0; i < NUM_REQ_CONDS; i++) { + if (!dfilter_compile((const gchar*)req_conds[i].dfilter_text, + &req_conds[i].dfilter)) { + g_message("NCP dissector failed to compile dfilter: %s\n", + req_conds[i].dfilter_text); + g_assert_not_reached(); + } + } +} + void dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, guint32 nw_connection, guint8 sequence, @@ -7540,6 +7557,15 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, const char *volatile message; + /* We're dissecting an ncp2222 request; Compile the dfilters (if not yet done). */ + /* XXX: We do this here rather than at "post-registration" (as previouly done) */ + /* so compiling over 100 dfilters is done only if needed (thus avoiding */ + /* compiling the dfilters each time Wireshark is started. */ + if (! ncp2222_dfilters_compiled) { + ncp2222_compile_dfilters(); + ncp2222_dfilters_compiled = TRUE; + } + /* Determine which ncp_record to use. */ switch (type) { case NCP_ALLOCATE_SLOT: diff --git a/tools/ncp2222.py b/tools/ncp2222.py index a377b98523..5162b05936 100755 --- a/tools/ncp2222.py +++ b/tools/ncp2222.py @@ -5756,10 +5756,10 @@ static int ptvc_struct_int_storage; if global_highest_var > -1: print "#define NUM_REPEAT_VARS\t%d" % (global_highest_var + 1) - print "static guint repeat_vars[NUM_REPEAT_VARS];", + print "static guint repeat_vars[NUM_REPEAT_VARS];" else: print "#define NUM_REPEAT_VARS\t0" - print "static guint *repeat_vars = NULL;", + print "static guint *repeat_vars = NULL;" print """ #define NO_VAR NUM_REPEAT_VARS @@ -6271,7 +6271,7 @@ static int hf_iter_search = -1; static int hf_iter_other = -1; static int hf_nds_oid = -1; - """ +""" # Look at all packet types in the packets collection, and cull information # from them. @@ -6296,6 +6296,9 @@ static int hf_nds_oid = -1; groups_used_hash[group] = len(groups_used_list) groups_used_list.append(group) + + + # Determine which variables are used. vars = pkt.Variables() ExamineVars(vars, structs_used_hash, variables_used_hash) @@ -6574,26 +6577,7 @@ static int hf_nds_oid = -1; print "\t0" print "};\n" - # final_registration_ncp2222() - print """ -static void -final_registration_ncp2222(void) -{ - int i; - """ - - # Create dfilter_t's for conditional_record's - print """ - for (i = 0; i < NUM_REQ_CONDS; i++) { - if (!dfilter_compile((const gchar*)req_conds[i].dfilter_text, - &req_conds[i].dfilter)) { - g_message("NCP dissector failed to compile dfilter: %s\\n", - req_conds[i].dfilter_text); - g_assert_not_reached(); - } - } -} - """ + print "" # proto_register_ncp2222() print """ @@ -8276,20 +8260,15 @@ proto_register_ncp2222(void) print "\t};\n" print """ - proto_register_field_array(proto_ncp, hf, array_length(hf)); - """ + proto_register_field_array(proto_ncp, hf, array_length(hf));""" if ett_list: print """ - proto_register_subtree_array(ett, array_length(ett)); - """ + proto_register_subtree_array(ett, array_length(ett));""" print """ register_init_routine(&ncp_init_protocol); - register_postseq_cleanup_routine(&ncp_postseq_cleanup); - register_final_registration_routine(final_registration_ncp2222); - """ - + register_postseq_cleanup_routine(&ncp_postseq_cleanup);""" # End of proto_register_ncp2222() print "}" |