diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-11-27 07:13:32 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-11-27 07:13:32 +0000 |
commit | 07b2709f8a32951cc2503d2e048d662a01cb472c (patch) | |
tree | 21d265bf7402a2739905bd87227383ae0a9f78ab /packet-snmp.c | |
parent | fd456eaf0b5af46449882983b95529e073fd989f (diff) |
Change "conversation_set_dissector()" to take a dissector handle, rather
than a pointer to a dissector function, as an argument.
This means that the conversation dissector is called through
"call_dissector()", so the dissector itself doesn't have to worry about
checking whether the protocol is enabled or setting
"pinfo->current_proto", so get rid of the code that does that in
conversation dissectors. Also, make the conversation dissectors static.
Get rid of some direct calls to dissectors; replace them with calls
through handles, and, again, get rid of code to check whether a protocol
is enabled and set "pinfo->current_proto" where that code isn't needed.
Make those dissectors static if they aren't already static.
Add a routine "create_dissector_handle()" to create a dissector handle
without registering it by name, if the dissector isn't used outside the
module in which it's defined.
svn path=/trunk/; revision=4281
Diffstat (limited to 'packet-snmp.c')
-rw-r--r-- | packet-snmp.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/packet-snmp.c b/packet-snmp.c index 0e4a05553d..63082af4a7 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -8,7 +8,7 @@ * * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u. * - * $Id: packet-snmp.c,v 1.73 2001/11/26 05:13:12 hagbard Exp $ + * $Id: packet-snmp.c,v 1.74 2001/11/27 07:13:26 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -223,6 +223,7 @@ static int hf_snmpv3_flags_auth = -1; static int hf_snmpv3_flags_crypt = -1; static int hf_snmpv3_flags_report = -1; +static dissector_handle_t snmp_handle; static dissector_handle_t data_handle; #define TH_AUTH 0x01 @@ -2101,15 +2102,6 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) conversation_t *conversation; /* - * XXX - this is a conversation dissector, and the code to - * call a conversation dissector doesn't check for disabled - * protocols or set "pinfo->current_proto". - */ - CHECK_DISPLAY_AS_X(data_handle,proto_snmp, tvb, pinfo, tree); - - pinfo->current_proto = "SNMP"; - - /* * The first SNMP packet goes to the SNMP port; the second one * may come from some *other* port, but goes back to the same * IP address and port as the ones from which the first packet @@ -2133,7 +2125,7 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (conversation == NULL) { conversation = conversation_new(&pinfo->src, &pinfo->dst, PT_UDP, pinfo->srcport, 0, NO_PORT2); - conversation_set_dissector(conversation, dissect_snmp); + conversation_set_dissector(conversation, snmp_handle); } } @@ -2298,6 +2290,7 @@ proto_register_snmp(void) "SMUX", "smux"); proto_register_field_array(proto_snmp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + snmp_handle = create_dissector_handle(dissect_snmp, proto_snmp); } void |