MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / plugins / wimax / msg_clk_cmp.c
blob731d9ffbfa0208207c59ee928bd8c2b87c1610bc
1 /* msg_clk_cmp.c
2 * WiMax MAC Management CLK_CMP Message decoders
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: Lu Pan <lu.pan@intel.com>
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1999 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 /* Include files */
31 #include "config.h"
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include "wimax_mac.h"
37 static gint proto_mac_mgmt_msg_clk_cmp_decoder = -1;
39 static gint ett_mac_mgmt_msg_clk_cmp_decoder = -1;
41 /* CLK_CMP fields */
42 static gint hf_clk_cmp_clock_count = -1;
43 static gint hf_clk_cmp_clock_id = -1;
44 static gint hf_clk_cmp_seq_number = -1;
45 static gint hf_clk_cmp_comparison_value = -1;
46 /* static gint hf_clk_cmp_invalid_tlv = -1; */
49 /* Decode CLK_CMP messages. */
50 static void dissect_mac_mgmt_msg_clk_cmp_decoder(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
52 guint offset = 0;
53 guint i;
54 guint clock_count;
55 proto_item *clk_cmp_item;
56 proto_tree *clk_cmp_tree;
58 { /* we are being asked for details */
59 /* display MAC payload type CLK_CMP */
60 clk_cmp_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_clk_cmp_decoder, tvb, offset, -1, "Clock Comparison (CLK-CMP)");
61 /* add MAC CLK_CMP subtree */
62 clk_cmp_tree = proto_item_add_subtree(clk_cmp_item, ett_mac_mgmt_msg_clk_cmp_decoder);
63 /* get the clock count */
64 clock_count = tvb_get_guint8(tvb, offset);
65 /* display the clock count */
66 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_clock_count, tvb, offset, 1, ENC_BIG_ENDIAN);
67 /* set the offset for clock comparison */
68 offset++;
69 for (i = 0; i < clock_count; i++ )
70 { /* display the Clock ID */
71 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_clock_id, tvb, offset++, 1, ENC_BIG_ENDIAN);
72 /* display the sequence number */
73 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_seq_number, tvb, offset++, 1, ENC_BIG_ENDIAN);
74 /* display the comparison value */
75 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_comparison_value, tvb, offset++, 1, ENC_BIG_ENDIAN);
80 /* Register Wimax Mac Payload Protocol and Dissector */
81 void proto_register_mac_mgmt_msg_clk_cmp(void)
83 /* CLK_CMP fields display */
84 static hf_register_info hf_clk_cmp[] =
87 &hf_clk_cmp_clock_count,
89 "Clock Count", "wmx.clk_cmp.clock_count",
90 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
94 &hf_clk_cmp_clock_id,
96 "Clock ID", "wmx.clk_cmp.clock_id",
97 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
101 &hf_clk_cmp_comparison_value,
103 "Comparison Value", "wmx.clk_cmp.comparison_value",
104 FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL
107 #if 0
109 &hf_clk_cmp_invalid_tlv,
111 "Invalid TLV", "wmx.clk_cmp.invalid_tlv",
112 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
115 #endif
117 &hf_clk_cmp_seq_number,
119 "Sequence Number", "wmx.clk_cmp.seq_number",
120 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
125 /* Setup protocol subtree array */
126 static gint *ett[] =
128 &ett_mac_mgmt_msg_clk_cmp_decoder,
131 proto_mac_mgmt_msg_clk_cmp_decoder = proto_register_protocol (
132 "WiMax CLK-CMP Message", /* name */
133 "WiMax CLK-CMP (clk)", /* short name */
134 "wmx.clk" /* abbrev */
137 proto_register_field_array(proto_mac_mgmt_msg_clk_cmp_decoder, hf_clk_cmp, array_length(hf_clk_cmp));
138 proto_register_subtree_array(ett, array_length(ett));
141 void
142 proto_reg_handoff_mac_mgmt_msg_clk_cmp(void)
144 dissector_handle_t handle;
146 handle = create_dissector_handle(dissect_mac_mgmt_msg_clk_cmp_decoder, proto_mac_mgmt_msg_clk_cmp_decoder);
147 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_CLK_CMP, handle);