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.
31 #include "moduleinfo.h"
39 #include <epan/packet.h>
41 #define DCD_DOWN_CLASSIFIER 23
42 #define DCD_DSG_RULE 50
43 #define DCD_DSG_CONFIG 51
45 /* Define Downstrean Classifier subtypes
46 * These are subtype of DCD_DOWN_CLASSIFIER (23)
50 #define DCD_CFR_RULE_PRI 5
51 #define DCD_CFR_IP_CLASSIFIER 9
53 /* Define IP Classifier sub-subtypes
54 * These are subtypes of DCD_CFR_IP_CLASSIFIER (23.9)
56 #define DCD_CFR_IP_SOURCE_ADDR 3
57 #define DCD_CFR_IP_SOURCE_MASK 4
58 #define DCD_CFR_IP_DEST_ADDR 5
59 #define DCD_CFR_IP_DEST_MASK 6
60 #define DCD_CFR_TCPUDP_SRCPORT_START 7
61 #define DCD_CFR_TCPUDP_SRCPORT_END 8
62 #define DCD_CFR_TCPUDP_DSTPORT_START 9
63 #define DCD_CFR_TCPUDP_DSTPORT_END 10
65 /* Define DSG Rule subtypes
66 * These are subtype of DCD_DSG_RULE (50)
70 #define DCD_RULE_PRI 2
71 #define DCD_RULE_UCID_RNG 3
72 #define DCD_RULE_CLIENT_ID 4
73 #define DCD_RULE_TUNL_ADDR 5
74 #define DCD_RULE_CFR_ID 6
75 #define DCD_RULE_VENDOR_SPEC 43
76 /* Define DSG Rule Client ID sub-subtypes
77 * These are subtypes of DCD_RULE_CLIENT_ID (50.4)
79 #define DCD_CLID_BCAST_ID 1
80 #define DCD_CLID_KNOWN_MAC_ADDR 2
81 #define DCD_CLID_CA_SYS_ID 3
82 #define DCD_CLID_APP_ID 4
84 /* Define DSG Configuration subtypes
85 * These are subtype of DCD_DSG_CONFIG (51)
88 #define DCD_CFG_CHAN_LST 1
89 #define DCD_CFG_TDSG1 2
90 #define DCD_CFG_TDSG2 3
91 #define DCD_CFG_TDSG3 4
92 #define DCD_CFG_TDSG4 5
93 #define DCD_CFG_VENDOR_SPEC 43
95 /* Initialize the protocol and registered fields */
96 static int proto_docsis_dcd = -1;
98 static int hf_docsis_dcd_config_ch_cnt = -1;
99 static int hf_docsis_dcd_num_of_frag = -1;
100 static int hf_docsis_dcd_frag_sequence_num = -1;
101 static int hf_docsis_dcd_cfr_id = -1;
102 static int hf_docsis_dcd_cfr_rule_pri = -1;
103 static int hf_docsis_dcd_cfr_ip_source_addr = -1;
104 static int hf_docsis_dcd_cfr_ip_source_mask = -1;
105 static int hf_docsis_dcd_cfr_ip_dest_addr = -1;
106 static int hf_docsis_dcd_cfr_ip_dest_mask = -1;
107 static int hf_docsis_dcd_cfr_tcpudp_srcport_start = -1;
108 static int hf_docsis_dcd_cfr_tcpudp_srcport_end = -1;
109 static int hf_docsis_dcd_cfr_tcpudp_dstport_start = -1;
110 static int hf_docsis_dcd_cfr_tcpudp_dstport_end = -1;
111 static int hf_docsis_dcd_rule_id = -1;
112 static int hf_docsis_dcd_rule_pri = -1;
113 static int hf_docsis_dcd_rule_ucid_list = -1;
114 static int hf_docsis_dcd_clid_known_mac_addr = -1;
115 static int hf_docsis_dcd_clid_ca_sys_id = -1;
116 static int hf_docsis_dcd_clid_app_id = -1;
117 static int hf_docsis_dcd_rule_tunl_addr = -1;
118 static int hf_docsis_dcd_rule_cfr_id = -1;
119 static int hf_docsis_dcd_rule_vendor_spec = -1;
120 static int hf_docsis_dcd_cfg_chan = -1;
121 static int hf_docsis_dcd_cfg_tdsg1 = -1;
122 static int hf_docsis_dcd_cfg_tdsg2 = -1;
123 static int hf_docsis_dcd_cfg_tdsg3 = -1;
124 static int hf_docsis_dcd_cfg_tdsg4 = -1;
125 static int hf_docsis_dcd_cfg_vendor_spec = -1;
127 /* Initialize the subtree pointers */
128 static gint ett_docsis_dcd = -1;
129 static gint ett_docsis_dcd_cfr = -1;
130 static gint ett_docsis_dcd_cfr_ip = -1;
131 static gint ett_docsis_dcd_rule = -1;
132 static gint ett_docsis_dcd_clid = -1;
133 static gint ett_docsis_dcd_cfg = -1;
135 /* Code to actually dissect the packets */
137 dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
140 proto_item *dcd_item;
141 proto_tree *dcd_tree;
145 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "51 DCD DSG Config Encodings (Length = %u)", len);
146 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_cfg);
148 while ( pos < ( start + len) )
150 type = tvb_get_guint8 (tvb, pos++);
151 length = tvb_get_guint8 (tvb, pos++);
155 case DCD_CFG_CHAN_LST:
158 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_chan, tvb,
163 THROW (ReportedBoundsError);
169 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg1, tvb,
174 THROW (ReportedBoundsError);
180 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg2, tvb,
185 THROW (ReportedBoundsError);
191 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg3, tvb,
196 THROW (ReportedBoundsError);
202 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg4, tvb,
207 THROW (ReportedBoundsError);
210 case DCD_CFG_VENDOR_SPEC:
211 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_vendor_spec, tvb,
220 dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
223 proto_item *dcd_item;
224 proto_tree *dcd_tree;
228 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "23.9 DCD_CFR_IP Encodings (Length = %u)", len);
229 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_cfr_ip);
231 while ( pos < ( start + len) )
233 type = tvb_get_guint8 (tvb, pos++);
234 length = tvb_get_guint8 (tvb, pos++);
238 case DCD_CFR_IP_SOURCE_ADDR:
241 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_addr, tvb,
246 THROW (ReportedBoundsError);
249 case DCD_CFR_IP_SOURCE_MASK:
252 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_mask, tvb,
257 THROW (ReportedBoundsError);
260 case DCD_CFR_IP_DEST_ADDR:
263 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_addr, tvb,
268 THROW (ReportedBoundsError);
271 case DCD_CFR_IP_DEST_MASK:
274 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_mask, tvb,
279 THROW (ReportedBoundsError);
282 case DCD_CFR_TCPUDP_SRCPORT_START:
285 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_start, tvb,
290 THROW (ReportedBoundsError);
293 case DCD_CFR_TCPUDP_SRCPORT_END:
296 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_end, tvb,
301 THROW (ReportedBoundsError);
304 case DCD_CFR_TCPUDP_DSTPORT_START:
307 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_start, tvb,
312 THROW (ReportedBoundsError);
315 case DCD_CFR_TCPUDP_DSTPORT_END:
318 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_end, tvb,
323 THROW (ReportedBoundsError);
331 dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
334 proto_item *dcd_item;
335 proto_tree *dcd_tree;
339 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "50.4 DCD Rule ClientID Encodings (Length = %u)", len);
340 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_clid);
342 while ( pos < ( start + len) )
344 type = tvb_get_guint8 (tvb, pos++);
345 length = tvb_get_guint8 (tvb, pos++);
349 case DCD_CLID_KNOWN_MAC_ADDR:
352 proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_known_mac_addr, tvb,
357 THROW (ReportedBoundsError);
360 case DCD_CLID_CA_SYS_ID:
363 proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_ca_sys_id, tvb,
368 THROW (ReportedBoundsError);
371 case DCD_CLID_APP_ID:
374 proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_app_id, tvb,
379 THROW (ReportedBoundsError);
387 dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
390 proto_item *dcd_item;
391 proto_tree *dcd_tree;
395 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "50 DCD DSG Rule Encodings (Length = %u)", len);
396 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_rule);
398 while ( pos < ( start + len) )
400 type = tvb_get_guint8 (tvb, pos++);
401 length = tvb_get_guint8 (tvb, pos++);
408 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_id, tvb,
413 THROW (ReportedBoundsError);
419 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_pri, tvb,
424 THROW (ReportedBoundsError);
427 case DCD_RULE_UCID_RNG:
428 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_ucid_list, tvb,
431 case DCD_RULE_CLIENT_ID:
432 dissect_dcd_clid (tvb , dcd_tree , pos , length );
434 case DCD_RULE_TUNL_ADDR:
437 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_tunl_addr, tvb,
442 THROW (ReportedBoundsError);
445 case DCD_RULE_CFR_ID:
448 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_cfr_id, tvb,
453 THROW (ReportedBoundsError);
456 case DCD_RULE_VENDOR_SPEC:
457 proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_vendor_spec, tvb,
466 dissect_dcd_down_classifier (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
469 proto_item *dcd_item;
470 proto_tree *dcd_tree;
474 dcd_item = proto_tree_add_text ( tree, tvb, start, len, "23 DCD_CFR Encodings (Length = %u)", len);
475 dcd_tree = proto_item_add_subtree ( dcd_item , ett_docsis_dcd_cfr);
477 while ( pos < ( start + len) )
479 type = tvb_get_guint8 (tvb, pos++);
480 length = tvb_get_guint8 (tvb, pos++);
487 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_id, tvb,
492 THROW (ReportedBoundsError);
495 case DCD_CFR_RULE_PRI:
498 proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_rule_pri, tvb,
503 THROW (ReportedBoundsError);
506 case DCD_CFR_IP_CLASSIFIER:
507 dissect_dcd_down_classifier_ip (tvb , dcd_tree , pos , length );
515 dissect_dcd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
519 proto_tree *dcd_tree;
520 proto_item *dcd_item;
523 len = tvb_length_remaining (tvb, 0);
525 if (check_col (pinfo->cinfo, COL_INFO))
527 col_clear (pinfo->cinfo, COL_INFO);
528 col_add_fstr (pinfo->cinfo, COL_INFO,"DCD Message: ");
534 proto_tree_add_protocol_format (tree, proto_docsis_dcd, tvb, 0,
535 tvb_length_remaining (tvb, 0),
537 dcd_tree = proto_item_add_subtree (dcd_item, ett_docsis_dcd);
538 proto_tree_add_item (dcd_tree, hf_docsis_dcd_config_ch_cnt, tvb, 0, 1, FALSE);
539 proto_tree_add_item (dcd_tree, hf_docsis_dcd_num_of_frag, tvb, 1, 1, FALSE);
540 proto_tree_add_item (dcd_tree, hf_docsis_dcd_frag_sequence_num, tvb, 2, 1, FALSE);
545 type = tvb_get_guint8 (tvb, pos++);
546 length = tvb_get_guint8 (tvb, pos++);
549 case DCD_DOWN_CLASSIFIER:
550 dissect_dcd_down_classifier (tvb , dcd_tree , pos , length );
553 dissect_dcd_dsg_rule (tvb , dcd_tree , pos , length );
556 dissect_dcd_dsg_cfg (tvb , dcd_tree , pos , length );
560 } /* while (pos < len) */
564 /* Register the protocol with Wireshark */
566 /* this format is require because a script is used to build the C function
567 that calls all the protocol registration.
572 proto_register_docsis_dcd (void)
574 /* Setup list of header fields See Section 1.6.1 for details*/
575 static hf_register_info hf[] = {
576 {&hf_docsis_dcd_config_ch_cnt,
578 "Configuration Change Count",
579 "docsis_dcd.config_ch_cnt",
580 FT_UINT8, BASE_DEC, NULL, 0x0,
585 {&hf_docsis_dcd_num_of_frag,
587 "Number of Fragments",
588 "docsis_dcd.num_of_frag",
589 FT_UINT8, BASE_DEC, NULL, 0x0,
594 {&hf_docsis_dcd_frag_sequence_num,
596 "Fragment Sequence Number",
597 "docsis_dcd.frag_sequence_num",
598 FT_UINT8, BASE_DEC, NULL, 0x0,
603 {&hf_docsis_dcd_cfr_id,
605 "Downstream Classifier Id",
607 FT_UINT16, BASE_DEC, NULL, 0x0,
612 {&hf_docsis_dcd_cfr_rule_pri,
614 "Downstream Classifier Rule Priority",
615 "docsis_dcd.cfr_rule_pri",
616 FT_UINT8, BASE_DEC, NULL, 0x0,
621 {&hf_docsis_dcd_cfr_ip_source_addr,
623 "Downstream Classifier IP Source Address",
624 "docsis_dcd.cfr_ip_source_addr",
625 FT_IPv4, BASE_NONE, NULL, 0x0,
630 {&hf_docsis_dcd_cfr_ip_source_mask,
632 "Downstream Classifier IP Source Mask",
633 "docsis_dcd.cfr_ip_source_mask",
634 FT_IPv4, BASE_NONE, NULL, 0x0,
639 {&hf_docsis_dcd_cfr_ip_dest_addr,
641 "Downstream Classifier IP Destination Address",
642 "docsis_dcd.cfr_ip_dest_addr",
643 FT_IPv4, BASE_NONE, NULL, 0x0,
648 {&hf_docsis_dcd_cfr_ip_dest_mask,
650 "Downstream Classifier IP Destination Mask",
651 "docsis_dcd.cfr_ip_dest_mask",
652 FT_IPv4, BASE_NONE, NULL, 0x0,
653 "Downstream Classifier IP Destination Address",
657 {&hf_docsis_dcd_cfr_tcpudp_srcport_start,
659 "Downstream Classifier IP TCP/UDP Source Port Start",
660 "docsis_dcd.cfr_ip_tcpudp_srcport_start",
661 FT_UINT16, BASE_DEC, NULL, 0x0,
666 {&hf_docsis_dcd_cfr_tcpudp_srcport_end,
668 "Downstream Classifier IP TCP/UDP Source Port End",
669 "docsis_dcd.cfr_ip_tcpudp_srcport_end",
670 FT_UINT16, BASE_DEC, NULL, 0x0,
675 {&hf_docsis_dcd_cfr_tcpudp_dstport_start,
677 "Downstream Classifier IP TCP/UDP Destination Port Start",
678 "docsis_dcd.cfr_ip_tcpudp_dstport_start",
679 FT_UINT16, BASE_DEC, NULL, 0x0,
684 {&hf_docsis_dcd_cfr_tcpudp_dstport_end,
686 "Downstream Classifier IP TCP/UDP Destination Port End",
687 "docsis_dcd.cfr_ip_tcpudp_dstport_end",
688 FT_UINT16, BASE_DEC, NULL, 0x0,
693 {&hf_docsis_dcd_rule_id,
696 "docsis_dcd.rule_id",
697 FT_UINT8, BASE_DEC, NULL, 0x0,
702 {&hf_docsis_dcd_rule_pri,
705 "docsis_dcd.rule_pri",
706 FT_UINT8, BASE_DEC, NULL, 0x0,
711 {&hf_docsis_dcd_rule_ucid_list,
713 "DSG Rule UCID Range",
714 "docsis_dcd.rule_ucid_list",
715 FT_BYTES, BASE_NONE, NULL, 0x0,
720 {&hf_docsis_dcd_clid_known_mac_addr,
722 "DSG Rule Client ID Known MAC Address",
723 "docsis_dcd.clid_known_mac_addr",
724 FT_ETHER, BASE_DEC, NULL, 0x0,
729 {&hf_docsis_dcd_clid_ca_sys_id,
731 "DSG Rule Client ID CA System ID",
732 "docsis_dcd.clid_ca_sys_id",
733 FT_UINT16, BASE_DEC, NULL, 0x0,
738 {&hf_docsis_dcd_clid_app_id,
740 "DSG Rule Client ID Application ID",
741 "docsis_dcd.clid_app_id",
742 FT_UINT16, BASE_DEC, NULL, 0x0,
747 {&hf_docsis_dcd_rule_tunl_addr,
749 "DSG Rule Tunnel MAC Address",
750 "docsis_dcd.rule_tunl_addr",
751 FT_ETHER, BASE_DEC, NULL, 0x0,
756 {&hf_docsis_dcd_rule_cfr_id,
758 "DSG Rule Classifier ID",
759 "docsis_dcd.rule_cfr_id",
760 FT_UINT16, BASE_DEC, NULL, 0x0,
765 {&hf_docsis_dcd_rule_vendor_spec,
767 "DSG Rule Vendor Specific Parameters",
768 "docsis_dcd.rule_vendor_spec",
769 FT_BYTES, BASE_NONE, NULL, 0x0,
774 {&hf_docsis_dcd_cfg_chan,
776 "DSG Configuration Channel",
777 "docsis_dcd.cfg_chan",
778 FT_UINT32, BASE_DEC, NULL, 0x0,
783 {&hf_docsis_dcd_cfg_tdsg1,
785 "DSG Initialization Timeout (Tdsg1)",
786 "docsis_dcd.cfg_tdsg1",
787 FT_UINT16, BASE_DEC, NULL, 0x0,
792 {&hf_docsis_dcd_cfg_tdsg2,
794 "DSG Operational Timeout (Tdsg2)",
795 "docsis_dcd.cfg_tdsg2",
796 FT_UINT16, BASE_DEC, NULL, 0x0,
801 {&hf_docsis_dcd_cfg_tdsg3,
803 "DSG Two-Way Retry Timer (Tdsg3)",
804 "docsis_dcd.cfg_tdsg3",
805 FT_UINT16, BASE_DEC, NULL, 0x0,
810 {&hf_docsis_dcd_cfg_tdsg4,
812 "DSG One-Way Retry Timer (Tdsg4)",
813 "docsis_dcd.cfg_tdsg4",
814 FT_UINT16, BASE_DEC, NULL, 0x0,
819 {&hf_docsis_dcd_cfg_vendor_spec,
821 "DSG Configuration Vendor Specific Parameters",
822 "docsis_dcd.cfg_vendor_spec",
823 FT_BYTES, BASE_NONE, NULL, 0x0,
831 /* Setup protocol subtree array */
832 static gint *ett[] = {
835 &ett_docsis_dcd_cfr_ip,
836 &ett_docsis_dcd_rule,
837 &ett_docsis_dcd_clid,
841 /* Register the protocol name and description */
843 proto_register_protocol ("DOCSIS Downstream Channel Descriptor ",
844 "DOCSIS DCD", "docsis_dcd");
846 /* Required function calls to register the header fields and subtrees used */
847 proto_register_field_array (proto_docsis_dcd, hf, array_length (hf));
848 proto_register_subtree_array (ett, array_length (ett));
850 register_dissector ("docsis_dcd", dissect_dcd, proto_docsis_dcd);
854 /* If this dissector uses sub-dissector registration add a registration routine.
855 This format is required because a script is used to find these routines and
856 create the code that calls these routines.
859 proto_reg_handoff_docsis_dcd (void)
861 dissector_handle_t docsis_dcd_handle;
863 docsis_dcd_handle = find_dissector ("docsis_dcd");
864 dissector_add ("docsis_mgmt", 0x20, docsis_dcd_handle);