Fix indent (use 4 spaces) And add modelines info

svn path=/trunk/; revision=51551
This commit is contained in:
Alexis La Goutte 2013-08-27 21:13:00 +00:00
parent f079ce9117
commit af7e3d0835
1 changed files with 72 additions and 59 deletions

View File

@ -1,4 +1,4 @@
/* packet-cmd.c /* packet-cisco-metadata.c
* Routines for dissection of Cisco's MetaData protocol. * Routines for dissection of Cisco's MetaData protocol.
* Copyright 2013 by Vaibhav Katkade (vkatkade[AT]cisco.com) * Copyright 2013 by Vaibhav Katkade (vkatkade[AT]cisco.com)
* *
@ -45,89 +45,102 @@ static gint ett_cmd = -1;
static void static void
dissect_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) dissect_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ {
guint16 encap_proto; guint16 encap_proto;
proto_tree *cmd_tree = NULL; proto_tree *cmd_tree = NULL;
gint offset = 0; gint offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMD"); col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMD");
col_clear(pinfo->cinfo, COL_INFO); col_clear(pinfo->cinfo, COL_INFO);
if (tree) { if (tree) {
proto_item *ti = proto_tree_add_item(tree, proto_cmd, tvb, 0, 6, ENC_NA); proto_item *ti = proto_tree_add_item(tree, proto_cmd, tvb, 0, 6, ENC_NA);
cmd_tree = proto_item_add_subtree(ti, ett_cmd); cmd_tree = proto_item_add_subtree(ti, ett_cmd);
proto_tree_add_item(cmd_tree, hf_cmd_version, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(cmd_tree, hf_cmd_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1; offset += 1;
proto_tree_add_item(cmd_tree, hf_cmd_length, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(cmd_tree, hf_cmd_length, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1; offset += 1;
proto_tree_add_item(cmd_tree, hf_cmd_options, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(cmd_tree, hf_cmd_options, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2; offset += 2;
proto_tree_add_item(cmd_tree, hf_cmd_sgt, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(cmd_tree, hf_cmd_sgt, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2; offset += 2;
} }
encap_proto = tvb_get_ntohs(tvb, 6); encap_proto = tvb_get_ntohs(tvb, 6);
/* This Logic to identify and decode IEEE 802.3 frames is not working correctly. Carry over code from packet-vlan.c /* This Logic to identify and decode IEEE 802.3 frames is not working correctly. Carry over code from packet-vlan.c
* Commenting it out for now will display as Unknown for L2 control frames instead of showing a wrong decode. * Commenting it out for now will display as Unknown for L2 control frames instead of showing a wrong decode.
*/ */
#if 0 #if 0
if (encap_proto <= IEEE_802_3_MAX_LEN) { if (encap_proto <= IEEE_802_3_MAX_LEN) {
gboolean is_802_2 = TRUE; gboolean is_802_2 = TRUE;
/* Don't throw an exception for this check (even a BoundsError) */ /* Don't throw an exception for this check (even a BoundsError) */
if (tvb_length_remaining(tvb, 4) >= 2) { if (tvb_length_remaining(tvb, 4) >= 2) {
if (tvb_get_ntohs(tvb, 4) == 0xffff) if (tvb_get_ntohs(tvb, 4) == 0xffff)
is_802_2 = FALSE; is_802_2 = FALSE;
} }
dissect_802_3(encap_proto, is_802_2, tvb, 4, pinfo, tree, cmd_tree, hf_eth_type, hf_cmd_trailer, 0); dissect_802_3(encap_proto, is_802_2, tvb, 4, pinfo, tree, cmd_tree, hf_eth_type, hf_cmd_trailer, 0);
} else { } else {
#endif #endif
ethertype(encap_proto, tvb, 8, pinfo, tree, cmd_tree, ethertype(encap_proto, tvb, 8, pinfo, tree, cmd_tree,
hf_eth_type, hf_cmd_trailer, 0); hf_eth_type, hf_cmd_trailer, 0);
} }
void void
proto_register_cmd(void) proto_register_cmd(void)
{ {
static hf_register_info hf[] = { static hf_register_info hf[] = {
{ &hf_cmd_version, { &hf_cmd_version,
{ "Version", "cmd.version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } { "Version", "cmd.version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
}, },
{ &hf_cmd_length, { &hf_cmd_length,
{ "Length", "cmd.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } { "Length", "cmd.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
}, },
{ &hf_cmd_options, { &hf_cmd_options,
{ "Options", "cmd.options", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } { "Options", "cmd.options", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
}, },
{ &hf_cmd_sgt, { &hf_cmd_sgt,
{ "SGT", "cmd.sgt", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } { "SGT", "cmd.sgt", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
}, },
{ &hf_eth_type, { &hf_eth_type,
{ "Type", "cmd.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, NULL, HFILL } { "Type", "cmd.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, NULL, HFILL }
}, },
{ &hf_cmd_trailer, { &hf_cmd_trailer,
{ "Trailer", "cmd.trailer", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } { "Trailer", "cmd.trailer", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
}, },
}; };
static gint *ett[] = { static gint *ett[] = {
&ett_cmd &ett_cmd
}; };
proto_cmd = proto_register_protocol("Cisco MetaData", "Cisco MetaData", "cmd"); proto_cmd = proto_register_protocol("Cisco MetaData", "Cisco MetaData", "cmd");
proto_register_field_array(proto_cmd, hf, array_length(hf)); proto_register_field_array(proto_cmd, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett)); proto_register_subtree_array(ett, array_length(ett));
} }
void void
proto_reg_handoff_cmd(void) proto_reg_handoff_cmd(void)
{ {
dissector_handle_t cmd_handle; dissector_handle_t cmd_handle;
cmd_handle = create_dissector_handle(dissect_cmd, proto_cmd); cmd_handle = create_dissector_handle(dissect_cmd, proto_cmd);
dissector_add_uint("ethertype", ETHERTYPE_CMD, cmd_handle); dissector_add_uint("ethertype", ETHERTYPE_CMD, cmd_handle);
} }
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/