diff options
author | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2014-08-11 09:35:11 +0200 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-08-11 14:44:08 +0000 |
commit | cb44442dfcaf94a1806b3559773e9fc4739f09f2 (patch) | |
tree | d2e5ee250b6ab98ee29348fea708eff7d756c532 /asn1 | |
parent | 4c131ced560998ae32916295959568e2a39e04aa (diff) |
SNMP: fix mixed indent (use tab)
Change-Id: I19fde26bf7d1d2b19fcb56573f6e0814d1a7b8ab
Reviewed-on: https://code.wireshark.org/review/3551
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/snmp/packet-snmp-template.c | 631 |
1 files changed, 314 insertions, 317 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index 566ad665c1..8f3f175fc6 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -130,10 +130,10 @@ static const value_string auth_types[] = { }; static snmp_usm_auth_model_t* auth_models[] = {&model_md5,&model_sha1}; -#define PRIV_DES 0 -#define PRIV_AES128 1 -#define PRIV_AES192 2 -#define PRIV_AES256 3 +#define PRIV_DES 0 +#define PRIV_AES128 1 +#define PRIV_AES192 2 +#define PRIV_AES256 3 static const value_string priv_types[] = { { PRIV_DES, "DES" }, @@ -291,7 +291,7 @@ static const true_false_string auth_flags = { /* Security Models */ #define SNMP_SEC_ANY 0 -#define SNMP_SEC_V1 1 +#define SNMP_SEC_V1 1 #define SNMP_SEC_V2C 2 #define SNMP_SEC_USM 3 @@ -397,57 +397,57 @@ DateAndTime ::= TEXTUAL-CONVENTION Note that if only local time is known, then timezone information (fields 8-10) is not present." SYNTAX OCTET STRING (SIZE (8 | 11)) - */ +*/ static proto_item * dissect_snmp_variable_date_and_time(proto_tree *tree,int hfid, tvbuff_t *tvb, int offset, int length) { - guint16 year; - guint8 month; - guint8 day; - guint8 hour; - guint8 minutes; - guint8 seconds; - guint8 deci_seconds; - guint8 hour_from_utc; - guint8 min_from_utc; - gchar *str; - - year = tvb_get_ntohs(tvb,offset); - month = tvb_get_guint8(tvb,offset+2); - day = tvb_get_guint8(tvb,offset+3); - hour = tvb_get_guint8(tvb,offset+4); - minutes = tvb_get_guint8(tvb,offset+5); - seconds = tvb_get_guint8(tvb,offset+6); - deci_seconds = tvb_get_guint8(tvb,offset+7); - if(length > 8){ - hour_from_utc = tvb_get_guint8(tvb,offset+9); - min_from_utc = tvb_get_guint8(tvb,offset+10); + guint16 year; + guint8 month; + guint8 day; + guint8 hour; + guint8 minutes; + guint8 seconds; + guint8 deci_seconds; + guint8 hour_from_utc; + guint8 min_from_utc; + gchar *str; + + year = tvb_get_ntohs(tvb,offset); + month = tvb_get_guint8(tvb,offset+2); + day = tvb_get_guint8(tvb,offset+3); + hour = tvb_get_guint8(tvb,offset+4); + minutes = tvb_get_guint8(tvb,offset+5); + seconds = tvb_get_guint8(tvb,offset+6); + deci_seconds = tvb_get_guint8(tvb,offset+7); + if(length > 8){ + hour_from_utc = tvb_get_guint8(tvb,offset+9); + min_from_utc = tvb_get_guint8(tvb,offset+10); str = wmem_strdup_printf(wmem_packet_scope(), - "%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u", - year, - month, - day, - hour, - minutes, - seconds, - deci_seconds, - tvb_get_string_enc(wmem_packet_scope(),tvb,offset+8,1,ENC_ASCII|ENC_NA), - hour_from_utc, - min_from_utc); - }else{ - str = wmem_strdup_printf(wmem_packet_scope(), - "%u-%u-%u, %u:%u:%u.%u", - year, - month, - day, - hour, - minutes, - seconds, - deci_seconds); - } - - return proto_tree_add_string(tree, hfid, tvb, offset, length, str); + "%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u", + year, + month, + day, + hour, + minutes, + seconds, + deci_seconds, + tvb_get_string_enc(wmem_packet_scope(),tvb,offset+8,1,ENC_ASCII|ENC_NA), + hour_from_utc, + min_from_utc); + }else{ + str = wmem_strdup_printf(wmem_packet_scope(), + "%u-%u-%u, %u:%u:%u.%u", + year, + month, + day, + hour, + minutes, + seconds, + deci_seconds); + } + + return proto_tree_add_string(tree, hfid, tvb, offset, length, str); } @@ -1007,7 +1007,7 @@ indexing_done: if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){ pi_value = dissect_snmp_variable_date_and_time(pt_varbind, hfid, tvb, value_offset, value_len); }else{ - pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN); + pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN); } if (format_error != BER_NO_ERROR) { expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib); @@ -1123,125 +1123,125 @@ static const value_string snmp_engineid_cisco_type_vals[] = { int dissect_snmp_engineid(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, int len) { - proto_item *item = NULL; - guint8 conformance, format; - guint32 enterpriseid, seconds; - nstime_t ts; - int len_remain = len; - - /* first bit: engine id conformance */ - if (len_remain<1) return offset; - conformance = ((tvb_get_guint8(tvb, offset)>>7) & 0x01); - proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN); - - /* 4-byte enterprise number/name */ - if (len_remain<4) return offset; - enterpriseid = tvb_get_ntohl(tvb, offset); - if (conformance) - enterpriseid -= 0x80000000; /* ignore first bit */ - proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid); - offset+=4; - len_remain-=4; - - switch(conformance) { - - case SNMP_ENGINEID_RFC1910: - /* 12-byte AgentID w/ 8-byte trailer */ - if (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_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain); - return offset; - } - break; - - case SNMP_ENGINEID_RFC3411: /* variable length: 5..32 */ - - /* 1-byte format specifier */ - if (len_remain<1) return offset; - format = tvb_get_guint8(tvb, offset); - item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)", - val_to_str(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"), format); - offset+=1; - len_remain-=1; - - switch(format) { - case SNMP_ENGINEID_FORMAT_IPV4: - /* 4-byte IPv4 address */ - if (len_remain==4) { - proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN); - offset+=4; - len_remain=0; - } - break; - case SNMP_ENGINEID_FORMAT_IPV6: - /* 16-byte IPv6 address */ - if (len_remain==16) { - proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA); - offset+=16; - len_remain=0; - } - break; - case SNMP_ENGINEID_FORMAT_MACADDRESS: - /* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */ - if ((enterpriseid==9)&&(len_remain==7)) { - proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - len_remain--; - } - /* 6-byte MAC address */ - if (len_remain==6) { - proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_NA); - offset+=6; - len_remain=0; - } - break; - case SNMP_ENGINEID_FORMAT_TEXT: - /* max. 27-byte string, administratively assigned */ - if (len_remain<=27) { - proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII|ENC_NA); - offset+=len_remain; - len_remain=0; - } - break; - case 128: - /* most common enterprise-specific format: (ucd|net)-snmp random */ - if ((enterpriseid==2021)||(enterpriseid==8072)) { - proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random"); - /* demystify: 4B random, 4B epoch seconds */ - if (len_remain==8) { - proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA); - seconds = tvb_get_letohl(tvb, offset+4); - ts.secs = seconds; - ts.nsecs = 0; - proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset+4, 4, - &ts, "%s", - abs_time_secs_to_str(wmem_packet_scope(), seconds, ABSOLUTE_TIME_LOCAL, TRUE)); - offset+=8; - len_remain=0; - } - break; + proto_item *item = NULL; + guint8 conformance, format; + guint32 enterpriseid, seconds; + nstime_t ts; + int len_remain = len; + + /* first bit: engine id conformance */ + if (len_remain<1) return offset; + conformance = ((tvb_get_guint8(tvb, offset)>>7) & 0x01); + proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN); + + /* 4-byte enterprise number/name */ + if (len_remain<4) return offset; + enterpriseid = tvb_get_ntohl(tvb, offset); + if (conformance) + enterpriseid -= 0x80000000; /* ignore first bit */ + proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid); + offset+=4; + len_remain-=4; + + switch(conformance) { + + case SNMP_ENGINEID_RFC1910: + /* 12-byte AgentID w/ 8-byte trailer */ + if (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_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain); + return offset; + } + break; + + case SNMP_ENGINEID_RFC3411: /* variable length: 5..32 */ + + /* 1-byte format specifier */ + if (len_remain<1) return offset; + format = tvb_get_guint8(tvb, offset); + item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)", + val_to_str(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"), format); + offset+=1; + len_remain-=1; + + switch(format) { + case SNMP_ENGINEID_FORMAT_IPV4: + /* 4-byte IPv4 address */ + if (len_remain==4) { + proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN); + offset+=4; + len_remain=0; + } + break; + case SNMP_ENGINEID_FORMAT_IPV6: + /* 16-byte IPv6 address */ + if (len_remain==16) { + proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA); + offset+=16; + len_remain=0; + } + break; + case SNMP_ENGINEID_FORMAT_MACADDRESS: + /* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */ + if ((enterpriseid==9)&&(len_remain==7)) { + proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN); + offset++; + len_remain--; + } + /* 6-byte MAC address */ + if (len_remain==6) { + proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_NA); + offset+=6; + len_remain=0; + } + break; + case SNMP_ENGINEID_FORMAT_TEXT: + /* max. 27-byte string, administratively assigned */ + if (len_remain<=27) { + proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII|ENC_NA); + offset+=len_remain; + len_remain=0; + } + break; + case 128: + /* most common enterprise-specific format: (ucd|net)-snmp random */ + if ((enterpriseid==2021)||(enterpriseid==8072)) { + proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random"); + /* demystify: 4B random, 4B epoch seconds */ + if (len_remain==8) { + proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA); + seconds = tvb_get_letohl(tvb, offset+4); + ts.secs = seconds; + ts.nsecs = 0; + proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset+4, 4, + &ts, "%s", + abs_time_secs_to_str(wmem_packet_scope(), seconds, ABSOLUTE_TIME_LOCAL, TRUE)); + offset+=8; + len_remain=0; + } + break; + } + /* fall through */ + case SNMP_ENGINEID_FORMAT_OCTETS: + default: + /* max. 27 bytes, administratively assigned or unknown format */ + if (len_remain<=27) { + proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA); + offset+=len_remain; + len_remain=0; + } + break; + } } - /* fall through */ - case SNMP_ENGINEID_FORMAT_OCTETS: - default: - /* max. 27 bytes, administratively assigned or unknown format */ - if (len_remain<=27) { - proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA); - offset+=len_remain; - len_remain=0; + + if (len_remain>0) { + proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain); + offset+=len_remain; } - break; - } - } - - if (len_remain>0) { - proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain); - offset+=len_remain; - } - return offset; + return offset; } @@ -1659,8 +1659,8 @@ static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_) { #ifdef HAVE_LIBGCRYPT - gcry_error_t err; - gcry_cipher_hd_t hd = NULL; + gcry_error_t err; + gcry_cipher_hd_t hd = NULL; guint8* cleartext; guint8* des_key = p->user_assoc->user.privKey.data; /* first 8 bytes */ @@ -2003,11 +2003,9 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo, next_tvb_init(&var_list); - col_set_str(pinfo->cinfo, COL_PROTOCOL, - proto_get_protocol_short_name(find_protocol_by_id(proto))); + col_set_str(pinfo->cinfo, COL_PROTOCOL, proto_get_protocol_short_name(find_protocol_by_id(proto))); - item = proto_tree_add_item(tree, proto, tvb, start_offset, - message_length, ENC_BIG_ENDIAN); + item = proto_tree_add_item(tree, proto, tvb, start_offset, message_length, ENC_BIG_ENDIAN); snmp_tree = proto_item_add_subtree(item, ett); switch (version) { @@ -2113,13 +2111,13 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ * wildcarded, and give it the SNMP dissector as a dissector. */ if (pinfo->destport == UDP_PORT_SNMP) { - conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP, + conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP, pinfo->srcport, 0, NO_PORT_B); - if( (conversation == NULL) || (conversation->dissector_handle!=snmp_handle) ) { - conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP, + if( (conversation == NULL) || (conversation->dissector_handle!=snmp_handle) ) { + conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP, pinfo->srcport, 0, NO_PORT2); - conversation_set_dissector(conversation, snmp_handle); - } + conversation_set_dissector(conversation, snmp_handle); + } } return dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, FALSE); @@ -2132,8 +2130,7 @@ dissect_snmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint message_len; while (tvb_reported_length_remaining(tvb, offset) > 0) { - message_len = dissect_snmp_pdu(tvb, 0, pinfo, tree, - proto_snmp, ett_snmp, TRUE); + message_len = dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, TRUE); if (message_len == 0) { /* * We don't have all the data for that message, @@ -2174,10 +2171,10 @@ snmp_usm_password_to_key_md5(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key) { - md5_state_t MD; - guint8 *cp, password_buf[64]; - guint32 password_index = 0; - guint32 count = 0, i; + md5_state_t MD; + guint8 *cp, password_buf[64]; + guint32 password_index = 0; + guint32 count = 0, i; guint8 key1[16]; md5_init(&MD); /* initialize MD5 */ @@ -2200,7 +2197,7 @@ snmp_usm_password_to_key_md5(const guint8 *password, guint passwordlen, md5_append(&MD, password_buf, 64); count += 64; } - md5_finish(&MD, key1); /* tell MD5 we're done */ + md5_finish(&MD, key1); /* tell MD5 we're done */ /*****************************************************/ /* Now localize the key with the engineID and pass */ @@ -2230,10 +2227,10 @@ snmp_usm_password_to_key_sha1(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key) { - sha1_context SH; - guint8 *cp, password_buf[64]; - guint32 password_index = 0; - guint32 count = 0, i; + sha1_context SH; + guint8 *cp, password_buf[64]; + guint32 password_index = 0; + guint32 count = 0, i; sha1_starts(&SH); /* initialize SHA */ @@ -2314,8 +2311,8 @@ UAT_CSTRING_CB_DEF(specific_traps, desc, snmp_st_assoc_t) /*--- proto_register_snmp -------------------------------------------*/ void proto_register_snmp(void) { - /* List of fields */ - static hf_register_info hf[] = { + /* List of fields */ + static hf_register_info hf[] = { { &hf_snmp_v3_flags_auth, { "Authenticated", "snmp.v3.flags.auth", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TH_AUTH, NULL, HFILL }}, @@ -2434,158 +2431,158 @@ void proto_register_snmp(void) { #include "packet-snmp-hfarr.c" - }; - - /* List of subtrees */ - static gint *ett[] = { - &ett_snmp, - &ett_engineid, - &ett_msgFlags, - &ett_encryptedPDU, - &ett_decrypted, - &ett_authParameters, - &ett_internet, - &ett_varbind, - &ett_name, - &ett_value, - &ett_decoding_error, + }; + + /* List of subtrees */ + static gint *ett[] = { + &ett_snmp, + &ett_engineid, + &ett_msgFlags, + &ett_encryptedPDU, + &ett_decrypted, + &ett_authParameters, + &ett_internet, + &ett_varbind, + &ett_name, + &ett_value, + &ett_decoding_error, #include "packet-snmp-ettarr.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, 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 }}, - { &ei_snmp_varbind_not_uni_class_seq, { "snmp.varbind.not_uni_class_seq", PI_MALFORMED, PI_WARN, "VarBind is not an universal class sequence", EXPFILL }}, - { &ei_snmp_varbind_has_indicator, { "snmp.varbind.has_indicator", PI_MALFORMED, PI_WARN, "VarBind has indicator set", EXPFILL }}, - { &ei_snmp_objectname_not_oid, { "snmp.objectname_not_oid", PI_MALFORMED, PI_WARN, "ObjectName not an OID", EXPFILL }}, - { &ei_snmp_objectname_has_indicator, { "snmp.objectname_has_indicator", PI_MALFORMED, PI_WARN, "ObjectName has indicator set", EXPFILL }}, - { &ei_snmp_value_not_primitive_encoding, { "snmp.value_not_primitive_encoding", PI_MALFORMED, PI_WARN, "value not in primitive encoding", EXPFILL }}, - { &ei_snmp_invalid_oid, { "snmp.invalid_oid", PI_MALFORMED, PI_WARN, "invalid oid", EXPFILL }}, - { &ei_snmp_varbind_wrong_tag, { "snmp.varbind.wrong_tag", PI_MALFORMED, PI_WARN, "Wrong tag for SNMP VarBind error value", EXPFILL }}, - { &ei_snmp_varbind_response, { "snmp.varbind.response", PI_RESPONSE_CODE, PI_NOTE, "Response", EXPFILL }}, - { &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, "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 }}, - { &ei_snmp_integral_value0, { "snmp.integral_value0", PI_UNDECODED, PI_NOTE, "Integral value is zero-length", EXPFILL }}, - { &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 }}, - - }; - - expert_module_t* expert_snmp; - module_t *snmp_module; - - static uat_field_t users_fields[] = { - UAT_FLD_BUFFER(snmp_users,engine_id,"Engine ID","Engine-id for this entry (empty = any)"), - UAT_FLD_LSTRING(snmp_users,userName,"Username","The username"), - UAT_FLD_VS(snmp_users,auth_model,"Authentication model",auth_types,"Algorithm to be used for authentication."), - UAT_FLD_LSTRING(snmp_users,authPassword,"Password","The password used for authenticating packets for this entry"), - UAT_FLD_VS(snmp_users,priv_proto,"Privacy protocol",priv_types,"Algorithm to be used for privacy."), - UAT_FLD_LSTRING(snmp_users,privPassword,"Privacy password","The password used for encrypting packets for this entry"), - UAT_END_FIELDS - }; - - uat_t *assocs_uat = uat_new("SNMP Users", - sizeof(snmp_ue_assoc_t), - "snmp_users", - TRUE, - &ueas, - &num_ueas, - UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ - "ChSNMPUsersSection", - snmp_users_copy_cb, - snmp_users_update_cb, - snmp_users_free_cb, - renew_ue_cache, - users_fields); - - static uat_field_t specific_traps_flds[] = { - UAT_FLD_CSTRING(specific_traps,enterprise,"Enterprise OID","Enterprise Object Identifier"), - UAT_FLD_DEC(specific_traps,trap,"Trap Id","The specific-trap value"), - UAT_FLD_CSTRING(specific_traps,desc,"Description","Trap type description"), - UAT_END_FIELDS - }; - - uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types", - sizeof(snmp_st_assoc_t), - "snmp_specific_traps", - TRUE, - &specific_traps, - &num_specific_traps, - UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ - "ChSNMPEnterpriseSpecificTrapTypes", - snmp_specific_trap_copy_cb, - NULL, - snmp_specific_trap_free_cb, - NULL, - specific_traps_flds); - - /* Register protocol */ - proto_snmp = proto_register_protocol(PNAME, PSNAME, PFNAME); - new_register_dissector("snmp", dissect_snmp, proto_snmp); - - /* Register fields and subtrees */ - proto_register_field_array(proto_snmp, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - expert_snmp = expert_register_protocol(proto_snmp); - expert_register_field_array(expert_snmp, ei, array_length(ei)); - - - /* Register configuration preferences */ - snmp_module = prefs_register_protocol(proto_snmp, process_prefs); - prefs_register_bool_preference(snmp_module, "display_oid", + }; + 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, 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 }}, + { &ei_snmp_varbind_not_uni_class_seq, { "snmp.varbind.not_uni_class_seq", PI_MALFORMED, PI_WARN, "VarBind is not an universal class sequence", EXPFILL }}, + { &ei_snmp_varbind_has_indicator, { "snmp.varbind.has_indicator", PI_MALFORMED, PI_WARN, "VarBind has indicator set", EXPFILL }}, + { &ei_snmp_objectname_not_oid, { "snmp.objectname_not_oid", PI_MALFORMED, PI_WARN, "ObjectName not an OID", EXPFILL }}, + { &ei_snmp_objectname_has_indicator, { "snmp.objectname_has_indicator", PI_MALFORMED, PI_WARN, "ObjectName has indicator set", EXPFILL }}, + { &ei_snmp_value_not_primitive_encoding, { "snmp.value_not_primitive_encoding", PI_MALFORMED, PI_WARN, "value not in primitive encoding", EXPFILL }}, + { &ei_snmp_invalid_oid, { "snmp.invalid_oid", PI_MALFORMED, PI_WARN, "invalid oid", EXPFILL }}, + { &ei_snmp_varbind_wrong_tag, { "snmp.varbind.wrong_tag", PI_MALFORMED, PI_WARN, "Wrong tag for SNMP VarBind error value", EXPFILL }}, + { &ei_snmp_varbind_response, { "snmp.varbind.response", PI_RESPONSE_CODE, PI_NOTE, "Response", EXPFILL }}, + { &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, "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 }}, + { &ei_snmp_integral_value0, { "snmp.integral_value0", PI_UNDECODED, PI_NOTE, "Integral value is zero-length", EXPFILL }}, + { &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 }}, + + }; + + expert_module_t* expert_snmp; + module_t *snmp_module; + + static uat_field_t users_fields[] = { + UAT_FLD_BUFFER(snmp_users,engine_id,"Engine ID","Engine-id for this entry (empty = any)"), + UAT_FLD_LSTRING(snmp_users,userName,"Username","The username"), + UAT_FLD_VS(snmp_users,auth_model,"Authentication model",auth_types,"Algorithm to be used for authentication."), + UAT_FLD_LSTRING(snmp_users,authPassword,"Password","The password used for authenticating packets for this entry"), + UAT_FLD_VS(snmp_users,priv_proto,"Privacy protocol",priv_types,"Algorithm to be used for privacy."), + UAT_FLD_LSTRING(snmp_users,privPassword,"Privacy password","The password used for encrypting packets for this entry"), + UAT_END_FIELDS + }; + + uat_t *assocs_uat = uat_new("SNMP Users", + sizeof(snmp_ue_assoc_t), + "snmp_users", + TRUE, + &ueas, + &num_ueas, + UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ + "ChSNMPUsersSection", + snmp_users_copy_cb, + snmp_users_update_cb, + snmp_users_free_cb, + renew_ue_cache, + users_fields); + + static uat_field_t specific_traps_flds[] = { + UAT_FLD_CSTRING(specific_traps,enterprise,"Enterprise OID","Enterprise Object Identifier"), + UAT_FLD_DEC(specific_traps,trap,"Trap Id","The specific-trap value"), + UAT_FLD_CSTRING(specific_traps,desc,"Description","Trap type description"), + UAT_END_FIELDS + }; + + uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types", + sizeof(snmp_st_assoc_t), + "snmp_specific_traps", + TRUE, + &specific_traps, + &num_specific_traps, + UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ + "ChSNMPEnterpriseSpecificTrapTypes", + snmp_specific_trap_copy_cb, + NULL, + snmp_specific_trap_free_cb, + NULL, + specific_traps_flds); + + /* Register protocol */ + proto_snmp = proto_register_protocol(PNAME, PSNAME, PFNAME); + new_register_dissector("snmp", dissect_snmp, proto_snmp); + + /* Register fields and subtrees */ + proto_register_field_array(proto_snmp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + expert_snmp = expert_register_protocol(proto_snmp); + expert_register_field_array(expert_snmp, ei, array_length(ei)); + + + /* Register configuration preferences */ + snmp_module = prefs_register_protocol(proto_snmp, process_prefs); + prefs_register_bool_preference(snmp_module, "display_oid", "Show SNMP OID in info column", "Whether the SNMP OID should be shown in the info column", &display_oid); - prefs_register_obsolete_preference(snmp_module, "mib_modules"); - prefs_register_obsolete_preference(snmp_module, "users_file"); + prefs_register_obsolete_preference(snmp_module, "mib_modules"); + prefs_register_obsolete_preference(snmp_module, "users_file"); - prefs_register_bool_preference(snmp_module, "desegment", + prefs_register_bool_preference(snmp_module, "desegment", "Reassemble SNMP-over-TCP messages\nspanning multiple TCP segments", "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &snmp_desegment); - prefs_register_bool_preference(snmp_module, "var_in_tree", + prefs_register_bool_preference(snmp_module, "var_in_tree", "Display dissected variables inside SNMP tree", "ON - display dissected variables inside SNMP tree, OFF - display dissected variables in root tree after SNMP", &snmp_var_in_tree); - prefs_register_uat_preference(snmp_module, "users_table", + prefs_register_uat_preference(snmp_module, "users_table", "Users Table", "Table of engine-user associations used for authentication and decryption", assocs_uat); - prefs_register_uat_preference(snmp_module, "specific_traps_table", + prefs_register_uat_preference(snmp_module, "specific_traps_table", "Enterprise Specific Trap Types", "Table of enterprise specific-trap type descriptions", specific_traps_uat); #ifdef HAVE_LIBSMI - prefs_register_static_text_preference(snmp_module, "info_mibs", - "MIB settings can be changed in the Name Resolution preferences", - "MIB settings can be changed in the Name Resolution preferences"); + prefs_register_static_text_preference(snmp_module, "info_mibs", + "MIB settings can be changed in the Name Resolution preferences", + "MIB settings can be changed in the Name Resolution preferences"); #endif - value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", FT_STRING, BASE_NONE); + value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", FT_STRING, BASE_NONE); - register_init_routine(renew_ue_cache); + register_init_routine(renew_ue_cache); - register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp); + register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp); } |