Minor cleanup related to proto_register and/or proto_reg_handoff

ep_alloc + memset --> ep_alloc0 (teamspeak2)

svn path=/trunk/; revision=26356
This commit is contained in:
Bill Meier 2008-10-05 23:08:54 +00:00
parent 94201f9daa
commit a7e61da1b3
6 changed files with 82 additions and 96 deletions

View File

@ -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");

View File

@ -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);

View File

@ -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));
}

View File

@ -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)

View File

@ -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");

View File

@ -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);