Remove trailing whitespace
[metze/wireshark/wip.git] / plugins / docsis / packet-ucd.c
1 /* packet-ucd.c
2  * Routines for UCD Message dissection
3  * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "config.h"
27
28 #include <epan/packet.h>
29 #include <epan/exceptions.h>
30
31 #define UCD_SYMBOL_RATE 1
32 #define UCD_FREQUENCY 2
33 #define UCD_PREAMBLE 3
34 #define UCD_BURST_DESCR 4
35 #define UCD_BURST_DESCR5 5
36
37 #define UCD_MODULATION 1
38 #define UCD_DIFF_ENCODING 2
39 #define UCD_PREAMBLE_LEN 3
40 #define UCD_PREAMBLE_VAL_OFF 4
41 #define UCD_FEC 5
42 #define UCD_FEC_CODEWORD 6
43 #define UCD_SCRAMBLER_SEED 7
44 #define UCD_MAX_BURST 8
45 #define UCD_GUARD_TIME 9
46 #define UCD_LAST_CW_LEN 10
47 #define UCD_SCRAMBLER_ONOFF 11
48 #define UCD_RS_INT_DEPTH 12
49 #define UCD_RS_INT_BLOCK 13
50 #define UCD_PREAMBLE_TYPE 14
51 #define UCD_SCMDA_SCRAMBLER_ONOFF 15
52 #define UCD_SCDMA_CODES_PER_SUBFRAME 16
53 #define UCD_SCDMA_FRAMER_INT_STEP_SIZE 17
54 #define UCD_TCM_ENABLED 18
55
56 #define IUC_REQUEST 1
57 #define IUC_REQ_DATA 2
58 #define IUC_INIT_MAINT 3
59 #define IUC_STATION_MAINT 4
60 #define IUC_SHORT_DATA_GRANT 5
61 #define IUC_LONG_DATA_GRANT 6
62 #define IUC_NULL_IE 7
63 #define IUC_DATA_ACK 8
64 #define IUC_ADV_PHY_SHORT_DATA_GRANT 9
65 #define IUC_ADV_PHY_LONG_DATA_GRANT 10
66 #define IUC_ADV_PHY_UGS 11
67 #define IUC_RESERVED12 12
68 #define IUC_RESERVED13 13
69 #define IUC_RESERVED14 14
70 #define IUC_EXPANSION 15
71
72 void proto_register_docsis_ucd(void);
73 void proto_reg_handoff_docsis_ucd(void);
74
75 /* Initialize the protocol and registered fields */
76 static int proto_docsis_ucd = -1;
77
78 static int hf_docsis_ucd_upstream_chid = -1;
79 static int hf_docsis_ucd_config_ch_cnt = -1;
80 static int hf_docsis_ucd_mini_slot_size = -1;
81 static int hf_docsis_ucd_down_chid = -1;
82 static int hf_docsis_ucd_type = -1;
83 static int hf_docsis_ucd_length = -1;
84 static int hf_docsis_ucd_symbol_rate = -1;
85 static int hf_docsis_ucd_frequency = -1;
86 static int hf_docsis_ucd_preamble_pat = -1;
87 static int hf_docsis_ucd_iuc = -1;
88
89 static int hf_docsis_burst_mod_type = -1;
90 static int hf_docsis_burst_diff_encoding = -1;
91 static int hf_docsis_burst_preamble_len = -1;
92 static int hf_docsis_burst_preamble_val_off = -1;
93 static int hf_docsis_burst_fec = -1;
94 static int hf_docsis_burst_fec_codeword = -1;
95 static int hf_docsis_burst_scrambler_seed = -1;
96 static int hf_docsis_burst_max_burst = -1;
97 static int hf_docsis_burst_guard_time = -1;
98 static int hf_docsis_burst_last_cw_len = -1;
99 static int hf_docsis_burst_scrambler_onoff = -1;
100 static int hf_docsis_rs_int_depth = -1;
101 static int hf_docsis_rs_int_block = -1;
102 static int hf_docsis_preamble_type = -1;
103 static int hf_docsis_scdma_scrambler_onoff = -1;
104 static int hf_docsis_scdma_codes_per_subframe = -1;
105 static int hf_docsis_scdma_framer_int_step_size = -1;
106 static int hf_docsis_tcm_enabled = -1;
107
108 /* Initialize the subtree pointers */
109 static gint ett_docsis_ucd = -1;
110 static gint ett_tlv = -1;
111
112 static const value_string channel_tlv_vals[] = {
113      {UCD_SYMBOL_RATE, "Symbol Rate"},
114      {UCD_FREQUENCY, "Frequency"},
115      {UCD_PREAMBLE, "Preamble Pattern"},
116      {UCD_BURST_DESCR, "Burst Descriptor"},
117      {UCD_BURST_DESCR5, "Burst Descriptor DOCSIS 2.0"},
118      {0, NULL}
119 };
120
121 static const value_string on_off_vals[] = {
122      {1, "On"},
123      {2, "Off"},
124      {0, NULL}
125 };
126
127 static const value_string mod_vals[] = {
128      {1, "QPSK"},
129      {2, "QAM16"},
130      {0, NULL}
131 };
132
133 value_string iuc_vals[] = {
134      {IUC_REQUEST, "Request"},
135      {IUC_REQ_DATA, "REQ/Data"},
136      {IUC_INIT_MAINT, "Initial Maintenance"},
137      {IUC_STATION_MAINT, "Station Maintenance"},
138      {IUC_SHORT_DATA_GRANT, "Short Data Grant"},
139      {IUC_LONG_DATA_GRANT, "Long Data Grant"},
140      {IUC_NULL_IE, "NULL IE"},
141      {IUC_DATA_ACK, "Data Ack"},
142      {IUC_ADV_PHY_SHORT_DATA_GRANT, "Advanced Phy Short Data Grant"},
143      {IUC_ADV_PHY_LONG_DATA_GRANT, "Advanced Phy Long Data Grant"},
144      {IUC_ADV_PHY_UGS, "Advanced Phy UGS"},
145      {IUC_RESERVED12, "Reserved"},
146      {IUC_RESERVED13, "Reserved"},
147      {IUC_RESERVED14, "Reserved"},
148      {IUC_EXPANSION, "Expanded IUC"},
149      {0, NULL}
150
151 };
152
153 static const value_string last_cw_len_vals[] = {
154      {1, "Fixed"},
155      {2, "Shortened"},
156      {0, NULL}
157 };
158 /* Code to actually dissect the packets */
159 static void
160   dissect_ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
161 {
162   int pos, endtlvpos;
163   guint8 type, length;
164   guint8 tlvlen, tlvtype;
165   proto_tree *ucd_tree;
166   proto_item *ucd_item;
167   proto_tree *tlv_tree;
168   proto_item *tlv_item;
169   gint len;
170   guint8 upchid, symrate;
171
172   len = tvb_reported_length_remaining (tvb, 0);
173    upchid = tvb_get_guint8 (tvb, 0);
174
175    /* if the upstream Channel ID is 0 then this is for Telephony Return) */
176         if (upchid > 0)
177           col_add_fstr (pinfo->cinfo, COL_INFO,
178                         "UCD Message:  Channel ID = %u (U%u)", upchid,
179                         upchid - 1);
180         else
181           col_add_fstr (pinfo->cinfo, COL_INFO,
182                         "UCD Message:  Channel ID = %u (Telephony Return)",
183                         upchid);
184
185    if (tree)
186      {
187         ucd_item =
188         proto_tree_add_protocol_format (tree, proto_docsis_ucd, tvb, 0, -1,
189                                         "UCD Message");
190         ucd_tree = proto_item_add_subtree (ucd_item, ett_docsis_ucd);
191         proto_tree_add_item (ucd_tree, hf_docsis_ucd_upstream_chid, tvb, 0, 1,
192                              ENC_BIG_ENDIAN);
193         proto_tree_add_item (ucd_tree, hf_docsis_ucd_config_ch_cnt, tvb, 1, 1,
194                              ENC_BIG_ENDIAN);
195         proto_tree_add_item (ucd_tree, hf_docsis_ucd_mini_slot_size, tvb, 2, 1,
196                              ENC_BIG_ENDIAN);
197         proto_tree_add_item (ucd_tree, hf_docsis_ucd_down_chid, tvb, 3, 1,
198                              ENC_BIG_ENDIAN);
199
200         pos = 4;
201         while (pos < len)
202           {
203           type = tvb_get_guint8 (tvb, pos);
204           tlv_item = proto_tree_add_text (ucd_tree, tvb, pos, -1,
205                                           "%s",
206                                           val_to_str(type, channel_tlv_vals,
207                                                      "Unknown TLV (%u)"));
208           tlv_tree = proto_item_add_subtree (tlv_item, ett_tlv);
209           proto_tree_add_uint (tlv_tree, hf_docsis_ucd_type,
210                                tvb, pos, 1, type);
211           pos++;
212           length = tvb_get_guint8 (tvb, pos);
213           proto_tree_add_uint (tlv_tree, hf_docsis_ucd_length,
214                                tvb, pos, 1, length);
215           pos++;
216           proto_item_set_len(tlv_item, length + 2);
217              switch (type)
218                {
219                 case UCD_SYMBOL_RATE:
220                   if (length == 1)
221                     {
222                        symrate = tvb_get_guint8 (tvb, pos);
223                        proto_tree_add_uint (tlv_tree, hf_docsis_ucd_symbol_rate,
224                                             tvb, pos, length, symrate * 160);
225                     }
226                   else
227                     {
228                        THROW (ReportedBoundsError);
229                     }
230                   pos = pos + length;
231                   break;
232                 case UCD_FREQUENCY:
233                   if (length == 4)
234                     {
235                        proto_tree_add_item (tlv_tree, hf_docsis_ucd_frequency, tvb,
236                                             pos, length, ENC_BIG_ENDIAN);
237                        pos = pos + length;
238                     }
239                   else
240                     {
241                        THROW (ReportedBoundsError);
242                     }
243                   break;
244                 case UCD_PREAMBLE:
245                   proto_tree_add_item (tlv_tree, hf_docsis_ucd_preamble_pat, tvb,
246                                        pos, length, ENC_NA);
247                   pos = pos + length;
248                   break;
249                 case UCD_BURST_DESCR:
250                   proto_tree_add_item (tlv_tree, hf_docsis_ucd_iuc, tvb,
251                                        pos++, 1, ENC_BIG_ENDIAN);
252                   endtlvpos = pos + length - 1;
253                   while (pos < endtlvpos)
254                     {
255                        tlvtype = tvb_get_guint8 (tvb, pos++);
256                        tlvlen = tvb_get_guint8 (tvb, pos++);
257                        switch (tlvtype)
258                          {
259                           case UCD_MODULATION:
260                             if (tlvlen == 1)
261                               {
262                                  proto_tree_add_item (tlv_tree,
263                                                       hf_docsis_burst_mod_type, tvb,
264                                                       pos, tlvlen, ENC_BIG_ENDIAN);
265                               }
266                             else
267                               {
268                                  THROW (ReportedBoundsError);
269                               }
270                             break;
271                           case UCD_DIFF_ENCODING:
272                             if (tlvlen == 1)
273                               {
274                                  proto_tree_add_item (tlv_tree,
275                                                       hf_docsis_burst_diff_encoding,
276                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
277                               }
278                             else
279                               {
280                                  THROW (ReportedBoundsError);
281                               }
282                             break;
283                           case UCD_PREAMBLE_LEN:
284                             if (tlvlen == 2)
285                               {
286                                  proto_tree_add_item (tlv_tree,
287                                                       hf_docsis_burst_preamble_len,
288                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
289                               }
290                             else
291                               {
292                                  THROW (ReportedBoundsError);
293                               }
294                             break;
295                           case UCD_PREAMBLE_VAL_OFF:
296                             if (tlvlen == 2)
297                               {
298                                  proto_tree_add_item (tlv_tree,
299                                                       hf_docsis_burst_preamble_val_off,
300                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
301                               }
302                             else
303                               {
304                                  THROW (ReportedBoundsError);
305                               }
306                             break;
307                           case UCD_FEC:
308                             if (tlvlen == 1)
309                               {
310                                  proto_tree_add_item (tlv_tree,
311                                                       hf_docsis_burst_fec, tvb, pos,
312                                                       tlvlen, ENC_BIG_ENDIAN);
313                               }
314                             else
315                               {
316                                  THROW (ReportedBoundsError);
317                               }
318                             break;
319                           case UCD_FEC_CODEWORD:
320                             if (tlvlen == 1)
321                               {
322                                  proto_tree_add_item (tlv_tree,
323                                                       hf_docsis_burst_fec_codeword,
324                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
325                               }
326                             else
327                               {
328                                  THROW (ReportedBoundsError);
329                               }
330                             break;
331                           case UCD_SCRAMBLER_SEED:
332                             if (tlvlen == 2)
333                               {
334                                  proto_tree_add_item (tlv_tree,
335                                                       hf_docsis_burst_scrambler_seed,
336                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
337                               }
338                             else
339                               {
340                                  THROW (ReportedBoundsError);
341                               }
342                             break;
343                           case UCD_MAX_BURST:
344                             if (tlvlen == 1)
345                               {
346                                  proto_tree_add_item (tlv_tree,
347                                                       hf_docsis_burst_max_burst, tvb,
348                                                       pos, tlvlen, ENC_BIG_ENDIAN);
349                               }
350                             else
351                               {
352                                  THROW (ReportedBoundsError);
353                               }
354                             break;
355                           case UCD_GUARD_TIME:
356                             if (tlvlen == 1)
357                               {
358                                  proto_tree_add_item (tlv_tree,
359                                                       hf_docsis_burst_guard_time,
360                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
361                               }
362                             else
363                               {
364                                  THROW (ReportedBoundsError);
365                               }
366                             break;
367                           case UCD_LAST_CW_LEN:
368                             if (tlvlen == 1)
369                               {
370                                  proto_tree_add_item (tlv_tree,
371                                                       hf_docsis_burst_last_cw_len,
372                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
373                               }
374                             else
375                               {
376                                  THROW (ReportedBoundsError);
377                               }
378                             break;
379                           case UCD_SCRAMBLER_ONOFF:
380                             if (tlvlen == 1)
381                               {
382                                  proto_tree_add_item (tlv_tree,
383                                                       hf_docsis_burst_scrambler_onoff,
384                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
385                               }
386                             else
387                               {
388                                  THROW (ReportedBoundsError);
389                               }
390                             break;
391                          }              /* switch(tlvtype) */
392                        pos = pos + tlvlen;
393                     }           /* while (pos < endtlvpos) */
394                   break;
395                 case UCD_BURST_DESCR5:
396                   /* DOCSIS 2.0 Upstream Channel Descriptor */
397                   proto_tree_add_item (tlv_tree, hf_docsis_ucd_iuc, tvb,
398                                        pos++, 1, ENC_BIG_ENDIAN);
399                   endtlvpos = pos + length - 1;
400                   while (pos < endtlvpos)
401                     {
402                        tlvtype = tvb_get_guint8 (tvb, pos++);
403                        tlvlen = tvb_get_guint8 (tvb, pos++);
404                        switch (tlvtype)
405                          {
406                           case UCD_MODULATION:
407                             if (tlvlen == 1)
408                               {
409                                  proto_tree_add_item (tlv_tree,
410                                                       hf_docsis_burst_mod_type, tvb,
411                                                       pos, tlvlen, ENC_BIG_ENDIAN);
412                               }
413                             else
414                               {
415                                  THROW (ReportedBoundsError);
416                               }
417                             break;
418                           case UCD_DIFF_ENCODING:
419                             if (tlvlen == 1)
420                               {
421                                  proto_tree_add_item (tlv_tree,
422                                                       hf_docsis_burst_diff_encoding,
423                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
424                               }
425                             else
426                               {
427                                  THROW (ReportedBoundsError);
428                               }
429                             break;
430                           case UCD_PREAMBLE_LEN:
431                             if (tlvlen == 2)
432                               {
433                                  proto_tree_add_item (tlv_tree,
434                                                       hf_docsis_burst_preamble_len,
435                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
436                               }
437                             else
438                               {
439                                  THROW (ReportedBoundsError);
440                               }
441                             break;
442                           case UCD_PREAMBLE_VAL_OFF:
443                             if (tlvlen == 2)
444                               {
445                                  proto_tree_add_item (tlv_tree,
446                                                       hf_docsis_burst_preamble_val_off,
447                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
448                               }
449                             else
450                               {
451                                  THROW (ReportedBoundsError);
452                               }
453                             break;
454                           case UCD_FEC:
455                             if (tlvlen == 1)
456                               {
457                                  proto_tree_add_item (tlv_tree,
458                                                       hf_docsis_burst_fec, tvb, pos,
459                                                       tlvlen, ENC_BIG_ENDIAN);
460                               }
461                             else
462                               {
463                                  THROW (ReportedBoundsError);
464                               }
465                             break;
466                           case UCD_FEC_CODEWORD:
467                             if (tlvlen == 1)
468                               {
469                                  proto_tree_add_item (tlv_tree,
470                                                       hf_docsis_burst_fec_codeword,
471                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
472                               }
473                             else
474                               {
475                                  THROW (ReportedBoundsError);
476                               }
477                             break;
478                           case UCD_SCRAMBLER_SEED:
479                             if (tlvlen == 2)
480                               {
481                                  proto_tree_add_item (tlv_tree,
482                                                       hf_docsis_burst_scrambler_seed,
483                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
484                               }
485                             else
486                               {
487                                  THROW (ReportedBoundsError);
488                               }
489                             break;
490                           case UCD_MAX_BURST:
491                             if (tlvlen == 1)
492                               {
493                                  proto_tree_add_item (tlv_tree,
494                                                       hf_docsis_burst_max_burst, tvb,
495                                                       pos, tlvlen, ENC_BIG_ENDIAN);
496                               }
497                             else
498                               {
499                                  THROW (ReportedBoundsError);
500                               }
501                             break;
502                           case UCD_GUARD_TIME:
503                             if (tlvlen == 1)
504                               {
505                                  proto_tree_add_item (tlv_tree,
506                                                       hf_docsis_burst_guard_time,
507                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
508                               }
509                             else
510                               {
511                                  THROW (ReportedBoundsError);
512                               }
513                             break;
514                           case UCD_LAST_CW_LEN:
515                             if (tlvlen == 1)
516                               {
517                                  proto_tree_add_item (tlv_tree,
518                                                       hf_docsis_burst_last_cw_len,
519                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
520                               }
521                             else
522                               {
523                                  THROW (ReportedBoundsError);
524                               }
525                             break;
526                           case UCD_SCRAMBLER_ONOFF:
527                             if (tlvlen == 1)
528                               {
529                                  proto_tree_add_item (tlv_tree,
530                                                       hf_docsis_burst_scrambler_onoff,
531                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
532                               }
533                             else
534                               {
535                                  THROW (ReportedBoundsError);
536                               }
537                             break;
538                             /* New cases added for DOCSIS 2.0 US Physical Burst Descriptor TLV */
539                             /* #define UCD_RS_INT_DEPTH 12
540                              *  * #define UCD_RS_INT_BLOCK 13
541                              *  * #define UCD_PREAMBLE_TYPE 14
542                              *  * #define UCD_SCMDA_SCRAMBLER_ONOFF 15
543                              *  * #define UCD_SCDMA_CODES_PER_SUBFRAME 16
544                              *  * #define UCD_SCDMA_FRAMER_INT_STEP_SIZE 17
545                              *  * #define UCD_TCM_ENABLED 18
546                              *  */
547                           case UCD_RS_INT_DEPTH:
548                             if (tlvlen == 1)
549                               {
550                                  proto_tree_add_item (tlv_tree,
551                                                       hf_docsis_rs_int_depth,
552                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
553                               }
554                             else
555                               {
556                                  THROW (ReportedBoundsError);
557                               }
558                             break;
559                           case UCD_RS_INT_BLOCK:
560                             if (tlvlen == 2)
561                               {
562                                  proto_tree_add_item (tlv_tree,
563                                                       hf_docsis_rs_int_block,
564                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
565                               }
566                             else
567                               {
568                                  THROW (ReportedBoundsError);
569                               }
570                             break;
571                           case UCD_PREAMBLE_TYPE:
572                             if (tlvlen == 1)
573                               {
574                                  proto_tree_add_item (tlv_tree,
575                                                       hf_docsis_preamble_type,
576                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
577                               }
578                             else
579                               {
580                                  THROW (ReportedBoundsError);
581                               }
582                             break;
583                           case UCD_SCMDA_SCRAMBLER_ONOFF:
584                             if (tlvlen == 1)
585                               {
586                                  proto_tree_add_item (tlv_tree,
587                                                       hf_docsis_scdma_scrambler_onoff,
588                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
589                               }
590                             else
591                               {
592                                  THROW (ReportedBoundsError);
593                               }
594                             break;
595                           case UCD_SCDMA_CODES_PER_SUBFRAME:
596                             if (tlvlen == 1)
597                               {
598                                  proto_tree_add_item (tlv_tree,
599                                                       hf_docsis_scdma_codes_per_subframe,
600                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
601                               }
602                             else
603                               {
604                                  THROW (ReportedBoundsError);
605                               }
606                             break;
607                           case UCD_SCDMA_FRAMER_INT_STEP_SIZE:
608                             if (tlvlen == 1)
609                               {
610                                  proto_tree_add_item (tlv_tree,
611                                                       hf_docsis_scdma_framer_int_step_size,
612                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
613                               }
614                             else
615                               {
616                                  THROW (ReportedBoundsError);
617                               }
618                             break;
619                           case UCD_TCM_ENABLED:
620                             if (tlvlen == 1)
621                               {
622                                  proto_tree_add_item (tlv_tree,
623                                                       hf_docsis_tcm_enabled,
624                                                       tvb, pos, tlvlen, ENC_BIG_ENDIAN);
625                               }
626                             else
627                               {
628                                  THROW (ReportedBoundsError);
629                               }
630                             break;
631                          }           /* switch(tlvtype) */
632                        pos = pos + tlvlen;
633                     }               /* while (pos < endtlvpos) */
634                   break;
635                }                   /* switch(type) */
636           }                       /* while (pos < len) */
637      }                           /* if (tree) */
638
639 }
640
641 /* Register the protocol with Wireshark */
642
643 /* this format is require because a script is used to build the C function
644  that calls all the protocol registration.
645  */
646
647
648 void
649 proto_register_docsis_ucd (void)
650 {
651
652    /* Setup list of header fields  See Section 1.6.1 for details*/
653    static hf_register_info hf[] = {
654     {&hf_docsis_ucd_upstream_chid,
655      {"Upstream Channel ID", "docsis_ucd.upchid",
656       FT_UINT8, BASE_DEC, NULL, 0x0,
657       NULL, HFILL}
658      },
659     {&hf_docsis_ucd_config_ch_cnt,
660      {"Config Change Count", "docsis_ucd.confcngcnt",
661       FT_UINT8, BASE_DEC, NULL, 0x0,
662       "Configuration Change Count", HFILL}
663      },
664     {&hf_docsis_ucd_mini_slot_size,
665      {"Mini Slot Size (6.25us TimeTicks)", "docsis_ucd.mslotsize",
666       FT_UINT8, BASE_DEC, NULL, 0x0,
667       NULL, HFILL}
668      },
669     {&hf_docsis_ucd_down_chid,
670      {"Downstream Channel ID", "docsis_ucd.downchid",
671       FT_UINT8, BASE_DEC, NULL, 0x0,
672       "Management Message", HFILL}
673      },
674     {&hf_docsis_ucd_type,
675      {"TLV Type", "docsis_ucd.type",
676       FT_UINT8, BASE_DEC, VALS(channel_tlv_vals), 0x0,
677       "Channel TLV type", HFILL}
678      },
679     {&hf_docsis_ucd_length,
680      {"TLV Length", "docsis_ucd.length",
681       FT_UINT8, BASE_DEC, NULL, 0x0,
682       "Channel TLV length", HFILL}
683      },
684     {&hf_docsis_ucd_symbol_rate,
685      {"Symbol Rate (ksym/sec)", "docsis_ucd.symrate",
686       FT_UINT8, BASE_DEC, NULL, 0x0,
687       "Symbol Rate", HFILL}
688      },
689     {&hf_docsis_ucd_frequency,
690      {"Frequency (Hz)", "docsis_ucd.freq",
691       FT_UINT32, BASE_DEC, NULL, 0x0,
692       "Upstream Center Frequency", HFILL}
693      },
694     {&hf_docsis_ucd_preamble_pat,
695      {"Preamble Pattern", "docsis_ucd.preamble",
696       FT_BYTES, BASE_NONE, NULL, 0x0,
697       "Preamble Superstring", HFILL}
698      },
699     {&hf_docsis_ucd_iuc,
700      {"Interval Usage Code", "docsis_ucd.iuc",
701       FT_UINT8, BASE_DEC, VALS (iuc_vals), 0x0,
702       NULL, HFILL}
703      },
704     {&hf_docsis_burst_mod_type,
705      {"1 Modulation Type", "docsis_ucd.burst.modtype",
706       FT_UINT8, BASE_DEC, VALS (mod_vals), 0x0,
707       "Modulation Type", HFILL}
708      },
709     {&hf_docsis_burst_diff_encoding,
710      {"2 Differential Encoding", "docsis_ucd.burst.diffenc",
711       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
712       "Differential Encoding", HFILL}
713      },
714     {&hf_docsis_burst_preamble_len,
715      {"3 Preamble Length (Bits)", "docsis_ucd.burst.preamble_len",
716       FT_UINT16, BASE_DEC, NULL, 0x0,
717       "Preamble Length (Bits)", HFILL}
718      },
719     {&hf_docsis_burst_preamble_val_off,
720      {"4 Preamble Offset (Bits)", "docsis_ucd.burst.preamble_off",
721       FT_UINT16, BASE_DEC, NULL, 0x0,
722       "Preamble Offset (Bits)", HFILL}
723      },
724     {&hf_docsis_burst_fec,
725      {"5 FEC (T)", "docsis_ucd.burst.fec",
726       FT_UINT8, BASE_DEC, NULL, 0x0,
727       "FEC (T) Codeword Parity Bits = 2^T", HFILL}
728      },
729     {&hf_docsis_burst_fec_codeword,
730      {"6 FEC Codeword Info bytes (k)", "docsis_ucd.burst.fec_codeword",
731       FT_UINT8, BASE_DEC, NULL, 0x0,
732       "FEC Codeword Info Bytes (k)", HFILL}
733      },
734     {&hf_docsis_burst_scrambler_seed,
735      {"7 Scrambler Seed", "docsis_ucd.burst.scrambler_seed",
736       FT_UINT16, BASE_HEX, NULL, 0x0,
737       "Burst Descriptor", HFILL}
738      },
739     {&hf_docsis_burst_max_burst,
740      {"8 Max Burst Size (Minislots)", "docsis_ucd.burst.maxburst",
741       FT_UINT8, BASE_DEC, NULL, 0x0,
742       "Max Burst Size (Minislots)", HFILL}
743      },
744     {&hf_docsis_burst_guard_time,
745      {"9 Guard Time Size (Symbol Times)", "docsis_ucd.burst.guardtime",
746       FT_UINT8, BASE_DEC, NULL, 0x0,
747       "Guard Time Size", HFILL}
748      },
749     {&hf_docsis_burst_last_cw_len,
750      {"10 Last Codeword Length", "docsis_ucd.burst.last_cw_len",
751       FT_UINT8, BASE_DEC, VALS (last_cw_len_vals), 0x0,
752       "Last Codeword Length", HFILL}
753      },
754     {&hf_docsis_burst_scrambler_onoff,
755      {"11 Scrambler On/Off", "docsis_ucd.burst.scrambleronoff",
756       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
757       "Scrambler On/Off", HFILL}
758      },
759     {&hf_docsis_rs_int_depth,
760      {"12 RS Interleaver Depth", "docsis_ucd.burst.rsintdepth",
761       FT_UINT8, BASE_DEC, NULL, 0x0,
762       "R-S Interleaver Depth", HFILL}
763     },
764     {&hf_docsis_rs_int_block,
765      {"13 RS Interleaver Block Size", "docsis_ucd.burst.rsintblock",
766       FT_UINT8, BASE_DEC, NULL, 0x0,
767       "R-S Interleaver Block", HFILL}
768     },
769     {&hf_docsis_preamble_type,
770      {"14 Preamble Type", "docsis_ucd.burst.preambletype",
771       FT_UINT8, BASE_DEC, NULL, 0x0,
772       "Preamble Type", HFILL}
773     },
774     {&hf_docsis_scdma_scrambler_onoff,
775      {"15 SCDMA Scrambler On/Off", "docsis_ucd.burst.scdmascrambleronoff",
776       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
777       "SCDMA Scrambler On/Off", HFILL}
778     },
779     {&hf_docsis_scdma_codes_per_subframe,
780      {"16 SCDMA Codes per Subframe", "docsis_ucd.burst.scdmacodespersubframe",
781       FT_UINT8, BASE_DEC, NULL, 0x0,
782       "SCDMA Codes per Subframe", HFILL}
783     },
784     {&hf_docsis_scdma_framer_int_step_size,
785      {"17 SDMA Framer Int Step Size", "docsis_ucd.burst.scdmaframerintstepsize",
786       FT_UINT8, BASE_DEC, NULL, 0x0,
787       "SCDMA Framer Interleaving Step Size", HFILL}
788     },
789     {&hf_docsis_tcm_enabled,
790      {"18 TCM Enable", "docsis_ucd.burst.tcmenabled",
791       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
792       "TCM Enabled", HFILL}
793     },
794    };
795
796    /* Setup protocol subtree array */
797    static gint *ett[] = {
798       &ett_docsis_ucd,
799         &ett_tlv,
800    };
801
802    /* Register the protocol name and description */
803    proto_docsis_ucd =
804      proto_register_protocol ("DOCSIS Upstream Channel Descriptor",
805                               "DOCSIS UCD", "docsis_ucd");
806
807    /* Required function calls to register the header fields and subtrees used */
808    proto_register_field_array (proto_docsis_ucd, hf, array_length (hf));
809    proto_register_subtree_array (ett, array_length (ett));
810
811    register_dissector ("docsis_ucd", dissect_ucd, proto_docsis_ucd);
812 }
813
814
815 /* If this dissector uses sub-dissector registration add a registration routine.
816  This format is required because a script is used to find these routines and
817  create the code that calls these routines.
818  */
819 void
820 proto_reg_handoff_docsis_ucd (void)
821 {
822    dissector_handle_t docsis_ucd_handle;
823
824    docsis_ucd_handle = find_dissector ("docsis_ucd");
825    dissector_add_uint ("docsis_mgmt", 0x02, docsis_ucd_handle);
826
827 }