aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/docsis/packet-type51ucd.c
blob: 25573672185cd93de5782c7cdd0f6fdc5060fb54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
/* packet-type51ucd.c
 *
 * Routines for Type 51 UCD - DOCSIS 3.1 only - Message dissection
 * Copyright 2016, Bruno Verstuyft <bruno.verstuyft@excentis.com>
 * Based on packet-type35ucd.c (Copyright 2015, Adrian Simionov <daniel.simionov@gmail.com>)
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "config.h"

#include <epan/packet.h>
#include <epan/expert.h>

#define type51ucd_SYMBOL_RATE 1
#define type51ucd_FREQUENCY 2
#define type51ucd_PREAMBLE 3
#define type51ucd_EXT_PREAMBLE 6
#define type51ucd_SCDMA_MODE_ENABLE 7
#define type51ucd_SCDMA_SPREADING_INTERVAL 8
#define type51ucd_SCDMA_CODES_PER_MINI_SLOT 9
#define type51ucd_SCDMA_ACTIVE_CODES 10
#define type51ucd_SCDMA_CODE_HOPPING_SEED 11
#define type51ucd_SCDMA_US_RATIO_NUM 12
#define type51ucd_SCDMA_US_RATIO_DENOM 13
#define type51ucd_SCDMA_TIMESTAMP_SNAPSHOT 14
#define type51ucd_MAINTAIN_POWER_SPECTRAL_DENSITY 15
#define type51ucd_RANGING_REQUIRED 16
#define type51ucd_MAX_SCHEDULED_CODES 17
#define type51ucd_RANGING_HOLD_OFF_PRIORITY_FIELD 18
#define type51ucd_RANGING_CHANNEL_CLASS_ID 19
#define type51ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING 20
#define type51ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES 21
#define type51ucd_HIGHER_UCD_FOR_SAME_UCID 22
#define type51ucd_BURST_DESCR23 23
#define type51ucd_UCD_CHANGE_IND_BITMASK 24
#define type51ucd_OFDMA_TIMESTAMP_SNAPSHOT 25
#define type51ucd_OFDMA_CYCLIC_PREFIX_SIZE 26
#define type51ucd_OFDMA_ROLLOFF_PERIOD_SIZE 27
#define type51ucd_SUBCARRIER_SPACING 28
#define type51ucd_CENTER_FREQ_SUBC_0 29
#define type51ucd_SUBC_EXCL_BAND 30
#define type51ucd_UNUSED_SUBC_SPEC 31
#define type51ucd_SYMB_IN_OFDMA_FRAME 32
#define type51ucd_RAND_SEED 33


#define type51ucd_MODULATION 1
#define type51ucd_DIFF_ENCODING 2
#define type51ucd_PREAMBLE_LEN 3
#define type51ucd_PREAMBLE_VAL_OFF 4
#define type51ucd_FEC 5
#define type51ucd_FEC_CODEWORD 6
#define type51ucd_SCRAMBLER_SEED 7
#define type51ucd_MAX_BURST 8
#define type51ucd_GUARD_TIME 9
#define type51ucd_LAST_CW_LEN 10
#define type51ucd_SCRAMBLER_ONOFF 11
#define type51ucd_RS_INT_DEPTH 12
#define type51ucd_RS_INT_BLOCK 13
#define type51ucd_PREAMBLE_TYPE 14
#define type51ucd_SCMDA_SCRAMBLER_ONOFF 15
#define type51ucd_SCDMA_CODES_PER_SUBFRAME 16
#define type51ucd_SCDMA_FRAMER_INT_STEP_SIZE 17
#define type51ucd_TCM_ENABLED 18
#define type51ucd_SUBC_INIT_RANG 19
#define type51ucd_SUBC_FINE_RANG 20
#define type51ucd_OFDMA_PROFILE 21
#define type51ucd_OFDMA_IR_POWER_CONTROL 22

#define IUC_REQUEST 1
#define IUC_REQ_DATA 2
#define IUC_INIT_MAINT 3
#define IUC_STATION_MAINT 4
#define IUC_SHORT_DATA_GRANT 5
#define IUC_LONG_DATA_GRANT 6
#define IUC_NULL_IE 7
#define IUC_DATA_ACK 8
#define IUC_ADV_PHY_SHORT_DATA_GRANT 9
#define IUC_ADV_PHY_LONG_DATA_GRANT 10
#define IUC_ADV_PHY_UGS 11
#define IUC_RESERVED12 12
#define IUC_RESERVED13 13
#define IUC_RESERVED14 14
#define IUC_EXPANSION 15

void proto_register_docsis_type51ucd(void);
void proto_reg_handoff_docsis_type51ucd(void);

/* Initialize the protocol and registered fields */
static int proto_docsis_type51ucd = -1;

static int hf_docsis_type51ucd_upstream_chid = -1;
static int hf_docsis_type51ucd_config_ch_cnt = -1;
static int hf_docsis_type51ucd_mini_slot_size = -1;
static int hf_docsis_type51ucd_down_chid = -1;
static int hf_docsis_type51ucd_type = -1;
static int hf_docsis_type51ucd_length = -1;
static int hf_docsis_type51ucd_burst_type = -1;
static int hf_docsis_type51ucd_burst_length = -1;
static int hf_docsis_type51ucd_symbol_rate = -1;
static int hf_docsis_type51ucd_frequency = -1;
static int hf_docsis_type51ucd_preamble_pat = -1;
static int hf_docsis_type51ucd_iuc = -1;
static int hf_docsis_type51ucd_ext_preamble = -1;
static int hf_docsis_type51ucd_scdma_mode_enable = -1;
static int hf_docsis_type51ucd_scdma_spreading_interval = -1;
static int hf_docsis_type51ucd_scdma_codes_per_mini_slot = -1;
static int hf_docsis_type51ucd_scdma_active_codes = -1;
static int hf_docsis_type51ucd_scdma_code_hopping_seed = -1;
static int hf_docsis_type51ucd_scdma_us_ratio_num = -1;
static int hf_docsis_type51ucd_scdma_us_ratio_denom = -1;
static int hf_docsis_type51ucd_scdma_timestamp_snapshot = -1;
static int hf_docsis_type51ucd_maintain_power_spectral_density = -1;
static int hf_docsis_type51ucd_ranging_required = -1;
static int hf_docsis_type51ucd_rnghoff_cm = -1;
static int hf_docsis_type51ucd_rnghoff_erouter = -1;
static int hf_docsis_type51ucd_rnghoff_emta = -1;
static int hf_docsis_type51ucd_rnghoff_estb = -1;
static int hf_docsis_type51ucd_rnghoff_rsvd = -1;
static int hf_docsis_type51ucd_rnghoff_id_ext = -1;
static int hf_docsis_type51ucd_chan_class_id_cm = -1;
static int hf_docsis_type51ucd_chan_class_id_erouter = -1;
static int hf_docsis_type51ucd_chan_class_id_emta = -1;
static int hf_docsis_type51ucd_chan_class_id_estb = -1;
static int hf_docsis_type51ucd_chan_class_id_rsvd = -1;
static int hf_docsis_type51ucd_chan_class_id_id_ext = -1;
static int hf_docsis_type51ucd_max_scheduled_codes = -1;
static int hf_docsis_type51ucd_active_code_hopping = -1;
static int hf_docsis_type51ucd_higher_ucd_for_same_ucid = -1;
static int hf_docsis_type51ucd_higher_ucd_for_same_ucid_resv = -1;
static int hf_docsis_type51ucd_scdma_selection_active_codes = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_subc_excl_band = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_unused_subc = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_other_subc = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc5 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc6 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc9 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc10 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc11 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc12 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc13 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc3_or_4 = -1;
static int hf_docsis_type51ucd_ucd_change_ind_bitmask_reserved = -1;
static int hf_docsis_type51ucd_ofdma_timestamp_snapshot = -1;
static int hf_docsis_type51ucd_ofdma_cyclic_prefix_size = -1;
static int hf_docsis_type51ucd_ofdma_rolloff_period_size = -1;
static int hf_docsis_type51ucd_subc_spacing = -1;
static int hf_docsis_type51ucd_cent_freq_subc0 = -1;
static int hf_docsis_type51ucd_subcarrier_range = -1;
static int hf_docsis_type51ucd_symb_ofdma_frame = -1;
static int hf_docsis_type51ucd_rand_seed = -1;
static int hf_docsis_burst_mod_type = -1;
static int hf_docsis_burst_diff_encoding = -1;
static int hf_docsis_burst_preamble_len = -1;
static int hf_docsis_burst_preamble_val_off = -1;
static int hf_docsis_burst_fec = -1;
static int hf_docsis_burst_fec_codeword = -1;
static int hf_docsis_burst_scrambler_seed = -1;
static int hf_docsis_burst_max_burst = -1;
static int hf_docsis_burst_guard_time = -1;
static int hf_docsis_burst_last_cw_len = -1;
static int hf_docsis_burst_scrambler_onoff = -1;
static int hf_docsis_rs_int_depth = -1;
static int hf_docsis_rs_int_block = -1;
static int hf_docsis_preamble_type = -1;
static int hf_docsis_scdma_scrambler_onoff = -1;
static int hf_docsis_scdma_codes_per_subframe = -1;
static int hf_docsis_scdma_framer_int_step_size = -1;
static int hf_docsis_tcm_enabled = -1;
static int hf_docsis_subc_init_rang = -1;
static int hf_docsis_subc_fine_rang = -1;
static int hf_docsis_type51ucd_ofdma_prof_mod_order = -1;
static int hf_docsis_type51ucd_ofdma_prof_pilot_pattern = -1;
static int hf_docsis_type51ucd_ofdma_prof_num_add_minislots = -1;
static int hf_docsis_ofdma_ir_pow_ctrl_start_pow = -1;
static int hf_docsis_ofdma_ir_pow_ctrl_step_size = -1;

static expert_field ei_docsis_type51ucd_tlvlen_bad = EI_INIT;
static expert_field ei_docsis_type51ucd_tlvtype_bad = EI_INIT;

/* Initialize the subtree pointers */
static gint ett_docsis_type51ucd = -1;
static gint ett_docsis_type51tlv = -1;
static gint ett_docsis_type51_burst_tlv = -1;

static dissector_handle_t docsis_type51ucd_handle;

static const value_string channel_tlv_vals[] _U_ = {
  {type51ucd_SYMBOL_RATE,                     "Symbol Rate"},
  {type51ucd_FREQUENCY,                       "Frequency"},
  {type51ucd_PREAMBLE,                        "Preamble Pattern"},
  {type51ucd_EXT_PREAMBLE,                    "Extended Preamble Pattern"},
  {type51ucd_SCDMA_MODE_ENABLE,               "SCDMA Mode Enabled"},
  {type51ucd_SCDMA_SPREADING_INTERVAL,        "SCDMA Spreading Intervals per Frame"},
  {type51ucd_SCDMA_CODES_PER_MINI_SLOT,       "SCDMA Codes per Mini-slot"},
  {type51ucd_SCDMA_ACTIVE_CODES,              "SCDMA Number of Active Codes"},
  {type51ucd_SCDMA_CODE_HOPPING_SEED,         "SCDMA Code Hopping Seed"},
  {type51ucd_SCDMA_US_RATIO_NUM,              "SCDMA US ratio numera7tor M"},
  {type51ucd_SCDMA_US_RATIO_DENOM,            "SCDMA US ratio denominator N"},
  {type51ucd_SCDMA_TIMESTAMP_SNAPSHOT,        "SCDMA Timestamp Snapshot"},
  {type51ucd_MAINTAIN_POWER_SPECTRAL_DENSITY, "Maintain Power Spectral Density"},
  {type51ucd_RANGING_REQUIRED,                "Ranging Required"},
  {type51ucd_MAX_SCHEDULED_CODES,             "S-CDMA Maximum Scheduled Codes"},
  {type51ucd_RANGING_HOLD_OFF_PRIORITY_FIELD, "Ranging Hold-Off Priority Field"},
  {type51ucd_RANGING_CHANNEL_CLASS_ID,        "Ranging Channel Class ID"},
  {type51ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING, "S-CDMA Selection Mode for Active Codes and Code Hopping"},
  {type51ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES, "S-CDMA Selection String for Active Codes"},
  {type51ucd_HIGHER_UCD_FOR_SAME_UCID,        "Higher UCD for the same UCID present bitmap"},
  {type51ucd_BURST_DESCR23,                   "Burst Descriptor Type 23"},
  {type51ucd_UCD_CHANGE_IND_BITMASK,          "UCD Change Indicator Bitmask"},
  {type51ucd_OFDMA_TIMESTAMP_SNAPSHOT,        "OFDMA Timestamp Snapshot"},
  {type51ucd_OFDMA_CYCLIC_PREFIX_SIZE,        "OFDMA Cyclic Prefix Size"},
  {type51ucd_OFDMA_ROLLOFF_PERIOD_SIZE,       "OFDMA Rolloff Period Size"},
  {type51ucd_SUBCARRIER_SPACING,              "Subcarrier Spacing"},
  {type51ucd_CENTER_FREQ_SUBC_0,              "Center Frequency of Subcarrier 0"},
  {type51ucd_SUBC_EXCL_BAND,                  "Subcarrier Exclusion Band"},
  {type51ucd_UNUSED_SUBC_SPEC,                "Unused Subcarrier Specification"},
  {type51ucd_SYMB_IN_OFDMA_FRAME,             "Symbols in OFDMA frame"},
  {type51ucd_RAND_SEED,                       "Randomization Seed"},
  {0, NULL}
};

static const value_string burst_tlv_vals[] = {
  {type51ucd_MODULATION,                      "Modulation Type"},
  {type51ucd_DIFF_ENCODING,                   "Differential Encoding"},
  {type51ucd_PREAMBLE_LEN,                    "Preamble Length"},
  {type51ucd_PREAMBLE_VAL_OFF,                "Preamble Value Offset"},
  {type51ucd_FEC,                             "FEC Error Correction (T)"},
  {type51ucd_FEC_CODEWORD,                    "FEC Codeword Information Bytes (k)"},
  {type51ucd_SCRAMBLER_SEED,                  "Scrambler Seed"},
  {type51ucd_MAX_BURST,                       "Maximum Burst Size"},
  {type51ucd_GUARD_TIME,                      "Guard Time Size"},
  {type51ucd_LAST_CW_LEN,                     "Last Codeword Length"},
  {type51ucd_SCRAMBLER_ONOFF,                 "Scrambler on/off"},
  {type51ucd_RS_INT_DEPTH,                    "R-S Interleaver Depth (Ir)"},
  {type51ucd_RS_INT_BLOCK,                    "R-S Interleaver Block Size (Br)"},
  {type51ucd_PREAMBLE_TYPE,                   "Preamble Type"},
  {type51ucd_SCMDA_SCRAMBLER_ONOFF,           "S-CDMA Spreader on/off"},
  {type51ucd_SCDMA_CODES_PER_SUBFRAME,        "S-CDMA Codes per Subframe"},
  {type51ucd_SCDMA_FRAMER_INT_STEP_SIZE,      "S-CDMA Framer Interleaving Step Size"},
  {type51ucd_TCM_ENABLED,                     "TCM Encoding"},
  {type51ucd_SUBC_INIT_RANG,                  "Subcarriers (Nir) Initial Ranging"},
  {type51ucd_SUBC_FINE_RANG,                  "Subcarriers (Nfr) Initial Ranging"},
  {type51ucd_OFDMA_PROFILE,                   "OFDMA Profile"},
  {0, NULL}
};

static const value_string on_off_vals[] = {
  {1, "On"},
  {2, "Off"},
  {0, NULL}
};

const true_false_string type51ucd_tfs_allow_inhibit = { "Inhibit Initial Ranging",
                                                        "Ranging Allowed" };

const true_false_string type51ucd_tfs_inhibit_allow = { "Ranging Allowed",
                                                        "Inhibit Initial Ranging" };

static const value_string mod_vals2[] = {
  {1, "QPSK"},
  {2, "16-QAM"},
  {3, "8-QAM"},
  {4, "32-QAM"},
  {5, "64-QAM"},
  {6, "128-QAM (SCDMA-only)"},
  {7, "Reserved for C-DOCSIS"},
  {0, NULL}
};

static const value_string tlv20_vals[] = {
  {0, "Selectable active codes mode 1 enabled and code hopping disabled"},
  {1, "Selectable active codes mode 1 enabled and code hopping mode 1 enabled"},
  {2, "Selectable active codes mode 2 enabled and code hopping mode 2 enabled"},
  {3, "Selectable active codes mode 2 enabled and code hopping disabled"},
  {0, NULL}
};

const true_false_string type51ucd_tfs_present_not_present = { "Higher UCD is present for this UCID",
                                                              "Higher UCD is not present for this UCID" };

static const value_string ofdma_prof_mod_order[] = {
  {1, "BPSK"},
  {2, "QPSK"},
  {3, "8-QAM"},
  {4, "16-QAM"},
  {5, "32-QAM"},
  {6, "64-QAM"},
  {7, "128-QAM"},
  {8, "256-QAM"},
  {9, "512-QAM"},
  {10, "1024-QAM"},
  {11, "2048-QAM"},
  {12, "4096-QAM"},
  {0, NULL}
};


static const value_string iuc_vals3[] = {
  {IUC_REQUEST,                  "Request"},
  {IUC_REQ_DATA,                 "REQ/Data"},
  {IUC_INIT_MAINT,               "Initial Maintenance"},
  {IUC_STATION_MAINT,            "Station Maintenance"},
  {IUC_SHORT_DATA_GRANT,         "Short Data Grant"},
  {IUC_LONG_DATA_GRANT,          "Long Data Grant"},
  {IUC_NULL_IE,                  "NULL IE"},
  {IUC_DATA_ACK,                 "Data Ack"},
  {IUC_ADV_PHY_SHORT_DATA_GRANT, "Advanced Phy Short Data Grant"},
  {IUC_ADV_PHY_LONG_DATA_GRANT,  "Advanced Phy Long Data Grant"},
  {IUC_ADV_PHY_UGS,              "Advanced Phy UGS"},
  {IUC_RESERVED12,               "Reserved 12"},
  {IUC_RESERVED13,               "Reserved 13"},
  {IUC_RESERVED14,               "Reserved 14"},
  {IUC_EXPANSION,                "IUC Expansion"},
  {0, NULL}
};

static const value_string last_cw_len_vals[] = {
  {1, "Fixed"},
  {2, "Shortened"},
  {0, NULL}
};

static const value_string max_scheduled_codes_vals[] = {
  {1, "Enabled."},
  {2, "Disabled."},
  {0, NULL}
};

static const value_string ranging_required[] = {
  {0, "No ranging required."},
  {1, "Unicast initial ranging required."},
  {2, "Broadcast initial ranging required."},
  {3, "Probing required."},
  {0, NULL}
};


static void
ofdma_ir_pow_ctrl_start_pow(
    char *buf,
    guint32 value)
{
    g_snprintf(buf, ITEM_LABEL_LENGTH,
               "%f dBmV/1.6MHz",
               value/4.0);
}

static void
ofdma_ir_pow_ctrl_step_size(
    char *buf,
    guint32 value)
{
    g_snprintf(buf, ITEM_LABEL_LENGTH,
               "%f dB",
               value/4.0);
}

static const value_string ucd_change_ind_vals[] = {
  {0, "No changes"},
  {1, "Changes"},
  {0, NULL}
};

static const value_string ofdma_cyclic_prefix_size_vals[] = {
  {1, "96 samples"},
  {2, "128 samples"},
  {3, "160 samples"},
  {4, "192 samples"},
  {5, "224 samples"},
  {6, "256 samples"},
  {7, "288 samples"},
  {8, "320 samples"},
  {9, "384 samples"},
  {10, "512 samples"},
  {11, "640 samples"},
  {0, NULL}
};

static const value_string ofdma_rolloff_period_size_vals[] = {
  {1, "0 samples"},
  {2, "32 samples"},
  {3, "64 samples"},
  {4, "96 samples"},
  {5, "128 samples"},
  {6, "160 samples"},
  {7, "192 samples"},
  {8, "224 samples"},
  {0, NULL}
};

static const value_string subc_spacing_vals[] = {
  {1, "25 kHz (corresponds to 4096 subcarriers and 16 subcarriers per minislot)"},
  {2, "50 kHz (corresponds to 2048 subcarriers and 8 subcarriers per minislot)"},
  {0, NULL}
};

static void
subcarrier_range (
    char *buf,
    guint32 value)
{
    g_snprintf(buf, ITEM_LABEL_LENGTH,
         "%u - %u",
         value >> 16, value &0xFFFF);
}

/* Dissection */
static void
dissect_type51ucd_burstdescriptor(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint16 start, guint16 length)
{
  guint16 endtlvpos, pos;
  guint16 i;
  proto_tree *type51ucd_burst_tree;
  proto_item *type51ucd_burst_item;
  guint8 tlvlen, tlvtype;

  pos = start;
  proto_tree_add_item (tree, hf_docsis_type51ucd_iuc, tvb, pos++, 1, ENC_BIG_ENDIAN);

  endtlvpos = pos + length - 1;
  while (pos < endtlvpos)
  {
    tlvtype = tvb_get_guint8 (tvb, pos);
    type51ucd_burst_tree = proto_tree_add_subtree (tree, tvb, pos, -1,
                                                   ett_docsis_type51_burst_tlv, &type51ucd_burst_item,
                                                   val_to_str(tlvtype, burst_tlv_vals,
                                                   "Unknown TLV (%u)"));
    proto_tree_add_uint (type51ucd_burst_tree, hf_docsis_type51ucd_burst_type, tvb, pos++, 1, tlvtype);
    tlvlen = tvb_get_guint8 (tvb, pos);
    proto_tree_add_uint (type51ucd_burst_tree, hf_docsis_type51ucd_burst_length, tvb, pos++, 1, tlvlen);
    proto_item_set_len(type51ucd_burst_item, tlvlen + 2);
    switch (tlvtype)
    {
      case type51ucd_MODULATION:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_mod_type, tvb,
                                 pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_DIFF_ENCODING:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_diff_encoding,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_PREAMBLE_LEN:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                hf_docsis_burst_preamble_len,
                               tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_PREAMBLE_VAL_OFF:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                hf_docsis_burst_preamble_val_off,
                                tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_FEC:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                hf_docsis_burst_fec, tvb, pos,
                                tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_FEC_CODEWORD:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_fec_codeword,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCRAMBLER_SEED:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_scrambler_seed,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_MAX_BURST:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_max_burst, tvb,
                                 pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_GUARD_TIME:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_guard_time,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_LAST_CW_LEN:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_last_cw_len,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCRAMBLER_ONOFF:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_burst_scrambler_onoff,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_RS_INT_DEPTH:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_rs_int_depth,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_RS_INT_BLOCK:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                hf_docsis_rs_int_block,
                                tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_PREAMBLE_TYPE:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_preamble_type,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCMDA_SCRAMBLER_ONOFF:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_scdma_scrambler_onoff,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_CODES_PER_SUBFRAME:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_scdma_codes_per_subframe,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);

        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_FRAMER_INT_STEP_SIZE:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_scdma_framer_int_step_size,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_TCM_ENABLED:
        if (tlvlen == 1)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_tcm_enabled,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SUBC_INIT_RANG:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                 hf_docsis_subc_init_rang,
                                 tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
            expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SUBC_FINE_RANG:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree,
                                hf_docsis_subc_fine_rang,
                                tvb, pos, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_OFDMA_PROFILE:
        if ((tlvlen % 2) == 0)
        {
          for(i =0; i < tlvlen; i+=2) {
            proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_mod_order, tvb, pos + i, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_pilot_pattern, tvb, pos + i, 1, ENC_BIG_ENDIAN);
            proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_num_add_minislots, tvb, pos + i + 1, 1, ENC_BIG_ENDIAN);
          }
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u (even length expected)", length);
        }
        break;
      case type51ucd_OFDMA_IR_POWER_CONTROL:
        if (tlvlen == 2)
        {
          proto_tree_add_item (type51ucd_burst_tree, hf_docsis_ofdma_ir_pow_ctrl_start_pow, tvb, pos, tlvlen, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51ucd_burst_tree, hf_docsis_ofdma_ir_pow_ctrl_step_size, tvb, pos + 1, tlvlen, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u (even length expected)", length);
        }
        break;
      default:
        expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvtype_bad, "Unknown TLV type: %u", tlvtype);

    }
    pos = pos + tlvlen;
  } /*while*/
}


static int
dissect_type51ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
{
  guint16 pos;
  guint8 type, length;
  guint16 i;

  proto_tree *type51ucd_tree;
  proto_item *type51ucd_item;
  proto_tree *type51tlv_tree;
  proto_item *type51tlv_item;
  guint16 len;
  guint8 upchid, symrate;

  len = tvb_reported_length(tvb);
  upchid = tvb_get_guint8 (tvb, 0);

  /* if the upstream Channel ID is 0 then this is for Telephony Return) */
  if (upchid > 0)
    col_add_fstr (pinfo->cinfo, COL_INFO,
                  "Type 51 UCD Message: Channel ID = %u (U%u)", upchid,
                  upchid - 1);
  else
    col_add_fstr (pinfo->cinfo, COL_INFO,
                  "Type 51 UCD Message: Channel ID = %u (Telephony Return)",
                  upchid);

  type51ucd_item =
    proto_tree_add_protocol_format (tree, proto_docsis_type51ucd, tvb, 0,
                                    tvb_captured_length(tvb),
                                    "UCD Message (Type 51)");
  type51ucd_tree = proto_item_add_subtree (type51ucd_item, ett_docsis_type51ucd);
  proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_upstream_chid, tvb, 0, 1,
                       ENC_BIG_ENDIAN);
  proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_config_ch_cnt, tvb, 1, 1,
                       ENC_BIG_ENDIAN);
  proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_mini_slot_size, tvb, 2, 1,
                       ENC_BIG_ENDIAN);
  proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_down_chid, tvb, 3, 1,
                       ENC_BIG_ENDIAN);

  pos = 4;
  while (pos < len)
  {
    type = tvb_get_guint8 (tvb, pos);
    type51tlv_tree = proto_tree_add_subtree(type51ucd_tree, tvb, pos, -1,
                                        ett_docsis_type51tlv, &type51tlv_item,
                                        val_to_str(type, channel_tlv_vals,
                                                   "Unknown TLV (%u)"));
    proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_type,
                           tvb, pos, 1, type);
    pos++;
    length = tvb_get_guint8 (tvb, pos);
    proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_length,
                           tvb, pos, 1, length);
    pos++;
    proto_item_set_len(type51tlv_item, length + 2);
    switch (type)
    {
      case type51ucd_SYMBOL_RATE:
        if (length == 1)
        {
          symrate = tvb_get_guint8 (tvb, pos);
          proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_symbol_rate,
                                     tvb, pos, length, symrate * 160);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_FREQUENCY:
        if (length == 4)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_frequency, tvb,
                                   pos, length, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_PREAMBLE:
        proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_preamble_pat, tvb,
                             pos, length, ENC_NA);
        break;
      case type51ucd_EXT_PREAMBLE:
        proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ext_preamble, tvb,
                             pos, length, ENC_NA);
        break;
      case type51ucd_SCDMA_MODE_ENABLE:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_mode_enable,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_SPREADING_INTERVAL:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_spreading_interval,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
            expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_CODES_PER_MINI_SLOT:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_codes_per_mini_slot,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_ACTIVE_CODES:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_active_codes,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_CODE_HOPPING_SEED:
        if (length == 2)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_code_hopping_seed,
                               tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_US_RATIO_NUM:
        if (length == 2)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_us_ratio_num,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_US_RATIO_DENOM:
        if (length == 2)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_us_ratio_denom,
                               tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_TIMESTAMP_SNAPSHOT:
        if (length == 9)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_timestamp_snapshot,
                               tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_MAINTAIN_POWER_SPECTRAL_DENSITY:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_maintain_power_spectral_density,
                               tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_RANGING_REQUIRED:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ranging_required,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_MAX_SCHEDULED_CODES:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_max_scheduled_codes,
                               tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_RANGING_HOLD_OFF_PRIORITY_FIELD:
        if (length == 4)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_cm, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_erouter, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_emta, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_estb, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_rsvd, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_id_ext, tvb,
                               pos, length, ENC_BIG_ENDIAN);
        }
        else
        {
            expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_RANGING_CHANNEL_CLASS_ID:
        if (length == 4)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_cm, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_erouter, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_emta, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_estb, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_rsvd, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_id_ext, tvb,
                                 pos, length, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_active_code_hopping,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES:
        if (length == 16)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_selection_active_codes,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_HIGHER_UCD_FOR_SAME_UCID:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_higher_ucd_for_same_ucid,
                                tvb, pos, length, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_higher_ucd_for_same_ucid_resv, tvb,
                                pos, length, ENC_BIG_ENDIAN);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_UCD_CHANGE_IND_BITMASK:
        if (length == 2)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_subc_excl_band,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_unused_subc,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_other_subc,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc5,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc6,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc9,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc10,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc11,
                                    tvb, pos + 1, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc12,
                                    tvb, pos, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc13,
                                    tvb, pos, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc3_or_4,
                                    tvb, pos, 1, ENC_NA);
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_reserved,
                                    tvb, pos, 1, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_OFDMA_TIMESTAMP_SNAPSHOT:
        if (length == 9)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_timestamp_snapshot,
                                tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_OFDMA_CYCLIC_PREFIX_SIZE:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_cyclic_prefix_size,
                                tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_OFDMA_ROLLOFF_PERIOD_SIZE:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_rolloff_period_size,
                                tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SUBCARRIER_SPACING:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subc_spacing,
                                tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_CENTER_FREQ_SUBC_0:
        if (length == 4)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_cent_freq_subc0,
                                   tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SUBC_EXCL_BAND:
        if ((length % 4) == 0)
        {
          for(i = 0; i < length; i+=4) {
            proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subcarrier_range, tvb, pos+i, 4, ENC_NA);
          }
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_UNUSED_SUBC_SPEC:
        if ((length % 4) == 0)
        {
          for(i = 0; i < length; i+=4) {
            proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subcarrier_range, tvb, pos+i, 4, ENC_NA);
          }
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_SYMB_IN_OFDMA_FRAME:
        if (length == 1)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_symb_ofdma_frame,
                                 tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_RAND_SEED:
        if (length == 3)
        {
          proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rand_seed,
                                tvb, pos, length, ENC_NA);
        }
        else
        {
          expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length);
        }
        break;
      case type51ucd_BURST_DESCR23:
        dissect_type51ucd_burstdescriptor(tvb, pinfo, type51tlv_tree, pos, length);
        break;
    default:
      expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvtype_bad, "Unknown TLV type: %u", type);
    }                   /* switch(type) */
    pos = pos + length;
  }                       /* while (pos < len) */
  return len;
}

/* Register the protocol with Wireshark */
void
proto_register_docsis_type51ucd (void)
{
  static hf_register_info hf[] = {
    {&hf_docsis_type51ucd_upstream_chid,
     {"Upstream Channel ID", "docsis_type51ucd.upchid",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_config_ch_cnt,
     {"Config Change Count", "docsis_type51ucd.confcngcnt",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Configuration Change Count", HFILL}
    },
    {&hf_docsis_type51ucd_mini_slot_size,
     {"Mini Slot Size (6.25us TimeTicks)", "docsis_type51ucd.mslotsize",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_down_chid,
     {"Downstream Channel ID", "docsis_type51ucd.downchid",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Management Message", HFILL}
    },
    {&hf_docsis_type51ucd_type,
     {"Type", "docsis_type51ucd.type",
      FT_UINT8, BASE_DEC, VALS(channel_tlv_vals), 0x0,
      "Channel TLV type", HFILL}
    },
    {&hf_docsis_type51ucd_length,
     {"Length", "docsis_type51ucd.length",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Channel TLV length", HFILL}
    },
    {&hf_docsis_type51ucd_burst_type,
     {"Type", "docsis_type51ucd.burst.tlvtype",
      FT_UINT8, BASE_DEC, VALS(burst_tlv_vals), 0x0,
      "Burst TLV type", HFILL}
    },
    {&hf_docsis_type51ucd_burst_length,
     {"Length", "docsis_type51ucd.burst.tlvlen",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Burst TLV length", HFILL}
    },
    {&hf_docsis_type51ucd_symbol_rate,
     {"Symbol Rate (ksym/sec)", "docsis_type51ucd.symrate",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Symbol Rate", HFILL}
    },
    {&hf_docsis_type51ucd_frequency,
     {"Frequency (Hz)", "docsis_type51ucd.freq",
      FT_UINT32, BASE_DEC, NULL, 0x0,
      "Upstream Center Frequency", HFILL}
    },
    {&hf_docsis_type51ucd_preamble_pat,
     {"Preamble Pattern", "docsis_type51ucd.preamble",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      "Preamble Superstring", HFILL}
    },
    {&hf_docsis_type51ucd_iuc,
     {"Interval Usage Code", "docsis_type51ucd.iuc",
      FT_UINT8, BASE_DEC, VALS (iuc_vals3), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_mod_type,
     {"Modulation Type", "docsis_type51ucd.burst.modtype",
      FT_UINT8, BASE_DEC, VALS (mod_vals2), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_diff_encoding,
     {"Differential Encoding", "docsis_type51ucd.burst.diffenc",
      FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_preamble_len,
     {"Preamble Length (Bits)", "docsis_type51ucd.burst.preamble_len",
      FT_UINT16, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_preamble_val_off,
     {"Preamble Offset (Bits)", "docsis_type51ucd.burst.preamble_off",
      FT_UINT16, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_fec,
     {"FEC (T)", "docsis_type51ucd.burst.fec",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "FEC (T) Codeword Parity Bits = 2^T", HFILL}
    },
    {&hf_docsis_burst_fec_codeword,
     {"FEC Codeword Info bytes (k)", "docsis_type51ucd.burst.fec_codeword",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_scrambler_seed,
     {"Scrambler Seed", "docsis_type51ucd.burst.scrambler_seed",
      FT_UINT16, BASE_HEX, NULL, 0x0,
      "Burst Descriptor", HFILL}
    },
    {&hf_docsis_burst_max_burst,
     {"Max Burst Size (Minislots)", "docsis_type51ucd.burst.maxburst",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_guard_time,
     {"Guard Time Size (Symbol Times)", "docsis_type51ucd.burst.guardtime",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Guard Time Size", HFILL}
    },
    {&hf_docsis_burst_last_cw_len,
     {"Last Codeword Length", "docsis_type51ucd.burst.last_cw_len",
      FT_UINT8, BASE_DEC, VALS (last_cw_len_vals), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_burst_scrambler_onoff,
     {"Scrambler On/Off", "docsis_type51ucd.burst.scrambleronoff",
      FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ext_preamble,
     {"Extended Preamble Pattern", "docsis_type51ucd.extpreamble",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_mode_enable,
     {"SCDMA Mode Enable", "docsis_type51ucd.scdmaenable",
      FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_spreading_interval,
     {"SCDMA Spreading Interval", "docsis_type51ucd.scdmaspreadinginterval",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_codes_per_mini_slot,
     {"SCDMA Codes per mini slot", "docsis_type51ucd.scdmacodesperminislot",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_active_codes,
     {"SCDMA Active Codes", "docsis_type51ucd.scdmaactivecodes",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_code_hopping_seed,
     {"SCDMA Code Hopping Seed", "docsis_type51ucd.scdmacodehoppingseed",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_us_ratio_num,
     {"SCDMA US Ratio Numerator", "docsis_type51ucd.scdmausrationum",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_us_ratio_denom,
     {"SCDMA US Ratio Denominator", "docsis_type51ucd.scdmausratiodenom",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_scdma_timestamp_snapshot,
     {"SCDMA Timestamp Snapshot", "docsis_type51ucd.scdmatimestamp",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_maintain_power_spectral_density,
     {"Maintain power spectral density", "docsis_type51ucd.maintainpowerspectraldensity",
      FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ranging_required,
     {"Ranging Required", "docsis_type51ucd.rangingrequired",
      FT_UINT8, BASE_DEC, VALS (ranging_required), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rnghoff_cm,
     {"Ranging Hold-Off (CM)","docsis_type51ucd.rnghoffcm",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_allow_inhibit), 0x1,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rnghoff_erouter,
     {"Ranging Hold-Off (eRouter)",
      "docsis_type51ucd.rnghofferouter",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_allow_inhibit), 0x2,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rnghoff_emta,
     {"Ranging Hold-Off (eMTA or EDVA)",
      "docsis_type51ucd.rnghoffemta",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_allow_inhibit), 0x4,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rnghoff_estb,
     {"Ranging Hold-Off (DSG/eSTB)",
      "docsis_type51ucd.rnghoffestb",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_allow_inhibit), 0x8,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rnghoff_rsvd,
     {"Reserved [0x000000]",
      "docsis_type51ucd.rnghoffrsvd",
      FT_UINT32, BASE_HEX, NULL, 0xFFF0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rnghoff_id_ext,
     {"CM Ranging Class ID Extension",
      "docsis_type51ucd.rngidext",
      FT_UINT32, BASE_HEX, NULL, 0xFFFF0000,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_chan_class_id_cm,
     {"Channel Class ID (CM)","docsis_type51ucd.classidcm",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_inhibit_allow), 0x1,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_chan_class_id_erouter,
     {"Channel Class ID (eRouter)",
      "docsis_type51ucd.classiderouter",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_inhibit_allow), 0x2,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_chan_class_id_emta,
     {"Channel Class ID (eMTA or EDVA)",
      "docsis_type51ucd.classidemta",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_inhibit_allow), 0x4,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_chan_class_id_estb,
     {"Channel Class ID (DSG/eSTB)",
      "docsis_type51ucd.classidestb",
      FT_BOOLEAN, 32, TFS(&type51ucd_tfs_inhibit_allow), 0x8,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_chan_class_id_rsvd,
     {"Reserved [0x000000]",
      "docsis_type51ucd.classidrsvd",
      FT_UINT32, BASE_HEX, NULL, 0xFFF0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_chan_class_id_id_ext,
     {"CM Ranging Class ID Extension",
      "docsis_type51ucd.classidext",
      FT_UINT32, BASE_HEX, NULL, 0xFFFF0000,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_active_code_hopping,
     {"S-CDMA Selection Mode for Active Codes and Code Hopping", "docsis_type51ucd.selectcodehop",
      FT_UINT8, BASE_DEC, VALS (tlv20_vals), 0x0,
      "SCDMA Selection Mode for Active Codes and Code Hopping", HFILL}
    },
    {&hf_docsis_type51ucd_scdma_selection_active_codes,
     {"S-CDMA Selection String for Active Codes", "docsis_type51ucd.selectcode",
      FT_BYTES, BASE_NONE, NULL, 0x0,
      "SCDMA Selection String for Active Codes", HFILL}
    },
    {&hf_docsis_type51ucd_higher_ucd_for_same_ucid,
     {"Higher UCD for the same UCID", "docsis_type51ucd.highucdpresent",
      FT_BOOLEAN, 8, TFS(&type51ucd_tfs_present_not_present), 0x1,
      "Higher UCD for the same UCID present bitmap", HFILL}
    },
    {&hf_docsis_type51ucd_higher_ucd_for_same_ucid_resv,
     {"Reserved", "docsis_type51ucd.highucdresv",
      FT_UINT8, BASE_HEX, NULL, 0xFE,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_max_scheduled_codes,
     {"S-CDMA Max Scheduled Codes", "docsis_type51ucd.scdmamaxcodes",
      FT_UINT8, BASE_DEC, VALS (max_scheduled_codes_vals), 0x0,
      "S-CDMA Maximum Scheduled Codes", HFILL}
    },
    {&hf_docsis_rs_int_depth,
     {"Scrambler On/Off", "docsis_type51ucd.burst.rsintdepth",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "R-S Interleaver Depth", HFILL}
    },
    {&hf_docsis_rs_int_block,
     {"Scrambler On/Off", "docsis_type51ucd.burst.rsintblock",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "R-S Interleaver Block", HFILL}
    },
    {&hf_docsis_preamble_type,
     {"Scrambler On/Off", "docsis_type51ucd.burst.preambletype",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      "Preamble Type", HFILL}
    },
    {&hf_docsis_scdma_scrambler_onoff,
     {"Scrambler On/Off", "docsis_type51ucd.burst.scdmascrambleronoff",
      FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
      "SCDMA Scrambler On/Off", HFILL}
    },
    {&hf_docsis_scdma_codes_per_subframe,
     {"SCDMA Codes per Subframe", "docsis_type51ucd.burst.scdmacodespersubframe",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_scdma_framer_int_step_size,
     {"SCDMA Framer Interleaving Step Size", "docsis_type51ucd.burst.scdmaframerintstepsize",
      FT_UINT8, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_tcm_enabled,
     {"TCM Enabled", "docsis_type51ucd.burst.tcmenabled",
      FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_subc_init_rang,
     {"Subcarriers (Nir) Initial Ranging", "docsis_type51ucd.burst.subc_init_rang",
      FT_UINT16, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_subc_fine_rang,
     {"Subcarriers (Nfr) Fine Ranging", "docsis_type51ucd.burst.subc_fine_rang",
      FT_UINT16, BASE_DEC, NULL, 0x0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ofdma_prof_mod_order,
     {"OFDMA Profile: modulation", "docsis_type51ucd.burst.ofma_prof_mod_order",
      FT_UINT8, BASE_DEC, VALS(ofdma_prof_mod_order), 0xF0,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ofdma_prof_pilot_pattern,
     {"OFDMA Profile: pilot pattern", "docsis_type51ucd.burst.ofma_prof_pilot_pattern",
      FT_UINT8, BASE_DEC, NULL, 0x0F,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ofdma_prof_num_add_minislots,
     {"OFDMA Profile: Additional Minislots that have identical bit-loading and pilot pattern index", "docsis_type51ucd.burst.ofma_prof_add_minislots",
      FT_UINT8, BASE_DEC, NULL, 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_ofdma_ir_pow_ctrl_start_pow,
     {"OFDMA IR Power Control Starting Power Level", "docsis_type51ucd.burst.ofma_ir_pow_ctrl_start_pow",
      FT_UINT8, BASE_CUSTOM, CF_FUNC(ofdma_ir_pow_ctrl_start_pow), 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_ofdma_ir_pow_ctrl_step_size,
     {"OFDMA IR Power Control Step Size", "docsis_type51ucd.burst.ofma_ir_pow_ctrl_step_size",
      FT_UINT8, BASE_CUSTOM, CF_FUNC(ofdma_ir_pow_ctrl_step_size), 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_subc_excl_band,
     {"UCD Change Indicator Bitmask: Subcarrier Exclusion Band TLV", "docsis_type51ucd.burst.ucd_change_ind_bitmask_subc_excl_band",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x01,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_unused_subc,
     {"UCD Change Indicator Bitmask: Unused Subcarrier Specification TLV", "docsis_type51ucd.burst.ucd_change_ind_bitmask_unused_subc",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x02,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_other_subc,
     {"UCD Change Indicator Bitmask: Other than Subcarrier Exclusion Band and Unused Subcarrier Specification TLV", "docsis_type51ucd.burst.ucd_change_ind_bitmask_other_subc",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x04,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc5,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC5", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc5",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x08,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc6,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC6", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc6",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x10,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc9,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC9", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc9",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x20,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc10,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC10", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc10",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x40,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc11,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC11", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc11",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x80,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc12,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC12", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc12",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x01,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc13,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC13", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc13",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x02,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc3_or_4,
     {"UCD Change Indicator Bitmask: Burst Attributes associated with IUC3 or IUC4", "docsis_type51ucd.burst.ucd_change_ind_bitmask_burst_attr_iuc3_or_4",
      FT_UINT8, BASE_DEC, VALS(ucd_change_ind_vals), 0x04,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ucd_change_ind_bitmask_reserved,
     {"UCD Change Indicator Bitmask: Reserved", "docsis_type51ucd.burst.ucd_change_ind_bitmask_reserved",
      FT_UINT8, BASE_HEX, NULL, 0xF8,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ofdma_timestamp_snapshot,
     {"OFDMA Timestamp Snapshot", "docsis_type51ucd.ofdma_timestamp_snapshot",
      FT_BYTES, BASE_NONE, NULL, 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ofdma_cyclic_prefix_size,
     {"OFDMA Cyclic Prefix Size", "docsis_type51ucd.ofdma_cyclic_prefix_size",
      FT_UINT8, BASE_DEC, VALS(ofdma_cyclic_prefix_size_vals), 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_ofdma_rolloff_period_size,
     {"OFDMA Rolloff Period Size", "docsis_type51ucd.ofdma_rolloff_period_size",
      FT_UINT8, BASE_DEC, VALS(ofdma_rolloff_period_size_vals), 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_subc_spacing,
     {"Subcarrier Spacing", "docsis_type51ucd.subc_spacing",
      FT_UINT8, BASE_DEC, VALS(subc_spacing_vals), 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_cent_freq_subc0,
     {"Center Frequency of Subcarrier 0", "docsis_type51ucd.cent_freq_subc0",
      FT_UINT8, BASE_DEC, NULL, 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_subcarrier_range,
     {"Subcarrier range", "docsis_type51ucd.subc_range",
      FT_UINT32, BASE_CUSTOM, CF_FUNC(subcarrier_range), 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_symb_ofdma_frame,
     {"Symbols in OFDMA frame", "docsis_type51ucd.symb_ofdma_frame",
      FT_UINT8, BASE_DEC, NULL, 0x00,
      NULL, HFILL}
    },
    {&hf_docsis_type51ucd_rand_seed,
     {"Randomization Seed", "docsis_type51ucd.rand_seed",
      FT_BYTES, BASE_NONE, NULL, 0x00,
      NULL, HFILL}
    },
  };



  static ei_register_info ei[] = {
    {&ei_docsis_type51ucd_tlvlen_bad, {"docsis_type51ucd.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
    {&ei_docsis_type51ucd_tlvtype_bad, {"docsis_type51ucd.tlvtypebad", PI_PROTOCOL, PI_WARN, "Bad TLV type", EXPFILL}},
  };

  static gint *ett[] = {
    &ett_docsis_type51ucd,
    &ett_docsis_type51tlv,
    &ett_docsis_type51_burst_tlv,
  };

  expert_module_t* expert_docsis_type51ucd;

  proto_docsis_type51ucd =
    proto_register_protocol ("DOCSIS Upstream Channel Descriptor Type 51",
                             "DOCSIS type51ucd", "docsis_type51ucd");

  proto_register_field_array (proto_docsis_type51ucd, hf, array_length (hf));
  proto_register_subtree_array (ett, array_length (ett));
  expert_docsis_type51ucd = expert_register_protocol(proto_docsis_type51ucd);
  expert_register_field_array(expert_docsis_type51ucd, ei, array_length(ei));

  docsis_type51ucd_handle = register_dissector ("docsis_type51ucd", dissect_type51ucd, proto_docsis_type51ucd);
}

void
proto_reg_handoff_docsis_type51ucd (void)
{
  dissector_add_uint ("docsis_mgmt", 0x33, docsis_type51ucd_handle);
}

/*
 * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
 *
 * Local Variables:
 * c-basic-offset: 2
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=2 tabstop=8 expandtab:
 * :indentSize=2:tabSize=8:noTabs=true:
 */