2 * WiMax MAC Management CLK_CMP Message decoders
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: Lu Pan <lu.pan@intel.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/packet.h>
37 #include "wimax_mac.h"
39 static gint proto_mac_mgmt_msg_clk_cmp_decoder = -1;
41 static gint ett_mac_mgmt_msg_clk_cmp_decoder = -1;
44 static gint hf_clk_cmp_message_type = -1;
45 static gint hf_clk_cmp_clock_count = -1;
46 static gint hf_clk_cmp_clock_id = -1;
47 static gint hf_clk_cmp_seq_number = -1;
48 static gint hf_clk_cmp_comparison_value = -1;
49 static gint hf_clk_cmp_invalid_tlv = -1;
52 /* Decode CLK_CMP messages. */
53 void dissect_mac_mgmt_msg_clk_cmp_decoder(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
58 guint tvb_len, payload_type;
59 proto_item *clk_cmp_item = NULL;
60 proto_tree *clk_cmp_tree = NULL;
62 /* Ensure the right payload type */
63 payload_type = tvb_get_guint8(tvb, 0);
64 if(payload_type != MAC_MGMT_MSG_CLK_CMP)
70 { /* we are being asked for details */
71 /* Get the tvb reported length */
72 tvb_len = tvb_reported_length(tvb);
73 /* display MAC payload type CLK_CMP */
74 clk_cmp_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_clk_cmp_decoder, tvb, offset, tvb_len, "Clock Comparison (CLK-CMP) (%u bytes)", tvb_len);
75 /* add MAC CLK_CMP subtree */
76 clk_cmp_tree = proto_item_add_subtree(clk_cmp_item, ett_mac_mgmt_msg_clk_cmp_decoder);
77 /* display the Message Type */
78 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_message_type, tvb, offset, 1, FALSE);
79 /* set the offset for clock count */
81 /* get the clock count */
82 clock_count = tvb_get_guint8(tvb, offset);
83 /* display the clock count */
84 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_clock_count, tvb, offset, 1, FALSE);
85 /* set the offset for clock comparison */
87 for (i = 0; i < clock_count; i++ )
88 { /* display the Clock ID */
89 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_clock_id, tvb, offset++, 1, FALSE);
90 /* display the sequence number */
91 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_seq_number, tvb, offset++, 1, FALSE);
92 /* display the comparison value */
93 proto_tree_add_item(clk_cmp_tree, hf_clk_cmp_comparison_value, tvb, offset++, 1, FALSE);
98 /* Register Wimax Mac Payload Protocol and Dissector */
99 void proto_register_mac_mgmt_msg_clk_cmp(void)
101 /* CLK_CMP fields display */
102 static hf_register_info hf_clk_cmp[] =
105 &hf_clk_cmp_message_type,
107 "MAC Management Message Type", "wmx.macmgtmsgtype.clk_cmp",
108 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
112 &hf_clk_cmp_clock_count,
114 "Clock Count", "wmx.clk_cmp.clock_count",
115 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
119 &hf_clk_cmp_clock_id,
121 "Clock ID", "wmx.clk_cmp.clock_id",
122 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
126 &hf_clk_cmp_comparison_value,
128 "Comparison Value", "wmx.clk_cmp.comparison_value",
129 FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL
133 &hf_clk_cmp_invalid_tlv,
135 "Invalid TLV", "wmx.clk_cmp.invalid_tlv",
136 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
140 &hf_clk_cmp_seq_number,
142 "Sequence Number", "wmx.clk_cmp.seq_number",
143 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
148 /* Setup protocol subtree array */
151 &ett_mac_mgmt_msg_clk_cmp_decoder,
154 proto_mac_mgmt_msg_clk_cmp_decoder = proto_register_protocol (
155 "WiMax CLK-CMP Message", /* name */
156 "WiMax CLK-CMP (clk)", /* short name */
157 "wmx.clk" /* abbrev */
160 proto_register_field_array(proto_mac_mgmt_msg_clk_cmp_decoder, hf_clk_cmp, array_length(hf_clk_cmp));
161 proto_register_subtree_array(ett, array_length(ett));