2 * Routines for DCD 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 DCD_DOWN_CLASSIFIER 23
33 #define DCD_DSG_RULE 50
34 #define DCD_DSG_CONFIG 51
36 /* Define Downstrean Classifier subtypes
37 * These are subtype of DCD_DOWN_CLASSIFIER (23)
41 #define DCD_CFR_RULE_PRI 5
42 #define DCD_CFR_IP_CLASSIFIER 9
44 /* Define IP Classifier sub-subtypes
45 * These are subtypes of DCD_CFR_IP_CLASSIFIER (23.9)
47 #define DCD_CFR_IP_SOURCE_ADDR 3
48 #define DCD_CFR_IP_SOURCE_MASK 4
49 #define DCD_CFR_IP_DEST_ADDR 5
50 #define DCD_CFR_IP_DEST_MASK 6
51 #define DCD_CFR_TCPUDP_SRCPORT_START 7
52 #define DCD_CFR_TCPUDP_SRCPORT_END 8
53 #define DCD_CFR_TCPUDP_DSTPORT_START 9
54 #define DCD_CFR_TCPUDP_DSTPORT_END 10
56 /* Define DSG Rule subtypes
57 * These are subtype of DCD_DSG_RULE (50)
61 #define DCD_RULE_PRI 2
62 #define DCD_RULE_UCID_RNG 3
63 #define DCD_RULE_CLIENT_ID 4
64 #define DCD_RULE_TUNL_ADDR 5
65 #define DCD_RULE_CFR_ID 6
66 #define DCD_RULE_VENDOR_SPEC 43
67 /* Define DSG Rule Client ID sub-subtypes
68 * These are subtypes of DCD_RULE_CLIENT_ID (50.4)
70 #define DCD_CLID_BCAST_ID 1
71 #define DCD_CLID_KNOWN_MAC_ADDR 2
72 #define DCD_CLID_CA_SYS_ID 3
73 #define DCD_CLID_APP_ID 4
75 /* Define DSG Configuration subtypes
76 * These are subtype of DCD_DSG_CONFIG (51)
79 #define DCD_CFG_CHAN_LST 1
80 #define DCD_CFG_TDSG1 2
81 #define DCD_CFG_TDSG2 3
82 #define DCD_CFG_TDSG3 4
83 #define DCD_CFG_TDSG4 5
84 #define DCD_CFG_VENDOR_SPEC 43
86 /* Initialize the protocol and registered fields */
87 static int proto_docsis_dcd = -1;
89 static int hf_docsis_dcd_config_ch_cnt = -1;
90 static int hf_docsis_dcd_num_of_frag = -1;
91 static int hf_docsis_dcd_frag_sequence_num = -1;
92 static int hf_docsis_dcd_cfr_id = -1;
93 static int hf_docsis_dcd_cfr_rule_pri = -1;
94 static int hf_docsis_dcd_cfr_ip_source_addr = -1;
95 static int hf_docsis_dcd_cfr_ip_source_mask = -1;
96 static int hf_docsis_dcd_cfr_ip_dest_addr = -1;
97 static int hf_docsis_dcd_cfr_ip_dest_mask = -1;
98 static int hf_docsis_dcd_cfr_tcpudp_srcport_start = -1;
99 static int hf_docsis_dcd_cfr_tcpudp_srcport_end = -1;
100 static int hf_docsis_dcd_cfr_tcpudp_dstport_start = -1;
101 static int hf_docsis_dcd_cfr_tcpudp_dstport_end = -1;
102 static int hf_docsis_dcd_rule_id = -1;
103 static int hf_docsis_dcd_rule_pri = -1;
104 static int hf_docsis_dcd_rule_ucid_list = -1;
105 static int hf_docsis_dcd_clid_known_mac_addr = -1;
106 static int hf_docsis_dcd_clid_ca_sys_id = -1;
107 static int hf_docsis_dcd_clid_app_id = -1;
108 static int hf_docsis_dcd_rule_tunl_addr = -1;
109 static int hf_docsis_dcd_rule_cfr_id = -1;
110 static int hf_docsis_dcd_rule_vendor_spec = -1;
111 static int hf_docsis_dcd_cfg_chan = -1;
112 static int hf_docsis_dcd_cfg_tdsg1 = -1;
113 static int hf_docsis_dcd_cfg_tdsg2 = -1;
114 static int hf_docsis_dcd_cfg_tdsg3 = -1;
115 static int hf_docsis_dcd_cfg_tdsg4 = -1;
116 static int hf_docsis_dcd_cfg_vendor_spec = -1;
118 /* Initialize the subtree pointers */
119 static gint ett_docsis_dcd = -1;
120 static gint ett_docsis_dcd_cfr = -1;
121 static gint ett_docsis_dcd_cfr_ip = -1;
122 static gint ett_docsis_dcd_rule = -1;
123 static gint ett_docsis_dcd_clid = -1;
124 static gint ett_docsis_dcd_cfg = -1;
126 /* Code to actually dissect the packets */
128 dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
131 proto_item *dcd_item;
132 proto_tree *dcd_tree;
136 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "51 DCD DSG Config Encodings (Length = %u)", len);
137 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_cfg);
139 while ( pos < ( start + len) )
141 type = tvb_get_guint8 (tvb, pos++);
142 length = tvb_get_guint8 (tvb, pos++);
146 case DCD_CFG_CHAN_LST:
149 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_chan, tvb,
154 THROW (ReportedBoundsError);
160 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg1, tvb,
165 THROW (ReportedBoundsError);
171 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg2, tvb,
176 THROW (ReportedBoundsError);
182 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg3, tvb,
187 THROW (ReportedBoundsError);
193 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg4, tvb,
198 THROW (ReportedBoundsError);
201 case DCD_CFG_VENDOR_SPEC:
202 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_vendor_spec, tvb,
211 dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
214 proto_item *dcd_item;
215 proto_tree *dcd_tree;
219 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "23.9 DCD_CFR_IP Encodings (Length = %u)", len);
220 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_cfr_ip);
222 while ( pos < ( start + len) )
224 type = tvb_get_guint8 (tvb, pos++);
225 length = tvb_get_guint8 (tvb, pos++);
229 case DCD_CFR_IP_SOURCE_ADDR:
232 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_addr, tvb,
237 THROW (ReportedBoundsError);
240 case DCD_CFR_IP_SOURCE_MASK:
243 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_mask, tvb,
248 THROW (ReportedBoundsError);
251 case DCD_CFR_IP_DEST_ADDR:
254 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_addr, tvb,
259 THROW (ReportedBoundsError);
262 case DCD_CFR_IP_DEST_MASK:
265 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_mask, tvb,
270 THROW (ReportedBoundsError);
273 case DCD_CFR_TCPUDP_SRCPORT_START:
276 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_start, tvb,
281 THROW (ReportedBoundsError);
284 case DCD_CFR_TCPUDP_SRCPORT_END:
287 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_end, tvb,
292 THROW (ReportedBoundsError);
295 case DCD_CFR_TCPUDP_DSTPORT_START:
298 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_start, tvb,
303 THROW (ReportedBoundsError);
306 case DCD_CFR_TCPUDP_DSTPORT_END:
309 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_end, tvb,
314 THROW (ReportedBoundsError);
322 dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
325 proto_item *dcd_item;
326 proto_tree *dcd_tree;
330 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "50.4 DCD Rule ClientID Encodings (Length = %u)", len);
331 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_clid);
333 while ( pos < ( start + len) )
335 type = tvb_get_guint8 (tvb, pos++);
336 length = tvb_get_guint8 (tvb, pos++);
340 case DCD_CLID_KNOWN_MAC_ADDR:
343 proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_known_mac_addr, tvb,
348 THROW (ReportedBoundsError);
351 case DCD_CLID_CA_SYS_ID:
354 proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_ca_sys_id, tvb,
359 THROW (ReportedBoundsError);
362 case DCD_CLID_APP_ID:
365 proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_app_id, tvb,
370 THROW (ReportedBoundsError);
378 dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
381 proto_item *dcd_item;
382 proto_tree *dcd_tree;
386 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "50 DCD DSG Rule Encodings (Length = %u)", len);
387 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_rule);
389 while ( pos < ( start + len) )
391 type = tvb_get_guint8 (tvb, pos++);
392 length = tvb_get_guint8 (tvb, pos++);
399 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_id, tvb,
404 THROW (ReportedBoundsError);
410 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_pri, tvb,
415 THROW (ReportedBoundsError);
418 case DCD_RULE_UCID_RNG:
419 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_ucid_list, tvb,
422 case DCD_RULE_CLIENT_ID:
423 dissect_dcd_clid (tvb , dcd_tree , pos , length );
425 case DCD_RULE_TUNL_ADDR:
428 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_tunl_addr, tvb,
433 THROW (ReportedBoundsError);
436 case DCD_RULE_CFR_ID:
439 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_cfr_id, tvb,
444 THROW (ReportedBoundsError);
447 case DCD_RULE_VENDOR_SPEC:
448 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_vendor_spec, tvb,
457 dissect_dcd_down_classifier (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
460 proto_item *dcd_item;
461 proto_tree *dcd_tree;
465 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "23 DCD_CFR Encodings (Length = %u)", len);
466 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_cfr);
468 while ( pos < ( start + len) )
470 type = tvb_get_guint8 (tvb, pos++);
471 length = tvb_get_guint8 (tvb, pos++);
478 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_id, tvb,
483 THROW (ReportedBoundsError);
486 case DCD_CFR_RULE_PRI:
489 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_rule_pri, tvb,
494 THROW (ReportedBoundsError);
497 case DCD_CFR_IP_CLASSIFIER:
498 dissect_dcd_down_classifier_ip (tvb , dcd_tree , pos , length );
506 dissect_dcd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
510 proto_tree *dcd_tree;
511 proto_item *dcd_item;
514 len = tvb_length_remaining (tvb, 0);
516 col_set_str(pinfo->cinfo, COL_INFO, "DCD Message: ");
521 proto_tree_add_protocol_format (tree, proto_docsis_dcd, tvb, 0,
522 tvb_length_remaining (tvb, 0),
524 dcd_tree = proto_item_add_subtree (dcd_item, ett_docsis_dcd);
525 proto_tree_add_item (dcd_tree, hf_docsis_dcd_config_ch_cnt, tvb, 0, 1, FALSE);
526 proto_tree_add_item (dcd_tree, hf_docsis_dcd_num_of_frag, tvb, 1, 1, FALSE);
527 proto_tree_add_item (dcd_tree, hf_docsis_dcd_frag_sequence_num, tvb, 2, 1, FALSE);
532 type = tvb_get_guint8 (tvb, pos++);
533 length = tvb_get_guint8 (tvb, pos++);
536 case DCD_DOWN_CLASSIFIER:
537 dissect_dcd_down_classifier (tvb , dcd_tree , pos , length );
540 dissect_dcd_dsg_rule (tvb , dcd_tree , pos , length );
543 dissect_dcd_dsg_cfg (tvb , dcd_tree , pos , length );
547 } /* while (pos < len) */
551 /* Register the protocol with Wireshark */
553 /* this format is require because a script is used to build the C function
554 that calls all the protocol registration.
559 proto_register_docsis_dcd (void)
561 /* Setup list of header fields See Section 1.6.1 for details*/
562 static hf_register_info hf[] = {
563 {&hf_docsis_dcd_config_ch_cnt,
565 "Configuration Change Count",
566 "docsis_dcd.config_ch_cnt",
567 FT_UINT8, BASE_DEC, NULL, 0x0,
572 {&hf_docsis_dcd_num_of_frag,
574 "Number of Fragments",
575 "docsis_dcd.num_of_frag",
576 FT_UINT8, BASE_DEC, NULL, 0x0,
581 {&hf_docsis_dcd_frag_sequence_num,
583 "Fragment Sequence Number",
584 "docsis_dcd.frag_sequence_num",
585 FT_UINT8, BASE_DEC, NULL, 0x0,
590 {&hf_docsis_dcd_cfr_id,
592 "Downstream Classifier Id",
594 FT_UINT16, BASE_DEC, NULL, 0x0,
599 {&hf_docsis_dcd_cfr_rule_pri,
601 "Downstream Classifier Rule Priority",
602 "docsis_dcd.cfr_rule_pri",
603 FT_UINT8, BASE_DEC, NULL, 0x0,
608 {&hf_docsis_dcd_cfr_ip_source_addr,
610 "Downstream Classifier IP Source Address",
611 "docsis_dcd.cfr_ip_source_addr",
612 FT_IPv4, BASE_NONE, NULL, 0x0,
617 {&hf_docsis_dcd_cfr_ip_source_mask,
619 "Downstream Classifier IP Source Mask",
620 "docsis_dcd.cfr_ip_source_mask",
621 FT_IPv4, BASE_NONE, NULL, 0x0,
626 {&hf_docsis_dcd_cfr_ip_dest_addr,
628 "Downstream Classifier IP Destination Address",
629 "docsis_dcd.cfr_ip_dest_addr",
630 FT_IPv4, BASE_NONE, NULL, 0x0,
635 {&hf_docsis_dcd_cfr_ip_dest_mask,
637 "Downstream Classifier IP Destination Mask",
638 "docsis_dcd.cfr_ip_dest_mask",
639 FT_IPv4, BASE_NONE, NULL, 0x0,
640 "Downstream Classifier IP Destination Address",
644 {&hf_docsis_dcd_cfr_tcpudp_srcport_start,
646 "Downstream Classifier IP TCP/UDP Source Port Start",
647 "docsis_dcd.cfr_ip_tcpudp_srcport_start",
648 FT_UINT16, BASE_DEC, NULL, 0x0,
653 {&hf_docsis_dcd_cfr_tcpudp_srcport_end,
655 "Downstream Classifier IP TCP/UDP Source Port End",
656 "docsis_dcd.cfr_ip_tcpudp_srcport_end",
657 FT_UINT16, BASE_DEC, NULL, 0x0,
662 {&hf_docsis_dcd_cfr_tcpudp_dstport_start,
664 "Downstream Classifier IP TCP/UDP Destination Port Start",
665 "docsis_dcd.cfr_ip_tcpudp_dstport_start",
666 FT_UINT16, BASE_DEC, NULL, 0x0,
671 {&hf_docsis_dcd_cfr_tcpudp_dstport_end,
673 "Downstream Classifier IP TCP/UDP Destination Port End",
674 "docsis_dcd.cfr_ip_tcpudp_dstport_end",
675 FT_UINT16, BASE_DEC, NULL, 0x0,
680 {&hf_docsis_dcd_rule_id,
683 "docsis_dcd.rule_id",
684 FT_UINT8, BASE_DEC, NULL, 0x0,
689 {&hf_docsis_dcd_rule_pri,
692 "docsis_dcd.rule_pri",
693 FT_UINT8, BASE_DEC, NULL, 0x0,
698 {&hf_docsis_dcd_rule_ucid_list,
700 "DSG Rule UCID Range",
701 "docsis_dcd.rule_ucid_list",
702 FT_BYTES, BASE_NONE, NULL, 0x0,
707 {&hf_docsis_dcd_clid_known_mac_addr,
709 "DSG Rule Client ID Known MAC Address",
710 "docsis_dcd.clid_known_mac_addr",
711 FT_ETHER, BASE_NONE, NULL, 0x0,
716 {&hf_docsis_dcd_clid_ca_sys_id,
718 "DSG Rule Client ID CA System ID",
719 "docsis_dcd.clid_ca_sys_id",
720 FT_UINT16, BASE_DEC, NULL, 0x0,
725 {&hf_docsis_dcd_clid_app_id,
727 "DSG Rule Client ID Application ID",
728 "docsis_dcd.clid_app_id",
729 FT_UINT16, BASE_DEC, NULL, 0x0,
734 {&hf_docsis_dcd_rule_tunl_addr,
736 "DSG Rule Tunnel MAC Address",
737 "docsis_dcd.rule_tunl_addr",
738 FT_ETHER, BASE_NONE, NULL, 0x0,
743 {&hf_docsis_dcd_rule_cfr_id,
745 "DSG Rule Classifier ID",
746 "docsis_dcd.rule_cfr_id",
747 FT_UINT16, BASE_DEC, NULL, 0x0,
752 {&hf_docsis_dcd_rule_vendor_spec,
754 "DSG Rule Vendor Specific Parameters",
755 "docsis_dcd.rule_vendor_spec",
756 FT_BYTES, BASE_NONE, NULL, 0x0,
761 {&hf_docsis_dcd_cfg_chan,
763 "DSG Configuration Channel",
764 "docsis_dcd.cfg_chan",
765 FT_UINT32, BASE_DEC, NULL, 0x0,
770 {&hf_docsis_dcd_cfg_tdsg1,
772 "DSG Initialization Timeout (Tdsg1)",
773 "docsis_dcd.cfg_tdsg1",
774 FT_UINT16, BASE_DEC, NULL, 0x0,
779 {&hf_docsis_dcd_cfg_tdsg2,
781 "DSG Operational Timeout (Tdsg2)",
782 "docsis_dcd.cfg_tdsg2",
783 FT_UINT16, BASE_DEC, NULL, 0x0,
788 {&hf_docsis_dcd_cfg_tdsg3,
790 "DSG Two-Way Retry Timer (Tdsg3)",
791 "docsis_dcd.cfg_tdsg3",
792 FT_UINT16, BASE_DEC, NULL, 0x0,
797 {&hf_docsis_dcd_cfg_tdsg4,
799 "DSG One-Way Retry Timer (Tdsg4)",
800 "docsis_dcd.cfg_tdsg4",
801 FT_UINT16, BASE_DEC, NULL, 0x0,
806 {&hf_docsis_dcd_cfg_vendor_spec,
808 "DSG Configuration Vendor Specific Parameters",
809 "docsis_dcd.cfg_vendor_spec",
810 FT_BYTES, BASE_NONE, NULL, 0x0,
818 /* Setup protocol subtree array */
819 static gint *ett[] = {
822 &ett_docsis_dcd_cfr_ip,
823 &ett_docsis_dcd_rule,
824 &ett_docsis_dcd_clid,
828 /* Register the protocol name and description */
830 proto_register_protocol ("DOCSIS Downstream Channel Descriptor",
831 "DOCSIS DCD", "docsis_dcd");
833 /* Required function calls to register the header fields and subtrees used */
834 proto_register_field_array (proto_docsis_dcd, hf, array_length (hf));
835 proto_register_subtree_array (ett, array_length (ett));
837 register_dissector ("docsis_dcd", dissect_dcd, proto_docsis_dcd);
841 /* If this dissector uses sub-dissector registration add a registration routine.
842 This format is required because a script is used to find these routines and
843 create the code that calls these routines.
846 proto_reg_handoff_docsis_dcd (void)
848 dissector_handle_t docsis_dcd_handle;
850 docsis_dcd_handle = find_dissector ("docsis_dcd");
851 dissector_add ("docsis_mgmt", 0x20, docsis_dcd_handle);