[DOCSIS] Use expert info instead of THROWing bounds errors for bad lengths

Also adjust whitespace for a few places where if (tree) would mess up
expert_info use.

Change-Id: I79b8f7105515fb9ce220a46f3e875be466ee1044
Reviewed-on: https://code.wireshark.org/review/21474
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2017-05-03 09:38:29 -04:00
parent 8f6b8e29f9
commit dbae27f7b2
9 changed files with 830 additions and 714 deletions

View File

@ -25,7 +25,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
/* BPKM Attributes defined in:
* http://www.cablemodem.com/downloads/specs/SP-BPI+_I10-030730.pdf
@ -104,6 +104,7 @@ static gint ett_docsis_bpkmattr_sadsc = -1;
static gint ett_docsis_bpkmattr_saqry = -1;
static gint ett_docsis_bpkmattr_dnld = -1;
static expert_field ei_docsis_bpkmattr_tlvlen_bad = EI_INIT;
static const value_string error_code_vals[] = {
{0, "No Information"},
@ -137,7 +138,7 @@ static const value_string bpi_ver_vals[] = {
* attributes. It's called recursively, to dissect embedded attributes
*/
static void
dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, proto_item* item)
{
guint8 type;
guint16 length;
@ -145,6 +146,7 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
gint total_len;
proto_tree *cmid_tree, *tekp_tree, *scap_tree;
proto_tree *saqry_tree, *dnld_tree, *sadsc_tree;
proto_item *ti;
tvbuff_t *cmid_tvb, *tekp_tvb, *scap_tvb;
tvbuff_t *saqry_tvb, *dnld_tvb, *sadsc_tvb;
@ -167,14 +169,14 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
proto_tree_add_item (tree, hf_docsis_bpkmattr_manf_id, tvb, pos,
length, ENC_NA);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_MAC_ADDR:
if (length == 6)
proto_tree_add_item (tree, hf_docsis_bpkmattr_mac_addr, tvb, pos,
length, ENC_NA);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_RSA_PUB_KEY:
proto_tree_add_item (tree, hf_docsis_bpkmattr_rsa_pub_key, tvb, pos,
@ -183,9 +185,9 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
case BPKM_CM_ID:
cmid_tree =
proto_tree_add_subtree(tree, tvb, pos, length,
ett_docsis_bpkmattr_cmid, NULL, "5 CM Identification");
ett_docsis_bpkmattr_cmid, &ti, "5 CM Identification");
cmid_tvb = tvb_new_subset_length (tvb, pos, length);
dissect_attrs (cmid_tvb, pinfo, cmid_tree);
dissect_attrs (cmid_tvb, pinfo, cmid_tree, ti);
break;
case BPKM_DISPLAY_STR:
proto_tree_add_item (tree, hf_docsis_bpkmattr_display_str, tvb, pos,
@ -196,48 +198,48 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
proto_tree_add_item (tree, hf_docsis_bpkmattr_auth_key, tvb, pos,
length, ENC_NA);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_TEK:
if (length == 8 || length == 16)
proto_tree_add_item (tree, hf_docsis_bpkmattr_tek, tvb, pos,
length, ENC_NA);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_KEY_LIFETIME:
if (length == 4)
proto_tree_add_item (tree, hf_docsis_bpkmattr_key_life, tvb, pos,
length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_KEY_SEQ_NUM:
if (length == 1)
proto_tree_add_item (tree, hf_docsis_bpkmattr_key_seq, tvb, pos,
length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_HMAC_DIGEST:
if (length == 20)
proto_tree_add_item (tree, hf_docsis_bpkmattr_hmac_digest, tvb,
pos, length, ENC_NA);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_SAID:
if (length == 2)
proto_tree_add_item (tree, hf_docsis_bpkmattr_said, tvb, pos,
length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_TEK_PARAM:
tekp_tree =
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_bpkmattr_tekp, NULL, "13 TEK Parameters");
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_bpkmattr_tekp, &ti, "13 TEK Parameters");
tekp_tvb = tvb_new_subset_length (tvb, pos, length);
dissect_attrs (tekp_tvb, pinfo, tekp_tree);
dissect_attrs (tekp_tvb, pinfo, tekp_tree, ti);
break;
case BPKM_OBSOLETED:
break;
@ -246,14 +248,14 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
proto_tree_add_item (tree, hf_docsis_bpkmattr_cbc_iv, tvb, pos,
length, ENC_NA);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_ERROR_CODE:
if (length == 1)
proto_tree_add_item (tree, hf_docsis_bpkmattr_error_code, tvb,
pos, length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_CA_CERT:
proto_tree_add_item (tree, hf_docsis_bpkmattr_ca_cert, tvb, pos,
@ -266,16 +268,16 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
case BPKM_SEC_CAPABILITIES:
scap_tree =
proto_tree_add_subtree(tree, tvb, pos, length,
ett_docsis_bpkmattr_scap, NULL, "19 Security Capabilities");
ett_docsis_bpkmattr_scap, &ti, "19 Security Capabilities");
scap_tvb = tvb_new_subset_length (tvb, pos, length);
dissect_attrs (scap_tvb, pinfo, scap_tree);
dissect_attrs (scap_tvb, pinfo, scap_tree, ti);
break;
case BPKM_CRYPTO_SUITE:
if (length == 2)
proto_tree_add_item (tree, hf_docsis_bpkmattr_crypto_suite, tvb,
pos, length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_CRYPTO_SUITE_LIST:
proto_tree_add_item (tree, hf_docsis_bpkmattr_crypto_suite_list,
@ -286,40 +288,40 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
proto_tree_add_item (tree, hf_docsis_bpkmattr_bpi_version, tvb,
pos, length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_SA_DESCRIPTOR:
sadsc_tree =
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_bpkmattr_sadsc, NULL, "23 SA Descriptor");
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_bpkmattr_sadsc, &ti, "23 SA Descriptor");
sadsc_tvb = tvb_new_subset_length (tvb, pos, length);
dissect_attrs (sadsc_tvb, pinfo, sadsc_tree);
dissect_attrs (sadsc_tvb, pinfo, sadsc_tree, ti);
break;
case BPKM_SA_TYPE:
if (length == 1)
proto_tree_add_item (tree, hf_docsis_bpkmattr_sa_type, tvb, pos,
length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_SA_QUERY:
saqry_tree =
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_bpkmattr_saqry, NULL, "25 SA Query");
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_bpkmattr_saqry, &ti, "25 SA Query");
saqry_tvb = tvb_new_subset_length (tvb, pos, length);
dissect_attrs (saqry_tvb, pinfo, saqry_tree);
dissect_attrs (saqry_tvb, pinfo, saqry_tree, ti);
break;
case BPKM_SA_QUERY_TYPE:
if (length == 1)
proto_tree_add_item (tree, hf_docsis_bpkmattr_sa_query_type, tvb,
pos, length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_IP_ADDRESS:
if (length == 4)
proto_tree_add_item (tree, hf_docsis_bpkmattr_ip_address, tvb,
pos, length, ENC_BIG_ENDIAN);
else
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, item, &ei_docsis_bpkmattr_tlvlen_bad, "Wrong TLV length: %u", length);
break;
case BPKM_VENDOR_DEFINED:
proto_tree_add_item (tree, hf_docsis_bpkmattr_vendor_def, tvb, pos,
@ -328,9 +330,9 @@ dissect_attrs (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
case BPKM_DNLD_PARAMS:
dnld_tree =
proto_tree_add_subtree(tree, tvb, pos, length,
ett_docsis_bpkmattr_dnld, NULL, "28 Download Parameters");
ett_docsis_bpkmattr_dnld, &ti, "28 Download Parameters");
dnld_tvb = tvb_new_subset_length (tvb, pos, length);
dissect_attrs (dnld_tvb, pinfo, dnld_tree);
dissect_attrs (dnld_tvb, pinfo, dnld_tree, ti);
break;
default:
proto_tree_add_item (tree, hf_docsis_bpkmattr_vendor_def, tvb, pos,
@ -348,14 +350,11 @@ dissect_bpkmattr (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void*
proto_item *it;
proto_tree *bpkmattr_tree;
if (tree)
{
it =
proto_tree_add_protocol_format (tree, proto_docsis_bpkmattr, tvb, 0, -1,
it = proto_tree_add_protocol_format (tree, proto_docsis_bpkmattr, tvb, 0, -1,
"BPKM Attributes");
bpkmattr_tree = proto_item_add_subtree (it, ett_docsis_bpkmattr);
dissect_attrs (tvb, pinfo, bpkmattr_tree);
}
bpkmattr_tree = proto_item_add_subtree (it, ett_docsis_bpkmattr);
dissect_attrs (tvb, pinfo, bpkmattr_tree, it);
return tvb_captured_length(tvb);
}
@ -528,6 +527,12 @@ proto_register_docsis_bpkmattr (void)
&ett_docsis_bpkmattr_dnld
};
static ei_register_info ei[] = {
{&ei_docsis_bpkmattr_tlvlen_bad, { "docsis_bpkmattr.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_bpkmattr;
proto_docsis_bpkmattr =
proto_register_protocol
("DOCSIS Baseline Privacy Key Management Attributes", "DOCSIS BPKM-ATTR",
@ -535,6 +540,8 @@ proto_register_docsis_bpkmattr (void)
proto_register_field_array (proto_docsis_bpkmattr, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_bpkmattr = expert_register_protocol(proto_docsis_bpkmattr);
expert_register_field_array(expert_docsis_bpkmattr, ei, array_length(ei));
register_dissector ("docsis_bpkmattr", dissect_bpkmattr,
proto_docsis_bpkmattr);

View File

@ -24,7 +24,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
#define SEC_CH_MDD_TIMEOUT 1
#define QAM_FEC_LOCK_FAILURE 2
@ -67,12 +67,14 @@ static int hf_docsis_cmstatus_descr = -1;
static gint ett_docsis_cmstatus = -1;
static gint ett_docsis_cmstatus_tlv = -1;
static expert_field ei_docsis_cmstatus_tlvlen_bad = EI_INIT;
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, proto_tree * tree, guint8 start, guint16 len)
dissect_cmstatus_tlv (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, guint8 start, guint16 len)
{
proto_item *it;
proto_tree *tlv_tree;
@ -95,7 +97,7 @@ dissect_cmstatus_tlv (tvbuff_t * tvb, proto_tree * tree, guint8 start, guint16 l
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
@ -106,7 +108,7 @@ dissect_cmstatus_tlv (tvbuff_t * tvb, proto_tree * tree, guint8 start, guint16 l
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
@ -117,7 +119,7 @@ dissect_cmstatus_tlv (tvbuff_t * tvb, proto_tree * tree, guint8 start, guint16 l
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
@ -128,7 +130,7 @@ dissect_cmstatus_tlv (tvbuff_t * tvb, proto_tree * tree, guint8 start, guint16 l
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmstatus_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
} /* switch */
@ -200,7 +202,7 @@ dissect_cmstatus (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void*
}
/* Call Dissector TLV's */
dissect_cmstatus_tlv(tvb, cmstatus_tree, 3, len);
dissect_cmstatus_tlv(tvb, pinfo, cmstatus_tree, 3, len);
return tvb_captured_length(tvb);
}
@ -258,15 +260,24 @@ proto_register_docsis_cmstatus (void)
}
};
static gint *ett[] = {
&ett_docsis_cmstatus,
&ett_docsis_cmstatus_tlv
};
static gint *ett[] = {
&ett_docsis_cmstatus,
&ett_docsis_cmstatus_tlv
};
static ei_register_info ei[] = {
{&ei_docsis_cmstatus_tlvlen_bad, { "docsis_cmstatus.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_cmstatus;
proto_docsis_cmstatus = proto_register_protocol ("DOCSIS CM-STATUS Report", "DOCSIS CM-STATUS", "docsis_cmstatus");
proto_register_field_array (proto_docsis_cmstatus, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_cmstatus = expert_register_protocol(proto_docsis_cmstatus);
expert_register_field_array(expert_docsis_cmstatus, ei, array_length(ei));
docsis_cmstatus_handle = register_dissector ("docsis_cmstatus", dissect_cmstatus, proto_docsis_cmstatus);
}

View File

@ -24,7 +24,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
void proto_register_docsis_dccack(void);
void proto_reg_handoff_docsis_dccack(void);
@ -42,6 +42,8 @@ static int hf_docsis_dccack_hmac_digest = -1;
/* Initialize the subtree pointers */
static gint ett_docsis_dccack = -1;
static expert_field ei_docsis_dccack_tlvlen_bad = EI_INIT;
static dissector_handle_t docsis_dccack_handle;
/* Dissection */
@ -58,47 +60,45 @@ dissect_dccack (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da
col_set_str(pinfo->cinfo, COL_INFO, "DCC-ACK Message: ");
if (tree)
{
dcc_item =
dcc_item =
proto_tree_add_protocol_format (tree, proto_docsis_dccack, tvb, 0,
-1, "DCC-ACK Message");
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);
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)
pos = 2;
while (pos < len)
{
type = tvb_get_guint8 (tvb, pos++);
length = tvb_get_guint8 (tvb, pos++);
switch (type)
{
type = tvb_get_guint8 (tvb, pos++);
length = tvb_get_guint8 (tvb, pos++);
switch (type)
case DCCACK_KEY_SEQ_NUM:
if (length == 1)
{
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
{
THROW (ReportedBoundsError);
}
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
{
THROW (ReportedBoundsError);
}
break;
} /* switch(type) */
pos = pos + length;
} /* while (pos < len) */
} /* if (tree) */
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);
}
@ -141,12 +141,20 @@ proto_register_docsis_dccack (void)
&ett_docsis_dccack,
};
static ei_register_info ei[] = {
{&ei_docsis_dccack_tlvlen_bad, { "docsis_dccack.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_dccack;
proto_docsis_dccack =
proto_register_protocol ("DOCSIS Downstream Channel Change Acknowledge",
"DOCSIS DCC-ACK", "docsis_dccack");
proto_register_field_array (proto_docsis_dccack, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_dccack = expert_register_protocol(proto_docsis_dccack);
expert_register_field_array(expert_docsis_dccack, ei, array_length(ei));
docsis_dccack_handle = register_dissector ("docsis_dccack", dissect_dccack, proto_docsis_dccack);
}

View File

@ -24,7 +24,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
void proto_register_docsis_dccreq(void);
void proto_reg_handoff_docsis_dccreq(void);
@ -87,6 +87,8 @@ static gint ett_docsis_dccreq = -1;
static gint ett_docsis_dccreq_ds_params = -1;
static gint ett_docsis_dccreq_sf_sub = -1;
static expert_field ei_docsis_dccreq_tlvlen_bad = EI_INIT;
static dissector_handle_t docsis_dccreq_handle;
value_string ds_mod_type_vals[] = {
@ -112,14 +114,15 @@ value_string init_tech_vals[] = {
/* Dissection */
static void
dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dccreq_ds_params (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcc_tree;
proto_item *dcc_item;
int pos;
pos = start;
dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccreq_ds_params, NULL,
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) )
@ -137,7 +140,7 @@ dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_DS_MOD_TYPE:
@ -148,7 +151,7 @@ dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_DS_SYM_RATE:
@ -159,7 +162,7 @@ dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_DS_INTLV_DEPTH:
@ -172,7 +175,7 @@ dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_DS_CHAN_ID:
@ -183,7 +186,7 @@ dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_DS_SYNC_SUB:
@ -197,14 +200,15 @@ dissect_dccreq_ds_params (tvbuff_t * tvb, proto_tree * tree, int start, guint16
}
static void
dissect_dccreq_sf_sub (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dccreq_sf_sub (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcc_tree;
proto_item *dcc_item;
int pos;
pos = start;
dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccreq_sf_sub, NULL, "7 DCC-REQ Service Flow Substitution Encodings (Length = %u)", len);
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) )
{
@ -223,7 +227,7 @@ dissect_dccreq_sf_sub (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_SF_SID:
@ -236,7 +240,7 @@ dissect_dccreq_sf_sub (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCREQ_SF_UNSOL_GRANT_TREF:
@ -247,7 +251,7 @@ dissect_dccreq_sf_sub (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccreq_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
}
@ -268,105 +272,102 @@ dissect_dccreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da
col_set_str(pinfo->cinfo, COL_INFO, "DCC-REQ Message: ");
if (tree)
{
dcc_item =
proto_tree_add_protocol_format (tree, proto_docsis_dccreq, tvb, 0,
-1, "DCC-REQ Message");
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);
dcc_item =
proto_tree_add_protocol_format (tree, proto_docsis_dccreq, tvb, 0,
-1, "DCC-REQ Message");
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)
pos = 2;
while (pos < len)
{
type = tvb_get_guint8 (tvb, pos++);
length = tvb_get_guint8 (tvb, pos++);
switch (type)
{
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
{
THROW (ReportedBoundsError);
}
break;
case DCCREQ_DS_PARAMS:
dissect_dccreq_ds_params (tvb , 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
{
THROW (ReportedBoundsError);
}
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
{
THROW (ReportedBoundsError);
}
break;
case DCCREQ_SF_SUB:
dissect_dccreq_sf_sub (tvb , 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
{
THROW (ReportedBoundsError);
}
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
{
THROW (ReportedBoundsError);
}
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
{
THROW (ReportedBoundsError);
}
break;
} /* switch(type) */
pos = pos + length;
} /* while (pos < len) */
} /* if (tree) */
return tvb_captured_length(tvb);
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) */
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
@ -572,12 +573,20 @@ proto_register_docsis_dccreq (void)
&ett_docsis_dccreq_ds_params,
};
static ei_register_info ei[] = {
{&ei_docsis_dccreq_tlvlen_bad, { "docsis_dccreq.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_dccreq;
proto_docsis_dccreq =
proto_register_protocol ("DOCSIS Downstream Channel Change Request",
"DOCSIS DCC-REQ", "docsis_dccreq");
proto_register_field_array (proto_docsis_dccreq, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_dccreq = expert_register_protocol(proto_docsis_dccreq);
expert_register_field_array(expert_docsis_dccreq, ei, array_length(ei));
docsis_dccreq_handle = register_dissector ("docsis_dccreq", dissect_dccreq, proto_docsis_dccreq);
}

View File

@ -24,7 +24,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
void proto_register_docsis_dccrsp(void);
void proto_reg_handoff_docsis_dccrsp(void);
@ -53,18 +53,21 @@ static int hf_docsis_dccrsp_hmac_digest = -1;
static gint ett_docsis_dccrsp = -1;
static gint ett_docsis_dccrsp_cm_jump_time = -1;
static expert_field ei_docsis_dccrsp_tlvlen_bad = EI_INIT;
static dissector_handle_t docsis_dccrsp_handle;
/* Dissection */
static void
dissect_dccrsp_cm_jump_time (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dccrsp_cm_jump_time (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcc_tree;
proto_item *dcc_item;
int pos;
pos = start;
dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccrsp_cm_jump_time, NULL,
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) )
@ -82,7 +85,7 @@ dissect_dccrsp_cm_jump_time (tvbuff_t * tvb, proto_tree * tree, int start, guint
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCCRSP_CM_JUMP_TIME_START:
@ -93,7 +96,7 @@ dissect_dccrsp_cm_jump_time (tvbuff_t * tvb, proto_tree * tree, int start, guint
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcc_item, &ei_docsis_dccrsp_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
}
@ -114,53 +117,50 @@ dissect_dccrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da
col_set_str(pinfo->cinfo, COL_INFO, "DCC-RSP Message: ");
if (tree)
{
dcc_item =
dcc_item =
proto_tree_add_protocol_format (tree, proto_docsis_dccrsp, tvb, 0,
-1, "DCC-RSP Message");
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);
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)
pos = 3;
while (pos < len)
{
type = tvb_get_guint8 (tvb, pos++);
length = tvb_get_guint8 (tvb, pos++);
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 , 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
{
THROW (ReportedBoundsError);
}
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
{
THROW (ReportedBoundsError);
}
break;
} /* switch(type) */
pos = pos + length;
} /* while (pos < len) */
} /* if (tree) */
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) */
return tvb_captured_length(tvb);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
@ -230,12 +230,20 @@ proto_register_docsis_dccrsp (void)
&ett_docsis_dccrsp_cm_jump_time,
};
static ei_register_info ei[] = {
{&ei_docsis_dccrsp_tlvlen_bad, { "docsis_dccrsp.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_dccrsp;
proto_docsis_dccrsp =
proto_register_protocol ("DOCSIS Downstream Channel Change Response",
"DOCSIS DCC-RSP", "docsis_dccrsp");
proto_register_field_array (proto_docsis_dccrsp, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_dccrsp = expert_register_protocol(proto_docsis_dccrsp);
expert_register_field_array(expert_docsis_dccrsp, ei, array_length(ei));
docsis_dccrsp_handle = register_dissector ("docsis_dccrsp", dissect_dccrsp, proto_docsis_dccrsp);
}

View File

@ -24,7 +24,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
void proto_register_docsis_dcd(void);
void proto_reg_handoff_docsis_dcd(void);
@ -124,19 +124,22 @@ static gint ett_docsis_dcd_rule = -1;
static gint ett_docsis_dcd_clid = -1;
static gint ett_docsis_dcd_cfg = -1;
static expert_field ei_docsis_dcd_tlvlen_bad = EI_INIT;
static dissector_handle_t docsis_dcd_handle;
/* Dissection */
static void
dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dcd_dsg_cfg (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcd_tree;
proto_item *dcd_item;
int pos;
pos = start;
dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len,
ett_docsis_dcd_cfg, NULL, "51 DCD DSG Config Encodings (Length = %u)", len);
ett_docsis_dcd_cfg, &dcd_item, "51 DCD DSG Config Encodings (Length = %u)", len);
while ( pos < ( start + len) )
{
@ -153,7 +156,7 @@ dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFG_TDSG1:
@ -164,7 +167,7 @@ dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFG_TDSG2:
@ -175,7 +178,7 @@ dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFG_TDSG3:
@ -186,7 +189,7 @@ dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFG_TDSG4:
@ -197,7 +200,7 @@ dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFG_VENDOR_SPEC:
@ -211,14 +214,15 @@ dissect_dcd_dsg_cfg (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
static void
dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dcd_down_classifier_ip (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcd_tree;
proto_item *dcd_item;
int pos;
pos = start;
dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_cfr_ip, NULL, "23.9 DCD_CFR_IP Encodings (Length = %u)", len);
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) )
{
@ -235,7 +239,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_IP_SOURCE_MASK:
@ -246,7 +250,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_IP_DEST_ADDR:
@ -257,7 +261,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_IP_DEST_MASK:
@ -268,7 +272,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_TCPUDP_SRCPORT_START:
@ -279,7 +283,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_TCPUDP_SRCPORT_END:
@ -290,7 +294,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_TCPUDP_DSTPORT_START:
@ -301,7 +305,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_TCPUDP_DSTPORT_END:
@ -312,7 +316,7 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
}
@ -321,14 +325,15 @@ dissect_dcd_down_classifier_ip (tvbuff_t * tvb, proto_tree * tree, int start, gu
}
static void
dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dcd_clid (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcd_tree;
proto_item *dcd_item;
int pos;
pos = start;
dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_clid, NULL, "50.4 DCD Rule ClientID Encodings (Length = %u)", len);
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) )
{
@ -344,7 +349,7 @@ dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CLID_KNOWN_MAC_ADDR:
@ -355,7 +360,7 @@ dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CLID_CA_SYS_ID:
@ -366,7 +371,7 @@ dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CLID_APP_ID:
@ -377,7 +382,7 @@ dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
}
@ -386,14 +391,15 @@ dissect_dcd_clid (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
static void
dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dcd_dsg_rule (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcd_tree;
proto_item *dcd_item;
int pos;
pos = start;
dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_rule, NULL, "50 DCD DSG Rule Encodings (Length = %u)", len);
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) )
{
@ -410,7 +416,7 @@ dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_RULE_PRI:
@ -421,7 +427,7 @@ dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_RULE_UCID_RNG:
@ -429,7 +435,7 @@ dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
pos, length, ENC_NA);
break;
case DCD_RULE_CLIENT_ID:
dissect_dcd_clid (tvb , dcd_tree , pos , length );
dissect_dcd_clid (tvb , pinfo , dcd_tree , pos , length );
break;
case DCD_RULE_TUNL_ADDR:
if (length == 6)
@ -439,7 +445,7 @@ dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_RULE_CFR_ID:
@ -450,7 +456,7 @@ dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_RULE_VENDOR_SPEC:
@ -464,14 +470,15 @@ dissect_dcd_dsg_rule (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
}
static void
dissect_dcd_down_classifier (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len)
dissect_dcd_down_classifier (tvbuff_t * tvb, packet_info* pinfo, proto_tree * tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *dcd_tree;
proto_tree *dcd_item;
int pos;
pos = start;
dcd_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dcd_cfr, NULL, "23 DCD_CFR Encodings (Length = %u)", len);
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) )
{
@ -488,7 +495,7 @@ dissect_dcd_down_classifier (tvbuff_t * tvb, proto_tree * tree, int start, guint
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, dcd_item, &ei_docsis_dcd_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DCD_CFR_RULE_PRI:
@ -499,11 +506,11 @@ dissect_dcd_down_classifier (tvbuff_t * tvb, proto_tree * tree, int start, guint
}
else
{
THROW (ReportedBoundsError);
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 , dcd_tree , pos , length );
dissect_dcd_down_classifier_ip (tvb , pinfo , dcd_tree , pos , length );
break;
}
@ -524,39 +531,36 @@ dissect_dcd (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data
col_set_str(pinfo->cinfo, COL_INFO, "DCD Message: ");
if (tree)
{
dcd_item =
dcd_item =
proto_tree_add_protocol_format (tree, proto_docsis_dcd, tvb, 0,
tvb_captured_length(tvb),
"DCD Message");
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);
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)
pos = 3;
while (pos < len)
{
type = tvb_get_guint8 (tvb, pos++);
length = tvb_get_guint8 (tvb, pos++);
switch (type)
{
type = tvb_get_guint8 (tvb, pos++);
length = tvb_get_guint8 (tvb, pos++);
switch (type)
{
case DCD_DOWN_CLASSIFIER:
dissect_dcd_down_classifier (tvb , dcd_tree , pos , length );
break;
case DCD_DSG_RULE:
dissect_dcd_dsg_rule (tvb , dcd_tree , pos , length );
break;
case DCD_DSG_CONFIG:
dissect_dcd_dsg_cfg (tvb , dcd_tree , pos , length );
break;
} /* switch(type) */
pos = pos + length;
} /* while (pos < len) */
} /* if (tree) */
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) */
return tvb_captured_length(tvb);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
@ -838,12 +842,20 @@ proto_register_docsis_dcd (void)
&ett_docsis_dcd_cfg,
};
static ei_register_info ei[] = {
{&ei_docsis_dcd_tlvlen_bad, { "docsis_dcd.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_dcd;
proto_docsis_dcd =
proto_register_protocol ("DOCSIS Downstream Channel Descriptor",
"DOCSIS DCD", "docsis_dcd");
proto_register_field_array (proto_docsis_dcd, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_dcd = expert_register_protocol(proto_docsis_dcd);
expert_register_field_array(expert_docsis_dcd, ei, array_length(ei));
docsis_dcd_handle = register_dissector ("docsis_dcd", dissect_dcd, proto_docsis_dcd);
}

View File

@ -24,7 +24,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
#define CM_CTRL_MUTE 1
#define CM_CTRL_MUTE_TIMEOUT 2
@ -64,16 +64,19 @@ static gint ett_cmctrl_tlv = -1;
static gint ett_cmctrl_tlv_ds_event = -1;
static gint ett_cmctrl_tlv_us_event = -1;
static expert_field ei_docsis_cmctrl_tlv_tlvlen_bad = EI_INIT;
/* Dissection */
static void
dissect_ds_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
dissect_ds_event(tvbuff_t * tvb, packet_info* pinfo, proto_tree *tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *event_tree;
proto_item *event_item;
int pos = start;
event_tree =
proto_tree_add_subtree_format(tree, tvb, start, len, ett_cmctrl_tlv_ds_event, NULL,
proto_tree_add_subtree_format(tree, tvb, start, len, ett_cmctrl_tlv_ds_event, &event_item,
"Override Downstream Status Event Event Mask (Length = %u)", len);
while (pos < (start + len))
@ -90,7 +93,7 @@ dissect_ds_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, event_item, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case DS_EVENT_MASK:
@ -101,7 +104,7 @@ dissect_ds_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, event_item, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
} /* switch */
@ -110,14 +113,15 @@ dissect_ds_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
}
static void
dissect_us_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
dissect_us_event(tvbuff_t * tvb, packet_info* pinfo, proto_tree *tree, int start, guint16 len)
{
guint8 type, length;
proto_tree *event_tree;
proto_item *event_item;
int pos = start;
event_tree =
proto_tree_add_subtree_format(tree, tvb, start, len, ett_cmctrl_tlv_us_event, NULL,
proto_tree_add_subtree_format(tree, tvb, start, len, ett_cmctrl_tlv_us_event, &event_item,
"Override Upstream Status Enable Event Mask (Length = %u)", len);
while (pos < (start + len))
@ -134,7 +138,7 @@ dissect_us_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, event_item, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case US_EVENT_MASK:
@ -145,7 +149,7 @@ dissect_us_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, event_item, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
} /* switch */
@ -154,7 +158,7 @@ dissect_us_event(tvbuff_t * tvb, proto_tree *tree, int start, guint16 len)
}
static int
dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void* data _U_)
dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
{
proto_item *it;
proto_tree *tlv_tree;
@ -183,7 +187,7 @@ dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case CM_CTRL_MUTE_TIMEOUT:
@ -194,7 +198,7 @@ dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case CM_CTRL_REINIT:
@ -205,7 +209,7 @@ dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case CM_CTRL_DISABLE_FWD:
@ -216,7 +220,7 @@ dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case CM_CTRL_DS_EVENT:
@ -224,14 +228,14 @@ dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
proto_tree_add_item (tlv_tree, hf_cmctrl_tlv_ds_event,
tvb, pos, length, ENC_NA);
else
dissect_ds_event(tvb, tlv_tree, pos, length);
dissect_ds_event(tvb, pinfo, tlv_tree, pos, length);
break;
case CM_CTRL_US_EVENT:
if (length == 1)
proto_tree_add_item (tlv_tree, hf_cmctrl_tlv_ds_event,
tvb, pos, length, ENC_NA);
else
dissect_us_event(tvb, tlv_tree, pos, length);
dissect_us_event(tvb, pinfo, tlv_tree, pos, length);
break;
case CM_CTRL_EVENT:
if (length == 2 || length == 1) /* response TLV always with len 1 */
@ -241,7 +245,7 @@ dissect_cmctrl_tlv (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree,
}
else
{
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, it, &ei_docsis_cmctrl_tlv_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
@ -321,11 +325,19 @@ proto_register_cmctrl_tlv (void)
&ett_cmctrl_tlv_us_event,
};
static ei_register_info ei[] = {
{&ei_docsis_cmctrl_tlv_tlvlen_bad, { "cmctrl_tlv.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
};
expert_module_t* expert_docsis_cmctrl_tlv;
proto_cmctrl_tlv = proto_register_protocol ("DOCSIS CM-CTRL TLV's",
"DOCSIS CM-CTRL TLVs", "cmctrl_tlv");
proto_register_field_array (proto_cmctrl_tlv, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_cmctrl_tlv = expert_register_protocol(proto_cmctrl_tlv);
expert_register_field_array(expert_docsis_cmctrl_tlv, ei, array_length(ei));
register_dissector ("cmctrl_tlv", dissect_cmctrl_tlv, proto_cmctrl_tlv);
}

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/expert.h>
/* Define Vendor ID's here */
#define VENDOR_CISCO 0x00000C
@ -64,73 +64,14 @@ static int hf_docsis_vsif_cisco_config_file = -1;
static gint ett_docsis_vsif = -1;
static gint ett_docsis_vsif_ipprec = -1;
static expert_field ei_docsis_vsif_tlvlen_bad = EI_INIT;
static expert_field ei_docsis_vsif_tlvtype_unknown = EI_INIT;
static const value_string vendorid_vals[] = {
{VENDOR_CISCO, "Cisco Systems, Inc."},
{0, NULL},
};
/* Forward Declarations for vendor specific dissectors */
static void dissect_cisco (tvbuff_t * tvb, proto_tree * tree,
gint vsif_len);
/* Dissection */
static int
dissect_vsif (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void* data _U_)
{
proto_item *it;
proto_tree *vsif_tree;
guint8 type;
guint8 length;
guint32 value;
gint vsif_len;
/* get the reported length of the VSIF TLV */
vsif_len = tvb_reported_length_remaining (tvb, 0);
/* The first TLV in the VSIF encodings must be type 0x08 (Vendor ID) and
* length 3.
*/
type = tvb_get_guint8 (tvb, 0);
if (type != 0x08)
{
THROW (ReportedBoundsError);
}
length = tvb_get_guint8 (tvb, 1);
if (length != 3)
{
THROW (ReportedBoundsError);
}
/* Extract the Value of the Vendor ID */
value = tvb_get_ntoh24 (tvb, 2);
if (tree)
{
it =
proto_tree_add_protocol_format (tree, proto_docsis_vsif, tvb, 0, -1,
"VSIF Encodings");
vsif_tree = proto_item_add_subtree (it, ett_docsis_vsif);
proto_tree_add_item (vsif_tree, hf_docsis_vsif_vendorid, tvb, 2, 3, ENC_BIG_ENDIAN);
/* switch on the Vendor ID */
switch (value)
{
case VENDOR_CISCO:
proto_item_append_text (it, " (Cisco)");
dissect_cisco (tvb, vsif_tree, vsif_len);
break;
default:
proto_item_append_text (it, " (Unknown)");
proto_tree_add_item (vsif_tree, hf_docsis_vsif_vendor_unknown, tvb,
0, -1, ENC_NA);
break;
}
} /* if(tree) */
return tvb_captured_length(tvb);
}
/* Dissector for Cisco Vendor Specific TLV's */
#define NUM_PHONES 0x0a
@ -140,12 +81,13 @@ dissect_vsif (tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, void*
#define IP_PREC_BW 0x02
static void
dissect_cisco (tvbuff_t * tvb, proto_tree * tree, gint vsif_len)
dissect_cisco (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, gint vsif_len)
{
/* Start at pos = 5, since tvb includes the Vendor ID field */
int pos = 5;
guint8 type, length;
proto_tree *ipprec_tree;
proto_item *ipprec_item;
int templen;
while (pos < vsif_len)
@ -161,7 +103,7 @@ dissect_cisco (tvbuff_t * tvb, proto_tree * tree, gint vsif_len)
break;
case IP_PREC:
ipprec_tree =
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_vsif_ipprec, NULL, "IP Precedence");
proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_vsif_ipprec, &ipprec_item, "IP Precedence");
/* Handle Sub-TLVs in IP Precedence */
templen = pos + length;
while (pos < templen)
@ -171,21 +113,31 @@ dissect_cisco (tvbuff_t * tvb, proto_tree * tree, gint vsif_len)
switch (type)
{
case IP_PREC_VAL:
if (length != 1)
THROW (ReportedBoundsError);
proto_tree_add_item (ipprec_tree,
if (length == 1)
{
proto_tree_add_item (ipprec_tree,
hf_docsis_vsif_cisco_ipprec_val, tvb,
pos, length, ENC_BIG_ENDIAN);
}
else
{
expert_add_info_format(pinfo, ipprec_item, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
case IP_PREC_BW:
if (length != 4)
THROW (ReportedBoundsError);
proto_tree_add_item (ipprec_tree,
{
proto_tree_add_item (ipprec_tree,
hf_docsis_vsif_cisco_ipprec_bw, tvb,
pos, length, ENC_BIG_ENDIAN);
}
else
{
expert_add_info_format(pinfo, ipprec_item, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
}
break;
default:
THROW (ReportedBoundsError);
expert_add_info_format(pinfo, ipprec_item, &ei_docsis_vsif_tlvtype_unknown, "Unknown TLV: %u", type);
}
pos += length;
}
@ -198,6 +150,53 @@ dissect_cisco (tvbuff_t * tvb, proto_tree * tree, gint vsif_len)
}
}
/* Dissection */
static int
dissect_vsif (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
{
proto_item *it;
proto_tree *vsif_tree;
guint8 type;
guint8 length;
guint32 value;
gint vsif_len;
/* get the reported length of the VSIF TLV */
vsif_len = tvb_reported_length_remaining (tvb, 0);
it = proto_tree_add_protocol_format (tree, proto_docsis_vsif, tvb, 0, -1,
"VSIF Encodings");
vsif_tree = proto_item_add_subtree (it, ett_docsis_vsif);
proto_tree_add_item_ret_uint(vsif_tree, hf_docsis_vsif_vendorid, tvb, 2, 3, ENC_BIG_ENDIAN, &value);
/* The first TLV in the VSIF encodings must be type 0x08 (Vendor ID) and
* length 3.
*/
type = tvb_get_guint8 (tvb, 0);
if (type != 0x08)
expert_add_info_format(pinfo, it, &ei_docsis_vsif_tlvtype_unknown, "Unknown TLV: %u", type);
length = tvb_get_guint8 (tvb, 1);
if (length != 3)
expert_add_info_format(pinfo, it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
/* switch on the Vendor ID */
switch (value)
{
case VENDOR_CISCO:
proto_item_append_text (it, " (Cisco)");
dissect_cisco (tvb, pinfo, vsif_tree, vsif_len);
break;
default:
proto_item_append_text (it, " (Unknown)");
proto_tree_add_item (vsif_tree, hf_docsis_vsif_vendor_unknown, tvb,
0, -1, ENC_NA);
break;
}
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_docsis_vsif (void)
@ -247,12 +246,21 @@ proto_register_docsis_vsif (void)
&ett_docsis_vsif_ipprec,
};
expert_module_t* expert_docsis_vsif;
static ei_register_info ei[] = {
{&ei_docsis_vsif_tlvlen_bad, { "docsis_vsif.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
{&ei_docsis_vsif_tlvtype_unknown, { "docsis_vsif.tlvtypeunknown", PI_PROTOCOL, PI_WARN, "Unknown TLV type", EXPFILL}},
};
proto_docsis_vsif =
proto_register_protocol ("DOCSIS Vendor Specific Encodings",
"DOCSIS VSIF", "docsis_vsif");
proto_register_field_array (proto_docsis_vsif, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_docsis_vsif = expert_register_protocol(proto_docsis_vsif);
expert_register_field_array(expert_docsis_vsif, ei, array_length(ei));
register_dissector ("docsis_vsif", dissect_vsif, proto_docsis_vsif);
}