From fa5f913256bc16d21f9b9727fdf2cec454059c8d Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Mon, 8 May 2017 20:32:56 -0400 Subject: Bring DOCSIS Mac Management "dissectors" into modernity. 1. Use proto_tree_add_item_ret_uint to remove separate "gets" 2. Remove if (tree)s that prevented expert_info 3. Apply consistent whitespace 4. Apply consistent TLV behavior, making T and L always filterable 5. Remove T name (of TLV) from field name itself (where applicable) 6. Use BASE_UNIT_STRING and BASE_NO_DISPLAY_VALUE Tested with capture generated from https://github.com/AdrianSimionov/docsis-generator Change-Id: I9987397ccb3248b2a26d850af468740f94b28a63 Reviewed-on: https://code.wireshark.org/review/21561 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- plugins/docsis/packet-bintrngreq.c | 36 +- plugins/docsis/packet-bpkmreq.c | 22 +- plugins/docsis/packet-bpkmrsp.c | 22 +- plugins/docsis/packet-cmctrlreq.c | 18 +- plugins/docsis/packet-cmctrlrsp.c | 26 +- plugins/docsis/packet-cmstatus.c | 265 ++++---- plugins/docsis/packet-dbcreq.c | 23 +- plugins/docsis/packet-dbcrsp.c | 22 +- plugins/docsis/packet-dccack.c | 116 ++-- plugins/docsis/packet-dccreq.c | 543 +++++++++------- plugins/docsis/packet-dccrsp.c | 226 ++++--- plugins/docsis/packet-dcd.c | 911 ++++++++++++++++---------- plugins/docsis/packet-dpd.c | 183 +++--- plugins/docsis/packet-dpvreq.c | 46 +- plugins/docsis/packet-dpvrsp.c | 44 +- plugins/docsis/packet-dsaack.c | 23 +- plugins/docsis/packet-dsareq.c | 27 +- plugins/docsis/packet-dsarsp.c | 31 +- plugins/docsis/packet-dscack.c | 31 +- plugins/docsis/packet-dscreq.c | 27 +- plugins/docsis/packet-dscrsp.c | 31 +- plugins/docsis/packet-dsdreq.c | 35 +- plugins/docsis/packet-dsdrsp.c | 26 +- plugins/docsis/packet-intrngreq.c | 25 +- plugins/docsis/packet-macmgmt.c | 42 +- plugins/docsis/packet-map.c | 106 +-- plugins/docsis/packet-mdd.c | 789 ++++++++++++++++------- plugins/docsis/packet-ocd.c | 300 ++++----- plugins/docsis/packet-regack.c | 23 +- plugins/docsis/packet-regreq.c | 33 +- plugins/docsis/packet-regreqmp.c | 15 +- plugins/docsis/packet-regrsp.c | 30 +- plugins/docsis/packet-regrspmp.c | 17 +- plugins/docsis/packet-rngreq.c | 24 +- plugins/docsis/packet-rngrsp.c | 150 ++--- plugins/docsis/packet-sync.c | 16 +- plugins/docsis/packet-type29ucd.c | 866 ++++++++++++------------- plugins/docsis/packet-type35ucd.c | 991 +++++++++++++--------------- plugins/docsis/packet-type51ucd.c | 1254 +++++++++++++++++------------------- plugins/docsis/packet-uccreq.c | 19 +- plugins/docsis/packet-uccrsp.c | 19 +- plugins/docsis/packet-ucd.c | 932 ++++++++++++--------------- 42 files changed, 4256 insertions(+), 4129 deletions(-) diff --git a/plugins/docsis/packet-bintrngreq.c b/plugins/docsis/packet-bintrngreq.c index d85e34adc9..d9fe14e3c0 100644 --- a/plugins/docsis/packet-bintrngreq.c +++ b/plugins/docsis/packet-bintrngreq.c @@ -49,35 +49,25 @@ dissect_bintrngreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void proto_item *bintrngreq_item; proto_tree *bintrngreq_tree; guint16 md_ds_sg_id; + guint16 offset = 0; md_ds_sg_id = tvb_get_ntohs (tvb, 0); col_add_fstr (pinfo->cinfo, COL_INFO, "Bonded Ranging Request: MD-DS-SG-ID = %u (0x%X)", md_ds_sg_id, md_ds_sg_id ); - if (tree) - { - guint16 offset = 0; - bintrngreq_item = proto_tree_add_protocol_format (tree, proto_docsis_bintrngreq, - tvb, offset, tvb_captured_length(tvb), - "Bonded Initial Ranging Request"); - bintrngreq_tree = proto_item_add_subtree (bintrngreq_item, ett_docsis_bintrngreq); - proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_capflags, - tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item( bintrngreq_tree, hf_docsis_bintrngreq_capflags_frag, - tvb, offset, 1, ENC_BIG_ENDIAN ); - proto_tree_add_item( bintrngreq_tree, hf_docsis_bintrngreq_capflags_encrypt, - tvb, offset, 1, ENC_BIG_ENDIAN ); - offset++; - proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_mddsgid, - tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_down_chid, - tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_up_chid, - tvb, offset, 1, ENC_BIG_ENDIAN); - } + bintrngreq_item = proto_tree_add_item(tree, proto_docsis_bintrngreq, tvb, offset, -1, ENC_NA); + bintrngreq_tree = proto_item_add_subtree (bintrngreq_item, ett_docsis_bintrngreq); + proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_capflags, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item( bintrngreq_tree, hf_docsis_bintrngreq_capflags_frag, tvb, offset, 1, ENC_BIG_ENDIAN ); + proto_tree_add_item( bintrngreq_tree, hf_docsis_bintrngreq_capflags_encrypt, tvb, offset, 1, ENC_BIG_ENDIAN ); + offset++; + proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_mddsgid, tvb, offset, 1, ENC_BIG_ENDIAN); + offset++; + proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_down_chid, tvb, offset, 1, ENC_BIG_ENDIAN); + offset++; + proto_tree_add_item (bintrngreq_tree, hf_docsis_bintrngreq_up_chid, tvb, offset, 1, ENC_BIG_ENDIAN); + return tvb_captured_length(tvb); } diff --git a/plugins/docsis/packet-bpkmreq.c b/plugins/docsis/packet-bpkmreq.c index e3e7a50db4..6676fa857b 100644 --- a/plugins/docsis/packet-bpkmreq.c +++ b/plugins/docsis/packet-bpkmreq.c @@ -66,27 +66,19 @@ dissect_bpkmreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* d { proto_item *it; proto_tree *bpkmreq_tree; - guint8 code; + guint32 code; tvbuff_t *attrs_tvb; - code = tvb_get_guint8 (tvb, 0); + it = proto_tree_add_item(tree, proto_docsis_bpkmreq, tvb, 0, -1, ENC_NA); + bpkmreq_tree = proto_item_add_subtree (it, ett_docsis_bpkmreq); + proto_tree_add_item_ret_uint (bpkmreq_tree, hf_docsis_bpkmreq_code, tvb, 0, 1, + ENC_BIG_ENDIAN, &code); col_add_fstr (pinfo->cinfo, COL_INFO, "BPKM Request (%s)", val_to_str (code, code_field_vals, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_bpkmreq, tvb, 0, -1, - "BPKM Request Message"); - bpkmreq_tree = proto_item_add_subtree (it, ett_docsis_bpkmreq); - proto_tree_add_item (bpkmreq_tree, hf_docsis_bpkmreq_code, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (bpkmreq_tree, hf_docsis_bpkmreq_ident, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (bpkmreq_tree, hf_docsis_bpkmreq_length, tvb, 2, 2, - ENC_BIG_ENDIAN); - } + proto_tree_add_item (bpkmreq_tree, hf_docsis_bpkmreq_ident, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (bpkmreq_tree, hf_docsis_bpkmreq_length, tvb, 2, 2, ENC_BIG_ENDIAN); attrs_tvb = tvb_new_subset_remaining (tvb, 4); call_dissector (attrs_handle, attrs_tvb, pinfo, tree); diff --git a/plugins/docsis/packet-bpkmrsp.c b/plugins/docsis/packet-bpkmrsp.c index ba179dfb2e..78f19d7d50 100644 --- a/plugins/docsis/packet-bpkmrsp.c +++ b/plugins/docsis/packet-bpkmrsp.c @@ -66,27 +66,19 @@ dissect_bpkmrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* d { proto_item *it; proto_tree *bpkmrsp_tree; - guint8 code; + guint32 code; tvbuff_t *attrs_tvb; - code = tvb_get_guint8 (tvb, 0); + it = proto_tree_add_item(tree, proto_docsis_bpkmrsp, tvb, 0, -1, ENC_NA); + bpkmrsp_tree = proto_item_add_subtree (it, ett_docsis_bpkmrsp); + + proto_tree_add_item_ret_uint (bpkmrsp_tree, hf_docsis_bpkmrsp_code, tvb, 0, 1, ENC_BIG_ENDIAN, &code); col_add_fstr (pinfo->cinfo, COL_INFO, "BPKM Response (%s)", val_to_str (code, code_field_vals, "Unknown code %u")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_bpkmrsp, tvb, 0, -1, - "BPKM Response Message"); - bpkmrsp_tree = proto_item_add_subtree (it, ett_docsis_bpkmrsp); - proto_tree_add_item (bpkmrsp_tree, hf_docsis_bpkmrsp_code, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (bpkmrsp_tree, hf_docsis_bpkmrsp_ident, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (bpkmrsp_tree, hf_docsis_bpkmrsp_length, tvb, 2, 2, - ENC_BIG_ENDIAN); - } + proto_tree_add_item (bpkmrsp_tree, hf_docsis_bpkmrsp_ident, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (bpkmrsp_tree, hf_docsis_bpkmrsp_length, tvb, 2, 2, ENC_BIG_ENDIAN); /* Code to Call subdissector */ attrs_tvb = tvb_new_subset_remaining (tvb, 4); diff --git a/plugins/docsis/packet-cmctrlreq.c b/plugins/docsis/packet-cmctrlreq.c index 8a8c5c8c05..c232355193 100644 --- a/plugins/docsis/packet-cmctrlreq.c +++ b/plugins/docsis/packet-cmctrlreq.c @@ -43,25 +43,17 @@ static int dissect_cmctrlreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *cmctrlreq_tree = NULL; - guint16 transid; + proto_tree *cmctrlreq_tree; + guint32 transid; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); + it = proto_tree_add_item (tree, proto_docsis_cmctrlreq, tvb, 0, -1, ENC_NA); + cmctrlreq_tree = proto_item_add_subtree (it, ett_docsis_cmctrlreq); + proto_tree_add_item_ret_uint (cmctrlreq_tree, hf_docsis_cmctrlreq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); col_add_fstr (pinfo->cinfo, COL_INFO, "CM Control Request: Transaction-Id = %u", transid); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_cmctrlreq, tvb, 0, -1, - "CM Control Request"); - cmctrlreq_tree = proto_item_add_subtree (it, ett_docsis_cmctrlreq); - proto_tree_add_item (cmctrlreq_tree, hf_docsis_cmctrlreq_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - - } /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 2); call_dissector (cmctrl_tlv_handle, next_tvb, pinfo, cmctrlreq_tree); diff --git a/plugins/docsis/packet-cmctrlrsp.c b/plugins/docsis/packet-cmctrlrsp.c index b392ef9a7b..9c514a5165 100644 --- a/plugins/docsis/packet-cmctrlrsp.c +++ b/plugins/docsis/packet-cmctrlrsp.c @@ -51,29 +51,21 @@ static int dissect_cmctrlrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *cmctrlrsp_tree = NULL; - guint16 transid; + proto_tree *cmctrlrsp_tree; + guint32 transid; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); + it = proto_tree_add_item(tree, proto_docsis_cmctrlrsp, tvb, 0, -1, ENC_NA); + cmctrlrsp_tree = proto_item_add_subtree (it, ett_docsis_cmctrlrsp); + proto_tree_add_item_ret_uint (cmctrlrsp_tree, hf_docsis_cmctrlrsp_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); col_add_fstr (pinfo->cinfo, COL_INFO, "CM Control Response: Transaction-Id = %u", transid); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_cmctrlrsp, tvb, 0, -1, - "CM Control Response"); - cmctrlrsp_tree = proto_item_add_subtree (it, ett_docsis_cmctrlrsp); - proto_tree_add_item (cmctrlrsp_tree, hf_docsis_cmctrlrsp_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - - } - /* Call Dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 2); - call_dissector (cmctrl_tlv_handle, next_tvb, pinfo, cmctrlrsp_tree); - return tvb_captured_length(tvb); + /* Call Dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 2); + call_dissector (cmctrl_tlv_handle, next_tvb, pinfo, cmctrlrsp_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-cmstatus.c b/plugins/docsis/packet-cmstatus.c index f531e2cd85..7fd397922c 100644 --- a/plugins/docsis/packet-cmstatus.c +++ b/plugins/docsis/packet-cmstatus.c @@ -42,6 +42,14 @@ #define EVENT_US_CH_ID 5 #define EVENT_DSID 6 +static const value_string cmstatus_tlv_vals[] = { + {EVENT_DS_CH_ID, "Downstream Channel ID"}, + {EVENT_US_CH_ID, "Upstream Channel ID"}, + {EVENT_DSID, "DSID"}, + {EVENT_DESCR, "Description"}, + {0, NULL} +}; + void proto_register_docsis_cmstatus(void); void proto_reg_handoff_docsis_cmstatus(void); @@ -62,10 +70,14 @@ static int hf_docsis_cmstatus_ds_ch_id = -1; static int hf_docsis_cmstatus_us_ch_id = -1; static int hf_docsis_cmstatus_dsid = -1; static int hf_docsis_cmstatus_descr = -1; +static int hf_docsis_cmstatus_tlv_data = -1; +static int hf_docsis_cmstatus_type = -1; +static int hf_docsis_cmstatus_length = -1; /* Initialize the subtree pointers */ static gint ett_docsis_cmstatus = -1; static gint ett_docsis_cmstatus_tlv = -1; +static gint ett_docsis_cmstatus_tlvtlv = -1; static expert_field ei_docsis_cmstatus_tlvlen_bad = EI_INIT; @@ -74,68 +86,78 @@ static dissector_handle_t docsis_cmstatus_handle; /* Dissection */ /* See Table 6-52 in CM-SP-MULPIv3.0-I14-101008 */ static void -dissect_cmstatus_tlv (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, guint8 start, guint16 len) +dissect_cmstatus_tlv (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree) { - proto_item *it; + proto_item *it, *tlv_item, *tlv_len_item; proto_tree *tlv_tree; - guint16 pos = start + 1; - guint8 type, length; + guint16 pos = 0; + guint8 type; + guint32 length; - it = proto_tree_add_protocol_format (tree, proto_docsis_cmstatus, tvb, 0, len, "TLV Data"); + it = proto_tree_add_item(tree, hf_docsis_cmstatus_tlv_data, tvb, 0, tvb_reported_length(tvb), ENC_NA); tlv_tree = proto_item_add_subtree (it, ett_docsis_cmstatus_tlv); - while (pos < (len + start + 1)) + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(tlv_tree, tvb, pos, -1, + ett_docsis_cmstatus_tlvtlv, &tlv_item, + val_to_str(type, cmstatus_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_cmstatus_type, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_cmstatus_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch (type) { - length = tvb_get_guint8 (tvb, pos++); - type = tvb_get_guint8 (tvb, pos++); - switch (type) - { - case EVENT_DS_CH_ID: - if (length == 3) - { - proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_ds_ch_id, tvb, pos + 1, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - - case EVENT_US_CH_ID: - if (length == 3) - { - proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_us_ch_id, tvb, pos + 1, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - - case EVENT_DSID: - if (length == 5) - { - proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_dsid, tvb, pos + 1, 3, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - - case EVENT_DESCR: - if (length >= 3 && length <= 82) - { - proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_descr, tvb, pos + 1, length - 2, ENC_NA); - } - else - { - expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } /* switch */ - pos = pos + length; - } /* while */ + case EVENT_DS_CH_ID: + if (length == 3) + { + proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_ds_ch_id, tvb, pos + 1, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + + case EVENT_US_CH_ID: + if (length == 3) + { + proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_us_ch_id, tvb, pos + 1, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + + case EVENT_DSID: + if (length == 5) + { + proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_dsid, tvb, pos + 1, 3, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + + case EVENT_DESCR: + if (length >= 3 && length <= 82) + { + proto_tree_add_item (tlv_tree, hf_docsis_cmstatus_descr, tvb, pos + 1, length - 2, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + } /* switch */ + pos += length; + } /* while */ } static int @@ -143,66 +165,63 @@ dissect_cmstatus (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* { proto_item *it; proto_tree *cmstatus_tree = NULL; - guint16 transid; + guint32 transid; guint8 event_type; - guint16 len; - transid = tvb_get_ntohs (tvb, 0); - event_type = tvb_get_guint8 (tvb, 2); - len = tvb_reported_length_remaining (tvb, 3); + tvbuff_t* next_tvb; + + it = proto_tree_add_protocol_format (tree, proto_docsis_cmstatus, tvb, 0, -1, "CM-STATUS Report"); + cmstatus_tree = proto_item_add_subtree (it, ett_docsis_cmstatus); + proto_tree_add_item_ret_uint (cmstatus_tree, hf_docsis_cmstatus_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + col_add_fstr (pinfo->cinfo, COL_INFO, "CM-STATUS Report: Transaction ID = %u", transid); - if (tree) - { - it = proto_tree_add_protocol_format (tree, proto_docsis_cmstatus, tvb, 0, -1, "CM-STATUS Report"); - cmstatus_tree = proto_item_add_subtree (it, ett_docsis_cmstatus); - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_tranid, tvb, 0, 2, ENC_BIG_ENDIAN); - - switch (event_type) - { - case SEC_CH_MDD_TIMEOUT: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_mdd_t, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case QAM_FEC_LOCK_FAILURE: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_qfl_f, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case SEQ_OUT_OF_RANGE: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_s_o, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case SEC_CH_MDD_RECOVERY: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_mdd_r, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case QAM_FEC_LOCK_RECOVERY: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_qfl_r, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case T4_TIMEOUT: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_t4_t, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case T3_RETRIES_EXCEEDED: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_t3_e, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case SUCCESS_RANGING_AFTER_T3_RETRIES_EXCEEDED: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_rng_s, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case CM_ON_BATTERY: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_cm_b, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - - case CM_ON_AC_POWER: - proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_cm_a, tvb, 2, 1, ENC_BIG_ENDIAN); - break; - } /* switch */ - - } + event_type = tvb_get_guint8 (tvb, 2); + switch (event_type) + { + case SEC_CH_MDD_TIMEOUT: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_mdd_t, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case QAM_FEC_LOCK_FAILURE: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_qfl_f, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case SEQ_OUT_OF_RANGE: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_s_o, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case SEC_CH_MDD_RECOVERY: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_mdd_r, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case QAM_FEC_LOCK_RECOVERY: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_qfl_r, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case T4_TIMEOUT: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_t4_t, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case T3_RETRIES_EXCEEDED: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_t3_e, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case SUCCESS_RANGING_AFTER_T3_RETRIES_EXCEEDED: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_rng_s, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case CM_ON_BATTERY: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_cm_b, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + + case CM_ON_AC_POWER: + proto_tree_add_item (cmstatus_tree, hf_docsis_cmstatus_e_t_cm_a, tvb, 2, 1, ENC_BIG_ENDIAN); + break; + } /* switch */ + /* Call Dissector TLV's */ - dissect_cmstatus_tlv(tvb, pinfo, cmstatus_tree, 3, len); + next_tvb = tvb_new_subset_remaining(tvb, 3); + dissect_cmstatus_tlv(next_tvb, pinfo, cmstatus_tree); return tvb_captured_length(tvb); } @@ -247,22 +266,32 @@ proto_register_docsis_cmstatus (void) {"CM returned to A/C power", "docsis_cmstatus.cm_on_ac_power", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_cmstatus_descr, - {"1.2 Description", "docsis_cmstatus.description",FT_BYTES, BASE_NONE, NULL, 0x0,"Description", HFILL} + {"Description", "docsis_cmstatus.description",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_cmstatus_ds_ch_id, - {"1.4 Downstream Channel ID", "docsis_cmstatus.ds_chid",FT_UINT8, BASE_DEC, NULL, 0x0, "Downstream Channel ID", HFILL} + {"Downstream Channel ID", "docsis_cmstatus.ds_chid",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_cmstatus_us_ch_id, - {"1.5 Upstream Channel ID", "docsis_cmstatus.us_chid",FT_UINT8, BASE_DEC, NULL, 0x0, "Upstream Channel ID", HFILL} + {"Upstream Channel ID", "docsis_cmstatus.us_chid",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_cmstatus_dsid, - {"1.6 DSID", "docsis_cmstatus.dsid", FT_UINT24, BASE_DEC, NULL, 0x0, "DSID", HFILL} - } + {"DSID", "docsis_cmstatus.dsid", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL} + }, + {&hf_docsis_cmstatus_tlv_data, + {"TLV Data", "docsis_cmstatus.tlv_data", FT_BYTES, BASE_NO_DISPLAY_VALUE, NULL, 0x0, NULL, HFILL} + }, + {&hf_docsis_cmstatus_type, + {"Type", "docsis_cmstatus.type",FT_UINT8, BASE_DEC, VALS(cmstatus_tlv_vals), 0x0, NULL, HFILL} + }, + {&hf_docsis_cmstatus_length, + {"Length", "docsis_cmstatus.length",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} + }, }; static gint *ett[] = { &ett_docsis_cmstatus, - &ett_docsis_cmstatus_tlv + &ett_docsis_cmstatus_tlv, + &ett_docsis_cmstatus_tlvtlv, }; static ei_register_info ei[] = { diff --git a/plugins/docsis/packet-dbcreq.c b/plugins/docsis/packet-dbcreq.c index efa9c9755b..f9c8399805 100644 --- a/plugins/docsis/packet-dbcreq.c +++ b/plugins/docsis/packet-dbcreq.c @@ -45,28 +45,19 @@ static int dissect_dbcreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *dbcreq_item; - proto_tree *dbcreq_tree = NULL; - guint16 transid; + proto_tree *dbcreq_tree; + guint32 transid; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); + dbcreq_item = proto_tree_add_item(tree, proto_docsis_dbcreq, tvb, 0, -1, ENC_NA); + dbcreq_tree = proto_item_add_subtree (dbcreq_item, ett_docsis_dbcreq); + proto_tree_add_item_ret_uint(dbcreq_tree, hf_docsis_dbcreq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item( dbcreq_tree, hf_docsis_dbcreq_number_of_fragments, tvb, 2, 1, ENC_BIG_ENDIAN ); + proto_tree_add_item( dbcreq_tree, hf_docsis_dbcreq_fragment_sequence_number, tvb, 3, 1, ENC_BIG_ENDIAN ); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Bonding Change Request: Tran-Id = %u", transid); - if (tree) - { - dbcreq_item = proto_tree_add_protocol_format (tree, proto_docsis_dbcreq, - tvb, 0, -1, - "Dynamic Bonding Change Request"); - dbcreq_tree = proto_item_add_subtree (dbcreq_item, ett_docsis_dbcreq); - proto_tree_add_item (dbcreq_tree, hf_docsis_dbcreq_tranid, - tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item( dbcreq_tree, hf_docsis_dbcreq_number_of_fragments, - tvb, 2, 1, ENC_BIG_ENDIAN ); - proto_tree_add_item( dbcreq_tree, hf_docsis_dbcreq_fragment_sequence_number , - tvb, 3, 1, ENC_BIG_ENDIAN ); - } /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 4); call_dissector (docsis_tlv_handle, next_tvb, pinfo, dbcreq_tree); diff --git a/plugins/docsis/packet-dbcrsp.c b/plugins/docsis/packet-dbcrsp.c index 5e4ca2c619..a07a0001d9 100644 --- a/plugins/docsis/packet-dbcrsp.c +++ b/plugins/docsis/packet-dbcrsp.c @@ -46,29 +46,19 @@ static int dissect_dbcrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *dbcrsp_item; - proto_tree *dbcrsp_tree = NULL; - guint16 transid; - guint8 confcode; + proto_tree *dbcrsp_tree; + guint32 transid, confcode; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); - confcode = tvb_get_guint8 (tvb, 2); + dbcrsp_item = proto_tree_add_item(tree, proto_docsis_dbcrsp, tvb, 0, -1, ENC_NA); + dbcrsp_tree = proto_item_add_subtree (dbcrsp_item, ett_docsis_dbcrsp); + proto_tree_add_item_ret_uint(dbcrsp_tree, hf_docsis_dbcrsp_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint( dbcrsp_tree, hf_docsis_dbcrsp_conf_code, tvb, 2, 1, ENC_BIG_ENDIAN, &confcode); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Bonding Change Response: Tran-Id = %u (%s)", transid, val_to_str (confcode, docsis_conf_code, "%d")); - if (tree) - { - dbcrsp_item = proto_tree_add_protocol_format (tree, proto_docsis_dbcrsp, - tvb, 0, -1, - "Dynamic Bonding Change Response"); - dbcrsp_tree = proto_item_add_subtree (dbcrsp_item, ett_docsis_dbcrsp); - proto_tree_add_item (dbcrsp_tree, hf_docsis_dbcrsp_tranid, - tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item( dbcrsp_tree, hf_docsis_dbcrsp_conf_code, - tvb, 2, 1, ENC_BIG_ENDIAN ); - } /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 3); call_dissector (docsis_tlv_handle, next_tvb, pinfo, dbcrsp_tree); diff --git a/plugins/docsis/packet-dccack.c b/plugins/docsis/packet-dccack.c index 38c4a665e7..4a20920008 100644 --- a/plugins/docsis/packet-dccack.c +++ b/plugins/docsis/packet-dccack.c @@ -35,12 +35,21 @@ void proto_reg_handoff_docsis_dccack(void); /* Initialize the protocol and registered fields */ static int proto_docsis_dccack = -1; +static int hf_docsis_dcc_type = -1; +static int hf_docsis_dcc_length = -1; static int hf_docsis_dccack_tran_id = -1; static int hf_docsis_dccack_key_seq_num = -1; static int hf_docsis_dccack_hmac_digest = -1; /* Initialize the subtree pointers */ static gint ett_docsis_dccack = -1; +static gint ett_docsis_dccack_tlv = -1; + +static const value_string dccack_tlv_vals[] = { + {DCCACK_HMAC_DIGEST, "HMAC-DigestNumber"}, + {DCCACK_KEY_SEQ_NUM, "Auth Key Sequence Number"}, + {0, NULL} +}; static expert_field ei_docsis_dccack_tlvlen_bad = EI_INIT; @@ -51,55 +60,59 @@ static int dissect_dccack (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { guint16 pos; - guint8 type, length; - proto_tree *dcc_tree; - proto_item *dcc_item; - guint16 len; - - len = tvb_reported_length(tvb); + guint8 type; + guint32 length; + proto_tree *dcc_tree, *tlv_tree; + proto_item *dcc_item, *tlv_item, *tlv_len_item; - col_set_str(pinfo->cinfo, COL_INFO, "DCC-ACK Message: "); + col_set_str(pinfo->cinfo, COL_INFO, "DCC-ACK Message"); - dcc_item = - proto_tree_add_protocol_format (tree, proto_docsis_dccack, tvb, 0, - -1, "DCC-ACK Message"); + dcc_item = proto_tree_add_item(tree, proto_docsis_dccack, tvb, 0, -1, ENC_NA); dcc_tree = proto_item_add_subtree (dcc_item, ett_docsis_dccack); proto_tree_add_item (dcc_tree, hf_docsis_dccack_tran_id, tvb, 0, 2, ENC_BIG_ENDIAN); pos = 2; - while (pos < len) + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(dcc_tree, tvb, pos, -1, + ett_docsis_dccack_tlv, &tlv_item, + val_to_str(type, dccack_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_dcc_type, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_dcc_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - switch (type) - { - case DCCACK_KEY_SEQ_NUM: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccack_key_seq_num, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccack_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCACK_HMAC_DIGEST: - if (length == 20) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccack_hmac_digest, tvb, - pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccack_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } /* switch(type) */ - pos = pos + length; - } /* while (pos < len) */ - - return tvb_captured_length(tvb); + case DCCACK_KEY_SEQ_NUM: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccack_key_seq_num, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccack_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCACK_HMAC_DIGEST: + if (length == 20) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccack_hmac_digest, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccack_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + } /* switch(type) */ + + pos += length; + } /* while (tvb_reported_length_remaining(tvb, pos) > 0) */ + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ @@ -107,6 +120,24 @@ void proto_register_docsis_dccack (void) { static hf_register_info hf[] = { + {&hf_docsis_dcc_type, + { + "Type", + "docsis_dccack.tlvtype", + FT_UINT8, BASE_DEC, VALS(dccack_tlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_length, + { + "Length", + "docsis_dccack.tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dccack_tran_id , { "Transaction ID", @@ -139,6 +170,7 @@ proto_register_docsis_dccack (void) static gint *ett[] = { &ett_docsis_dccack, + &ett_docsis_dccack_tlv, }; static ei_register_info ei[] = { diff --git a/plugins/docsis/packet-dccreq.c b/plugins/docsis/packet-dccreq.c index 5767dd7365..0c7e306cf6 100644 --- a/plugins/docsis/packet-dccreq.c +++ b/plugins/docsis/packet-dccreq.c @@ -60,8 +60,12 @@ void proto_reg_handoff_docsis_dccreq(void); /* Initialize the protocol and registered fields */ static int proto_docsis_dccreq = -1; +static int hf_docsis_dcc_type = -1; +static int hf_docsis_dcc_length = -1; static int hf_docsis_dccreq_tran_id = -1; static int hf_docsis_dccreq_up_chan_id = -1; +static int hf_docsis_dcc_ds_params_subtype = -1; +static int hf_docsis_dcc_ds_params_length = -1; static int hf_docsis_dccreq_ds_freq = -1; static int hf_docsis_dccreq_ds_mod_type = -1; static int hf_docsis_dccreq_ds_sym_rate = -1; @@ -73,6 +77,8 @@ static int hf_docsis_dccreq_init_tech = -1; static int hf_docsis_dccreq_ucd_sub = -1; static int hf_docsis_dccreq_said_sub_cur = -1; static int hf_docsis_dccreq_said_sub_new = -1; +static int hf_docsis_dcc_sf_sub_subtype = -1; +static int hf_docsis_dcc_sf_sub_length = -1; static int hf_docsis_dccreq_sf_sfid_cur = -1; static int hf_docsis_dccreq_sf_sfid_new = -1; static int hf_docsis_dccreq_sf_sid_cur = -1; @@ -84,6 +90,7 @@ static int hf_docsis_dccreq_hmac_digest = -1; /* Initialize the subtree pointers */ static gint ett_docsis_dccreq = -1; +static gint ett_docsis_dccreq_tlv = -1; static gint ett_docsis_dccreq_ds_params = -1; static gint ett_docsis_dccreq_sf_sub = -1; @@ -91,19 +98,19 @@ static expert_field ei_docsis_dccreq_tlvlen_bad = EI_INIT; static dissector_handle_t docsis_dccreq_handle; -value_string ds_mod_type_vals[] = { +static const value_string ds_mod_type_vals[] = { {0 , "64 QAM"}, {1 , "256 QAM"}, {0, NULL} }; -value_string ds_sym_rate_vals[] = { +static const value_string ds_sym_rate_vals[] = { {0 , "5.056941 Msym/sec"}, {1 , "5.360537 Msym/sec"}, {2 , "6.952 Msym/sec"}, {0, NULL} }; -value_string init_tech_vals[] = { +static const value_string init_tech_vals[] = { {0 , "Reinitialize MAC"}, {1 , "Broadcast Init RNG on new chanbefore normal op"}, {2 , "Unicast RNG on new chan before normal op"}, @@ -112,261 +119,298 @@ value_string init_tech_vals[] = { {0, NULL} }; +static const value_string dcc_tlv_vals[] = { + {DCCREQ_UP_CHAN_ID, "Up Channel ID"}, + {DCCREQ_DS_PARAMS, "Downstream Params Encodings"}, + {DCCREQ_INIT_TECH, "Initialization Technique"}, + {DCCREQ_UCD_SUB, "UCD Substitution"}, + {DCCREQ_SAID_SUB, "SAID Sub"}, + {DCCREQ_SF_SUB, "Service Flow Substitution Encodings"}, + {DCCREQ_CMTS_MAC_ADDR, "CMTS Mac Address"}, + {DCCREQ_KEY_SEQ_NUM, "Auth Key Sequence Number"}, + {DCCREQ_HMAC_DIGEST, "HMAC-DigestNumber"}, + {0, NULL} +}; + +static const value_string ds_param_subtlv_vals[] = { + {DCCREQ_DS_FREQ, "Frequency"}, + {DCCREQ_DS_MOD_TYPE, "Modulation Type"}, + {DCCREQ_DS_SYM_RATE, "Symbol Rate"}, + {DCCREQ_DS_INTLV_DEPTH, "Interleaver Depth"}, + {DCCREQ_DS_CHAN_ID, "Downstream Channel ID"}, + {DCCREQ_DS_SYNC_SUB, "SYNC Substitution"}, + {0, NULL} +}; + +static const value_string sf_sub_subtlv_vals[] = { + {DCCREQ_SF_SFID, "SFID"}, + {DCCREQ_SF_SID, "SID"}, + {DCCREQ_SF_UNSOL_GRANT_TREF, "Unsolicited Grant Time Reference"}, + {0, NULL} +}; + + /* Dissection */ static void dissect_dccreq_ds_params (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcc_tree; - proto_item *dcc_item; + proto_item *dcc_item, *tlv_len_item; int pos; pos = start; - dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccreq_ds_params, &dcc_item, - "2 DCC-REQ Downstream Params Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcc_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dccreq_ds_params, &dcc_item, + val_to_str(type, ds_param_subtlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcc_tree, hf_docsis_dcc_ds_params_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcc_tree, hf_docsis_dcc_ds_params_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcc_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCCREQ_DS_FREQ: - if (length == 4) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_freq, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_DS_MOD_TYPE: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_mod_type, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_DS_SYM_RATE: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_sym_rate, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_DS_INTLV_DEPTH: - if (length == 2) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_intlv_depth_i, tvb, - pos, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_intlv_depth_j, tvb, - pos + 1, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_DS_CHAN_ID: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_chan_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_DS_SYNC_SUB: - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_sync_sub, tvb, - pos, length, ENC_BIG_ENDIAN); - break; - - } - pos = pos + length; + case DCCREQ_DS_FREQ: + if (length == 4) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_freq, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_DS_MOD_TYPE: + if (length == 1) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_mod_type, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_DS_SYM_RATE: + if (length == 1) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_sym_rate, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_DS_INTLV_DEPTH: + if (length == 2) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_intlv_depth_i, tvb, pos, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_intlv_depth_j, tvb, pos + 1, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_DS_CHAN_ID: + if (length == 1) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_chan_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_DS_SYNC_SUB: + if (length == 1) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ds_sync_sub, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; } + + pos += length; + } } static void dissect_dccreq_sf_sub (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcc_tree; - proto_item *dcc_item; + proto_item *dcc_item, *tlv_len_item; int pos; pos = start; - dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccreq_sf_sub, &dcc_item, "7 DCC-REQ Service Flow Substitution Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcc_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dccreq_sf_sub, &dcc_item, + val_to_str(type, sf_sub_subtlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcc_tree, hf_docsis_dcc_sf_sub_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcc_tree, hf_docsis_dcc_sf_sub_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcc_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCCREQ_SF_SFID: - if (length == 8) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_cur, tvb, - pos, 4, ENC_BIG_ENDIAN); - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_new, tvb, - pos + 4, 4, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_SF_SID: - if (length == 4) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_cur, tvb, - pos, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_new, tvb, - pos + 2, 2, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_SF_UNSOL_GRANT_TREF: - if (length == 4) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_unsol_grant_tref, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } - pos = pos + length; + case DCCREQ_SF_SFID: + if (length == 8) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_cur, tvb, pos, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_new, tvb, pos + 4, 4, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_SF_SID: + if (length == 4) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_cur, tvb, pos, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_new, tvb, pos + 2, 2, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_SF_UNSOL_GRANT_TREF: + if (length == 4) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_unsol_grant_tref, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; } + + pos += length; + } } static int dissect_dccreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { guint16 pos; - guint8 type, length; - proto_tree *dcc_tree; - proto_item *dcc_item; - guint16 len; + guint8 type; + guint32 length; + proto_tree *dcc_tree, *tlv_tree; + proto_item *dcc_item, *tlv_item, *tlv_len_item; - len = tvb_reported_length(tvb); + col_set_str(pinfo->cinfo, COL_INFO, "DCC-REQ Message"); - col_set_str(pinfo->cinfo, COL_INFO, "DCC-REQ Message: "); - - dcc_item = - proto_tree_add_protocol_format (tree, proto_docsis_dccreq, tvb, 0, - -1, "DCC-REQ Message"); + dcc_item = proto_tree_add_item (tree, proto_docsis_dccreq, tvb, 0, -1, ENC_NA); dcc_tree = proto_item_add_subtree (dcc_item, ett_docsis_dccreq); + proto_tree_add_item (dcc_tree, hf_docsis_dccreq_tran_id, tvb, 0, 2, ENC_BIG_ENDIAN); pos = 2; - while (pos < len) + while (tvb_reported_length_remaining(tvb, pos) > 0) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCCREQ_UP_CHAN_ID: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_up_chan_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_DS_PARAMS: - dissect_dccreq_ds_params (tvb , pinfo, dcc_tree , pos , length ); - break; - case DCCREQ_INIT_TECH: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_init_tech, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_UCD_SUB: - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_ucd_sub, tvb, - pos, length, ENC_NA); - break; - case DCCREQ_SAID_SUB: - if (length == 4) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_said_sub_cur, tvb, - pos, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_said_sub_new, tvb, - pos + 2, 2, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_SF_SUB: - dissect_dccreq_sf_sub (tvb , pinfo, dcc_tree , pos , length ); - break; - case DCCREQ_CMTS_MAC_ADDR: - if (length == 6) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_cmts_mac_addr, tvb, - pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_KEY_SEQ_NUM: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_key_seq_num, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCREQ_HMAC_DIGEST: - if (length == 20) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccreq_hmac_digest, tvb, - pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } /* switch(type) */ - pos = pos + length; - } /* while (pos < len) */ + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(dcc_tree, tvb, pos, -1, + ett_docsis_dccreq_tlv, &tlv_item, + val_to_str(type, dcc_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_dcc_type, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_dcc_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch (type) + { + case DCCREQ_UP_CHAN_ID: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_up_chan_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_DS_PARAMS: + dissect_dccreq_ds_params (tvb, pinfo, tlv_tree, pos, length); + break; + case DCCREQ_INIT_TECH: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_init_tech, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_UCD_SUB: + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_ucd_sub, tvb, pos, length, ENC_NA); + break; + case DCCREQ_SAID_SUB: + if (length == 4) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_said_sub_cur, tvb, pos, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_said_sub_new, tvb, pos + 2, 2, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_SF_SUB: + dissect_dccreq_sf_sub (tvb, pinfo, tlv_tree, pos, length ); + break; + case DCCREQ_CMTS_MAC_ADDR: + if (length == 6) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_cmts_mac_addr, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_KEY_SEQ_NUM: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_key_seq_num, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCREQ_HMAC_DIGEST: + if (length == 20) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccreq_hmac_digest, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + } /* switch(type) */ + pos += length; + } /* (tvb_reported_length_remaining(tvb, pos) > 0) */ return tvb_captured_length(tvb); } @@ -375,6 +419,24 @@ void proto_register_docsis_dccreq (void) { static hf_register_info hf[] = { + {&hf_docsis_dcc_type, + { + "Type", + "docsis_dccreq.tlvtype", + FT_UINT8, BASE_DEC, VALS(dcc_tlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_length, + { + "Length", + "docsis_dccreq.tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dccreq_tran_id , { "Transaction ID", @@ -393,6 +455,24 @@ proto_register_docsis_dccreq (void) HFILL } }, + {&hf_docsis_dcc_ds_params_subtype, + { + "Type", + "docsis_dccreq.ds_tlvtype", + FT_UINT8, BASE_DEC, VALS(ds_param_subtlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_ds_params_length, + { + "Length", + "docsis_dccreq.ds_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dccreq_ds_freq , { "Frequency", @@ -492,6 +572,24 @@ proto_register_docsis_dccreq (void) HFILL } }, + {&hf_docsis_dcc_sf_sub_subtype, + { + "Type", + "docsis_dccreq.sf_tlvtype", + FT_UINT8, BASE_DEC, VALS(sf_sub_subtlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_sf_sub_length, + { + "Length", + "docsis_dccreq.sf_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dccreq_sf_sfid_cur , { "SF Sub - SFID Current Value", @@ -571,6 +669,7 @@ proto_register_docsis_dccreq (void) &ett_docsis_dccreq, &ett_docsis_dccreq_sf_sub, &ett_docsis_dccreq_ds_params, + &ett_docsis_dccreq_tlv, }; static ei_register_info ei[] = { diff --git a/plugins/docsis/packet-dccrsp.c b/plugins/docsis/packet-dccrsp.c index 84d317bced..b71584feee 100644 --- a/plugins/docsis/packet-dccrsp.c +++ b/plugins/docsis/packet-dccrsp.c @@ -44,6 +44,10 @@ static int proto_docsis_dccrsp = -1; static int hf_docsis_dccrsp_tran_id = -1; static int hf_docsis_dccrsp_conf_code = -1; +static int hf_docsis_dcc_type = -1; +static int hf_docsis_dcc_length = -1; +static int hf_docsis_dcc_cm_jump_subtype = -1; +static int hf_docsis_dcc_cm_jump_length = -1; static int hf_docsis_dccrsp_cm_jump_time_length = -1; static int hf_docsis_dccrsp_cm_jump_time_start = -1; static int hf_docsis_dccrsp_key_seq_num = -1; @@ -52,6 +56,7 @@ static int hf_docsis_dccrsp_hmac_digest = -1; /* Initialize the subtree pointers */ static gint ett_docsis_dccrsp = -1; static gint ett_docsis_dccrsp_cm_jump_time = -1; +static gint ett_docsis_dccrsp_tlv = -1; static expert_field ei_docsis_dccrsp_tlvlen_bad = EI_INIT; @@ -60,108 +65,130 @@ static dissector_handle_t docsis_dccrsp_handle; /* Defined in packet-tlv.c */ extern value_string docsis_conf_code[]; +static const value_string dccrsp_tlv_vals[] = { + {DCCRSP_CM_JUMP_TIME, "CM Jump Time Encodings"}, + {DCCRSP_KEY_SEQ_NUM, "Auth Key Sequence Number"}, + {DCCRSP_HMAC_DIGEST, "HMAC-Digest Number"}, + {0, NULL} +}; + +static const value_string cm_jump_subtlv_vals[] = { + {DCCRSP_CM_JUMP_TIME_LENGTH, "Length of Jump"}, + {DCCRSP_CM_JUMP_TIME_START, "Start Time of Jump"}, + {0, NULL} +}; + /* Dissection */ static void dissect_dccrsp_cm_jump_time (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcc_tree; - proto_item *dcc_item; + proto_item *dcc_item, *tlv_len_item; int pos; pos = start; - dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccrsp_cm_jump_time, &dcc_item, - "1 CM Jump Time Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcc_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dccrsp_cm_jump_time, &dcc_item, + val_to_str(type, cm_jump_subtlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcc_tree, hf_docsis_dcc_cm_jump_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcc_tree, hf_docsis_dcc_cm_jump_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcc_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCCRSP_CM_JUMP_TIME_LENGTH: - if (length == 4) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_cm_jump_time_length, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCRSP_CM_JUMP_TIME_START: - if (length == 8) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_cm_jump_time_start, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } - pos = pos + length; + case DCCRSP_CM_JUMP_TIME_LENGTH: + if (length == 4) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_cm_jump_time_length, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCRSP_CM_JUMP_TIME_START: + if (length == 8) + { + proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_cm_jump_time_start, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; } + + pos += length; + } } static int dissect_dccrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { guint16 pos; - guint8 type, length; - proto_tree *dcc_tree; - proto_item *dcc_item; - guint16 len; + guint8 type; + guint32 length; + proto_tree *dcc_tree, *tlv_tree; + proto_item *dcc_item, *tlv_item, *tlv_len_item; - len = tvb_reported_length(tvb); + col_set_str(pinfo->cinfo, COL_INFO, "DCC-RSP Message"); - col_set_str(pinfo->cinfo, COL_INFO, "DCC-RSP Message: "); - - dcc_item = - proto_tree_add_protocol_format (tree, proto_docsis_dccrsp, tvb, 0, - -1, "DCC-RSP Message"); + dcc_item = proto_tree_add_item (tree, proto_docsis_dccrsp, tvb, 0, -1, ENC_NA); dcc_tree = proto_item_add_subtree (dcc_item, ett_docsis_dccrsp); proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_tran_id, tvb, 0, 2, ENC_BIG_ENDIAN); proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_conf_code, tvb, 2, 1, ENC_BIG_ENDIAN); pos = 3; - while (pos < len) + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(dcc_tree, tvb, pos, -1, + ett_docsis_dccrsp_tlv, &tlv_item, + val_to_str(type, dccrsp_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_dcc_type, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_dcc_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - switch (type) - { - case DCCRSP_CM_JUMP_TIME: - dissect_dccrsp_cm_jump_time (tvb , pinfo, dcc_tree , pos , length ); - break; - case DCCRSP_KEY_SEQ_NUM: - if (length == 1) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_key_seq_num, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCCRSP_HMAC_DIGEST: - if (length == 20) - { - proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_hmac_digest, tvb, - pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } /* switch(type) */ - pos = pos + length; - } /* while (pos < len) */ + case DCCRSP_CM_JUMP_TIME: + dissect_dccrsp_cm_jump_time (tvb, pinfo, tlv_tree, pos, length ); + break; + case DCCRSP_KEY_SEQ_NUM: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccrsp_key_seq_num, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCCRSP_HMAC_DIGEST: + if (length == 20) + { + proto_tree_add_item (tlv_tree, hf_docsis_dccrsp_hmac_digest, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + } /* switch(type) */ + + pos += length; + } /* while (tvb_reported_length_remaining(tvb, pos) > 0) */ return tvb_captured_length(tvb); } @@ -189,9 +216,45 @@ proto_register_docsis_dccrsp (void) HFILL } }, + {&hf_docsis_dcc_type, + { + "Type", + "docsis_dccrsp.tlvtype", + FT_UINT8, BASE_DEC, VALS(dccrsp_tlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_length, + { + "Length", + "docsis_dccrsp.tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_cm_jump_subtype, + { + "Type", + "docsis_dccrsp.cm_jump_tlvtype", + FT_UINT8, BASE_DEC, VALS(cm_jump_subtlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcc_cm_jump_length, + { + "Length", + "docsis_dccrsp.cm_jump_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dccrsp_cm_jump_time_length , { - ".1 Length of Jump", + "Length of Jump", "docsis_dccrsp.cm_jump_time_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, @@ -200,7 +263,7 @@ proto_register_docsis_dccrsp (void) }, {&hf_docsis_dccrsp_cm_jump_time_start , { - ".2 Start Time of Jump", + "Start Time of Jump", "docsis_dccrsp.cm_jump_time_start", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, @@ -209,7 +272,7 @@ proto_register_docsis_dccrsp (void) }, {&hf_docsis_dccrsp_key_seq_num , { - "31 Auth Key Sequence Number", + "Auth Key Sequence Number", "docsis_dccrsp.key_seq_num", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, @@ -218,7 +281,7 @@ proto_register_docsis_dccrsp (void) }, {&hf_docsis_dccrsp_hmac_digest , { - "27 HMAC-Digest Number", + "HMAC-Digest Number", "docsis_dccrsp.hmac_digest", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, @@ -231,6 +294,7 @@ proto_register_docsis_dccrsp (void) static gint *ett[] = { &ett_docsis_dccrsp, &ett_docsis_dccrsp_cm_jump_time, + &ett_docsis_dccrsp_tlv, }; static ei_register_info ei[] = { diff --git a/plugins/docsis/packet-dcd.c b/plugins/docsis/packet-dcd.c index 033d1952ea..1e9976f4b7 100644 --- a/plugins/docsis/packet-dcd.c +++ b/plugins/docsis/packet-dcd.c @@ -89,8 +89,14 @@ static int proto_docsis_dcd = -1; static int hf_docsis_dcd_config_ch_cnt = -1; static int hf_docsis_dcd_num_of_frag = -1; static int hf_docsis_dcd_frag_sequence_num = -1; +static int hf_docsis_dcd_type = -1; +static int hf_docsis_dcd_length = -1; +static int hf_docsis_dcd_down_classifier_subtype = -1; +static int hf_docsis_dcd_down_classifier_length = -1; static int hf_docsis_dcd_cfr_id = -1; static int hf_docsis_dcd_cfr_rule_pri = -1; +static int hf_docsis_dcd_cfr_ip_subtype = -1; +static int hf_docsis_dcd_cfr_ip_length = -1; static int hf_docsis_dcd_cfr_ip_source_addr = -1; static int hf_docsis_dcd_cfr_ip_source_mask = -1; static int hf_docsis_dcd_cfr_ip_dest_addr = -1; @@ -102,13 +108,19 @@ static int hf_docsis_dcd_cfr_tcpudp_dstport_end = -1; static int hf_docsis_dcd_rule_id = -1; static int hf_docsis_dcd_rule_pri = -1; static int hf_docsis_dcd_rule_ucid_list = -1; +static int hf_docsis_dcd_clid_subtype = -1; +static int hf_docsis_dcd_clid_length = -1; static int hf_docsis_dcd_clid_bcast_id = -1; static int hf_docsis_dcd_clid_known_mac_addr = -1; static int hf_docsis_dcd_clid_ca_sys_id = -1; static int hf_docsis_dcd_clid_app_id = -1; +static int hf_docsis_dcd_dsg_rule_subtype = -1; +static int hf_docsis_dcd_dsg_rule_length = -1; static int hf_docsis_dcd_rule_tunl_addr = -1; static int hf_docsis_dcd_rule_cfr_id = -1; static int hf_docsis_dcd_rule_vendor_spec = -1; +static int hf_docsis_dcd_cfg_subtype = -1; +static int hf_docsis_dcd_cfg_length = -1; static int hf_docsis_dcd_cfg_chan = -1; static int hf_docsis_dcd_cfg_tdsg1 = -1; static int hf_docsis_dcd_cfg_tdsg2 = -1; @@ -123,6 +135,62 @@ static gint ett_docsis_dcd_cfr_ip = -1; static gint ett_docsis_dcd_rule = -1; static gint ett_docsis_dcd_clid = -1; static gint ett_docsis_dcd_cfg = -1; +static gint ett_docsis_dcd_tlv = -1; + +static const value_string dcd_tlv_vals[] = { + {DCD_DOWN_CLASSIFIER, "DCD_CFR Encodings"}, + {DCD_DSG_RULE, "DCD DSG Rule Encodings"}, + {DCD_DSG_CONFIG, "DCD DSG Config Encodings"}, + {0, NULL} +}; + +static const value_string dcd_down_classifier_vals[] = { + {DCD_CFR_ID, "Downstream Classifier Id"}, + {DCD_CFR_RULE_PRI, "Downstream Classifier Rule Priority"}, + {DCD_CFR_IP_CLASSIFIER, "DCD_CFR_IP Encodings"}, + {0, NULL} +}; + +static const value_string dcd_dsg_rule_vals[] = { + {DCD_RULE_ID, "DSG Rule Id"}, + {DCD_RULE_PRI, "DSG Rule Priority"}, + {DCD_RULE_UCID_RNG, "DSG Rule UCID Range"}, + {DCD_RULE_CLIENT_ID, "DCD Rule ClientID Encodings"}, + {DCD_RULE_TUNL_ADDR, "DSG Rule Tunnel MAC Address"}, + {DCD_RULE_CFR_ID, "DSG Rule Classifier ID"}, + {DCD_RULE_VENDOR_SPEC, "DSG Rule Vendor Specific Parameters"}, + {0, NULL} +}; + +static const value_string dcd_clid_vals[] = { + {DCD_CLID_BCAST_ID, "DSG Rule Client ID Broadcast ID"}, + {DCD_CLID_KNOWN_MAC_ADDR, "DSG Rule Client ID Known MAC Address"}, + {DCD_CLID_CA_SYS_ID, "DSG Rule Client ID CA System ID"}, + {DCD_CLID_APP_ID, "DSG Rule Client ID Application ID"}, + {0, NULL} +}; + +static const value_string dcd_cfr_ip_vals[] = { + {DCD_CFR_IP_SOURCE_ADDR, "Downstream Classifier IP Source Address"}, + {DCD_CFR_IP_SOURCE_MASK, "Downstream Classifier IP Source Mask"}, + {DCD_CFR_IP_DEST_ADDR, "Downstream Classifier IP Destination Address"}, + {DCD_CFR_IP_DEST_MASK, "Downstream Classifier IP Destination Mask"}, + {DCD_CFR_TCPUDP_SRCPORT_START, "Downstream Classifier IP TCP/UDP Source Port Start"}, + {DCD_CFR_TCPUDP_SRCPORT_END, "Downstream Classifier IP TCP/UDP Source Port End"}, + {DCD_CFR_TCPUDP_DSTPORT_START, "Downstream Classifier IP TCP/UDP Destination Port Start"}, + {DCD_CFR_TCPUDP_DSTPORT_END, "Downstream Classifier IP TCP/UDP Destination Port End"}, + {0, NULL} +}; + +static const value_string dcd_cfg_vals[] = { + {DCD_CFG_CHAN_LST, "DSG Configuration Channel"}, + {DCD_CFG_TDSG1, "DSG Initialization Timeout (Tdsg1)"}, + {DCD_CFG_TDSG2, "DSG Initialization Timeout (Tdsg2)"}, + {DCD_CFG_TDSG3, "DSG Initialization Timeout (Tdsg3)"}, + {DCD_CFG_TDSG4, "DSG Initialization Timeout (Tdsg4)"}, + {DCD_CFG_VENDOR_SPEC, "DSG Configuration Vendor Specific Parameters"}, + {0, NULL} +}; static expert_field ei_docsis_dcd_tlvlen_bad = EI_INIT; @@ -132,433 +200,451 @@ static dissector_handle_t docsis_dcd_handle; static void dissect_dcd_dsg_cfg (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcd_tree; - proto_item *dcd_item; + proto_tree *dcd_item, *tlv_len_item; int pos; pos = start; - dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, - ett_docsis_dcd_cfg, &dcd_item, "51 DCD DSG Config Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dcd_cfg, &dcd_item, + val_to_str(type, dcd_cfg_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcd_tree, hf_docsis_dcd_cfg_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcd_tree, hf_docsis_dcd_cfg_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcd_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCD_CFG_CHAN_LST: - if (length == 4) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_chan, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFG_TDSG1: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg1, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFG_TDSG2: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg2, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFG_TDSG3: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg3, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFG_TDSG4: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg4, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFG_VENDOR_SPEC: - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_vendor_spec, tvb, - pos, length, ENC_NA); - break; - - } - pos = pos + length; + case DCD_CFG_CHAN_LST: + if (length == 4) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_chan, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFG_TDSG1: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg1, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFG_TDSG2: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg2, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFG_TDSG3: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg3, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFG_TDSG4: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_tdsg4, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFG_VENDOR_SPEC: + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfg_vendor_spec, tvb, pos, length, ENC_NA); + break; + } + + pos += length; + } } static void dissect_dcd_down_classifier_ip (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcd_tree; - proto_item *dcd_item; + proto_tree *dcd_item, *tlv_len_item; int pos; pos = start; - dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_cfr_ip, &dcd_item, "23.9 DCD_CFR_IP Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dcd_cfr_ip, &dcd_item, + val_to_str(type, dcd_cfr_ip_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcd_tree, hf_docsis_dcd_cfr_ip_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcd_tree, hf_docsis_dcd_cfr_ip_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcd_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCD_CFR_IP_SOURCE_ADDR: - if (length == 4) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_addr, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_IP_SOURCE_MASK: - if (length == 4) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_mask, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_IP_DEST_ADDR: - if (length == 4) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_addr, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_IP_DEST_MASK: - if (length == 4) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_mask, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_TCPUDP_SRCPORT_START: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_start, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_TCPUDP_SRCPORT_END: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_end, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_TCPUDP_DSTPORT_START: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_start, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_TCPUDP_DSTPORT_END: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_end, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } - pos = pos + length; + case DCD_CFR_IP_SOURCE_ADDR: + if (length == 4) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_addr, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_IP_SOURCE_MASK: + if (length == 4) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_source_mask, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_IP_DEST_ADDR: + if (length == 4) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_addr, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_IP_DEST_MASK: + if (length == 4) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_ip_dest_mask, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_TCPUDP_SRCPORT_START: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_start, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_TCPUDP_SRCPORT_END: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_srcport_end, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_TCPUDP_DSTPORT_START: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_start, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_TCPUDP_DSTPORT_END: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_tcpudp_dstport_end, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; } + + pos += length; + } } static void dissect_dcd_clid (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcd_tree; - proto_item *dcd_item; + proto_tree *dcd_item, *tlv_len_item; int pos; pos = start; - dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_clid, &dcd_item, "50.4 DCD Rule ClientID Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dcd_clid, &dcd_item, + val_to_str(type, dcd_clid_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcd_tree, hf_docsis_dcd_clid_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcd_tree, hf_docsis_dcd_clid_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcd_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCD_CLID_BCAST_ID: - if (length == 2) - { - proto_tree_add_item(dcd_tree, hf_docsis_dcd_clid_bcast_id, tvb, pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CLID_KNOWN_MAC_ADDR: - if (length == 6) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_known_mac_addr, tvb, - pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CLID_CA_SYS_ID: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_ca_sys_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CLID_APP_ID: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_app_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } - pos = pos + length; + case DCD_CLID_BCAST_ID: + if (length == 2) + { + proto_tree_add_item(dcd_tree, hf_docsis_dcd_clid_bcast_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CLID_KNOWN_MAC_ADDR: + if (length == 6) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_known_mac_addr, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CLID_CA_SYS_ID: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_ca_sys_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CLID_APP_ID: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_clid_app_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; } + + pos += length; + } } static void dissect_dcd_dsg_rule (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcd_tree; - proto_item *dcd_item; + proto_tree *dcd_item, *tlv_len_item; int pos; pos = start; - dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_rule, &dcd_item, "50 DCD DSG Rule Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dcd_rule, &dcd_item, + val_to_str(type, dcd_dsg_rule_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcd_tree, hf_docsis_dcd_dsg_rule_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcd_tree, hf_docsis_dcd_dsg_rule_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcd_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCD_RULE_ID: - if (length == 1) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_RULE_PRI: - if (length == 1) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_pri, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_RULE_UCID_RNG: - proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_ucid_list, tvb, - pos, length, ENC_NA); - break; - case DCD_RULE_CLIENT_ID: - dissect_dcd_clid (tvb , pinfo , dcd_tree , pos , length ); - break; - case DCD_RULE_TUNL_ADDR: - if (length == 6) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_tunl_addr, tvb, - pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_RULE_CFR_ID: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_cfr_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_RULE_VENDOR_SPEC: - proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_vendor_spec, tvb, - pos, length, ENC_NA); - break; - - } - pos = pos + length; + case DCD_RULE_ID: + if (length == 1) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_RULE_PRI: + if (length == 1) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_pri, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_RULE_UCID_RNG: + proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_ucid_list, tvb, pos, length, ENC_NA); + break; + case DCD_RULE_CLIENT_ID: + dissect_dcd_clid (tvb, pinfo, dcd_tree, pos, length ); + break; + case DCD_RULE_TUNL_ADDR: + if (length == 6) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_tunl_addr, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_RULE_CFR_ID: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_cfr_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_RULE_VENDOR_SPEC: + proto_tree_add_item (dcd_tree, hf_docsis_dcd_rule_vendor_spec, tvb, pos, length, ENC_NA); + break; + } + + pos += length; + } } static void dissect_dcd_down_classifier (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len) { - guint8 type, length; + guint8 type; + guint32 length; proto_tree *dcd_tree; - proto_tree *dcd_item; + proto_tree *dcd_item, *tlv_len_item; int pos; pos = start; - dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_cfr, &dcd_item, "23 DCD_CFR Encodings (Length = %u)", len); - while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + dcd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_dcd_cfr, &dcd_item, + val_to_str(type, dcd_down_classifier_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (dcd_tree, hf_docsis_dcd_down_classifier_subtype, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (dcd_tree, hf_docsis_dcd_down_classifier_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(dcd_item, length + 2); + + switch (type) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - - switch (type) - { - case DCD_CFR_ID: - if (length == 2) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_id, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_RULE_PRI: - if (length == 1) - { - proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_rule_pri, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case DCD_CFR_IP_CLASSIFIER: - dissect_dcd_down_classifier_ip (tvb , pinfo , dcd_tree , pos , length ); - break; - - } - pos = pos + length; + case DCD_CFR_ID: + if (length == 2) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_id, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_RULE_PRI: + if (length == 1) + { + proto_tree_add_item (dcd_tree, hf_docsis_dcd_cfr_rule_pri, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case DCD_CFR_IP_CLASSIFIER: + dissect_dcd_down_classifier_ip (tvb , pinfo , dcd_tree , pos , length ); + break; } + + pos += length; + } } static int dissect_dcd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { guint16 pos; - guint8 type, length; - proto_tree *dcd_tree; - proto_item *dcd_item; - guint16 len; - - len = tvb_reported_length(tvb); + guint8 type; + guint32 length; + proto_tree *dcd_tree, *tlv_tree; + proto_item *dcd_item, *tlv_item; col_set_str(pinfo->cinfo, COL_INFO, "DCD Message: "); - dcd_item = - proto_tree_add_protocol_format (tree, proto_docsis_dcd, tvb, 0, - tvb_captured_length(tvb), - "DCD Message"); + dcd_item = proto_tree_add_item(tree, proto_docsis_dcd, tvb, 0, -1, ENC_NA); dcd_tree = proto_item_add_subtree (dcd_item, ett_docsis_dcd); proto_tree_add_item (dcd_tree, hf_docsis_dcd_config_ch_cnt, tvb, 0, 1, ENC_BIG_ENDIAN); proto_tree_add_item (dcd_tree, hf_docsis_dcd_num_of_frag, tvb, 1, 1, ENC_BIG_ENDIAN); proto_tree_add_item (dcd_tree, hf_docsis_dcd_frag_sequence_num, tvb, 2, 1, ENC_BIG_ENDIAN); pos = 3; - while (pos < len) + while (tvb_reported_length_remaining(tvb, pos) > 0) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - switch (type) - { - case DCD_DOWN_CLASSIFIER: - dissect_dcd_down_classifier (tvb , pinfo , dcd_tree , pos , length ); - break; - case DCD_DSG_RULE: - dissect_dcd_dsg_rule (tvb , pinfo , dcd_tree , pos , length ); - break; - case DCD_DSG_CONFIG: - dissect_dcd_dsg_cfg (tvb , pinfo , dcd_tree , pos , length ); - break; - } /* switch(type) */ - pos = pos + length; - } /* while (pos < len) */ + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(dcd_tree, tvb, pos, -1, + ett_docsis_dcd_tlv, &tlv_item, + val_to_str(type, dcd_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_dcd_type, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_dcd_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch (type) + { + case DCD_DOWN_CLASSIFIER: + dissect_dcd_down_classifier (tvb, pinfo, tlv_tree, pos, length); + break; + case DCD_DSG_RULE: + dissect_dcd_dsg_rule (tvb, pinfo, tlv_tree, pos, length); + break; + case DCD_DSG_CONFIG: + dissect_dcd_dsg_cfg (tvb, pinfo, tlv_tree, pos, length); + break; + } /* switch(type) */ + + pos += length; + } /* while (tvb_reported_length_remaining(tvb, pos) > 0) */ return tvb_captured_length(tvb); } @@ -596,6 +682,42 @@ proto_register_docsis_dcd (void) HFILL } }, + {&hf_docsis_dcd_type, + { + "Type", + "docsis_dcd.tlvtype", + FT_UINT8, BASE_DEC, VALS(dcd_tlv_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_length, + { + "Length", + "docsis_dcd.tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_down_classifier_subtype, + { + "Type", + "docsis_dcd.down_classifier_tlvtype", + FT_UINT8, BASE_DEC, VALS(dcd_down_classifier_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_down_classifier_length, + { + "Length", + "docsis_dcd.down_classifier_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dcd_cfr_id, { "Downstream Classifier Id", @@ -614,6 +736,24 @@ proto_register_docsis_dcd (void) HFILL } }, + {&hf_docsis_dcd_cfr_ip_subtype, + { + "Type", + "docsis_dcd.cfr_ip_tlvtype", + FT_UINT8, BASE_DEC, VALS(dcd_cfr_ip_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_cfr_ip_length, + { + "Length", + "docsis_dcd.cfr_ip_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dcd_cfr_ip_source_addr, { "Downstream Classifier IP Source Address", @@ -627,7 +767,7 @@ proto_register_docsis_dcd (void) { "Downstream Classifier IP Source Mask", "docsis_dcd.cfr_ip_source_mask", - FT_IPv4, BASE_NONE, NULL, 0x0, + FT_IPv4, BASE_NETMASK, NULL, 0x0, NULL, HFILL } @@ -645,7 +785,7 @@ proto_register_docsis_dcd (void) { "Downstream Classifier IP Destination Mask", "docsis_dcd.cfr_ip_dest_mask", - FT_IPv4, BASE_NONE, NULL, 0x0, + FT_IPv4, BASE_NETMASK, NULL, 0x0, "Downstream Classifier IP Destination Address", HFILL } @@ -713,6 +853,24 @@ proto_register_docsis_dcd (void) HFILL } }, + {&hf_docsis_dcd_clid_subtype, + { + "Type", + "docsis_dcd.clid_tlvtype", + FT_UINT8, BASE_DEC, VALS(dcd_clid_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_clid_length, + { + "Length", + "docsis_dcd.clid_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dcd_clid_bcast_id, { "DSG Rule Client ID Broadcast ID", @@ -749,6 +907,24 @@ proto_register_docsis_dcd (void) HFILL } }, + {&hf_docsis_dcd_dsg_rule_subtype, + { + "Type", + "docsis_dcd.rule_tlvtype", + FT_UINT8, BASE_DEC, VALS(dcd_dsg_rule_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_dsg_rule_length, + { + "Length", + "docsis_dcd.rule_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dcd_rule_tunl_addr, { "DSG Rule Tunnel MAC Address", @@ -776,6 +952,24 @@ proto_register_docsis_dcd (void) HFILL } }, + {&hf_docsis_dcd_cfg_subtype, + { + "Type", + "docsis_dcd.cfg_tlvtype", + FT_UINT8, BASE_DEC, VALS(dcd_cfg_vals), 0x0, + NULL, + HFILL + } + }, + {&hf_docsis_dcd_cfg_length, + { + "Length", + "docsis_dcd.cfg_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, + HFILL + } + }, {&hf_docsis_dcd_cfg_chan, { "DSG Configuration Channel", @@ -840,6 +1034,7 @@ proto_register_docsis_dcd (void) &ett_docsis_dcd_rule, &ett_docsis_dcd_clid, &ett_docsis_dcd_cfg, + &ett_docsis_dcd_tlv, }; static ei_register_info ei[] = { diff --git a/plugins/docsis/packet-dpd.c b/plugins/docsis/packet-dpd.c index 9743b6506d..47c509c689 100644 --- a/plugins/docsis/packet-dpd.c +++ b/plugins/docsis/packet-dpd.c @@ -57,6 +57,10 @@ static int hf_docsis_dpd_tlv_subc_assign_vector_reserved = -1; static int hf_docsis_dpd_tlv_subc_assign_vector_subc_start = -1; static int hf_docsis_dpd_tlv_subc_assign_vector_modulation_odd = -1; static int hf_docsis_dpd_tlv_subc_assign_vector_modulation_even = -1; +static int hf_docsis_dpd_tlv_data = -1; +static int hf_docsis_dpd_type = -1; +static int hf_docsis_dpd_length = -1; + static expert_field ei_docsis_dpd_tlvlen_bad = EI_INIT; @@ -66,6 +70,7 @@ static expert_field ei_docsis_dpd_value_unknown = EI_INIT; /* Initialize the subtree pointers */ static gint ett_docsis_dpd = -1; static gint ett_docsis_dpd_tlv = -1; +static gint ett_docsis_dpd_tlvtlv = -1; static gint ett_docsis_dpd_tlv_subcarrier_assignment = -1; static gint ett_docsis_dpd_tlv_subcarrier_assignment_vector = -1; @@ -142,40 +147,40 @@ static const value_string docsis_dpd_tlv_subc_assign_vector_modulation_str[] = { {0, NULL} }; +static const value_string dpd_tlv_vals[] = { + {SUBCARRIER_ASSIGNMENT_RANGE_LIST, "Subcarrier Assignment Range/List"}, + {SUBCARRIER_ASSIGNMENT_VECTOR, "Subcarrier Assignment Vector"}, + {0, NULL} +}; + /* Dissection */ static void -dissect_dpd_subcarrier_assignment_range_list(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint start, guint len) +dissect_dpd_subcarrier_assignment_range_list(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint pos, guint len) { - proto_item *it; - proto_tree *subcarrier_assignment_tree; - guint8 subcarrier_assignment_type; - guint16 subcarrier_assignment_index; - - it = proto_tree_add_protocol_format (tree, proto_docsis_dpd, tvb, start-2, len+2, ".5 Subcarrier Assignment Range/List"); - subcarrier_assignment_tree = proto_item_add_subtree (it, ett_docsis_dpd_tlv_subcarrier_assignment); - - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_dpd_tlv_subc_assign_type, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_dpd_tlv_subc_assign_value, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_dpd_tlv_subc_assign_reserved, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_dpd_tlv_subc_assign_modulation, tvb, start, 1, ENC_BIG_ENDIAN); + guint32 i, subcarrier_assignment_type; + proto_item* type_item; - - subcarrier_assignment_type = (tvb_get_guint8 (tvb, start) >> 6); + type_item = proto_tree_add_item_ret_uint (tree, hf_docsis_dpd_tlv_subc_assign_type, tvb, pos, 1, ENC_BIG_ENDIAN, &subcarrier_assignment_type); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_value, tvb, pos, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_reserved, tvb, pos, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_modulation, tvb, pos, 1, ENC_BIG_ENDIAN); + pos++; switch (subcarrier_assignment_type) { case SUBCARRIER_ASSIGNMENT_RANGE_CONT: case SUBCARRIER_ASSIGNMENT_RANGE_SKIPBY1: - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_dpd_subc_assign_range, tvb, start + 1, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_dpd_subc_assign_range, tvb, pos, 4, ENC_BIG_ENDIAN); break; case SUBCARRIER_ASSIGNMENT_LIST: - for (subcarrier_assignment_index = 0; subcarrier_assignment_index < len/2; ++subcarrier_assignment_index) { - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_dpd_subc_assign_index, tvb, start + 1 + 2*subcarrier_assignment_index, 2, ENC_BIG_ENDIAN); + for (i = 0; i < len/2; ++i) { + proto_tree_add_item (tree, hf_docsis_dpd_subc_assign_index, tvb, pos, 2, ENC_BIG_ENDIAN); + pos += 2; } break; default: - expert_add_info_format(pinfo, subcarrier_assignment_tree, &ei_docsis_dpd_value_unknown, "Unknown subcarrier assignment type: %u", subcarrier_assignment_type); + expert_add_info_format(pinfo, type_item, &ei_docsis_dpd_value_unknown, "Unknown subcarrier assignment type: %u", subcarrier_assignment_type); break; } } @@ -183,83 +188,84 @@ dissect_dpd_subcarrier_assignment_range_list(tvbuff_t * tvb, packet_info * pinfo static void dissect_dpd_subcarrier_assignment_vector(tvbuff_t * tvb, proto_tree * tree, guint start, guint len) { - proto_item *it; - proto_tree *subcarrier_assignment_vector_tree; - guint8 subcarrier_assignment_vector_oddness; + guint32 subcarrier_assignment_vector_oddness; guint vector_index; - it = proto_tree_add_protocol_format (tree, proto_docsis_dpd, tvb, start-3, len+3, ".6 Subcarrier Assignment Vector"); - subcarrier_assignment_vector_tree = proto_item_add_subtree (it, ett_docsis_dpd_tlv_subcarrier_assignment_vector); - - proto_tree_add_item (subcarrier_assignment_vector_tree, hf_docsis_dpd_tlv_subc_assign_vector_oddness, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_vector_tree, hf_docsis_dpd_tlv_subc_assign_vector_reserved, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_vector_tree, hf_docsis_dpd_tlv_subc_assign_vector_subc_start, tvb, start, 2, ENC_BIG_ENDIAN); - - - subcarrier_assignment_vector_oddness = (tvb_get_guint8(tvb, start) >> 7); + proto_tree_add_item_ret_uint (tree, hf_docsis_dpd_tlv_subc_assign_vector_oddness, tvb, start, 1, ENC_BIG_ENDIAN, &subcarrier_assignment_vector_oddness); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_vector_reserved, tvb, start, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_vector_subc_start, tvb, start, 2, ENC_BIG_ENDIAN); for(vector_index = 0; vector_index < len; ++vector_index) { - proto_tree_add_item (subcarrier_assignment_vector_tree, hf_docsis_dpd_tlv_subc_assign_vector_modulation_odd, tvb, start + 2 + vector_index, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_vector_modulation_odd, tvb, start + 2 + vector_index, 1, ENC_BIG_ENDIAN); if (!((vector_index == len -1) && subcarrier_assignment_vector_oddness)) { - proto_tree_add_item (subcarrier_assignment_vector_tree, hf_docsis_dpd_tlv_subc_assign_vector_modulation_even, tvb, start + 2 + vector_index, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_dpd_tlv_subc_assign_vector_modulation_even, tvb, start + 2 + vector_index, 1, ENC_BIG_ENDIAN); } } } static void -dissect_dpd_tlv (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint start, guint len) +dissect_dpd_tlv (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) { - proto_item *it; + proto_item *it, *tlv_item, *tlv_len_item; proto_tree *tlv_tree; - guint pos = start; + guint pos = 0; guint length; guint8 type; - it = proto_tree_add_protocol_format (tree, proto_docsis_dpd, tvb, 0, len, "TLV Data"); + it = proto_tree_add_item(tree, hf_docsis_dpd_tlv_data, tvb, 0, tvb_reported_length(tvb), ENC_NA); tlv_tree = proto_item_add_subtree (it, ett_docsis_dpd_tlv); - while (pos < (len + start)) + while (tvb_reported_length_remaining(tvb, pos) > 0) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - if(pos + length > start + len) + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(tlv_tree, tvb, pos, -1, + ett_docsis_dpd_tlvtlv, &tlv_item, + val_to_str(type, dpd_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_dpd_type, tvb, pos, 1, type); + pos++; + if (type != SUBCARRIER_ASSIGNMENT_VECTOR) { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_dpd_tlvlen_bad, "Wrong TLV length: %u", length); + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_dpd_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); } switch (type) { - case SUBCARRIER_ASSIGNMENT_RANGE_LIST: - if (length >= 5) - { - dissect_dpd_subcarrier_assignment_range_list(tvb, pinfo, tlv_tree, pos, length); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_dpd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case SUBCARRIER_ASSIGNMENT_VECTOR: - /*FOR THIS TYPE, LENGTH IS 2 BYTES INSTEAD OF 1 */ - length = tvb_get_ntohs (tvb, pos-1); - ++pos; - if (length >=2) - { - dissect_dpd_subcarrier_assignment_vector(tvb, tlv_tree, pos, length); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_dpd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - default: proto_tree_add_item (tlv_tree, hf_docsis_dpd_tlv_unknown, tvb, pos - 2, length+2, ENC_NA); - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_dpd_value_unknown, "Unknown TLV: %u", type); - break; + case SUBCARRIER_ASSIGNMENT_RANGE_LIST: + if (length >= 5) + { + dissect_dpd_subcarrier_assignment_range_list(tvb, pinfo, tlv_tree, pos, length); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dpd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case SUBCARRIER_ASSIGNMENT_VECTOR: + /*FOR THIS TYPE, LENGTH IS 2 BYTES INSTEAD OF 1 */ + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_dpd_length, tvb, pos, 2, ENC_BIG_ENDIAN, &length); + pos += 2; + proto_item_set_len(tlv_item, length + 2); + if (length >=2) + { + dissect_dpd_subcarrier_assignment_vector(tvb, tlv_tree, pos, length); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_dpd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + default: + proto_tree_add_item (tlv_tree, hf_docsis_dpd_tlv_unknown, tvb, pos - 2, length+2, ENC_NA); + expert_add_info_format(pinfo, tlv_item, &ei_docsis_dpd_value_unknown, "Unknown TLV: %u", type); + break; } /* switch */ - pos = pos + length; + pos += length; } /* while */ } @@ -267,29 +273,22 @@ static int dissect_dpd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dpd_tree = NULL; + proto_tree *dpd_tree; + tvbuff_t *next_tvb; - guint8 downstream_channel_id; - guint8 profile_identifier; - guint8 configuration_change_count; - guint len; - downstream_channel_id = tvb_get_guint8 (tvb, 0); - profile_identifier = tvb_get_guint8 (tvb, 1); - configuration_change_count = tvb_get_guint8 (tvb, 2); - len = tvb_captured_length_remaining (tvb, 3); + guint32 downstream_channel_id, profile_identifier, configuration_change_count; + + it = proto_tree_add_item(tree, proto_docsis_dpd, tvb, 0, -1, ENC_NA); + dpd_tree = proto_item_add_subtree (it, ett_docsis_dpd); + proto_tree_add_item_ret_uint (dpd_tree, hf_docsis_dpd_dschid, tvb, 0, 1, ENC_BIG_ENDIAN, &downstream_channel_id); + proto_tree_add_item_ret_uint (dpd_tree, hf_docsis_dpd_prof_id, tvb, 1, 1, ENC_BIG_ENDIAN, &profile_identifier); + proto_tree_add_item_ret_uint (dpd_tree, hf_docsis_dpd_ccc, tvb, 2, 1, ENC_BIG_ENDIAN, &configuration_change_count); col_add_fstr (pinfo->cinfo, COL_INFO, "DPD: DS CH ID: %u, Profile ID: %u, CCC: %u", downstream_channel_id, profile_identifier, configuration_change_count); - if (tree) - { - it = proto_tree_add_protocol_format (tree, proto_docsis_dpd, tvb, 0, -1, "Downstream Profile Descriptor"); - dpd_tree = proto_item_add_subtree (it, ett_docsis_dpd); - proto_tree_add_item (dpd_tree, hf_docsis_dpd_dschid, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpd_tree, hf_docsis_dpd_prof_id, tvb, 1, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpd_tree, hf_docsis_dpd_ccc, tvb, 2, 1, ENC_BIG_ENDIAN); - } /* Call Dissector TLV's */ - dissect_dpd_tlv(tvb, pinfo, dpd_tree, 3, len); + next_tvb = tvb_new_subset_remaining(tvb, 3); + dissect_dpd_tlv(next_tvb, pinfo, dpd_tree); return tvb_captured_length(tvb); } @@ -346,6 +345,15 @@ proto_register_docsis_dpd(void) {&hf_docsis_dpd_tlv_subc_assign_vector_modulation_even, {"Modulation", "docsis_dpd.tlv.subc_assign_vect.modulation", FT_UINT8, BASE_DEC, VALS(docsis_dpd_tlv_subc_assign_vector_modulation_str), 0x0F, NULL, HFILL} }, + {&hf_docsis_dpd_tlv_data, + {"TLV Data", "docsis_dpd.tlv_data", FT_BYTES, BASE_NO_DISPLAY_VALUE, NULL, 0x0, NULL, HFILL} + }, + {&hf_docsis_dpd_type, + {"Type", "docsis_dpd.type",FT_UINT8, BASE_DEC, VALS(dpd_tlv_vals), 0x0, NULL, HFILL} + }, + {&hf_docsis_dpd_length, + {"Length", "docsis_dpd.length",FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} + }, }; static ei_register_info ei[] = { @@ -356,6 +364,7 @@ proto_register_docsis_dpd(void) static gint *ett[] = { &ett_docsis_dpd, &ett_docsis_dpd_tlv, + &ett_docsis_dpd_tlvtlv, &ett_docsis_dpd_tlv_subcarrier_assignment, &ett_docsis_dpd_tlv_subcarrier_assignment_vector }; diff --git a/plugins/docsis/packet-dpvreq.c b/plugins/docsis/packet-dpvreq.c index 33b133fc38..05db59ab30 100644 --- a/plugins/docsis/packet-dpvreq.c +++ b/plugins/docsis/packet-dpvreq.c @@ -50,43 +50,27 @@ static int dissect_dpvreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dpvreq_tree = NULL; - guint16 transid; - guint8 dschan; + proto_tree *dpvreq_tree; + guint32 transid, dschan; - transid = tvb_get_ntohs (tvb, 0); - dschan = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item(tree, proto_docsis_dpvreq, tvb, 0, -1, ENC_NA); + dpvreq_tree = proto_item_add_subtree (it, ett_docsis_dpvreq); + proto_tree_add_item_ret_uint (dpvreq_tree, hf_docsis_dpvreq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint (dpvreq_tree, hf_docsis_dpvreq_dschan, tvb, 2, 1, ENC_BIG_ENDIAN, &dschan); col_add_fstr (pinfo->cinfo, COL_INFO, "DOCSIS Path Verify Request: Transaction-Id = %u DS-Ch %d", transid, dschan); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dpvreq, tvb, 0, -1, - "DPV Request"); - dpvreq_tree = proto_item_add_subtree (it, ett_docsis_dpvreq); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_tranid, tvb, - 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_dschan, tvb, - 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_flags, tvb, - 3, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_us_sf, tvb, - 4, 4, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_n, tvb, - 8, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_start, tvb, - 10, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_end, tvb, - 11, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_start, tvb, - 12, 4, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_end, tvb, - 16, 4, ENC_BIG_ENDIAN); - } - return tvb_captured_length(tvb); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_flags, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_us_sf, tvb, 4, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_n, tvb, 8, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_start, tvb, 10, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_end, tvb, 11, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_start, tvb, 12, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_end, tvb, 16, 4, ENC_BIG_ENDIAN); + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dpvrsp.c b/plugins/docsis/packet-dpvrsp.c index 23e1d95f98..c7ffb990c1 100644 --- a/plugins/docsis/packet-dpvrsp.c +++ b/plugins/docsis/packet-dpvrsp.c @@ -51,42 +51,26 @@ dissect_dpvrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da { proto_item *it; proto_tree *dpvrsp_tree = NULL; - guint16 transid; - guint8 dschan; + guint32 transid, dschan; - transid = tvb_get_ntohs (tvb, 0); - dschan = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item (tree, proto_docsis_dpvrsp, tvb, 0, -1, ENC_NA); + dpvrsp_tree = proto_item_add_subtree (it, ett_docsis_dpvrsp); + proto_tree_add_item_ret_uint (dpvrsp_tree, hf_docsis_dpvrsp_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint (dpvrsp_tree, hf_docsis_dpvrsp_dschan, tvb, 2, 1, ENC_BIG_ENDIAN, &dschan); col_add_fstr (pinfo->cinfo, COL_INFO, "DOCSIS Path Verify Response: Transaction-Id = %u DS-Ch %d", transid, dschan); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dpvrsp, tvb, 0, -1, - "DPV Response"); - dpvrsp_tree = proto_item_add_subtree (it, ett_docsis_dpvrsp); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_tranid, tvb, - 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_dschan, tvb, - 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_flags, tvb, - 3, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_us_sf, tvb, - 4, 4, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_n, tvb, - 8, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_start, tvb, - 10, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_end, tvb, - 11, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_start, tvb, - 12, 4, ENC_BIG_ENDIAN); - proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_end, tvb, - 16, 4, ENC_BIG_ENDIAN); - } - return tvb_captured_length(tvb); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_flags, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_us_sf, tvb, 4, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_n, tvb, 8, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_start, tvb, 10, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_end, tvb, 11, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_start, tvb, 12, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_end, tvb, 16, 4, ENC_BIG_ENDIAN); + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dsaack.c b/plugins/docsis/packet-dsaack.c index e684d7f23d..fbbe629a3b 100644 --- a/plugins/docsis/packet-dsaack.c +++ b/plugins/docsis/packet-dsaack.c @@ -46,30 +46,19 @@ static int dissect_dsaack (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dsaack_tree = NULL; - guint16 transid; - guint8 response; + proto_tree *dsaack_tree; + guint32 transid, response; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); - response = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item (tree, proto_docsis_dsaack, tvb, 0, -1, ENC_NA); + dsaack_tree = proto_item_add_subtree (it, ett_docsis_dsaack); + proto_tree_add_item_ret_uint (dsaack_tree, hf_docsis_dsaack_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint (dsaack_tree, hf_docsis_dsaack_response, tvb, 2, 1, ENC_BIG_ENDIAN, &response); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Add Ack ID = %u (%s)", transid, val_to_str (response, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dsaack, tvb, 0, -1, - "DSA Acknowledge"); - dsaack_tree = proto_item_add_subtree (it, ett_docsis_dsaack); - proto_tree_add_item (dsaack_tree, hf_docsis_dsaack_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dsaack_tree, hf_docsis_dsaack_response, tvb, 2, 1, - ENC_BIG_ENDIAN); - } - /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 3); call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsaack_tree); diff --git a/plugins/docsis/packet-dsareq.c b/plugins/docsis/packet-dsareq.c index 0a74cbccae..3375c5f680 100644 --- a/plugins/docsis/packet-dsareq.c +++ b/plugins/docsis/packet-dsareq.c @@ -43,29 +43,22 @@ static int dissect_dsareq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dsareq_tree = NULL; - guint16 transid; + proto_tree *dsareq_tree; + guint32 transid; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); + it = proto_tree_add_item(tree, proto_docsis_dsareq, tvb, 0, -1, ENC_NA); + dsareq_tree = proto_item_add_subtree (it, ett_docsis_dsareq); + + proto_tree_add_item_ret_uint (dsareq_tree, hf_docsis_dsareq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Addition Request Tran-id = %u", transid); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dsareq, tvb, 0, -1, - "DSA Request"); - dsareq_tree = proto_item_add_subtree (it, ett_docsis_dsareq); - proto_tree_add_item (dsareq_tree, hf_docsis_dsareq_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - - } - /* Call Dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 2); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsareq_tree); - return tvb_captured_length(tvb); + /* Call Dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 2); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsareq_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dsarsp.c b/plugins/docsis/packet-dsarsp.c index eb31168b15..5d85ed326e 100644 --- a/plugins/docsis/packet-dsarsp.c +++ b/plugins/docsis/packet-dsarsp.c @@ -46,34 +46,23 @@ static int dissect_dsarsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dsarsp_tree = NULL; - guint16 transid; - guint8 response; + proto_tree *dsarsp_tree; + guint32 transid, response; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); - response = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item (tree, proto_docsis_dsarsp, tvb, 0, -1, ENC_NA); + dsarsp_tree = proto_item_add_subtree (it, ett_docsis_dsarsp); + proto_tree_add_item_ret_uint (dsarsp_tree, hf_docsis_dsarsp_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint (dsarsp_tree, hf_docsis_dsarsp_response, tvb, 2, 1, ENC_BIG_ENDIAN, &response); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Add Response ID = %u (%s)", transid, val_to_str (response, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dsarsp, tvb, 0, -1, - "DSA Response"); - dsarsp_tree = proto_item_add_subtree (it, ett_docsis_dsarsp); - proto_tree_add_item (dsarsp_tree, hf_docsis_dsarsp_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dsarsp_tree, hf_docsis_dsarsp_response, tvb, 2, 1, - ENC_BIG_ENDIAN); - } - - /* Call dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 3); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsarsp_tree); - return tvb_captured_length(tvb); + /* Call dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 3); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsarsp_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dscack.c b/plugins/docsis/packet-dscack.c index 48a9f6dc0e..09803feaf4 100644 --- a/plugins/docsis/packet-dscack.c +++ b/plugins/docsis/packet-dscack.c @@ -46,33 +46,24 @@ static int dissect_dscack (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dscack_tree = NULL; - guint16 transid; - guint8 response; + proto_tree *dscack_tree; + guint32 transid, response; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); - response = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item(tree, proto_docsis_dscack, tvb, 0, -1, ENC_NA); + dscack_tree = proto_item_add_subtree (it, ett_docsis_dscack); + + proto_tree_add_item_ret_uint (dscack_tree, hf_docsis_dscack_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint (dscack_tree, hf_docsis_dscack_response, tvb, 2, 1, ENC_BIG_ENDIAN, &response); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Change Ack ID = %u (%s)", transid, val_to_str (response, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dscack, tvb, 0, -1, - "DSC Acknowledge"); - dscack_tree = proto_item_add_subtree (it, ett_docsis_dscack); - proto_tree_add_item (dscack_tree, hf_docsis_dscack_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dscack_tree, hf_docsis_dscack_response, tvb, 2, 1, - ENC_BIG_ENDIAN); - } - /* Call Dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 3); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscack_tree); - return tvb_captured_length(tvb); + /* Call Dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 3); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscack_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dscreq.c b/plugins/docsis/packet-dscreq.c index d94e23183c..c8f3478066 100644 --- a/plugins/docsis/packet-dscreq.c +++ b/plugins/docsis/packet-dscreq.c @@ -43,29 +43,22 @@ static int dissect_dscreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dscreq_tree = NULL; - guint16 transid; + proto_tree *dscreq_tree; + guint32 transid; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); + it = proto_tree_add_item (tree, proto_docsis_dscreq, tvb, 0, -1, ENC_NA); + dscreq_tree = proto_item_add_subtree (it, ett_docsis_dscreq); + + proto_tree_add_item_ret_uint (dscreq_tree, hf_docsis_dscreq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Change Request Tran-id = %u", transid); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dscreq, tvb, 0, -1, - "DSC Request"); - dscreq_tree = proto_item_add_subtree (it, ett_docsis_dscreq); - proto_tree_add_item (dscreq_tree, hf_docsis_dscreq_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - - } - /* Call dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 2); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscreq_tree); - return tvb_captured_length(tvb); + /* Call dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 2); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscreq_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dscrsp.c b/plugins/docsis/packet-dscrsp.c index 684d98e69d..dba96622b5 100644 --- a/plugins/docsis/packet-dscrsp.c +++ b/plugins/docsis/packet-dscrsp.c @@ -46,34 +46,23 @@ static int dissect_dscrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dscrsp_tree = NULL; - guint16 transid; - guint8 response; + proto_tree *dscrsp_tree; + guint32 transid, response; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); - response = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item(tree, proto_docsis_dscrsp, tvb, 0, -1, ENC_NA); + dscrsp_tree = proto_item_add_subtree (it, ett_docsis_dscrsp); + proto_tree_add_item_ret_uint (dscrsp_tree, hf_docsis_dscrsp_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); + proto_tree_add_item_ret_uint (dscrsp_tree, hf_docsis_dscrsp_response, tvb, 2, 1, ENC_BIG_ENDIAN, &response); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Change Response ID = %u (%s)", transid, val_to_str (response, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dscrsp, tvb, 0, -1, - "DSC Response"); - dscrsp_tree = proto_item_add_subtree (it, ett_docsis_dscrsp); - proto_tree_add_item (dscrsp_tree, hf_docsis_dscrsp_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dscrsp_tree, hf_docsis_dscrsp_response, tvb, 2, 1, - ENC_BIG_ENDIAN); - - } - /* Call Dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 3); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscrsp_tree); - return tvb_captured_length(tvb); + /* Call Dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 3); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscrsp_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dsdreq.c b/plugins/docsis/packet-dsdreq.c index 98bc2ec136..3c4271c311 100644 --- a/plugins/docsis/packet-dsdreq.c +++ b/plugins/docsis/packet-dsdreq.c @@ -46,32 +46,25 @@ static int dissect_dsdreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *dsdreq_tree = NULL; - guint16 transid; + proto_tree *dsdreq_tree; + guint32 transid; tvbuff_t *next_tvb; - transid = tvb_get_ntohs (tvb, 0); + it = proto_tree_add_item (tree, proto_docsis_dsdreq, tvb, 0, -1, ENC_NA); + dsdreq_tree = proto_item_add_subtree (it, ett_docsis_dsdreq); + + proto_tree_add_item_ret_uint (dsdreq_tree, hf_docsis_dsdreq_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &transid); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Delete Request Tran-id = %u", transid); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dsdreq, tvb, 0, -1, - "DSD Request"); - dsdreq_tree = proto_item_add_subtree (it, ett_docsis_dsdreq); - proto_tree_add_item (dsdreq_tree, hf_docsis_dsdreq_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dsdreq_tree, hf_docsis_dsdreq_rsvd, tvb, 2, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dsdreq_tree, hf_docsis_dsdreq_sfid, tvb, 4, 4, - ENC_BIG_ENDIAN); - } - - /* Call Dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 8); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsdreq_tree); - return tvb_captured_length(tvb); + + proto_tree_add_item (dsdreq_tree, hf_docsis_dsdreq_rsvd, tvb, 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (dsdreq_tree, hf_docsis_dsdreq_sfid, tvb, 4, 4, ENC_BIG_ENDIAN); + + /* Call Dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 8); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, dsdreq_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-dsdrsp.c b/plugins/docsis/packet-dsdrsp.c index e405e5aff9..d9cd0f42ec 100644 --- a/plugins/docsis/packet-dsdrsp.c +++ b/plugins/docsis/packet-dsdrsp.c @@ -47,31 +47,19 @@ dissect_dsdrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da { proto_item *it; proto_tree *dsdrsp_tree; - guint16 tranid; - guint8 confcode; + guint32 tranid, confcode; - tranid = tvb_get_ntohs (tvb, 0); - confcode = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item(tree, proto_docsis_dsdrsp, tvb, 0, -1, ENC_NA); + dsdrsp_tree = proto_item_add_subtree (it, ett_docsis_dsdrsp); + proto_tree_add_item_ret_uint (dsdrsp_tree, hf_docsis_dsdrsp_tranid, tvb, 0, 2, ENC_BIG_ENDIAN, &tranid); + proto_tree_add_item_ret_uint (dsdrsp_tree, hf_docsis_dsdrsp_confcode, tvb, 2, 1, ENC_BIG_ENDIAN, &confcode); + proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_rsvd, tvb, 3, 1, ENC_BIG_ENDIAN); col_add_fstr (pinfo->cinfo, COL_INFO, "Dynamic Service Delete Response Tran id = %u (%s)", tranid, val_to_str (confcode, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_dsdrsp, tvb, 0, -1, - "DSD Response"); - dsdrsp_tree = proto_item_add_subtree (it, ett_docsis_dsdrsp); - proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_tranid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_confcode, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_rsvd, tvb, 3, 1, - ENC_BIG_ENDIAN); - } - - return tvb_captured_length(tvb); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-intrngreq.c b/plugins/docsis/packet-intrngreq.c index b40593c084..0ad493ec1e 100644 --- a/plugins/docsis/packet-intrngreq.c +++ b/plugins/docsis/packet-intrngreq.c @@ -45,27 +45,18 @@ dissect_intrngreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* { proto_item *intrngreq_item; proto_tree *intrngreq_tree; - guint16 sid; + guint32 sid; - sid = tvb_get_ntohs (tvb, 0); + intrngreq_item = proto_tree_add_item(tree, proto_docsis_intrngreq, tvb, 0, -1, ENC_NA); + intrngreq_tree = proto_item_add_subtree (intrngreq_item, ett_docsis_intrngreq); + proto_tree_add_item_ret_uint (intrngreq_tree, hf_docsis_intrngreq_sid, tvb, 0, 2, ENC_BIG_ENDIAN, &sid); col_add_fstr (pinfo->cinfo, COL_INFO, "Initial Ranging Request: SID = %u",sid); - if (tree) - { - intrngreq_item = - proto_tree_add_protocol_format (tree, proto_docsis_intrngreq, tvb, 0, - tvb_captured_length(tvb), - "Initial Ranging Request"); - intrngreq_tree = proto_item_add_subtree (intrngreq_item, ett_docsis_intrngreq); - proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_sid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_down_chid, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_up_chid, tvb, 3, - 1, ENC_BIG_ENDIAN); - } - return tvb_captured_length(tvb); + proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_down_chid, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_up_chid, tvb, 3, 1, ENC_BIG_ENDIAN); + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-macmgmt.c b/plugins/docsis/packet-macmgmt.c index f2041037f6..35c4e264a7 100644 --- a/plugins/docsis/packet-macmgmt.c +++ b/plugins/docsis/packet-macmgmt.c @@ -156,11 +156,10 @@ static const value_string mgmt_type_vals[] = { static int dissect_macmgmt (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { - guint16 msg_len; + guint32 type, msg_len; proto_item *mgt_hdr_it; proto_tree *mgt_hdr_tree; tvbuff_t *payload_tvb; - guint8 type; col_set_str (pinfo->cinfo, COL_PROTOCOL, "DOCSIS MGMT"); @@ -171,35 +170,20 @@ dissect_macmgmt (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* d set_address_tvb (&pinfo->dl_dst, AT_ETHER, 6, tvb, 0); copy_address_shallow(&pinfo->dst, &pinfo->dl_dst); - if (tree) - { - mgt_hdr_it = - proto_tree_add_protocol_format (tree, proto_docsis_mgmt, tvb, 0, 20, - "Mac Management"); - mgt_hdr_tree = proto_item_add_subtree (mgt_hdr_it, ett_docsis_mgmt); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dst_addr, tvb, 0, 6, - ENC_NA); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_src_addr, tvb, 6, 6, - ENC_NA); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_msg_len, tvb, 12, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dsap, tvb, 14, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_ssap, tvb, 15, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_control, tvb, 16, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_version, tvb, 17, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_type, tvb, 18, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_rsvd, tvb, 19, 1, - ENC_BIG_ENDIAN); - } + mgt_hdr_it = proto_tree_add_protocol_format (tree, proto_docsis_mgmt, tvb, 0, 20, "Mac Management"); + mgt_hdr_tree = proto_item_add_subtree (mgt_hdr_it, ett_docsis_mgmt); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dst_addr, tvb, 0, 6, ENC_NA); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_src_addr, tvb, 6, 6, ENC_NA); + proto_tree_add_item_ret_uint (mgt_hdr_tree, hf_docsis_mgt_msg_len, tvb, 12, 2, ENC_BIG_ENDIAN, &msg_len); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dsap, tvb, 14, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_ssap, tvb, 15, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_control, tvb, 16, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_version, tvb, 17, 1, ENC_BIG_ENDIAN); + proto_tree_add_item_ret_uint (mgt_hdr_tree, hf_docsis_mgt_type, tvb, 18, 1, ENC_BIG_ENDIAN, &type); + proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_rsvd, tvb, 19, 1, ENC_BIG_ENDIAN); + /* Code to Call subdissector */ /* sub-dissectors are based on the type field */ - type = tvb_get_guint8 (tvb, 18); - msg_len = tvb_get_ntohs (tvb, 12); payload_tvb = tvb_new_subset_length (tvb, 20, msg_len - 6); if (!dissector_try_uint(docsis_mgmt_dissector_table, type, payload_tvb, pinfo, tree)) diff --git a/plugins/docsis/packet-map.c b/plugins/docsis/packet-map.c index e2beee53f0..8d13e1e50f 100644 --- a/plugins/docsis/packet-map.c +++ b/plugins/docsis/packet-map.c @@ -62,6 +62,7 @@ static int hf_docsis_map_offset = -1; /* Initialize the subtree pointers */ static gint ett_docsis_map = -1; +static gint ett_docsis_map_ie = -1; static dissector_handle_t docsis_map_handle; @@ -88,20 +89,23 @@ static const value_string iuc_vals[] = { static int dissect_map (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { - guint8 i, numie; + guint32 i, numie, upchid, ucd_count; int pos; - guint16 sid; - guint8 iuc; - guint16 offset; - guint32 ie, temp, mask; - proto_item *it, *item; + proto_item *it; proto_tree *map_tree; - guint8 upchid, ucd_count; + static const int * ies[] = { + &hf_docsis_map_sid, + &hf_docsis_map_iuc, + &hf_docsis_map_offset, + NULL + }; + it = proto_tree_add_item(tree, proto_docsis_map, tvb, 0, -1, ENC_NA); + map_tree = proto_item_add_subtree (it, ett_docsis_map); - numie = tvb_get_guint8 (tvb, 2); - upchid = tvb_get_guint8 (tvb, 0); - ucd_count = tvb_get_guint8 (tvb, 1); + proto_tree_add_item_ret_uint (map_tree, hf_docsis_map_upstream_chid, tvb, 0, 1, ENC_BIG_ENDIAN, &upchid); + proto_tree_add_item_ret_uint (map_tree, hf_docsis_map_ucd_count, tvb, 1, 1, ENC_BIG_ENDIAN, &ucd_count); + proto_tree_add_item_ret_uint (map_tree, hf_docsis_map_numie, tvb, 2, 1, ENC_BIG_ENDIAN, &numie); if (upchid > 0) col_add_fstr (pinfo->cinfo, COL_INFO, @@ -112,66 +116,22 @@ dissect_map (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data "Map Message: Channel ID = %u (Telephony Return), UCD Count = %u, # IE's = %u", upchid, ucd_count, numie); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_map, tvb, 0, -1, - "MAP Message"); - map_tree = proto_item_add_subtree (it, ett_docsis_map); - - proto_tree_add_item (map_tree, hf_docsis_map_upstream_chid, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_ucd_count, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_numie, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_rsvd, tvb, 3, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_alloc_start, tvb, 4, 4, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_ack_time, tvb, 8, 4, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_rng_start, tvb, 12, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_rng_end, tvb, 13, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_data_start, tvb, 14, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (map_tree, hf_docsis_map_data_end, tvb, 15, 1, - ENC_BIG_ENDIAN); - - pos = 16; - for (i = 0; i < numie; i++) - { - ie = tvb_get_ntohl (tvb, pos); - mask = 0xFFFC0000; - temp = (ie & mask); - temp = temp >> 18; - sid = (guint16) (temp & 0x3FFF); - mask = 0x3C000; - temp = (ie & mask); - temp = temp >> 14; - iuc = (guint8) (temp & 0x0F); - mask = 0x3FFF; - offset = (guint16) (ie & mask); - item = proto_tree_add_item(map_tree, hf_docsis_map_sid, tvb, pos, 4, ENC_BIG_ENDIAN); - PROTO_ITEM_SET_HIDDEN(item); - item = proto_tree_add_item(map_tree, hf_docsis_map_iuc, tvb, pos, 4, ENC_BIG_ENDIAN); - PROTO_ITEM_SET_HIDDEN(item); - item = proto_tree_add_item(map_tree, hf_docsis_map_offset, tvb, pos, 4, ENC_BIG_ENDIAN); - PROTO_ITEM_SET_HIDDEN(item); - if (sid == 0x3FFF) - proto_tree_add_uint_format (map_tree, hf_docsis_map_ie, tvb, pos, 4, - ie, "SID = 0x%x (All CM's), IUC = %s, Offset = %u", - sid, val_to_str (iuc, iuc_vals, "%d"), - offset); - else - proto_tree_add_uint_format (map_tree, hf_docsis_map_ie, tvb, pos, 4, - ie, "SID = %u, IUC = %s, Offset = %u", - sid, val_to_str (iuc, iuc_vals, "%d"), - offset); - pos = pos + 4; - } /* for... */ - } /* if(tree) */ - return tvb_captured_length(tvb); + proto_tree_add_item (map_tree, hf_docsis_map_rsvd, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (map_tree, hf_docsis_map_alloc_start, tvb, 4, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (map_tree, hf_docsis_map_ack_time, tvb, 8, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (map_tree, hf_docsis_map_rng_start, tvb, 12, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (map_tree, hf_docsis_map_rng_end, tvb, 13, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (map_tree, hf_docsis_map_data_start, tvb, 14, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (map_tree, hf_docsis_map_data_end, tvb, 15, 1, ENC_BIG_ENDIAN); + + pos = 16; + for (i = 0; i < numie; i++) + { + proto_tree_add_bitmask_with_flags(map_tree, tvb, pos, hf_docsis_map_ie, ett_docsis_map_ie, ies, ENC_BIG_ENDIAN, BMT_NO_FLAGS); + pos = pos + 4; + } + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ @@ -230,7 +190,7 @@ proto_register_docsis_map (void) NULL, HFILL} }, {&hf_docsis_map_rsvd, - {"Reserved [0x00]", "docsis_map.rsvd", + {"Reserved", "docsis_map.rsvd", FT_UINT8, BASE_HEX, NULL, 0x0, "Reserved Byte", HFILL} }, @@ -254,11 +214,11 @@ proto_register_docsis_map (void) static gint *ett[] = { &ett_docsis_map, + &ett_docsis_map_ie, }; proto_docsis_map = - proto_register_protocol ("DOCSIS Upstream Bandwidth Allocation", - "DOCSIS MAP", "docsis_map"); + proto_register_protocol ("DOCSIS Upstream Bandwidth Allocation", "DOCSIS MAP", "docsis_map"); proto_register_field_array (proto_docsis_map, hf, array_length (hf)); proto_register_subtree_array (ett, array_length (ett)); diff --git a/plugins/docsis/packet-mdd.c b/plugins/docsis/packet-mdd.c index 755e0f0623..5573f9da04 100644 --- a/plugins/docsis/packet-mdd.c +++ b/plugins/docsis/packet-mdd.c @@ -284,6 +284,54 @@ static const value_string upstream_transmit_power_reporting_vals[] = { {0, NULL} }; +static const value_string mdd_ds_active_channel_list_vals[] = { + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_CHANNEL_ID, "Channel ID"}, + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_FREQUENCY, "Frequency"}, + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_MODULATION_ORDER_ANNEX, "Annex/Modulation Order"}, + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_PRIMARY_CAPABLE, "Primary Capable"}, + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK, "CM-STATUS Event Enable Bitmask"}, + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_MAP_UCD_TRANSPORT_INDICATOR, "MAP and UCD transport indicator"}, + {DOWNSTREAM_ACTIVE_CHANNEL_LIST_OFDM_PLC_PARAMETERS, "OFDM PLC Parameters"}, + {0, NULL} +}; + +static const value_string mdd_ds_service_group_vals[] = { + {MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_MD_DS_SG_IDENTIFIER, "MD-DS-SG Identifier"}, + {MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_CHANNEL_IDS, "Channel Ids"}, + {0, NULL} +}; + +static const value_string mdd_channel_profile_reporting_control_vals[] = { + {RCP_CENTER_FREQUENCY_SPACING, "RPC Center Frequency Spacing"}, + {VERBOSE_RCP_REPORTING, "Verbose RCP reporting"}, + {0, NULL} +}; + +static const value_string mdd_ip_init_param_vals[] = { + {IP_PROVISIONING_MODE, "IP Provisioning Mode"}, + {PRE_REGISTRATION_DSID, "Pre-registration DSID"}, + {0, NULL} +}; + +static const value_string mdd_up_active_channel_list_vals[] = { + {UPSTREAM_ACTIVE_CHANNEL_LIST_UPSTREAM_CHANNEL_ID, "Upstream Channel Id"}, + {UPSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK, "CM-STATUS Event Enable Bitmask"}, + {0, NULL} +}; + +static const value_string mdd_cm_status_event_control_vals[] = { + {EVENT_TYPE_CODE, "Event Type"}, + {MAXIMUM_EVENT_HOLDOFF_TIMER, "Maximum Event Holdoff Timer"}, + {MAXIMUM_NUMBER_OF_REPORTS_PER_EVENT, "Maximum Number of Reports per Event"}, + {0, NULL} +}; + +static const value_string mdd_cm_dsg_da_to_dsid_vals[] = { + {DSG_DA_TO_DSID_ASSOCIATION_DA, "Destination Address"}, + {DSG_DA_TO_DSID_ASSOCIATION_DSID, "DSID"}, + {0, NULL} +}; + static const value_string unique_unlimited[] = { { 0, "Unlimited" }, {0, NULL} @@ -300,6 +348,8 @@ static int hf_docsis_mdd_number_of_fragments = -1; static int hf_docsis_mdd_fragment_sequence_number = -1; static int hf_docsis_mdd_current_channel_dcid = -1; +static int hf_docsis_mdd_ds_active_channel_list_subtype = -1; +static int hf_docsis_mdd_ds_active_channel_list_length = -1; static int hf_docsis_mdd_downstream_active_channel_list_channel_id = -1; static int hf_docsis_mdd_downstream_active_channel_list_frequency = -1; static int hf_docsis_mdd_downstream_active_channel_list_annex = -1; @@ -307,25 +357,37 @@ static int hf_docsis_mdd_downstream_active_channel_list_modulation_order = -1; static int hf_docsis_mdd_downstream_active_channel_list_primary_capable = -1; static int hf_docsis_mdd_downstream_active_channel_list_map_ucd_transport_indicator = -1; +static int hf_docsis_mdd_cm_status_event_enable_bitmask = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_failure = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_recovery = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_recovery = -1; +static int hf_docsis_mdd_ofdm_plc_parameters = -1; static int hf_docsis_mdd_ofdm_plc_parameters_tukey_raised_cosine_window = -1; static int hf_docsis_mdd_ofdm_plc_parameters_cyclic_prefix = -1; static int hf_docsis_mdd_ofdm_plc_parameters_sub_carrier_spacing = -1; +static int hf_docsis_mdd_up_active_channel_list_subtype = -1; +static int hf_docsis_mdd_up_active_channel_list_length = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_t3_retries_exceeded = -1; static int hf_docsis_mdd_cm_status_event_enable_bitmask_successful_ranging_after_t3_retries_exceeded = -1; +static int hf_docsis_mdd_ds_service_group_subtype = -1; +static int hf_docsis_mdd_ds_service_group_length = -1; static int hf_docsis_mdd_mac_domain_downstream_service_group_md_ds_sg_identifier = -1; static int hf_docsis_mdd_mac_domain_downstream_service_group_channel_id = -1; +static int hf_docsis_mdd_type = -1; +static int hf_docsis_mdd_length = -1; static int hf_docsis_mdd_downstream_ambiguity_resolution_frequency = -1; +static int hf_docsis_mdd_channel_profile_reporting_control_subtype = -1; +static int hf_docsis_mdd_channel_profile_reporting_control_length = -1; static int hf_docsis_mdd_rpc_center_frequency_spacing = -1; static int hf_docsis_mdd_verbose_rcp_reporting = -1; +static int hf_docsis_mdd_ip_init_param_subtype = -1; +static int hf_docsis_mdd_ip_init_param_length = -1; static int hf_docsis_mdd_ip_provisioning_mode = -1; static int hf_docsis_mdd_pre_registration_dsid = -1; @@ -339,6 +401,8 @@ static int hf_docsis_mdd_upstream_frequency_range = -1; static int hf_docsis_mdd_symbol_clock_locking_indicator = -1; +static int hf_docsis_mdd_cm_status_event_control_subtype = -1; +static int hf_docsis_mdd_cm_status_event_control_length = -1; static int hf_docsis_mdd_event_type = -1; static int hf_docsis_mdd_maximum_event_holdoff_timer = -1; @@ -346,9 +410,12 @@ static int hf_docsis_mdd_maximum_event_holdoff_timer = -1; static int hf_docsis_mdd_maximum_number_of_reports_per_event = -1; static int hf_docsis_mdd_upstream_transmit_power_reporting = -1; +static int hf_docsis_mdd_dsg_da_to_dsid_subtype = -1; +static int hf_docsis_mdd_dsg_da_to_dsid_length = -1; static int hf_docsis_mdd_dsg_da_to_dsid_association_da = -1; static int hf_docsis_mdd_dsg_da_to_dsid_association_dsid = -1; +static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events = -1; static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_sequence_out_of_range = -1; static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_operating_on_battery_backup = -1; static int hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_returned_to_ac_power = -1; @@ -359,10 +426,321 @@ static int hf_docsis_mdd_extended_upstream_transmit_power_support = -1; static gint ett_docsis_mdd = -1; static gint ett_tlv = -1; static gint ett_sub_tlv = -1; +static gint ett_docsis_mdd_ds_active_channel_list = -1; +static gint ett_docsis_mdd_ds_service_group = -1; +static gint ett_docsis_mdd_channel_profile_reporting_control = -1; +static gint ett_docsis_mdd_ip_init_param = -1; +static gint ett_docsis_mdd_up_active_channel_list = -1; +static gint ett_docsis_mdd_cm_status_event_control = -1; +static gint ett_docsis_mdd_dsg_da_to_dsid = -1; static dissector_handle_t docsis_mdd_handle; /* Dissection */ +static void +dissect_mdd_ds_active_channel_list(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 length; + proto_tree *mdd_tree; + proto_item *mdd_item; + int pos; + static const int * order_annex[] = { + &hf_docsis_mdd_downstream_active_channel_list_modulation_order, + &hf_docsis_mdd_downstream_active_channel_list_annex, + NULL + }; + static const int * cm_status_event[] = { + &hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout, + &hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_failure, + &hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_recovery, + &hf_docsis_mdd_cm_status_event_enable_bitmask_qam_fec_lock_recovery, + NULL + }; + static const int * ofdm_plc_parameters[] = { + &hf_docsis_mdd_ofdm_plc_parameters_tukey_raised_cosine_window, + &hf_docsis_mdd_ofdm_plc_parameters_cyclic_prefix, + &hf_docsis_mdd_ofdm_plc_parameters_sub_carrier_spacing, + NULL + }; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_ds_active_channel_list, &mdd_item, + val_to_str(type, mdd_ds_active_channel_list_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_ds_active_channel_list_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_ds_active_channel_list_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_CHANNEL_ID: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_downstream_active_channel_list_channel_id, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_FREQUENCY: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_downstream_active_channel_list_frequency, tvb, pos, 4, ENC_BIG_ENDIAN); + break; + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_MODULATION_ORDER_ANNEX: + proto_tree_add_bitmask_list(mdd_tree, tvb, pos, 1, order_annex, ENC_BIG_ENDIAN); + break; + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_PRIMARY_CAPABLE: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_downstream_active_channel_list_primary_capable, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK: + proto_tree_add_bitmask(mdd_tree, tvb, pos, hf_docsis_mdd_cm_status_event_enable_bitmask, ett_sub_tlv, cm_status_event, ENC_BIG_ENDIAN); + break; + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_MAP_UCD_TRANSPORT_INDICATOR: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_downstream_active_channel_list_map_ucd_transport_indicator, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case DOWNSTREAM_ACTIVE_CHANNEL_LIST_OFDM_PLC_PARAMETERS: + proto_tree_add_bitmask(mdd_tree, tvb, pos, hf_docsis_mdd_ofdm_plc_parameters, ett_sub_tlv, ofdm_plc_parameters, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } +} + +static void +dissect_mdd_ds_service_group(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 i, length; + proto_tree *mdd_tree; + proto_item *mdd_item; + int pos; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_ds_service_group, &mdd_item, + val_to_str(type, mdd_ds_service_group_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_ds_service_group_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_ds_service_group_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_MD_DS_SG_IDENTIFIER: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_mac_domain_downstream_service_group_md_ds_sg_identifier, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_CHANNEL_IDS: + for (i = 0; i < length; i++) { + proto_tree_add_item (mdd_tree, hf_docsis_mdd_mac_domain_downstream_service_group_channel_id, tvb, pos + i , 1, ENC_BIG_ENDIAN); + } + break; + } + + pos += length; + } +} + +static void +dissect_mdd_channel_profile_reporting_control(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 length; + proto_tree *mdd_tree; + proto_item *mdd_item; + int pos; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_channel_profile_reporting_control, &mdd_item, + val_to_str(type, mdd_channel_profile_reporting_control_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_channel_profile_reporting_control_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_channel_profile_reporting_control_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case RCP_CENTER_FREQUENCY_SPACING: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_rpc_center_frequency_spacing, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case VERBOSE_RCP_REPORTING: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_verbose_rcp_reporting, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } +} + +static void +dissect_mdd_ip_init_param(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 length; + proto_tree *mdd_tree; + proto_item *mdd_item; + int pos; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_ip_init_param, &mdd_item, + val_to_str(type, mdd_ip_init_param_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_ip_init_param_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_ip_init_param_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case IP_PROVISIONING_MODE: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_ip_provisioning_mode, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case PRE_REGISTRATION_DSID: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_pre_registration_dsid, tvb, pos, 3, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } +} + +static void +dissect_mdd_upstream_active_channel_list(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 length; + proto_tree *mdd_tree; + proto_item *mdd_item; + int pos; + static const int * cm_status_event[] = { + &hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout, + &hf_docsis_mdd_cm_status_event_enable_bitmask_t3_retries_exceeded, + &hf_docsis_mdd_cm_status_event_enable_bitmask_successful_ranging_after_t3_retries_exceeded, + NULL + }; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_up_active_channel_list, &mdd_item, + val_to_str(type, mdd_up_active_channel_list_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_up_active_channel_list_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_up_active_channel_list_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case UPSTREAM_ACTIVE_CHANNEL_LIST_UPSTREAM_CHANNEL_ID: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_upstream_active_channel_list_upstream_channel_id, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case UPSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK: + proto_tree_add_bitmask(mdd_tree, tvb, pos, hf_docsis_mdd_cm_status_event_enable_bitmask, ett_sub_tlv, cm_status_event, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } +} + +static void +dissect_mdd_cm_status_event_control(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 length, timer; + proto_tree *mdd_tree; + proto_item *mdd_item, *text_item; + int pos; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_cm_status_event_control, &mdd_item, + val_to_str(type, mdd_cm_status_event_control_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_cm_status_event_control_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_cm_status_event_control_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case EVENT_TYPE_CODE: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_event_type, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case MAXIMUM_EVENT_HOLDOFF_TIMER: + text_item = proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_maximum_event_holdoff_timer, tvb, pos, 2, ENC_BIG_ENDIAN, &timer); + proto_item_append_text(text_item, " (%d ms)", timer * 20); + break; + case MAXIMUM_NUMBER_OF_REPORTS_PER_EVENT: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_maximum_number_of_reports_per_event, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } +} + +static void +dissect_mdd_dsg_da_to_dsid(tvbuff_t * tvb, packet_info* pinfo _U_, proto_tree * tree, int start, guint16 len) +{ + guint8 type; + guint32 length; + proto_tree *mdd_tree; + proto_item *mdd_item; + int pos; + + pos = start; + while ( pos < ( start + len) ) + { + type = tvb_get_guint8 (tvb, pos); + mdd_tree = proto_tree_add_subtree(tree, tvb, pos, -1, + ett_docsis_mdd_dsg_da_to_dsid, &mdd_item, + val_to_str(type, mdd_cm_dsg_da_to_dsid_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (mdd_tree, hf_docsis_mdd_dsg_da_to_dsid_subtype, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (mdd_tree, hf_docsis_mdd_dsg_da_to_dsid_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(mdd_item, length + 2); + + switch(type) + { + case DSG_DA_TO_DSID_ASSOCIATION_DA: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_dsg_da_to_dsid_association_da, tvb, pos, 6, ENC_NA); + break; + case DSG_DA_TO_DSID_ASSOCIATION_DSID: + proto_tree_add_item (mdd_tree, hf_docsis_mdd_dsg_da_to_dsid_association_dsid, tvb, pos, 3, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } +} + static int dissect_mdd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { @@ -370,230 +748,99 @@ dissect_mdd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data proto_tree *mdd_tree; int pos; - int subpos = 0; - gint len; - guint8 type, length; - guint8 subtype, sublength; - int i; - + guint8 type; + guint32 i, length; proto_tree *tlv_tree; - - proto_tree *tlv_sub_tree; - proto_item *text_item; - - len = tvb_reported_length_remaining (tvb, 0); + proto_item *tlv_item; + static const int * non_channel_events[] = { + &hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_sequence_out_of_range, + &hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_operating_on_battery_backup, + &hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_cm_returned_to_ac_power, + NULL + }; col_set_str(pinfo->cinfo, COL_INFO, "MDD Message:"); - if (tree) + it = proto_tree_add_protocol_format (tree, proto_docsis_mdd, tvb, 0, -1,"MDD Message"); + mdd_tree = proto_item_add_subtree (it, ett_docsis_mdd); + + proto_tree_add_item (mdd_tree, hf_docsis_mdd_ccc, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (mdd_tree, hf_docsis_mdd_number_of_fragments, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (mdd_tree, hf_docsis_mdd_fragment_sequence_number, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (mdd_tree, hf_docsis_mdd_current_channel_dcid, tvb, 3, 1, ENC_BIG_ENDIAN); + + /*TLVs...*/ + pos = 4; + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(mdd_tree, tvb, pos, -1, + ett_tlv, &tlv_item, + val_to_str(type, mdd_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_mdd_type, tvb, pos, 1, type); + pos++; + proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_mdd_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch(type) { - it = proto_tree_add_protocol_format (tree, proto_docsis_mdd, tvb, 0, -1,"MDD Message"); - mdd_tree = proto_item_add_subtree (it, ett_docsis_mdd); - - proto_tree_add_item (mdd_tree, hf_docsis_mdd_ccc, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (mdd_tree, hf_docsis_mdd_number_of_fragments, tvb, 1, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (mdd_tree, hf_docsis_mdd_fragment_sequence_number, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (mdd_tree, hf_docsis_mdd_current_channel_dcid, tvb, 3, 1, ENC_BIG_ENDIAN); - - /*TLVs...*/ - pos = 4; - while (pos < len) - { - type = tvb_get_guint8 (tvb, pos); - length = tvb_get_guint8 (tvb, pos + 1); - tlv_tree = proto_tree_add_subtree(mdd_tree, tvb, pos, length + 2, ett_tlv, NULL, val_to_str(type, mdd_tlv_vals, "Unknown TLV (%u)")); - - switch(type) { - - case DOWNSTREAM_ACTIVE_CHANNEL_LIST: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_CHANNEL_ID: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_channel_id, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_FREQUENCY: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_frequency, tvb, subpos + 2 , 4, ENC_BIG_ENDIAN); - break; - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_MODULATION_ORDER_ANNEX: - tlv_sub_tree = proto_tree_add_subtree(tlv_tree, tvb, subpos + 2, 1, ett_sub_tlv, NULL, "Modulation Order/Annex"); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_downstream_active_channel_list_modulation_order, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_downstream_active_channel_list_annex, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_PRIMARY_CAPABLE: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_primary_capable, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK: - tlv_sub_tree = proto_tree_add_subtree(tlv_tree, tvb, subpos + 2, 2, ett_sub_tlv, NULL, "CM-STATUS Event Enable Bitmask"); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout, tvb, subpos + 2 , 2,ENC_BIG_ENDIAN); - 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); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_recovery, tvb, subpos + 2 , 2,ENC_BIG_ENDIAN); - 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); - break; - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_MAP_UCD_TRANSPORT_INDICATOR: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_active_channel_list_map_ucd_transport_indicator, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case DOWNSTREAM_ACTIVE_CHANNEL_LIST_OFDM_PLC_PARAMETERS: - tlv_sub_tree = proto_tree_add_subtree(tlv_tree, tvb, subpos + 2, 1, ett_sub_tlv, NULL, "OFDM PLC Parameters"); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_ofdm_plc_parameters_tukey_raised_cosine_window, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_ofdm_plc_parameters_cyclic_prefix, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_ofdm_plc_parameters_sub_carrier_spacing, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - } - subpos += sublength + 2; - } - break; - case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_MD_DS_SG_IDENTIFIER: - 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); - break; - case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP_CHANNEL_IDS: - for (i = 0; i < sublength; i++) { - proto_tree_add_item (tlv_tree, hf_docsis_mdd_mac_domain_downstream_service_group_channel_id, tvb, subpos + 2 + i , 1, ENC_BIG_ENDIAN); - } - break; - } - subpos += sublength + 2; - } - break; - case DOWNSTREAM_AMBIGUITY_RESOLUTION_FREQUENCY_LIST: - subpos = pos + 2; - for (i = 0; i < length; i+=4) { - proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_ambiguity_resolution_frequency, tvb, subpos + i , 4, ENC_BIG_ENDIAN); - } - break; - case RECEIVE_CHANNEL_PROFILE_REPORTING_CONTROL: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case RCP_CENTER_FREQUENCY_SPACING: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_rpc_center_frequency_spacing, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case VERBOSE_RCP_REPORTING: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_verbose_rcp_reporting, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - } - subpos += sublength + 2; - } - break; - case IP_INITIALIZATION_PARAMETERS: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case IP_PROVISIONING_MODE: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_ip_provisioning_mode, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case PRE_REGISTRATION_DSID: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_pre_registration_dsid, tvb, subpos + 2 , 3, ENC_BIG_ENDIAN); - break; - } - subpos += sublength + 2; - } - break; - case EARLY_AUTHENTICATION_AND_ENCRYPTION: - subpos = pos + 2; - proto_tree_add_item (tlv_tree, hf_docsis_mdd_early_authentication_and_encryption, tvb, subpos, 1, ENC_BIG_ENDIAN); - break; - case UPSTREAM_ACTIVE_CHANNEL_LIST: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case UPSTREAM_ACTIVE_CHANNEL_LIST_UPSTREAM_CHANNEL_ID: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_active_channel_list_upstream_channel_id, tvb, subpos + 2 , 1, ENC_BIG_ENDIAN); - break; - case UPSTREAM_ACTIVE_CHANNEL_LIST_CM_STATUS_EVENT_ENABLE_BITMASK: - tlv_sub_tree = proto_tree_add_subtree(tlv_tree, tvb, subpos + 2, 2, ett_sub_tlv, NULL, "CM-STATUS Event Enable Bitmask"); - proto_tree_add_item (tlv_sub_tree, hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout, tvb, subpos + 2 , 2, ENC_BIG_ENDIAN); - 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); - 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); - break; - } - subpos += sublength + 2; - } - break; - case UPSTREAM_AMBIGUITY_RESOLUTION_CHANNEL_LIST: - sublength = tvb_get_guint8 (tvb, subpos + 1); - for (i = 0; i < sublength; i++) { - proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_ambiguity_resolution_channel_list_channel_id, tvb, pos + 2 + i , 1, ENC_BIG_ENDIAN); - } - break; - case UPSTREAM_FREQUENCY_RANGE: - subpos = pos + 2; - proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_frequency_range, tvb, subpos, 1, ENC_BIG_ENDIAN); - break; - case SYMBOL_CLOCK_LOCKING_INDICATOR: - subpos = pos + 2; - proto_tree_add_item (tlv_tree, hf_docsis_mdd_symbol_clock_locking_indicator, tvb, subpos, 1, ENC_BIG_ENDIAN); - break; - case CM_STATUS_EVENT_CONTROL: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case EVENT_TYPE_CODE: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_event_type, tvb, subpos+2, 1, ENC_BIG_ENDIAN); - break; - case MAXIMUM_EVENT_HOLDOFF_TIMER: - text_item = proto_tree_add_item (tlv_tree, hf_docsis_mdd_maximum_event_holdoff_timer, tvb, subpos, 2, ENC_BIG_ENDIAN); - proto_item_append_text(text_item, " (%d ms)", (256*tvb_get_guint8 (tvb, subpos) + tvb_get_guint8 (tvb, subpos + 1)) * 20); - break; - case MAXIMUM_NUMBER_OF_REPORTS_PER_EVENT: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_maximum_number_of_reports_per_event, tvb, subpos, 1, ENC_BIG_ENDIAN); - break; - } - subpos += sublength + 2; - } - break; - case UPSTREAM_TRANSMIT_POWER_REPORTING: - subpos = pos + 2; - proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_transmit_power_reporting, tvb, subpos, 1, ENC_BIG_ENDIAN); - break; - case DSG_DA_TO_DSID_ASSOCIATION_ENTRY: - subpos = pos + 2; - while (subpos < pos + length + 2) { - subtype = tvb_get_guint8 (tvb, subpos); - sublength = tvb_get_guint8 (tvb, subpos + 1); - switch(subtype) { - case DSG_DA_TO_DSID_ASSOCIATION_DA: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_dsg_da_to_dsid_association_da, tvb, subpos + 2, 6, ENC_NA); - break; - case DSG_DA_TO_DSID_ASSOCIATION_DSID: - proto_tree_add_item (tlv_tree, hf_docsis_mdd_dsg_da_to_dsid_association_dsid, tvb, subpos + 2, 3, ENC_BIG_ENDIAN); - break; - } - subpos += sublength + 2; - } - break; - case CM_STATUS_EVENT_ENABLE_NON_CHANNEL_SPECIFIC_EVENTS: - subpos = pos + 2; - tlv_sub_tree = proto_tree_add_subtree(tlv_tree, tvb, subpos, 2, ett_sub_tlv, NULL, "CM-STATUS Event Enable Bitmask for Non-Channel-Specific Events"); - 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); - 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); - 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); - break; - case EXTENDED_UPSTREAM_TRANSMIT_POWER_SUPPORT: - subpos = pos + 2; - proto_tree_add_item (tlv_tree, hf_docsis_mdd_extended_upstream_transmit_power_support, tvb, subpos, 1, ENC_BIG_ENDIAN); - break; - } - pos += length + 2; - } - } /* if(tree) */ - return tvb_captured_length(tvb); + case DOWNSTREAM_ACTIVE_CHANNEL_LIST: + dissect_mdd_ds_active_channel_list(tvb, pinfo, tlv_tree, pos, length ); + break; + case MAC_DOMAIN_DOWNSTREAM_SERVICE_GROUP: + dissect_mdd_ds_service_group(tvb, pinfo, tlv_tree, pos, length ); + break; + case DOWNSTREAM_AMBIGUITY_RESOLUTION_FREQUENCY_LIST: + for (i = 0; i < length; i+=4) { + proto_tree_add_item (tlv_tree, hf_docsis_mdd_downstream_ambiguity_resolution_frequency, tvb, pos + i, 4, ENC_BIG_ENDIAN); + } + break; + case RECEIVE_CHANNEL_PROFILE_REPORTING_CONTROL: + dissect_mdd_channel_profile_reporting_control(tvb, pinfo, tlv_tree, pos, length ); + break; + case IP_INITIALIZATION_PARAMETERS: + dissect_mdd_ip_init_param(tvb, pinfo, tlv_tree, pos, length ); + break; + case EARLY_AUTHENTICATION_AND_ENCRYPTION: + proto_tree_add_item (tlv_tree, hf_docsis_mdd_early_authentication_and_encryption, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case UPSTREAM_ACTIVE_CHANNEL_LIST: + dissect_mdd_upstream_active_channel_list(tvb, pinfo, tlv_tree, pos, length ); + break; + case UPSTREAM_AMBIGUITY_RESOLUTION_CHANNEL_LIST: + for (i = 0; i < length; i++) { + proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_ambiguity_resolution_channel_list_channel_id, tvb, pos + i , 1, ENC_BIG_ENDIAN); + } + break; + case UPSTREAM_FREQUENCY_RANGE: + proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_frequency_range, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case SYMBOL_CLOCK_LOCKING_INDICATOR: + proto_tree_add_item (tlv_tree, hf_docsis_mdd_symbol_clock_locking_indicator, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case CM_STATUS_EVENT_CONTROL: + dissect_mdd_cm_status_event_control(tvb, pinfo, tlv_tree, pos, length ); + break; + case UPSTREAM_TRANSMIT_POWER_REPORTING: + proto_tree_add_item (tlv_tree, hf_docsis_mdd_upstream_transmit_power_reporting, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + case DSG_DA_TO_DSID_ASSOCIATION_ENTRY: + dissect_mdd_dsg_da_to_dsid(tvb, pinfo, tlv_tree, pos, length ); + break; + case CM_STATUS_EVENT_ENABLE_NON_CHANNEL_SPECIFIC_EVENTS: + proto_tree_add_bitmask(tlv_tree, tvb, pos, hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events, ett_sub_tlv, non_channel_events, ENC_BIG_ENDIAN); + break; + case EXTENDED_UPSTREAM_TRANSMIT_POWER_SUPPORT: + proto_tree_add_item (tlv_tree, hf_docsis_mdd_extended_upstream_transmit_power_support, tvb, pos, 1, ENC_BIG_ENDIAN); + break; + } + + pos += length; + } + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ @@ -621,6 +868,16 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, NULL, 0x0, "Mdd Current Channel DCID", HFILL} }, + {&hf_docsis_mdd_ds_active_channel_list_subtype, + {"Type", "docsis_mdd.downstream_active_channel_list_tlvtype", + FT_UINT8, BASE_DEC, VALS(mdd_ds_active_channel_list_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_ds_active_channel_list_length, + {"Length", "docsis_mdd.downstream_active_channel_list_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_downstream_active_channel_list_channel_id, {"Channel ID", "docsis_mdd.downstream_active_channel_list_channel_id", FT_UINT8, BASE_DEC, NULL, 0x0, @@ -646,6 +903,11 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, VALS(primary_capable_vals), 0x0, "Mdd Downstream Active Channel List Primary Capable", HFILL} }, + {&hf_docsis_mdd_cm_status_event_enable_bitmask, + {"CM-STATUS Event Enable Bitmask", "docsis_mdd.cm_status_event_enable_bitmask", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_cm_status_event_enable_bitmask_mdd_timeout, {"MDD Timeout", "docsis_mdd.downstream_active_channel_list_mdd_timeout", FT_UINT16, BASE_DEC, NULL, 0x0002, @@ -671,6 +933,11 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, VALS(map_ucd_transport_indicator_vals), 0x0, "Mdd Downstream Active Channel List MAP and UCD Transport Indicator", HFILL} }, + {&hf_docsis_mdd_ofdm_plc_parameters, + {"OFDM PLC Parameters", "docsis_mdd.ofdm_plc_parameters", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_ofdm_plc_parameters_tukey_raised_cosine_window, {"Tukey raised cosine window", "docsis_mdd.ofdm_plc_parameters_tukey_raised_cosine_window", FT_UINT8, BASE_DEC, VALS(tukey_raised_cosine_vals), 0x07, @@ -686,6 +953,16 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, VALS(spacing_vals), 0x40, "OFDM PLC parameters Sub carrier spacing", HFILL} }, + {&hf_docsis_mdd_up_active_channel_list_subtype, + {"Type", "docsis_mdd.up_active_channel_list_tlvtype", + FT_UINT8, BASE_DEC, VALS(mdd_up_active_channel_list_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_up_active_channel_list_length, + {"Length", "docsis_mdd.up_active_channel_list_tlvlen", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_cm_status_event_enable_bitmask_t4_timeout, {"T4 timeout", "docsis_mdd.cm_status_event_enable_bitmask_t4_timeout", FT_UINT16, BASE_DEC, NULL, 0x0040, @@ -706,16 +983,46 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, NULL, 0x0, "Mdd Mac Domain Downstream Service Group Channel Id", HFILL} }, + {&hf_docsis_mdd_ds_service_group_subtype, + {"Type", "docsis_mdd.ds_service_group_type", + FT_UINT8, BASE_DEC, VALS(mdd_ds_service_group_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_ds_service_group_length, + {"Length", "docsis_mdd.ds_service_group_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_mac_domain_downstream_service_group_md_ds_sg_identifier, {"MD-DS-SG Identifier", "docsis_mdd.mac_domain_downstream_service_group_md_ds_sg_identifier", FT_UINT8, BASE_DEC, NULL, 0x0, "Mdd Mac Domain Downstream Service Group MD-DS-SG Identifier", HFILL} }, + {&hf_docsis_mdd_type, + {"Type", "docsis_mdd.type", + FT_UINT8, BASE_DEC, VALS(mdd_tlv_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_length, + {"Length", "docsis_mdd.length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_downstream_ambiguity_resolution_frequency, {"Frequency", "docsis_mdd.downstream_ambiguity_resolution_frequency", FT_UINT32, BASE_DEC, NULL, 0x0, "Mdd Downstream Ambiguity Resolution frequency", HFILL} }, + {&hf_docsis_mdd_channel_profile_reporting_control_subtype, + {"Type", "docsis_mdd.channel_profile_reporting_control_type", + FT_UINT8, BASE_DEC, VALS(mdd_channel_profile_reporting_control_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_channel_profile_reporting_control_length, + {"Length", "docsis_mdd.channel_profile_reporting_control_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_rpc_center_frequency_spacing, {"RPC Center Frequency Spacing", "docsis_mdd.rpc_center_frequency_spacing", FT_UINT8, BASE_DEC, VALS(rpc_center_frequency_spacing_vals), 0x0, @@ -726,6 +1033,16 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, VALS(verbose_rpc_reporting_vals), 0x0, "Mdd Verbose RPC Reporting", HFILL} }, + {&hf_docsis_mdd_ip_init_param_subtype, + {"Type", "docsis_mdd.ip_init_param_type", + FT_UINT8, BASE_DEC, VALS(mdd_ip_init_param_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_ip_init_param_length, + {"Length", "docsis_mdd.ip_init_param_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_ip_provisioning_mode, {"IP Provisioning Mode", "docsis_mdd.ip_provisioning_mode", FT_UINT8, BASE_DEC, VALS(ip_provisioning_mode_vals), 0x0, @@ -761,6 +1078,16 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, VALS(symbol_clock_locking_indicator_vals), 0x0, "Mdd Symbol Clock Locking Indicator", HFILL} }, + {&hf_docsis_mdd_cm_status_event_control_subtype, + {"Type", "docsis_mdd.cm_status_event_control_type", + FT_UINT8, BASE_DEC, VALS(mdd_cm_status_event_control_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_cm_status_event_control_length, + {"Length", "docsis_mdd.cm_status_event_control_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_event_type, {"Event Type", "docsis_mdd.event_type", FT_UINT8, BASE_DEC, VALS(symbol_cm_status_event_vals), 0x0, @@ -781,6 +1108,16 @@ void proto_register_docsis_mdd (void) FT_UINT8, BASE_DEC, VALS(upstream_transmit_power_reporting_vals), 0x0, "Mdd Upstream Transmit Power Reporting", HFILL} }, + {&hf_docsis_mdd_dsg_da_to_dsid_subtype, + {"Type", "docsis_mdd.dsg_da_to_dsid_type", + FT_UINT8, BASE_DEC, VALS(mdd_cm_dsg_da_to_dsid_vals), 0x0, + NULL, HFILL} + }, + {&hf_docsis_mdd_dsg_da_to_dsid_length, + {"Length", "docsis_mdd.dsg_da_to_dsid_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_dsg_da_to_dsid_association_da, {"Destination Address", "docsis_mdd.dsg_da_to_dsid_association_da", FT_ETHER, BASE_NONE, NULL, 0x0, @@ -791,6 +1128,11 @@ void proto_register_docsis_mdd (void) FT_UINT24, BASE_DEC, NULL, 0x0FFFFF, "Mdd Mdd DSG DA to DSID association DSID", HFILL} }, + {&hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events, + {"CM-STATUS Event Enable Bitmask for Non-Channel-Specific Events", "docsis_mdd.cm_status_event_enable_non_channel_specific_events", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL} + }, {&hf_docsis_mdd_cm_status_event_enable_non_channel_specific_events_sequence_out_of_range, {"Sequence out of range", "docsis_mdd.cm_status_event_enable_non_channel_specific_events_sequence_out_of_range", FT_UINT16, BASE_DEC, NULL, 0x0008, @@ -816,7 +1158,14 @@ void proto_register_docsis_mdd (void) static gint *ett[] = { &ett_docsis_mdd, &ett_tlv, - &ett_sub_tlv + &ett_sub_tlv, + &ett_docsis_mdd_ds_active_channel_list, + &ett_docsis_mdd_ds_service_group, + &ett_docsis_mdd_channel_profile_reporting_control, + &ett_docsis_mdd_ip_init_param, + &ett_docsis_mdd_up_active_channel_list, + &ett_docsis_mdd_cm_status_event_control, + &ett_docsis_mdd_dsg_da_to_dsid, }; proto_docsis_mdd = diff --git a/plugins/docsis/packet-ocd.c b/plugins/docsis/packet-ocd.c index fb16d152f5..cec82e3386 100644 --- a/plugins/docsis/packet-ocd.c +++ b/plugins/docsis/packet-ocd.c @@ -57,17 +57,20 @@ static int hf_docsis_ocd_tlv_ofdm_spec_loc = -1; static int hf_docsis_ocd_tlv_time_int_depth = -1; static int hf_docsis_ocd_tlv_prim_cap_ind = -1; -static int hf_docsis_ocd_tlv_sub_assign_length = -1; static int hf_docsis_ocd_tlv_subc_assign_type = -1; static int hf_docsis_ocd_tlv_subc_assign_value = -1; -static int docsis_ocd_subc_assign_subc_type = -1; -static int docsis_ocd_subc_assign_range = -1; -static int docsis_ocd_subc_assign_index = -1; +static int hf_docsis_ocd_subc_assign_subc_type = -1; +static int hf_docsis_ocd_subc_assign_range = -1; +static int hf_docsis_ocd_subc_assign_index = -1; +static int hf_docsis_ocd_tlv_data = -1; +static int hf_docsis_ocd_type = -1; +static int hf_docsis_ocd_length = -1; + /* Initialize the subtree pointers */ static gint ett_docsis_ocd = -1; static gint ett_docsis_ocd_tlv = -1; -static gint ett_docsis_ocd_tlv_subcarrier_assignment = -1; +static gint ett_docsis_ocd_tlvtlv = -1; static expert_field ei_docsis_ocd_tlvlen_bad = EI_INIT; static expert_field ei_docsis_ocd_value_unknown = EI_INIT; @@ -104,18 +107,19 @@ static const value_string docsis_ocd_prim_cap_ind_str[] = { {0, NULL} }; +static const value_string ocd_tlv_vals[] = { + {DISCRETE_FOURIER_TRANSFORM_SIZE, "Discrete Fourier Transform Size"}, + {CYCLIC_PREFIX, "Cylic Prefix"}, + {ROLL_OFF, "Roll Off"}, + {OFDM_SPECTRUM_LOCATION, "OFDM Spectrum Location"}, + {TIME_INTERLEAVING_DEPTH, "Time Interleaving Depth"}, + {SUBCARRIER_ASSIGNMENT_RANGE_LIST, "Subcarrier Assignment Range/List"}, + {PRIMARY_CAPABILITY_INDICATOR, "Primary Capable Indicator"}, + {0, NULL} +}; + /** BASE_CUSTOM formatter for the OFDM spectrum location */ -static void -ofdm_spec_loc( - char *buf, - guint32 value) -{ - g_snprintf(buf, ITEM_LABEL_LENGTH, - "%u Hz", - value); -} - static void subc_assign_range( char *buf, @@ -147,139 +151,139 @@ static const value_string docsis_ocd_subc_assign_subc_type_str[] = { {0, NULL} }; +static const unit_name_string local_units_hz = { "Hz", NULL }; /* Dissection */ static void -dissect_subcarrier_assignment_range_list(tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, guint16 start, guint16 len) +dissect_subcarrier_assignment_range_list(tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, guint16 pos, guint32 len) { - proto_item *it; - proto_tree *subcarrier_assignment_tree; - guint8 subcarrier_assignment_type; - guint16 subcarrier_assignment_index; + proto_item* type_item; + guint32 i, subcarrier_assignment_type; - it = proto_tree_add_protocol_format (tree, proto_docsis_ocd, tvb, start-2, len+2, ".5 Subcarrier Assignment Range/List"); - subcarrier_assignment_tree = proto_item_add_subtree (it, ett_docsis_ocd_tlv_subcarrier_assignment); - - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_ocd_tlv_sub_assign_length, tvb, start-1, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_ocd_tlv_subc_assign_type, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_tree, hf_docsis_ocd_tlv_subc_assign_value, tvb, start, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (subcarrier_assignment_tree, docsis_ocd_subc_assign_subc_type, tvb, start, 1, ENC_BIG_ENDIAN); - - - subcarrier_assignment_type = (tvb_get_guint8 (tvb, start) >> 6); + type_item = proto_tree_add_item_ret_uint (tree, hf_docsis_ocd_tlv_subc_assign_type, tvb, pos, 1, ENC_BIG_ENDIAN, &subcarrier_assignment_type); + proto_tree_add_item (tree, hf_docsis_ocd_tlv_subc_assign_value, tvb, pos, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_ocd_subc_assign_subc_type, tvb, pos, 1, ENC_BIG_ENDIAN); + pos++; switch (subcarrier_assignment_type) { case SUBCARRIER_ASSIGNMENT_RANGE_CONT: case SUBCARRIER_ASSIGNMENT_RANGE_SKIPBY1: - proto_tree_add_item (subcarrier_assignment_tree, docsis_ocd_subc_assign_range, tvb, start + 1, 4, ENC_BIG_ENDIAN); + proto_tree_add_item (tree, hf_docsis_ocd_subc_assign_range, tvb, pos, 4, ENC_BIG_ENDIAN); break; case SUBCARRIER_ASSIGNMENT_LIST: - for (subcarrier_assignment_index = 0; subcarrier_assignment_index < len/2; ++subcarrier_assignment_index) { - proto_tree_add_item (subcarrier_assignment_tree, docsis_ocd_subc_assign_index, tvb, start + 1 + 2*subcarrier_assignment_index, 2, ENC_BIG_ENDIAN); + for (i = 0; i < len/2; ++i) { + proto_tree_add_item (tree, hf_docsis_ocd_subc_assign_index, tvb, pos, 2, ENC_BIG_ENDIAN); + pos += 2; } break; default: - expert_add_info_format(pinfo, tree, &ei_docsis_ocd_value_unknown, "Unknown subcarrier assignment type %d", subcarrier_assignment_type); + expert_add_info_format(pinfo, type_item, &ei_docsis_ocd_value_unknown, "Unknown subcarrier assignment type %d", subcarrier_assignment_type); break; } } - static void -dissect_ocd_tlv (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint8 start, guint16 len) +dissect_ocd_tlv (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree) { - proto_item *it; + proto_item *it, *tlv_item, *tlv_len_item; proto_tree *tlv_tree; - guint16 pos = start; - guint8 type, length; + guint16 pos = 0; + guint8 type; + guint32 length; - it = proto_tree_add_protocol_format (tree, proto_docsis_ocd, tvb, start, len, "TLV Data"); + it = proto_tree_add_item(tree, hf_docsis_ocd_tlv_data, tvb, 0, tvb_reported_length(tvb), ENC_NA); tlv_tree = proto_item_add_subtree (it, ett_docsis_ocd_tlv); - while (pos < (len + start)) + while (tvb_reported_length_remaining(tvb, pos) > 0) { - type = tvb_get_guint8 (tvb, pos++); - length = tvb_get_guint8 (tvb, pos++); - if(pos + length > start + len) { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(tlv_tree, tvb, pos, -1, + ett_docsis_ocd_tlvtlv, &tlv_item, + val_to_str(type, ocd_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (tlv_tree, hf_docsis_ocd_type, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_ocd_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + switch (type) { - case DISCRETE_FOURIER_TRANSFORM_SIZE: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_four_trans_size, tvb, pos, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case CYCLIC_PREFIX: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_cycl_pref, tvb, pos, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case ROLL_OFF: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_roll_off, tvb, pos, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case OFDM_SPECTRUM_LOCATION: - if (length == 4) - { - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_ofdm_spec_loc, tvb, pos, 4, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case TIME_INTERLEAVING_DEPTH: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_time_int_depth, tvb, pos, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case SUBCARRIER_ASSIGNMENT_RANGE_LIST: - if (length >= 5) - { - dissect_subcarrier_assignment_range_list(tvb, pinfo, tlv_tree, pos, length); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case PRIMARY_CAPABILITY_INDICATOR: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_prim_cap_ind, tvb, pos, 1, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, tlv_tree, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - default: - proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_unknown, tvb, pos - 2, length+2, ENC_NA); - break; + case DISCRETE_FOURIER_TRANSFORM_SIZE: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_four_trans_size, tvb, pos, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case CYCLIC_PREFIX: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_cycl_pref, tvb, pos, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case ROLL_OFF: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_roll_off, tvb, pos, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case OFDM_SPECTRUM_LOCATION: + if (length == 4) + { + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_ofdm_spec_loc, tvb, pos, 4, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case TIME_INTERLEAVING_DEPTH: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_time_int_depth, tvb, pos, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case SUBCARRIER_ASSIGNMENT_RANGE_LIST: + if (length >= 5) + { + dissect_subcarrier_assignment_range_list(tvb, pinfo, tlv_tree, pos, length); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case PRIMARY_CAPABILITY_INDICATOR: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_prim_cap_ind, tvb, pos, 1, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ocd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + default: + proto_tree_add_item (tlv_tree, hf_docsis_ocd_tlv_unknown, tvb, pos - 2, length+2, ENC_NA); + break; } /* switch */ - pos = pos + length; + pos += length; } /* while */ } @@ -287,27 +291,21 @@ static int dissect_ocd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *ocd_tree = NULL; + proto_tree *ocd_tree; + tvbuff_t *next_tvb; + guint32 downstream_channel_id, configuration_change_count; - guint8 downstream_channel_id; - guint8 configuration_change_count; - guint16 len; + it = proto_tree_add_item(tree, proto_docsis_ocd, tvb, 0, -1, ENC_NA); + ocd_tree = proto_item_add_subtree (it, ett_docsis_ocd); - downstream_channel_id = tvb_get_guint8 (tvb, 0); - configuration_change_count = tvb_get_guint8 (tvb, 1); - len = tvb_captured_length_remaining (tvb, 2); + proto_tree_add_item_ret_uint (ocd_tree, hf_docsis_ocd_dschid, tvb, 0, 1, ENC_BIG_ENDIAN, &downstream_channel_id); + proto_tree_add_item_ret_uint (ocd_tree, hf_docsis_ocd_ccc, tvb, 1, 1, ENC_BIG_ENDIAN, &configuration_change_count); col_add_fstr (pinfo->cinfo, COL_INFO, "OCD: DS CH ID: %u, CCC: %u", downstream_channel_id, configuration_change_count); - if (tree) - { - it = proto_tree_add_protocol_format (tree, proto_docsis_ocd, tvb, 0, -1, "OFDM Channel Descriptor"); - ocd_tree = proto_item_add_subtree (it, ett_docsis_ocd); - proto_tree_add_item (ocd_tree, hf_docsis_ocd_dschid, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (ocd_tree, hf_docsis_ocd_ccc, tvb, 1, 1, ENC_BIG_ENDIAN); - } /* Call Dissector TLV's */ - dissect_ocd_tlv(tvb, pinfo, ocd_tree, 2, len); + next_tvb = tvb_new_subset_remaining(tvb, 2); + dissect_ocd_tlv(next_tvb, pinfo, ocd_tree); return tvb_captured_length(tvb); } @@ -327,25 +325,22 @@ proto_register_docsis_ocd(void) {"Configuration Change Count", "docsis_ocd.ccc", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_four_trans_size, - {".0 Discrete Fourier Transform Size", "docsis_ocd.tlv.four_trans_size", FT_UINT8, BASE_DEC, VALS (docsis_ocd_four_trans_size), 0x0, NULL, HFILL} + {"Discrete Fourier Transform Size", "docsis_ocd.tlv.four_trans_size", FT_UINT8, BASE_DEC, VALS (docsis_ocd_four_trans_size), 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_cycl_pref, - {".1 Cylic Prefix", "docsis_ocd.tlv.cyc_pref", FT_UINT8, BASE_DEC, VALS (docsis_ocd_cyc_prefix), 0x0, NULL, HFILL} + {"Cylic Prefix", "docsis_ocd.tlv.cyc_pref", FT_UINT8, BASE_DEC, VALS (docsis_ocd_cyc_prefix), 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_roll_off, - {".2 Roll Off", "docsis_ocd.tlv.roll_off", FT_UINT8, BASE_DEC, VALS (docsis_ocd_roll_off), 0x0, NULL, HFILL} + {"Roll Off", "docsis_ocd.tlv.roll_off", FT_UINT8, BASE_DEC, VALS (docsis_ocd_roll_off), 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_ofdm_spec_loc, - {".3 OFDM Spectrum Location", "docsis_ocd.tlv.ofdm_spec_loc", FT_UINT32, BASE_CUSTOM, CF_FUNC(ofdm_spec_loc) , 0x0, NULL, HFILL} + {"OFDM Spectrum Location", "docsis_ocd.tlv.ofdm_spec_loc", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &local_units_hz, 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_time_int_depth, - {".4 Time Interleaving Depth", "docsis_ocd.tlv.time_int_depth", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} + {"Time Interleaving Depth", "docsis_ocd.tlv.time_int_depth", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_prim_cap_ind, - {".6 Primary Capable Indicator", "docsis_ocd.tlv.prim_cap_ind", FT_UINT8, BASE_DEC, VALS(docsis_ocd_prim_cap_ind_str), 0x0, NULL, HFILL} - }, - {&hf_docsis_ocd_tlv_sub_assign_length, - {"Subcarrier Assignment Length", "docsis_ocd.tlv.subc_assign.length", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} + {"Primary Capable Indicator", "docsis_ocd.tlv.prim_cap_ind", FT_UINT8, BASE_DEC, VALS(docsis_ocd_prim_cap_ind_str), 0x0, NULL, HFILL} }, {&hf_docsis_ocd_tlv_subc_assign_type, {"Assignment type", "docsis_ocd.tlv.subc_assign.type", FT_UINT8, BASE_DEC, VALS(docsis_ocd_subc_assign_type_str), 0xC0, NULL, HFILL} @@ -353,15 +348,24 @@ proto_register_docsis_ocd(void) {&hf_docsis_ocd_tlv_subc_assign_value, {"Assignment value", "docsis_ocd.tlv.subc_assign.value", FT_UINT8, BASE_DEC, VALS(docsis_ocd_subc_assign_value_str), 0x20, NULL, HFILL} }, - {&docsis_ocd_subc_assign_subc_type, + {&hf_docsis_ocd_subc_assign_subc_type, {"Subcarrier Type", "docsis_ocd.tlv.subc_assign.subc_type", FT_UINT8, BASE_DEC, VALS(docsis_ocd_subc_assign_subc_type_str), 0x1F, NULL, HFILL} }, - {&docsis_ocd_subc_assign_range, + {&hf_docsis_ocd_subc_assign_range, {"Subcarrier index range", "docsis_ocd.tlv.subc_assign.range", FT_UINT32, BASE_CUSTOM, CF_FUNC(subc_assign_range), 0x00, NULL, HFILL} }, - {&docsis_ocd_subc_assign_index, + {&hf_docsis_ocd_subc_assign_index, {"Subcarrier index", "docsis_ocd.tlv.subc_assign.index", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} }, + {&hf_docsis_ocd_tlv_data, + {"TLV Data", "docsis_ocd.tlv_data", FT_BYTES, BASE_NO_DISPLAY_VALUE, NULL, 0x0, NULL, HFILL} + }, + {&hf_docsis_ocd_type, + {"Type", "docsis_ocd.type",FT_UINT8, BASE_DEC, VALS(ocd_tlv_vals), 0x0, NULL, HFILL} + }, + {&hf_docsis_ocd_length, + {"Length", "docsis_ocd.length",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} + }, }; static ei_register_info ei[] = { @@ -372,7 +376,7 @@ proto_register_docsis_ocd(void) static gint *ett[] = { &ett_docsis_ocd, &ett_docsis_ocd_tlv, - &ett_docsis_ocd_tlv_subcarrier_assignment + &ett_docsis_ocd_tlvtlv, }; expert_module_t* expert_docsis_ocd; diff --git a/plugins/docsis/packet-regack.c b/plugins/docsis/packet-regack.c index 26d275249d..3e288ce312 100644 --- a/plugins/docsis/packet-regack.c +++ b/plugins/docsis/packet-regack.c @@ -47,28 +47,19 @@ static int dissect_regack (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *regack_tree = NULL; - guint16 sid; - guint8 response; + proto_tree *regack_tree; + guint32 sid, response; tvbuff_t *next_tvb; - sid = tvb_get_ntohs (tvb, 0); - response = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item (tree, proto_docsis_regack, tvb, 0, -1, ENC_NA); + regack_tree = proto_item_add_subtree (it, ett_docsis_regack); + + proto_tree_add_item_ret_uint (regack_tree, hf_docsis_regack_sid, tvb, 0, 2, ENC_BIG_ENDIAN, &sid); + proto_tree_add_item_ret_uint (regack_tree, hf_docsis_regack_response, tvb, 2, 1, ENC_BIG_ENDIAN, &response); col_add_fstr (pinfo->cinfo, COL_INFO, "Registration Acknowledge SID = %u (%s)", sid, val_to_str (response, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_regack, tvb, 0, -1, - "Registration Acknowledge"); - regack_tree = proto_item_add_subtree (it, ett_docsis_regack); - proto_tree_add_item (regack_tree, hf_docsis_regack_sid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (regack_tree, hf_docsis_regack_response, tvb, 2, 1, - ENC_BIG_ENDIAN); - } /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 3); diff --git a/plugins/docsis/packet-regreq.c b/plugins/docsis/packet-regreq.c index 53b5563549..6bf6fb9b91 100644 --- a/plugins/docsis/packet-regreq.c +++ b/plugins/docsis/packet-regreq.c @@ -44,28 +44,21 @@ static int dissect_regreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *regreq_tree = NULL; - guint16 sid; + proto_tree *regreq_tree; + guint32 sid; tvbuff_t *next_tvb; - sid = tvb_get_ntohs (tvb, 0); - - col_add_fstr (pinfo->cinfo, COL_INFO, "Registration Request SID = %u", - sid); - - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_regreq, tvb, 0, -1, - "Registration Request"); - regreq_tree = proto_item_add_subtree (it, ett_docsis_regreq); - proto_tree_add_item (regreq_tree, hf_docsis_regreq_sid, tvb, 0, 2, - ENC_BIG_ENDIAN); - } - /* Call Dissector for Appendix C TlV's */ - next_tvb = tvb_new_subset_remaining (tvb, 2); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, regreq_tree); - return tvb_captured_length(tvb); + it = proto_tree_add_item(tree, proto_docsis_regreq, tvb, 0, -1, ENC_NA); + regreq_tree = proto_item_add_subtree (it, ett_docsis_regreq); + + proto_tree_add_item_ret_uint (regreq_tree, hf_docsis_regreq_sid, tvb, 0, 2, ENC_BIG_ENDIAN, &sid); + + col_add_fstr (pinfo->cinfo, COL_INFO, "Registration Request SID = %u", sid); + + /* Call Dissector for Appendix C TlV's */ + next_tvb = tvb_new_subset_remaining (tvb, 2); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, regreq_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-regreqmp.c b/plugins/docsis/packet-regreqmp.c index 5b6b9c00c8..1afa357653 100644 --- a/plugins/docsis/packet-regreqmp.c +++ b/plugins/docsis/packet-regreqmp.c @@ -49,21 +49,18 @@ static int dissect_regreqmp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *regreqmp_tree = NULL; + proto_tree *regreqmp_tree; tvbuff_t *next_tvb; col_set_str(pinfo->cinfo, COL_INFO, "REG-REQ-MP Message:"); - if (tree) - { - it = proto_tree_add_protocol_format (tree, proto_docsis_regreqmp, tvb, 0, -1,"REG-REQ-MP Message"); - regreqmp_tree = proto_item_add_subtree (it, ett_docsis_regreqmp); + it = proto_tree_add_item(tree, proto_docsis_regreqmp, tvb, 0, -1, ENC_NA); + regreqmp_tree = proto_item_add_subtree (it, ett_docsis_regreqmp); - proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_sid, tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_number_of_fragments, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_fragment_sequence_number, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_sid, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_number_of_fragments, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_fragment_sequence_number, tvb, 3, 1, ENC_BIG_ENDIAN); - } /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 4); call_dissector (docsis_tlv_handle, next_tvb, pinfo, regreqmp_tree); diff --git a/plugins/docsis/packet-regrsp.c b/plugins/docsis/packet-regrsp.c index 9bf578b3c0..896512e36a 100644 --- a/plugins/docsis/packet-regrsp.c +++ b/plugins/docsis/packet-regrsp.c @@ -47,33 +47,23 @@ static int dissect_regrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *regrsp_tree = NULL; - guint16 sid; - guint8 response; + proto_tree *regrsp_tree; + guint32 sid, response; tvbuff_t *next_tvb; - sid = tvb_get_ntohs (tvb, 0); - response = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item(tree, proto_docsis_regrsp, tvb, 0, -1, ENC_NA); + regrsp_tree = proto_item_add_subtree (it, ett_docsis_regrsp); + proto_tree_add_item_ret_uint (regrsp_tree, hf_docsis_regrsp_sid, tvb, 0, 2, ENC_BIG_ENDIAN, &sid); + proto_tree_add_item_ret_uint (regrsp_tree, hf_docsis_regrsp_response, tvb, 2, 1, ENC_BIG_ENDIAN, &response); col_add_fstr (pinfo->cinfo, COL_INFO, "Registration Response SID = %u (%s)", sid, val_to_str (response, docsis_conf_code, "%d")); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_regrsp, tvb, 0, -1, - "Registration Response"); - regrsp_tree = proto_item_add_subtree (it, ett_docsis_regrsp); - proto_tree_add_item (regrsp_tree, hf_docsis_regrsp_sid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (regrsp_tree, hf_docsis_regrsp_response, tvb, 2, 1, - ENC_BIG_ENDIAN); - } - /* Call Dissector for Appendix C TLV's */ - next_tvb = tvb_new_subset_remaining (tvb, 3); - call_dissector (docsis_tlv_handle, next_tvb, pinfo, regrsp_tree); - return tvb_captured_length(tvb); + /* Call Dissector for Appendix C TLV's */ + next_tvb = tvb_new_subset_remaining (tvb, 3); + call_dissector (docsis_tlv_handle, next_tvb, pinfo, regrsp_tree); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-regrspmp.c b/plugins/docsis/packet-regrspmp.c index 726f353dfb..e43d0bea62 100644 --- a/plugins/docsis/packet-regrspmp.c +++ b/plugins/docsis/packet-regrspmp.c @@ -52,22 +52,19 @@ static int dissect_regrspmp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *regrspmp_tree = NULL; + proto_tree *regrspmp_tree; tvbuff_t *next_tvb; col_set_str(pinfo->cinfo, COL_INFO, "REG-RSP-MP Message:"); - if (tree) - { - it = proto_tree_add_protocol_format (tree, proto_docsis_regrspmp, tvb, 0, -1,"REG-RSP-MP Message"); - regrspmp_tree = proto_item_add_subtree (it, ett_docsis_regrspmp); + it = proto_tree_add_item(tree, proto_docsis_regrspmp, tvb, 0, -1, ENC_NA); + regrspmp_tree = proto_item_add_subtree (it, ett_docsis_regrspmp); - proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_sid, tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_response, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_number_of_fragments, tvb, 3, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_fragment_sequence_number, tvb, 4, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_sid, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_response, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_number_of_fragments, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (regrspmp_tree, hf_docsis_regrspmp_fragment_sequence_number, tvb, 4, 1, ENC_BIG_ENDIAN); - } /* Call Dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 5); call_dissector (docsis_tlv_handle, next_tvb, pinfo, regrspmp_tree); diff --git a/plugins/docsis/packet-rngreq.c b/plugins/docsis/packet-rngreq.c index 94b99ef762..2e93daa188 100644 --- a/plugins/docsis/packet-rngreq.c +++ b/plugins/docsis/packet-rngreq.c @@ -45,9 +45,11 @@ dissect_rngreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da { proto_item *it; proto_tree *rngreq_tree; - guint16 sid; + guint32 sid; - sid = tvb_get_ntohs (tvb, 0); + it = proto_tree_add_item(tree, proto_docsis_rngreq, tvb, 0, -1, ENC_NA); + rngreq_tree = proto_item_add_subtree (it, ett_docsis_rngreq); + proto_tree_add_item_ret_uint (rngreq_tree, hf_docsis_rngreq_sid, tvb, 0, 2, ENC_BIG_ENDIAN, &sid); if (sid > 0) col_add_fstr (pinfo->cinfo, COL_INFO, "Ranging Request: SID = %u", @@ -55,20 +57,10 @@ dissect_rngreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da else col_set_str(pinfo->cinfo, COL_INFO, "Initial Ranging Request SID = 0"); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_rngreq, tvb, 0, -1, - "Ranging Request"); - rngreq_tree = proto_item_add_subtree (it, ett_docsis_rngreq); - proto_tree_add_item (rngreq_tree, hf_docsis_rngreq_sid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (rngreq_tree, hf_docsis_rngreq_down_chid, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (rngreq_tree, hf_docsis_rngreq_pend_compl, tvb, 3, - 1, ENC_BIG_ENDIAN); - } - return tvb_captured_length(tvb); + proto_tree_add_item (rngreq_tree, hf_docsis_rngreq_down_chid, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (rngreq_tree, hf_docsis_rngreq_pend_compl, tvb, 3, 1, ENC_BIG_ENDIAN); + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-rngrsp.c b/plugins/docsis/packet-rngrsp.c index 3971e65e3c..7dfc51b015 100644 --- a/plugins/docsis/packet-rngrsp.c +++ b/plugins/docsis/packet-rngrsp.c @@ -83,14 +83,16 @@ dissect_rngrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da proto_tree *rngrsp_tree; proto_item *rngrsptlv_item; proto_tree *rngrsptlv_tree; - guint8 tlvtype, tlvlen; + guint8 tlvtype; int pos; - gint length; - guint8 upchid; - guint16 sid; + guint tlvlen; + guint32 sid, upchid; - sid = tvb_get_ntohs (tvb, 0); - upchid = tvb_get_guint8 (tvb, 2); + it = proto_tree_add_item(tree, proto_docsis_rngrsp, tvb, 0, -1, ENC_NA); + rngrsp_tree = proto_item_add_subtree (it, ett_docsis_rngrsp); + + proto_tree_add_item_ret_uint (rngrsp_tree, hf_docsis_rngrsp_sid, tvb, 0, 2, ENC_BIG_ENDIAN, &sid); + proto_tree_add_item_ret_uint (rngrsp_tree, hf_docsis_rngrsp_upstream_chid, tvb, 2, 1, ENC_BIG_ENDIAN, &upchid); if (upchid > 0) col_add_fstr (pinfo->cinfo, COL_INFO, @@ -99,88 +101,68 @@ dissect_rngrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da else col_add_fstr (pinfo->cinfo, COL_INFO, "Ranging Response: SID = %u, Telephony Return", sid); - it = proto_tree_add_protocol_format (tree, proto_docsis_rngrsp, tvb, 0, -1, - "Ranging Response"); - rngrsp_tree = proto_item_add_subtree (it, ett_docsis_rngrsp); - proto_tree_add_item (rngrsp_tree, hf_docsis_rngrsp_sid, tvb, 0, 2, - ENC_BIG_ENDIAN); - proto_tree_add_item (rngrsp_tree, hf_docsis_rngrsp_upstream_chid, tvb, - 2, 1, ENC_BIG_ENDIAN); - length = tvb_reported_length (tvb); + pos = 3; - while (pos < length) - { - tlvtype = tvb_get_guint8 (tvb, pos); - rngrsptlv_tree = proto_tree_add_subtree(rngrsp_tree, tvb, pos, -1, + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + tlvtype = tvb_get_guint8 (tvb, pos); + rngrsptlv_tree = proto_tree_add_subtree(rngrsp_tree, tvb, pos, -1, ett_docsis_rngrsptlv, &rngrsptlv_item, val_to_str(tlvtype, rngrsp_tlv_vals, "Unknown TLV (%u)")); - proto_tree_add_uint (rngrsptlv_tree, hf_docsis_rngrsp_type, - tvb, pos, 1, tlvtype); - pos++; - tlvlen = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (rngrsptlv_tree, hf_docsis_rngrsp_length, - tvb, pos, 1, tlvlen); - pos++; - proto_item_set_len(rngrsptlv_item, tlvlen + 2); - switch (tlvtype) - { - case RNGRSP_TIMING: - if (tlvlen == 4) - { - proto_tree_add_item (rngrsptlv_tree, - hf_docsis_rngrsp_timing_adj, tvb, pos, - tlvlen, ENC_BIG_ENDIAN); - } - pos = pos + tlvlen; - break; - case RNGRSP_PWR_LEVEL_ADJ: - if (tlvlen == 1) - { - proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_power_adj, - tvb, pos, tlvlen, ENC_NA); - } - pos = pos + tlvlen; - break; - case RNGRSP_OFFSET_FREQ_ADJ: - if (tlvlen == 2) - { - proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_freq_adj, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - pos = pos + tlvlen; - break; - case RNGRSP_TRANSMIT_EQ_ADJ: - proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_xmit_eq_adj, - tvb, pos, tlvlen, ENC_NA); - pos = pos + tlvlen; - break; - case RNGRSP_RANGING_STATUS: - if (tlvlen == 1) - proto_tree_add_item (rngrsptlv_tree, - hf_docsis_rngrsp_ranging_status, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - pos = pos + tlvlen; - break; - case RNGRSP_DOWN_FREQ_OVER: - if (tlvlen == 4) - proto_tree_add_item (rngrsptlv_tree, - hf_docsis_rngrsp_down_freq_over, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - pos = pos + tlvlen; - break; - case RNGRSP_UP_CHID_OVER: - if (tlvlen == 1) - proto_tree_add_item (rngrsptlv_tree, - hf_docsis_rngrsp_upstream_ch_over, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - pos = pos + tlvlen; - break; - default: - pos = pos + tlvlen; - } /* switch(tlvtype) */ - } /* while (pos < length) */ - return length; + proto_tree_add_uint (rngrsptlv_tree, hf_docsis_rngrsp_type, tvb, pos, 1, tlvtype); + pos++; + proto_tree_add_item_ret_uint (rngrsptlv_tree, hf_docsis_rngrsp_length, + tvb, pos, 1, ENC_NA, &tlvlen); + pos++; + proto_item_set_len(rngrsptlv_item, tlvlen + 2); + switch (tlvtype) + { + case RNGRSP_TIMING: + if (tlvlen == 4) + { + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_timing_adj, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + break; + case RNGRSP_PWR_LEVEL_ADJ: + if (tlvlen == 1) + { + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_power_adj, tvb, pos, tlvlen, ENC_NA); + } + break; + case RNGRSP_OFFSET_FREQ_ADJ: + if (tlvlen == 2) + { + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_freq_adj, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + break; + case RNGRSP_TRANSMIT_EQ_ADJ: + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_xmit_eq_adj, tvb, pos, tlvlen, ENC_NA); + break; + case RNGRSP_RANGING_STATUS: + if (tlvlen == 1) + { + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_ranging_status, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + break; + case RNGRSP_DOWN_FREQ_OVER: + if (tlvlen == 4) + { + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_down_freq_over, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + break; + case RNGRSP_UP_CHID_OVER: + if (tlvlen == 1) + { + proto_tree_add_item (rngrsptlv_tree, hf_docsis_rngrsp_upstream_ch_over, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + break; + default: + ; + } /* switch(tlvtype) */ + pos += tlvlen; + } /* while (tvb_reported_length_remaining(tvb, pos) > 0) */ + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-sync.c b/plugins/docsis/packet-sync.c index 9e2565ee43..021d099be0 100644 --- a/plugins/docsis/packet-sync.c +++ b/plugins/docsis/packet-sync.c @@ -47,14 +47,11 @@ dissect_sync (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data col_set_str(pinfo->cinfo, COL_INFO, "Sync Message"); - if (tree) - { - it = proto_tree_add_protocol_format (tree, proto_docsis_sync, tvb, 0, -1,"SYNC Message"); - sync_tree = proto_item_add_subtree (it, ett_docsis_sync); - - proto_tree_add_item (sync_tree, hf_docsis_sync_cmts_timestamp, tvb, 0, 4, - ENC_BIG_ENDIAN); - } /* if(tree) */ + it = proto_tree_add_item(tree, proto_docsis_sync, tvb, 0, -1, ENC_NA); + sync_tree = proto_item_add_subtree (it, ett_docsis_sync); + + proto_tree_add_item (sync_tree, hf_docsis_sync_cmts_timestamp, tvb, 0, 4, ENC_BIG_ENDIAN); + return tvb_captured_length(tvb); } @@ -76,8 +73,7 @@ proto_register_docsis_sync (void) }; proto_docsis_sync = - proto_register_protocol ("DOCSIS Synchronisation Message", - "DOCSIS Sync", "docsis_sync"); + proto_register_protocol ("DOCSIS Synchronisation Message", "SYNC Message", "docsis_sync"); proto_register_field_array (proto_docsis_sync, hf, array_length (hf)); proto_register_subtree_array (ett, array_length (ett)); diff --git a/plugins/docsis/packet-type29ucd.c b/plugins/docsis/packet-type29ucd.c index 1524bbed84..893d445c21 100644 --- a/plugins/docsis/packet-type29ucd.c +++ b/plugins/docsis/packet-type29ucd.c @@ -264,13 +264,14 @@ dissect_type29ucd_burstdescriptor(tvbuff_t * tvb, packet_info * pinfo, proto_tre { guint16 endtlvpos, pos; proto_tree *type29ucd_burst_tree; - proto_item *type29ucd_burst_item; - guint8 tlvlen, tlvtype; + proto_item *type29ucd_burst_item, *type29ucd_burst_len_item; + guint8 tlvtype; + guint32 tlvlen; pos = start; + endtlvpos = pos + length; proto_tree_add_item (tree, hf_docsis_type29ucd_iuc, tvb, pos++, 1, ENC_BIG_ENDIAN); - endtlvpos = pos + length - 1; while (pos < endtlvpos) { tlvtype = tvb_get_guint8 (tvb, pos); @@ -279,230 +280,193 @@ dissect_type29ucd_burstdescriptor(tvbuff_t * tvb, packet_info * pinfo, proto_tre val_to_str(tlvtype, burst_tlv_vals, "Unknown TLV (%u)")); proto_tree_add_uint (type29ucd_burst_tree, hf_docsis_type29ucd_burst_type, tvb, pos++, 1, tlvtype); - tlvlen = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type29ucd_burst_tree, hf_docsis_type29ucd_burst_length, tvb, pos++, 1, tlvlen); + type29ucd_burst_len_item = proto_tree_add_item_ret_uint (type29ucd_burst_tree, hf_docsis_type29ucd_burst_length, tvb, pos++, 1, ENC_NA, &tlvlen); proto_item_set_len(type29ucd_burst_item, tlvlen + 2); switch (tlvtype) { - case type29ucd_MODULATION: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_mod_type, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_DIFF_ENCODING: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_diff_encoding, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_PREAMBLE_LEN: - if (tlvlen == 2) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_preamble_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_PREAMBLE_VAL_OFF: - if (tlvlen == 2) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_preamble_val_off, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_FEC: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_fec, tvb, pos, - tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_FEC_CODEWORD: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_fec_codeword, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCRAMBLER_SEED: - if (tlvlen == 2) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_scrambler_seed, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_MAX_BURST: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_max_burst, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_GUARD_TIME: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_guard_time, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_LAST_CW_LEN: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_last_cw_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_burst_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_RS_INT_DEPTH: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_rs_int_depth, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_RS_INT_BLOCK: - if (tlvlen == 2) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_rs_int_block, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_PREAMBLE_TYPE: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_preamble_type, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCMDA_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_scdma_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_CODES_PER_SUBFRAME: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_scdma_codes_per_subframe, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_FRAMER_INT_STEP_SIZE: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_scdma_framer_int_step_size, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_TCM_ENABLED: - if (tlvlen == 1) - { - proto_tree_add_item (type29ucd_burst_tree, - hf_docsis_tcm_enabled, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - default: - expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvtype_unknown, "Unknown TLV type: %u", tlvtype); - break; + case type29ucd_MODULATION: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_mod_type, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_DIFF_ENCODING: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_diff_encoding, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_PREAMBLE_LEN: + if (tlvlen == 2) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_preamble_len, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_PREAMBLE_VAL_OFF: + if (tlvlen == 2) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_preamble_val_off, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_FEC: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_fec, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_FEC_CODEWORD: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_fec_codeword, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCRAMBLER_SEED: + if (tlvlen == 2) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_scrambler_seed, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_MAX_BURST: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_max_burst, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_GUARD_TIME: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_guard_time, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_LAST_CW_LEN: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_last_cw_len, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_burst_scrambler_onoff, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_RS_INT_DEPTH: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_rs_int_depth, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_RS_INT_BLOCK: + if (tlvlen == 2) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_rs_int_block, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_PREAMBLE_TYPE: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_preamble_type, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCMDA_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_scdma_scrambler_onoff, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_CODES_PER_SUBFRAME: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_scdma_codes_per_subframe, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_FRAMER_INT_STEP_SIZE: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_scdma_framer_int_step_size, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_TCM_ENABLED: + if (tlvlen == 1) + { + proto_tree_add_item (type29ucd_burst_tree, hf_docsis_tcm_enabled, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29ucd_burst_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + default: + expert_add_info_format(pinfo, type29ucd_burst_item, &ei_docsis_type29ucd_tlvtype_unknown, "Unknown TLV type: %u", tlvtype); + break; } /* switch(tlvtype) */ pos = pos + tlvlen; } /* while (pos < endtlvpos) */ @@ -512,16 +476,19 @@ static int dissect_type29ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { guint16 pos; - guint8 type, length; + guint8 type, symrate; + guint32 length, upchid; proto_tree *type29ucd_tree; proto_item *type29ucd_item; proto_tree *type29tlv_tree; - proto_item *type29tlv_item; - guint16 len; - guint8 upchid, symrate; + proto_item *type29tlv_item, *type29tlv_len_item; - len = tvb_reported_length(tvb); - upchid = tvb_get_guint8 (tvb, 0); + type29ucd_item = proto_tree_add_item(tree, proto_docsis_type29ucd, tvb, 0, -1, ENC_NA); + type29ucd_tree = proto_item_add_subtree (type29ucd_item, ett_docsis_type29ucd); + proto_tree_add_item_ret_uint (type29ucd_tree, hf_docsis_type29ucd_upstream_chid, tvb, 0, 1, ENC_BIG_ENDIAN, &upchid); + proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_config_ch_cnt, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_mini_slot_size, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_down_chid, tvb, 3, 1, ENC_BIG_ENDIAN); /* if the upstream Channel ID is 0 then this is for Telephony Return) */ if (upchid > 0) @@ -533,246 +500,211 @@ dissect_type29ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* "Type 29 UCD Message: Channel ID = %u (Telephony Return)", upchid); - if (tree) - { - type29ucd_item = - proto_tree_add_protocol_format (tree, proto_docsis_type29ucd, tvb, 0, - tvb_captured_length(tvb), - "UCD Message (Type 29)"); - type29ucd_tree = proto_item_add_subtree (type29ucd_item, ett_docsis_type29ucd); - proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_upstream_chid, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_config_ch_cnt, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_mini_slot_size, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type29ucd_tree, hf_docsis_type29ucd_down_chid, tvb, 3, 1, - ENC_BIG_ENDIAN); - - pos = 4; - while (pos < len) - { - type = tvb_get_guint8 (tvb, pos); - type29tlv_tree = proto_tree_add_subtree(type29ucd_tree, tvb, pos, -1, + pos = 4; + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + type29tlv_tree = proto_tree_add_subtree(type29ucd_tree, tvb, pos, -1, ett_docsis_type29tlv, &type29tlv_item, val_to_str(type, channel_tlv_vals, "Unknown TLV (%u)")); - proto_tree_add_uint (type29tlv_tree, hf_docsis_type29ucd_type, - tvb, pos, 1, type); - pos++; - length = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type29tlv_tree, hf_docsis_type29ucd_length, - tvb, pos, 1, length); - pos++; - proto_item_set_len(type29tlv_item, length + 2); - switch (type) - { - case type29ucd_SYMBOL_RATE: - if (length == 1) - { - symrate = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type29tlv_tree, hf_docsis_type29ucd_symbol_rate, - tvb, pos, length, symrate * 160); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_FREQUENCY: - if (length == 4) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_frequency, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_PREAMBLE: - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_preamble_pat, tvb, - pos, length, ENC_NA); - break; - case type29ucd_EXT_PREAMBLE: - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_ext_preamble, tvb, - pos, length, ENC_NA); - break; - case type29ucd_SCDMA_MODE_ENABLE: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_mode_enable, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_SPREADING_INTERVAL: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_spreading_interval, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_CODES_PER_MINI_SLOT: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_codes_per_mini_slot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_ACTIVE_CODES: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_active_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_CODE_HOPPING_SEED: - if (length == 2) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_code_hopping_seed, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_US_RATIO_NUM: - if (length == 2) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_us_ratio_num, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_US_RATIO_DENOM: - if (length == 2) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_us_ratio_denom, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_SCDMA_TIMESTAMP_SNAPSHOT: - if (length == 9) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_timestamp_snapshot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_maintain_power_spectral_density, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_RANGING_REQUIRED: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_ranging_required, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_MAX_SCHEDULED_CODES: - if (length == 1) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_max_scheduled_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_RANGING_HOLD_OFF_PRIORITY_FIELD: - if (length == 4) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_rnghoff_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_rnghoff_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_rnghoff_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_rnghoff_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_rnghoff_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_rnghoff_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_RANGING_CHANNEL_CLASS_ID: - if (length == 4) - { - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_chan_class_id_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_chan_class_id_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_chan_class_id_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_chan_class_id_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_chan_class_id_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_chan_class_id_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type29ucd_BURST_DESCR5: - dissect_type29ucd_burstdescriptor(tvb, pinfo, type29tlv_tree, pos, length); - break; - default: - expert_add_info_format(pinfo, type29tlv_item, &ei_docsis_type29ucd_tlvtype_unknown, "Unknown TLV type: %u", type); - break; - } /* switch(type) */ - pos = pos + length; - } /* while (pos < len) */ - } /* if (tree) */ + proto_tree_add_uint (type29tlv_tree, hf_docsis_type29ucd_type, tvb, pos, 1, type); + pos++; + type29tlv_len_item = proto_tree_add_item_ret_uint (type29tlv_tree, hf_docsis_type29ucd_length, + tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(type29tlv_item, length + 2); + switch (type) + { + case type29ucd_SYMBOL_RATE: + if (length == 1) + { + symrate = tvb_get_guint8 (tvb, pos); + proto_tree_add_uint (type29tlv_tree, hf_docsis_type29ucd_symbol_rate, tvb, pos, length, symrate * 160); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_FREQUENCY: + if (length == 4) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_frequency, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_PREAMBLE: + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_preamble_pat, tvb, pos, length, ENC_NA); + break; + case type29ucd_EXT_PREAMBLE: + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_ext_preamble, tvb, pos, length, ENC_NA); + break; + case type29ucd_SCDMA_MODE_ENABLE: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_mode_enable, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_SPREADING_INTERVAL: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_spreading_interval, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_CODES_PER_MINI_SLOT: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_codes_per_mini_slot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_ACTIVE_CODES: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_active_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_CODE_HOPPING_SEED: + if (length == 2) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_code_hopping_seed, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_US_RATIO_NUM: + if (length == 2) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_us_ratio_num, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_US_RATIO_DENOM: + if (length == 2) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_us_ratio_denom, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_SCDMA_TIMESTAMP_SNAPSHOT: + if (length == 9) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_scdma_timestamp_snapshot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_MAINTAIN_POWER_SPECTRAL_DENSITY: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_maintain_power_spectral_density, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_RANGING_REQUIRED: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_ranging_required, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_MAX_SCHEDULED_CODES: + if (length == 1) + { + proto_tree_add_item (type29tlv_tree, hf_docsis_type29ucd_max_scheduled_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_RANGING_HOLD_OFF_PRIORITY_FIELD: + if (length == 4) + { + static const int * ucd_rnghoff[] = { + &hf_docsis_type29ucd_rnghoff_cm, + &hf_docsis_type29ucd_rnghoff_erouter, + &hf_docsis_type29ucd_rnghoff_emta, + &hf_docsis_type29ucd_rnghoff_estb, + &hf_docsis_type29ucd_rnghoff_rsvd, + &hf_docsis_type29ucd_rnghoff_id_ext, + NULL + }; - return tvb_captured_length(tvb); + proto_tree_add_bitmask_list(type29tlv_tree, tvb, pos, length, ucd_rnghoff, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_RANGING_CHANNEL_CLASS_ID: + if (length == 4) + { + static const int * ucd_chan_class_id[] = { + &hf_docsis_type29ucd_chan_class_id_cm, + &hf_docsis_type29ucd_chan_class_id_erouter, + &hf_docsis_type29ucd_chan_class_id_emta, + &hf_docsis_type29ucd_chan_class_id_estb, + &hf_docsis_type29ucd_chan_class_id_rsvd, + &hf_docsis_type29ucd_chan_class_id_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(type29tlv_tree, tvb, pos, length, ucd_chan_class_id, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type29ucd_BURST_DESCR5: + dissect_type29ucd_burstdescriptor(tvb, pinfo, type29tlv_tree, pos, length); + break; + default: + expert_add_info_format(pinfo, type29tlv_len_item, &ei_docsis_type29ucd_tlvtype_unknown, "Unknown TLV type: %u", type); + break; + } /* switch(type) */ + + pos += length; + } /* while (pos < len) */ + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ @@ -1009,7 +941,7 @@ proto_register_docsis_type29ucd (void) NULL, HFILL} }, {&hf_docsis_type29ucd_chan_class_id_rsvd, - {"Reserved [0x000000]", + {"Reserved", "docsis_type29ucd.classidrsvd", FT_UINT32, BASE_HEX, NULL, 0xFFF0, NULL, HFILL} diff --git a/plugins/docsis/packet-type35ucd.c b/plugins/docsis/packet-type35ucd.c index 251a1732ee..737d78beb7 100644 --- a/plugins/docsis/packet-type35ucd.c +++ b/plugins/docsis/packet-type35ucd.c @@ -273,15 +273,15 @@ static const value_string last_cw_len_vals[] = { }; static const value_string max_scheduled_codes_vals[] = { - {1, "Enabled."}, - {2, "Disabled."}, + {1, "Enabled"}, + {2, "Disabled"}, {0, NULL} }; static const value_string ranging_required[] = { - {0, "No ranging required."}, - {1, "Unicast initial ranging required."}, - {2, "Broadcast initial ranging required."}, + {0, "No ranging required"}, + {1, "Unicast initial ranging required"}, + {2, "Broadcast initial ranging required"}, {0, NULL} }; @@ -289,20 +289,20 @@ static const value_string ranging_required[] = { static int dissect_type35ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { - guint16 pos, endtlvpos; - guint8 type, length; - guint8 tlvlen, tlvtype; - proto_tree *type35ucd_burst_tree; - proto_item *type35ucd_burst_item; - proto_tree *type35ucd_tree; - proto_item *type35ucd_item; - proto_tree *type35tlv_tree; - proto_item *type35tlv_item; - guint16 len; - guint8 upchid, symrate; + guint16 pos, endtlvpos, subpos; + guint8 type; + guint32 upchid, length, tlvlen; + guint8 tlvtype; + proto_tree *type35ucd_tree, *type35tlv_tree, *type35ucd_burst_tree; + proto_item *type35ucd_item, *type35tlv_item, *type35tlv_len_item, *type35ucd_burst_item, *type35ucd_burst_len_item; + guint8 symrate; - len = tvb_reported_length(tvb); - upchid = tvb_get_guint8 (tvb, 0); + type35ucd_item = proto_tree_add_item (tree, proto_docsis_type35ucd, tvb, 0, -1, ENC_NA); + type35ucd_tree = proto_item_add_subtree (type35ucd_item, ett_docsis_type35ucd); + proto_tree_add_item_ret_uint (type35ucd_tree, hf_docsis_type35ucd_upstream_chid, tvb, 0, 1, ENC_BIG_ENDIAN, &upchid); + proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_config_ch_cnt, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_mini_slot_size, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_down_chid, tvb, 3, 1, ENC_BIG_ENDIAN); /* if the upstream Channel ID is 0 then this is for Telephony Return) */ if (upchid > 0) @@ -314,534 +314,443 @@ dissect_type35ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* "Type 35 UCD Message: Channel ID = %u (Telephony Return)", upchid); - type35ucd_item = - proto_tree_add_protocol_format (tree, proto_docsis_type35ucd, tvb, 0, - tvb_captured_length(tvb), - "UCD Message (Type 35)"); - type35ucd_tree = proto_item_add_subtree (type35ucd_item, ett_docsis_type35ucd); - proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_upstream_chid, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_config_ch_cnt, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_mini_slot_size, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type35ucd_tree, hf_docsis_type35ucd_down_chid, tvb, 3, 1, - ENC_BIG_ENDIAN); - pos = 4; - while (pos < len) - { - type = tvb_get_guint8 (tvb, pos); - type35tlv_tree = proto_tree_add_subtree(type35ucd_tree, tvb, pos, -1, + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + type35tlv_tree = proto_tree_add_subtree(type35ucd_tree, tvb, pos, -1, ett_docsis_type35tlv, &type35tlv_item, val_to_str(type, channel_tlv_vals, "Unknown TLV (%u)")); - proto_tree_add_uint (type35tlv_tree, hf_docsis_type35ucd_type, - tvb, pos, 1, type); - pos++; - length = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type35tlv_tree, hf_docsis_type35ucd_length, - tvb, pos, 1, length); - pos++; - proto_item_set_len(type35tlv_item, length + 2); - switch (type) + proto_tree_add_uint (type35tlv_tree, hf_docsis_type35ucd_type, tvb, pos, 1, type); + pos++; + type35tlv_len_item = proto_tree_add_item_ret_uint (type35tlv_tree, hf_docsis_type35ucd_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(type35tlv_item, length + 2); + + switch (type) + { + case type35ucd_SYMBOL_RATE: + if (length == 1) + { + symrate = tvb_get_guint8 (tvb, pos); + proto_tree_add_uint (type35tlv_tree, hf_docsis_type35ucd_symbol_rate, tvb, pos, length, symrate * 160); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_FREQUENCY: + if (length == 4) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_frequency, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_PREAMBLE: + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_preamble_pat, tvb, pos, length, ENC_NA); + break; + case type35ucd_EXT_PREAMBLE: + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_ext_preamble, tvb, pos, length, ENC_NA); + break; + case type35ucd_SCDMA_MODE_ENABLE: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_mode_enable, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_SPREADING_INTERVAL: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_spreading_interval, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_CODES_PER_MINI_SLOT: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_codes_per_mini_slot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_ACTIVE_CODES: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_active_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_CODE_HOPPING_SEED: + if (length == 2) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_code_hopping_seed, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_US_RATIO_NUM: + if (length == 2) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_us_ratio_num, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_US_RATIO_DENOM: + if (length == 2) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_us_ratio_denom, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_TIMESTAMP_SNAPSHOT: + if (length == 9) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_timestamp_snapshot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_MAINTAIN_POWER_SPECTRAL_DENSITY: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_maintain_power_spectral_density, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_RANGING_REQUIRED: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_ranging_required, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_MAX_SCHEDULED_CODES: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_max_scheduled_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_RANGING_HOLD_OFF_PRIORITY_FIELD: + if (length == 4) + { + static const int * ucd_rnghoff[] = { + &hf_docsis_type35ucd_rnghoff_cm, + &hf_docsis_type35ucd_rnghoff_erouter, + &hf_docsis_type35ucd_rnghoff_emta, + &hf_docsis_type35ucd_rnghoff_estb, + &hf_docsis_type35ucd_rnghoff_rsvd, + &hf_docsis_type35ucd_rnghoff_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(type35tlv_tree, tvb, pos, length, ucd_rnghoff, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_RANGING_CHANNEL_CLASS_ID: + if (length == 4) + { + static const int * ucd_chan_class_id[] = { + &hf_docsis_type35ucd_chan_class_id_cm, + &hf_docsis_type35ucd_chan_class_id_erouter, + &hf_docsis_type35ucd_chan_class_id_emta, + &hf_docsis_type35ucd_chan_class_id_estb, + &hf_docsis_type35ucd_chan_class_id_rsvd, + &hf_docsis_type35ucd_chan_class_id_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(type35tlv_tree, tvb, pos, length, ucd_chan_class_id, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_active_code_hopping, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES: + if (length == 16) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_selection_active_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_HIGHER_UCD_FOR_SAME_UCID: + if (length == 1) + { + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_higher_ucd_for_same_ucid, tvb, pos, length, ENC_NA); + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_higher_ucd_for_same_ucid_resv, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35tlv_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_BURST_DESCR5: + endtlvpos = pos + length; + subpos = pos; + proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_iuc, tvb, subpos++, 1, ENC_BIG_ENDIAN); + while (subpos < endtlvpos) + { + tlvtype = tvb_get_guint8 (tvb, subpos); + type35ucd_burst_tree = proto_tree_add_subtree (type35tlv_tree, tvb, subpos, -1, + ett_docsis_type35_burst_tlv, &type35ucd_burst_item, + val_to_str(tlvtype, burst_tlv_vals, + "Unknown TLV (%u)")); + proto_tree_add_uint (type35ucd_burst_tree, hf_docsis_type35ucd_burst_type, tvb, subpos, 1, tlvtype); + subpos++; + type35ucd_burst_len_item = proto_tree_add_item_ret_uint (type35ucd_burst_tree, hf_docsis_type35ucd_burst_length, tvb, subpos, 1, ENC_NA, &tlvlen); + subpos++; + proto_item_set_len(type35ucd_burst_item, tlvlen + 2); + switch (tlvtype) { - case type35ucd_SYMBOL_RATE: - if (length == 1) - { - symrate = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type35tlv_tree, hf_docsis_type35ucd_symbol_rate, - tvb, pos, length, symrate * 160); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_FREQUENCY: - if (length == 4) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_frequency, tvb, - pos, length, ENC_BIG_ENDIAN); - pos = pos + length; - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_PREAMBLE: - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_preamble_pat, tvb, - pos, length, ENC_NA); - pos = pos + length; - break; - case type35ucd_EXT_PREAMBLE: - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_ext_preamble, tvb, - pos, length, ENC_NA); - pos = pos + length; - break; - case type35ucd_SCDMA_MODE_ENABLE: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_mode_enable, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_SPREADING_INTERVAL: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_spreading_interval, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_CODES_PER_MINI_SLOT: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_codes_per_mini_slot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_ACTIVE_CODES: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_active_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_CODE_HOPPING_SEED: - if (length == 2) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_code_hopping_seed, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_US_RATIO_NUM: - if (length == 2) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_us_ratio_num, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_US_RATIO_DENOM: - if (length == 2) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_us_ratio_denom, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_TIMESTAMP_SNAPSHOT: - if (length == 9) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_timestamp_snapshot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_MAINTAIN_POWER_SPECTRAL_DENSITY: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_maintain_power_spectral_density, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_RANGING_REQUIRED: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_ranging_required, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_MAX_SCHEDULED_CODES: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_max_scheduled_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_RANGING_HOLD_OFF_PRIORITY_FIELD: - if (length == 4) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_rnghoff_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_rnghoff_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_rnghoff_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_rnghoff_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_rnghoff_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_rnghoff_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_RANGING_CHANNEL_CLASS_ID: - if (length == 4) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_chan_class_id_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_chan_class_id_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_chan_class_id_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_chan_class_id_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_chan_class_id_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_chan_class_id_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_active_code_hopping, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES: - if (length == 16) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_scdma_selection_active_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_HIGHER_UCD_FOR_SAME_UCID: - if (length == 1) - { - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_higher_ucd_for_same_ucid, - tvb, pos, length, ENC_NA); - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_higher_ucd_for_same_ucid_resv, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case type35ucd_BURST_DESCR5: - proto_tree_add_item (type35tlv_tree, hf_docsis_type35ucd_iuc, tvb, - pos++, 1, ENC_BIG_ENDIAN); - endtlvpos = pos + length - 1; - while (pos < endtlvpos) - { - tlvtype = tvb_get_guint8 (tvb, pos); - type35ucd_burst_tree = proto_tree_add_subtree (type35tlv_tree, tvb, pos, -1, - ett_docsis_type35_burst_tlv, &type35ucd_burst_item, - val_to_str(tlvtype, burst_tlv_vals, - "Unknown TLV (%u)")); - proto_tree_add_uint (type35ucd_burst_tree, hf_docsis_type35ucd_burst_type, tvb, pos, 1, tlvtype); - pos++; - tlvlen = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type35ucd_burst_tree, hf_docsis_type35ucd_burst_length, tvb, pos, 1, tlvlen); - pos++; - proto_item_set_len(type35ucd_burst_item, tlvlen + 2); - switch (tlvtype) - { - case type35ucd_MODULATION: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_mod_type, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_DIFF_ENCODING: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_diff_encoding, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_PREAMBLE_LEN: - if (tlvlen == 2) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_preamble_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_PREAMBLE_VAL_OFF: - if (tlvlen == 2) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_preamble_val_off, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_FEC: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_fec, tvb, pos, - tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_FEC_CODEWORD: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_fec_codeword, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_SCRAMBLER_SEED: - if (tlvlen == 2) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_scrambler_seed, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_MAX_BURST: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_max_burst, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_GUARD_TIME: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_guard_time, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_LAST_CW_LEN: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_last_cw_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_burst_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_RS_INT_DEPTH: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_rs_int_depth, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_RS_INT_BLOCK: - if (tlvlen == 2) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_rs_int_block, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_PREAMBLE_TYPE: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_preamble_type, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_SCMDA_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_scdma_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_SCDMA_CODES_PER_SUBFRAME: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_scdma_codes_per_subframe, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_SCDMA_FRAMER_INT_STEP_SIZE: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_scdma_framer_int_step_size, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type35ucd_TCM_ENABLED: - if (tlvlen == 1) - { - proto_tree_add_item (type35ucd_burst_tree, - hf_docsis_tcm_enabled, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - default: - expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvtype_bad, "Unknown TLV type: %u", tlvtype); - } /* switch(tlvtype) */ - pos = pos + tlvlen; - } /* while (pos < endtlvpos) */ - break; - default: - expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvtype_bad, "Unknown TLV type: %u", type); - pos = pos + length; - } /* switch(type) */ - } /* while (pos < len) */ - return len; + case type35ucd_MODULATION: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_mod_type, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_DIFF_ENCODING: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_diff_encoding, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_PREAMBLE_LEN: + if (tlvlen == 2) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_preamble_len, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_PREAMBLE_VAL_OFF: + if (tlvlen == 2) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_preamble_val_off, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_FEC: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_fec, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_FEC_CODEWORD: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_fec_codeword, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCRAMBLER_SEED: + if (tlvlen == 2) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_scrambler_seed, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_MAX_BURST: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_max_burst, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo,type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_GUARD_TIME: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_guard_time, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_LAST_CW_LEN: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_last_cw_len, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_burst_scrambler_onoff, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_RS_INT_DEPTH: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_rs_int_depth, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_RS_INT_BLOCK: + if (tlvlen == 2) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_rs_int_block, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_PREAMBLE_TYPE: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_preamble_type, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCMDA_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_scdma_scrambler_onoff, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_CODES_PER_SUBFRAME: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_scdma_codes_per_subframe, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_SCDMA_FRAMER_INT_STEP_SIZE: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_scdma_framer_int_step_size, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type35ucd_TCM_ENABLED: + if (tlvlen == 1) + { + proto_tree_add_item (type35ucd_burst_tree, hf_docsis_tcm_enabled, tvb, subpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type35ucd_burst_len_item, &ei_docsis_type35ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + default: + expert_add_info_format(pinfo, type35ucd_burst_item, &ei_docsis_type35ucd_tlvtype_bad, "Unknown TLV type: %u", tlvtype); + } /* switch(tlvtype) */ + + subpos += tlvlen; + } /* while (pos < endtlvpos) */ + break; + default: + expert_add_info_format(pinfo, type35tlv_item, &ei_docsis_type35ucd_tlvtype_bad, "Unknown TLV type: %u", type); + } /* switch(type) */ + + pos += length; + } /* while (tvb_reported_length_remaining(tvb, pos) > 0) */ + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-type51ucd.c b/plugins/docsis/packet-type51ucd.c index 2557367218..1b7684b80a 100644 --- a/plugins/docsis/packet-type51ucd.c +++ b/plugins/docsis/packet-type51ucd.c @@ -339,8 +339,8 @@ static const value_string last_cw_len_vals[] = { }; static const value_string max_scheduled_codes_vals[] = { - {1, "Enabled."}, - {2, "Disabled."}, + {1, "Enabled"}, + {2, "Disabled"}, {0, NULL} }; @@ -426,16 +426,15 @@ subcarrier_range ( static void dissect_type51ucd_burstdescriptor(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint16 start, guint16 length) { - guint16 endtlvpos, pos; + guint16 endtlvpos, pos = start; guint16 i; proto_tree *type51ucd_burst_tree; - proto_item *type51ucd_burst_item; - guint8 tlvlen, tlvtype; + proto_item *type51ucd_burst_item, *type51ucd_burst_len_item; + guint32 tlvlen, tlvtype; - pos = start; + endtlvpos = pos + length; proto_tree_add_item (tree, hf_docsis_type51ucd_iuc, tvb, pos++, 1, ENC_BIG_ENDIAN); - endtlvpos = pos + length - 1; while (pos < endtlvpos) { tlvtype = tvb_get_guint8 (tvb, pos); @@ -444,282 +443,240 @@ dissect_type51ucd_burstdescriptor(tvbuff_t * tvb, packet_info * pinfo, proto_tre val_to_str(tlvtype, burst_tlv_vals, "Unknown TLV (%u)")); proto_tree_add_uint (type51ucd_burst_tree, hf_docsis_type51ucd_burst_type, tvb, pos++, 1, tlvtype); - tlvlen = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type51ucd_burst_tree, hf_docsis_type51ucd_burst_length, tvb, pos++, 1, tlvlen); + type51ucd_burst_len_item = proto_tree_add_item_ret_uint (type51ucd_burst_tree, hf_docsis_type51ucd_burst_length, tvb, pos++, 1, ENC_NA, &tlvlen); proto_item_set_len(type51ucd_burst_item, tlvlen + 2); switch (tlvtype) { - case type51ucd_MODULATION: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_mod_type, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_DIFF_ENCODING: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_diff_encoding, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_PREAMBLE_LEN: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_preamble_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_PREAMBLE_VAL_OFF: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_preamble_val_off, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_FEC: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_fec, tvb, pos, - tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_FEC_CODEWORD: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_fec_codeword, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCRAMBLER_SEED: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_scrambler_seed, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_MAX_BURST: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_max_burst, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_GUARD_TIME: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_guard_time, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_LAST_CW_LEN: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_last_cw_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_burst_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_RS_INT_DEPTH: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_rs_int_depth, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_RS_INT_BLOCK: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_rs_int_block, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_PREAMBLE_TYPE: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_preamble_type, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCMDA_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_scdma_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_CODES_PER_SUBFRAME: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_scdma_codes_per_subframe, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_FRAMER_INT_STEP_SIZE: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_scdma_framer_int_step_size, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_TCM_ENABLED: - if (tlvlen == 1) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_tcm_enabled, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SUBC_INIT_RANG: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_subc_init_rang, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SUBC_FINE_RANG: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, - hf_docsis_subc_fine_rang, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_OFDMA_PROFILE: - if ((tlvlen % 2) == 0) - { - for(i =0; i < tlvlen; i+=2) { - proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_mod_order, tvb, pos + i, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_pilot_pattern, tvb, pos + i, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_num_add_minislots, tvb, pos + i + 1, 1, ENC_BIG_ENDIAN); - } - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u (even length expected)", length); - } - break; - case type51ucd_OFDMA_IR_POWER_CONTROL: - if (tlvlen == 2) - { - proto_tree_add_item (type51ucd_burst_tree, hf_docsis_ofdma_ir_pow_ctrl_start_pow, tvb, pos, tlvlen, ENC_BIG_ENDIAN); - proto_tree_add_item (type51ucd_burst_tree, hf_docsis_ofdma_ir_pow_ctrl_step_size, tvb, pos + 1, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u (even length expected)", length); - } - break; - default: - expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvtype_bad, "Unknown TLV type: %u", tlvtype); - + case type51ucd_MODULATION: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_mod_type, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_DIFF_ENCODING: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_diff_encoding, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_PREAMBLE_LEN: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_preamble_len, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_PREAMBLE_VAL_OFF: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_preamble_val_off, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_FEC: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_fec, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_FEC_CODEWORD: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_fec_codeword, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCRAMBLER_SEED: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_scrambler_seed, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_MAX_BURST: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_max_burst, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_GUARD_TIME: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_guard_time, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_LAST_CW_LEN: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_last_cw_len, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_burst_scrambler_onoff, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_RS_INT_DEPTH: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_rs_int_depth, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_RS_INT_BLOCK: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_rs_int_block, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_PREAMBLE_TYPE: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_preamble_type, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCMDA_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_scdma_scrambler_onoff, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_CODES_PER_SUBFRAME: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_scdma_codes_per_subframe, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_FRAMER_INT_STEP_SIZE: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_scdma_framer_int_step_size, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_TCM_ENABLED: + if (tlvlen == 1) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_tcm_enabled, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SUBC_INIT_RANG: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_subc_init_rang, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SUBC_FINE_RANG: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_subc_fine_rang, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_OFDMA_PROFILE: + if ((tlvlen % 2) == 0) + { + for(i =0; i < tlvlen; i+=2) { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_mod_order, tvb, pos + i, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_pilot_pattern, tvb, pos + i, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_type51ucd_ofdma_prof_num_add_minislots, tvb, pos + i + 1, 1, ENC_BIG_ENDIAN); + } + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u (even length expected)", length); + } + break; + case type51ucd_OFDMA_IR_POWER_CONTROL: + if (tlvlen == 2) + { + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_ofdma_ir_pow_ctrl_start_pow, tvb, pos, tlvlen, ENC_BIG_ENDIAN); + proto_tree_add_item (type51ucd_burst_tree, hf_docsis_ofdma_ir_pow_ctrl_step_size, tvb, pos + 1, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51ucd_burst_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + default: + expert_add_info_format(pinfo, type51ucd_burst_item, &ei_docsis_type51ucd_tlvtype_bad, "Unknown TLV type: %u", tlvtype); } - pos = pos + tlvlen; + + pos += tlvlen; } /*while*/ } @@ -728,18 +685,16 @@ static int dissect_type51ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { guint16 pos; - guint8 type, length; + guint8 type, symrate; guint16 i; - proto_tree *type51ucd_tree; - proto_item *type51ucd_item; - proto_tree *type51tlv_tree; - proto_item *type51tlv_item; - guint16 len; - guint8 upchid, symrate; + proto_tree *type51ucd_tree, *type51tlv_tree; + proto_item *type51ucd_item, *type51tlv_item, *type51tlv_len_item; + guint32 upchid, length; - len = tvb_reported_length(tvb); - upchid = tvb_get_guint8 (tvb, 0); + type51ucd_item = proto_tree_add_item(tree, proto_docsis_type51ucd, tvb, 0, -1, ENC_NA); + type51ucd_tree = proto_item_add_subtree (type51ucd_item, ett_docsis_type51ucd); + proto_tree_add_item_ret_uint (type51ucd_tree, hf_docsis_type51ucd_upstream_chid, tvb, 0, 1, ENC_BIG_ENDIAN, &upchid); /* if the upstream Channel ID is 0 then this is for Telephony Return) */ if (upchid > 0) @@ -751,22 +706,12 @@ dissect_type51ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* "Type 51 UCD Message: Channel ID = %u (Telephony Return)", upchid); - type51ucd_item = - proto_tree_add_protocol_format (tree, proto_docsis_type51ucd, tvb, 0, - tvb_captured_length(tvb), - "UCD Message (Type 51)"); - type51ucd_tree = proto_item_add_subtree (type51ucd_item, ett_docsis_type51ucd); - proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_upstream_chid, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_config_ch_cnt, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_mini_slot_size, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_down_chid, tvb, 3, 1, - ENC_BIG_ENDIAN); + proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_config_ch_cnt, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_mini_slot_size, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (type51ucd_tree, hf_docsis_type51ucd_down_chid, tvb, 3, 1, ENC_BIG_ENDIAN); pos = 4; - while (pos < len) + while (tvb_reported_length_remaining(tvb, pos) > 0) { type = tvb_get_guint8 (tvb, pos); type51tlv_tree = proto_tree_add_subtree(type51ucd_tree, tvb, pos, -1, @@ -776,385 +721,344 @@ dissect_type51ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_type, tvb, pos, 1, type); pos++; - length = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_length, - tvb, pos, 1, length); + type51tlv_len_item = proto_tree_add_item_ret_uint (type51tlv_tree, hf_docsis_type51ucd_length, + tvb, pos, 1, ENC_NA, &length); pos++; proto_item_set_len(type51tlv_item, length + 2); switch (type) { - case type51ucd_SYMBOL_RATE: - if (length == 1) - { - symrate = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_symbol_rate, - tvb, pos, length, symrate * 160); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_FREQUENCY: - if (length == 4) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_frequency, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_PREAMBLE: - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_preamble_pat, tvb, - pos, length, ENC_NA); - break; - case type51ucd_EXT_PREAMBLE: - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ext_preamble, tvb, - pos, length, ENC_NA); - break; - case type51ucd_SCDMA_MODE_ENABLE: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_mode_enable, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_SPREADING_INTERVAL: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_spreading_interval, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_CODES_PER_MINI_SLOT: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_codes_per_mini_slot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_ACTIVE_CODES: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_active_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_CODE_HOPPING_SEED: - if (length == 2) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_code_hopping_seed, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_US_RATIO_NUM: - if (length == 2) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_us_ratio_num, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_US_RATIO_DENOM: - if (length == 2) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_us_ratio_denom, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_TIMESTAMP_SNAPSHOT: - if (length == 9) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_timestamp_snapshot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_MAINTAIN_POWER_SPECTRAL_DENSITY: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_maintain_power_spectral_density, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_RANGING_REQUIRED: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ranging_required, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_MAX_SCHEDULED_CODES: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_max_scheduled_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_RANGING_HOLD_OFF_PRIORITY_FIELD: - if (length == 4) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rnghoff_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_RANGING_CHANNEL_CLASS_ID: - if (length == 4) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_chan_class_id_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_active_code_hopping, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES: - if (length == 16) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_selection_active_codes, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_HIGHER_UCD_FOR_SAME_UCID: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_higher_ucd_for_same_ucid, - tvb, pos, length, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_higher_ucd_for_same_ucid_resv, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_UCD_CHANGE_IND_BITMASK: - if (length == 2) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_subc_excl_band, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_unused_subc, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_other_subc, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc5, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc6, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc9, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc10, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc11, - tvb, pos + 1, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc12, - tvb, pos, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc13, - tvb, pos, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc3_or_4, - tvb, pos, 1, ENC_NA); - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_reserved, - tvb, pos, 1, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_OFDMA_TIMESTAMP_SNAPSHOT: - if (length == 9) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_timestamp_snapshot, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_OFDMA_CYCLIC_PREFIX_SIZE: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_cyclic_prefix_size, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_OFDMA_ROLLOFF_PERIOD_SIZE: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_rolloff_period_size, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SUBCARRIER_SPACING: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subc_spacing, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_CENTER_FREQ_SUBC_0: - if (length == 4) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_cent_freq_subc0, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SUBC_EXCL_BAND: - if ((length % 4) == 0) - { - for(i = 0; i < length; i+=4) { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subcarrier_range, tvb, pos+i, 4, ENC_NA); - } - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_UNUSED_SUBC_SPEC: - if ((length % 4) == 0) - { - for(i = 0; i < length; i+=4) { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subcarrier_range, tvb, pos+i, 4, ENC_NA); - } - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_SYMB_IN_OFDMA_FRAME: - if (length == 1) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_symb_ofdma_frame, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_RAND_SEED: - if (length == 3) - { - proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rand_seed, - tvb, pos, length, ENC_NA); - } - else - { - expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case type51ucd_BURST_DESCR23: - dissect_type51ucd_burstdescriptor(tvb, pinfo, type51tlv_tree, pos, length); - break; + case type51ucd_SYMBOL_RATE: + if (length == 1) + { + symrate = tvb_get_guint8 (tvb, pos); + proto_tree_add_uint (type51tlv_tree, hf_docsis_type51ucd_symbol_rate, tvb, pos, length, symrate * 160); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_FREQUENCY: + if (length == 4) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_frequency, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_PREAMBLE: + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_preamble_pat, tvb, pos, length, ENC_NA); + break; + case type51ucd_EXT_PREAMBLE: + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ext_preamble, tvb, pos, length, ENC_NA); + break; + case type51ucd_SCDMA_MODE_ENABLE: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_mode_enable, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_SPREADING_INTERVAL: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_spreading_interval, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_CODES_PER_MINI_SLOT: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_codes_per_mini_slot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_ACTIVE_CODES: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_active_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_CODE_HOPPING_SEED: + if (length == 2) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_code_hopping_seed, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_US_RATIO_NUM: + if (length == 2) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_us_ratio_num, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_US_RATIO_DENOM: + if (length == 2) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_us_ratio_denom, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_TIMESTAMP_SNAPSHOT: + if (length == 9) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_timestamp_snapshot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_MAINTAIN_POWER_SPECTRAL_DENSITY: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_maintain_power_spectral_density, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_RANGING_REQUIRED: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ranging_required, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_MAX_SCHEDULED_CODES: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_max_scheduled_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_RANGING_HOLD_OFF_PRIORITY_FIELD: + if (length == 4) + { + static const int * ucd_rnghoff[] = { + &hf_docsis_type51ucd_rnghoff_cm, + &hf_docsis_type51ucd_rnghoff_erouter, + &hf_docsis_type51ucd_rnghoff_emta, + &hf_docsis_type51ucd_rnghoff_estb, + &hf_docsis_type51ucd_rnghoff_rsvd, + &hf_docsis_type51ucd_rnghoff_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(type51tlv_tree, tvb, pos, length, ucd_rnghoff, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_RANGING_CHANNEL_CLASS_ID: + if (length == 4) + { + static const int * ucd_chan_class_id[] = { + &hf_docsis_type51ucd_chan_class_id_cm, + &hf_docsis_type51ucd_chan_class_id_erouter, + &hf_docsis_type51ucd_chan_class_id_emta, + &hf_docsis_type51ucd_chan_class_id_estb, + &hf_docsis_type51ucd_chan_class_id_rsvd, + &hf_docsis_type51ucd_chan_class_id_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(type51tlv_tree, tvb, pos, length, ucd_chan_class_id, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_SELECTION_ACTIVE_CODES_AND_CODE_HOPPING: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_active_code_hopping, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SCDMA_SELECTION_STRING_FOR_ACTIVE_CODES: + if (length == 16) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_scdma_selection_active_codes, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_HIGHER_UCD_FOR_SAME_UCID: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_higher_ucd_for_same_ucid, tvb, pos, length, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_higher_ucd_for_same_ucid_resv, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_UCD_CHANGE_IND_BITMASK: + if (length == 2) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_subc_excl_band, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_unused_subc, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_other_subc, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc5, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc6, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc9, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc10, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc11, tvb, pos + 1, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc12, tvb, pos, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc13, tvb, pos, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_burst_attr_iuc3_or_4, tvb, pos, 1, ENC_NA); + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ucd_change_ind_bitmask_reserved, tvb, pos, 1, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_OFDMA_TIMESTAMP_SNAPSHOT: + if (length == 9) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_timestamp_snapshot, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_OFDMA_CYCLIC_PREFIX_SIZE: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_cyclic_prefix_size, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_OFDMA_ROLLOFF_PERIOD_SIZE: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_ofdma_rolloff_period_size, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SUBCARRIER_SPACING: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subc_spacing, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_CENTER_FREQ_SUBC_0: + if (length == 4) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_cent_freq_subc0, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SUBC_EXCL_BAND: + if ((length % 4) == 0) + { + for(i = 0; i < length; i+=4) { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subcarrier_range, tvb, pos+i, 4, ENC_NA); + } + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_UNUSED_SUBC_SPEC: + if ((length % 4) == 0) + { + for(i = 0; i < length; i+=4) { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_subcarrier_range, tvb, pos+i, 4, ENC_NA); + } + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_SYMB_IN_OFDMA_FRAME: + if (length == 1) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_symb_ofdma_frame, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_RAND_SEED: + if (length == 3) + { + proto_tree_add_item (type51tlv_tree, hf_docsis_type51ucd_rand_seed, tvb, pos, length, ENC_NA); + } + else + { + expert_add_info_format(pinfo, type51tlv_len_item, &ei_docsis_type51ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case type51ucd_BURST_DESCR23: + dissect_type51ucd_burstdescriptor(tvb, pinfo, type51tlv_tree, pos, length); + break; default: expert_add_info_format(pinfo, type51tlv_item, &ei_docsis_type51ucd_tlvtype_bad, "Unknown TLV type: %u", type); - } /* switch(type) */ - pos = pos + length; - } /* while (pos < len) */ - return len; + } /* switch(type) */ + pos += length; + } /* while (tvb_reported_length_remaining(tvb, pos) > 0) */ + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-uccreq.c b/plugins/docsis/packet-uccreq.c index 856112a103..9a1a090160 100644 --- a/plugins/docsis/packet-uccreq.c +++ b/plugins/docsis/packet-uccreq.c @@ -43,26 +43,19 @@ static int dissect_uccreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { proto_item *it; - proto_tree *uccreq_tree = NULL; - guint8 chid; + proto_tree *uccreq_tree; + guint32 chid; tvbuff_t *next_tvb; - chid = tvb_get_guint8 (tvb, 0); + it = proto_tree_add_item (tree, proto_docsis_uccreq, tvb, 0, -1, ENC_NA); + uccreq_tree = proto_item_add_subtree (it, ett_docsis_uccreq); + + proto_tree_add_item_ret_uint (uccreq_tree, hf_docsis_uccreq_upchid, tvb, 0, 1, ENC_BIG_ENDIAN, &chid); col_add_fstr (pinfo->cinfo, COL_INFO, "Upstream Channel Change request Channel ID = %u (U%u)", chid, (chid > 0 ? chid - 1 : chid)); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_uccreq, tvb, 0, -1, - "UCC Request"); - uccreq_tree = proto_item_add_subtree (it, ett_docsis_uccreq); - proto_tree_add_item (uccreq_tree, hf_docsis_uccreq_upchid, tvb, 0, 1, - ENC_BIG_ENDIAN); - - } /* call dissector for Appendix C TLV's */ next_tvb = tvb_new_subset_remaining (tvb, 1); call_dissector (docsis_tlv_handle, next_tvb, pinfo, uccreq_tree); diff --git a/plugins/docsis/packet-uccrsp.c b/plugins/docsis/packet-uccrsp.c index 54b0d678a9..47fa5f0072 100644 --- a/plugins/docsis/packet-uccrsp.c +++ b/plugins/docsis/packet-uccrsp.c @@ -43,25 +43,18 @@ dissect_uccrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da { proto_item *it; proto_tree *uccrsp_tree; - guint8 chid; + guint32 chid; - chid = tvb_get_guint8 (tvb, 0); + it = proto_tree_add_item(tree, proto_docsis_uccrsp, tvb, 0, -1, ENC_NA); + uccrsp_tree = proto_item_add_subtree (it, ett_docsis_uccrsp); + + proto_tree_add_item_ret_uint (uccrsp_tree, hf_docsis_uccrsp_upchid, tvb, 0, 1, ENC_BIG_ENDIAN, &chid); col_add_fstr (pinfo->cinfo, COL_INFO, "Upstream Channel Change response Channel ID = %u (U%u)", chid, (chid > 0 ? chid - 1 : chid)); - if (tree) - { - it = - proto_tree_add_protocol_format (tree, proto_docsis_uccrsp, tvb, 0, -1, - "UCC Response"); - uccrsp_tree = proto_item_add_subtree (it, ett_docsis_uccrsp); - proto_tree_add_item (uccrsp_tree, hf_docsis_uccrsp_upchid, tvb, 0, 1, - ENC_BIG_ENDIAN); - } - - return tvb_captured_length(tvb); + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ diff --git a/plugins/docsis/packet-ucd.c b/plugins/docsis/packet-ucd.c index 02f0e5ed0b..dab2d9861f 100644 --- a/plugins/docsis/packet-ucd.c +++ b/plugins/docsis/packet-ucd.c @@ -168,11 +168,7 @@ static const value_string on_off_vals[] = { {0, NULL} }; -static const value_string allow_inhibit_vals[] = { - {0, "Ranging Allowed"}, - {1, "Inhibit Initial Ranging"}, - {0, NULL}, -}; +static const true_false_string tfs_allow_inhibit = { "Inhibit Initial Ranging", "Ranging Allowed" }; static const value_string inhibit_allow_vals[] = { {0, "Inhibit Initial Ranging"}, @@ -227,19 +223,13 @@ static const value_string ranging_req_vals[] = { static int dissect_ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_) { - int pos, endtlvpos; - guint8 type, length; - guint8 tlvlen, tlvtype; - proto_tree *ucd_tree; - proto_item *ucd_item; - proto_tree *tlv_tree; - proto_item *tlv_item; - proto_tree *burst_tree; - proto_item *burst_item; - gint len; + int pos, tlvpos, endtlvpos; + guint32 length, tlvlen; + guint8 type, tlvtype; + proto_tree *ucd_tree, *tlv_tree, *burst_tree; + proto_item *ucd_item, *tlv_item, *tlv_len_item, *burst_item, *burst_len_item; guint8 upchid, symrate; - len = tvb_reported_length_remaining (tvb, 0); upchid = tvb_get_guint8 (tvb, 0); /* if the upstream Channel ID is 0 then this is for Telephony Return) */ @@ -252,502 +242,423 @@ dissect_ucd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data "Type 2 UCD Message: Channel ID = %u (Telephony Return)", upchid); - if (tree) - { - ucd_item = - proto_tree_add_protocol_format (tree, proto_docsis_ucd, tvb, 0, -1, - "UCD Message (Type 2)"); - ucd_tree = proto_item_add_subtree (ucd_item, ett_docsis_ucd); - proto_tree_add_item (ucd_tree, hf_docsis_ucd_upstream_chid, tvb, 0, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (ucd_tree, hf_docsis_ucd_config_ch_cnt, tvb, 1, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (ucd_tree, hf_docsis_ucd_mini_slot_size, tvb, 2, 1, - ENC_BIG_ENDIAN); - proto_tree_add_item (ucd_tree, hf_docsis_ucd_down_chid, tvb, 3, 1, - ENC_BIG_ENDIAN); - - pos = 4; - while (pos < len) - { - type = tvb_get_guint8 (tvb, pos); - tlv_tree = proto_tree_add_subtree(ucd_tree, tvb, pos, -1, + ucd_item = proto_tree_add_item(tree, proto_docsis_ucd, tvb, 0, -1, ENC_NA); + ucd_tree = proto_item_add_subtree (ucd_item, ett_docsis_ucd); + proto_tree_add_item (ucd_tree, hf_docsis_ucd_upstream_chid, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (ucd_tree, hf_docsis_ucd_config_ch_cnt, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (ucd_tree, hf_docsis_ucd_mini_slot_size, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (ucd_tree, hf_docsis_ucd_down_chid, tvb, 3, 1, ENC_BIG_ENDIAN); + + pos = 4; + while (tvb_reported_length_remaining(tvb, pos) > 0) + { + type = tvb_get_guint8 (tvb, pos); + tlv_tree = proto_tree_add_subtree(ucd_tree, tvb, pos, -1, ett_docsis_tlv, &tlv_item, val_to_str(type, channel_tlv_vals, "Unknown TLV (%u)")); - proto_tree_add_uint (tlv_tree, hf_docsis_ucd_type, - tvb, pos, 1, type); - pos++; - length = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (tlv_tree, hf_docsis_ucd_length, - tvb, pos, 1, length); - pos++; - proto_item_set_len(tlv_item, length + 2); - switch (type) - { - case UCD_SYMBOL_RATE: - if (length == 1) - { - symrate = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (tlv_tree, hf_docsis_ucd_symbol_rate, - tvb, pos, length, symrate * 160); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case UCD_FREQUENCY: - if (length == 4) - { - proto_tree_add_item (tlv_tree, hf_docsis_ucd_frequency, tvb, - pos, length, ENC_BIG_ENDIAN); - pos = pos + length; - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_PREAMBLE: - proto_tree_add_item (tlv_tree, hf_docsis_ucd_preamble_pat, tvb, - pos, length, ENC_NA); - pos = pos + length; - break; - case UCD_EXT_PREAMBLE: - proto_tree_add_item (tlv_tree, hf_docsis_ucd_ext_preamble_pat, tvb, - pos, length, ENC_NA); - pos = pos + length; - break; - case UCD_SCDMA_MODE_ENABLED: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ucd_scdma_mode_enabled, - tvb, pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case UCD_MAINTAIN_POWER_SPECTRAL_DENSITY: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ucd_maintain_power_spectral_density, - tvb, pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case UCD_RANGING_REQUIRED: - if (length == 1) - { - proto_tree_add_item (tlv_tree, hf_docsis_ucd_ranging_required, - tvb, pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case UCD_RANGING_HOLD_OFF_PRIORITY_FIELD: - if (length == 4) - { - proto_tree_add_item (tlv_tree, hf_docsis_ucd_rnghoff_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_rnghoff_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_rnghoff_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_rnghoff_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_rnghoff_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_rnghoff_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case UCD_RANGING_CHANNEL_CLASS_ID: - if (length == 4) - { - proto_tree_add_item (tlv_tree, hf_docsis_ucd_chan_class_id_cm, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_chan_class_id_erouter, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_chan_class_id_emta, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_chan_class_id_estb, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_chan_class_id_rsvd, tvb, - pos, length, ENC_BIG_ENDIAN); - proto_tree_add_item (tlv_tree, hf_docsis_ucd_chan_class_id_id_ext, tvb, - pos, length, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - pos = pos + length; - break; - case UCD_BURST_DESCR: - proto_tree_add_item (tlv_tree, hf_docsis_ucd_iuc, tvb, - pos++, 1, ENC_BIG_ENDIAN); - endtlvpos = pos + length - 1; - while (pos < endtlvpos) - { - tlvtype = tvb_get_guint8 (tvb, pos); - burst_tree = proto_tree_add_subtree (tlv_tree, tvb, pos, -1, + proto_tree_add_uint (tlv_tree, hf_docsis_ucd_type, tvb, pos, 1, type); + pos++; + tlv_len_item = proto_tree_add_item_ret_uint (tlv_tree, hf_docsis_ucd_length, tvb, pos, 1, ENC_NA, &length); + pos++; + proto_item_set_len(tlv_item, length + 2); + + switch (type) + { + case UCD_SYMBOL_RATE: + if (length == 1) + { + symrate = tvb_get_guint8 (tvb, pos); + proto_tree_add_uint (tlv_tree, hf_docsis_ucd_symbol_rate, tvb, pos, length, symrate * 160); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_FREQUENCY: + if (length == 4) + { + proto_tree_add_item (tlv_tree, hf_docsis_ucd_frequency, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_PREAMBLE: + proto_tree_add_item (tlv_tree, hf_docsis_ucd_preamble_pat, tvb, pos, length, ENC_NA); + break; + case UCD_EXT_PREAMBLE: + proto_tree_add_item (tlv_tree, hf_docsis_ucd_ext_preamble_pat, tvb, pos, length, ENC_NA); + break; + case UCD_SCDMA_MODE_ENABLED: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ucd_scdma_mode_enabled, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_MAINTAIN_POWER_SPECTRAL_DENSITY: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ucd_maintain_power_spectral_density, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_RANGING_REQUIRED: + if (length == 1) + { + proto_tree_add_item (tlv_tree, hf_docsis_ucd_ranging_required, tvb, pos, length, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_RANGING_HOLD_OFF_PRIORITY_FIELD: + if (length == 4) + { + static const int * ucd_rnghoff[] = { + &hf_docsis_ucd_rnghoff_cm, + &hf_docsis_ucd_rnghoff_erouter, + &hf_docsis_ucd_rnghoff_emta, + &hf_docsis_ucd_rnghoff_estb, + &hf_docsis_ucd_rnghoff_rsvd, + &hf_docsis_ucd_rnghoff_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(tlv_tree, tvb, pos, length, ucd_rnghoff, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_RANGING_CHANNEL_CLASS_ID: + if (length == 4) + { + static const int * ucd_chan_class_id[] = { + &hf_docsis_ucd_chan_class_id_cm, + &hf_docsis_ucd_chan_class_id_erouter, + &hf_docsis_ucd_chan_class_id_emta, + &hf_docsis_ucd_chan_class_id_estb, + &hf_docsis_ucd_chan_class_id_rsvd, + &hf_docsis_ucd_chan_class_id_id_ext, + NULL + }; + + proto_tree_add_bitmask_list(tlv_tree, tvb, pos, length, ucd_chan_class_id, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, tlv_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_BURST_DESCR: + tlvpos = pos; + endtlvpos = tlvpos + length; + proto_tree_add_item (tlv_tree, hf_docsis_ucd_iuc, tvb, tlvpos++, 1, ENC_BIG_ENDIAN); + while (tlvpos < endtlvpos) + { + tlvtype = tvb_get_guint8 (tvb, tlvpos); + burst_tree = proto_tree_add_subtree (tlv_tree, tvb, tlvpos, -1, ett_docsis_burst_tlv, &burst_item, val_to_str(tlvtype, burst_tlv_vals, "Unknown TLV (%u)")); - proto_tree_add_uint (burst_tree, hf_docsis_ucd_burst_type, tvb, pos++, 1, tlvtype); - tlvlen = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (burst_tree, hf_docsis_ucd_burst_length, tvb, pos++, 1, tlvlen); - proto_item_set_len(burst_item, tlvlen + 2); - switch (tlvtype) - { - case UCD_MODULATION: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_mod_type, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_DIFF_ENCODING: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_diff_encoding, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_PREAMBLE_LEN: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_preamble_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_PREAMBLE_VAL_OFF: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_preamble_val_off, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_FEC: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_fec, tvb, pos, - tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_FEC_CODEWORD: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_fec_codeword, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_SCRAMBLER_SEED: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_scrambler_seed, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_MAX_BURST: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_max_burst, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_GUARD_TIME: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_guard_time, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_LAST_CW_LEN: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_last_cw_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } /* switch(tlvtype) */ - pos = pos + tlvlen; - } /* while (pos < endtlvpos) */ - break; - case UCD_BURST_DESCR5: - /* DOCSIS 2.0 Upstream Channel Descriptor */ - proto_tree_add_item (tlv_tree, hf_docsis_ucd_iuc, tvb, - pos++, 1, ENC_BIG_ENDIAN); - endtlvpos = pos + length - 1; - while (pos < endtlvpos) - { - tlvtype = tvb_get_guint8 (tvb, pos); - burst_tree = proto_tree_add_subtree (tlv_tree, tvb, pos, -1, + proto_tree_add_uint (burst_tree, hf_docsis_ucd_burst_type, tvb, tlvpos++, 1, tlvtype); + burst_len_item = proto_tree_add_item_ret_uint (burst_tree, hf_docsis_ucd_burst_length, tvb, tlvpos++, 1, ENC_NA, &tlvlen); + proto_item_set_len(burst_item, tlvlen + 2); + switch (tlvtype) + { + case UCD_MODULATION: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_mod_type, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_DIFF_ENCODING: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_diff_encoding, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_PREAMBLE_LEN: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_preamble_len, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_PREAMBLE_VAL_OFF: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_preamble_val_off, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_FEC: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_fec, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_FEC_CODEWORD: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_fec_codeword, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_SCRAMBLER_SEED: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_scrambler_seed, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_MAX_BURST: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_max_burst, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_GUARD_TIME: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_guard_time, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_LAST_CW_LEN: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_last_cw_len, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_scrambler_onoff, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + } /* switch(tlvtype) */ + + tlvpos += tlvlen; + } /* while (tlvpos < endtlvpos) */ + break; + case UCD_BURST_DESCR5: + /* DOCSIS 2.0 Upstream Channel Descriptor */ + tlvpos = pos; + endtlvpos = tlvpos + length; + proto_tree_add_item (tlv_tree, hf_docsis_ucd_iuc, tvb, tlvpos++, 1, ENC_BIG_ENDIAN); + while (tlvpos < endtlvpos) + { + tlvtype = tvb_get_guint8 (tvb, tlvpos); + burst_tree = proto_tree_add_subtree (tlv_tree, tvb, tlvpos, -1, ett_docsis_burst_tlv, &burst_item, val_to_str(tlvtype, burst_tlv_vals, "Unknown TLV (%u)")); - proto_tree_add_uint (burst_tree, hf_docsis_ucd_burst_type, tvb, pos++, 1, tlvtype); - tlvlen = tvb_get_guint8 (tvb, pos); - proto_tree_add_uint (burst_tree, hf_docsis_ucd_burst_length, tvb, pos++, 1, tlvlen); - proto_item_set_len(burst_item, tlvlen + 2); - switch (tlvtype) - { - case UCD_MODULATION: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_mod_type, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_DIFF_ENCODING: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_diff_encoding, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_PREAMBLE_LEN: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_preamble_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_PREAMBLE_VAL_OFF: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_preamble_val_off, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_FEC: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_fec, tvb, pos, - tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_FEC_CODEWORD: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_fec_codeword, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_SCRAMBLER_SEED: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_scrambler_seed, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_MAX_BURST: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_max_burst, tvb, - pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_GUARD_TIME: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_guard_time, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_LAST_CW_LEN: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_last_cw_len, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_SCRAMBLER_ONOFF: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_burst_scrambler_onoff, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_RS_INT_DEPTH: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_rs_int_depth, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_RS_INT_BLOCK: - if (tlvlen == 2) - { - proto_tree_add_item (burst_tree, - hf_docsis_rs_int_block, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - case UCD_PREAMBLE_TYPE: - if (tlvlen == 1) - { - proto_tree_add_item (burst_tree, - hf_docsis_preamble_type, - tvb, pos, tlvlen, ENC_BIG_ENDIAN); - } - else - { - expert_add_info_format(pinfo, ucd_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); - } - break; - } /* switch(tlvtype) */ - pos = pos + tlvlen; - } /* while (pos < endtlvpos) */ - break; - } /* switch(type) */ - } /* while (pos < len) */ - } /* if (tree) */ - - return tvb_captured_length(tvb); + proto_tree_add_uint (burst_tree, hf_docsis_ucd_burst_type, tvb, tlvpos++, 1, tlvtype); + burst_len_item = proto_tree_add_item_ret_uint (burst_tree, hf_docsis_ucd_burst_length, tvb, tlvpos++, 1, ENC_NA, &tlvlen); + proto_item_set_len(burst_item, tlvlen + 2); + switch (tlvtype) + { + case UCD_MODULATION: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_mod_type, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_DIFF_ENCODING: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_diff_encoding, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_PREAMBLE_LEN: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_preamble_len, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_PREAMBLE_VAL_OFF: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_preamble_val_off, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_FEC: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_fec, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_FEC_CODEWORD: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_fec_codeword, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_SCRAMBLER_SEED: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_scrambler_seed, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_MAX_BURST: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_max_burst, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_GUARD_TIME: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_guard_time, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_LAST_CW_LEN: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_last_cw_len, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_SCRAMBLER_ONOFF: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_burst_scrambler_onoff, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_RS_INT_DEPTH: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_rs_int_depth, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_RS_INT_BLOCK: + if (tlvlen == 2) + { + proto_tree_add_item (burst_tree, hf_docsis_rs_int_block, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + case UCD_PREAMBLE_TYPE: + if (tlvlen == 1) + { + proto_tree_add_item (burst_tree, hf_docsis_preamble_type, tvb, tlvpos, tlvlen, ENC_BIG_ENDIAN); + } + else + { + expert_add_info_format(pinfo, burst_len_item, &ei_docsis_ucd_tlvlen_bad, "Wrong TLV length: %u", length); + } + break; + } /* switch(tlvtype) */ + tlvpos += tlvlen; + } /* while (tlvpos < endtlvpos) */ + break; + } /* switch(type) */ + pos += length; + } /* tvb_reported_length_remaining(tvb, pos) > 0 */ + + return tvb_captured_length(tvb); } /* Register the protocol with Wireshark */ @@ -832,29 +743,29 @@ proto_register_docsis_ucd (void) }, {&hf_docsis_ucd_rnghoff_cm, {"Ranging Hold-Off (CM)","docsis_ucd.rnghoffcm", - FT_UINT32, BASE_DEC, VALS (allow_inhibit_vals), 0x1, + FT_BOOLEAN, 32, TFS(&tfs_allow_inhibit), 0x1, NULL, HFILL} }, {&hf_docsis_ucd_rnghoff_erouter, {"Ranging Hold-Off (eRouter)", "docsis_ucd.rnghofferouter", - FT_UINT32, BASE_DEC, VALS (allow_inhibit_vals), 0x2, + FT_BOOLEAN, 32, TFS(&tfs_allow_inhibit), 0x2, NULL, HFILL} }, {&hf_docsis_ucd_rnghoff_emta, {"Ranging Hold-Off (eMTA or EDVA)", "docsis_ucd.rnghoffemta", - FT_UINT32, BASE_DEC, VALS (allow_inhibit_vals), 0x4, + FT_BOOLEAN, 32, TFS(&tfs_allow_inhibit), 0x4, NULL, HFILL} }, {&hf_docsis_ucd_rnghoff_estb, {"Ranging Hold-Off (DSG/eSTB)", "docsis_ucd.rnghoffestb", - FT_UINT32, BASE_DEC, VALS (allow_inhibit_vals), 0x8, + FT_BOOLEAN, 32, TFS(&tfs_allow_inhibit), 0x8, NULL, HFILL} }, {&hf_docsis_ucd_rnghoff_rsvd, - {"Reserved [0x000000]", + {"Reserved", "docsis_ucd.rnghoffrsvd", FT_UINT32, BASE_HEX, NULL, 0xFFF0, NULL, HFILL} @@ -889,7 +800,7 @@ proto_register_docsis_ucd (void) NULL, HFILL} }, {&hf_docsis_ucd_chan_class_id_rsvd, - {"Reserved [0x000000]", + {"Reserved", "docsis_ucd.classidrsvd", FT_UINT32, BASE_HEX, NULL, 0xFFF0, NULL, HFILL} @@ -990,8 +901,7 @@ proto_register_docsis_ucd (void) expert_module_t* expert_docsis_ucd; proto_docsis_ucd = - proto_register_protocol ("DOCSIS Upstream Channel Descriptor", - "DOCSIS UCD", "docsis_ucd"); + proto_register_protocol ("DOCSIS Upstream Channel Descriptor", "DOCSIS UCD", "docsis_ucd"); proto_register_field_array (proto_docsis_ucd, hf, array_length (hf)); proto_register_subtree_array (ett, array_length (ett)); -- cgit v1.2.3