diff options
author | Bill Meier <wmeier@newsguy.com> | 2008-11-04 22:01:35 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2008-11-04 22:01:35 +0000 |
commit | 017f36d61bd8f72f3eb06f962245385dc0a5ed38 (patch) | |
tree | 285f9e57641612fd7549f040ef082a42a7c34c26 /asn1/ulp | |
parent | 92a9b695a49890ba962794753669551a2871ac3f (diff) |
Minor cleanup mostly related to proto_reg_handoff
Remove code for unused handles;
Localize handles to proto_reg_handoff as appropriate;
Localize "saved_prefs" to proto_reg_handoff;
In some cases: move "once-only" code in proto_reg_handoff
so that it's executed only the first time thru
proto_reg_handoff;
Properly delete/add port when pref changed (packet_ulp);
svn path=/trunk/; revision=26697
Diffstat (limited to 'asn1/ulp')
-rw-r--r-- | asn1/ulp/packet-ulp-template.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/asn1/ulp/packet-ulp-template.c b/asn1/ulp/packet-ulp-template.c index 6524e3d90c..5e780729df 100644 --- a/asn1/ulp/packet-ulp-template.c +++ b/asn1/ulp/packet-ulp-template.c @@ -48,14 +48,13 @@ #define PSNAME "ULP" #define PFNAME "ulp" -static dissector_handle_t ulp_handle = NULL; -static dissector_handle_t rrlp_handle = NULL; +static dissector_handle_t rrlp_handle; /* IANA Registered Ports * oma-ulp 7275/tcp OMA UserPlane Location * oma-ulp 7275/udp OMA UserPlane Location */ -guint gbl_ulp_port = 7275; +static guint gbl_ulp_port = 7275; /* Initialize the protocol and registered fields */ static int proto_ulp = -1; @@ -128,12 +127,12 @@ void proto_register_ulp(void) { " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &ulp_desegment); - /* Register a configuration option for port */ - prefs_register_uint_preference(ulp_module, "tcp.port", - "ULP TCP Port", - "Set the TCP port for Ulp messages(IANA registerd port is 7275)", - 10, - &gbl_ulp_port); + /* Register a configuration option for port */ + prefs_register_uint_preference(ulp_module, "tcp.port", + "ULP TCP Port", + "Set the TCP port for Ulp messages(IANA registerd port is 7275)", + 10, + &gbl_ulp_port); } @@ -142,15 +141,23 @@ void proto_register_ulp(void) { void proto_reg_handoff_ulp(void) { - - ulp_handle = create_dissector_handle(dissect_ulp_tcp, proto_ulp); - + static gboolean initialized = FALSE; + static dissector_handle_t ulp_handle; + static guint local_ulp_port; + + if (!initialized) { + ulp_handle = find_dissector("ulp"); + dissector_add_string("media_type","application/oma-supl-ulp", ulp_handle); + rrlp_handle = find_dissector("rrlp"); + initialized = TRUE; + } else { + dissector_delete("tcp.port", local_ulp_port, ulp_handle); + } + + local_ulp_port = gbl_ulp_port; dissector_add("tcp.port", gbl_ulp_port, ulp_handle); /* application/oma-supl-ulp */ - dissector_add_string("media_type","application/oma-supl-ulp", ulp_handle); - - rrlp_handle = find_dissector("rrlp"); } |