aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-lapd.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2016-06-29 23:18:57 +0200
committerAnders Broman <a.broman58@gmail.com>2016-07-01 14:27:34 +0000
commitad309999fdff362bbc16dc183ade5103c6a83048 (patch)
treed84a4b33e41fad65412286bf977b1dfa1f977475 /epan/dissectors/packet-lapd.c
parenta062c802364fd83d43f934560149f2ddd1fee6a3 (diff)
Cleanup LAPD preferences and registration handoff routine
The preferences and the registration handoff routine used to handle preference changes are setup inconsistent and less efficient. This change cleans it up. Change-Id: I9a1d51d8924c30d9e86d8af394ab1f0f31da4d2d Reviewed-on: https://code.wireshark.org/review/16208 Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-lapd.c')
-rw-r--r--epan/dissectors/packet-lapd.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/epan/dissectors/packet-lapd.c b/epan/dissectors/packet-lapd.c
index 672e3a8f9e..467977cd8b 100644
--- a/epan/dissectors/packet-lapd.c
+++ b/epan/dissectors/packet-lapd.c
@@ -81,12 +81,16 @@ static gint ett_lapd = -1;
static gint ett_lapd_address = -1;
static gint ett_lapd_control = -1;
static gint ett_lapd_checksum = -1;
-static gint pref_lapd_rtp_payload_type = 0;
-static guint pref_lapd_sctp_payload_protocol_identifier = 0;
+
+static guint pref_lapd_rtp_payload_type = 0;
+static guint pref_lapd_sctp_ppi = 0;
static expert_field ei_lapd_abort = EI_INIT;
static expert_field ei_lapd_checksum_bad = EI_INIT;
+static dissector_handle_t lapd_handle;
+static dissector_handle_t lapd_bitstream_handle;
+
static dissector_table_t lapd_sapi_dissector_table;
static dissector_table_t lapd_gsm_sapi_dissector_table;
@@ -728,7 +732,8 @@ proto_register_lapd(void)
expert_lapd = expert_register_protocol(proto_lapd);
expert_register_field_array(expert_lapd, ei, array_length(ei));
- register_dissector("lapd", dissect_lapd, proto_lapd);
+ lapd_handle = register_dissector("lapd", dissect_lapd, proto_lapd);
+ lapd_bitstream_handle = register_dissector("lapd-bitstream", dissect_lapd_bitstream, proto_lapd);
lapd_sapi_dissector_table = register_dissector_table("lapd.sapi",
"LAPD SAPI", proto_lapd, FT_UINT16, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
@@ -748,27 +753,20 @@ proto_register_lapd(void)
"from 96 to 127. Set it to 0 to disable.",
10, &pref_lapd_rtp_payload_type);
prefs_register_uint_preference(lapd_module, "sctp_payload_protocol_identifier",
- "SCTP Payload protocol Identifier for LAPD",
- "SCTP Payload protocol Identifier for LAPD. Its a "
+ "SCTP Payload Protocol Identifier for LAPD",
+ "SCTP Payload Protocol Identifier for LAPD. It is a "
"32 bits value from 0 to 4294967295. Set it to 0 to disable.",
- 10, &pref_lapd_sctp_payload_protocol_identifier);
-
-
+ 10, &pref_lapd_sctp_ppi);
}
void
proto_reg_handoff_lapd(void)
{
static gboolean init = FALSE;
- static dissector_handle_t lapd_bitstream_handle;
- static gint lapd_rtp_payload_type;
- static guint lapd_sctp_payload_protocol_identifier;
-
- dissector_handle_t lapd_handle;
- lapd_handle = find_dissector("lapd");
+ static guint lapd_rtp_payload_type;
+ static guint lapd_sctp_ppi;
if (!init) {
-
dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_LAPD, lapd_handle);
dissector_add_uint("wtap_encap", WTAP_ENCAP_LAPD, lapd_handle);
dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_LAPD, lapd_handle);
@@ -777,27 +775,22 @@ proto_reg_handoff_lapd(void)
dissector_add_for_decode_as("sctp.ppi", lapd_handle);
dissector_add_for_decode_as("sctp.port", lapd_handle);
- register_dissector("lapd-bitstream", dissect_lapd_bitstream, proto_lapd);
- lapd_bitstream_handle = find_dissector("lapd-bitstream");
-
init = TRUE;
} else {
if ((lapd_rtp_payload_type > 95) && (lapd_rtp_payload_type < 128))
dissector_delete_uint("rtp.pt", lapd_rtp_payload_type, lapd_bitstream_handle);
- /* If "previous" value is a valid protocol id, then clean up the dissector preference mapping. */
- if (lapd_sctp_payload_protocol_identifier != 0)
- dissector_delete_uint("sctp.ppi", lapd_sctp_payload_protocol_identifier, lapd_handle);
+ if (lapd_sctp_ppi > 0)
+ dissector_delete_uint("sctp.ppi", lapd_sctp_ppi, lapd_handle);
}
lapd_rtp_payload_type = pref_lapd_rtp_payload_type;
if ((lapd_rtp_payload_type > 95) && (lapd_rtp_payload_type < 128))
dissector_add_uint("rtp.pt", lapd_rtp_payload_type, lapd_bitstream_handle);
- /* Only update the protocol identifier preference if there is a valid identifier (value > 0). */
- lapd_sctp_payload_protocol_identifier = pref_lapd_sctp_payload_protocol_identifier;
- if ( lapd_sctp_payload_protocol_identifier > 0)
- dissector_add_uint("sctp.ppi", lapd_sctp_payload_protocol_identifier, lapd_handle);
+ lapd_sctp_ppi = pref_lapd_sctp_ppi;
+ if (lapd_sctp_ppi > 0)
+ dissector_add_uint("sctp.ppi", lapd_sctp_ppi, lapd_handle);
}
/*