Revert "In get_unicode_or_ascii_string(), check if the length is odd/even, not the...
[wireshark-wip.git] / plugins / docsis / packet-mdd.c
blob54b14f1251f01b3429dc8a8d274d5b271aa11452
1 /* packet-mdd.c
2 * $Id$
3 * Routines for MDD Message dissection
4 * Copyright 2007, Bruno Verstuyft <bruno.verstuyft@excentis.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "config.h"
28 #include <epan/packet.h>
31 #define DOWNSTREAM_ACTIVE_CHANNEL_LIST 1
32 #define MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP 2
33 #define DOWNSTREAM_AMBIGUITY_RESOLUTION_FREQUENCY_LIST 3
34 #define RECEIVE_CHANNEL_PROFILE_REPORTING_CONTROL 4
35 #define IP_INITIALIZATION_PARAMETERS 5
36 #define EARLY_AUTHENTICATION_AND_ENCRYPTION 6
37 #define UPSTREAM_ACTIVE_CHANNEL_LIST 7
38 #define UPSTREAM_AMBIGUITY_RESOLUTION_CHANNEL_LIST 8
39 #define UPSTREAM_FREQUENCY_RANGE 9
40 #define SYMBOL_CLOCK_LOCKING_INDICATOR 10
41 #define CM_STATUS_EVENT_CONTROL 11
42 #define UPSTREAM_TRANSMIT_POWER_REPORTING 12
43 #define DSG_DA_TO_DSID_ASSOCIATION_ENTRY 13
44 #define CM_STATUS_EVENT_ENABLE_NON_CHANNEL_SPECIFIC_EVENTS 15
46 /*Downstream Active Channel List*/
47 #define DOWNSTREAM_ACTIVE_CHANNEL_LIST_CHANNEL_ID 1
48 #define DOWNSTREAM_ACTIVE_CHANNEL_LIST_FREQUENCY 2
49 #define DOWNSTREAM_ACTIVE_CHANNEL_LIST_MODULATION_ORDER_ANNEX 3
50 #define DOWNSTREAM_ACTIVE_CHANNEL_LIST_PRIMARY_CAPABLE 4
51 #define DOWNSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK 5
53 /*Mac Domain Downstream Service Group*/
54 #define MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_MD_DS_SG_IDENTIFIER 1
55 #define MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_CHANNEL_IDS 2
57 /*Modulation Orders*/
58 #define QAM64 0
59 #define QAM256 1
61 /*Annexes*/
62 #define J83_ANNEX_A 0
63 #define J83_ANNEX_B 1
64 #define J83_ANNEX_C 2
66 /*Primary Capable*/
67 #define NOT_PRIMARY_CAPABLE 0
68 #define PRIMARY_CAPABLE 1
70 /*Receive Channel Profile Reporting Control*/
71 #define RCP_CENTER_FREQUENCY_SPACING 1
72 #define VERBOSE_RCP_REPORTING 2
74 /*Frequency spacing*/
75 #define ASSUME_6MHZ_CENTER_FREQUENCY_SPACING 0
76 #define ASSUME_8MHZ_CENTER_FREQUENCY_SPACING 1
78 /*Verbose RCP reporting*/
79 #define RCP_NO_VERBOSE_REPORTING 0
80 #define RCP_VERBOSE_REPORTING 1
82 /*Sub-TLVs for IP Initialization Parameters*/
83 #define IP_PROVISIONING_MODE 1
84 #define PRE_REGISTRATION_DSID 2
86 /*IP Provisioning Modes*/
87 #define IPv4_ONLY 0
88 #define IPv6_ONLY 1
89 #define IP_ALTERNATE 2
90 #define DUAL_STACK 3
92 /*Early authentication and encryption*/
93 #define EAE_DISABLED 0
94 #define EAE_ENABLED 1
96 /*Upstream Active Channel List*/
97 #define UPSTREAM_ACTIVE_CHANNEL_LIST_UPSTREAM_CHANNEL_ID 1
98 #define UPSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK 2
100 /*Upstream Frequency Range*/
101 #define STANDARD_UPSTREAM_FREQUENCY_RANGE 0
102 #define EXTENDED_UPSTREAM_FREQUENCY_RANGE 1
104 /*Symbol Clock Locking Indicator*/
105 #define NOT_LOCKED_TO_MASTER_CLOCK 0
106 #define LOCKED_TO_MASTER_CLOCK 1
108 /*CM-STATUS Event Control */
109 #define EVENT_TYPE_CODE 1
110 #define MAXIMUM_EVENT_HOLDOFF_TIMER 2
111 #define MAXIMUM_NUMBER_OF_REPORTS_PER_EVENT 3
113 /*CM-STATUS Events*/
114 #define SECONDARY_CHANNEL_MDD_TIMEOUT 1
115 #define QAM_FEC_LOCK_FAILURE 2
116 #define SEQUENCE_OUT_OF_RANGE 3
117 #define MDD_RECOVERY 4
118 #define QAM_FEC_LOCK_RECOVERY 5
119 #define T4_TIMEOUT 6
120 #define T3_RETRIES_EXCEEDED 7
121 #define SUCCESFUL_RANGING_AFTER_T3_RETRIES_EXCEEDED 8
122 #define CM_OPERATING_ON_BATTERY_BACKUP 9
123 #define CM_RETURNED_TO_AC_POWER 10
125 /*Upstream Transmit Power Reporting*/
126 #define CM_DOESNT_REPORT_TRANSMIT_POWER 0
127 #define CM_REPORTS_TRANSMIT_POWER 1
130 /*Dsg DA to DSID association entry*/
131 #define DSG_DA_TO_DSID_ASSOCIATION_DA 1
132 #define DSG_DA_TO_DSID_ASSOCIATION_DSID 2
137 static const value_string J83_annex_vals[] = {
138 {J83_ANNEX_A, "J.83 Annex A"},
139 {J83_ANNEX_B, "J.83 Annex B"},
140 {J83_ANNEX_C, "J.83 Annex C"},
141 {0, NULL}
145 static const value_string modulation_order_vals[] = {
146 {QAM64, "64 QAM"},
147 {QAM256, "256 QAM"},
148 {0, NULL}
151 static const value_string primary_capable_vals[] = {
152 {NOT_PRIMARY_CAPABLE, "Channel is not primary-capable"},
153 {PRIMARY_CAPABLE, "channel is primary-capable"},
154 {0, NULL}
158 static const value_string mdd_tlv_vals[] = {
159 {DOWNSTREAM_ACTIVE_CHANNEL_LIST, "Downstream Active Channel List"},
160 {MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP, "Mac Domain Downstream Service Group"},
161 {DOWNSTREAM_AMBIGUITY_RESOLUTION_FREQUENCY_LIST, "Downstream Ambiguity Resolution Frequency List "},
162 {RECEIVE_CHANNEL_PROFILE_REPORTING_CONTROL , "Receive Channel Profile Reporting Control"},
163 {IP_INITIALIZATION_PARAMETERS , "IP Initialization Parameters"},
164 {EARLY_AUTHENTICATION_AND_ENCRYPTION , "Early Authentication and Encryption"},
165 {UPSTREAM_ACTIVE_CHANNEL_LIST , "Upstream Active Channel List"},
166 {UPSTREAM_AMBIGUITY_RESOLUTION_CHANNEL_LIST , "Upstream Ambiguity Resolution Channel List"},
167 {UPSTREAM_FREQUENCY_RANGE , "Upstream Frequency Range"},
168 {SYMBOL_CLOCK_LOCKING_INDICATOR , "Symbol Clock Locking Indicator"},
169 {CM_STATUS_EVENT_CONTROL , "CM-STATUS Event Control"},
170 {UPSTREAM_TRANSMIT_POWER_REPORTING , "Upstream Transmit Power Reporting"},
171 {DSG_DA_TO_DSID_ASSOCIATION_ENTRY , "DSG DA-to-DSID Association Entry"},
172 {CM_STATUS_EVENT_ENABLE_NON_CHANNEL_SPECIFIC_EVENTS ,
173 "CM-STATUS Event Enable for Non-Channel-Specific-Events"},
174 {0, NULL}
178 static const value_string rpc_center_frequency_spacing_vals[] = {
179 {ASSUME_6MHZ_CENTER_FREQUENCY_SPACING , "CM MUST report only Receive Channel Profiles assuming 6 MHz center frequency spacing"},
180 {ASSUME_8MHZ_CENTER_FREQUENCY_SPACING , "CM MUST report only Receive Channel Profiles assuming 8 MHz center frequency spacing"},
181 {0, NULL}
184 static const value_string verbose_rpc_reporting_vals[] = {
185 {RCP_NO_VERBOSE_REPORTING , "CM MUST NOT provide verbose reporting of all its Receive Channel Profile(s) (both standard profiles and manufacturers profiles)."},
186 {RCP_VERBOSE_REPORTING , "CM MUST provide verbose reporting of Receive Channel Profile(s) (both standard profiles and manufacturers profiles)."},
187 {0, NULL}
190 static const value_string ip_provisioning_mode_vals[] = {
191 {IPv4_ONLY , "IPv4 Only"},
192 {IPv6_ONLY , "IPv6 Only"},
193 {IP_ALTERNATE, "Alternate"},
194 {DUAL_STACK , "Dual Stack"},
195 {0, NULL}
198 static const value_string eae_vals[] = {
199 {EAE_DISABLED , "early authentication and encryption disabled"},
200 {EAE_ENABLED , "early authentication and encryption enabled"},
201 {0, NULL}
204 static const value_string upstream_frequency_range_vals[] = {
205 {STANDARD_UPSTREAM_FREQUENCY_RANGE, "Standard Upstream Frequency Range"},
206 {EXTENDED_UPSTREAM_FREQUENCY_RANGE, "Extended Upstream Frequency Range"},
207 {0, NULL}
210 static const value_string symbol_clock_locking_indicator_vals[] = {
211 {NOT_LOCKED_TO_MASTER_CLOCK, "Symbol Clock is not locked to Master Clock"},
212 {LOCKED_TO_MASTER_CLOCK, "Symbol Clock is locked to Master Clock"},
213 {0, NULL}
216 static const value_string symbol_cm_status_event_vals[] = {
217 {SECONDARY_CHANNEL_MDD_TIMEOUT, "Secondary Channel MDD timeout"},
218 {QAM_FEC_LOCK_FAILURE, "Qam FEC Lock Failure"},
219 {SEQUENCE_OUT_OF_RANGE, "Sequence out of Range"},
220 {MDD_RECOVERY, "MDD Recovery"},
221 {QAM_FEC_LOCK_RECOVERY, "Qam FEC Lock Recovery"},
222 {T4_TIMEOUT, "T4 Timeout"},
223 {T3_RETRIES_EXCEEDED, "T3 Retries Exceeded"},
224 {SUCCESFUL_RANGING_AFTER_T3_RETRIES_EXCEEDED, "Successful ranging after T3 Retries Exceeded"},
225 {CM_OPERATING_ON_BATTERY_BACKUP, "CM Operating on Battery Backup"},
226 {CM_RETURNED_TO_AC_POWER, "CM Returned to AC Power"},
227 {0, NULL}
230 static const value_string upstream_transmit_power_reporting_vals[] = {
231 {CM_DOESNT_REPORT_TRANSMIT_POWER, "CM does not report transmit power in RNG-REQ, INIT-RNG-REQ, and B-INIT-RNG-REQ messages"},
232 {CM_REPORTS_TRANSMIT_POWER, "CM reports transmit power in RNG-REQ, INIT-RNG-REQ, and B-INIT-RNG-REQ messages"},
233 {0, NULL}
238 /* Initialize the protocol and registered fields */
239 static int proto_docsis_mdd = -1;
240 static int hf_docsis_mdd_ccc = -1;
241 static int hf_docsis_mdd_number_of_fragments = -1;
242 static int hf_docsis_mdd_fragment_sequence_number = -1;
243 static int hf_docsis_mdd_current_channel_dcid = -1;
245 static int hf_docsis_mdd_downstream_active_channel_list_channel_id = -1;
246 static int hf_docsis_mdd_downstream_active_channel_list_frequency = -1;
247 static int hf_docsis_mdd_downstream_active_channel_list_annex = -1;
248 static int hf_docsis_mdd_downstream_active_channel_list_modulation_order = -1;
249 static int hf_docsis_mdd_downstream_active_channel_list_primary_capable = -1;
251 static int hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout = -1;
252 static int hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_failure = -1;
253 static int hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_recovery = -1;
254 static int hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_recovery = -1;
255 static int hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout = -1;
256 static int hf_docsis_mdd_cm_status_event_enable_bitmask_t3_retries_exceeded = -1;
257 static int hf_docsis_mdd_cm_status_event_enable_bitmask_successful_ranging_after_t3_retries_exceeded = -1;
260 static int hf_docsis_mdd_mac_domain_downstream_service_group_md_ds_sg_identifier = -1;
261 static int hf_docsis_mdd_mac_domain_downstream_service_group_channel_id = -1;
263 static int hf_docsis_mdd_downstream_ambiguity_resolution_frequency = -1;
265 static int hf_docsis_mdd_rpc_center_frequency_spacing = -1;
266 static int hf_docsis_mdd_verbose_rcp_reporting = -1;
268 static int hf_docsis_mdd_ip_provisioning_mode = -1;
269 static int hf_docsis_mdd_pre_registration_dsid = -1;
271 static int hf_docsis_mdd_early_authentication_and_encryption = -1;
273 static int hf_docsis_mdd_upstream_active_channel_list_upstream_channel_id = -1;
275 static int hf_docsis_mdd_upstream_ambiguity_resolution_channel_list_channel_id = -1;
277 static int hf_docsis_mdd_upstream_frequency_range = -1;
279 static int hf_docsis_mdd_symbol_clock_locking_indicator = -1;
281 static int hf_docsis_mdd_event_type = -1;
283 static int hf_docsis_mdd_maximum_event_holdoff_timer = -1;
285 static int hf_docsis_mdd_maximum_number_of_reports_per_event = -1;
286 static int hf_docsis_mdd_upstream_transmit_power_reporting = -1;
288 static int hf_docsis_mdd_dsg_da_to_dsid_association_da = -1;
289 static int hf_docsis_mdd_dsg_da_to_dsid_association_dsid = -1;
291 static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_sequence_out_of_range = -1;
292 static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_operating_on_battery_backup = -1;
293 static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_returned_to_ac_power = -1;
296 /* Initialize the subtree pointers */
297 static gint ett_docsis_mdd = -1;
298 static gint ett_tlv = -1;
299 static gint ett_sub_tlv = -1;
301 static void
302 dissect_mdd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
304 proto_item *it;
305 proto_tree *mdd_tree;
307 int pos;
308 int subpos = 0;
309 gint len;
310 guint8 type, length;
311 guint8 subtype, sublength;
312 int i;
314 proto_item *tlv_item;
315 proto_tree *tlv_tree;
317 proto_item *tlv_sub_item;
318 proto_tree *tlv_sub_tree;
319 proto_item *text_item;
322 len = tvb_reported_length_remaining (tvb, 0);
324 col_set_str(pinfo->cinfo, COL_INFO, "MDD Message:");
326 if (tree)
328 it = proto_tree_add_protocol_format (tree, proto_docsis_mdd, tvb, 0, -1,"MDD Message");
329 mdd_tree = proto_item_add_subtree (it, ett_docsis_mdd);
331 proto_tree_add_item (mdd_tree, hf_docsis_mdd_ccc, tvb, 0, 1, ENC_BIG_ENDIAN);
332 proto_tree_add_item (mdd_tree, hf_docsis_mdd_number_of_fragments, tvb, 1, 1, ENC_BIG_ENDIAN);
333 proto_tree_add_item (mdd_tree, hf_docsis_mdd_fragment_sequence_number, tvb, 2, 1, ENC_BIG_ENDIAN);
334 proto_tree_add_item (mdd_tree, hf_docsis_mdd_current_channel_dcid, tvb, 3, 1, ENC_BIG_ENDIAN);
336 /*TLVs...*/
337 pos = 4;
338 while (pos < len)
340 type = tvb_get_guint8 (tvb, pos);
341 length = tvb_get_guint8 (tvb, pos + 1);
342 tlv_item = proto_tree_add_text (mdd_tree, tvb, pos, length + 2,"%s", val_to_str(type, mdd_tlv_vals, "Unknown TLV (%u)"));
343 tlv_tree = proto_item_add_subtree (tlv_item, ett_tlv);
345 switch(type) {
347 case DOWNSTREAM_ACTIVE_CHANNEL_LIST:
348 subpos = pos + 2;
349 while (subpos < pos + length + 2) {
350 subtype = tvb_get_guint8 (tvb, subpos);
351 sublength = tvb_get_guint8 (tvb, subpos + 1);
352 switch(subtype) {
353 case DOWNSTREAM_ACTIVE_CHANNEL_LIST_CHANNEL_ID:
354 proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_channel_id, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
355 break;
356 case DOWNSTREAM_ACTIVE_CHANNEL_LIST_FREQUENCY:
357 proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_frequency, tvb, subpos + 2 , 4, ENC_BIG_ENDIAN);
358 break;
359 case DOWNSTREAM_ACTIVE_CHANNEL_LIST_MODULATION_ORDER_ANNEX:
360 tlv_sub_item = proto_tree_add_text (tlv_tree, tvb, subpos + 2, 1, "Modulation Order/Annex");
361 tlv_sub_tree = proto_item_add_subtree (tlv_sub_item, ett_sub_tlv);
362 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_downstream_active_channel_list_modulation_order, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
363 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_downstream_active_channel_list_annex, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
364 break;
365 case DOWNSTREAM_ACTIVE_CHANNEL_LIST_PRIMARY_CAPABLE:
366 proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_primary_capable, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
367 break;
368 case DOWNSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK:
369 tlv_sub_item = proto_tree_add_text (tlv_tree, tvb, subpos + 2, 2, "CM-STATUS Event Enable Bitmask");
370 tlv_sub_tree = proto_item_add_subtree (tlv_sub_item, ett_sub_tlv);
371 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout, tvb, subpos + 2 , 2,ENC_BIG_ENDIAN);
372 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_failure, tvb, subpos + 2 , 2, ENC_BIG_ENDIAN);
373 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_recovery, tvb, subpos + 2 , 2,ENC_BIG_ENDIAN);
374 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_recovery, tvb, subpos + 2 , 2, ENC_BIG_ENDIAN);
375 break;
377 subpos += sublength + 2;
379 break;
380 case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP:
381 subpos = pos + 2;
382 while (subpos < pos + length + 2) {
383 subtype = tvb_get_guint8 (tvb, subpos);
384 sublength = tvb_get_guint8 (tvb, subpos + 1);
385 switch(subtype) {
386 case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_MD_DS_SG_IDENTIFIER:
387 proto_tree_add_item (tlv_tree, hf_docsis_mdd_mac_domain_downstream_service_group_md_ds_sg_identifier, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
388 break;
389 case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_CHANNEL_IDS:
390 for (i = 0; i < sublength; i++) {
391 proto_tree_add_item (tlv_tree, hf_docsis_mdd_mac_domain_downstream_service_group_channel_id, tvb, subpos + 2 + i , 1, ENC_BIG_ENDIAN);
393 break;
395 subpos += sublength + 2;
397 break;
398 case DOWNSTREAM_AMBIGUITY_RESOLUTION_FREQUENCY_LIST:
399 subpos = pos + 2;
400 for (i = 0; i < length; i+=4) {
401 proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_ambiguity_resolution_frequency, tvb, subpos + i , 4, ENC_BIG_ENDIAN);
403 break;
404 case RECEIVE_CHANNEL_PROFILE_REPORTING_CONTROL:
405 subpos = pos + 2;
406 while (subpos < pos + length + 2) {
407 subtype = tvb_get_guint8 (tvb, subpos);
408 sublength = tvb_get_guint8 (tvb, subpos + 1);
409 switch(subtype) {
410 case RCP_CENTER_FREQUENCY_SPACING:
411 proto_tree_add_item (tlv_tree, hf_docsis_mdd_rpc_center_frequency_spacing, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
412 break;
413 case VERBOSE_RCP_REPORTING:
414 proto_tree_add_item (tlv_tree, hf_docsis_mdd_verbose_rcp_reporting, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
415 break;
417 subpos += sublength + 2;
419 break;
420 case IP_INITIALIZATION_PARAMETERS:
421 subpos = pos + 2;
422 while (subpos < pos + length + 2) {
423 subtype = tvb_get_guint8 (tvb, subpos);
424 sublength = tvb_get_guint8 (tvb, subpos + 1);
425 switch(subtype) {
426 case IP_PROVISIONING_MODE:
427 proto_tree_add_item (tlv_tree, hf_docsis_mdd_ip_provisioning_mode, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
428 break;
429 case PRE_REGISTRATION_DSID:
430 proto_tree_add_item (tlv_tree, hf_docsis_mdd_pre_registration_dsid, tvb, subpos + 2 , 3, ENC_BIG_ENDIAN);
431 break;
433 subpos += sublength + 2;
435 break;
436 case EARLY_AUTHENTICATION_AND_ENCRYPTION:
437 subpos = pos + 2;
438 proto_tree_add_item (tlv_tree, hf_docsis_mdd_early_authentication_and_encryption, tvb, subpos, 1, ENC_BIG_ENDIAN);
439 break;
440 case UPSTREAM_ACTIVE_CHANNEL_LIST:
441 subpos = pos + 2;
442 while (subpos < pos + length + 2) {
443 subtype = tvb_get_guint8 (tvb, subpos);
444 sublength = tvb_get_guint8 (tvb, subpos + 1);
445 switch(subtype) {
446 case UPSTREAM_ACTIVE_CHANNEL_LIST_UPSTREAM_CHANNEL_ID:
447 proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_active_channel_list_upstream_channel_id, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN);
448 break;
449 case UPSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK:
450 tlv_sub_item = proto_tree_add_text (tlv_tree, tvb, subpos + 2, 2, "CM-STATUS Event Enable Bitmask");
451 tlv_sub_tree = proto_item_add_subtree (tlv_sub_item, ett_sub_tlv);
452 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout, tvb, subpos + 2 , 2, ENC_BIG_ENDIAN);
453 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_t3_retries_exceeded, tvb, subpos + 2 , 2, ENC_BIG_ENDIAN);
454 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_successful_ranging_after_t3_retries_exceeded, tvb, subpos + 2 , 2, ENC_BIG_ENDIAN);
455 break;
457 subpos += sublength + 2;
459 break;
460 case UPSTREAM_AMBIGUITY_RESOLUTION_CHANNEL_LIST:
461 sublength = tvb_get_guint8 (tvb, subpos + 1);
462 for (i = 0; i < sublength; i++) {
463 proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_ambiguity_resolution_channel_list_channel_id, tvb, pos + 2 + i , 1, ENC_BIG_ENDIAN);
465 break;
466 case UPSTREAM_FREQUENCY_RANGE:
467 subpos = pos + 2;
468 proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_frequency_range, tvb, subpos, 1, ENC_BIG_ENDIAN);
469 break;
470 case SYMBOL_CLOCK_LOCKING_INDICATOR:
471 subpos = pos + 2;
472 proto_tree_add_item (tlv_tree, hf_docsis_mdd_symbol_clock_locking_indicator, tvb, subpos, 1, ENC_BIG_ENDIAN);
473 break;
474 case CM_STATUS_EVENT_CONTROL:
475 subpos = pos + 2;
476 while (subpos < pos + length + 2) {
477 subtype = tvb_get_guint8 (tvb, subpos);
478 sublength = tvb_get_guint8 (tvb, subpos + 1);
479 switch(subtype) {
480 case EVENT_TYPE_CODE:
481 proto_tree_add_item (tlv_tree, hf_docsis_mdd_event_type, tvb, subpos+2, 1, ENC_BIG_ENDIAN);
482 break;
483 case MAXIMUM_EVENT_HOLDOFF_TIMER:
484 text_item = proto_tree_add_item (tlv_tree, hf_docsis_mdd_maximum_event_holdoff_timer, tvb, subpos, 2, ENC_BIG_ENDIAN);
485 proto_item_append_text(text_item, " (%d ms)", (256*tvb_get_guint8 (tvb, subpos) + tvb_get_guint8 (tvb, subpos + 1)) * 20);
486 break;
487 case MAXIMUM_NUMBER_OF_REPORTS_PER_EVENT:
488 text_item = proto_tree_add_item (tlv_tree, hf_docsis_mdd_maximum_number_of_reports_per_event, tvb, subpos, 1, ENC_BIG_ENDIAN);
489 if ( tvb_get_guint8 (tvb, subpos) == 0) {
490 proto_item_append_text(text_item, " (Unlimited)");
492 break;
494 subpos += sublength + 2;
496 break;
497 case UPSTREAM_TRANSMIT_POWER_REPORTING:
498 subpos = pos + 2;
499 proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_transmit_power_reporting, tvb, subpos, 1, ENC_BIG_ENDIAN);
500 break;
501 case DSG_DA_TO_DSID_ASSOCIATION_ENTRY:
502 subpos = pos + 2;
503 while (subpos < pos + length + 2) {
504 subtype = tvb_get_guint8 (tvb, subpos);
505 sublength = tvb_get_guint8 (tvb, subpos + 1);
506 switch(subtype) {
507 case DSG_DA_TO_DSID_ASSOCIATION_DA:
508 proto_tree_add_item (tlv_tree, hf_docsis_mdd_dsg_da_to_dsid_association_da, tvb, subpos + 2, 6, ENC_BIG_ENDIAN);
509 break;
510 case DSG_DA_TO_DSID_ASSOCIATION_DSID:
511 proto_tree_add_item (tlv_tree, hf_docsis_mdd_dsg_da_to_dsid_association_dsid, tvb, subpos + 2, 3, ENC_BIG_ENDIAN);
512 break;
514 subpos += sublength + 2;
516 break;
517 case CM_STATUS_EVENT_ENABLE_NON_CHANNEL_SPECIFIC_EVENTS:
518 subpos = pos + 2;
519 tlv_sub_item = proto_tree_add_text (tlv_tree, tvb, subpos, 2, "CM-STATUS Event Enable Bitmask for Non-Channel-Specific Events");
520 tlv_sub_tree = proto_item_add_subtree (tlv_sub_item, ett_sub_tlv);
521 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_sequence_out_of_range, tvb, subpos, 2,ENC_BIG_ENDIAN);
522 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_operating_on_battery_backup, tvb, subpos , 2,ENC_BIG_ENDIAN);
523 proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_returned_to_ac_power, tvb, subpos , 2,ENC_BIG_ENDIAN);
524 break;
526 pos += length + 2;
528 } /* if(tree) */
534 /* Register the protocol with Wireshark */
536 /* this format is require because a script is used to build the C function
537 that calls all the protocol registration.
541 void proto_register_docsis_mdd (void)
543 /* Setup list of header fields See Section 1.6.1 for details*/
544 static hf_register_info hf[] = {
545 {&hf_docsis_mdd_ccc,
546 {"Configuration Change Count", "docsis_mdd.ccc",
547 FT_UINT8, BASE_DEC, NULL, 0x0,
548 "Mdd Configuration Change Count", HFILL}
550 {&hf_docsis_mdd_number_of_fragments,
551 {"Number of Fragments", "docsis_mdd.number_of_fragments",
552 FT_UINT8, BASE_DEC, NULL, 0x0,
553 "Mdd Number of Fragments", HFILL}
555 {&hf_docsis_mdd_fragment_sequence_number,
556 {"Fragment Sequence Number", "docsis_mdd.fragment_sequence_number",
557 FT_UINT8, BASE_DEC, NULL, 0x0,
558 "Mdd Fragment Sequence Number", HFILL}
560 {&hf_docsis_mdd_current_channel_dcid,
561 {"Current Channel DCID", "docsis_mdd.current_channel_dcid",
562 FT_UINT8, BASE_DEC, NULL, 0x0,
563 "Mdd Current Channel DCID", HFILL}
565 {&hf_docsis_mdd_downstream_active_channel_list_channel_id,
566 {"Channel ID", "docsis_mdd.downstream_active_channel_list_channel_id",
567 FT_UINT8, BASE_DEC, NULL, 0x0,
568 "Mdd Downstream Active Channel List Channel ID", HFILL}
570 {&hf_docsis_mdd_downstream_active_channel_list_frequency,
571 {"Frequency", "docsis_mdd.downstream_active_channel_list_frequency",
572 FT_UINT32, BASE_DEC, NULL, 0x0,
573 "Mdd Downstream Active Channel List Frequency", HFILL}
575 {&hf_docsis_mdd_downstream_active_channel_list_annex,
576 {"Annex", "docsis_mdd.downstream_active_channel_list_annex",
577 FT_UINT8, BASE_DEC, VALS(J83_annex_vals), 0xF0,
578 "Mdd Downstream Active Channel List Annex", HFILL}
580 {&hf_docsis_mdd_downstream_active_channel_list_modulation_order,
581 {"Modulation Order", "docsis_mdd.downstream_active_channel_list_modulation_order",
582 FT_UINT8, BASE_DEC, VALS(modulation_order_vals), 0x0F,
583 "Mdd Downstream Active Channel List Modulation Order", HFILL}
585 {&hf_docsis_mdd_downstream_active_channel_list_primary_capable,
586 {"Primary Capable", "docsis_mdd.downstream_active_channel_list_primary_capable",
587 FT_UINT8, BASE_DEC, VALS(primary_capable_vals), 0x0,
588 "Mdd Downstream Active Channel List Primary Capable", HFILL}
590 {&hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout,
591 {"MDD Timeout", "docsis_mdd.downstream_active_channel_list_mdd_timeout",
592 FT_UINT16, BASE_DEC, NULL, 0x0002,
593 "Mdd Downstream Active Channel List MDD Timeout", HFILL}
595 {&hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_failure,
596 {"QAM/FEC Lock Failure", "docsis_mdd.cm_status_event_enable_bitmask_qam_fec_lock_failure",
597 FT_UINT16, BASE_DEC, NULL, 0x0004,
598 "Mdd Downstream Active Channel List QAM/FEC Lock Failure", HFILL}
600 {&hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_recovery,
601 {"MDD Recovery", "docsis_mdd.cm_status_event_enable_bitmask_mdd_recovery",
602 FT_UINT16, BASE_DEC, NULL, 0x0010,
603 "CM-STATUS event MDD Recovery", HFILL}
605 {&hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_recovery,
606 {"QAM/FEC Lock Recovery", "docsis_mdd.cm_status_event_enable_bitmask_qam_fec_lock_recovery",
607 FT_UINT16, BASE_DEC, NULL, 0x0020,
608 "CM-STATUS event QAM/FEC Lock Recovery", HFILL}
610 {&hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout,
611 {"T4 timeout", "docsis_mdd.cm_status_event_enable_bitmask_t4_timeout",
612 FT_UINT16, BASE_DEC, NULL, 0x0040,
613 "CM-STATUS event T4 timeout", HFILL}
615 {&hf_docsis_mdd_cm_status_event_enable_bitmask_t3_retries_exceeded,
616 {"T3 Retries Exceeded", "docsis_mdd.cm_status_event_enable_bitmask_t3_retries_exceeded",
617 FT_UINT16, BASE_DEC, NULL, 0x0080,
618 "CM-STATUS event T3 Retries Exceeded", HFILL}
620 {&hf_docsis_mdd_cm_status_event_enable_bitmask_successful_ranging_after_t3_retries_exceeded,
621 {"Successful Ranging after T3 Retries Exceeded", "docsis_mdd.cm_status_event_enable_bitmask_successful_ranging_after_t3_retries_exceeded",
622 FT_UINT16, BASE_DEC, NULL, 0x0100,
623 "CM-STATUS event Successful Ranging after T3 Retries Exceeded", HFILL}
625 {&hf_docsis_mdd_mac_domain_downstream_service_group_channel_id,
626 {"Channel Id", "docsis_mdd.mac_domain_downstream_service_group_channel_id",
627 FT_UINT8, BASE_DEC, NULL, 0x0,
628 "Mdd Mac Domain Downstream Service Group Channel Id", HFILL}
630 {&hf_docsis_mdd_mac_domain_downstream_service_group_md_ds_sg_identifier,
631 {"MD-DS-SG Identifier", "docsis_mdd.mac_domain_downstream_service_group_md_ds_sg_identifier",
632 FT_UINT8, BASE_DEC, NULL, 0x0,
633 "Mdd Mac Domain Downstream Service Group MD-DS-SG Identifier", HFILL}
635 {&hf_docsis_mdd_downstream_ambiguity_resolution_frequency,
636 {"Frequency", "docsis_mdd.downstream_ambiguity_resolution_frequency",
637 FT_UINT32, BASE_DEC, NULL, 0x0,
638 "Mdd Downstream Ambiguity Resolution frequency", HFILL}
640 {&hf_docsis_mdd_rpc_center_frequency_spacing,
641 {"RPC Center Frequency Spacing", "docsis_mdd.rpc_center_frequency_spacing",
642 FT_UINT8, BASE_DEC, VALS(rpc_center_frequency_spacing_vals), 0x0,
643 "Mdd RPC Center Frequency Spacing", HFILL}
645 {&hf_docsis_mdd_verbose_rcp_reporting,
646 {"Verbose RCP reporting", "docsis_mdd.verbose_rpc_reporting",
647 FT_UINT8, BASE_DEC, VALS(verbose_rpc_reporting_vals), 0x0,
648 "Mdd Verbose RPC Reporting", HFILL}
650 {&hf_docsis_mdd_ip_provisioning_mode,
651 {"IP Provisioning Mode", "docsis_mdd.ip_provisioning_mode",
652 FT_UINT8, BASE_DEC, VALS(ip_provisioning_mode_vals), 0x0,
653 "Mdd IP Provisioning Mode", HFILL}
655 {&hf_docsis_mdd_pre_registration_dsid,
656 {"Pre-registration DSID", "docsis_mdd.pre_registration_dsid",
657 FT_UINT24, BASE_DEC, NULL, 0x0FFFFF,
658 "Mdd Pre-registration DSID", HFILL}
660 {&hf_docsis_mdd_early_authentication_and_encryption,
661 {"Early Authentication and Encryption", "docsis_mdd.early_authentication_and_encryption",
662 FT_UINT8, BASE_DEC, VALS(eae_vals), 0x0,
663 "Mdd Early Authentication and Encryption", HFILL}
665 {&hf_docsis_mdd_upstream_active_channel_list_upstream_channel_id,
666 {"Upstream Channel Id", "docsis_mdd.upstream_active_channel_list_upstream_channel_id",
667 FT_UINT8, BASE_DEC, NULL, 0x0,
668 "Mdd Upstream Active Channel List Upstream Channel Id", HFILL}
670 {&hf_docsis_mdd_upstream_ambiguity_resolution_channel_list_channel_id,
671 {"Channel Id", "docsis_mdd.upstream_ambiguity_resolution_channel_list_channel_id",
672 FT_UINT8, BASE_DEC, NULL, 0x0,
673 "Mdd Mac Domain Upstream Ambiguity Resolution Channel List Channel Id", HFILL}
675 {&hf_docsis_mdd_upstream_frequency_range,
676 {"Upstream Frequency Range", "docsis_mdd.upstream_frequency_range",
677 FT_UINT8, BASE_DEC, VALS(upstream_frequency_range_vals), 0x0,
678 "Mdd Upstream Frequency Range", HFILL}
680 {&hf_docsis_mdd_symbol_clock_locking_indicator,
681 {"Symbol Clock Locking Indicator", "docsis_mdd.symbol_clock_locking_indicator",
682 FT_UINT8, BASE_DEC, VALS(symbol_clock_locking_indicator_vals), 0x0,
683 "Mdd Symbol Clock Locking Indicator", HFILL}
685 {&hf_docsis_mdd_event_type,
686 {"Event Type", "docsis_mdd.event_type",
687 FT_UINT8, BASE_DEC, VALS(symbol_cm_status_event_vals), 0x0,
688 "Mdd CM-STATUS Event Type", HFILL}
690 {&hf_docsis_mdd_maximum_event_holdoff_timer,
691 {"Maximum Event Holdoff Timer (units of 20 ms)", "docsis_mdd.maximum_event_holdoff_timer",
692 FT_UINT16, BASE_DEC, NULL, 0x0,
693 "Mdd Maximum Event Holdoff Timer", HFILL}
695 {&hf_docsis_mdd_maximum_number_of_reports_per_event,
696 {"Maximum Number of Reports per Event", "docsis_mdd.maximum_number_of_reports_per_event",
697 FT_UINT8, BASE_DEC, NULL, 0x0,
698 "Mdd Maximum Number of Reports per Event", HFILL}
700 {&hf_docsis_mdd_upstream_transmit_power_reporting,
701 {"Upstream Transmit Power Reporting", "docsis_mdd.upstream_transmit_power_reporting",
702 FT_UINT8, BASE_DEC, VALS(upstream_transmit_power_reporting_vals), 0x0,
703 "Mdd Upstream Transmit Power Reporting", HFILL}
705 {&hf_docsis_mdd_dsg_da_to_dsid_association_da,
706 {"Destination Address", "docsis_mdd.dsg_da_to_dsid_association_da",
707 FT_ETHER, BASE_NONE, NULL, 0x0,
708 "Mdd DSG DA to DSID association Destination Address", HFILL}
710 {&hf_docsis_mdd_dsg_da_to_dsid_association_dsid,
711 {"DSID", "docsis_mdd.dsg_da_to_dsid_association_dsid",
712 FT_UINT24, BASE_DEC, NULL, 0x0FFFFF,
713 "Mdd Mdd DSG DA to DSID association DSID", HFILL}
715 {&hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_sequence_out_of_range,
716 {"Sequence out of range", "docsis_mdd.cm_status_event_enable_non_channel_specific_events_sequence_out_of_range",
717 FT_UINT16, BASE_DEC, NULL, 0x0008,
718 "CM-STATUS event non-channel-event Sequence out of range", HFILL}
720 {&hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_operating_on_battery_backup,
721 {"CM operating on battery backup", "docsis_mdd.cm_status_event_enable_non_channel_specific_events_cm_operating_on_battery_backup",
722 FT_UINT16, BASE_DEC, NULL, 0x0200,
723 "CM-STATUS event non-channel-event Cm operating on battery backup", HFILL}
725 {&hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_returned_to_ac_power,
726 {"Returned to AC power", "docsis_mdd.cm_status_event_enable_non_channel_specific_events_cm_returned_to_ac_power",
727 FT_UINT16, BASE_DEC, NULL, 0x0400,
728 "CM-STATUS event non-channel-event Cm returned to AC power", HFILL}
733 /* Setup protocol subtree array */
734 static gint *ett[] = {
735 &ett_docsis_mdd,
736 &ett_tlv,
737 &ett_sub_tlv
740 /* Register the protocol name and description */
741 proto_docsis_mdd =
742 proto_register_protocol ("DOCSIS Mac Domain Description",
743 "DOCSIS Mdd", "docsis_mdd");
745 /* Required function calls to register the header fields and subtrees used */
746 proto_register_field_array (proto_docsis_mdd, hf, array_length (hf));
747 proto_register_subtree_array (ett, array_length (ett));
749 register_dissector ("docsis_mdd", dissect_mdd, proto_docsis_mdd);
753 /* If this dissector uses sub-dissector registration add a registration routine.
754 This format is required because a script is used to find these routines and
755 create the code that calls these routines.
757 void
758 proto_reg_handoff_docsis_mdd (void)
760 dissector_handle_t docsis_mdd_handle;
762 docsis_mdd_handle = find_dissector ("docsis_mdd");
763 dissector_add_uint ("docsis_mgmt", 33, docsis_mdd_handle);