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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <epan/exceptions.h>
31 #define DCCREQ_UP_CHAN_ID 1
32 #define DCCREQ_DS_PARAMS 2
33 #define DCCREQ_INIT_TECH 3
34 #define DCCREQ_UCD_SUB 4
35 #define DCCREQ_SAID_SUB 6
36 #define DCCREQ_SF_SUB 7
37 #define DCCREQ_CMTS_MAC_ADDR 8
38 #define DCCREQ_KEY_SEQ_NUM 31
39 #define DCCREQ_HMAC_DIGEST 27
41 /* Define Downstrean Parameters subtypes
42 * These are subtype of DCCREQ_DS_PARAMS (2)
45 #define DCCREQ_DS_FREQ 1
46 #define DCCREQ_DS_MOD_TYPE 2
47 #define DCCREQ_DS_SYM_RATE 3
48 #define DCCREQ_DS_INTLV_DEPTH 4
49 #define DCCREQ_DS_CHAN_ID 5
50 #define DCCREQ_DS_SYNC_SUB 6
52 /* Define Service Flow Substitution subtypes
53 * These are subtypes of DCCREQ_SF_SUB (7)
55 #define DCCREQ_SF_SFID 1
56 #define DCCREQ_SF_SID 2
57 #define DCCREQ_SF_UNSOL_GRANT_TREF 5
59 /* Initialize the protocol and registered fields */
60 static int proto_docsis_dccreq
= -1;
62 static int hf_docsis_dccreq_tran_id
= -1;
63 static int hf_docsis_dccreq_up_chan_id
= -1;
64 static int hf_docsis_dccreq_ds_freq
= -1;
65 static int hf_docsis_dccreq_ds_mod_type
= -1;
66 static int hf_docsis_dccreq_ds_sym_rate
= -1;
67 static int hf_docsis_dccreq_ds_intlv_depth_i
= -1;
68 static int hf_docsis_dccreq_ds_intlv_depth_j
= -1;
69 static int hf_docsis_dccreq_ds_chan_id
= -1;
70 static int hf_docsis_dccreq_ds_sync_sub
= -1;
71 static int hf_docsis_dccreq_init_tech
= -1;
72 static int hf_docsis_dccreq_ucd_sub
= -1;
73 static int hf_docsis_dccreq_said_sub_cur
= -1;
74 static int hf_docsis_dccreq_said_sub_new
= -1;
75 static int hf_docsis_dccreq_sf_sfid_cur
= -1;
76 static int hf_docsis_dccreq_sf_sfid_new
= -1;
77 static int hf_docsis_dccreq_sf_sid_cur
= -1;
78 static int hf_docsis_dccreq_sf_sid_new
= -1;
79 static int hf_docsis_dccreq_sf_unsol_grant_tref
= -1;
80 static int hf_docsis_dccreq_cmts_mac_addr
= -1;
81 static int hf_docsis_dccreq_key_seq_num
= -1;
82 static int hf_docsis_dccreq_hmac_digest
= -1;
84 /* Initialize the subtree pointers */
85 static gint ett_docsis_dccreq
= -1;
86 static gint ett_docsis_dccreq_ds_params
= -1;
87 static gint ett_docsis_dccreq_sf_sub
= -1;
90 value_string ds_mod_type_vals
[] = {
96 value_string ds_sym_rate_vals
[] = {
97 {0 , "5.056941 Msym/sec"},
98 {1 , "5.360537 Msym/sec"},
99 {2 , "6.952 Msym/sec"},
102 value_string init_tech_vals
[] = {
103 {0 , "Reinitialize MAC"},
104 {1 , "Broadcast Init RNG on new chanbefore normal op"},
105 {2 , "Unicast RNG on new chan before normal op"},
106 {3 , "Either Unicast or broadcast RNG on new chan before normal op"},
107 {4 , "Use new chan directly without re-init or RNG"},
110 /* Code to actually dissect the packets */
112 dissect_dccreq_ds_params (tvbuff_t
* tvb
, proto_tree
* tree
, int start
, guint16 len
)
115 proto_item
*dcc_item
;
116 proto_tree
*dcc_tree
;
120 dcc_item
= proto_tree_add_text ( tree
, tvb
, start
, len
, "2 DCC-REQ Downstream Params Encodings (Length = %u)", len
);
121 dcc_tree
= proto_item_add_subtree ( dcc_item
, ett_docsis_dccreq_ds_params
);
123 while ( pos
< ( start
+ len
) )
125 type
= tvb_get_guint8 (tvb
, pos
++);
126 length
= tvb_get_guint8 (tvb
, pos
++);
133 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_freq
, tvb
,
134 pos
, length
, ENC_BIG_ENDIAN
);
138 THROW (ReportedBoundsError
);
141 case DCCREQ_DS_MOD_TYPE
:
144 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_mod_type
, tvb
,
145 pos
, length
, ENC_BIG_ENDIAN
);
149 THROW (ReportedBoundsError
);
152 case DCCREQ_DS_SYM_RATE
:
155 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_sym_rate
, tvb
,
156 pos
, length
, ENC_BIG_ENDIAN
);
160 THROW (ReportedBoundsError
);
163 case DCCREQ_DS_INTLV_DEPTH
:
166 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_intlv_depth_i
, tvb
,
167 pos
, 1, ENC_BIG_ENDIAN
);
168 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_intlv_depth_j
, tvb
,
169 pos
+ 1, 1, ENC_BIG_ENDIAN
);
173 THROW (ReportedBoundsError
);
176 case DCCREQ_DS_CHAN_ID
:
179 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_chan_id
, tvb
,
180 pos
, length
, ENC_BIG_ENDIAN
);
184 THROW (ReportedBoundsError
);
187 case DCCREQ_DS_SYNC_SUB
:
188 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ds_sync_sub
, tvb
,
189 pos
, length
, ENC_BIG_ENDIAN
);
197 dissect_dccreq_sf_sub (tvbuff_t
* tvb
, proto_tree
* tree
, int start
, guint16 len
)
200 proto_item
*dcc_item
;
201 proto_tree
*dcc_tree
;
205 dcc_item
= proto_tree_add_text ( tree
, tvb
, start
, len
, "7 DCC-REQ Service Flow Substitution Encodings (Length = %u)", len
);
206 dcc_tree
= proto_item_add_subtree ( dcc_item
, ett_docsis_dccreq_sf_sub
);
208 while ( pos
< ( start
+ len
) )
210 type
= tvb_get_guint8 (tvb
, pos
++);
211 length
= tvb_get_guint8 (tvb
, pos
++);
218 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_sf_sfid_cur
, tvb
,
219 pos
, 4, ENC_BIG_ENDIAN
);
220 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_sf_sfid_new
, tvb
,
221 pos
+ 4, 4, ENC_BIG_ENDIAN
);
225 THROW (ReportedBoundsError
);
231 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_sf_sid_cur
, tvb
,
232 pos
, 2, ENC_BIG_ENDIAN
);
233 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_sf_sid_new
, tvb
,
234 pos
+ 2, 2, ENC_BIG_ENDIAN
);
238 THROW (ReportedBoundsError
);
241 case DCCREQ_SF_UNSOL_GRANT_TREF
:
244 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_sf_unsol_grant_tref
, tvb
,
245 pos
, length
, ENC_BIG_ENDIAN
);
249 THROW (ReportedBoundsError
);
257 dissect_dccreq (tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
)
261 proto_tree
*dcc_tree
;
262 proto_item
*dcc_item
;
265 len
= tvb_length_remaining (tvb
, 0);
267 col_set_str(pinfo
->cinfo
, COL_INFO
, "DCC-REQ Message: ");
272 proto_tree_add_protocol_format (tree
, proto_docsis_dccreq
, tvb
, 0,
273 tvb_length_remaining (tvb
, 0),
275 dcc_tree
= proto_item_add_subtree (dcc_item
, ett_docsis_dccreq
);
276 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_tran_id
, tvb
, 0, 2, ENC_BIG_ENDIAN
);
281 type
= tvb_get_guint8 (tvb
, pos
++);
282 length
= tvb_get_guint8 (tvb
, pos
++);
286 case DCCREQ_UP_CHAN_ID
:
289 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_up_chan_id
, tvb
,
290 pos
, length
, ENC_BIG_ENDIAN
);
294 THROW (ReportedBoundsError
);
297 case DCCREQ_DS_PARAMS
:
298 dissect_dccreq_ds_params (tvb
, dcc_tree
, pos
, length
);
300 case DCCREQ_INIT_TECH
:
303 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_init_tech
, tvb
,
304 pos
, length
, ENC_BIG_ENDIAN
);
308 THROW (ReportedBoundsError
);
312 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_ucd_sub
, tvb
,
313 pos
, length
, ENC_NA
);
315 case DCCREQ_SAID_SUB
:
318 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_said_sub_cur
, tvb
,
319 pos
, 2, ENC_BIG_ENDIAN
);
320 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_said_sub_new
, tvb
,
321 pos
+ 2, 2, ENC_BIG_ENDIAN
);
325 THROW (ReportedBoundsError
);
329 dissect_dccreq_sf_sub (tvb
, dcc_tree
, pos
, length
);
331 case DCCREQ_CMTS_MAC_ADDR
:
334 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_cmts_mac_addr
, tvb
,
335 pos
, length
, ENC_NA
);
339 THROW (ReportedBoundsError
);
342 case DCCREQ_KEY_SEQ_NUM
:
345 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_key_seq_num
, tvb
,
346 pos
, length
, ENC_BIG_ENDIAN
);
350 THROW (ReportedBoundsError
);
353 case DCCREQ_HMAC_DIGEST
:
356 proto_tree_add_item (dcc_tree
, hf_docsis_dccreq_hmac_digest
, tvb
,
357 pos
, length
, ENC_NA
);
361 THROW (ReportedBoundsError
);
366 } /* while (pos < len) */
370 /* Register the protocol with Wireshark */
372 /* this format is require because a script is used to build the C function
373 that calls all the protocol registration.
378 proto_register_docsis_dccreq (void)
380 /* Setup list of header fields See Section 1.6.1 for details*/
381 static hf_register_info hf
[] = {
382 {&hf_docsis_dccreq_tran_id
,
385 "docsis_dccreq.tran_id",
386 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
391 {&hf_docsis_dccreq_up_chan_id
,
394 "docsis_dccreq.up_chan_id",
395 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
400 {&hf_docsis_dccreq_ds_freq
,
403 "docsis_dccreq.ds_freq",
404 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
409 {&hf_docsis_dccreq_ds_mod_type
,
412 "docsis_dccreq.ds_mod_type",
413 FT_UINT8
, BASE_DEC
, VALS (ds_mod_type_vals
), 0x0,
418 {&hf_docsis_dccreq_ds_sym_rate
,
421 "docsis_dccreq.ds_sym_rate",
422 FT_UINT8
, BASE_DEC
, VALS (ds_sym_rate_vals
), 0x0,
427 {&hf_docsis_dccreq_ds_intlv_depth_i
,
429 "Interleaver Depth I Value",
430 "docsis_dccreq.ds_intlv_depth_i",
431 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
436 {&hf_docsis_dccreq_ds_intlv_depth_j
,
438 "Interleaver Depth J Value",
439 "docsis_dccreq.ds_intlv_depth_j",
440 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
445 {&hf_docsis_dccreq_ds_chan_id
,
447 "Downstream Channel ID",
448 "docsis_dccreq.ds_chan_id",
449 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
454 {&hf_docsis_dccreq_ds_sync_sub
,
457 "docsis_dccreq.ds_sync_sub",
458 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
463 {&hf_docsis_dccreq_init_tech
,
465 "Initialization Technique",
466 "docsis_dccreq.init_tech",
467 FT_UINT8
, BASE_DEC
, VALS (init_tech_vals
), 0x0,
472 {&hf_docsis_dccreq_ucd_sub
,
475 "docsis_dccreq.ucd_sub",
476 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
481 {&hf_docsis_dccreq_said_sub_cur
,
483 "SAID Sub - Current Value",
484 "docsis_dccreq.said_sub_cur",
485 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
490 {&hf_docsis_dccreq_said_sub_new
,
492 "SAID Sub - New Value",
493 "docsis_dccreq.said_sub_new",
494 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
499 {&hf_docsis_dccreq_sf_sfid_cur
,
501 "SF Sub - SFID Current Value",
502 "docsis_dccreq.sf_sfid_cur",
503 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
508 {&hf_docsis_dccreq_sf_sfid_new
,
510 "SF Sub - SFID New Value",
511 "docsis_dccreq.sf_sfid_new",
512 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
517 {&hf_docsis_dccreq_sf_sid_cur
,
519 "SF Sub - SID Current Value",
520 "docsis_dccreq.sf_sid_cur",
521 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
526 {&hf_docsis_dccreq_sf_sid_new
,
528 "SF Sub - SID New Value",
529 "docsis_dccreq.sf_sid_new",
530 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
535 {&hf_docsis_dccreq_sf_unsol_grant_tref
,
537 "SF Sub - Unsolicited Grant Time Reference",
538 "docsis_dccreq.sf_unsol_grant_tref",
539 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
544 {&hf_docsis_dccreq_cmts_mac_addr
,
547 "docsis_dccreq.cmts_mac_addr",
548 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
553 {&hf_docsis_dccreq_key_seq_num
,
555 "Auth Key Sequence Number",
556 "docsis_dccreq.key_seq_num",
557 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
562 {&hf_docsis_dccreq_hmac_digest
,
565 "docsis_dccreq.hmac_digest",
566 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
574 /* Setup protocol subtree array */
575 static gint
*ett
[] = {
577 &ett_docsis_dccreq_sf_sub
,
578 &ett_docsis_dccreq_ds_params
,
581 /* Register the protocol name and description */
582 proto_docsis_dccreq
=
583 proto_register_protocol ("DOCSIS Downstream Channel Change Request",
584 "DOCSIS DCC-REQ", "docsis_dccreq");
586 /* Required function calls to register the header fields and subtrees used */
587 proto_register_field_array (proto_docsis_dccreq
, hf
, array_length (hf
));
588 proto_register_subtree_array (ett
, array_length (ett
));
590 register_dissector ("docsis_dccreq", dissect_dccreq
, proto_docsis_dccreq
);
594 /* If this dissector uses sub-dissector registration add a registration routine.
595 This format is required because a script is used to find these routines and
596 create the code that calls these routines.
599 proto_reg_handoff_docsis_dccreq (void)
601 dissector_handle_t docsis_dccreq_handle
;
603 docsis_dccreq_handle
= find_dissector ("docsis_dccreq");
604 dissector_add_uint ("docsis_mgmt", 0x17, docsis_dccreq_handle
);