1 /* Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include <epan/packet.h>
31 #define IUC_REQ_DATA 2
32 #define IUC_INIT_MAINT 3
33 #define IUC_STATION_MAINT 4
34 #define IUC_SHORT_DATA_GRANT 5
35 #define IUC_LONG_DATA_GRANT 6
37 #define IUC_DATA_ACK 8
38 #define IUC_RESERVED9 9
39 #define IUC_RESERVED10 10
40 #define IUC_RESERVED11 11
41 #define IUC_RESERVED12 12
42 #define IUC_RESERVED13 13
43 #define IUC_RESERVED14 14
44 #define IUC_EXPANSION 15
46 /* Initialize the protocol and registered fields */
47 static int proto_docsis_map = -1;
48 static int hf_docsis_map_upstream_chid = -1;
49 static int hf_docsis_map_ucd_count = -1;
50 static int hf_docsis_map_numie = -1;
51 static int hf_docsis_map_alloc_start = -1;
52 static int hf_docsis_map_ack_time = -1;
53 static int hf_docsis_map_rng_start = -1;
54 static int hf_docsis_map_rng_end = -1;
55 static int hf_docsis_map_data_start = -1;
56 static int hf_docsis_map_data_end = -1;
57 static int hf_docsis_map_ie = -1;
58 static int hf_docsis_map_rsvd = -1;
60 static int hf_docsis_map_sid = -1;
61 static int hf_docsis_map_iuc = -1;
62 static int hf_docsis_map_offset = -1;
64 /* Initialize the subtree pointers */
65 static gint ett_docsis_map = -1;
67 /* Defined in packet-ucd.c */
68 extern value_string iuc_vals[];
70 /* Code to actually dissect the packets */
72 dissect_map (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
79 guint32 ie, temp, mask;
80 proto_item *it, *item;
82 guint8 upchid, ucd_count;
85 numie = tvb_get_guint8 (tvb, 2);
86 upchid = tvb_get_guint8 (tvb, 0);
87 ucd_count = tvb_get_guint8 (tvb, 1);
89 col_clear (pinfo->cinfo, COL_INFO);
91 col_add_fstr (pinfo->cinfo, COL_INFO,
92 "Map Message: Channel ID = %u (U%u), UCD Count = %u, # IE's = %u",
93 upchid, upchid - 1, ucd_count, numie);
95 col_add_fstr (pinfo->cinfo, COL_INFO,
96 "Map Message: Channel ID = %u (Telephony Return), UCD Count = %u, # IE's = %u",
97 upchid, ucd_count, numie);
102 proto_tree_add_protocol_format (tree, proto_docsis_map, tvb, 0, -1,
104 map_tree = proto_item_add_subtree (it, ett_docsis_map);
106 proto_tree_add_item (map_tree, hf_docsis_map_upstream_chid, tvb, 0, 1,
108 proto_tree_add_item (map_tree, hf_docsis_map_ucd_count, tvb, 1, 1,
110 proto_tree_add_item (map_tree, hf_docsis_map_numie, tvb, 2, 1, FALSE);
111 proto_tree_add_item (map_tree, hf_docsis_map_rsvd, tvb, 3, 1, FALSE);
112 proto_tree_add_item (map_tree, hf_docsis_map_alloc_start, tvb, 4, 4,
114 proto_tree_add_item (map_tree, hf_docsis_map_ack_time, tvb, 8, 4,
116 proto_tree_add_item (map_tree, hf_docsis_map_rng_start, tvb, 12, 1,
118 proto_tree_add_item (map_tree, hf_docsis_map_rng_end, tvb, 13, 1,
120 proto_tree_add_item (map_tree, hf_docsis_map_data_start, tvb, 14, 1,
122 proto_tree_add_item (map_tree, hf_docsis_map_data_end, tvb, 15, 1,
126 for (i = 0; i < numie; i++)
128 ie = tvb_get_ntohl (tvb, pos);
132 sid = (guint16) (temp & 0x3FFF);
136 iuc = (guint8) (temp & 0x0F);
138 offset = (guint16) (ie & mask);
139 item = proto_tree_add_item(map_tree, hf_docsis_map_sid, tvb, pos, 4, FALSE);
140 PROTO_ITEM_SET_HIDDEN(item);
141 item = proto_tree_add_item(map_tree, hf_docsis_map_iuc, tvb, pos, 4, FALSE);
142 PROTO_ITEM_SET_HIDDEN(item);
143 item = proto_tree_add_item(map_tree, hf_docsis_map_offset, tvb, pos, 4, FALSE);
144 PROTO_ITEM_SET_HIDDEN(item);
146 proto_tree_add_uint_format (map_tree, hf_docsis_map_ie, tvb, pos, 4,
147 ie, "SID = 0x%x (All CM's), IUC = %s, Offset = %u",
148 sid, val_to_str (iuc, iuc_vals, "%d"),
151 proto_tree_add_uint_format (map_tree, hf_docsis_map_ie, tvb, pos, 4,
152 ie, "SID = %u, IUC = %s, Offset = %u",
153 sid, val_to_str (iuc, iuc_vals, "%d"),
165 /* Register the protocol with Wireshark */
167 /* this format is require because a script is used to build the C function
168 that calls all the protocol registration.
173 proto_register_docsis_map (void)
176 /* Setup list of header fields See Section 1.6.1 for details*/
177 static hf_register_info hf[] = {
178 {&hf_docsis_map_ucd_count,
179 {"UCD Count", "docsis_map.ucdcount",
180 FT_UINT8, BASE_DEC, NULL, 0x0,
181 "Map UCD Count", HFILL}
183 {&hf_docsis_map_upstream_chid,
184 {"Upstream Channel ID", "docsis_map.upchid",
185 FT_UINT8, BASE_DEC, NULL, 0x0,
188 {&hf_docsis_map_numie,
189 {"Number of IE's", "docsis_map.numie",
190 FT_UINT8, BASE_DEC, NULL, 0x0,
191 "Number of Information Elements", HFILL}
193 {&hf_docsis_map_alloc_start,
194 {"Alloc Start Time (minislots)", "docsis_map.allocstart",
195 FT_UINT32, BASE_DEC, NULL, 0x0,
198 {&hf_docsis_map_ack_time,
199 {"ACK Time (minislots)", "docsis_map.acktime",
200 FT_UINT32, BASE_DEC, NULL, 0x0,
203 {&hf_docsis_map_rng_start,
204 {"Ranging Backoff Start", "docsis_map.rng_start",
205 FT_UINT8, BASE_DEC, NULL, 0x0,
208 {&hf_docsis_map_rng_end,
209 {"Ranging Backoff End", "docsis_map.rng_end",
210 FT_UINT8, BASE_DEC, NULL, 0x0,
213 {&hf_docsis_map_data_start,
214 {"Data Backoff Start", "docsis_map.data_start",
215 FT_UINT8, BASE_DEC, NULL, 0x0,
218 {&hf_docsis_map_data_end,
219 {"Data Backoff End", "docsis_map.data_end",
220 FT_UINT8, BASE_DEC, NULL, 0x0,
224 {"Information Element", "docsis_map.ie",
225 FT_UINT32, BASE_HEX, NULL, 0x0,
228 {&hf_docsis_map_rsvd,
229 {"Reserved [0x00]", "docsis_map.rsvd",
230 FT_UINT8, BASE_HEX, NULL, 0x0,
231 "Reserved Byte", HFILL}
234 {"Service Identifier", "docsis_map.sid",
235 FT_UINT32, BASE_DEC, NULL, 0xFFFC0000,
239 {"Interval Usage Code", "docsis_map.iuc",
240 FT_UINT32, BASE_DEC, VALS(iuc_vals), 0x0003c000,
243 {&hf_docsis_map_offset,
244 {"Offset", "docsis_map.offset",
245 FT_UINT32, BASE_DEC, NULL, 0x00003fff,
251 /* Setup protocol subtree array */
252 static gint *ett[] = {
256 /* Register the protocol name and description */
258 proto_register_protocol ("DOCSIS Upstream Bandwidth Allocation",
259 "DOCSIS MAP", "docsis_map");
261 /* Required function calls to register the header fields and subtrees used */
262 proto_register_field_array (proto_docsis_map, hf, array_length (hf));
263 proto_register_subtree_array (ett, array_length (ett));
265 register_dissector ("docsis_map", dissect_map, proto_docsis_map);
269 /* If this dissector uses sub-dissector registration add a registration routine.
270 This format is required because a script is used to find these routines and
271 create the code that calls these routines.
274 proto_reg_handoff_docsis_map (void)
276 dissector_handle_t docsis_map_handle;
278 docsis_map_handle = find_dissector ("docsis_map");
279 dissector_add_uint ("docsis_mgmt", 0x03, docsis_map_handle);