2 * Routines for MAP Message dissection
3 * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #include "moduleinfo.h"
38 #include <epan/packet.h>
41 #define IUC_REQ_DATA 2
42 #define IUC_INIT_MAINT 3
43 #define IUC_STATION_MAINT 4
44 #define IUC_SHORT_DATA_GRANT 5
45 #define IUC_LONG_DATA_GRANT 6
47 #define IUC_DATA_ACK 8
48 #define IUC_RESERVED9 9
49 #define IUC_RESERVED10 10
50 #define IUC_RESERVED11 11
51 #define IUC_RESERVED12 12
52 #define IUC_RESERVED13 13
53 #define IUC_RESERVED14 14
54 #define IUC_EXPANSION 15
56 /* Initialize the protocol and registered fields */
57 static int proto_docsis_map = -1;
58 static int hf_docsis_map_upstream_chid = -1;
59 static int hf_docsis_map_ucd_count = -1;
60 static int hf_docsis_map_numie = -1;
61 static int hf_docsis_map = -1;
62 static int hf_docsis_map_alloc_start = -1;
63 static int hf_docsis_map_ack_time = -1;
64 static int hf_docsis_map_rng_start = -1;
65 static int hf_docsis_map_rng_end = -1;
66 static int hf_docsis_map_data_start = -1;
67 static int hf_docsis_map_data_end = -1;
68 static int hf_docsis_map_ie = -1;
69 static int hf_docsis_map_rsvd = -1;
71 static int hf_docsis_map_sid = -1;
72 static int hf_docsis_map_iuc = -1;
73 static int hf_docsis_map_offset = -1;
75 /* Initialize the subtree pointers */
76 static gint ett_docsis_map = -1;
78 /* Defined in packet-ucd.c */
79 extern value_string iuc_vals[];
81 /* Code to actually dissect the packets */
83 dissect_map (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
90 guint32 ie, temp, mask;
91 proto_item *it, *item;
93 guint8 upchid, ucd_count;
96 numie = tvb_get_guint8 (tvb, 2);
97 upchid = tvb_get_guint8 (tvb, 0);
98 ucd_count = tvb_get_guint8 (tvb, 1);
100 if (check_col (pinfo->cinfo, COL_INFO))
102 col_clear (pinfo->cinfo, COL_INFO);
104 col_add_fstr (pinfo->cinfo, COL_INFO,
105 "Map Message: Channel ID = %u (U%u), UCD Count = %u, # IE's = %u",
106 upchid, upchid - 1, ucd_count, numie);
108 col_add_fstr (pinfo->cinfo, COL_INFO,
109 "Map Message: Channel ID = %u (Telephony Return), UCD Count = %u, # IE's = %u",
110 upchid, ucd_count, numie);
116 proto_tree_add_protocol_format (tree, proto_docsis_map, tvb, 0, -1,
118 map_tree = proto_item_add_subtree (it, ett_docsis_map);
120 proto_tree_add_item (map_tree, hf_docsis_map_upstream_chid, tvb, 0, 1,
122 proto_tree_add_item (map_tree, hf_docsis_map_ucd_count, tvb, 1, 1,
124 proto_tree_add_item (map_tree, hf_docsis_map_numie, tvb, 2, 1, FALSE);
125 proto_tree_add_item (map_tree, hf_docsis_map_rsvd, tvb, 3, 1, FALSE);
126 proto_tree_add_item (map_tree, hf_docsis_map_alloc_start, tvb, 4, 4,
128 proto_tree_add_item (map_tree, hf_docsis_map_ack_time, tvb, 8, 4,
130 proto_tree_add_item (map_tree, hf_docsis_map_rng_start, tvb, 12, 1,
132 proto_tree_add_item (map_tree, hf_docsis_map_rng_end, tvb, 13, 1,
134 proto_tree_add_item (map_tree, hf_docsis_map_data_start, tvb, 14, 1,
136 proto_tree_add_item (map_tree, hf_docsis_map_data_end, tvb, 15, 1,
140 for (i = 0; i < numie; i++)
142 ie = tvb_get_ntohl (tvb, pos);
146 sid = (guint16) (temp & 0x3FFF);
150 iuc = (guint8) (temp & 0x0F);
152 offset = (guint16) (ie & mask);
153 item = proto_tree_add_item(map_tree, hf_docsis_map_sid, tvb, pos, 4, FALSE);
154 PROTO_ITEM_SET_HIDDEN(item);
155 item = proto_tree_add_item(map_tree, hf_docsis_map_iuc, tvb, pos, 4, FALSE);
156 PROTO_ITEM_SET_HIDDEN(item);
157 item = proto_tree_add_item(map_tree, hf_docsis_map_offset, tvb, pos, 4, FALSE);
158 PROTO_ITEM_SET_HIDDEN(item);
160 proto_tree_add_uint_format (map_tree, hf_docsis_map_ie, tvb, pos, 4,
161 ie, "SID = 0x%x (All CM's), IUC = %s, Offset = %u",
162 sid, val_to_str (iuc, iuc_vals, "%s"),
165 proto_tree_add_uint_format (map_tree, hf_docsis_map_ie, tvb, pos, 4,
166 ie, "SID = %u, IUC = %s, Offset = %u",
167 sid, val_to_str (iuc, iuc_vals, "%s"),
179 /* Register the protocol with Wireshark */
181 /* this format is require because a script is used to build the C function
182 that calls all the protocol registration.
187 proto_register_docsis_map (void)
190 /* Setup list of header fields See Section 1.6.1 for details*/
191 static hf_register_info hf[] = {
193 {"Map Message", "docsis_map",
194 FT_BYTES, BASE_NONE, NULL, 0x0,
195 "MAP Message", HFILL}
197 {&hf_docsis_map_ucd_count,
198 {"UCD Count", "docsis_map.ucdcount",
199 FT_UINT8, BASE_DEC, NULL, 0x0,
200 "Map UCD Count", HFILL}
202 {&hf_docsis_map_upstream_chid,
203 {"Upstream Channel ID", "docsis_map.upchid",
204 FT_UINT8, BASE_DEC, NULL, 0x0,
207 {&hf_docsis_map_numie,
208 {"Number of IE's", "docsis_map.numie",
209 FT_UINT8, BASE_DEC, NULL, 0x0,
210 "Number of Information Elements", HFILL}
212 {&hf_docsis_map_alloc_start,
213 {"Alloc Start Time (minislots)", "docsis_map.allocstart",
214 FT_UINT32, BASE_DEC, NULL, 0x0,
217 {&hf_docsis_map_ack_time,
218 {"ACK Time (minislots)", "docsis_map.acktime",
219 FT_UINT32, BASE_DEC, NULL, 0x0,
220 "Ack Time (minislots)", HFILL}
222 {&hf_docsis_map_rng_start,
223 {"Ranging Backoff Start", "docsis_map.rng_start",
224 FT_UINT8, BASE_DEC, NULL, 0x0,
227 {&hf_docsis_map_rng_end,
228 {"Ranging Backoff End", "docsis_map.rng_end",
229 FT_UINT8, BASE_DEC, NULL, 0x0,
232 {&hf_docsis_map_data_start,
233 {"Data Backoff Start", "docsis_map.data_start",
234 FT_UINT8, BASE_DEC, NULL, 0x0,
237 {&hf_docsis_map_data_end,
238 {"Data Backoff End", "docsis_map.data_end",
239 FT_UINT8, BASE_DEC, NULL, 0x0,
243 {"Information Element", "docsis_map.ie",
244 FT_UINT32, BASE_HEX, NULL, 0x0,
247 {&hf_docsis_map_rsvd,
248 {"Reserved [0x00]", "docsis_map.rsvd",
249 FT_UINT8, BASE_HEX, NULL, 0x0,
250 "Reserved Byte", HFILL}
253 {"Service Identifier", "docsis_map.sid",
254 FT_UINT32, BASE_DEC, NULL, 0xFFFC0000,
258 {"Interval Usage Code", "docsis_map.iuc",
259 FT_UINT32, BASE_DEC, VALS(iuc_vals), 0x0003c000,
262 {&hf_docsis_map_offset,
263 {"Offset", "docsis_map.offset",
264 FT_UINT32, BASE_DEC, NULL, 0x00003fff,
270 /* Setup protocol subtree array */
271 static gint *ett[] = {
275 /* Register the protocol name and description */
277 proto_register_protocol ("DOCSIS Upstream Bandwidth Allocation",
278 "DOCSIS MAP", "docsis_map");
280 /* Required function calls to register the header fields and subtrees used */
281 proto_register_field_array (proto_docsis_map, hf, array_length (hf));
282 proto_register_subtree_array (ett, array_length (ett));
284 register_dissector ("docsis_map", dissect_map, proto_docsis_map);
288 /* If this dissector uses sub-dissector registration add a registration routine.
289 This format is required because a script is used to find these routines and
290 create the code that calls these routines.
293 proto_reg_handoff_docsis_map (void)
295 dissector_handle_t docsis_map_handle;
297 docsis_map_handle = find_dissector ("docsis_map");
298 dissector_add ("docsis_mgmt", 0x03, docsis_map_handle);