aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2008-10-05 23:08:54 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2008-10-05 23:08:54 +0000
commitfa63d37768db94d28186516b12abf595bb0fd90c (patch)
tree001fd3d21961befbb4b9302bcfd942edf7b309b4 /epan
parent98c3f1e40f0656dd78fc42e23ef5f17a4591ab92 (diff)
Minor cleanup related to proto_register and/or proto_reg_handoff
ep_alloc + memset --> ep_alloc0 (teamspeak2) git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26356 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-ayiya.c2
-rw-r--r--epan/dissectors/packet-iec104.c125
-rw-r--r--epan/dissectors/packet-kdp.c8
-rw-r--r--epan/dissectors/packet-lanforge.c2
-rw-r--r--epan/dissectors/packet-pop.c2
-rw-r--r--epan/dissectors/packet-teamspeak2.c39
6 files changed, 82 insertions, 96 deletions
diff --git a/epan/dissectors/packet-ayiya.c b/epan/dissectors/packet-ayiya.c
index c57f087c50..964c57b21a 100644
--- a/epan/dissectors/packet-ayiya.c
+++ b/epan/dissectors/packet-ayiya.c
@@ -212,7 +212,7 @@ proto_reg_handoff_ayiya(void)
{
dissector_handle_t ayiya_handle;
- ayiya_handle = create_dissector_handle(dissect_ayiya, proto_ayiya);
+ ayiya_handle = find_dissector("ayiya");
dissector_add("udp.port", UDP_PORT_AYIYA, ayiya_handle);
ip_dissector_table = find_dissector_table("ip.proto");
diff --git a/epan/dissectors/packet-iec104.c b/epan/dissectors/packet-iec104.c
index aeab6b3883..68acd48491 100644
--- a/epan/dissectors/packet-iec104.c
+++ b/epan/dissectors/packet-iec104.c
@@ -86,9 +86,6 @@ struct apciheader {
static guint iec104port = 2404;
-void proto_reg_handoff_iec104(void);
-
-
/* Define the iec104 proto */
static int proto_iec104apci = -1;
static int proto_iec104asdu = -1;
@@ -668,33 +665,33 @@ void
proto_register_iec104apci(void)
{
-static hf_register_info hf_ap[] = {
+ static hf_register_info hf_ap[] = {
- { &hf_apdulen,
- { "ApduLen", "104apci.apdulen", FT_UINT8, BASE_DEC, NULL, 0x0,
- "APDU Len", HFILL }},
+ { &hf_apdulen,
+ { "ApduLen", "104apci.apdulen", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "APDU Len", HFILL }},
- { &hf_apcitype,
- { "ApciType", "104apci.type", FT_UINT8, BASE_HEX, VALS(apci_types), 0x03,
- "APCI type", HFILL }},
+ { &hf_apcitype,
+ { "ApciType", "104apci.type", FT_UINT8, BASE_HEX, VALS(apci_types), 0x03,
+ "APCI type", HFILL }},
- { &hf_apciutype,
- { "ApciUType", "104apci.utype", FT_UINT8, BASE_HEX, VALS(u_types), 0xFC,
- "Apci U type", HFILL }},
+ { &hf_apciutype,
+ { "ApciUType", "104apci.utype", FT_UINT8, BASE_HEX, VALS(u_types), 0xFC,
+ "Apci U type", HFILL }},
- };
+ };
-static gint *ett_ap[] = {
- &ett_apci,
-};
+ static gint *ett_ap[] = {
+ &ett_apci,
+ };
-proto_iec104apci = proto_register_protocol(
- "IEC 60870-5-104,Apci",
- "104apci",
- "104apci"
- );
-proto_register_field_array(proto_iec104apci, hf_ap, array_length(hf_ap));
-proto_register_subtree_array(ett_ap, array_length(ett_ap));
+ proto_iec104apci = proto_register_protocol(
+ "IEC 60870-5-104,Apci",
+ "104apci",
+ "104apci"
+ );
+ proto_register_field_array(proto_iec104apci, hf_ap, array_length(hf_ap));
+ proto_register_subtree_array(ett_ap, array_length(ett_ap));
}
@@ -704,58 +701,58 @@ void
proto_register_iec104asdu(void)
{
-static hf_register_info hf_as[] = {
+ static hf_register_info hf_as[] = {
- { &hf_addr,
- { "Addr", "104asdu.addr", FT_UINT16, BASE_DEC, NULL, 0x0,
- "Common Address of Asdu", HFILL }},
+ { &hf_addr,
+ { "Addr", "104asdu.addr", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Common Address of Asdu", HFILL }},
- { &hf_oa,
- { "OA ", "104asdu.oa", FT_UINT8, BASE_DEC, NULL, 0x0,
- "Originator Address", HFILL }},
+ { &hf_oa,
+ { "OA ", "104asdu.oa", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "Originator Address", HFILL }},
- { &hf_typeid,
- { "TypeId ", "104asdu.typeid", FT_UINT8, BASE_DEC, VALS(asdu_types), 0x0,
- "Asdu Type Id", HFILL }},
+ { &hf_typeid,
+ { "TypeId ", "104asdu.typeid", FT_UINT8, BASE_DEC, VALS(asdu_types), 0x0,
+ "Asdu Type Id", HFILL }},
- { &hf_causetx,
- { "CauseTx", "104asdu.causetx", FT_UINT8, BASE_DEC, VALS(causetx_types), 0x3F,
- "Cause of Transmision", HFILL }},
+ { &hf_causetx,
+ { "CauseTx", "104asdu.causetx", FT_UINT8, BASE_DEC, VALS(causetx_types), 0x3F,
+ "Cause of Transmision", HFILL }},
- { &hf_nega,
- { "Negative", "104asdu.nega", FT_BOOLEAN, 8, NULL, F_NEGA,
- "Negative", HFILL }},
+ { &hf_nega,
+ { "Negative", "104asdu.nega", FT_BOOLEAN, 8, NULL, F_NEGA,
+ "Negative", HFILL }},
- { &hf_test,
- { "Test", "104asdu.test", FT_BOOLEAN, 8, NULL, F_TEST,
- "Test", HFILL }},
+ { &hf_test,
+ { "Test", "104asdu.test", FT_BOOLEAN, 8, NULL, F_TEST,
+ "Test", HFILL }},
- { &hf_ioa,
- { "IOA ", "104asdu.ioa", FT_UINT24, BASE_DEC, NULL, 0x0,
- "Information Object Address", HFILL }},
+ { &hf_ioa,
+ { "IOA ", "104asdu.ioa", FT_UINT24, BASE_DEC, NULL, 0x0,
+ "Information Object Address", HFILL }},
- { &hf_numix,
- { "NumIx", "104asdu.numix", FT_UINT8, BASE_DEC, NULL, 0x7F,
- "Number of Information Objects/Elements", HFILL }},
+ { &hf_numix,
+ { "NumIx", "104asdu.numix", FT_UINT8, BASE_DEC, NULL, 0x7F,
+ "Number of Information Objects/Elements", HFILL }},
- { &hf_sq,
- { "SQ", "104asdu.sq", FT_BOOLEAN, 8, NULL, F_SQ,
- "Sequence", HFILL }},
+ { &hf_sq,
+ { "SQ", "104asdu.sq", FT_BOOLEAN, 8, NULL, F_SQ,
+ "Sequence", HFILL }},
- };
+ };
-static gint *ett_as[] = {
- &ett_asdu,
-};
+ static gint *ett_as[] = {
+ &ett_asdu,
+ };
-proto_iec104asdu = proto_register_protocol(
- "IEC 60870-5-104,Asdu",
- "104asdu",
- "104asdu"
- );
-proto_register_field_array(proto_iec104asdu, hf_as, array_length(hf_as));
-proto_register_subtree_array(ett_as, array_length(ett_as));
+ proto_iec104asdu = proto_register_protocol(
+ "IEC 60870-5-104,Asdu",
+ "104asdu",
+ "104asdu"
+ );
+ proto_register_field_array(proto_iec104asdu, hf_as, array_length(hf_as));
+ proto_register_subtree_array(ett_as, array_length(ett_as));
}
@@ -765,7 +762,7 @@ proto_register_subtree_array(ett_as, array_length(ett_as));
void
proto_reg_handoff_iec104(void)
{
- static dissector_handle_t iec104apci_handle;
+ dissector_handle_t iec104apci_handle;
iec104apci_handle = create_dissector_handle(dissect_iec104reas, proto_iec104apci);
iec104asdu_handle = create_dissector_handle(dissect_iec104asdu, proto_iec104asdu);
diff --git a/epan/dissectors/packet-kdp.c b/epan/dissectors/packet-kdp.c
index 021851b50a..b4494d2bd6 100644
--- a/epan/dissectors/packet-kdp.c
+++ b/epan/dissectors/packet-kdp.c
@@ -343,11 +343,9 @@ void proto_register_kdp(void) {
&ett_kdp, &ett_kdp_flags
};
- if (proto_kdp == -1) {
- proto_kdp = proto_register_protocol("Kontiki Delivery Protocol", /* name */
- "KDP", /* short name */
- "kdp"); /* abbrev */
- }
+ proto_kdp = proto_register_protocol("Kontiki Delivery Protocol", /* name */
+ "KDP", /* short name */
+ "kdp"); /* abbrev */
proto_register_field_array(proto_kdp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
diff --git a/epan/dissectors/packet-lanforge.c b/epan/dissectors/packet-lanforge.c
index 22a7db04c0..4ef5fc572a 100644
--- a/epan/dissectors/packet-lanforge.c
+++ b/epan/dissectors/packet-lanforge.c
@@ -68,7 +68,7 @@ static int hf_lanforge_timestamp = -1;
static gint ett_lanforge = -1;
/* data dissector handle */
-static dissector_handle_t data_handle = NULL;
+static dissector_handle_t data_handle;
/* entry point */
static gboolean dissect_lanforge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
diff --git a/epan/dissectors/packet-pop.c b/epan/dissectors/packet-pop.c
index 06d0a3122f..6bf649d70e 100644
--- a/epan/dissectors/packet-pop.c
+++ b/epan/dissectors/packet-pop.c
@@ -468,7 +468,7 @@ proto_reg_handoff_pop(void)
{
dissector_handle_t pop_handle;
- pop_handle = create_dissector_handle(dissect_pop, proto_pop);
+ pop_handle = find_dissector("pop");
dissector_add("tcp.port", TCP_PORT_POP, pop_handle);
ssl_dissector_add(TCP_PORT_SSL_POP, "pop", TRUE);
data_handle = find_dissector("data");
diff --git a/epan/dissectors/packet-teamspeak2.c b/epan/dissectors/packet-teamspeak2.c
index 936f4d6212..67fe1b8d2e 100644
--- a/epan/dissectors/packet-teamspeak2.c
+++ b/epan/dissectors/packet-teamspeak2.c
@@ -218,10 +218,9 @@ static const value_string codecnames[] =
{ 0, NULL }
};
+#define TS2_PORT 8767
static int proto_ts2 = -1;
-static int global_ts2_port = 8767;
-static dissector_handle_t ts2_handle;
static int hf_ts2_type = -1;
static int hf_ts2_class = -1;
@@ -599,12 +598,11 @@ static void ts2_parse_loginpart2(tvbuff_t *tvb, proto_tree *ts2_tree);
void proto_register_ts2(void)
{
/* Setup protocol subtree array */
- if (proto_ts2 == -1) {
- proto_ts2 = proto_register_protocol (
- "Teamspeak2 Protocol", /* name */
- "TeamSpeak2", /* short name */
- "ts2" /* abbrev */
- );
+ proto_ts2 = proto_register_protocol (
+ "Teamspeak2 Protocol", /* name */
+ "TeamSpeak2", /* short name */
+ "ts2" /* abbrev */
+ );
proto_register_field_array(proto_ts2, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@@ -613,12 +611,11 @@ void proto_register_ts2(void)
if (conv_vals)
g_mem_chunk_destroy(conv_vals);
- /* now create memory chunks */
- conv_vals = g_mem_chunk_new("ts2_conv_vals",
- sizeof(ts2_conversation),
- my_init_count * sizeof(ts2_conversation),
- G_ALLOC_AND_FREE);
- }
+ /* now create memory chunks */
+ conv_vals = g_mem_chunk_new("ts2_conv_vals",
+ sizeof(ts2_conversation),
+ my_init_count * sizeof(ts2_conversation),
+ G_ALLOC_AND_FREE);
}
/*
@@ -626,16 +623,11 @@ void proto_register_ts2(void)
* */
void proto_reg_handoff_ts2(void)
{
- static gboolean initialized = FALSE;
-
- if (!initialized) {
- ts2_handle = create_dissector_handle(dissect_ts2, proto_ts2);
- dissector_add("udp.port", global_ts2_port, ts2_handle);
- }
+ dissector_handle_t ts2_handle;
+ ts2_handle = create_dissector_handle(dissect_ts2, proto_ts2);
+ dissector_add("udp.port", TS2_PORT, ts2_handle);
}
-
-
/*
* Check if a packet is in order and if it is set its fragmentation details into the passed pointers.
* Returns TRUE if the packet is fragmented.
@@ -1152,8 +1144,7 @@ static gboolean ts2_add_checked_crc32(proto_tree *tree, int hf_item, tvbuff_t *t
{
guint8 *zero;
guint32 ocrc32;
- zero = ep_alloc(4);
- memset(zero, 0, 4);
+ zero = ep_alloc0(4);
ocrc32 = crc32_ccitt_tvb(tvb, offset);
ocrc32 = crc32_ccitt_seed(zero, 4, 0xffffffff-ocrc32);
ocrc32 = crc32_ccitt_tvb_offset_seed(tvb, offset+4, tvb_reported_length_remaining(tvb, offset+4), 0xffffffff-ocrc32);