aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-snmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-snmp.c')
-rw-r--r--epan/dissectors/packet-snmp.c107
1 files changed, 49 insertions, 58 deletions
diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c
index 1052a83f56..a92c44f4e3 100644
--- a/epan/dissectors/packet-snmp.c
+++ b/epan/dissectors/packet-snmp.c
@@ -237,6 +237,7 @@ static int hf_snmp_objectname = -1;
static int hf_snmp_scalar_instance_index = -1;
static int hf_snmp_var_bind_str = -1;
+static int hf_snmp_agentid_trailer = -1;
/*--- Included file: packet-snmp-hf.c ---*/
@@ -308,7 +309,7 @@ static int hf_snmp_priority = -1; /* INTEGER_M1_2147483647 */
static int hf_snmp_operation = -1; /* T_operation */
/*--- End of included file: packet-snmp-hf.c ---*/
-#line 234 "../../asn1/snmp/packet-snmp-template.c"
+#line 235 "../../asn1/snmp/packet-snmp-template.c"
static int hf_smux_version = -1;
static int hf_smux_pdutype = -1;
@@ -351,7 +352,7 @@ static gint ett_snmp_SimpleOpen_U = -1;
static gint ett_snmp_RReqPDU_U = -1;
/*--- End of included file: packet-snmp-ett.c ---*/
-#line 253 "../../asn1/snmp/packet-snmp-template.c"
+#line 254 "../../asn1/snmp/packet-snmp-template.c"
static expert_field ei_snmp_failed_decrypted_data_pdu = EI_INIT;
static expert_field ei_snmp_decrypted_data_bad_formatted = EI_INIT;
@@ -380,6 +381,9 @@ static expert_field ei_snmp_integral_value0 = EI_INIT;
static expert_field ei_snmp_missing_mib = EI_INIT;
static expert_field ei_snmp_varbind_wrong_length_value = EI_INIT;
static expert_field ei_snmp_varbind_wrong_class_tag = EI_INIT;
+static expert_field ei_snmp_rfc1910_non_conformant = EI_INIT;
+static expert_field ei_snmp_rfc3411_non_conformant = EI_INIT;
+static expert_field ei_snmp_version_unknown = EI_INIT;
static const true_false_string auth_flags = {
"OK",
@@ -783,14 +787,12 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
goto set_label;
} else {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"A scalar should have one instance sub-id this one has none");
- expert_add_info(actx->pinfo, pi, &ei_snmp_no_instance_subid);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_no_instance_subid,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
} else {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"A scalar should have only one instance sub-id this has: %d",oid_left);
- expert_add_info(actx->pinfo, pi, &ei_snmp_wrong_num_of_subids);
+ proto_tree_add_expert_format(pt_name,actx->pinfo,&ei_snmp_wrong_num_of_subids,tvb,0,0,"A scalar should have only one instance sub-id this has: %d",oid_left);
oid_info_is_ok = FALSE;
goto indexing_done;
}
@@ -813,16 +815,14 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
guint suboid_len;
if (key_start >= oid_matched+oid_left) {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"index sub-oid shorter than expected");
- expert_add_info(actx->pinfo, pi, &ei_snmp_index_suboid_too_short);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_short,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
switch(k->key_type) {
case OID_KEY_TYPE_WRONG: {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"OID instaces not handled, if you want this implemented please contact the wireshark developers");
- expert_add_info(actx->pinfo, pi, &ei_snmp_unimplemented_instance_index);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
@@ -853,15 +853,13 @@ show_oid_index:
suboid = &(subids[key_start]);
if( suboid_len == 0 ) {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"an index sub-oid OID cannot be 0 bytes long!");
- expert_add_info(actx->pinfo, pi, &ei_snmp_index_suboid_len0);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_len0,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
if( key_len < suboid_len ) {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"index sub-oid should not be longer than remaining oid size");
- expert_add_info(actx->pinfo, pi, &ei_snmp_index_suboid_too_long);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_long,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
@@ -907,8 +905,7 @@ show_oid_index:
}
if( key_len < buf_len ) {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"index string should not be longer than remaining oid size");
- expert_add_info(actx->pinfo, pi, &ei_snmp_index_string_too_long);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_string_too_long,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
@@ -949,20 +946,17 @@ show_oid_index:
}
goto indexing_done;
} else {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"We do not know how to handle this OID, if you want this implemented please contact the wireshark developers");
- expert_add_info(actx->pinfo, pi, &ei_snmp_unimplemented_instance_index);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
} else {
- proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"The COLUMS's parent is not a ROW. This is a BUG! please contact the wireshark developers.");
- expert_add_info(actx->pinfo, pi, &ei_snmp_column_parent_not_row);
+ proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_column_parent_not_row,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
default: {
-/* proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"This kind OID should have no value");
- expert_add_info_format(actx->pinfo, pi, PI_MALFORMED, PI_WARN, "This kind OID should have no value"); */
+/* proto_tree_add_expert (pt_name,actx->pinfo,PI_MALFORMED, PI_WARN,tvb,0,0,"This kind OID should have no value"); */
oid_info_is_ok = FALSE;
goto indexing_done;
}
@@ -1083,8 +1077,7 @@ indexing_done:
*/
if (value_len > 9 || tvb_get_guint8(tvb, value_offset) != 0) {
/* It is. Fail. */
- pi_value = proto_tree_add_text(pt_varbind,tvb,value_offset,value_len,"Integral value too large");
- expert_add_info(actx->pinfo, pi_value, &ei_snmp_uint_too_large);
+ proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_uint_too_large,tvb,value_offset,value_len,"Integral value too large");
goto already_added;
}
/* Cheat and skip the leading 0 byte */
@@ -1094,8 +1087,7 @@ indexing_done:
/*
* For now, just reject these.
*/
- pi_value = proto_tree_add_text(pt_varbind,tvb,value_offset,value_len,"Integral value too large or too small");
- expert_add_info(actx->pinfo, pi_value, &ei_snmp_int_too_large);
+ proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_int_too_large,tvb,value_offset,value_len,"Integral value too large or too small");
goto already_added;
}
} else if (value_len == 0) {
@@ -1109,8 +1101,7 @@ indexing_done:
*/
header_field_info *hfinfo = proto_registrar_get_nth(hfid);
if (hfinfo->type == FT_UINT64 || hfinfo->type == FT_INT64) {
- pi_value = proto_tree_add_text(pt_varbind,tvb,value_offset,value_len,"Integral value is zero-length");
- expert_add_info(actx->pinfo, pi_value, &ei_snmp_integral_value0);
+ proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_integral_value0,tvb,value_offset,value_len,"Integral value is zero-length");
goto already_added;
}
}
@@ -1234,7 +1225,7 @@ static const value_string snmp_engineid_cisco_type_vals[] = {
* or historic RFC 1910 (AgentID)
*/
int
-dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
+dissect_snmp_engineid(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, int len)
{
proto_item *item = NULL;
guint8 conformance, format;
@@ -1261,13 +1252,12 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
case SNMP_ENGINEID_RFC1910:
/* 12-byte AgentID w/ 8-byte trailer */
if (len_remain==8) {
- proto_tree_add_text(tree, tvb, offset, 8, "AgentID Trailer: 0x%s",
- tvb_bytes_to_ep_str(tvb, offset, 8));
- offset+=8;
- len_remain-=8;
+ proto_tree_add_item(tree, hf_snmp_agentid_trailer, tvb, offset, 8, ENC_NA);
+ offset+=8;
+ len_remain-=8;
} else {
- proto_tree_add_text(tree, tvb, offset, len_remain, "<Data not conforming to RFC1910>");
- return offset;
+ proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain);
+ return offset;
}
break;
@@ -1352,7 +1342,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
}
if (len_remain>0) {
- proto_tree_add_text(tree, tvb, offset, len_remain, "<Data not conforming to RFC3411>");
+ proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain);
offset+=len_remain;
}
return offset;
@@ -2488,7 +2478,7 @@ dissect_snmp_SnmpEngineID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offs
&param_tvb);
if (param_tvb) {
proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);
- dissect_snmp_engineid(engine_tree, param_tvb, 0, tvb_length_remaining(param_tvb,0));
+ dissect_snmp_engineid(engine_tree, actx->pinfo, param_tvb, 0, tvb_length_remaining(param_tvb,0));
}
@@ -2506,7 +2496,7 @@ dissect_snmp_T_msgAuthoritativeEngineID(gboolean implicit_tag _U_, tvbuff_t *tvb
&usm_p.engine_tvb);
if (usm_p.engine_tvb) {
proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);
- dissect_snmp_engineid(engine_tree, usm_p.engine_tvb, 0, tvb_length_remaining(usm_p.engine_tvb,0));
+ dissect_snmp_engineid(engine_tree, actx->pinfo, usm_p.engine_tvb, 0, tvb_length_remaining(usm_p.engine_tvb,0));
}
@@ -2602,7 +2592,7 @@ dissect_snmp_INTEGER_484_2147483647(gboolean implicit_tag _U_, tvbuff_t *tvb _U_
static int
dissect_snmp_T_msgFlags(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
-#line 216 "../../asn1/snmp/snmp.cnf"
+#line 213 "../../asn1/snmp/snmp.cnf"
tvbuff_t *parameter_tvb = NULL;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
@@ -2657,7 +2647,7 @@ dissect_snmp_HeaderData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
static int
dissect_snmp_T_msgSecurityParameters(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
-#line 164 "../../asn1/snmp/snmp.cnf"
+#line 161 "../../asn1/snmp/snmp.cnf"
switch(MsgSecurityModel){
case SNMP_SEC_USM: /* 3 */
@@ -2723,10 +2713,7 @@ dissect_snmp_T_encryptedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
proto_tree* decrypted_tree;
if (! check_ScopedPdu(cleartext_tvb)) {
- proto_item* cause = proto_tree_add_text(encryptedpdu_tree, cleartext_tvb, 0, -1,
- "Decrypted data not formatted as expected, wrong key?");
-
- expert_add_info(actx->pinfo, cause, &ei_snmp_decrypted_data_bad_formatted);
+ proto_tree_add_expert(encryptedpdu_tree, actx->pinfo, &ei_snmp_decrypted_data_bad_formatted, cleartext_tvb, 0, -1);
col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");
@@ -2785,7 +2772,7 @@ dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);
-#line 179 "../../asn1/snmp/snmp.cnf"
+#line 176 "../../asn1/snmp/snmp.cnf"
if( usm_p.authenticated
&& usm_p.user_assoc
@@ -3097,7 +3084,7 @@ static void dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pro
/*--- End of included file: packet-snmp-fn.c ---*/
-#line 1886 "../../asn1/snmp/packet-snmp-template.c"
+#line 1876 "../../asn1/snmp/packet-snmp-template.c"
guint
@@ -3233,11 +3220,9 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
col_set_str(pinfo->cinfo, COL_PROTOCOL,
proto_get_protocol_short_name(find_protocol_by_id(proto)));
- if (tree) {
- item = proto_tree_add_item(tree, proto, tvb, start_offset,
+ item = proto_tree_add_item(tree, proto, tvb, start_offset,
message_length, ENC_BIG_ENDIAN);
- snmp_tree = proto_item_add_subtree(item, ett);
- }
+ snmp_tree = proto_item_add_subtree(item, ett);
switch (version) {
case 0: /* v1 */
@@ -3257,7 +3242,7 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
* if this is SNMP-over-TCP, our caller thinks there's
* nothing left to dissect.
*/
- proto_tree_add_text(snmp_tree, tvb, offset, -1,"Unknown version");
+ expert_add_info(pinfo, item, &ei_snmp_version_unknown);
return length_remaining;
break;
}
@@ -3657,6 +3642,9 @@ void proto_register_snmp(void) {
{ &hf_snmp_var_bind_str, {
"Variable-binding-string", "snmp.var-bind_str", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
+ { &hf_snmp_agentid_trailer, {
+ "AgentID Trailer", "snmp.agentid_trailer", FT_BYTES, BASE_NONE,
+ NULL, 0, NULL, HFILL }},
@@ -3924,7 +3912,7 @@ void proto_register_snmp(void) {
NULL, HFILL }},
/*--- End of included file: packet-snmp-hfarr.c ---*/
-#line 2448 "../../asn1/snmp/packet-snmp-template.c"
+#line 2439 "../../asn1/snmp/packet-snmp-template.c"
};
/* List of subtrees */
@@ -3964,11 +3952,11 @@ void proto_register_snmp(void) {
&ett_snmp_RReqPDU_U,
/*--- End of included file: packet-snmp-ettarr.c ---*/
-#line 2464 "../../asn1/snmp/packet-snmp-template.c"
+#line 2455 "../../asn1/snmp/packet-snmp-template.c"
};
static ei_register_info ei[] = {
{ &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED, PI_WARN, "Failed to decrypt encryptedPDU", EXPFILL }},
- { &ei_snmp_decrypted_data_bad_formatted, { "snmp.decrypted_data_bad_formatted", PI_MALFORMED, PI_WARN, "Decrypted data not formatted as expected", EXPFILL }},
+ { &ei_snmp_decrypted_data_bad_formatted, { "snmp.decrypted_data_bad_formatted", PI_MALFORMED, PI_WARN, "Decrypted data not formatted as expected, wrong key?", EXPFILL }},
{ &ei_snmp_verify_authentication_error, { "snmp.verify_authentication_error", PI_MALFORMED, PI_ERROR, "Error while verifying Message authenticity", EXPFILL }},
{ &ei_snmp_authentication_ok, { "snmp.authentication_ok", PI_CHECKSUM, PI_CHAT, "SNMP Authentication OK", EXPFILL }},
{ &ei_snmp_authentication_error, { "snmp.authentication_error", PI_CHECKSUM, PI_WARN, "SNMP Authentication Error", EXPFILL }},
@@ -3983,10 +3971,10 @@ void proto_register_snmp(void) {
{ &ei_snmp_no_instance_subid, { "snmp.no_instance_subid", PI_MALFORMED, PI_WARN, "No instance sub-id in scalar value", EXPFILL }},
{ &ei_snmp_wrong_num_of_subids, { "snmp.wrong_num_of_subids", PI_MALFORMED, PI_WARN, "Wrong number of instance sub-ids in scalar value", EXPFILL }},
{ &ei_snmp_index_suboid_too_short, { "snmp.index_suboid_too_short", PI_MALFORMED, PI_WARN, "index sub-oid shorter than expected", EXPFILL }},
- { &ei_snmp_unimplemented_instance_index, { "snmp.unimplemented_instance_index", PI_UNDECODED, PI_WARN, "Unimplemented instance index", EXPFILL }},
- { &ei_snmp_index_suboid_len0, { "snmp.ndex_suboid_len0", PI_MALFORMED, PI_WARN, "index sub-oid OID with len=0", EXPFILL }},
- { &ei_snmp_index_suboid_too_long, { "snmp.index_suboid_too_long", PI_MALFORMED, PI_WARN, "index sub-oid longer than remaining oid size", EXPFILL }},
- { &ei_snmp_index_string_too_long, { "snmp.index_string_too_long", PI_MALFORMED, PI_WARN, "index string longer than remaining oid size", EXPFILL }},
+ { &ei_snmp_unimplemented_instance_index, { "snmp.unimplemented_instance_index", PI_UNDECODED, PI_WARN, "OID instaces not handled, if you want this implemented please contact the wireshark developers", EXPFILL }},
+ { &ei_snmp_index_suboid_len0, { "snmp.ndex_suboid_len0", PI_MALFORMED, PI_WARN, "an index sub-oid OID cannot be 0 bytes long!", EXPFILL }},
+ { &ei_snmp_index_suboid_too_long, { "snmp.index_suboid_too_long", PI_MALFORMED, PI_WARN, "index sub-oid should not be longer than remaining oid size", EXPFILL }},
+ { &ei_snmp_index_string_too_long, { "snmp.index_string_too_long", PI_MALFORMED, PI_WARN, "index string should not be longer than remaining oid size", EXPFILL }},
{ &ei_snmp_column_parent_not_row, { "snmp.column_parent_not_row", PI_MALFORMED, PI_ERROR, "COLUMS's parent is not a ROW", EXPFILL }},
{ &ei_snmp_uint_too_large, { "snmp.uint_too_large", PI_UNDECODED, PI_NOTE, "Unsigned integer value > 2^64 - 1", EXPFILL }},
{ &ei_snmp_int_too_large, { "snmp.int_too_large", PI_UNDECODED, PI_NOTE, "Signed integer value > 2^63 - 1 or <= -2^63", EXPFILL }},
@@ -3994,6 +3982,9 @@ void proto_register_snmp(void) {
{ &ei_snmp_missing_mib, { "snmp.missing_mib", PI_UNDECODED, PI_NOTE, "Unresolved value, Missing MIB", EXPFILL }},
{ &ei_snmp_varbind_wrong_length_value, { "snmp.varbind.wrong_length_value", PI_MALFORMED, PI_WARN, "Wrong length for SNMP VarBind/value", EXPFILL }},
{ &ei_snmp_varbind_wrong_class_tag, { "snmp.varbind.wrong_class_tag", PI_MALFORMED, PI_WARN, "Wrong class/tag for SNMP VarBind/value", EXPFILL }},
+ { &ei_snmp_rfc1910_non_conformant, { "snmp.rfc1910_non_conformant", PI_PROTOCOL, PI_WARN, "Data not conforming to RFC1910", EXPFILL }},
+ { &ei_snmp_rfc3411_non_conformant, { "snmp.rfc3411_non_conformant", PI_PROTOCOL, PI_WARN, "Data not conforming to RFC3411", EXPFILL }},
+ { &ei_snmp_version_unknown, { "snmp.version.unknown", PI_PROTOCOL, PI_WARN, "Unknown version", EXPFILL }},
};