epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-xra.c
blobe81c357c9ad25959c53f5f1995822884db9b7dc2
1 /* packet-xra.c
2 * Routines for Excentis DOCSIS31 XRA31 sniffer dissection
3 * Copyright 2017, Bruno Verstuyft <bruno.verstuyft[AT]excentis.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <wiretap/wtap.h>
16 #include <wsutil/utf8_entities.h>
17 #include <epan/expert.h>
18 #include <epan/crc16-tvb.h>
19 #include <epan/tfs.h>
20 #include <wsutil/array.h>
22 void proto_register_xra(void);
23 void proto_reg_handoff_xra(void);
25 /* Initialize the protocol and registered fields */
26 static dissector_handle_t docsis_handle;
27 static dissector_handle_t xra_handle;
29 static int proto_xra;
31 static int proto_plc;
32 static int proto_ncp;
33 static int proto_segment;
34 static int proto_init_ranging;
36 static int ett_xra;
37 static int ett_xra_tlv;
38 static int ett_xra_tlv_cw_info;
39 static int ett_xra_tlv_ms_info;
40 static int ett_xra_tlv_burst_info;
41 static int ett_plc;
42 static int ett_plc_mb;
43 static int ett_plc_timestamp;
44 static int ett_ncp;
45 static int ett_ncp_mb;
46 static int ett_init_ranging;
48 static int hf_xra_version;
49 static int hf_xra_direction;
50 static int hf_xra_packettype;
51 static int hf_xra_tlvlength;
52 static int hf_xra_tlv;
54 /* XRA TLV */
55 static int hf_xra_tlv_ds_channel_id;
56 static int hf_xra_tlv_ds_channel_frequency;
57 static int hf_xra_tlv_modulation;
58 static int hf_xra_tlv_annex;
59 static int hf_xra_tlv_us_channel_id;
60 static int hf_xra_tlv_profile_id;
61 static int hf_xra_tlv_sid;
62 static int hf_xra_tlv_iuc;
63 static int hf_xra_tlv_burstid;
64 static int hf_xra_tlv_ms_info;
65 static int hf_xra_tlv_burst_info;
66 static int hf_xra_tlv_ucd_ccc_parity;
67 static int hf_xra_tlv_grant_size;
68 static int hf_xra_tlv_segment_header_present;
69 static int hf_xra_tlv_ncp_trunc;
70 static int hf_xra_tlv_ncp_symbolid;
72 /* Minislot Info */
73 static int hf_xra_tlv_start_minislot_id_abs;
74 static int hf_xra_tlv_start_minislot_id_rel;
75 static int hf_xra_tlv_stop_minislot_id_rel;
77 /* Ranging TLV */
78 static int hf_xra_tlv_ranging_number_ofdma_frames;
79 static int hf_xra_tlv_ranging_timing_adjust;
81 static int hf_xra_tlv_power_level;
82 static int hf_xra_tlv_mer;
83 static int hf_xra_tlv_subslot_id;
84 static int hf_xra_tlv_control_word;
86 static int hf_xra_unknown;
88 /* Codeword Info TLV */
89 static int hf_xra_tlv_cw_info;
90 static int hf_xra_tlv_cw_info_nr_of_info_bytes;
91 static int hf_xra_tlv_cw_info_bch_decoding_successful;
92 static int hf_xra_tlv_cw_info_profile_parity;
93 static int hf_xra_tlv_cw_info_bch_number_of_corrected_bits;
94 static int hf_xra_tlv_cw_info_ldpc_nr_of_code_bits;
95 static int hf_xra_tlv_cw_info_ldpc_decoding_successful;
96 static int hf_xra_tlv_cw_info_ldpc_number_of_corrected_bits;
97 static int hf_xra_tlv_cw_info_ldpc_number_of_iterations;
98 static int hf_xra_tlv_cw_info_rs_decoding_successful;
99 static int hf_xra_tlv_cw_info_rs_number_of_corrected_symbols;
101 /* Burst Info TLV */
102 static int hf_xra_tlv_burst_info_burst_id_reference;
104 /* PLC Specific */
105 static int hf_plc_mb;
107 /* NCP Specific */
108 static int hf_ncp_mb;
109 static int hf_ncp_mb_profileid;
110 static int hf_ncp_mb_z;
111 static int hf_ncp_mb_c;
112 static int hf_ncp_mb_n;
113 static int hf_ncp_mb_l;
114 static int hf_ncp_mb_t;
115 static int hf_ncp_mb_u;
116 static int hf_ncp_mb_r;
117 static int hf_ncp_mb_subcarrier_start_pointer;
118 static int hf_ncp_crc;
120 /* Init Ranging Specific */
121 static int hf_xra_init_ranging_mac;
122 static int hf_xra_init_ranging_ds_channel_id;
123 static int hf_xra_init_ranging_crc;
125 /* PLC MB */
126 static int hf_plc_em_mb;
127 static int hf_plc_trigger_mb;
129 /* PLC Timestamp MB Specific */
130 static int hf_plc_mb_ts_reserved;
131 static int hf_plc_mb_ts_timestamp;
132 static int hf_plc_mb_ts_timestamp_epoch;
133 static int hf_plc_mb_ts_timestamp_d30timestamp;
134 static int hf_plc_mb_ts_timestamp_extra_204_8;
135 static int hf_plc_mb_ts_timestamp_extra_204_8_X_16;
136 static int hf_plc_mb_ts_timestamp_formatted;
137 static int hf_plc_mb_ts_crc24d;
139 /* PLC Message Channel MB Specific */
140 static int hf_plc_mb_mc_reserved;
141 static int hf_plc_mb_mc_pspf_present;
142 static int hf_plc_mb_mc_psp;
144 /* OFDMA Segment */
145 static int hf_docsis_segment_pfi;
146 static int hf_docsis_segment_reserved;
147 static int hf_docsis_segment_pointerfield;
148 static int hf_docsis_segment_sequencenumber;
149 static int hf_docsis_segment_sidclusterid;
150 static int hf_docsis_segment_request;
151 static int hf_docsis_segment_hcs;
152 static int hf_docsis_segment_hcs_status;
153 static int hf_docsis_segment_data;
155 static expert_field ei_docsis_segment_hcs_bad;
157 static int dissect_xra(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_);
158 static int dissect_xra_tlv(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_, uint16_t tlvLength, unsigned* segmentHeaderPresent);
159 static int dissect_plc(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_);
160 static int dissect_ncp(tvbuff_t * tvb, proto_tree * tree, void* data _U_);
161 static int dissect_init_ranging(tvbuff_t * tvb, proto_tree * tree, void* data _U_);
162 static int dissect_ofdma_segment(tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, void* data _U_);
164 #define XRA_DIRECTION_DOWNSTREAM 0
165 #define XRA_DIRECTION_UPSTREAM 1
167 #define XRA_PACKETTYPE_DS_SCQAM_DOCSIS_MACFRAME 1
168 #define XRA_PACKETTYPE_OFDM_DOCSIS 8
169 #define XRA_PACKETTYPE_OFDM_NCP 9
170 #define XRA_PACKETTYPE_OFDM_PLC 10
171 #define XRA_PACKETTYPE_OFDM_PLC_MMM 11
173 #define XRA_PACKETTYPE_TDMA_BURST 65
174 #define XRA_PACKETTYPE_OFDMA_DATA_BURST 72
175 #define XRA_PACKETTTYPE_OFDMA_INITIAL_RANGING 73
176 #define XRA_PACKETTTYPE_OFDMA_FINE_RANGING 74
177 #define XRA_PACKETTYPE_OFDMA_REQ 75
178 #define XRA_PACKETTYPE_OFDMA_PROBING_SEQUENCE 76
179 #define XRA_PACKETTYPE_US_DOCSIS_MACFRAME 80
181 /* TLVs */
182 #define XRA_DS_CHANNEL_ID 1
183 #define XRA_DS_FREQUENCY 2
184 #define XRA_MODULATION 3
185 #define XRA_ANNEX 4
186 #define XRA_PROFILE_ID 5
187 #define XRA_CODEWORD_INFO 6
188 #define XRA_NCP_TRUNC 7
189 #define XRA_NCP_SYMBOLID 8
190 #define XRA_MER 9
191 #define XRA_US_CHANNEL_ID 10
192 #define XRA_SID 11
193 #define XRA_IUC 12
194 #define XRA_BURST_ID 13
195 #define XRA_BURST_INFO 14
196 #define XRA_MINISLOT_INFO 15
197 #define XRA_UCD_CCC_PARITY 16
198 #define XRA_GRANT_SIZE 17
199 #define XRA_SEGMENT_HEADER_PRESENT 18
200 #define XRA_NUMBER_OFDMA_FRAMES 19
201 #define XRA_ESTIMATED_TIMING_ADJUST 20
202 #define XRA_ESTIMATED_POWER_LEVEL 21
203 #define XRA_SUBSLOT_ID 22
204 #define XRA_CONTROL_WORD 23
206 #define XRA_CONFIGURATION_INFO 254
207 #define XRA_EXTENSION_TYPE 255
209 /* Codeword Info Sub-TLVs */
210 #define XRA_TLV_CW_INFO_PROFILE_PARITY 1
211 #define XRA_TLV_CW_INFO_NR_OF_INFO_BYTES 2
212 #define XRA_TLV_CW_INFO_BCH_DECODING_SUCCESFUL 3
213 #define XRA_TLV_CW_INFO_BCH_NUMBER_OF_CORRECTED_BITS 4
214 #define XRA_TLV_CW_INFO_LDPC_NUMBER_OF_CODE_BITS 5
215 #define XRA_TLV_CW_INFO_LDPC_DECODING_SUCCESSFUL 6
216 #define XRA_TLV_CW_INFO_LDPC_NUMBER_OF_CORRECTED_BITS 7
217 #define XRA_TLV_CW_INFO_LDPC_NUMBER_OF_ITERATIONS 8
218 #define XRA_TLV_CW_INFO_RS_DECODING_SUCCESFUL 9
219 #define XRA_TLV_CW_INFO_RS_NUMBER_OF_CORRECTED_SYMBOLS 10
221 /* Burst Info Sub-TLV */
222 #define XRA_BURST_INFO_BURST_ID_REFERENCE 1
224 /* Minislot Info Sub-TLVs */
225 #define XRA_TLV_MINISLOT_INFO_START_MINISLOT_ID 1
226 #define XRA_TLV_MINISLOT_INFO_REL_START_MINISLOT 2
227 #define XRA_TLV_MINISLOT_INFO_REL_STOP_MINISLOT 3
229 /* PLC Message Block Types */
230 #define PLC_TIMESTAMP_MB 1
231 #define PLC_ENERGY_MANAGEMENT_MB 2
232 #define PLC_MESSAGE_CHANNEL_MB 3
233 #define PLC_TRIGGER_MB 4
235 static const value_string direction_vals[] = {
236 {XRA_DIRECTION_DOWNSTREAM, "Downstream"},
237 {XRA_DIRECTION_UPSTREAM, "Upstream"},
238 {0, NULL}
241 static const value_string packettype[] = {
242 {XRA_PACKETTYPE_DS_SCQAM_DOCSIS_MACFRAME, "SC-QAM DOCSIS MAC Frame"},
243 {XRA_PACKETTYPE_OFDM_DOCSIS, "OFDM DOCSIS"},
244 {XRA_PACKETTYPE_OFDM_NCP, "OFDM NCP"},
245 {XRA_PACKETTYPE_OFDM_PLC, "OFDM PLC"},
246 {XRA_PACKETTYPE_OFDM_PLC_MMM, "OFDM PLC MMM"},
247 {XRA_PACKETTYPE_TDMA_BURST, "TDMA Burst"},
248 {XRA_PACKETTYPE_OFDMA_DATA_BURST, "OFDMA Data Burst"},
249 {XRA_PACKETTTYPE_OFDMA_INITIAL_RANGING, "OFDMA Initial Ranging"},
250 {XRA_PACKETTTYPE_OFDMA_FINE_RANGING, "OFDMA Fine Ranging"},
251 {XRA_PACKETTYPE_OFDMA_REQ, "OFDMA REQ"},
252 {XRA_PACKETTYPE_OFDMA_PROBING_SEQUENCE, "OFDMA Probing Sequence"},
253 {XRA_PACKETTYPE_US_DOCSIS_MACFRAME, "US DOCSIS MAC Frame"},
254 {0, NULL}
257 static const value_string annex_vals[] = {
258 {0, "Annex A"},
259 {1, "Annex B"},
260 {0, NULL}
263 static const value_string modulation_vals[] = {
264 {0, "64-QAM"},
265 {1, "256-QAM"},
266 {0, NULL}
269 static const value_string profile_id[] = {
270 {0, "Profile A"},
271 {1, "Profile B"},
272 {2, "Profile C"},
273 {3, "Profile D"},
274 {4, "Profile E"},
275 {5, "Profile F"},
276 {6, "Profile G"},
277 {7, "Profile H"},
278 {8, "Profile I"},
279 {9, "Profile J"},
280 {10, "Profile K"},
281 {11, "Profile L"},
282 {12, "Profile M"},
283 {13, "Profile N"},
284 {14, "Profile O"},
285 {15, "Profile P"},
286 {0, NULL}
289 static const value_string message_block_type[] = {
290 {PLC_TIMESTAMP_MB, "Timestamp Message Block"},
291 {PLC_ENERGY_MANAGEMENT_MB, "Energy Management Message Block"},
292 {PLC_MESSAGE_CHANNEL_MB, "Message Channel Message Block"},
293 {PLC_TRIGGER_MB, "Trigger Message Block"},
294 {0, NULL}
297 static const true_false_string zero_bit_loading = {
298 "subcarriers are all zero-bit-loaded",
299 "subcarriers follow profile"
302 static const true_false_string data_profile_update = {
303 "use odd profile",
304 "use even profile"
307 static const true_false_string ncp_profile_select = {
308 "use odd profile",
309 "use even profile"
312 static const true_false_string last_ncp_block = {
313 "this is the last NCP in the chain and is followed by an NCP CRC message block",
314 "this NCP is followed by another NCP"
317 static const true_false_string codeword_tagging = {
318 "this codeword is included in the codeword counts reported by the CM in the OPT-RSP message",
319 "this codeword is not included in the codeword counts reported by the CM in the OPT-RSP message"
322 static const value_string local_proto_checksum_vals[] = {
323 { PROTO_CHECKSUM_E_BAD, "Bad"},
324 { PROTO_CHECKSUM_E_GOOD, "Good"},
325 { 0, NULL}
328 static const value_string control_word_vals[] = {
329 { 0, "I=128, J=1"},
330 { 1, "I=128, J=1"},
331 { 2, "I=128, J=2"},
332 { 3, "I=64, J=2"},
333 { 4, "I=128, J=3"},
334 { 5, "I=32, J=4"},
335 { 6, "I=128, J=4"},
336 { 7, "I=16, J=8"},
337 { 8, "I=128, J=5"},
338 { 9, "I=8, J=16"},
339 { 10, "I=128, J=6"},
340 { 11, "Reserved"},
341 { 12, "I=128, J=7"},
342 { 13, "Reserved"},
343 { 14, "I=128, J=8"},
344 { 15, "Reserved"},
345 { 0, NULL}
348 static int
349 dissect_xra(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) {
350 proto_item *it;
351 proto_tree *xra_tree;
353 it = proto_tree_add_protocol_format (tree, proto_xra, tvb, 0, -1, "XRA");
355 xra_tree = proto_item_add_subtree (it, ett_xra);
357 tvbuff_t *docsis_tvb;
358 tvbuff_t *plc_tvb;
359 tvbuff_t *ncp_tvb;
360 tvbuff_t *xra_tlv_tvb;
361 tvbuff_t *segment_tvb;
362 tvbuff_t *init_ranging_tvb;
364 unsigned direction, packet_type, tlv_length;
366 proto_tree_add_item (xra_tree, hf_xra_version, tvb, 0, 1, ENC_BIG_ENDIAN);
367 proto_tree_add_item_ret_uint (xra_tree, hf_xra_direction, tvb, 1, 1, ENC_BIG_ENDIAN, &direction);
368 proto_tree_add_item_ret_uint (xra_tree, hf_xra_packettype, tvb, 1, 1, ENC_BIG_ENDIAN, &packet_type);
369 proto_tree_add_item_ret_uint (xra_tree, hf_xra_tlvlength, tvb, 2, 2, ENC_BIG_ENDIAN, &tlv_length);
371 uint16_t xra_length = 4 + tlv_length;
372 proto_item_append_text(it, " (Excentis XRA header: %d bytes). DOCSIS frame is %d bytes.", xra_length, tvb_reported_length_remaining(tvb, xra_length));
373 proto_item_set_len(it, xra_length);
375 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(packet_type, packettype, "Unknown XRA Packet Type: %u"));
377 /* Dissecting TLVs */
378 unsigned segment_header_present = 0;
379 xra_tlv_tvb = tvb_new_subset_length(tvb, 4, tlv_length);
380 dissect_xra_tlv(xra_tlv_tvb, pinfo, xra_tree, data, tlv_length, &segment_header_present);
382 if(tvb_reported_length_remaining(tvb, xra_length) == 0) {
383 return xra_length;
385 /* Dissecting contents */
386 switch(packet_type) {
387 case XRA_PACKETTYPE_DS_SCQAM_DOCSIS_MACFRAME:
388 case XRA_PACKETTYPE_OFDM_DOCSIS:
389 case XRA_PACKETTYPE_OFDM_PLC_MMM:
390 /* Calling DOCSIS dissector */
391 docsis_tvb = tvb_new_subset_remaining(tvb, xra_length);
392 if (docsis_handle) {
393 call_dissector (docsis_handle, docsis_tvb, pinfo, tree);
395 break;
396 case XRA_PACKETTYPE_OFDM_PLC:
397 plc_tvb = tvb_new_subset_remaining(tvb, xra_length);
398 return dissect_plc(plc_tvb , pinfo, tree, data);
399 case XRA_PACKETTYPE_OFDM_NCP:
400 ncp_tvb = tvb_new_subset_remaining(tvb, xra_length);
401 return dissect_ncp(ncp_tvb, tree, data);
402 case XRA_PACKETTYPE_TDMA_BURST:
403 case XRA_PACKETTYPE_OFDMA_DATA_BURST:
404 if(segment_header_present) {
405 col_append_str(pinfo->cinfo, COL_INFO, ": Segment");
406 segment_tvb = tvb_new_subset_remaining(tvb, xra_length);
407 return dissect_ofdma_segment(segment_tvb, pinfo, tree, data);
409 break;
410 case XRA_PACKETTYPE_OFDMA_REQ:
411 case XRA_PACKETTYPE_US_DOCSIS_MACFRAME:
412 /* Calling DOCSIS dissector */
413 docsis_tvb = tvb_new_subset_remaining(tvb, xra_length);
414 if (docsis_handle) {
415 call_dissector (docsis_handle, docsis_tvb, pinfo, tree);
417 break;
418 case XRA_PACKETTTYPE_OFDMA_FINE_RANGING:
419 /* Calling DOCSIS dissector */
420 docsis_tvb = tvb_new_subset_remaining(tvb, xra_length);
421 if (docsis_handle) {
422 call_dissector (docsis_handle, docsis_tvb, pinfo, tree);
424 break;
425 case XRA_PACKETTTYPE_OFDMA_INITIAL_RANGING:
426 init_ranging_tvb = tvb_new_subset_remaining(tvb, xra_length);
427 return dissect_init_ranging(init_ranging_tvb, tree, data);
428 default:
429 proto_tree_add_item (xra_tree, hf_xra_unknown, tvb, 1, 1, ENC_NA);
430 break;
433 return tvb_captured_length(tvb);
436 static int
437 dissect_xra_tlv_cw_info(tvbuff_t * tvb, proto_tree * tree, void* data _U_, uint16_t tlv_length) {
438 proto_item *it;
439 proto_tree *xra_tlv_cw_info_tree;
441 it = proto_tree_add_item (tree, hf_xra_tlv_cw_info, tvb, 0, tlv_length, ENC_NA);
442 xra_tlv_cw_info_tree = proto_item_add_subtree (it, ett_xra_tlv_cw_info);
444 unsigned tlv_index = 0;
445 while (tlv_index < tlv_length) {
446 uint8_t type = tvb_get_uint8 (tvb, tlv_index);
447 ++tlv_index;
448 uint8_t length = tvb_get_uint8 (tvb, tlv_index);
449 ++tlv_index;
450 switch (type) {
451 case XRA_TLV_CW_INFO_NR_OF_INFO_BYTES:
452 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_nr_of_info_bytes, tvb, tlv_index, length, ENC_NA);
453 break;
454 case XRA_TLV_CW_INFO_BCH_DECODING_SUCCESFUL:
455 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_bch_decoding_successful, tvb, tlv_index, length, ENC_NA);
456 break;
457 case XRA_TLV_CW_INFO_PROFILE_PARITY:
458 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_profile_parity, tvb, tlv_index, length, ENC_NA);
459 break;
460 case XRA_TLV_CW_INFO_BCH_NUMBER_OF_CORRECTED_BITS:
461 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_bch_number_of_corrected_bits, tvb, tlv_index, length, ENC_BIG_ENDIAN);
462 break;
463 case XRA_TLV_CW_INFO_LDPC_NUMBER_OF_CODE_BITS:
464 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_ldpc_nr_of_code_bits, tvb, tlv_index, length, ENC_BIG_ENDIAN);
465 break;
466 case XRA_TLV_CW_INFO_LDPC_DECODING_SUCCESSFUL:
467 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_ldpc_decoding_successful, tvb, tlv_index, length, ENC_BIG_ENDIAN);
468 break;
469 case XRA_TLV_CW_INFO_LDPC_NUMBER_OF_CORRECTED_BITS:
470 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_ldpc_number_of_corrected_bits, tvb, tlv_index, length, ENC_BIG_ENDIAN);
471 break;
472 case XRA_TLV_CW_INFO_LDPC_NUMBER_OF_ITERATIONS:
473 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_ldpc_number_of_iterations, tvb, tlv_index, length, ENC_BIG_ENDIAN);
474 break;
475 case XRA_TLV_CW_INFO_RS_DECODING_SUCCESFUL:
476 proto_tree_add_item(xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_rs_decoding_successful, tvb, tlv_index, length, ENC_BIG_ENDIAN);
477 break;
478 case XRA_TLV_CW_INFO_RS_NUMBER_OF_CORRECTED_SYMBOLS:
479 proto_tree_add_item(xra_tlv_cw_info_tree, hf_xra_tlv_cw_info_rs_number_of_corrected_symbols, tvb, tlv_index, length, ENC_BIG_ENDIAN);
480 break;
481 default:
482 proto_tree_add_item (xra_tlv_cw_info_tree, hf_xra_unknown, tvb, tlv_index, length, ENC_NA);
483 break;
485 tlv_index+=length;
488 return tvb_captured_length(tvb);
491 static int
492 dissect_xra_tlv_ms_info(tvbuff_t * tvb, proto_tree * tree, void* data _U_, uint16_t tlv_length) {
493 proto_item *it;
494 proto_tree *xra_tlv_ms_info_tree;
496 it = proto_tree_add_item (tree, hf_xra_tlv_ms_info, tvb, 0, tlv_length, ENC_NA);
497 xra_tlv_ms_info_tree = proto_item_add_subtree (it, ett_xra_tlv_ms_info);
499 unsigned tlv_index = 0;
500 while (tlv_index < tlv_length) {
501 uint8_t type = tvb_get_uint8 (tvb, tlv_index);
502 ++tlv_index;
503 uint8_t length = tvb_get_uint8 (tvb, tlv_index);
504 ++tlv_index;
505 switch (type) {
506 case XRA_TLV_MINISLOT_INFO_START_MINISLOT_ID:
507 proto_tree_add_item (xra_tlv_ms_info_tree, hf_xra_tlv_start_minislot_id_abs, tvb, tlv_index, length, ENC_BIG_ENDIAN);
508 break;
509 case XRA_TLV_MINISLOT_INFO_REL_START_MINISLOT:
510 proto_tree_add_item (xra_tlv_ms_info_tree, hf_xra_tlv_start_minislot_id_rel, tvb, tlv_index, length, ENC_BIG_ENDIAN);
511 break;
512 case XRA_TLV_MINISLOT_INFO_REL_STOP_MINISLOT:
513 proto_tree_add_item (xra_tlv_ms_info_tree, hf_xra_tlv_stop_minislot_id_rel, tvb, tlv_index, length, ENC_BIG_ENDIAN);
514 break;
515 default:
516 proto_tree_add_item (xra_tlv_ms_info_tree, hf_xra_unknown, tvb, tlv_index, length, ENC_NA);
517 break;
519 tlv_index+=length;
522 return tvb_captured_length(tvb);
525 static int
526 dissect_xra_tlv_burst_info(tvbuff_t * tvb, proto_tree * tree, void* data _U_, uint16_t tlv_length) {
527 proto_item *it;
528 proto_tree *xra_tlv_burst_info_tree;
530 it = proto_tree_add_item (tree, hf_xra_tlv_burst_info, tvb, 0, tlv_length, ENC_NA);
531 xra_tlv_burst_info_tree = proto_item_add_subtree (it, ett_xra_tlv_burst_info);
533 unsigned tlv_index = 0;
534 while (tlv_index < tlv_length) {
535 uint8_t type = tvb_get_uint8 (tvb, tlv_index);
536 ++tlv_index;
537 uint8_t length = tvb_get_uint8 (tvb, tlv_index);
538 ++tlv_index;
539 switch (type) {
540 case XRA_BURST_INFO_BURST_ID_REFERENCE:
541 proto_tree_add_item (xra_tlv_burst_info_tree, hf_xra_tlv_burst_info_burst_id_reference, tvb, tlv_index, length, ENC_BIG_ENDIAN);
542 break;
543 case XRA_US_CHANNEL_ID:
544 proto_tree_add_item (xra_tlv_burst_info_tree, hf_xra_tlv_us_channel_id, tvb, tlv_index, length, ENC_BIG_ENDIAN);
545 break;
546 case XRA_SID:
547 proto_tree_add_item (xra_tlv_burst_info_tree, hf_xra_tlv_sid, tvb, tlv_index, length, ENC_BIG_ENDIAN);
548 break;
549 case XRA_IUC:
550 proto_tree_add_item (xra_tlv_burst_info_tree, hf_xra_tlv_iuc, tvb, tlv_index, length, ENC_BIG_ENDIAN);
551 break;
553 default:
554 proto_tree_add_item (xra_tlv_burst_info_tree, hf_xra_unknown, tvb, tlv_index, length, ENC_NA);
555 break;
557 tlv_index+=length;
560 return tvb_captured_length(tvb);
563 static int
564 dissect_xra_tlv(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_, uint16_t tlv_length, unsigned* segment_header_present) {
565 proto_item *it;
566 proto_tree *xra_tlv_tree;
567 unsigned symbol_id;
568 double mer, power_level;
570 it = proto_tree_add_item (tree, hf_xra_tlv, tvb, 0, tlv_length, ENC_NA);
571 xra_tlv_tree = proto_item_add_subtree (it, ett_xra_tlv);
573 unsigned tlv_index = 0;
574 tvbuff_t *xra_tlv_cw_info_tvb, *xra_tlv_ms_info_tvb, *xra_tlv_burst_info_tvb;
576 while (tlv_index < tlv_length) {
577 uint8_t type = tvb_get_uint8 (tvb, tlv_index);
578 ++tlv_index;
579 uint8_t length = tvb_get_uint8 (tvb, tlv_index);
580 ++tlv_index;
581 switch (type) {
582 case XRA_DS_CHANNEL_ID:
583 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_ds_channel_id, tvb, tlv_index, length, ENC_BIG_ENDIAN);
584 break;
585 case XRA_DS_FREQUENCY:
586 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_ds_channel_frequency, tvb, tlv_index, length, ENC_BIG_ENDIAN);
587 break;
588 case XRA_MODULATION:
589 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_modulation, tvb, tlv_index, length, ENC_BIG_ENDIAN);
590 break;
591 case XRA_ANNEX:
592 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_annex, tvb, tlv_index, length, ENC_BIG_ENDIAN);
593 break;
594 case XRA_PROFILE_ID:
595 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_profile_id, tvb, tlv_index, length, ENC_BIG_ENDIAN);
596 break;
597 case XRA_CODEWORD_INFO:
598 xra_tlv_cw_info_tvb = tvb_new_subset_length(tvb, tlv_index, length);
599 dissect_xra_tlv_cw_info(xra_tlv_cw_info_tvb, xra_tlv_tree, data, length);
600 break;
601 case XRA_NCP_TRUNC:
602 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_ncp_trunc, tvb, tlv_index, length, ENC_BIG_ENDIAN);
603 break;
604 case XRA_NCP_SYMBOLID:
605 proto_tree_add_item_ret_uint (xra_tlv_tree, hf_xra_tlv_ncp_symbolid, tvb, tlv_index, length, false, &symbol_id);
606 col_append_fstr(pinfo->cinfo, COL_INFO, ": (Symbol ID: %u):", symbol_id);
607 break;
608 case XRA_MER:
609 mer = tvb_get_uint8(tvb, tlv_index)/4.0;
610 proto_tree_add_double_format_value(xra_tlv_tree, hf_xra_tlv_mer, tvb, tlv_index, length, mer, "%.2f dB", mer);
611 break;
612 case XRA_US_CHANNEL_ID:
613 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_us_channel_id, tvb, tlv_index, length, ENC_BIG_ENDIAN);
614 break;
615 case XRA_SID:
616 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_sid, tvb, tlv_index, length, ENC_BIG_ENDIAN);
617 break;
618 case XRA_IUC:
619 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_iuc, tvb, tlv_index, length, ENC_BIG_ENDIAN);
620 break;
621 case XRA_BURST_ID:
622 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_burstid, tvb, tlv_index, length, ENC_BIG_ENDIAN);
623 break;
624 case XRA_BURST_INFO:
625 xra_tlv_burst_info_tvb = tvb_new_subset_length(tvb, tlv_index, length);
626 dissect_xra_tlv_burst_info(xra_tlv_burst_info_tvb, xra_tlv_tree, data, length);
627 break;
628 case XRA_MINISLOT_INFO:
629 xra_tlv_ms_info_tvb = tvb_new_subset_length(tvb, tlv_index, length);
630 dissect_xra_tlv_ms_info(xra_tlv_ms_info_tvb, xra_tlv_tree, data, length);
631 break;
632 case XRA_UCD_CCC_PARITY:
633 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_ucd_ccc_parity, tvb, tlv_index, length, ENC_BIG_ENDIAN);
634 break;
635 case XRA_GRANT_SIZE:
636 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_grant_size, tvb, tlv_index, length, ENC_BIG_ENDIAN);
637 break;
638 case XRA_SEGMENT_HEADER_PRESENT:
639 proto_tree_add_item_ret_uint (xra_tlv_tree, hf_xra_tlv_segment_header_present, tvb, tlv_index, length, false, segment_header_present);
640 break;
641 case XRA_NUMBER_OFDMA_FRAMES:
642 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_ranging_number_ofdma_frames, tvb, tlv_index, length, ENC_BIG_ENDIAN);
643 break;
644 case XRA_ESTIMATED_TIMING_ADJUST:
645 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_ranging_timing_adjust, tvb, tlv_index, length, ENC_BIG_ENDIAN);
646 break;
647 case XRA_ESTIMATED_POWER_LEVEL:
648 power_level = ((int16_t) (256*tvb_get_uint8(tvb, tlv_index) + tvb_get_uint8(tvb, tlv_index+1)) )/10.0;
649 proto_tree_add_double_format_value(xra_tlv_tree, hf_xra_tlv_power_level, tvb, tlv_index, length, power_level, "%.1f dBmV", power_level);
650 break;
651 case XRA_SUBSLOT_ID:
652 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_subslot_id, tvb, tlv_index, length, ENC_BIG_ENDIAN);
653 break;
654 case XRA_CONTROL_WORD:
655 proto_tree_add_item (xra_tlv_tree, hf_xra_tlv_control_word, tvb, tlv_index, length, ENC_BIG_ENDIAN);
656 break;
657 default:
658 proto_tree_add_item (xra_tlv_tree, hf_xra_unknown, tvb, tlv_index, length, ENC_NA);
659 break;
661 tlv_index+=length;
664 return tvb_captured_length(tvb);
667 static void
668 dissect_timestamp_mb(tvbuff_t * tvb, proto_tree* tree) {
669 nstime_t ts;
670 uint64_t plc_timestamp, plc_timestamp_ns;
671 proto_item* timestamp_it;
672 proto_tree* timestamp_tree;
674 static int * const timestamp_parts[] = {
675 &hf_plc_mb_ts_timestamp_epoch,
676 &hf_plc_mb_ts_timestamp_d30timestamp,
677 &hf_plc_mb_ts_timestamp_extra_204_8,
678 &hf_plc_mb_ts_timestamp_extra_204_8_X_16,
679 NULL
682 proto_tree_add_item (tree, hf_plc_mb_ts_reserved, tvb, 0, 1, ENC_BIG_ENDIAN);
684 timestamp_it = proto_tree_add_item_ret_uint64 (tree, hf_plc_mb_ts_timestamp, tvb, 1, 8, ENC_BIG_ENDIAN, &plc_timestamp);
685 timestamp_tree = proto_item_add_subtree (timestamp_it, ett_plc_timestamp);
687 /* See Figure 104 of CM-SP-MULPIv3.1-115-180509 */
688 proto_tree_add_bitmask_list(timestamp_tree, tvb, 1, 8, timestamp_parts, ENC_BIG_ENDIAN);
690 /* Timestamp calculation in ns. Beware of overflow of uint64_t. Splitting off timestamp in composing contributions
691 * Epoch (bits 63-41): 10.24 MHz/2^32 clock: *100000*2^22 ns
692 * D3.0 timestamp (bits 40-9): 204.8MHz/20 clock: 10.24MHz clock
693 * Bits 8-4: 204.8MHz clock
694 * Lowest 4 bits (bits 3-0): 16*204.8MHz clock
696 plc_timestamp_ns = ((plc_timestamp>>41)&0x7FFFFF)*100000*4194304 + ((plc_timestamp >>9)&0xFFFFFFFF)*100000/1024 + ((plc_timestamp>>4)&0x1F)*10000/2048 + (plc_timestamp&0x0F)*10000/2048/16;
698 ts.secs= (time_t)(plc_timestamp_ns/1000000000);
699 ts.nsecs=plc_timestamp_ns%1000000000;
700 proto_tree_add_time(timestamp_tree, hf_plc_mb_ts_timestamp_formatted, tvb, 1, 8, &ts);
702 proto_tree_add_item (tree, hf_plc_mb_ts_crc24d, tvb, 9, 3, ENC_NA);
705 static void
706 dissect_message_channel_mb(tvbuff_t * tvb, packet_info * pinfo, proto_tree* tree, uint16_t remaining_length) {
707 proto_tree_add_item (tree, hf_plc_mb_mc_reserved, tvb, 0, 1, ENC_BIG_ENDIAN);
709 bool packet_start_pointer_field_present;
710 unsigned packet_start_pointer;
712 proto_tree_add_item_ret_boolean(tree, hf_plc_mb_mc_pspf_present, tvb, 0, 1, false, &packet_start_pointer_field_present);
714 /* If not present, this contains stuff from other packet. We can't do much in this case */
715 if(packet_start_pointer_field_present) {
716 proto_tree_add_item_ret_uint (tree, hf_plc_mb_mc_psp, tvb, 1, 2, false, &packet_start_pointer);
718 unsigned docsis_start = 3 + packet_start_pointer;
719 while (docsis_start + 6 < remaining_length) {
720 /* DOCSIS header in packet */
721 uint8_t fc = tvb_get_uint8(tvb,docsis_start + 0);
722 if (fc == 0xFF) {
723 /* Skip fill bytes */
724 docsis_start += 1;
725 continue;
727 unsigned docsis_length = 256*tvb_get_uint8(tvb,docsis_start + 2) + tvb_get_uint8(tvb,docsis_start + 3);
728 if (docsis_start + 6 + docsis_length <= remaining_length) {
729 /* DOCSIS packet included in packet */
730 tvbuff_t *docsis_tvb;
732 docsis_tvb = tvb_new_subset_length(tvb, docsis_start, docsis_length + 6);
733 if (docsis_handle) {
734 call_dissector (docsis_handle, docsis_tvb, pinfo, tree);
735 col_append_str(pinfo->cinfo, COL_INFO, "; ");
736 col_set_fence(pinfo->cinfo,COL_INFO);
739 docsis_start += 6 + docsis_length;
744 static int
745 dissect_message_block(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, uint8_t mb_type, uint16_t mb_length) {
746 proto_tree * mb_tree;
747 proto_item *mb_item;
749 mb_item = proto_tree_add_item (tree, hf_plc_mb, tvb, 0, 1, ENC_BIG_ENDIAN);
751 mb_tree = proto_item_add_subtree (mb_item, ett_plc_mb);
753 switch (mb_type) {
754 case PLC_TIMESTAMP_MB:
755 dissect_timestamp_mb(tvb, mb_tree);
756 break;
757 case PLC_ENERGY_MANAGEMENT_MB:
758 proto_tree_add_item (mb_tree, hf_plc_em_mb, tvb, 0, mb_length, ENC_NA);
759 break;
760 case PLC_MESSAGE_CHANNEL_MB:
761 dissect_message_channel_mb(tvb, pinfo, mb_tree, mb_length);
762 break;
763 case PLC_TRIGGER_MB:
764 proto_tree_add_item (mb_tree, hf_plc_trigger_mb, tvb, 0, mb_length, ENC_NA);
765 break;
766 /* Future Use Message Block */
767 default:
768 break;
770 return tvb_captured_length(tvb);
773 static int
774 dissect_ncp_message_block(tvbuff_t * tvb, proto_tree * tree) {
775 proto_tree * mb_tree;
776 proto_item *mb_item;
778 mb_item = proto_tree_add_item (tree, hf_ncp_mb, tvb, 0, 3, ENC_NA);
779 mb_tree = proto_item_add_subtree (mb_item, ett_ncp_mb);
781 proto_tree_add_item (mb_tree, hf_ncp_mb_profileid, tvb, 0, 1, ENC_BIG_ENDIAN);
782 proto_tree_add_item (mb_tree, hf_ncp_mb_z, tvb, 0, 1, ENC_BIG_ENDIAN);
783 proto_tree_add_item (mb_tree, hf_ncp_mb_c, tvb, 0, 1, ENC_BIG_ENDIAN);
784 proto_tree_add_item (mb_tree, hf_ncp_mb_n, tvb, 0, 1, ENC_BIG_ENDIAN);
785 proto_tree_add_item (mb_tree, hf_ncp_mb_l, tvb, 0, 1, ENC_BIG_ENDIAN);
786 proto_tree_add_item (mb_tree, hf_ncp_mb_t, tvb, 1, 1, ENC_BIG_ENDIAN);
787 proto_tree_add_item (mb_tree, hf_ncp_mb_u, tvb, 1, 1, ENC_BIG_ENDIAN);
788 proto_tree_add_item (mb_tree, hf_ncp_mb_r, tvb, 1, 1, ENC_BIG_ENDIAN);
789 proto_tree_add_item (mb_tree, hf_ncp_mb_subcarrier_start_pointer, tvb, 1, 2, ENC_BIG_ENDIAN);
791 return tvb_captured_length(tvb);
794 static int
795 dissect_plc(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) {
797 int offset = 0;
798 proto_tree *plc_tree;
799 proto_item *plc_item;
800 tvbuff_t *mb_tvb;
802 plc_item = proto_tree_add_protocol_format (tree, proto_plc, tvb, 0, -1, "DOCSIS PLC");
803 plc_tree = proto_item_add_subtree (plc_item, ett_plc);
805 while (tvb_reported_length_remaining(tvb, offset) > 0) {
806 uint8_t mb_type = tvb_get_uint8 (tvb, offset) >>4;
807 uint8_t mb_nibble2 = tvb_get_uint8 (tvb, offset) & 0x0F;
808 uint8_t mb_byte2 = tvb_get_uint8 (tvb, offset+1);
809 uint8_t last_mb = 0;
811 /* Do not initialize with 0, otherwise an infinite loop results in case mbLength is not initialized. */
812 uint16_t mb_length = 1000;
814 if(mb_type == 0xFF) {
815 break;
817 switch (mb_type) {
818 case PLC_TIMESTAMP_MB:
819 mb_length =12;
820 /* Note that a Timestamp Message Block is mandatory and always comes first. */
821 col_append_str(pinfo->cinfo, COL_INFO, ": TS-MB");
822 break;
823 case PLC_ENERGY_MANAGEMENT_MB:
824 mb_length = 4 + mb_nibble2*6;
825 col_append_str(pinfo->cinfo, COL_INFO, ", EM-MB");
826 break;
827 case PLC_MESSAGE_CHANNEL_MB:
828 last_mb = 1;
829 mb_length = tvb_reported_length_remaining(tvb, offset);
830 col_append_str(pinfo->cinfo, COL_INFO, ", MC-MB");
831 break;
832 case PLC_TRIGGER_MB:
833 mb_length = 9;
834 col_append_str(pinfo->cinfo, COL_INFO, ", TR-MB");
835 break;
836 /* Future Use Message Block */
837 default:
838 mb_length = 5 + 256*(mb_nibble2 &0x01) + mb_byte2;
839 col_append_str(pinfo->cinfo, COL_INFO, ", FUT-MB");
840 break;
842 mb_tvb = tvb_new_subset_remaining(tvb, offset);
843 dissect_message_block(mb_tvb,pinfo, plc_tree, mb_type, mb_length);
845 if (last_mb) {
846 break;
849 offset+= mb_length;
852 return tvb_captured_length(tvb);
855 static int
856 dissect_ncp(tvbuff_t * tvb, proto_tree * tree, void* data _U_) {
857 int offset = 0;
858 proto_tree *ncp_tree;
859 proto_item *ncp_item;
860 tvbuff_t *ncp_mb_tvb;
862 ncp_item = proto_tree_add_protocol_format (tree, proto_ncp, tvb, 0, -1, "DOCSIS NCP");
863 ncp_tree = proto_item_add_subtree (ncp_item, ett_ncp);
865 while (tvb_captured_length_remaining(tvb, offset) > 3) {
866 ncp_mb_tvb = tvb_new_subset_length(tvb, offset, 3);
867 dissect_ncp_message_block(ncp_mb_tvb, ncp_tree);
869 offset+= 3;
871 proto_tree_add_item (ncp_tree, hf_ncp_crc, tvb, offset, 3, ENC_NA);
873 return tvb_captured_length(tvb);
876 static int
877 dissect_init_ranging(tvbuff_t * tvb, proto_tree * tree, void* data _U_) {
879 proto_tree *init_ranging_tree;
880 proto_item *init_ranging_item;
882 init_ranging_item = proto_tree_add_protocol_format (tree, proto_init_ranging, tvb, 0, -1, "OFDMA Initial Ranging Request");
883 init_ranging_tree = proto_item_add_subtree (init_ranging_item, ett_init_ranging);
885 proto_tree_add_item (init_ranging_tree, hf_xra_init_ranging_mac, tvb, 0, 6, ENC_NA);
886 proto_tree_add_item (init_ranging_tree, hf_xra_init_ranging_ds_channel_id, tvb, 6, 1, ENC_BIG_ENDIAN);
887 proto_tree_add_item (init_ranging_tree, hf_xra_init_ranging_crc, tvb, 7, 3, ENC_NA);
889 return tvb_captured_length(tvb);
892 static int
893 dissect_ofdma_segment(tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, void* data _U_) {
894 proto_tree *segment_tree;
895 proto_item *segment_item;
897 segment_item = proto_tree_add_protocol_format (tree, proto_segment, tvb, 0, -1, "DOCSIS Segment");
898 segment_tree = proto_item_add_subtree (segment_item, ett_plc);
900 proto_tree_add_item (segment_tree, hf_docsis_segment_pfi, tvb, 0, 1, ENC_BIG_ENDIAN);
901 proto_tree_add_item (segment_tree, hf_docsis_segment_reserved, tvb, 0, 1, ENC_BIG_ENDIAN);
902 proto_tree_add_item (segment_tree, hf_docsis_segment_pointerfield, tvb, 0, 2, ENC_BIG_ENDIAN);
903 proto_tree_add_item (segment_tree, hf_docsis_segment_sequencenumber, tvb, 2, 2, ENC_BIG_ENDIAN);
904 proto_tree_add_item (segment_tree, hf_docsis_segment_sidclusterid, tvb, 3, 1, ENC_BIG_ENDIAN);
905 proto_tree_add_item (segment_tree, hf_docsis_segment_request, tvb, 4, 2, ENC_BIG_ENDIAN);
907 /* Dissect the header check sequence. */
908 /* CRC-CCITT(16+12+5+1). */
909 uint16_t fcs = g_ntohs(crc16_ccitt_tvb(tvb, 6));
910 proto_tree_add_checksum(segment_tree, tvb, 6, hf_docsis_segment_hcs, hf_docsis_segment_hcs_status, &ei_docsis_segment_hcs_bad, pinfo, fcs, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
912 proto_tree_add_item (segment_tree, hf_docsis_segment_data, tvb, 8, tvb_reported_length_remaining(tvb, 8), ENC_NA);
914 return tvb_captured_length(tvb);
917 void
918 proto_register_xra (void)
920 static hf_register_info hf[] = {
921 {&hf_xra_version,
922 {"Version", "xra.version",
923 FT_UINT8, BASE_DEC, NULL, 0x0,
924 "XRA Header Version", HFILL}
926 {&hf_xra_direction,
927 {"Direction", "xra.direction",
928 FT_UINT8, BASE_DEC, VALS(direction_vals), 0xC0,
929 NULL, HFILL}
931 {&hf_xra_packettype,
932 {"Packet Type", "xra.packettype",
933 FT_UINT8, BASE_DEC, VALS(packettype), 0x0,
934 NULL, HFILL}
936 {&hf_xra_tlvlength,
937 {"TLV Length", "xra.tlvlength",
938 FT_UINT16, BASE_DEC, NULL, 0x0,
939 NULL, HFILL}
941 {&hf_xra_tlv,
942 {"XRA TLV", "xra.tlv",
943 FT_BYTES, BASE_NONE, NULL, 0x0,
944 NULL, HFILL}
946 /* XRA TLVs */
947 {&hf_xra_tlv_ds_channel_id,
948 {"DS Channel ID", "xra.tlv.ds_channel_id",
949 FT_UINT8, BASE_DEC, NULL, 0x0,
950 NULL, HFILL}
952 {&hf_xra_tlv_ds_channel_frequency,
953 {"DS Channel Frequency", "xra.tlv.ds_channel_frequency",
954 FT_UINT32, BASE_DEC, NULL, 0x0,
955 NULL, HFILL}
957 {&hf_xra_tlv_modulation,
958 {"Modulation", "xra.tlv.modulation",
959 FT_UINT8, BASE_DEC, VALS(modulation_vals), 0x0,
960 NULL, HFILL}
962 {&hf_xra_tlv_annex,
963 {"Annex", "xra.tlv.annex",
964 FT_UINT8, BASE_DEC, VALS(annex_vals), 0x0,
965 NULL, HFILL}
967 {&hf_xra_tlv_us_channel_id,
968 {"US Channel ID", "xra.tlv.us_channel_id",
969 FT_UINT8, BASE_DEC, NULL, 0x0,
970 NULL, HFILL}
972 {&hf_xra_tlv_profile_id,
973 {"Profile", "xra.tlv.profile_id",
974 FT_UINT8, BASE_DEC, VALS(profile_id), 0x0,
975 NULL, HFILL}
977 {&hf_xra_tlv_sid,
978 {"SID", "xra.tlv.sid",
979 FT_UINT16, BASE_DEC, NULL, 0x0,
980 NULL, HFILL}
982 {&hf_xra_tlv_iuc,
983 {"IUC", "xra.tlv.iuc",
984 FT_UINT8, BASE_DEC, NULL, 0x0,
985 NULL, HFILL}
987 {&hf_xra_tlv_burstid,
988 {"Burst ID", "xra.tlv.burstid",
989 FT_UINT64, BASE_DEC, NULL, 0x0,
990 NULL, HFILL}
992 {&hf_xra_tlv_ms_info,
993 {"Minislot Info", "xra.tlv.ms_info",
994 FT_BYTES, BASE_NONE, NULL, 0x0,
995 NULL, HFILL}
997 {&hf_xra_tlv_ucd_ccc_parity,
998 {"UCD CCC Parity", "xra.tlv.ucd_ccc_parity",
999 FT_UINT8, BASE_DEC, NULL, 0x0,
1000 NULL, HFILL}
1002 {&hf_xra_tlv_grant_size,
1003 {"Grant Size (bits)", "xra.tlv.grant_size",
1004 FT_UINT32, BASE_DEC, NULL, 0x00FFFFFF,
1005 NULL, HFILL}
1007 {&hf_xra_tlv_segment_header_present,
1008 {"Segment Header Present", "xra.tlv.segment_header_present",
1009 FT_UINT8, BASE_DEC, NULL,0x0,
1010 NULL, HFILL}
1012 {&hf_xra_tlv_ncp_trunc,
1013 {"Truncated due to Uncorrectables", "xra.tlv.ncp.trunc",
1014 FT_UINT8, BASE_DEC, NULL, 0x0,
1015 NULL, HFILL}
1017 {&hf_xra_tlv_ncp_symbolid,
1018 {"Symbol ID", "xra.tlv.ncp.symbolid",
1019 FT_UINT32, BASE_DEC, NULL, 0x0,
1020 NULL, HFILL}
1022 {&hf_xra_tlv_start_minislot_id_abs,
1023 {"Start Minislot ID (absolute)", "xra.tlv.ms_info.start_minislot_id_abs",
1024 FT_UINT32, BASE_DEC, NULL, 0x0,
1025 NULL, HFILL}
1027 {&hf_xra_tlv_start_minislot_id_rel,
1028 {"Start Minislot ID (relative)", "xra.tlv.ms_info.start_minislot_id_rel",
1029 FT_UINT8, BASE_DEC, NULL, 0x0,
1030 NULL, HFILL}
1032 {&hf_xra_tlv_stop_minislot_id_rel,
1033 {"Stop Minislot ID (relative)", "xra.tlv.ms_info.stop_minislot_id_rel",
1034 FT_UINT8, BASE_DEC, NULL, 0x0,
1035 NULL, HFILL}
1037 /* Ranging */
1038 {&hf_xra_tlv_ranging_number_ofdma_frames,
1039 {"Number of OFDMA Frames", "xra.tlv.ranging.number_ofdma_frames",
1040 FT_UINT16, BASE_DEC, NULL, 0x0,
1041 NULL, HFILL}
1043 {&hf_xra_tlv_ranging_timing_adjust,
1044 {"Estimated Timing Adjust (in 1/204.8 "UTF8_MICRO_SIGN"s units)", "xra.tlv.ranging.timing_adjust",
1045 FT_INT32, BASE_DEC, NULL, 0x0,
1046 NULL, HFILL}
1048 {&hf_xra_tlv_power_level,
1049 {"Estimated Power Level", "xra.tlv.power_level",
1050 FT_DOUBLE, BASE_NONE, NULL, 0x0,
1051 NULL, HFILL}
1053 {&hf_xra_tlv_mer,
1054 {"MER", "xra.tlv.mer",
1055 FT_DOUBLE, BASE_NONE, NULL, 0x0,
1056 NULL, HFILL}
1058 {&hf_xra_tlv_subslot_id,
1059 {"Subslot ID", "xra.tlv.subslot_id",
1060 FT_UINT32, BASE_DEC, NULL, 0x0,
1061 NULL, HFILL}
1063 {&hf_xra_tlv_control_word,
1064 {"Control Word", "xra.tlv.control_word",
1065 FT_UINT8, BASE_DEC, VALS(control_word_vals), 0x0,
1066 NULL, HFILL}
1068 /* Codeword Info */
1069 {&hf_xra_tlv_cw_info,
1070 {"Codeword Info", "xra.tlv.cw_info",
1071 FT_BYTES, BASE_NONE, NULL, 0x0,
1072 NULL, HFILL}
1074 {&hf_xra_tlv_cw_info_nr_of_info_bytes,
1075 {"Number of Info Bytes", "xra.tlv.cw_info.nr_of_info_bytes",
1076 FT_UINT16, BASE_DEC, NULL, 0x0,
1077 NULL, HFILL}
1079 {&hf_xra_tlv_cw_info_bch_decoding_successful,
1080 {"BCH Decoding Successful", "xra.tlv.cw_info.bch_decoding_successful",
1081 FT_UINT8, BASE_DEC, NULL, 0x0,
1082 NULL, HFILL}
1084 {&hf_xra_tlv_cw_info_profile_parity,
1085 {"Codeword Parity", "xra.tlv.cw_info.profile_parity",
1086 FT_UINT8, BASE_DEC, NULL, 0x0,
1087 NULL, HFILL}
1089 {&hf_xra_tlv_cw_info_bch_number_of_corrected_bits,
1090 {"BCH Number of Corrected Bits", "xra.tlv.cw_info.bch_number_of_corrected_bits",
1091 FT_UINT8, BASE_DEC, NULL, 0x0,
1092 NULL, HFILL}
1094 {&hf_xra_tlv_cw_info_ldpc_nr_of_code_bits,
1095 {"Number of Code Bits", "xra.tlv.cw_info.ldpc_nr_of_code_bits",
1096 FT_UINT16, BASE_DEC, NULL, 0x0,
1097 NULL, HFILL}
1099 {&hf_xra_tlv_cw_info_ldpc_decoding_successful,
1100 {"LDPC Decoding Successful", "xra.tlv.cw_info.ldpc_decoding_successful",
1101 FT_UINT8, BASE_DEC, NULL, 0x0,
1102 NULL, HFILL}
1104 {&hf_xra_tlv_cw_info_ldpc_number_of_iterations,
1105 {"LDPC Number of Iterations", "xra.tlv.cw_info.ldpc_number_of_iterations",
1106 FT_UINT8, BASE_DEC, NULL, 0x0,
1107 NULL, HFILL}
1109 {&hf_xra_tlv_cw_info_ldpc_number_of_corrected_bits,
1110 {"LDPC Number of Corrected Info Bits", "xra.tlv.cw_info.ldpc_number_of_corrected_bits",
1111 FT_UINT16, BASE_DEC, NULL, 0x0,
1112 NULL, HFILL}
1114 {&hf_xra_tlv_cw_info_rs_decoding_successful,
1115 {"Reed-Solomon Decoding Successful", "xra.tlv.cw_info.rs_decoding_successful",
1116 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1117 NULL, HFILL}
1119 {&hf_xra_tlv_cw_info_rs_number_of_corrected_symbols,
1120 {"Reed-Solomon Number of Corrected Symbols", "xra.tlv.cw_info.rs_number_of_corrected_symbols",
1121 FT_UINT8, BASE_DEC, NULL, 0x0,
1122 NULL, HFILL}
1124 {&hf_xra_unknown,
1125 {"Unknown", "xra.unknown",
1126 FT_BYTES, BASE_NONE, NULL, 0x0,
1127 NULL, HFILL}
1129 /* Burst Info */
1130 {&hf_xra_tlv_burst_info,
1131 {"Burst Info", "xra.tlv.burst_info",
1132 FT_BYTES, BASE_NONE, NULL, 0x0,
1133 NULL, HFILL}
1135 {&hf_xra_tlv_burst_info_burst_id_reference,
1136 {"Burst ID Reference", "xra.tlv.burst_info.burst_id_reference",
1137 FT_UINT64, BASE_DEC, NULL, 0x0,
1138 NULL, HFILL}
1140 /* PLC Specific */
1141 {&hf_plc_mb,
1142 {"PLC Message Block", "docsis_plc.mb_type",
1143 FT_UINT8, BASE_DEC,VALS(message_block_type) , 0xF0,
1144 NULL, HFILL}
1146 /* NCP Specific */
1147 {&hf_ncp_mb,
1148 {"NCP Message Block", "docsis_ncp.mb",
1149 FT_BYTES, BASE_NONE,NULL , 0x0,
1150 NULL, HFILL}
1152 {&hf_ncp_mb_profileid,
1153 {"NCP MB Profile ID", "docsis_ncp.mb.profileid",
1154 FT_UINT8, BASE_DEC,NULL , 0xF0,
1155 NULL, HFILL}
1157 {&hf_ncp_mb_z,
1158 {"NCP MB Zero Bit-Loading", "docsis_ncp.mb.z",
1159 FT_BOOLEAN, 8, TFS(&zero_bit_loading) , 0x08,
1160 NULL, HFILL}
1162 {&hf_ncp_mb_c,
1163 {"NCP MB Data Profile Update", "docsis_ncp.mb.c",
1164 FT_BOOLEAN, 8, TFS(&data_profile_update) , 0x04,
1165 NULL, HFILL}
1167 {&hf_ncp_mb_n,
1168 {"NCP MB NCP Profile Selected", "docsis_ncp.mb.n",
1169 FT_BOOLEAN, 8, TFS(&ncp_profile_select) , 0x02,
1170 NULL, HFILL}
1172 {&hf_ncp_mb_l,
1173 {"NCP MB Last NCP Block", "docsis_ncp.mb.l",
1174 FT_BOOLEAN, 8, TFS(&last_ncp_block) , 0x01,
1175 NULL, HFILL}
1177 {&hf_ncp_mb_t,
1178 {"NCP MB Codeword Tagging", "docsis_ncp.mb.t",
1179 FT_BOOLEAN, 8, TFS(&codeword_tagging) , 0x80,
1180 NULL, HFILL}
1182 {&hf_ncp_mb_u,
1183 {"NCP MB NCP Profile Update Indicator", "docsis_ncp.mb.u",
1184 FT_BOOLEAN, 8, NULL , 0x40,
1185 NULL, HFILL}
1187 {&hf_ncp_mb_r,
1188 {"NCP MB Reserved", "docsis_ncp.mb.r",
1189 FT_BOOLEAN, 8, NULL , 0x20,
1190 NULL, HFILL}
1192 {&hf_ncp_mb_subcarrier_start_pointer,
1193 {"NCP MB Subcarrier Start Pointer", "docsis_ncp.mb.subcarrier_start_pointer",
1194 FT_UINT16, BASE_DEC, NULL , 0x1FFF,
1195 NULL, HFILL}
1197 {&hf_ncp_crc,
1198 {"NCP CRC", "docsis_ncp.crc",
1199 FT_BYTES, BASE_NONE, NULL , 0x0,
1200 NULL, HFILL}
1202 /* Init Ranging Specific */
1203 {&hf_xra_init_ranging_mac,
1204 {"MAC Address", "xra.init_ranging.mac",
1205 FT_ETHER, BASE_NONE, NULL , 0x0,
1206 NULL, HFILL}
1208 {&hf_xra_init_ranging_ds_channel_id,
1209 {"DS Channel ID", "xra.init_ranging.ds_channel_id",
1210 FT_UINT8, BASE_DEC, NULL , 0x0,
1211 NULL, HFILL}
1213 {&hf_xra_init_ranging_crc,
1214 {"CRC", "xra.init_ranging.crc",
1215 FT_BYTES, BASE_NONE, NULL , 0x0,
1216 NULL, HFILL}
1218 /* PLC MB */
1219 {&hf_plc_em_mb,
1220 {"PLC EM MB", "docsis_plc.em_mb",
1221 FT_BYTES, BASE_NONE, NULL , 0x0,
1222 NULL, HFILL}
1224 {&hf_plc_trigger_mb,
1225 {"PLC Trigger MB", "docsis_plc.trigger_mb",
1226 FT_BYTES, BASE_NONE, NULL , 0x0,
1227 NULL, HFILL}
1229 /* Timestamp MB */
1230 {&hf_plc_mb_ts_reserved,
1231 {"Reserved", "docsis_plc.mb_ts_reserved",
1232 FT_UINT8, BASE_DEC,0 , 0x0F,
1233 NULL, HFILL}
1235 {&hf_plc_mb_ts_timestamp,
1236 {"Timestamp", "docsis_plc.mb_ts_timestamp",
1237 FT_UINT64, BASE_DEC,0 , 0x0,
1238 NULL, HFILL}
1240 {&hf_plc_mb_ts_timestamp_epoch,
1241 {"Timestamp Epoch", "docsis_plc.mb_ts_timestamp_epoch",
1242 FT_UINT64, BASE_HEX,0 , 0xFFFFFE0000000000,
1243 NULL, HFILL}
1245 {&hf_plc_mb_ts_timestamp_d30timestamp,
1246 {"D3.0 Timestamp", "docsis_plc.mb_ts_timestamp_d30timestamp",
1247 FT_UINT64, BASE_HEX,0 , 0x000001FFFFFFFE00,
1248 NULL, HFILL}
1250 {&hf_plc_mb_ts_timestamp_extra_204_8,
1251 {"Timestamp: Extra 204.8MHz Samples", "docsis_plc.mb_ts_timestamp_extra_204_8",
1252 FT_UINT64, BASE_DEC,0 , 0x00000000000001F0,
1253 NULL, HFILL}
1255 {&hf_plc_mb_ts_timestamp_extra_204_8_X_16,
1256 {"Timestamp: Extra 16 x 204.8MHz Samples", "docsis_plc.mb_ts_timestamp_extra_204_8_X_16",
1257 FT_UINT64, BASE_DEC, 0 , 0x000000000000000F,
1258 NULL, HFILL}
1260 {&hf_plc_mb_ts_timestamp_formatted,
1261 {"Formatted PLC Timestamp", "docsis_plc.mb_ts_timestamp_formatted",
1262 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0,
1263 NULL, HFILL }
1265 {&hf_plc_mb_ts_crc24d,
1266 {"CRC-24-D", "docsis_plc.mb_ts_crc24d",
1267 FT_BYTES, BASE_NONE, 0 , 0x0,
1268 NULL, HFILL}
1270 /* Message Channel MB */
1271 {&hf_plc_mb_mc_reserved,
1272 {"Reserved", "docsis_plc.mb_mc_reserved",
1273 FT_UINT8, BASE_DEC,0 , 0x0E,
1274 NULL, HFILL}
1276 {&hf_plc_mb_mc_pspf_present,
1277 {"Packet Start Pointer Field", "docsis_plc.mb_mc_pspf_present",
1278 FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x01,
1279 NULL, HFILL}
1281 {&hf_plc_mb_mc_psp,
1282 {"Packet Start Pointer", "docsis_plc.mb_mc_psp",
1283 FT_UINT16, BASE_DEC, 0 , 0x0,
1284 NULL, HFILL}
1286 /* DOCSIS Segment */
1287 {&hf_docsis_segment_pfi,
1288 {"Pointer Field Indicator", "docsis_segment.pfi",
1289 FT_UINT8, BASE_DEC, NULL, 0x80,
1290 NULL, HFILL}
1292 {&hf_docsis_segment_reserved,
1293 {"Reserved", "docsis_segment.reserved",
1294 FT_UINT8, BASE_DEC, NULL, 0x40,
1295 NULL, HFILL}
1297 {&hf_docsis_segment_pointerfield,
1298 {"Pointer Field", "docsis_segment.pointerfield",
1299 FT_UINT16, BASE_DEC, NULL, 0x3FFF,
1300 NULL, HFILL}
1302 {&hf_docsis_segment_sequencenumber,
1303 {"Sequence Number", "docsis_segment.sequencenumber",
1304 FT_UINT16, BASE_DEC, NULL, 0xFFF8,
1305 NULL, HFILL}
1307 {&hf_docsis_segment_sidclusterid,
1308 {"SID Cluster ID", "docsis_segment.sidclusterid",
1309 FT_UINT8, BASE_DEC, NULL, 0x07,
1310 NULL, HFILL}
1312 {&hf_docsis_segment_request,
1313 {"Request (N bytes)", "docsis_segment.request",
1314 FT_UINT16, BASE_DEC, NULL, 0x0,
1315 NULL, HFILL}
1317 {&hf_docsis_segment_hcs,
1318 {"HCS", "docsis_segment.hcs",
1319 FT_UINT16, BASE_HEX, NULL, 0x0,
1320 NULL, HFILL}
1322 { &hf_docsis_segment_hcs_status,
1323 { "Segment HCS Status", "docsis_segment.hcs.status",
1324 FT_UINT8, BASE_NONE, VALS(local_proto_checksum_vals), 0x0,
1325 NULL, HFILL}
1327 {&hf_docsis_segment_data,
1328 {"Data", "docsis_segment.data",
1329 FT_BYTES, BASE_NONE, NULL, 0x0,
1330 NULL, HFILL}
1334 static ei_register_info ei[] = {
1335 { &ei_docsis_segment_hcs_bad, { "docsis_segment.hcs_bad", PI_CHECKSUM, PI_ERROR, "Bad Checksum", EXPFILL }},
1338 /* Setup protocol subtree array */
1339 static int *ett[] = {
1340 &ett_xra,
1341 &ett_xra_tlv,
1342 &ett_xra_tlv_cw_info,
1343 &ett_xra_tlv_ms_info,
1344 &ett_xra_tlv_burst_info,
1345 &ett_plc,
1346 &ett_plc_mb,
1347 &ett_plc_timestamp,
1348 &ett_ncp,
1349 &ett_ncp_mb,
1350 &ett_init_ranging
1353 expert_module_t* expert_xra;
1355 /* Register the protocol name and description */
1356 proto_xra = proto_register_protocol ("Excentis XRA Header", "XRA", "xra");
1357 proto_segment = proto_register_protocol("DOCSIS Segment", "DOCSIS Segment", "docsis_segment");
1358 proto_plc = proto_register_protocol("DOCSIS PHY Link Channel", "DOCSIS PLC", "docsis_plc");
1359 proto_ncp = proto_register_protocol("DOCSIS_NCP", "DOCSIS_NCP", "docsis_ncp");
1360 proto_init_ranging = proto_register_protocol("DOCSIS_INIT_RANGING", "DOCSIS_INIT_RANGING", "docsis_init_ranging");
1362 /* Register expert notifications */
1363 expert_xra = expert_register_protocol(proto_xra);
1364 expert_register_field_array(expert_xra, ei, array_length(ei));
1366 /* Required function calls to register the header fields and subtrees used */
1367 proto_register_field_array (proto_xra, hf, array_length (hf));
1368 proto_register_subtree_array (ett, array_length (ett));
1370 xra_handle = register_dissector ("xra", dissect_xra, proto_xra);
1374 void
1375 proto_reg_handoff_xra(void)
1377 docsis_handle = find_dissector ("docsis");
1379 dissector_add_uint("wtap_encap", WTAP_ENCAP_DOCSIS31_XRA31, xra_handle);
1383 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1385 * Local Variables:
1386 * c-basic-offset: 2
1387 * tab-width: 8
1388 * indent-tabs-mode: nil
1389 * End:
1391 * ex: set shiftwidth=2 tabstop=8 expandtab:
1392 * :indentSize=2:tabSize=8:noTabs=true: