[docsis->type29ucd] Remove Type 4 Burst from Type 29 UCD
[metze/wireshark/wip.git] / plugins / docsis / packet-type29ucd.c
1 /* packet-type29ucd.c
2  *
3  * Routines for Type 29 UCD - DOCSIS 2.0 only - Message dissection
4  * Copyright 2015, Adrian Simionov <daniel.simionov@gmail.com>
5  * Copyright 2003, Brian Wheeler <brian.wheeler[AT]arrisi.com>
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 type29ucd_SYMBOL_RATE 1
32 #define type29ucd_FREQUENCY 2
33 #define type29ucd_PREAMBLE 3
34 #define type29ucd_BURST_DESCR5 5
35 #define type29ucd_EXT_PREAMBLE 6
36 #define type29ucd_SCDMA_MODE_ENABLE 7
37 #define type29ucd_SCDMA_SPREADING_INTERVAL 8
38 #define type29ucd_SCDMA_CODES_PER_MINI_SLOT 9
39 #define type29ucd_SCDMA_ACTIVE_CODES 10
40 #define type29ucd_SCDMA_CODE_HOPPING_SEED 11
41 #define type29ucd_SCDMA_US_RATIO_NUM 12
42 #define type29ucd_SCDMA_US_RATIO_DENOM 13
43 #define type29ucd_SCDMA_TIMESTAMP_SNAPSHOT 14
44 #define type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY 15
45 #define type29ucd_RANGING_REQUIRED 16
46
47 #define type29ucd_MODULATION 1
48 #define type29ucd_DIFF_ENCODING 2
49 #define type29ucd_PREAMBLE_LEN 3
50 #define type29ucd_PREAMBLE_VAL_OFF 4
51 #define type29ucd_FEC 5
52 #define type29ucd_FEC_CODEWORD 6
53 #define type29ucd_SCRAMBLER_SEED 7
54 #define type29ucd_MAX_BURST 8
55 #define type29ucd_GUARD_TIME 9
56 #define type29ucd_LAST_CW_LEN 10
57 #define type29ucd_SCRAMBLER_ONOFF 11
58 #define type29ucd_RS_INT_DEPTH 12
59 #define type29ucd_RS_INT_BLOCK 13
60 #define type29ucd_PREAMBLE_TYPE 14
61 #define type29ucd_SCMDA_SCRAMBLER_ONOFF 15
62 #define type29ucd_SCDMA_CODES_PER_SUBFRAME 16
63 #define type29ucd_SCDMA_FRAMER_INT_STEP_SIZE 17
64 #define type29ucd_TCM_ENABLED 18
65
66 #define IUC_REQUEST 1
67 #define IUC_REQ_DATA 2
68 #define IUC_INIT_MAINT 3
69 #define IUC_STATION_MAINT 4
70 #define IUC_SHORT_DATA_GRANT 5
71 #define IUC_LONG_DATA_GRANT 6
72 #define IUC_NULL_IE 7
73 #define IUC_DATA_ACK 8
74 #define IUC_ADV_PHY_SHORT_DATA_GRANT 9
75 #define IUC_ADV_PHY_LONG_DATA_GRANT 10
76 #define IUC_ADV_PHY_UGS 11
77 #define IUC_RESERVED12 12
78 #define IUC_RESERVED13 13
79 #define IUC_RESERVED14 14
80 #define IUC_EXPANSION 15
81
82 void proto_register_docsis_type29ucd(void);
83 void proto_reg_handoff_docsis_type29ucd(void);
84
85 /* Initialize the protocol and registered fields */
86 static int proto_docsis_type29ucd = -1;
87
88 static int hf_docsis_type29ucd_upstream_chid = -1;
89 static int hf_docsis_type29ucd_config_ch_cnt = -1;
90 static int hf_docsis_type29ucd_mini_slot_size = -1;
91 static int hf_docsis_type29ucd_down_chid = -1;
92 static int hf_docsis_type29ucd_symbol_rate = -1;
93 static int hf_docsis_type29ucd_frequency = -1;
94 static int hf_docsis_type29ucd_preamble_pat = -1;
95 static int hf_docsis_type29ucd_iuc = -1;
96 static int hf_docsis_type29ucd_ext_preamble = -1;
97 static int hf_docsis_type29ucd_scdma_mode_enable = -1;
98 static int hf_docsis_type29ucd_scdma_spreading_interval = -1;
99 static int hf_docsis_type29ucd_scdma_codes_per_mini_slot = -1;
100 static int hf_docsis_type29ucd_scdma_active_codes = -1;
101 static int hf_docsis_type29ucd_scdma_code_hopping_seed = -1;
102 static int hf_docsis_type29ucd_scdma_us_ratio_num = -1;
103 static int hf_docsis_type29ucd_scdma_us_ratio_denom = -1;
104 static int hf_docsis_type29ucd_scdma_timestamp_snapshot = -1;
105 static int hf_docsis_type29ucd_maintain_power_spectral_density = -1;
106 static int hf_docsis_type29ucd_ranging_required = -1;
107
108 static int hf_docsis_burst_mod_type = -1;
109 static int hf_docsis_burst_diff_encoding = -1;
110 static int hf_docsis_burst_preamble_len = -1;
111 static int hf_docsis_burst_preamble_val_off = -1;
112 static int hf_docsis_burst_fec = -1;
113 static int hf_docsis_burst_fec_codeword = -1;
114 static int hf_docsis_burst_scrambler_seed = -1;
115 static int hf_docsis_burst_max_burst = -1;
116 static int hf_docsis_burst_guard_time = -1;
117 static int hf_docsis_burst_last_cw_len = -1;
118 static int hf_docsis_burst_scrambler_onoff = -1;
119 static int hf_docsis_rs_int_depth = -1;
120 static int hf_docsis_rs_int_block = -1;
121 static int hf_docsis_preamble_type = -1;
122 static int hf_docsis_scdma_scrambler_onoff = -1;
123 static int hf_docsis_scdma_codes_per_subframe = -1;
124 static int hf_docsis_scdma_framer_int_step_size = -1;
125 static int hf_docsis_tcm_enabled = -1;
126
127
128 /* Initialize the subtree pointers */
129 static gint ett_docsis_type29ucd = -1;
130 static gint ett_burst_descr = -1;
131
132 static const value_string channel_tlv_vals[] _U_ = {
133   {type29ucd_SYMBOL_RATE,                     "Symbol Rate"},
134   {type29ucd_FREQUENCY,                       "Frequency"},
135   {type29ucd_PREAMBLE,                        "Preamble Pattern"},
136   {type29ucd_BURST_DESCR5,                    "Burst Descriptor DOCSIS 2.0"},
137   {type29ucd_EXT_PREAMBLE,                    "Extended Preamble Pattern"},
138   {type29ucd_SCDMA_MODE_ENABLE,               "SCDMA Mode Enabled"},
139   {type29ucd_SCDMA_SPREADING_INTERVAL,        "SCDMA Spreading Intervals per Frame"},
140   {type29ucd_SCDMA_CODES_PER_MINI_SLOT,       "SCDMA Codes per Mini-slot"},
141   {type29ucd_SCDMA_ACTIVE_CODES,              "SCDMA Number of Active Codes"},
142   {type29ucd_SCDMA_CODE_HOPPING_SEED,         "SCDMA Code Hopping Seed"},
143   {type29ucd_SCDMA_US_RATIO_NUM,              "SCDMA US ratio numerator M"},
144   {type29ucd_SCDMA_US_RATIO_DENOM,            "SCDMA US ratio denominator N"},
145   {type29ucd_SCDMA_TIMESTAMP_SNAPSHOT,        "SCDMA Timestamp Snapshot"},
146   {type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY, "Maintain Power Spectral Density"},
147   {type29ucd_RANGING_REQUIRED,                "Ranging Required"},
148   {0, NULL}
149 };
150
151 static const value_string on_off_vals[] = {
152   {1, "On"},
153   {2, "Off"},
154   {0, NULL}
155 };
156
157 static const value_string mod_vals2[] = {
158   {1, "QPSK"},
159   {2, "QAM16"},
160   {3, "QAM8"},
161   {4, "QAM32"},
162   {5, "QAM64"},
163   {6, "QAM128 (S-CDMA)"},
164   {0, NULL}
165 };
166
167 value_string iuc_vals2[] = {
168   {IUC_REQUEST,                  "Request"},
169   {IUC_REQ_DATA,                 "REQ/Data"},
170   {IUC_INIT_MAINT,               "Initial Maintenance"},
171   {IUC_STATION_MAINT,            "Station Maintenance"},
172   {IUC_SHORT_DATA_GRANT,         "Short Data Grant"},
173   {IUC_LONG_DATA_GRANT,          "Long Data Grant"},
174   {IUC_NULL_IE,                  "NULL IE"},
175   {IUC_DATA_ACK,                 "Data Ack"},
176   {IUC_ADV_PHY_SHORT_DATA_GRANT, "Advanced Phy Short Data Grant"},
177   {IUC_ADV_PHY_LONG_DATA_GRANT,  "Advanced Phy Long Data Grant"},
178   {IUC_ADV_PHY_UGS,              "Advanced Phy UGS"},
179   {IUC_RESERVED12,               "Reserved 12"},
180   {IUC_RESERVED13,               "Reserved 13"},
181   {IUC_RESERVED14,               "Reserved 14"},
182   {IUC_EXPANSION,                "IUC Expansion"},
183   {0, NULL}
184 };
185
186 static const value_string last_cw_len_vals[] = {
187   {1, "Fixed"},
188   {2, "Shortened"},
189   {0, NULL}
190 };
191
192 /* Dissection */
193 static int
194 dissect_type29ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
195 {
196   guint16 pos, endtlvpos;
197   guint8 type, length;
198   guint8 tlvlen, tlvtype;
199   proto_tree *burst_descr_tree;
200   proto_tree *type29ucd_tree;
201   proto_item *type29ucd_item;
202   guint16 len;
203   guint8 upchid, symrate;
204
205   len = tvb_reported_length(tvb);
206   upchid = tvb_get_guint8 (tvb, 0);
207
208   /* if the upstream Channel ID is 0 then this is for Telephony Return) */
209   if (upchid > 0)
210     col_add_fstr (pinfo->cinfo, COL_INFO,
211                   "type29ucd Message:  Channel ID = %u (U%u)", upchid,
212                   upchid - 1);
213   else
214     col_add_fstr (pinfo->cinfo, COL_INFO,
215                   "type29ucd Message:  Channel ID = %u (Telephony Return)",
216                   upchid);
217
218   if (tree)
219     {
220       type29ucd_item =
221         proto_tree_add_protocol_format (tree, proto_docsis_type29ucd, tvb, 0,
222                                         tvb_captured_length(tvb),
223                                         "type29ucd Message");
224       type29ucd_tree = proto_item_add_subtree (type29ucd_item, ett_docsis_type29ucd);
225       proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_upstream_chid, tvb, 0, 1,
226                            ENC_BIG_ENDIAN);
227       proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_config_ch_cnt, tvb, 1, 1,
228                            ENC_BIG_ENDIAN);
229       proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_mini_slot_size, tvb, 2, 1,
230                            ENC_BIG_ENDIAN);
231       proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_down_chid, tvb, 3, 1,
232                            ENC_BIG_ENDIAN);
233
234       pos = 4;
235       while (pos < len)
236         {
237           type = tvb_get_guint8 (tvb, pos++);
238           length = tvb_get_guint8 (tvb, pos++);
239           switch (type)
240             {
241               case type29ucd_SYMBOL_RATE:
242                 if (length == 1)
243                   {
244                     symrate = tvb_get_guint8 (tvb, pos);
245                     proto_tree_add_uint (type29ucd_tree, hf_docsis_type29ucd_symbol_rate,
246                                          tvb, pos, length, symrate * 160);
247                   }
248                 else
249                   {
250                     THROW (ReportedBoundsError);
251                   }
252                 pos = pos + length;
253                 break;
254               case type29ucd_FREQUENCY:
255                 if (length == 4)
256                   {
257                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_frequency, tvb,
258                                          pos, length, ENC_BIG_ENDIAN);
259                     pos = pos + length;
260                   }
261                 else
262                   {
263                     THROW (ReportedBoundsError);
264                   }
265                 break;
266               case type29ucd_PREAMBLE:
267                 proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_preamble_pat, tvb,
268                                      pos, length, ENC_NA);
269                 pos = pos + length;
270                 break;
271                 /* DOCSIS 2.0 UCD TLV definitions
272                  * #define type29ucd_EXT_PREAMBLE 6
273                  * #define type29ucd_SCDMA_MODE_ENABLE 7
274                  * #define type29ucd_SCDMA_SPREADING_INTERVAL 8
275                  * #define type29ucd_SCDMA_CODES_PER_MINI_SLOT 9
276                  * #define type29ucd_SCDMA_ACTIVE_CODES 10
277                  * #define type29ucd_SCDMA_CODE_HOPPING_SEED 11
278                  * #define type29ucd_SCDMA_US_RATIO_NUM 12
279                  * #define type29ucd_SCDMA_US_RATIO_DENOM 13
280                  * #define type29ucd_SCDMA_TIMESTAMP_SNAPSHOT 14
281                  * #define type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY 15
282                  * #define type29ucd_RANGING_REQUIRED 16
283                  */
284               case type29ucd_EXT_PREAMBLE:
285                 proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_ext_preamble, tvb,
286                                      pos, length, ENC_NA);
287                 pos = pos + length;
288                 break;
289               case type29ucd_SCDMA_MODE_ENABLE:
290                 if (length == 1)
291                   {
292                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_mode_enable,
293                                          tvb, pos, length, ENC_NA);
294                   }
295                 else
296                   {
297                     THROW (ReportedBoundsError);
298                   }
299                 pos = pos + length;
300                 break;
301               case type29ucd_SCDMA_SPREADING_INTERVAL:
302                 if (length == 1)
303                   {
304                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_spreading_interval,
305                                          tvb, pos, length, ENC_NA);
306                   }
307                 else
308                   {
309                     THROW (ReportedBoundsError);
310                   }
311                 pos = pos + length;
312                 break;
313               case type29ucd_SCDMA_CODES_PER_MINI_SLOT:
314                 if (length == 1)
315                   {
316                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_codes_per_mini_slot,
317                                          tvb, pos, length, ENC_NA);
318                   }
319                 else
320                   {
321                     THROW (ReportedBoundsError);
322                   }
323                 pos = pos + length;
324                 break;
325               case type29ucd_SCDMA_ACTIVE_CODES:
326                 if (length == 1)
327                   {
328                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_active_codes,
329                                          tvb, pos, length, ENC_NA);
330                   }
331                 else
332                   {
333                     THROW (ReportedBoundsError);
334                   }
335                 pos = pos + length;
336                 break;
337               case type29ucd_SCDMA_CODE_HOPPING_SEED:
338                 if (length == 2)
339                   {
340                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_code_hopping_seed,
341                                          tvb, pos, length, ENC_NA);
342                   }
343                 else
344                   {
345                     THROW (ReportedBoundsError);
346                   }
347                 pos = pos + length;
348                 break;
349               case type29ucd_SCDMA_US_RATIO_NUM:
350                 if (length == 2)
351                   {
352                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_us_ratio_num,
353                                          tvb, pos, length, ENC_NA);
354                   }
355                 else
356                   {
357                     THROW (ReportedBoundsError);
358                   }
359                 pos = pos + length;
360                 break;
361               case type29ucd_SCDMA_US_RATIO_DENOM:
362                 if (length == 2)
363                   {
364                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_us_ratio_denom,
365                                          tvb, pos, length, ENC_NA);
366                   }
367                 else
368                   {
369                     THROW (ReportedBoundsError);
370                   }
371                 pos = pos + length;
372                 break;
373               case type29ucd_SCDMA_TIMESTAMP_SNAPSHOT:
374                 if (length == 9)
375                   {
376                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_scdma_timestamp_snapshot,
377                                          tvb, pos, length, ENC_NA);
378                   }
379                 else
380                   {
381                     THROW (ReportedBoundsError);
382                   }
383                 pos = pos + length;
384                 break;
385               case type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY:
386                 if (length == 1)
387                   {
388                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_maintain_power_spectral_density,
389                                          tvb, pos, length, ENC_NA);
390                   }
391                 else
392                   {
393                     THROW (ReportedBoundsError);
394                   }
395                 pos = pos + length;
396                 break;
397               case type29ucd_RANGING_REQUIRED:
398                 if (length == 1)
399                   {
400                     proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_ranging_required,
401                                          tvb, pos, length, ENC_NA);
402                   }
403                 else
404                   {
405                     THROW (ReportedBoundsError);
406                   }
407                 pos = pos + length;
408                 break;
409               case type29ucd_BURST_DESCR5:
410                 burst_descr_tree =
411                   proto_tree_add_subtree_format(type29ucd_tree, tvb, pos, length,
412                                                 ett_burst_descr, NULL, "5 Burst Descriptor (Length = %u)",
413                                                 length);
414                 proto_tree_add_item (burst_descr_tree, hf_docsis_type29ucd_iuc, tvb,
415                                      pos++, 1, ENC_BIG_ENDIAN);
416                 endtlvpos = pos + length - 1;
417                 while (pos < endtlvpos)
418                   {
419                     tlvtype = tvb_get_guint8 (tvb, pos++);
420                     tlvlen = tvb_get_guint8 (tvb, pos++);
421                     switch (tlvtype)
422                       {
423                         case type29ucd_MODULATION:
424                           if (tlvlen == 1)
425                             {
426                               proto_tree_add_item (burst_descr_tree,
427                                                    hf_docsis_burst_mod_type, tvb,
428                                                    pos, tlvlen, ENC_BIG_ENDIAN);
429                             }
430                           else
431                             {
432                               THROW (ReportedBoundsError);
433                             }
434                           break;
435                         case type29ucd_DIFF_ENCODING:
436                           if (tlvlen == 1)
437                             {
438                               proto_tree_add_item (burst_descr_tree,
439                                                    hf_docsis_burst_diff_encoding,
440                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
441                             }
442                           else
443                             {
444                               THROW (ReportedBoundsError);
445                             }
446                           break;
447                         case type29ucd_PREAMBLE_LEN:
448                           if (tlvlen == 2)
449                             {
450                               proto_tree_add_item (burst_descr_tree,
451                                                    hf_docsis_burst_preamble_len,
452                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
453                             }
454                           else
455                             {
456                               THROW (ReportedBoundsError);
457                             }
458                           break;
459                         case type29ucd_PREAMBLE_VAL_OFF:
460                           if (tlvlen == 2)
461                             {
462                               proto_tree_add_item (burst_descr_tree,
463                                                    hf_docsis_burst_preamble_val_off,
464                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
465                             }
466                           else
467                             {
468                               THROW (ReportedBoundsError);
469                             }
470                           break;
471                         case type29ucd_FEC:
472                           if (tlvlen == 1)
473                             {
474                               proto_tree_add_item (burst_descr_tree,
475                                                    hf_docsis_burst_fec, tvb, pos,
476                                                    tlvlen, ENC_BIG_ENDIAN);
477                             }
478                           else
479                             {
480                               THROW (ReportedBoundsError);
481                             }
482                           break;
483                         case type29ucd_FEC_CODEWORD:
484                           if (tlvlen == 1)
485                             {
486                               proto_tree_add_item (burst_descr_tree,
487                                                    hf_docsis_burst_fec_codeword,
488                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
489                             }
490                           else
491                             {
492                               THROW (ReportedBoundsError);
493                             }
494                           break;
495                         case type29ucd_SCRAMBLER_SEED:
496                           if (tlvlen == 2)
497                             {
498                               proto_tree_add_item (burst_descr_tree,
499                                                    hf_docsis_burst_scrambler_seed,
500                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
501                             }
502                           else
503                             {
504                               THROW (ReportedBoundsError);
505                             }
506                           break;
507                         case type29ucd_MAX_BURST:
508                           if (tlvlen == 1)
509                             {
510                               proto_tree_add_item (burst_descr_tree,
511                                                    hf_docsis_burst_max_burst, tvb,
512                                                    pos, tlvlen, ENC_BIG_ENDIAN);
513                             }
514                           else
515                             {
516                               THROW (ReportedBoundsError);
517                             }
518                           break;
519                         case type29ucd_GUARD_TIME:
520                           if (tlvlen == 1)
521                             {
522                               proto_tree_add_item (burst_descr_tree,
523                                                    hf_docsis_burst_guard_time,
524                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
525                             }
526                           else
527                             {
528                               THROW (ReportedBoundsError);
529                             }
530                           break;
531                         case type29ucd_LAST_CW_LEN:
532                           if (tlvlen == 1)
533                             {
534                               proto_tree_add_item (burst_descr_tree,
535                                                    hf_docsis_burst_last_cw_len,
536                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
537                             }
538                           else
539                             {
540                               THROW (ReportedBoundsError);
541                             }
542                           break;
543                         case type29ucd_SCRAMBLER_ONOFF:
544                           if (tlvlen == 1)
545                             {
546                               proto_tree_add_item (burst_descr_tree,
547                                                    hf_docsis_burst_scrambler_onoff,
548                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
549                             }
550                           else
551                             {
552                               THROW (ReportedBoundsError);
553                             }
554                           break;
555                           /* New cases added for DOCSIS 2.0 US Physical Burst Descriptor TLV */
556                           /* #define type29ucd_RS_INT_DEPTH 12
557                            * #define type29ucd_RS_INT_BLOCK 13
558                            * #define type29ucd_PREAMBLE_TYPE 14
559                            * #define type29ucd_SCMDA_SCRAMBLER_ONOFF 15
560                            * #define type29ucd_SCDMA_CODES_PER_SUBFRAME 16
561                            * #define type29ucd_SCDMA_FRAMER_INT_STEP_SIZE 17
562                            * #define type29ucd_TCM_ENABLED 18
563                            */
564                         case type29ucd_RS_INT_DEPTH:
565                           if (tlvlen == 1)
566                             {
567                               proto_tree_add_item (burst_descr_tree,
568                                                    hf_docsis_rs_int_depth,
569                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
570                             }
571                           else
572                             {
573                               THROW (ReportedBoundsError);
574                             }
575                           break;
576                         case type29ucd_RS_INT_BLOCK:
577                           if (tlvlen == 2)
578                             {
579                               proto_tree_add_item (burst_descr_tree,
580                                                    hf_docsis_rs_int_block,
581                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
582                             }
583                           else
584                             {
585                               THROW (ReportedBoundsError);
586                             }
587                           break;
588                         case type29ucd_PREAMBLE_TYPE:
589                           if (tlvlen == 1)
590                             {
591                               proto_tree_add_item (burst_descr_tree,
592                                                    hf_docsis_preamble_type,
593                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
594                             }
595                           else
596                             {
597                               THROW (ReportedBoundsError);
598                             }
599                           break;
600                         case type29ucd_SCMDA_SCRAMBLER_ONOFF:
601                           if (tlvlen == 1)
602                             {
603                               proto_tree_add_item (burst_descr_tree,
604                                                    hf_docsis_scdma_scrambler_onoff,
605                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
606                             }
607                           else
608                             {
609                               THROW (ReportedBoundsError);
610                             }
611                           break;
612                         case type29ucd_SCDMA_CODES_PER_SUBFRAME:
613                           if (tlvlen == 1)
614                             {
615                               proto_tree_add_item (burst_descr_tree,
616                                                    hf_docsis_scdma_codes_per_subframe,
617                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
618                             }
619                           else
620                             {
621                               THROW (ReportedBoundsError);
622                             }
623                           break;
624                         case type29ucd_SCDMA_FRAMER_INT_STEP_SIZE:
625                           if (tlvlen == 1)
626                             {
627                               proto_tree_add_item (burst_descr_tree,
628                                                    hf_docsis_scdma_framer_int_step_size,
629                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
630                             }
631                           else
632                             {
633                               THROW (ReportedBoundsError);
634                             }
635                           break;
636                         case type29ucd_TCM_ENABLED:
637                           if (tlvlen == 1)
638                             {
639                               proto_tree_add_item (burst_descr_tree,
640                                                    hf_docsis_tcm_enabled,
641                                                    tvb, pos, tlvlen, ENC_BIG_ENDIAN);
642                             }
643                           else
644                             {
645                               THROW (ReportedBoundsError);
646                             }
647                           break;
648                           /* End of DOCSIS 2.0 US burst Descriptor Changes */
649                       }         /* switch(tlvtype) */
650                     pos = pos + tlvlen;
651                   }             /* while (pos < endtlvpos) */
652                 break;
653             }                   /* switch(type) */
654         }                       /* while (pos < len) */
655     }                           /* if (tree) */
656
657     return tvb_captured_length(tvb);
658 }
659
660 /* Register the protocol with Wireshark */
661 void
662 proto_register_docsis_type29ucd (void)
663 {
664   static hf_register_info hf[] = {
665     {&hf_docsis_type29ucd_upstream_chid,
666      {"Upstream Channel ID", "docsis_type29ucd.upchid",
667       FT_UINT8, BASE_DEC, NULL, 0x0,
668       NULL, HFILL}
669     },
670     {&hf_docsis_type29ucd_config_ch_cnt,
671      {"Config Change Count", "docsis_type29ucd.confcngcnt",
672       FT_UINT8, BASE_DEC, NULL, 0x0,
673       "Configuration Change Count", HFILL}
674     },
675     {&hf_docsis_type29ucd_mini_slot_size,
676      {"Mini Slot Size (6.25us TimeTicks)", "docsis_type29ucd.mslotsize",
677       FT_UINT8, BASE_DEC, NULL, 0x0,
678       NULL, HFILL}
679     },
680     {&hf_docsis_type29ucd_down_chid,
681      {"Downstream Channel ID", "docsis_type29ucd.downchid",
682       FT_UINT8, BASE_DEC, NULL, 0x0,
683       "Management Message", HFILL}
684     },
685     {&hf_docsis_type29ucd_symbol_rate,
686      {"1 Symbol Rate (ksym/sec)", "docsis_type29ucd.symrate",
687       FT_UINT8, BASE_DEC, NULL, 0x0,
688       "Symbol Rate", HFILL}
689     },
690     {&hf_docsis_type29ucd_frequency,
691      {"2 Frequency (Hz)", "docsis_type29ucd.freq",
692       FT_UINT32, BASE_DEC, NULL, 0x0,
693       "Upstream Center Frequency", HFILL}
694     },
695     {&hf_docsis_type29ucd_preamble_pat,
696      {"3 Preamble Pattern", "docsis_type29ucd.preamble",
697       FT_BYTES, BASE_NONE, NULL, 0x0,
698       "Preamble Superstring", HFILL}
699     },
700     {&hf_docsis_type29ucd_iuc,
701      {"Interval Usage Code", "docsis_type29ucd.iuc",
702       FT_UINT8, BASE_DEC, VALS (iuc_vals2), 0x0,
703       NULL, HFILL}
704     },
705     {&hf_docsis_burst_mod_type,
706      {"1 Modulation Type", "docsis_type29ucd.burst.modtype",
707       FT_UINT8, BASE_DEC, VALS (mod_vals2), 0x0,
708       "Modulation Type", HFILL}
709     },
710     {&hf_docsis_burst_diff_encoding,
711      {"2 Differential Encoding", "docsis_type29ucd.burst.diffenc",
712       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
713       "Differential Encoding", HFILL}
714     },
715     {&hf_docsis_burst_preamble_len,
716      {"3 Preamble Length (Bits)", "docsis_type29ucd.burst.preamble_len",
717       FT_UINT16, BASE_DEC, NULL, 0x0,
718       "Preamble Length (Bits)", HFILL}
719     },
720     {&hf_docsis_burst_preamble_val_off,
721      {"4 Preamble Offset (Bits)", "docsis_type29ucd.burst.preamble_off",
722       FT_UINT16, BASE_DEC, NULL, 0x0,
723       "Preamble Offset (Bits)", HFILL}
724     },
725     {&hf_docsis_burst_fec,
726      {"5 FEC (T)", "docsis_type29ucd.burst.fec",
727       FT_UINT8, BASE_DEC, NULL, 0x0,
728       "FEC (T) Codeword Parity Bits = 2^T", HFILL}
729     },
730     {&hf_docsis_burst_fec_codeword,
731      {"6 FEC Codeword Info bytes (k)", "docsis_type29ucd.burst.fec_codeword",
732       FT_UINT8, BASE_DEC, NULL, 0x0,
733       "FEC Codeword Info Bytes (k)", HFILL}
734     },
735     {&hf_docsis_burst_scrambler_seed,
736      {"7 Scrambler Seed", "docsis_type29ucd.burst.scrambler_seed",
737       FT_UINT16, BASE_HEX, NULL, 0x0,
738       "Burst Descriptor", HFILL}
739     },
740     {&hf_docsis_burst_max_burst,
741      {"8 Max Burst Size (Minislots)", "docsis_type29ucd.burst.maxburst",
742       FT_UINT8, BASE_DEC, NULL, 0x0,
743       "Max Burst Size (Minislots)", HFILL}
744     },
745     {&hf_docsis_burst_guard_time,
746      {"9 Guard Time Size (Symbol Times)", "docsis_type29ucd.burst.guardtime",
747       FT_UINT8, BASE_DEC, NULL, 0x0,
748       "Guard Time Size", HFILL}
749     },
750     {&hf_docsis_burst_last_cw_len,
751      {"10 Last Codeword Length", "docsis_type29ucd.burst.last_cw_len",
752       FT_UINT8, BASE_DEC, VALS (last_cw_len_vals), 0x0,
753       "Last Codeword Length", HFILL}
754     },
755     {&hf_docsis_burst_scrambler_onoff,
756      {"11 Scrambler On/Off", "docsis_type29ucd.burst.scrambleronoff",
757       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
758       "Scrambler On/Off", HFILL}
759     },
760     /* DOCSIS 2.0 UCD TLV definitions
761      *  * #define type29ucd_EXT_PREAMBLE 6
762      *  * #define type29ucd_SCDMA_MODE_ENABLE 7
763      *  * #define type29ucd_SCDMA_SPREADING_INTERVAL 8
764      *  * #define type29ucd_SCDMA_CODES_PER_MINI_SLOT 9
765      *  * #define type29ucd_SCDMA_ACTIVE_CODES 10
766      *  * #define type29ucd_SCDMA_CODE_HOPPING_SEED 11
767      *  * #define type29ucd_SCDMA_US_RATIO_NUM 12
768      *  * #define type29ucd_SCDMA_US_RATIO_DENOM 13
769      *  * #define type29ucd_SCDMA_TIMESTAMP_SNAPSHOT 14
770      *  * #define type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY 15
771      *  * #define type29ucd_RANGING_REQUIRED 16
772      *  */
773     {&hf_docsis_type29ucd_ext_preamble,
774      {"6 Extended Preamble Pattern", "docsis_type29ucd.extpreamble",
775       FT_BYTES, BASE_NONE, NULL, 0x0,
776       "Extended Preamble Pattern", HFILL}
777     },
778     {&hf_docsis_type29ucd_scdma_mode_enable,
779      {"7 SCDMA Mode Enable", "docsis_type29ucd.scdmaenable",
780       FT_BYTES, BASE_NONE, NULL, 0x0,
781       "SCDMA Mode Enable", HFILL}
782     },
783     {&hf_docsis_type29ucd_scdma_spreading_interval,
784      {"8 SCDMA Spreading Interval", "docsis_type29ucd.scdmaspreadinginterval",
785       FT_BYTES, BASE_NONE, NULL, 0x0,
786       "SCDMA Spreading Interval", HFILL}
787     },
788     {&hf_docsis_type29ucd_scdma_codes_per_mini_slot,
789      {"9 SCDMA Codes per mini slot", "docsis_type29ucd.scdmacodesperminislot",
790       FT_BYTES, BASE_NONE, NULL, 0x0,
791       "SCDMA Codes per mini slot", HFILL}
792     },
793     {&hf_docsis_type29ucd_scdma_active_codes,
794      {"10 SCDMA Active Codes", "docsis_type29ucd.scdmaactivecodes",
795       FT_BYTES, BASE_NONE, NULL, 0x0,
796       "SCDMA Active Codes", HFILL}
797     },
798     {&hf_docsis_type29ucd_scdma_code_hopping_seed,
799      {"11 SCDMA Code Hopping Seed", "docsis_type29ucd.scdmacodehoppingseed",
800       FT_BYTES, BASE_NONE, NULL, 0x0,
801       "SCDMA Code Hopping Seed", HFILL}
802     },
803     {&hf_docsis_type29ucd_scdma_us_ratio_num,
804      {"12 SCDMA US Ratio Numerator", "docsis_type29ucd.scdmausrationum",
805       FT_BYTES, BASE_NONE, NULL, 0x0,
806       "SCDMA US Ratio Numerator", HFILL}
807     },
808     {&hf_docsis_type29ucd_scdma_us_ratio_denom,
809      {"13 SCDMA US Ratio Denominator", "docsis_type29ucd.scdmausratiodenom",
810       FT_BYTES, BASE_NONE, NULL, 0x0,
811       "SCDMA US Ratio Denominator", HFILL}
812     },
813     {&hf_docsis_type29ucd_scdma_timestamp_snapshot,
814      {"14 SCDMA Timestamp Snapshot", "docsis_type29ucd.scdmatimestamp",
815       FT_BYTES, BASE_NONE, NULL, 0x0,
816       "SCDMA Timestamp Snapshot", HFILL}
817     },
818     {&hf_docsis_type29ucd_maintain_power_spectral_density,
819      {"15 Maintain power spectral density", "docsis_type29ucd.maintainpowerspectraldensity",
820       FT_BYTES, BASE_NONE, NULL, 0x0,
821       "Maintain power spectral density", HFILL}
822     },
823     {&hf_docsis_type29ucd_ranging_required,
824      {"16 Ranging Required", "docsis_type29ucd.rangingrequired",
825       FT_BYTES, BASE_NONE, NULL, 0x0,
826       "Ranging Required", HFILL}
827     },
828     /* #define type29ucd_RS_INT_DEPTH 12
829      * #define type29ucd_RS_INT_BLOCK 13
830      * #define type29ucd_PREAMBLE_TYPE 14
831      * #define type29ucd_SCMDA_SCRAMBLER_ONOFF 15
832      * #define type29ucd_SCDMA_CODES_PER_SUBFRAME 16
833      * #define type29ucd_SCDMA_FRAMER_INT_STEP_SIZE 17
834      * #define type29ucd_TCM_ENABLED 18
835      */
836     {&hf_docsis_rs_int_depth,
837      {"12 Scrambler On/Off", "docsis_type29ucd.burst.rsintdepth",
838       FT_UINT8, BASE_DEC, NULL, 0x0,
839       "R-S Interleaver Depth", HFILL}
840     },
841     {&hf_docsis_rs_int_block,
842      {"13 Scrambler On/Off", "docsis_type29ucd.burst.rsintblock",
843       FT_UINT8, BASE_DEC, NULL, 0x0,
844       "R-S Interleaver Block", HFILL}
845     },
846     {&hf_docsis_preamble_type,
847      {"14 Scrambler On/Off", "docsis_type29ucd.burst.preambletype",
848       FT_UINT8, BASE_DEC, NULL, 0x0,
849       "Preamble Type", HFILL}
850     },
851     {&hf_docsis_scdma_scrambler_onoff,
852      {"15 Scrambler On/Off", "docsis_type29ucd.burst.scdmascrambleronoff",
853       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
854       "SCDMA Scrambler On/Off", HFILL}
855     },
856     {&hf_docsis_scdma_codes_per_subframe,
857      {"16 Scrambler On/Off", "docsis_type29ucd.burst.scdmacodespersubframe",
858       FT_UINT8, BASE_DEC, NULL, 0x0,
859       "SCDMA Codes per Subframe", HFILL}
860     },
861     {&hf_docsis_scdma_framer_int_step_size,
862      {"17 Scrambler On/Off", "docsis_type29ucd.burst.scdmaframerintstepsize",
863       FT_UINT8, BASE_DEC, NULL, 0x0,
864       "SCDMA Framer Interleaving Step Size", HFILL}
865     },
866     {&hf_docsis_tcm_enabled,
867      {"18 Scrambler On/Off", "docsis_type29ucd.burst.tcmenabled",
868       FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
869       "TCM Enabled", HFILL}
870     },
871   };
872
873   static gint *ett[] = {
874     &ett_docsis_type29ucd,
875     &ett_burst_descr,
876   };
877
878   proto_docsis_type29ucd =
879     proto_register_protocol ("DOCSIS Upstream Channel Descriptor Type 29",
880                              "DOCSIS type29ucd", "docsis_type29ucd");
881
882   proto_register_field_array (proto_docsis_type29ucd, hf, array_length (hf));
883   proto_register_subtree_array (ett, array_length (ett));
884
885   new_register_dissector ("docsis_type29ucd", dissect_type29ucd, proto_docsis_type29ucd);
886 }
887
888 void
889 proto_reg_handoff_docsis_type29ucd (void)
890 {
891   dissector_handle_t docsis_type29ucd_handle;
892
893   docsis_type29ucd_handle = find_dissector ("docsis_type29ucd");
894   dissector_add_uint ("docsis_mgmt", 0x1D, docsis_type29ucd_handle);
895 }
896
897 /*
898  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
899  *
900  * Local Variables:
901  * c-basic-offset: 2
902  * tab-width: 8
903  * indent-tabs-mode: nil
904  * End:
905  *
906  * ex: set shiftwidth=2 tabstop=8 expandtab:
907  * :indentSize=2:tabSize=8:noTabs=true:
908  */