2 * Routines for DCC Request Message dissection
3 * Copyright 2004, Darryl Hymel <darryl.hymel[AT]arrisi.com>
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 <epan/packet.h>
32 #define DCCREQ_UP_CHAN_ID 1
33 #define DCCREQ_DS_PARAMS 2
34 #define DCCREQ_INIT_TECH 3
35 #define DCCREQ_UCD_SUB 4
36 #define DCCREQ_SAID_SUB 6
37 #define DCCREQ_SF_SUB 7
38 #define DCCREQ_CMTS_MAC_ADDR 8
39 #define DCCREQ_KEY_SEQ_NUM 31
40 #define DCCREQ_HMAC_DIGEST 27
42 /* Define Downstrean Parameters subtypes
43 * These are subtype of DCCREQ_DS_PARAMS (2)
46 #define DCCREQ_DS_FREQ 1
47 #define DCCREQ_DS_MOD_TYPE 2
48 #define DCCREQ_DS_SYM_RATE 3
49 #define DCCREQ_DS_INTLV_DEPTH 4
50 #define DCCREQ_DS_CHAN_ID 5
51 #define DCCREQ_DS_SYNC_SUB 6
53 /* Define Service Flow Substitution subtypes
54 * These are subtypes of DCCREQ_SF_SUB (7)
56 #define DCCREQ_SF_SFID 1
57 #define DCCREQ_SF_SID 2
58 #define DCCREQ_SF_UNSOL_GRANT_TREF 5
60 /* Initialize the protocol and registered fields */
61 static int proto_docsis_dccreq = -1;
63 static int hf_docsis_dccreq_tran_id = -1;
64 static int hf_docsis_dccreq_up_chan_id = -1;
65 static int hf_docsis_dccreq_ds_freq = -1;
66 static int hf_docsis_dccreq_ds_mod_type = -1;
67 static int hf_docsis_dccreq_ds_sym_rate = -1;
68 static int hf_docsis_dccreq_ds_intlv_depth_i = -1;
69 static int hf_docsis_dccreq_ds_intlv_depth_j = -1;
70 static int hf_docsis_dccreq_ds_chan_id = -1;
71 static int hf_docsis_dccreq_ds_sync_sub = -1;
72 static int hf_docsis_dccreq_init_tech = -1;
73 static int hf_docsis_dccreq_ucd_sub = -1;
74 static int hf_docsis_dccreq_said_sub_cur = -1;
75 static int hf_docsis_dccreq_said_sub_new = -1;
76 static int hf_docsis_dccreq_sf_sfid_cur = -1;
77 static int hf_docsis_dccreq_sf_sfid_new = -1;
78 static int hf_docsis_dccreq_sf_sid_cur = -1;
79 static int hf_docsis_dccreq_sf_sid_new = -1;
80 static int hf_docsis_dccreq_sf_unsol_grant_tref = -1;
81 static int hf_docsis_dccreq_cmts_mac_addr = -1;
82 static int hf_docsis_dccreq_key_seq_num = -1;
83 static int hf_docsis_dccreq_hmac_digest = -1;
85 /* Initialize the subtree pointers */
86 static gint ett_docsis_dccreq = -1;
87 static gint ett_docsis_dccreq_ds_params = -1;
88 static gint ett_docsis_dccreq_sf_sub = -1;
91 value_string ds_mod_type_vals[] = {
97 value_string ds_sym_rate_vals[] = {
98 {0 , "5.056941 Msym/sec"},
99 {1 , "5.360537 Msym/sec"},
100 {2 , "6.952 Msym/sec"},
103 value_string init_tech_vals[] = {
104 {0 , "Reinitialize MAC"},
105 {1 , "Broadcast Init RNG on new chanbefore normal op"},
106 {2 , "Unicast RNG on new chan before normal op"},
107 {3 , "Either Unicast or broadcast RNG on new chan before normal op"},
108 {4 , "Use new chan directly without re-init or RNG"},
111 /* Code to actually dissect the packets */
113 dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
116 proto_item *dcc_item;
117 proto_tree *dcc_tree;
121 dcc_item = proto_tree_add_text ( tree, tvb, start, len, "2 DCC-REQ Downstream Params Encodings (Length = %u)", len);
122 dcc_tree = proto_item_add_subtree ( dcc_item , ett_docsis_dccreq_ds_params);
124 while ( pos < ( start + len) )
126 type = tvb_get_guint8 (tvb, pos++);
127 length = tvb_get_guint8 (tvb, pos++);
134 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_freq, tvb,
135 pos, length, ENC_BIG_ENDIAN);
139 THROW (ReportedBoundsError);
142 case DCCREQ_DS_MOD_TYPE:
145 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_mod_type, tvb,
146 pos, length, ENC_BIG_ENDIAN);
150 THROW (ReportedBoundsError);
153 case DCCREQ_DS_SYM_RATE:
156 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_sym_rate, tvb,
157 pos, length, ENC_BIG_ENDIAN);
161 THROW (ReportedBoundsError);
164 case DCCREQ_DS_INTLV_DEPTH:
167 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_intlv_depth_i, tvb,
168 pos, 1, ENC_BIG_ENDIAN);
169 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_intlv_depth_j, tvb,
170 pos + 1, 1, ENC_BIG_ENDIAN);
174 THROW (ReportedBoundsError);
177 case DCCREQ_DS_CHAN_ID:
180 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_chan_id, tvb,
181 pos, length, ENC_BIG_ENDIAN);
185 THROW (ReportedBoundsError);
188 case DCCREQ_DS_SYNC_SUB:
189 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_sync_sub, tvb,
190 pos, length, ENC_BIG_ENDIAN);
198 dissect_dccreq_sf_sub (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
201 proto_item *dcc_item;
202 proto_tree *dcc_tree;
206 dcc_item = proto_tree_add_text ( tree, tvb, start, len, "7 DCC-REQ Service Flow Substitution Encodings (Length = %u)", len);
207 dcc_tree = proto_item_add_subtree ( dcc_item , ett_docsis_dccreq_sf_sub);
209 while ( pos < ( start + len) )
211 type = tvb_get_guint8 (tvb, pos++);
212 length = tvb_get_guint8 (tvb, pos++);
219 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_cur, tvb,
220 pos, 4, ENC_BIG_ENDIAN);
221 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_new, tvb,
222 pos + 4, 4, ENC_BIG_ENDIAN);
226 THROW (ReportedBoundsError);
232 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_cur, tvb,
233 pos, 2, ENC_BIG_ENDIAN);
234 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_new, tvb,
235 pos + 2, 2, ENC_BIG_ENDIAN);
239 THROW (ReportedBoundsError);
242 case DCCREQ_SF_UNSOL_GRANT_TREF:
245 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_unsol_grant_tref, tvb,
246 pos, length, ENC_BIG_ENDIAN);
250 THROW (ReportedBoundsError);
258 dissect_dccreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
262 proto_tree *dcc_tree;
263 proto_item *dcc_item;
266 len = tvb_length_remaining (tvb, 0);
268 col_set_str(pinfo->cinfo, COL_INFO, "DCC-REQ Message: ");
273 proto_tree_add_protocol_format (tree, proto_docsis_dccreq, tvb, 0,
274 tvb_length_remaining (tvb, 0),
276 dcc_tree = proto_item_add_subtree (dcc_item, ett_docsis_dccreq);
277 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_tran_id, tvb, 0, 2, ENC_BIG_ENDIAN);
282 type = tvb_get_guint8 (tvb, pos++);
283 length = tvb_get_guint8 (tvb, pos++);
287 case DCCREQ_UP_CHAN_ID:
290 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_up_chan_id, tvb,
291 pos, length, ENC_BIG_ENDIAN);
295 THROW (ReportedBoundsError);
298 case DCCREQ_DS_PARAMS:
299 dissect_dccreq_ds_params (tvb , dcc_tree , pos , length );
301 case DCCREQ_INIT_TECH:
304 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_init_tech, tvb,
305 pos, length, ENC_BIG_ENDIAN);
309 THROW (ReportedBoundsError);
313 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ucd_sub, tvb,
314 pos, length, ENC_NA);
316 case DCCREQ_SAID_SUB:
319 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_said_sub_cur, tvb,
320 pos, 2, ENC_BIG_ENDIAN);
321 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_said_sub_new, tvb,
322 pos + 2, 2, ENC_BIG_ENDIAN);
326 THROW (ReportedBoundsError);
330 dissect_dccreq_sf_sub (tvb , dcc_tree , pos , length );
332 case DCCREQ_CMTS_MAC_ADDR:
335 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_cmts_mac_addr, tvb,
336 pos, length, ENC_NA);
340 THROW (ReportedBoundsError);
343 case DCCREQ_KEY_SEQ_NUM:
346 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_key_seq_num, tvb,
347 pos, length, ENC_BIG_ENDIAN);
351 THROW (ReportedBoundsError);
354 case DCCREQ_HMAC_DIGEST:
357 proto_tree_add_item (dcc_tree, hf_docsis_dccreq_hmac_digest, tvb,
358 pos, length, ENC_NA);
362 THROW (ReportedBoundsError);
367 } /* while (pos < len) */
371 /* Register the protocol with Wireshark */
373 /* this format is require because a script is used to build the C function
374 that calls all the protocol registration.
379 proto_register_docsis_dccreq (void)
381 /* Setup list of header fields See Section 1.6.1 for details*/
382 static hf_register_info hf[] = {
383 {&hf_docsis_dccreq_tran_id ,
386 "docsis_dccreq.tran_id",
387 FT_UINT16, BASE_DEC, NULL, 0x0,
392 {&hf_docsis_dccreq_up_chan_id ,
395 "docsis_dccreq.up_chan_id",
396 FT_UINT8, BASE_DEC, NULL, 0x0,
401 {&hf_docsis_dccreq_ds_freq ,
404 "docsis_dccreq.ds_freq",
405 FT_UINT32, BASE_DEC, NULL, 0x0,
410 {&hf_docsis_dccreq_ds_mod_type ,
413 "docsis_dccreq.ds_mod_type",
414 FT_UINT8, BASE_DEC, VALS (ds_mod_type_vals), 0x0,
419 {&hf_docsis_dccreq_ds_sym_rate ,
422 "docsis_dccreq.ds_sym_rate",
423 FT_UINT8, BASE_DEC, VALS (ds_sym_rate_vals), 0x0,
428 {&hf_docsis_dccreq_ds_intlv_depth_i ,
430 "Interleaver Depth I Value",
431 "docsis_dccreq.ds_intlv_depth_i",
432 FT_UINT8, BASE_DEC, NULL, 0x0,
437 {&hf_docsis_dccreq_ds_intlv_depth_j ,
439 "Interleaver Depth J Value",
440 "docsis_dccreq.ds_intlv_depth_j",
441 FT_UINT8, BASE_DEC, NULL, 0x0,
446 {&hf_docsis_dccreq_ds_chan_id ,
448 "Downstream Channel ID",
449 "docsis_dccreq.ds_chan_id",
450 FT_UINT8, BASE_DEC, NULL, 0x0,
455 {&hf_docsis_dccreq_ds_sync_sub ,
458 "docsis_dccreq.ds_sync_sub",
459 FT_UINT8, BASE_DEC, NULL, 0x0,
464 {&hf_docsis_dccreq_init_tech ,
466 "Initialization Technique",
467 "docsis_dccreq.init_tech",
468 FT_UINT8, BASE_DEC, VALS (init_tech_vals), 0x0,
473 {&hf_docsis_dccreq_ucd_sub ,
476 "docsis_dccreq.ucd_sub",
477 FT_BYTES, BASE_NONE, NULL, 0x0,
482 {&hf_docsis_dccreq_said_sub_cur ,
484 "SAID Sub - Current Value",
485 "docsis_dccreq.said_sub_cur",
486 FT_UINT16, BASE_DEC, NULL, 0x0,
491 {&hf_docsis_dccreq_said_sub_new ,
493 "SAID Sub - New Value",
494 "docsis_dccreq.said_sub_new",
495 FT_UINT16, BASE_DEC, NULL, 0x0,
500 {&hf_docsis_dccreq_sf_sfid_cur ,
502 "SF Sub - SFID Current Value",
503 "docsis_dccreq.sf_sfid_cur",
504 FT_UINT32, BASE_DEC, NULL, 0x0,
509 {&hf_docsis_dccreq_sf_sfid_new ,
511 "SF Sub - SFID New Value",
512 "docsis_dccreq.sf_sfid_new",
513 FT_UINT32, BASE_DEC, NULL, 0x0,
518 {&hf_docsis_dccreq_sf_sid_cur ,
520 "SF Sub - SID Current Value",
521 "docsis_dccreq.sf_sid_cur",
522 FT_UINT16, BASE_DEC, NULL, 0x0,
527 {&hf_docsis_dccreq_sf_sid_new ,
529 "SF Sub - SID New Value",
530 "docsis_dccreq.sf_sid_new",
531 FT_UINT16, BASE_DEC, NULL, 0x0,
536 {&hf_docsis_dccreq_sf_unsol_grant_tref ,
538 "SF Sub - Unsolicited Grant Time Reference",
539 "docsis_dccreq.sf_unsol_grant_tref",
540 FT_UINT32, BASE_DEC, NULL, 0x0,
545 {&hf_docsis_dccreq_cmts_mac_addr ,
548 "docsis_dccreq.cmts_mac_addr",
549 FT_ETHER, BASE_NONE, NULL, 0x0,
554 {&hf_docsis_dccreq_key_seq_num ,
556 "Auth Key Sequence Number",
557 "docsis_dccreq.key_seq_num",
558 FT_UINT8, BASE_DEC, NULL, 0x0,
563 {&hf_docsis_dccreq_hmac_digest ,
566 "docsis_dccreq.hmac_digest",
567 FT_BYTES, BASE_NONE, NULL, 0x0,
575 /* Setup protocol subtree array */
576 static gint *ett[] = {
578 &ett_docsis_dccreq_sf_sub,
579 &ett_docsis_dccreq_ds_params,
582 /* Register the protocol name and description */
583 proto_docsis_dccreq =
584 proto_register_protocol ("DOCSIS Downstream Channel Change Request",
585 "DOCSIS DCC-REQ", "docsis_dccreq");
587 /* Required function calls to register the header fields and subtrees used */
588 proto_register_field_array (proto_docsis_dccreq, hf, array_length (hf));
589 proto_register_subtree_array (ett, array_length (ett));
591 register_dissector ("docsis_dccreq", dissect_dccreq, proto_docsis_dccreq);
595 /* If this dissector uses sub-dissector registration add a registration routine.
596 This format is required because a script is used to find these routines and
597 create the code that calls these routines.
600 proto_reg_handoff_docsis_dccreq (void)
602 dissector_handle_t docsis_dccreq_handle;
604 docsis_dccreq_handle = find_dissector ("docsis_dccreq");
605 dissector_add_uint ("docsis_mgmt", 0x17, docsis_dccreq_handle);