2 * Routines for UCD Message dissection
3 * Copyright 2002, Anand V. Narwani <anarwani@cisco.com>
5 * $Id: packet-ucd.c,v 1.4 2002/09/10 19:07:40 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include "plugins/plugin_api.h"
32 #include "plugins/plugin_api_defs.h"
33 #include "moduleinfo.h"
41 #include <epan/packet.h>
43 #define UCD_SYMBOL_RATE 1
44 #define UCD_FREQUENCY 2
45 #define UCD_PREAMBLE 3
46 #define UCD_BURST_DESCR 4
48 #define UCD_MODULATION 1
49 #define UCD_DIFF_ENCODING 2
50 #define UCD_PREAMBLE_LEN 3
51 #define UCD_PREAMBLE_VAL_OFF 4
53 #define UCD_FEC_CODEWORD 6
54 #define UCD_SCRAMBLER_SEED 7
55 #define UCD_MAX_BURST 8
56 #define UCD_GUARD_TIME 9
57 #define UCD_LAST_CW_LEN 10
58 #define UCD_SCRAMBLER_ONOFF 11
61 #define IUC_REQ_DATA 2
62 #define IUC_INIT_MAINT 3
63 #define IUC_STATION_MAINT 4
64 #define IUC_SHORT_DATA_GRANT 5
65 #define IUC_LONG_DATA_GRANT 6
67 #define IUC_DATA_ACK 8
68 #define IUC_RESERVED9 9
69 #define IUC_RESERVED10 10
70 #define IUC_RESERVED11 11
71 #define IUC_RESERVED12 12
72 #define IUC_RESERVED13 13
73 #define IUC_RESERVED14 14
74 #define IUC_EXPANSION 15
76 /* Initialize the protocol and registered fields */
77 static int proto_docsis_ucd = -1;
79 static int hf_docsis_ucd_upstream_chid = -1;
80 static int hf_docsis_ucd_config_ch_cnt = -1;
81 static int hf_docsis_ucd_mini_slot_size = -1;
82 static int hf_docsis_ucd_down_chid = -1;
83 static int hf_docsis_ucd_symbol_rate = -1;
84 static int hf_docsis_ucd_frequency = -1;
85 static int hf_docsis_ucd_preamble_pat = -1;
86 static int hf_docsis_ucd_iuc = -1;
88 static int hf_docsis_burst_mod_type = -1;
89 static int hf_docsis_burst_diff_encoding = -1;
90 static int hf_docsis_burst_preamble_len = -1;
91 static int hf_docsis_burst_preamble_val_off = -1;
92 static int hf_docsis_burst_fec = -1;
93 static int hf_docsis_burst_fec_codeword = -1;
94 static int hf_docsis_burst_scrambler_seed = -1;
95 static int hf_docsis_burst_max_burst = -1;
96 static int hf_docsis_burst_guard_time = -1;
97 static int hf_docsis_burst_last_cw_len = -1;
98 static int hf_docsis_burst_scrambler_onoff = -1;
100 /* Initialize the subtree pointers */
101 static gint ett_docsis_ucd = -1;
102 static gint ett_burst_descr = -1;
104 static const value_string channel_tlv_vals[] = {
105 {UCD_SYMBOL_RATE, "Symbol Rate"},
106 {UCD_FREQUENCY, "Frequency"},
107 {UCD_PREAMBLE, "Preamble Pattern"},
108 {UCD_BURST_DESCR, "Burst Descriptor"},
112 static const value_string on_off_vals[] = {
118 static const value_string mod_vals[] = {
124 value_string iuc_vals[] = {
125 {IUC_REQUEST, "Request"},
126 {IUC_REQ_DATA, "REQ/Data"},
127 {IUC_INIT_MAINT, "Initial Maintenance"},
128 {IUC_STATION_MAINT, "Station Maintenance"},
129 {IUC_SHORT_DATA_GRANT, "Short Data Grant"},
130 {IUC_LONG_DATA_GRANT, "Long Data Grant"},
131 {IUC_NULL_IE, "NULL IE"},
132 {IUC_DATA_ACK, "Data Ack"},
133 {IUC_RESERVED9, "Reserved"},
134 {IUC_RESERVED10, "Reserved"},
135 {IUC_RESERVED11, "Reserved"},
136 {IUC_RESERVED12, "Reserved"},
137 {IUC_RESERVED13, "Reserved"},
138 {IUC_RESERVED14, "Reserved"},
139 {IUC_EXPANSION, "Expanded IUC"},
143 static const value_string last_cw_len_vals[] = {
148 /* Code to actually dissect the packets */
150 dissect_ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
152 guint16 pos, endtlvpos;
154 guint8 tlvlen, tlvtype;
155 proto_tree *burst_descr_tree;
157 proto_tree *ucd_tree;
158 proto_item *ucd_item;
160 guint8 upchid, symrate;
162 len = tvb_length_remaining (tvb, 0);
163 upchid = tvb_get_guint8 (tvb, 0);
165 /* if the upstream Channel ID is 0 then this is for Telephony Return) */
166 if (check_col (pinfo->cinfo, COL_INFO))
168 col_clear (pinfo->cinfo, COL_INFO);
170 col_add_fstr (pinfo->cinfo, COL_INFO,
171 "UCD Message: Channel ID = %u (U%u)", upchid,
174 col_add_fstr (pinfo->cinfo, COL_INFO,
175 "UCD Message: Channel ID = %u (Telephony Return)",
182 proto_tree_add_protocol_format (tree, proto_docsis_ucd, tvb, 0,
183 tvb_length_remaining (tvb, 0),
185 ucd_tree = proto_item_add_subtree (ucd_item, ett_docsis_ucd);
186 proto_tree_add_item (ucd_tree, hf_docsis_ucd_upstream_chid, tvb, 0, 1,
188 proto_tree_add_item (ucd_tree, hf_docsis_ucd_config_ch_cnt, tvb, 1, 1,
190 proto_tree_add_item (ucd_tree, hf_docsis_ucd_mini_slot_size, tvb, 2, 1,
192 proto_tree_add_item (ucd_tree, hf_docsis_ucd_down_chid, tvb, 3, 1,
198 type = tvb_get_guint8 (tvb, pos++);
199 length = tvb_get_guint8 (tvb, pos++);
202 case UCD_SYMBOL_RATE:
205 symrate = tvb_get_guint8 (tvb, pos);
206 proto_tree_add_uint (ucd_tree, hf_docsis_ucd_symbol_rate,
207 tvb, pos, length, symrate * 160);
211 THROW (ReportedBoundsError);
218 proto_tree_add_item (ucd_tree, hf_docsis_ucd_frequency, tvb,
224 THROW (ReportedBoundsError);
228 proto_tree_add_item (ucd_tree, hf_docsis_ucd_preamble_pat, tvb,
232 case UCD_BURST_DESCR:
234 proto_tree_add_text (ucd_tree, tvb, pos, length,
235 "4 Burst Descriptor (Length = %u)",
237 burst_descr_tree = proto_item_add_subtree (it, ett_burst_descr);
238 proto_tree_add_item (burst_descr_tree, hf_docsis_ucd_iuc, tvb,
240 endtlvpos = pos + length - 1;
241 while (pos < endtlvpos)
243 tlvtype = tvb_get_guint8 (tvb, pos++);
244 tlvlen = tvb_get_guint8 (tvb, pos++);
250 proto_tree_add_item (burst_descr_tree,
251 hf_docsis_burst_mod_type, tvb,
256 THROW (ReportedBoundsError);
259 case UCD_DIFF_ENCODING:
262 proto_tree_add_item (burst_descr_tree,
263 hf_docsis_burst_diff_encoding,
264 tvb, pos, tlvlen, FALSE);
268 THROW (ReportedBoundsError);
271 case UCD_PREAMBLE_LEN:
274 proto_tree_add_item (burst_descr_tree,
275 hf_docsis_burst_preamble_len,
276 tvb, pos, tlvlen, FALSE);
280 THROW (ReportedBoundsError);
283 case UCD_PREAMBLE_VAL_OFF:
286 proto_tree_add_item (burst_descr_tree,
287 hf_docsis_burst_preamble_val_off,
288 tvb, pos, tlvlen, FALSE);
292 THROW (ReportedBoundsError);
298 proto_tree_add_item (burst_descr_tree,
299 hf_docsis_burst_fec, tvb, pos,
304 THROW (ReportedBoundsError);
307 case UCD_FEC_CODEWORD:
310 proto_tree_add_item (burst_descr_tree,
311 hf_docsis_burst_fec_codeword,
312 tvb, pos, tlvlen, FALSE);
316 THROW (ReportedBoundsError);
319 case UCD_SCRAMBLER_SEED:
322 proto_tree_add_item (burst_descr_tree,
323 hf_docsis_burst_scrambler_seed,
324 tvb, pos, tlvlen, FALSE);
328 THROW (ReportedBoundsError);
334 proto_tree_add_item (burst_descr_tree,
335 hf_docsis_burst_max_burst, tvb,
340 THROW (ReportedBoundsError);
346 proto_tree_add_item (burst_descr_tree,
347 hf_docsis_burst_guard_time,
348 tvb, pos, tlvlen, FALSE);
352 THROW (ReportedBoundsError);
355 case UCD_LAST_CW_LEN:
358 proto_tree_add_item (burst_descr_tree,
359 hf_docsis_burst_last_cw_len,
360 tvb, pos, tlvlen, FALSE);
364 THROW (ReportedBoundsError);
367 case UCD_SCRAMBLER_ONOFF:
370 proto_tree_add_item (burst_descr_tree,
371 hf_docsis_burst_scrambler_onoff,
372 tvb, pos, tlvlen, FALSE);
376 THROW (ReportedBoundsError);
379 } /* switch(tlvtype) */
381 } /* while (pos < endtlvpos) */
384 } /* while (pos < len) */
389 /* Register the protocol with Ethereal */
391 /* this format is require because a script is used to build the C function
392 that calls all the protocol registration.
397 proto_register_docsis_ucd (void)
400 /* Setup list of header fields See Section 1.6.1 for details*/
401 static hf_register_info hf[] = {
402 {&hf_docsis_ucd_upstream_chid,
403 {"Upstream Channel ID", "docsis.ucd.upchid",
404 FT_UINT8, BASE_DEC, NULL, 0x0,
405 "Upstream Channel ID", HFILL}
407 {&hf_docsis_ucd_config_ch_cnt,
408 {"Config Change Count", "docsis.ucd.confcngcnt",
409 FT_UINT8, BASE_DEC, NULL, 0x0,
410 "Configuration Change Count", HFILL}
412 {&hf_docsis_ucd_mini_slot_size,
413 {"Mini Slot Size (6.25us TimeTicks)", "docsis.ucd.mslotsize",
414 FT_UINT8, BASE_DEC, NULL, 0x0,
415 "Mini Slot Size (6.25us TimeTicks)", HFILL}
417 {&hf_docsis_ucd_down_chid,
418 {"Downstream Channel ID", "docsis.ucd.downchid",
419 FT_UINT8, BASE_DEC, NULL, 0x0,
420 "Management Message", HFILL}
422 {&hf_docsis_ucd_symbol_rate,
423 {"1 Symbol Rate (ksym/sec)", "docsis.ucd.symrate",
424 FT_UINT8, BASE_DEC, NULL, 0x0,
425 "Symbol Rate", HFILL}
427 {&hf_docsis_ucd_frequency,
428 {"2 Frequency (Hz)", "docsis.ucd.freq",
429 FT_UINT32, BASE_DEC, NULL, 0x0,
430 "Upstream Center Frequency", HFILL}
432 {&hf_docsis_ucd_preamble_pat,
433 {"3 Preamble Pattern", "docsis.ucd.preamble",
434 FT_BYTES, BASE_HEX, NULL, 0x0,
435 "Preamble Superstring", HFILL}
438 {"Interval Usage Code", "docsis.ucd.iuc",
439 FT_UINT8, BASE_DEC, VALS (iuc_vals), 0x0,
440 "Interval Usage Code", HFILL}
442 {&hf_docsis_burst_mod_type,
443 {"1 Modulation Type", "docsis.ucd.burst.modtype",
444 FT_UINT8, BASE_DEC, VALS (mod_vals), 0x0,
445 "Modulation Type", HFILL}
447 {&hf_docsis_burst_diff_encoding,
448 {"2 Differential Encoding", "docsis.ucd.burst.diffenc",
449 FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
450 "Differential Encoding", HFILL}
452 {&hf_docsis_burst_preamble_len,
453 {"3 Preamble Length (Bits)", "docsis.ucd.burst.preamble_len",
454 FT_UINT16, BASE_DEC, NULL, 0x0,
455 "Preamble Length (Bits)", HFILL}
457 {&hf_docsis_burst_preamble_val_off,
458 {"4 Preamble Offset (Bits)", "docsis.ucd.burst.preamble_off",
459 FT_UINT16, BASE_DEC, NULL, 0x0,
460 "Preamble Offset (Bits)", HFILL}
462 {&hf_docsis_burst_fec,
463 {"5 FEC (T)", "docsis.ucd.burst.fec",
464 FT_UINT8, BASE_DEC, NULL, 0x0,
465 "FEC (T) Codeword Parity Bits = 2^T", HFILL}
467 {&hf_docsis_burst_fec_codeword,
468 {"6 FEC Codeword Info bytes (k)", "docsis.ucd.burst.fec_codeword",
469 FT_UINT8, BASE_DEC, NULL, 0x0,
470 "FEC Codeword Info Bytes (k)", HFILL}
472 {&hf_docsis_burst_scrambler_seed,
473 {"7 Scrambler Seed", "docsis.ucd.burst.scrambler_seed",
474 FT_UINT16, BASE_HEX, NULL, 0x0,
475 "Burst Descriptor", HFILL}
477 {&hf_docsis_burst_max_burst,
478 {"8 Max Burst Size (Minislots)", "docsis.ucd.burst.maxburst",
479 FT_UINT8, BASE_DEC, NULL, 0x0,
480 "Max Burst Size (Minislots)", HFILL}
482 {&hf_docsis_burst_guard_time,
483 {"9 Guard Time Size (Symbol Times)", "docsis.ucd.burst.guardtime",
484 FT_UINT8, BASE_DEC, NULL, 0x0,
485 "Guard Time Size", HFILL}
487 {&hf_docsis_burst_last_cw_len,
488 {"10 Last Codeword Length", "docsis.ucd.burst.last_cw_len",
489 FT_UINT8, BASE_DEC, VALS (last_cw_len_vals), 0x0,
490 "Last Codeword Length", HFILL}
492 {&hf_docsis_burst_scrambler_onoff,
493 {"11 Scrambler On/Off", "docsis.ucd.burst.scrambleronoff",
494 FT_UINT8, BASE_DEC, VALS (on_off_vals), 0x0,
495 "Scrambler On/Off", HFILL}
499 /* Setup protocol subtree array */
500 static gint *ett[] = {
505 /* Register the protocol name and description */
507 proto_register_protocol ("DOCSIS Upstream Channel Descriptor",
508 "DOCSIS UCD", "docsis_ucd");
510 /* Required function calls to register the header fields and subtrees used */
511 proto_register_field_array (proto_docsis_ucd, hf, array_length (hf));
512 proto_register_subtree_array (ett, array_length (ett));
514 register_dissector ("docsis_ucd", dissect_ucd, proto_docsis_ucd);
518 /* If this dissector uses sub-dissector registration add a registration routine.
519 This format is required because a script is used to find these routines and
520 create the code that calls these routines.
523 proto_reg_handoff_docsis_ucd (void)
525 dissector_handle_t docsis_ucd_handle;
527 docsis_ucd_handle = find_dissector ("docsis_ucd");
528 dissector_add ("docsis_mgmt", 0x02, docsis_ucd_handle);