230adbc2d2bffa35d50ba1adfdf53bf2b015f2f9
[obnox/wireshark/wip.git] / plugins / docsis / packet-dcd.c
1 /* packet-dcd.c
2  * Routines for DCD Message dissection
3  * Copyright 2004, Darryl Hymel <darryl.hymel[AT]arrisi.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30
31 #include "moduleinfo.h"
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include <gmodule.h>
38
39 #include <epan/packet.h>
40
41 #define DCD_DOWN_CLASSIFIER 23
42 #define DCD_DSG_RULE 50
43 #define DCD_DSG_CONFIG 51
44
45 /* Define Downstrean Classifier subtypes
46  * These are subtype of DCD_DOWN_CLASSIFIER (23)
47  */
48
49 #define DCD_CFR_ID 2
50 #define DCD_CFR_RULE_PRI 5
51 #define DCD_CFR_IP_CLASSIFIER 9
52
53 /* Define IP Classifier sub-subtypes
54  * These are subtypes of DCD_CFR_IP_CLASSIFIER (23.9)
55  */
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
64
65 /* Define DSG Rule subtypes
66  * These are subtype of DCD_DSG_RULE (50)
67  */
68
69 #define DCD_RULE_ID 1
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)
78  */
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
83
84 /* Define DSG Configuration subtypes
85  * These are subtype of DCD_DSG_CONFIG (51)
86  */
87
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
94
95 /* Initialize the protocol and registered fields */
96 static int proto_docsis_dcd = -1;
97
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;
126
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;
134
135 /* Code to actually dissect the packets */
136 static void
137 dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
138 {
139   guint8 type, length;
140   proto_item *dcd_item;
141   proto_tree *dcd_tree;
142   int pos;
143    
144   pos = start;
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);
147   
148   while ( pos < ( start + len) ) 
149     {
150         type = tvb_get_guint8 (tvb, pos++);
151         length = tvb_get_guint8 (tvb, pos++);
152         
153         switch (type)
154           {
155             case DCD_CFG_CHAN_LST:
156               if (length == 4)
157                 {
158                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_chan, tvb,
159                                        pos, length, FALSE);
160                 }
161               else
162                 {
163                   THROW (ReportedBoundsError);
164                 }
165               break;
166             case DCD_CFG_TDSG1:
167               if (length == 2)
168                 {
169                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg1, tvb,
170                                    pos, length, FALSE);
171                 }
172               else 
173                 {
174                   THROW (ReportedBoundsError);
175                 }
176               break;
177             case DCD_CFG_TDSG2:
178               if (length == 2)
179                 {
180                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg2, tvb,
181                                    pos, length, FALSE);
182                 }
183               else 
184                 {
185                   THROW (ReportedBoundsError);
186                 }
187               break;
188             case DCD_CFG_TDSG3:
189               if (length == 2)
190                 {
191                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg3, tvb,
192                                    pos, length, FALSE);
193                 }
194               else 
195                 {
196                   THROW (ReportedBoundsError);
197                 }
198               break;
199             case DCD_CFG_TDSG4:
200               if (length == 2)
201                 {
202                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg4, tvb,
203                                    pos, length, FALSE);
204                 }
205               else 
206                 {
207                   THROW (ReportedBoundsError);
208                 }
209               break;
210             case DCD_CFG_VENDOR_SPEC:
211                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_vendor_spec, tvb,
212                                    pos, length, FALSE);
213               break;
214
215             }
216           pos = pos + length;
217       }
218 }
219 static void
220 dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
221 {
222   guint8 type, length;
223   proto_item *dcd_item;
224   proto_tree *dcd_tree;
225   int pos;
226    
227   pos = start;
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);
230   
231   while ( pos < ( start + len) ) 
232     {
233         type = tvb_get_guint8 (tvb, pos++);
234         length = tvb_get_guint8 (tvb, pos++);
235         
236         switch (type)
237           {
238             case DCD_CFR_IP_SOURCE_ADDR:
239               if (length == 4)
240                 {
241                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_addr, tvb,
242                                        pos, length, FALSE);
243                 }
244               else
245                 {
246                   THROW (ReportedBoundsError);
247                 }
248               break;
249             case DCD_CFR_IP_SOURCE_MASK:
250               if (length == 4)
251                 {
252                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_mask, tvb,
253                                        pos, length, FALSE);
254                 }
255               else
256                 {
257                   THROW (ReportedBoundsError);
258                 }
259               break;
260             case DCD_CFR_IP_DEST_ADDR:
261               if (length == 4)
262                 {
263                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_addr, tvb,
264                                        pos, length, FALSE);
265                 }
266               else
267                 {
268                   THROW (ReportedBoundsError);
269                 }
270                 break;
271             case DCD_CFR_IP_DEST_MASK:
272               if (length == 4)
273                 {
274                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_mask, tvb,
275                                        pos, length, FALSE);
276                 }
277               else
278                 {
279                   THROW (ReportedBoundsError);
280                 }
281                 break;
282             case DCD_CFR_TCPUDP_SRCPORT_START:
283               if (length == 2)
284                 {
285                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_start, tvb,
286                                        pos, length, FALSE);
287                 }
288               else
289                 {
290                   THROW (ReportedBoundsError);
291                 }
292                 break;
293             case DCD_CFR_TCPUDP_SRCPORT_END:
294               if (length == 2)
295                 {
296                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_end, tvb,
297                                        pos, length, FALSE);
298                 }
299               else
300                 {
301                   THROW (ReportedBoundsError);
302                 }
303                 break;
304             case DCD_CFR_TCPUDP_DSTPORT_START:
305               if (length == 2)
306                 {
307                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_start, tvb,
308                                        pos, length, FALSE);
309                 }
310               else
311                 {
312                   THROW (ReportedBoundsError);
313                 }
314                 break;
315             case DCD_CFR_TCPUDP_DSTPORT_END:
316               if (length == 2)
317                 {
318                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_end, tvb,
319                                        pos, length, FALSE);
320                 }
321               else
322                 {
323                   THROW (ReportedBoundsError);
324                 }
325                 break;
326             }
327           pos = pos + length;
328       }
329 }
330 static void
331 dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
332 {
333   guint8 type, length;
334   proto_item *dcd_item;
335   proto_tree *dcd_tree;
336   int pos;
337    
338   pos = start;
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);
341   
342   while ( pos < ( start + len) ) 
343     {
344         type = tvb_get_guint8 (tvb, pos++);
345         length = tvb_get_guint8 (tvb, pos++);
346         
347         switch (type)
348           {
349             case DCD_CLID_KNOWN_MAC_ADDR:
350               if (length == 6)
351                 {
352                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_known_mac_addr, tvb,
353                                        pos, length, FALSE);
354                 }
355               else
356                 {
357                   THROW (ReportedBoundsError);
358                 }
359               break;
360             case DCD_CLID_CA_SYS_ID:
361               if (length == 2)
362                 {
363                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_ca_sys_id, tvb,
364                                        pos, length, FALSE);
365                 }
366               else
367                 {
368                   THROW (ReportedBoundsError);
369                 }
370               break;
371             case DCD_CLID_APP_ID:
372               if (length == 2)
373                 {
374                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_app_id, tvb,
375                                        pos, length, FALSE);
376                 }
377               else
378                 {
379                   THROW (ReportedBoundsError);
380                 }
381                 break;
382             }
383           pos = pos + length;
384       }
385 }
386 static void
387 dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
388 {
389   guint8 type, length;
390   proto_item *dcd_item;
391   proto_tree *dcd_tree;
392   int pos;
393    
394   pos = start;
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);
397   
398   while ( pos < ( start + len) ) 
399     {
400         type = tvb_get_guint8 (tvb, pos++);
401         length = tvb_get_guint8 (tvb, pos++);
402         
403         switch (type)
404           {
405             case DCD_RULE_ID:
406               if (length == 1)
407                 {
408                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_id, tvb,
409                                        pos, length, FALSE);
410                 }
411               else
412                 {
413                   THROW (ReportedBoundsError);
414                 }
415               break;
416             case DCD_RULE_PRI:
417               if (length == 1)
418                 {
419                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_pri, tvb,
420                                    pos, length, FALSE);
421                 }
422               else 
423                 {
424                   THROW (ReportedBoundsError);
425                 }
426               break;
427             case DCD_RULE_UCID_RNG:
428                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_ucid_list, tvb,
429                                    pos, length, FALSE);
430               break;
431             case DCD_RULE_CLIENT_ID:
432               dissect_dcd_clid (tvb , dcd_tree , pos , length );
433               break;
434             case DCD_RULE_TUNL_ADDR:
435               if (length == 6)
436                 {
437                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_tunl_addr, tvb,
438                                    pos, length, FALSE);
439                 }
440               else 
441                 {
442                   THROW (ReportedBoundsError);
443                 }
444               break;
445             case DCD_RULE_CFR_ID:
446               if (length == 2)
447                 {
448                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_cfr_id, tvb,
449                                    pos, length, FALSE);
450                 }
451               else 
452                 {
453                   THROW (ReportedBoundsError);
454                 }
455               break;
456             case DCD_RULE_VENDOR_SPEC:
457                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_vendor_spec, tvb,
458                                    pos, length, FALSE);
459               break;
460
461             }
462           pos = pos + length;
463       }
464 }
465 static void
466 dissect_dcd_down_classifier (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
467 {
468   guint8 type, length;
469   proto_item *dcd_item;
470   proto_tree *dcd_tree;
471   int pos;
472    
473   pos = start;
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);
476   
477   while ( pos < ( start + len) ) 
478     {
479         type = tvb_get_guint8 (tvb, pos++);
480         length = tvb_get_guint8 (tvb, pos++);
481         
482         switch (type)
483           {
484             case DCD_CFR_ID:
485               if (length == 2)
486                 {
487                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_id, tvb,
488                                        pos, length, FALSE);
489                 }
490               else
491                 {
492                   THROW (ReportedBoundsError);
493                 }
494               break;
495             case DCD_CFR_RULE_PRI:
496               if (length == 1)
497                 {
498                   proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_rule_pri, tvb,
499                                    pos, length, FALSE);
500                 }
501               else 
502                 {
503                   THROW (ReportedBoundsError);
504                 }
505               break;
506             case DCD_CFR_IP_CLASSIFIER:
507               dissect_dcd_down_classifier_ip (tvb , dcd_tree , pos , length );
508               break;
509
510             }
511           pos = pos + length;
512       }
513 }
514 static void
515 dissect_dcd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
516 {
517   guint16 pos;
518   guint8 type, length;
519   proto_tree *dcd_tree;
520   proto_item *dcd_item;
521   guint16 len;
522
523   len = tvb_length_remaining (tvb, 0);
524
525   if (check_col (pinfo->cinfo, COL_INFO))
526     {
527       col_clear (pinfo->cinfo, COL_INFO);
528       col_add_fstr (pinfo->cinfo, COL_INFO,"DCD Message: ");
529     }
530
531   if (tree)
532     {
533       dcd_item =
534         proto_tree_add_protocol_format (tree, proto_docsis_dcd, tvb, 0,
535                                         tvb_length_remaining (tvb, 0),
536                                         "DCD Message");
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);
541
542       pos = 3;
543       while (pos < len)
544         {
545           type = tvb_get_guint8 (tvb, pos++);
546           length = tvb_get_guint8 (tvb, pos++);
547           switch (type)
548             {
549             case DCD_DOWN_CLASSIFIER:
550               dissect_dcd_down_classifier (tvb , dcd_tree , pos , length );
551               break;
552             case DCD_DSG_RULE:
553               dissect_dcd_dsg_rule (tvb , dcd_tree , pos , length );
554               break;
555             case DCD_DSG_CONFIG:
556               dissect_dcd_dsg_cfg (tvb , dcd_tree , pos , length );
557               break;
558             }                   /* switch(type) */
559           pos = pos + length;
560         }                       /* while (pos < len) */
561     }                           /* if (tree) */
562
563 }
564 /* Register the protocol with Wireshark */
565
566 /* this format is require because a script is used to build the C function
567    that calls all the protocol registration.
568 */
569
570
571 void
572 proto_register_docsis_dcd (void)
573 {
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,
577       {
578       "Configuration Change Count", 
579       "docsis_dcd.config_ch_cnt",
580       FT_UINT8, BASE_DEC, NULL, 0x0,
581       NULL, 
582       HFILL
583       }
584     },
585     {&hf_docsis_dcd_num_of_frag,
586       {
587       "Number of Fragments", 
588       "docsis_dcd.num_of_frag",
589       FT_UINT8, BASE_DEC, NULL, 0x0,
590       NULL, 
591       HFILL
592       }
593     },
594     {&hf_docsis_dcd_frag_sequence_num,
595       {
596       "Fragment Sequence Number", 
597       "docsis_dcd.frag_sequence_num",
598       FT_UINT8, BASE_DEC, NULL, 0x0,
599       NULL, 
600       HFILL
601       }
602     },
603     {&hf_docsis_dcd_cfr_id,
604       {
605       "Downstream Classifier Id", 
606       "docsis_dcd.cfr_id",
607       FT_UINT16, BASE_DEC, NULL, 0x0,
608       NULL, 
609       HFILL
610       }
611     },
612     {&hf_docsis_dcd_cfr_rule_pri,
613       {
614       "Downstream Classifier Rule Priority", 
615       "docsis_dcd.cfr_rule_pri",
616       FT_UINT8, BASE_DEC, NULL, 0x0,
617       NULL, 
618       HFILL
619       }
620     },
621     {&hf_docsis_dcd_cfr_ip_source_addr,
622       {
623       "Downstream Classifier IP Source Address", 
624       "docsis_dcd.cfr_ip_source_addr",
625       FT_IPv4, BASE_NONE, NULL, 0x0,
626       NULL, 
627       HFILL
628       }
629     },
630     {&hf_docsis_dcd_cfr_ip_source_mask,
631       {
632       "Downstream Classifier IP Source Mask", 
633       "docsis_dcd.cfr_ip_source_mask",
634       FT_IPv4, BASE_NONE, NULL, 0x0,
635       NULL, 
636       HFILL
637       }
638     },
639     {&hf_docsis_dcd_cfr_ip_dest_addr,
640       {
641       "Downstream Classifier IP Destination Address", 
642       "docsis_dcd.cfr_ip_dest_addr",
643       FT_IPv4, BASE_NONE, NULL, 0x0,
644       NULL, 
645       HFILL
646       }
647     },
648     {&hf_docsis_dcd_cfr_ip_dest_mask,
649       {
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", 
654       HFILL
655       }
656     },
657     {&hf_docsis_dcd_cfr_tcpudp_srcport_start,
658       {
659       "Downstream Classifier IP TCP/UDP Source Port Start", 
660       "docsis_dcd.cfr_ip_tcpudp_srcport_start",
661       FT_UINT16, BASE_DEC, NULL, 0x0,
662       NULL, 
663       HFILL
664       }
665     },
666     {&hf_docsis_dcd_cfr_tcpudp_srcport_end,
667       {
668       "Downstream Classifier IP TCP/UDP Source Port End", 
669       "docsis_dcd.cfr_ip_tcpudp_srcport_end",
670       FT_UINT16, BASE_DEC, NULL, 0x0,
671       NULL, 
672       HFILL
673       }
674     },
675     {&hf_docsis_dcd_cfr_tcpudp_dstport_start,
676       {
677       "Downstream Classifier IP TCP/UDP Destination Port Start", 
678       "docsis_dcd.cfr_ip_tcpudp_dstport_start",
679       FT_UINT16, BASE_DEC, NULL, 0x0,
680       NULL, 
681       HFILL
682       }
683     },
684     {&hf_docsis_dcd_cfr_tcpudp_dstport_end,
685       {
686       "Downstream Classifier IP TCP/UDP Destination Port End", 
687       "docsis_dcd.cfr_ip_tcpudp_dstport_end",
688       FT_UINT16, BASE_DEC, NULL, 0x0,
689       NULL, 
690       HFILL
691       }
692     },
693     {&hf_docsis_dcd_rule_id,
694       {
695       "DSG Rule Id", 
696       "docsis_dcd.rule_id",
697       FT_UINT8, BASE_DEC, NULL, 0x0,
698       NULL, 
699       HFILL
700       }
701     },
702     {&hf_docsis_dcd_rule_pri,
703       {
704       "DSG Rule Priority", 
705       "docsis_dcd.rule_pri",
706       FT_UINT8, BASE_DEC, NULL, 0x0,
707       NULL, 
708       HFILL
709       }
710     },
711     {&hf_docsis_dcd_rule_ucid_list,
712       {
713       "DSG Rule UCID Range", 
714       "docsis_dcd.rule_ucid_list",
715       FT_BYTES, BASE_NONE, NULL, 0x0,
716       NULL, 
717       HFILL
718       }
719     },
720     {&hf_docsis_dcd_clid_known_mac_addr,
721       {
722       "DSG Rule Client ID Known MAC Address", 
723       "docsis_dcd.clid_known_mac_addr",
724       FT_ETHER, BASE_DEC, NULL, 0x0,
725       NULL, 
726       HFILL
727       }
728     },
729     {&hf_docsis_dcd_clid_ca_sys_id,
730       {
731       "DSG Rule Client ID CA System ID", 
732       "docsis_dcd.clid_ca_sys_id",
733       FT_UINT16, BASE_DEC, NULL, 0x0,
734       NULL, 
735       HFILL
736       }
737     },
738     {&hf_docsis_dcd_clid_app_id,
739       {
740       "DSG Rule Client ID Application ID", 
741       "docsis_dcd.clid_app_id",
742       FT_UINT16, BASE_DEC, NULL, 0x0,
743       NULL, 
744       HFILL
745       }
746     },
747     {&hf_docsis_dcd_rule_tunl_addr,
748       {
749       "DSG Rule Tunnel MAC Address", 
750       "docsis_dcd.rule_tunl_addr",
751       FT_ETHER, BASE_DEC, NULL, 0x0,
752       NULL, 
753       HFILL
754       }
755     },
756     {&hf_docsis_dcd_rule_cfr_id,
757       {
758       "DSG Rule Classifier ID", 
759       "docsis_dcd.rule_cfr_id",
760       FT_UINT16, BASE_DEC, NULL, 0x0,
761       NULL, 
762       HFILL
763       }
764     },
765     {&hf_docsis_dcd_rule_vendor_spec,
766       {
767       "DSG Rule Vendor Specific Parameters", 
768       "docsis_dcd.rule_vendor_spec",
769       FT_BYTES, BASE_NONE, NULL, 0x0,
770       NULL, 
771       HFILL
772       }
773     },
774     {&hf_docsis_dcd_cfg_chan,
775       {
776       "DSG Configuration Channel", 
777       "docsis_dcd.cfg_chan",
778       FT_UINT32, BASE_DEC, NULL, 0x0,
779       NULL, 
780       HFILL
781       }
782     },
783     {&hf_docsis_dcd_cfg_tdsg1,
784       {
785       "DSG Initialization Timeout (Tdsg1)", 
786       "docsis_dcd.cfg_tdsg1",
787       FT_UINT16, BASE_DEC, NULL, 0x0,
788       NULL, 
789       HFILL
790       }
791     },
792     {&hf_docsis_dcd_cfg_tdsg2,
793       {
794       "DSG Operational Timeout (Tdsg2)", 
795       "docsis_dcd.cfg_tdsg2",
796       FT_UINT16, BASE_DEC, NULL, 0x0,
797       NULL, 
798       HFILL
799       }
800     },
801     {&hf_docsis_dcd_cfg_tdsg3,
802       {
803       "DSG Two-Way Retry Timer (Tdsg3)", 
804       "docsis_dcd.cfg_tdsg3",
805       FT_UINT16, BASE_DEC, NULL, 0x0,
806       NULL, 
807       HFILL
808       }
809     },
810     {&hf_docsis_dcd_cfg_tdsg4,
811       {
812       "DSG One-Way Retry Timer (Tdsg4)", 
813       "docsis_dcd.cfg_tdsg4",
814       FT_UINT16, BASE_DEC, NULL, 0x0,
815       NULL, 
816       HFILL
817       }
818     },
819     {&hf_docsis_dcd_cfg_vendor_spec,
820       {
821       "DSG Configuration Vendor Specific Parameters", 
822       "docsis_dcd.cfg_vendor_spec",
823       FT_BYTES, BASE_NONE, NULL, 0x0,
824       NULL, 
825       HFILL
826       }
827     },
828
829   };
830
831 /* Setup protocol subtree array */
832   static gint *ett[] = {
833     &ett_docsis_dcd,
834     &ett_docsis_dcd_cfr,
835     &ett_docsis_dcd_cfr_ip,
836     &ett_docsis_dcd_rule,
837     &ett_docsis_dcd_clid,
838     &ett_docsis_dcd_cfg,
839   };
840
841 /* Register the protocol name and description */
842   proto_docsis_dcd =
843     proto_register_protocol ("DOCSIS Downstream Channel Descriptor ",
844                              "DOCSIS DCD", "docsis_dcd");
845
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));
849
850   register_dissector ("docsis_dcd", dissect_dcd, proto_docsis_dcd);
851 }
852
853
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.
857 */
858 void
859 proto_reg_handoff_docsis_dcd (void)
860 {
861   dissector_handle_t docsis_dcd_handle;
862
863   docsis_dcd_handle = find_dissector ("docsis_dcd");
864   dissector_add ("docsis_mgmt", 0x20, docsis_dcd_handle);
865
866 }