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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <epan/packet.h>
29 #define IUC_REQ_DATA 2
30 #define IUC_INIT_MAINT 3
31 #define IUC_STATION_MAINT 4
32 #define IUC_SHORT_DATA_GRANT 5
33 #define IUC_LONG_DATA_GRANT 6
35 #define IUC_DATA_ACK 8
36 #define IUC_RESERVED9 9
37 #define IUC_RESERVED10 10
38 #define IUC_RESERVED11 11
39 #define IUC_RESERVED12 12
40 #define IUC_RESERVED13 13
41 #define IUC_RESERVED14 14
42 #define IUC_EXPANSION 15
44 /* Initialize the protocol and registered fields */
45 static int proto_docsis_map
= -1;
46 static int hf_docsis_map_upstream_chid
= -1;
47 static int hf_docsis_map_ucd_count
= -1;
48 static int hf_docsis_map_numie
= -1;
49 static int hf_docsis_map_alloc_start
= -1;
50 static int hf_docsis_map_ack_time
= -1;
51 static int hf_docsis_map_rng_start
= -1;
52 static int hf_docsis_map_rng_end
= -1;
53 static int hf_docsis_map_data_start
= -1;
54 static int hf_docsis_map_data_end
= -1;
55 static int hf_docsis_map_ie
= -1;
56 static int hf_docsis_map_rsvd
= -1;
58 static int hf_docsis_map_sid
= -1;
59 static int hf_docsis_map_iuc
= -1;
60 static int hf_docsis_map_offset
= -1;
62 /* Initialize the subtree pointers */
63 static gint ett_docsis_map
= -1;
65 /* Defined in packet-ucd.c */
66 extern value_string iuc_vals
[];
68 /* Code to actually dissect the packets */
70 dissect_map (tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
)
77 guint32 ie
, temp
, mask
;
78 proto_item
*it
, *item
;
80 guint8 upchid
, ucd_count
;
83 numie
= tvb_get_guint8 (tvb
, 2);
84 upchid
= tvb_get_guint8 (tvb
, 0);
85 ucd_count
= tvb_get_guint8 (tvb
, 1);
88 col_add_fstr (pinfo
->cinfo
, COL_INFO
,
89 "Map Message: Channel ID = %u (U%u), UCD Count = %u, # IE's = %u",
90 upchid
, upchid
- 1, ucd_count
, numie
);
92 col_add_fstr (pinfo
->cinfo
, COL_INFO
,
93 "Map Message: Channel ID = %u (Telephony Return), UCD Count = %u, # IE's = %u",
94 upchid
, ucd_count
, numie
);
99 proto_tree_add_protocol_format (tree
, proto_docsis_map
, tvb
, 0, -1,
101 map_tree
= proto_item_add_subtree (it
, ett_docsis_map
);
103 proto_tree_add_item (map_tree
, hf_docsis_map_upstream_chid
, tvb
, 0, 1,
105 proto_tree_add_item (map_tree
, hf_docsis_map_ucd_count
, tvb
, 1, 1,
107 proto_tree_add_item (map_tree
, hf_docsis_map_numie
, tvb
, 2, 1, ENC_BIG_ENDIAN
);
108 proto_tree_add_item (map_tree
, hf_docsis_map_rsvd
, tvb
, 3, 1, ENC_BIG_ENDIAN
);
109 proto_tree_add_item (map_tree
, hf_docsis_map_alloc_start
, tvb
, 4, 4,
111 proto_tree_add_item (map_tree
, hf_docsis_map_ack_time
, tvb
, 8, 4,
113 proto_tree_add_item (map_tree
, hf_docsis_map_rng_start
, tvb
, 12, 1,
115 proto_tree_add_item (map_tree
, hf_docsis_map_rng_end
, tvb
, 13, 1,
117 proto_tree_add_item (map_tree
, hf_docsis_map_data_start
, tvb
, 14, 1,
119 proto_tree_add_item (map_tree
, hf_docsis_map_data_end
, tvb
, 15, 1,
123 for (i
= 0; i
< numie
; i
++)
125 ie
= tvb_get_ntohl (tvb
, pos
);
129 sid
= (guint16
) (temp
& 0x3FFF);
133 iuc
= (guint8
) (temp
& 0x0F);
135 offset
= (guint16
) (ie
& mask
);
136 item
= proto_tree_add_item(map_tree
, hf_docsis_map_sid
, tvb
, pos
, 4, ENC_BIG_ENDIAN
);
137 PROTO_ITEM_SET_HIDDEN(item
);
138 item
= proto_tree_add_item(map_tree
, hf_docsis_map_iuc
, tvb
, pos
, 4, ENC_BIG_ENDIAN
);
139 PROTO_ITEM_SET_HIDDEN(item
);
140 item
= proto_tree_add_item(map_tree
, hf_docsis_map_offset
, tvb
, pos
, 4, ENC_BIG_ENDIAN
);
141 PROTO_ITEM_SET_HIDDEN(item
);
143 proto_tree_add_uint_format (map_tree
, hf_docsis_map_ie
, tvb
, pos
, 4,
144 ie
, "SID = 0x%x (All CM's), IUC = %s, Offset = %u",
145 sid
, val_to_str (iuc
, iuc_vals
, "%d"),
148 proto_tree_add_uint_format (map_tree
, hf_docsis_map_ie
, tvb
, pos
, 4,
149 ie
, "SID = %u, IUC = %s, Offset = %u",
150 sid
, val_to_str (iuc
, iuc_vals
, "%d"),
162 /* Register the protocol with Wireshark */
164 /* this format is require because a script is used to build the C function
165 that calls all the protocol registration.
170 proto_register_docsis_map (void)
173 /* Setup list of header fields See Section 1.6.1 for details*/
174 static hf_register_info hf
[] = {
175 {&hf_docsis_map_ucd_count
,
176 {"UCD Count", "docsis_map.ucdcount",
177 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
178 "Map UCD Count", HFILL
}
180 {&hf_docsis_map_upstream_chid
,
181 {"Upstream Channel ID", "docsis_map.upchid",
182 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
185 {&hf_docsis_map_numie
,
186 {"Number of IE's", "docsis_map.numie",
187 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
188 "Number of Information Elements", HFILL
}
190 {&hf_docsis_map_alloc_start
,
191 {"Alloc Start Time (minislots)", "docsis_map.allocstart",
192 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
195 {&hf_docsis_map_ack_time
,
196 {"ACK Time (minislots)", "docsis_map.acktime",
197 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
200 {&hf_docsis_map_rng_start
,
201 {"Ranging Backoff Start", "docsis_map.rng_start",
202 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
205 {&hf_docsis_map_rng_end
,
206 {"Ranging Backoff End", "docsis_map.rng_end",
207 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
210 {&hf_docsis_map_data_start
,
211 {"Data Backoff Start", "docsis_map.data_start",
212 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
215 {&hf_docsis_map_data_end
,
216 {"Data Backoff End", "docsis_map.data_end",
217 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
221 {"Information Element", "docsis_map.ie",
222 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
225 {&hf_docsis_map_rsvd
,
226 {"Reserved [0x00]", "docsis_map.rsvd",
227 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
228 "Reserved Byte", HFILL
}
231 {"Service Identifier", "docsis_map.sid",
232 FT_UINT32
, BASE_DEC
, NULL
, 0xFFFC0000,
236 {"Interval Usage Code", "docsis_map.iuc",
237 FT_UINT32
, BASE_DEC
, VALS(iuc_vals
), 0x0003c000,
240 {&hf_docsis_map_offset
,
241 {"Offset", "docsis_map.offset",
242 FT_UINT32
, BASE_DEC
, NULL
, 0x00003fff,
248 /* Setup protocol subtree array */
249 static gint
*ett
[] = {
253 /* Register the protocol name and description */
255 proto_register_protocol ("DOCSIS Upstream Bandwidth Allocation",
256 "DOCSIS MAP", "docsis_map");
258 /* Required function calls to register the header fields and subtrees used */
259 proto_register_field_array (proto_docsis_map
, hf
, array_length (hf
));
260 proto_register_subtree_array (ett
, array_length (ett
));
262 register_dissector ("docsis_map", dissect_map
, proto_docsis_map
);
266 /* If this dissector uses sub-dissector registration add a registration routine.
267 This format is required because a script is used to find these routines and
268 create the code that calls these routines.
271 proto_reg_handoff_docsis_map (void)
273 dissector_handle_t docsis_map_handle
;
275 docsis_map_handle
= find_dissector ("docsis_map");
276 dissector_add_uint ("docsis_mgmt", 0x03, docsis_map_handle
);