/builds/wireshark/wireshark/epan/dissectors/packet-snmp.c (2024)

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name packet-snmp.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-17/lib/clang/17 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/epan -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-error=stringop-overflow= -Wno-error=deprecated-declarations -Wno-format-truncation -Wno-pointer-sign -std=gnu11 -fdebug-compilation-dir=/builds/wireshark/wireshark/build -ferror-limit 19 -fvisibility=hidden -fwrapv -fgnuc-version=4.2.1 -fcolor-diagnostics -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2024-06-16-100241-3154-1 -x c /builds/wireshark/wireshark/epan/dissectors/packet-snmp.c

1/* Do not modify this file. Changes will be overwritten. */2/* Generated automatically by the ASN.1 to Wireshark dissector compiler */3/* packet-snmp.c */4/* asn2wrs.py -b -q -L -p snmp -c ./snmp.cnf -s ./packet-snmp-template -D . -O ../.. snmp.asn */5 6/* packet-snmp.c7 * Routines for SNMP (simple network management protocol)8 * Copyright (C) 1998 Didier Jorand9 *10 * See RFC 1157 for SNMPv1.11 *12 * See RFCs 1901, 1905, and 1906 for SNMPv2c.13 *14 * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u [historic].15 *16 * See RFCs 2570-2576 for SNMPv317 * Updated to use the asn2wrs compiler made by Tomas Kukosa18 * Copyright (C) 2005 - 2006 Anders Broman [AT] ericsson.com19 *20 * See RFC 3414 for User-based Security Model for SNMPv321 * See RFC 3826 for (AES) Cipher Algorithm in the SNMP USM22 * See RFC 2578 for Structure of Management Information Version 2 (SMIv2)23 * Copyright (C) 2007 Luis E. Garcia Ontanon <[emailprotected]>24 *25 * Wireshark - Network traffic analyzer26 * By Gerald Combs <[emailprotected]>27 * Copyright 1998 Gerald Combs28 *29 * Some stuff from:30 *31 * GXSNMP -- An snmp mangament application32 * Copyright (C) 1998 Gregory McLean & Jochen Friedrich33 * Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP group34 *35 * SPDX-License-Identifier: GPL-2.0-or-later36 */37 38#if 039#include <stdio.h>40#define D(args) do {printf args; fflush(stdoutstdout); } while(0)41#endif42 43#include "config.h"44 45#include <epan/packet.h>46#include <epan/strutil.h>47#include <epan/conversation.h>48#include <epan/etypes.h>49#include <epan/prefs.h>50#include <epan/addr_resolv.h>51#include <epan/next_tvb.h>52#include <epan/uat.h>53#include <epan/asn1.h>54#include <epan/expert.h>55#include <epan/oids.h>56#include <epan/srt_table.h>57#include <epan/tap.h>58#include "packet-ipx.h"59#include "packet-hpext.h"60#include "packet-ber.h"61#include "packet-snmp.h"62#include <wsutil/wsgcrypt.h>63 64#define PNAME"Simple Network Management Protocol" "Simple Network Management Protocol"65#define PSNAME"SNMP" "SNMP"66#define PFNAME"snmp" "snmp"67 68#define UDP_PORT_SNMP16116169#define UDP_PORT_SNMP_TRAP16216270#define TCP_PORT_SNMP16116171#define TCP_PORT_SNMP_TRAP16216272#define TCP_PORT_SMUX19919973#define UDP_PORT_SNMP_PATROL8161 816174#define SNMP_NUM_PROCEDURES8 875 76/* Initialize the protocol and registered fields */77static int snmp_tap;78static int proto_snmp;79static int proto_smux;80 81static bool_Bool display_oid = true1;82static bool_Bool snmp_var_in_tree = true1;83 84void proto_register_snmp(void);85void proto_reg_handoff_snmp(void);86void proto_register_smux(void);87void proto_reg_handoff_smux(void);88 89static void snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const guint8 *password, guint passwordlen,90const guint8 *engineID, guint engineLength, guint8 *key);91 92static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);93static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);94static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);95static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);96 97static bool_Bool snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, guint8**, guint*, gchar const**);98 99static const value_string auth_types[] = {100{SNMP_USM_AUTH_MD5,"MD5"},101{SNMP_USM_AUTH_SHA1,"SHA1"},102{SNMP_USM_AUTH_SHA2_224,"SHA2-224"},103{SNMP_USM_AUTH_SHA2_256,"SHA2-256"},104{SNMP_USM_AUTH_SHA2_384,"SHA2-384"},105{SNMP_USM_AUTH_SHA2_512,"SHA2-512"},106{0,NULL((void*)0)}107};108 109static const guint auth_hash_len[] = {110HASH_MD5_LENGTH16,111HASH_SHA1_LENGTH20,112HASH_SHA2_224_LENGTH28,113HASH_SHA2_256_LENGTH32,114HASH_SHA2_384_LENGTH48,115HASH_SHA2_512_LENGTH64116};117 118static const guint auth_tag_len[] = {11912,12012,12116,12224,12332,12448125};126 127static const enum gcry_md_algos auth_hash_algo[] = {128GCRY_MD_MD5,129GCRY_MD_SHA1,130GCRY_MD_SHA224,131GCRY_MD_SHA256,132GCRY_MD_SHA384,133GCRY_MD_SHA512134};135 136#define PRIV_DES00137#define PRIV_AES12811138#define PRIV_AES19222139#define PRIV_AES25633140 141static const value_string priv_types[] = {142{ PRIV_DES0, "DES" },143{ PRIV_AES1281, "AES" },144{ PRIV_AES1922, "AES192" },145{ PRIV_AES2563, "AES256" },146{ 0, NULL((void*)0)}147};148static snmp_usm_decoder_t priv_protos[] = {149snmp_usm_priv_des,150snmp_usm_priv_aes128,151snmp_usm_priv_aes192,152snmp_usm_priv_aes256153};154 155static snmp_ue_assoc_t* ueas;156static guint num_ueas;157static snmp_ue_assoc_t* localized_ues;158static snmp_ue_assoc_t* unlocalized_ues;159/****/160 161/* Variables used for handling enterprise specific trap types */162typedef struct _snmp_st_assoc_t {163char *enterprise;164guint trap;165char *desc;166} snmp_st_assoc_t;167static guint num_specific_traps;168static snmp_st_assoc_t *specific_traps;169static const char *enterprise_oid;170static guint generic_trap;171static guint32 snmp_version;172static guint32 RequestID = -1;173 174static snmp_usm_params_t usm_p;175 176#define TH_AUTH0x01 0x01177#define TH_CRYPT0x02 0x02178#define TH_REPORT0x04 0x04179 180/* desegmentation of SNMP-over-TCP */181static bool_Bool snmp_desegment = true1;182 183/* Global variables */184 185guint32 MsgSecurityModel;186tvbuff_t *oid_tvb=NULL((void*)0);187tvbuff_t *value_tvb=NULL((void*)0);188 189static dissector_handle_t snmp_handle;190static dissector_handle_t snmp_tcp_handle;191static dissector_handle_t data_handle;192static dissector_handle_t smux_handle;193 194static next_tvb_list_t *var_list;195 196static int hf_snmp_response_in;197static int hf_snmp_response_to;198static int hf_snmp_time;199 200static int hf_snmp_v3_flags_auth;201static int hf_snmp_v3_flags_crypt;202static int hf_snmp_v3_flags_report;203 204static int hf_snmp_engineid_conform;205static int hf_snmp_engineid_enterprise;206static int hf_snmp_engineid_format;207static int hf_snmp_engineid_ipv4;208static int hf_snmp_engineid_ipv6;209static int hf_snmp_engineid_cisco_type;210static int hf_snmp_engineid_mac;211static int hf_snmp_engineid_text;212static int hf_snmp_engineid_time;213static int hf_snmp_engineid_data;214static int hf_snmp_decryptedPDU;215static int hf_snmp_msgAuthentication;216 217static int hf_snmp_noSuchObject;218static int hf_snmp_noSuchInstance;219static int hf_snmp_endOfMibView;220static int hf_snmp_unSpecified;221 222static int hf_snmp_integer32_value;223static int hf_snmp_octetstring_value;224static int hf_snmp_oid_value;225static int hf_snmp_null_value;226static int hf_snmp_ipv4_value;227static int hf_snmp_ipv6_value;228static int hf_snmp_anyaddress_value;229static int hf_snmp_unsigned32_value;230static int hf_snmp_unknown_value;231static int hf_snmp_opaque_value;232static int hf_snmp_nsap_value;233static int hf_snmp_counter_value;234static int hf_snmp_timeticks_value;235static int hf_snmp_big_counter_value;236static int hf_snmp_gauge32_value;237 238static int hf_snmp_objectname;239static int hf_snmp_scalar_instance_index;240 241static int hf_snmp_var_bind_str;242static int hf_snmp_agentid_trailer;243 244static int hf_snmp_SMUX_PDUs_PDU; /* SMUX_PDUs */245static int hf_snmp_version; /* Version */246static int hf_snmp_community; /* Community */247static int hf_snmp_data; /* PDUs */248static int hf_snmp_parameters; /* OCTET_STRING */249static int hf_snmp_datav2u; /* T_datav2u */250static int hf_snmp_v2u_plaintext; /* PDUs */251static int hf_snmp_encrypted; /* OCTET_STRING */252static int hf_snmp_msgAuthoritativeEngineID; /* T_msgAuthoritativeEngineID */253static int hf_snmp_msgAuthoritativeEngineBoots; /* T_msgAuthoritativeEngineBoots */254static int hf_snmp_msgAuthoritativeEngineTime; /* T_msgAuthoritativeEngineTime */255static int hf_snmp_msgUserName; /* T_msgUserName */256static int hf_snmp_msgAuthenticationParameters; /* T_msgAuthenticationParameters */257static int hf_snmp_msgPrivacyParameters; /* T_msgPrivacyParameters */258static int hf_snmp_msgVersion; /* Version */259static int hf_snmp_msgGlobalData; /* HeaderData */260static int hf_snmp_msgSecurityParameters; /* T_msgSecurityParameters */261static int hf_snmp_msgData; /* ScopedPduData */262static int hf_snmp_msgID; /* INTEGER_0_2147483647 */263static int hf_snmp_msgMaxSize; /* INTEGER_484_2147483647 */264static int hf_snmp_msgFlags; /* T_msgFlags */265static int hf_snmp_msgSecurityModel; /* T_msgSecurityModel */266static int hf_snmp_plaintext; /* ScopedPDU */267static int hf_snmp_encryptedPDU; /* T_encryptedPDU */268static int hf_snmp_contextEngineID; /* SnmpEngineID */269static int hf_snmp_contextName; /* OCTET_STRING */270static int hf_snmp_get_request; /* GetRequest_PDU */271static int hf_snmp_get_next_request; /* GetNextRequest_PDU */272static int hf_snmp_get_response; /* GetResponse_PDU */273static int hf_snmp_set_request; /* SetRequest_PDU */274static int hf_snmp_trap; /* Trap_PDU */275static int hf_snmp_getBulkRequest; /* GetBulkRequest_PDU */276static int hf_snmp_informRequest; /* InformRequest_PDU */277static int hf_snmp_snmpV2_trap; /* SNMPv2_Trap_PDU */278static int hf_snmp_report; /* Report_PDU */279static int hf_snmp_request_id; /* T_request_id */280static int hf_snmp_error_status; /* T_error_status */281static int hf_snmp_error_index; /* INTEGER */282static int hf_snmp_variable_bindings; /* VarBindList */283static int hf_snmp_bulkPDU_request_id; /* Integer32 */284static int hf_snmp_non_repeaters; /* INTEGER_0_2147483647 */285static int hf_snmp_max_repetitions; /* INTEGER_0_2147483647 */286static int hf_snmp_enterprise; /* EnterpriseOID */287static int hf_snmp_agent_addr; /* NetworkAddress */288static int hf_snmp_generic_trap; /* GenericTrap */289static int hf_snmp_specific_trap; /* SpecificTrap */290static int hf_snmp_time_stamp; /* TimeTicks */291static int hf_snmp_name; /* ObjectName */292static int hf_snmp_valueType; /* ValueType */293static int hf_snmp_VarBindList_item; /* VarBind */294static int hf_snmp_open; /* OpenPDU */295static int hf_snmp_close; /* ClosePDU */296static int hf_snmp_registerRequest; /* RReqPDU */297static int hf_snmp_registerResponse; /* RegisterResponse */298static int hf_snmp_commitOrRollback; /* SOutPDU */299static int hf_snmp_rRspPDU; /* RRspPDU */300static int hf_snmp_pDUs; /* PDUs */301static int hf_snmp_smux_simple; /* SimpleOpen */302static int hf_snmp_smux_version; /* T_smux_version */303static int hf_snmp_identity; /* OBJECT_IDENTIFIER */304static int hf_snmp_description; /* DisplayString */305static int hf_snmp_password; /* OCTET_STRING */306static int hf_snmp_subtree; /* ObjectName */307static int hf_snmp_priority; /* INTEGER_M1_2147483647 */308static int hf_snmp_operation; /* T_operation */309 310/* Initialize the subtree pointers */311static gint ett_smux;312static gint ett_snmp;313static gint ett_engineid;314static gint ett_msgFlags;315static gint ett_encryptedPDU;316static gint ett_decrypted;317static gint ett_authParameters;318static gint ett_internet;319static gint ett_varbind;320static gint ett_name;321static gint ett_value;322static gint ett_decoding_error;323 324static int ett_snmp_Message;325static int ett_snmp_Messagev2u;326static int ett_snmp_T_datav2u;327static int ett_snmp_UsmSecurityParameters;328static int ett_snmp_SNMPv3Message;329static int ett_snmp_HeaderData;330static int ett_snmp_ScopedPduData;331static int ett_snmp_ScopedPDU;332static int ett_snmp_PDUs;333static int ett_snmp_PDU;334static int ett_snmp_BulkPDU;335static int ett_snmp_Trap_PDU_U;336static int ett_snmp_VarBind;337static int ett_snmp_VarBindList;338static int ett_snmp_SMUX_PDUs;339static int ett_snmp_RegisterResponse;340static int ett_snmp_OpenPDU;341static int ett_snmp_SimpleOpen_U;342static int ett_snmp_RReqPDU_U;343 344static expert_field ei_snmp_failed_decrypted_data_pdu;345static expert_field ei_snmp_decrypted_data_bad_formatted;346static expert_field ei_snmp_verify_authentication_error;347static expert_field ei_snmp_authentication_ok;348static expert_field ei_snmp_authentication_error;349static expert_field ei_snmp_varbind_not_uni_class_seq;350static expert_field ei_snmp_varbind_has_indicator;351static expert_field ei_snmp_objectname_not_oid;352static expert_field ei_snmp_objectname_has_indicator;353static expert_field ei_snmp_value_not_primitive_encoding;354static expert_field ei_snmp_invalid_oid;355static expert_field ei_snmp_varbind_wrong_tag;356static expert_field ei_snmp_varbind_response;357static expert_field ei_snmp_no_instance_subid;358static expert_field ei_snmp_wrong_num_of_subids;359static expert_field ei_snmp_index_suboid_too_short;360static expert_field ei_snmp_unimplemented_instance_index;361static expert_field ei_snmp_index_suboid_len0;362static expert_field ei_snmp_index_suboid_too_long;363static expert_field ei_snmp_index_string_too_long;364static expert_field ei_snmp_column_parent_not_row;365static expert_field ei_snmp_uint_too_large;366static expert_field ei_snmp_int_too_large;367static expert_field ei_snmp_integral_value0;368static expert_field ei_snmp_missing_mib;369static expert_field ei_snmp_varbind_wrong_length_value;370static expert_field ei_snmp_varbind_wrong_class_tag;371static expert_field ei_snmp_rfc1910_non_conformant;372static expert_field ei_snmp_rfc3411_non_conformant;373static expert_field ei_snmp_version_unknown;374static expert_field ei_snmp_trap_pdu_obsolete;375 376static const true_false_string auth_flags = {377"OK",378"Failed"379};380 381/* Security Models */382 383#define SNMP_SEC_ANY00384#define SNMP_SEC_V111385#define SNMP_SEC_V2C22386#define SNMP_SEC_USM33387 388static const value_string sec_models[] = {389{ SNMP_SEC_ANY0,"Any" },390{ SNMP_SEC_V11,"V1" },391{ SNMP_SEC_V2C2,"V2C" },392{ SNMP_SEC_USM3,"USM" },393{ 0,NULL((void*)0) }394};395 396#if 0397/* SMUX PDU types */398#define SMUX_MSG_OPEN 0399#define SMUX_MSG_CLOSE1400#define SMUX_MSG_RREQ2401#define SMUX_MSG_RRSP3402#define SMUX_MSG_SOUT4403 404static const value_string smux_types[] = {405{ SMUX_MSG_OPEN,"Open" },406{ SMUX_MSG_CLOSE,"Close" },407{ SMUX_MSG_RREQ,"Registration Request" },408{ SMUX_MSG_RRSP,"Registration Response" },409{ SMUX_MSG_SOUT,"Commit Or Rollback" },410{ 0,NULL((void*)0) }411};412#endif413 414/* Procedure names (used in Service Response Time) */415static const value_string snmp_procedure_names[] = {416{ 0,"Get" },417{ 1,"GetNext" },418{ 3,"Set" },419{ 4,"Register" },420{ 5,"Bulk" },421{ 6,"Inform" },422{ 0,NULL((void*)0) }423};424 425#define SNMP_IPA0 0/* IP Address */426#define SNMP_CNT1 1/* Counter (Counter32) */427#define SNMP_GGE2 2/* Gauge (Gauge32) */428#define SNMP_TIT3 3/* TimeTicks */429#define SNMP_OPQ4 4/* Opaque */430#define SNMP_NSP5 5/* NsapAddress */431#define SNMP_C646 6/* Counter64 */432#define SNMP_U327 7/* Uinteger32 */433 434#define SERR_NSO0 0435#define SERR_NSI1 1436#define SERR_EOM2 2437 438 439dissector_table_t value_sub_dissectors_table;440 441/*442 * Data structure attached to a conversation, request/response information443 */444typedef struct snmp_conv_info_t {445wmem_map_t *request_response;446} snmp_conv_info_t;447 448static snmp_conv_info_t*449snmp_find_conversation_and_get_conv_data(packet_info *pinfo);450 451static snmp_request_response_t *452snmp_get_request_response_pointer(wmem_map_t *map, guint32 requestId)453{454snmp_request_response_t *srrp=(snmp_request_response_t *)wmem_map_lookup(map, &requestId);455if (!srrp) {456srrp=wmem_new0(wmem_file_scope(), snmp_request_response_t)((snmp_request_response_t*)wmem_alloc0((wmem_file_scope()), sizeof
(snmp_request_response_t)))
;457srrp->requestId=requestId;458wmem_map_insert(map, &(srrp->requestId), (void *)srrp);459}460 461return srrp;462}463 464static snmp_request_response_t*465snmp_match_request_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint requestId, guint procedure_id, snmp_conv_info_t *snmp_info)466{467snmp_request_response_t *srrp=NULL((void*)0);468 469DISSECTOR_ASSERT_HINT(snmp_info, "No SNMP info from ASN1 context")((void) ((snmp_info) ? (void)0 : (proto_report_dissector_bug(
"%s:%u: failed assertion \"%s\" (%s)", "epan/dissectors/packet-snmp.c"
, 469, "snmp_info", "No SNMP info from ASN1 context"))))
;470 471/* get or create request/response pointer based on request id */472srrp=(snmp_request_response_t *)snmp_get_request_response_pointer(snmp_info->request_response, requestId);473 474// if not visited fill the request/response data475if (!PINFO_FD_VISITED(pinfo)((pinfo)->fd->visited)) {476switch(procedure_id)477{478case SNMP_REQ_GET0:479case SNMP_REQ_GETNEXT1:480case SNMP_REQ_SET3:481case SNMP_REQ_GETBULK5:482case SNMP_REQ_INFORM6:483srrp->request_frame_id=pinfo->fd->num;484srrp->response_frame_id=0;485srrp->request_time=pinfo->abs_ts;486srrp->request_procedure_id=procedure_id;487break;488case SNMP_RES_GET2:489srrp->response_frame_id=pinfo->fd->num;490break;491default:492return NULL((void*)0);493}494}495 496/* if request and response was matched */497if (srrp->request_frame_id!=0 && srrp->response_frame_id!=0)498{499proto_item *it;500 501// if it is the response502if (srrp->response_frame_id == pinfo->fd->num)503{504nstime_t ns;505it=proto_tree_add_uint(tree, hf_snmp_response_to, tvb, 0, 0, srrp->request_frame_id);506proto_item_set_generated(it);507nstime_delta(&ns, &pinfo->abs_ts, &srrp->request_time);508it=proto_tree_add_time(tree, hf_snmp_time, tvb, 0, 0, &ns);509proto_item_set_generated(it);510 511return srrp;512} else {513it=proto_tree_add_uint(tree, hf_snmp_response_in, tvb, 0, 0, srrp->response_frame_id);514proto_item_set_generated(it);515}516}517 518return NULL((void*)0);519}520 521static void522snmpstat_init(struct register_srt* srt _U___attribute__((unused)), GArray* srt_array)523{524srt_stat_table *snmp_srt_table;525guint32 i;526 527snmp_srt_table = init_srt_table("SNMP Commands", NULL((void*)0), srt_array, SNMP_NUM_PROCEDURES8, NULL((void*)0), "snmp.data", NULL((void*)0));528for (i = 0; i < SNMP_NUM_PROCEDURES8; i++)529{530init_srt_table_row(snmp_srt_table, i, val_to_str_const(i, snmp_procedure_names, "<unknown>"));531}532}533 534/* This is called only if request and response was matched -> no need to return anything than TAP_PACKET_REDRAW */535static tap_packet_status536snmpstat_packet(void *psnmp, packet_info *pinfo, epan_dissect_t *edt _U___attribute__((unused)), const void *psi, tap_flags_t flags _U___attribute__((unused)))537{538guint i = 0;539srt_stat_table *snmp_srt_table;540const snmp_request_response_t *snmp=(const snmp_request_response_t *)psi;541srt_data_t *data = (srt_data_t *)psnmp;542 543snmp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i)(((srt_stat_table**) (void *) (data->srt_array)->data) [
(i)])
;544 545add_srt_table_data(snmp_srt_table, snmp->request_procedure_id, &snmp->request_time, pinfo);546return TAP_PACKET_REDRAW;547}548 549static const gchar *550snmp_lookup_specific_trap (guint specific_trap)551{552guint i;553 554for (i = 0; i < num_specific_traps; i++) {555snmp_st_assoc_t *u = &(specific_traps[i]);556 557if ((u->trap == specific_trap) &&558 (strcmp (u->enterprise, enterprise_oid) == 0))559{560return u->desc;561}562}563 564return NULL((void*)0);565}566 567static int568dissect_snmp_variable_string(tvbuff_t *tvb, packet_info *pinfo _U___attribute__((unused)), proto_tree *tree, void *data _U___attribute__((unused)))569{570 571proto_tree_add_item(tree, hf_snmp_var_bind_str, tvb, 0, -1, ENC_ASCII0x00000000);572 573return tvb_captured_length(tvb);574}575 576/*577DateAndTime ::= TEXTUAL-CONVENTION578 DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"579 STATUS current580 DESCRIPTION581 "A date-time specification.582 583 field octets contents range584 ----- ------ -------- -----585 1 1-2 year* 0..65536586 2 3 month 1..12587 3 4 day 1..31588 4 5 hour 0..23589 5 6 minutes 0..59590 6 7 seconds 0..60591 (use 60 for leap-second)592 7 8 deci-seconds 0..9593 8 9 direction from UTC '+' / '-'594 9 10 hours from UTC* 0..13595 10 11 minutes from UTC 0..59596 597 * Notes:598 - the value of year is in network-byte order599 - daylight saving time in New Zealand is +13600 601 For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be602 displayed as:603 604 1992-5-26,13:30:15.0,-4:0605 606 Note that if only local time is known, then timezone607 information (fields 8-10) is not present."608 SYNTAX OCTET STRING (SIZE (8 | 11))609*/610static proto_item *611dissect_snmp_variable_date_and_time(proto_tree *tree, packet_info *pinfo, int hfid, tvbuff_t *tvb, int offset, int length)612{613guint16 year;614guint8 month;615guint8 day;616guint8 hour;617guint8 minutes;618guint8 seconds;619guint8 deci_seconds;620guint8 hour_from_utc;621guint8 min_from_utc;622gchar *str;623 624year= tvb_get_ntohs(tvb,offset);625month= tvb_get_guint8(tvb,offset+2);626day= tvb_get_guint8(tvb,offset+3);627hour= tvb_get_guint8(tvb,offset+4);628minutes= tvb_get_guint8(tvb,offset+5);629seconds= tvb_get_guint8(tvb,offset+6);630deci_seconds= tvb_get_guint8(tvb,offset+7);631if(length > 8){632hour_from_utc= tvb_get_guint8(tvb,offset+9);633min_from_utc= tvb_get_guint8(tvb,offset+10);634 635str = wmem_strdup_printf(pinfo->pool,636 "%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u",637 year,638 month,639 day,640 hour,641 minutes,642 seconds,643 deci_seconds,644 tvb_get_string_enc(pinfo->pool,tvb,offset+8,1,ENC_ASCII0x00000000|ENC_NA0x00000000),645 hour_from_utc,646 min_from_utc);647}else{648 str = wmem_strdup_printf(pinfo->pool,649 "%u-%u-%u, %u:%u:%u.%u",650 year,651 month,652 day,653 hour,654 minutes,655 seconds,656 deci_seconds);657}658 659return proto_tree_add_string(tree, hfid, tvb, offset, length, str);660 661}662 663/*664 * dissect_snmp_VarBind665 * this routine dissects variable bindings, looking for the oid information in our oid reporsitory666 * to format and add the value adequatelly.667 *668 * The choice to handwrite this code instead of using the asn compiler is to avoid having tons669 * of uses of global variables distributed in very different parts of the code.670 * Other than that there's a cosmetic thing: the tree from ASN generated code would be so671 * convoluted due to the nesting of CHOICEs in the definition of VarBind/value.672 *673 * XXX: the length of this function (~400 lines) is an aberration!674 * oid_key_t:key_type could become a series of callbacks instead of an enum675 * the (! oid_info_is_ok) switch could be made into an array (would be slower)676 *677 678NetworkAddress ::= CHOICE { internet IpAddress }679IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))680TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)681Integer32 ::= INTEGER (-2147483648..2147483647)682ObjectName ::= OBJECT IDENTIFIER683Counter32 ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295)684Gauge32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)685Unsigned32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)686Integer-value ::= INTEGER (-2147483648..2147483647)687Integer32 ::= INTEGER (-2147483648..2147483647)688ObjectID-value ::= OBJECT IDENTIFIER689Empty ::= NULL690TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)691Opaque ::= [APPLICATION 4] IMPLICIT OCTET STRING692Counter64 ::= [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615)693 694ObjectSyntax ::= CHOICE {695 simple SimpleSyntax,696 application-wide ApplicationSyntax697}698 699SimpleSyntax ::= CHOICE {700 integer-value Integer-value,701 string-value String-value,702 objectID-value ObjectID-value,703 empty Empty704}705 706ApplicationSyntax ::= CHOICE {707 ipAddress-value IpAddress,708 counter-value Counter32,709 timeticks-value TimeTicks,710 arbitrary-value Opaque,711 big-counter-value Counter64,712 unsigned-integer-value Unsigned32713}714 715ValueType ::= CHOICE {716 value ObjectSyntax,717 unSpecified NULL,718 noSuchObject[0] IMPLICIT NULL,719 noSuchInstance[1] IMPLICIT NULL,720 endOfMibView[2] IMPLICIT NULL721}722 723VarBind ::= SEQUENCE {724 name ObjectName,725 valueType ValueType726}727 728 */729 730static int731dissect_snmp_VarBind(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb, int offset,732 asn1_ctx_t *actx, proto_tree *tree, int hf_index _U___attribute__((unused)))733{734int seq_offset, name_offset, value_offset, value_start;735guint32 seq_len, name_len, value_len;736gint8 ber_class;737bool_Bool pc;738gint32 tag;739bool_Bool ind;740guint32* subids;741guint8* oid_bytes;742oid_info_t* oid_info = NULL((void*)0);743guint oid_matched, oid_left;744proto_item *pi_name, *pi_varbind, *pi_value = NULL((void*)0);745proto_tree *pt, *pt_varbind, *pt_name, *pt_value;746char label[ITEM_LABEL_LENGTH240];747const char* repr = NULL((void*)0);748const char* info_oid = NULL((void*)0);749char* valstr;750int hfid = -1;751int min_len = 0, max_len = 0;752bool_Bool oid_info_is_ok;753const char* oid_string = NULL((void*)0);754enum {BER_NO_ERROR, BER_WRONG_LENGTH, BER_WRONG_TAG} format_error = BER_NO_ERROR;755 756seq_offset = offset;757 758/* first have the VarBind's sequence header */759offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);760offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &seq_len, &ind);761 762if (!pc && ber_class==BER_CLASS_UNI0 && tag==BER_UNI_TAG_SEQUENCE16) {

1

Assuming 'pc' is true

763proto_item* pi;764pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),765ett_decoding_error, &pi, "VarBind must be an universal class sequence");766expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_not_uni_class_seq);767return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);768}769 770if (ind) {

2

Assuming 'ind' is false

3

Taking false branch

771proto_item* pi;772pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),773ett_decoding_error, &pi, "Indicator must be clear in VarBind");774expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_has_indicator);775return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);776}777 778/* we add the varbind tree root with a dummy label we'll fill later on */779pt_varbind = proto_tree_add_subtree(tree,tvb,offset,seq_len,ett_varbind,&pi_varbind,"VarBind");780*label = '\0';781 782seq_len += offset - seq_offset;783 784/* then we have the ObjectName's header */785 786offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);787name_offset = offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &name_len, &ind);788 789if (! ( !pc && ber_class==BER_CLASS_UNI0 && tag==BER_UNI_TAG_OID6) ) {

4

Assuming 'pc' is false

5

Assuming 'ber_class' is equal to BER_CLASS_UNI

6

Assuming 'tag' is equal to BER_UNI_TAG_OID

7

Taking false branch

790proto_item* pi;791pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,792ett_decoding_error, &pi, "ObjectName must be an OID in primitive encoding");793expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_not_oid);794return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);795}796 797if (ind) {

8

Assuming 'ind' is false

9

Taking false branch

798proto_item* pi;799pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,800ett_decoding_error, &pi, "Indicator must be clear in ObjectName");801expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_has_indicator);802return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);803}804 805pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,ENC_NA0x00000000);806pt_name = proto_item_add_subtree(pi_name,ett_name);807 808offset += name_len;809value_start = offset;810/* then we have the value's header */811offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);812value_offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &value_len, &ind);813 814if (! (!pc) ) {

10

Assuming 'pc' is false

11

Taking false branch

815proto_item* pi;816pt = proto_tree_add_subtree(pt_varbind, tvb, value_start, value_len,817ett_decoding_error, &pi, "the value must be in primitive encoding");818expert_add_info(actx->pinfo, pi, &ei_snmp_value_not_primitive_encoding);819return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);820}821 822/* Now, we know where everything is */823 824/* fetch ObjectName and its relative oid_info */825oid_bytes = (guint8*)tvb_memdup(actx->pinfo->pool, tvb, name_offset, name_len);826oid_info = oid_get_from_encoded(actx->pinfo->pool, oid_bytes, name_len, &subids, &oid_matched, &oid_left);827 828add_oid_debug_subtree(oid_info,pt_name)((void)0);829 830if (!subids) {

12

Assuming 'subids' is non-null

13

Taking false branch

831proto_item* pi;832 833repr = oid_encoded2string(actx->pinfo->pool, oid_bytes, name_len);834pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr);835expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr);836return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt);837}838 839if (oid_matched+oid_left) {

14

Assuming the condition is false

15

Taking false branch

840oid_string = oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left);841}842 843if (ber_class == BER_CLASS_CON2) {

16

Assuming 'ber_class' is not equal to BER_CLASS_CON

17

Taking false branch

844/* if we have an error value just add it and get out the way ASAP */845proto_item* pi;846const char* note;847 848if (value_len != 0) {849min_len = max_len = 0;850format_error = BER_WRONG_LENGTH;851}852 853switch (tag) {854case SERR_NSO0:855hfid = hf_snmp_noSuchObject;856note = "noSuchObject";857break;858case SERR_NSI1:859hfid = hf_snmp_noSuchInstance;860note = "noSuchInstance";861break;862case SERR_EOM2:863hfid = hf_snmp_endOfMibView;864note = "endOfMibView";865break;866default: {867pt = proto_tree_add_subtree_format(pt_varbind,tvb,0,0,ett_decoding_error,&pi,868"Wrong tag for Error Value: expected 0, 1, or 2 but got: %d",tag);869expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_tag);870return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);871}872}873 874pi = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);875expert_add_info_format(actx->pinfo, pi, &ei_snmp_varbind_response, "%s",note);876(void) g_strlcpy (label, note, ITEM_LABEL_LENGTH240);877goto set_label;878}879 880/* now we'll try to figure out which are the indexing sub-oids and whether the oid we know about is the one oid we have to use */881switch (oid_info->kind) {

18

Control jumps to the 'default' case at line 1062

882case OID_KIND_SCALAR:883if (oid_left == 1) {884/* OK: we got the instance sub-id */885proto_tree_add_uint64(pt_name,hf_snmp_scalar_instance_index,tvb,name_offset,name_len,subids[oid_matched]);886oid_info_is_ok = TRUE(!(0));887goto indexing_done;888} else if (oid_left == 0) {889if (ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {890/* unSpecified does not require an instance sub-id add the new value and get off the way! */891pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);892goto set_label;893} else {894proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_no_instance_subid,tvb,0,0);895oid_info_is_ok = FALSE(0);896goto indexing_done;897}898} else {899proto_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);900oid_info_is_ok = FALSE(0);901goto indexing_done;902}903break;904case OID_KIND_COLUMN:905if ( oid_info->parent->kind == OID_KIND_ROW) {906oid_key_t* k = oid_info->parent->key;907guint key_start = oid_matched;908guint key_len = oid_left;909oid_info_is_ok = TRUE(!(0));910 911if ( key_len == 0 && ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {912/* unSpecified does not require an instance sub-id add the new value and get off the way! */913pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);914goto set_label;915}916 917if (k) {918for (;k;k = k->next) {919guint suboid_len;920 921if (key_start >= oid_matched+oid_left) {922proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_short,tvb,0,0);923oid_info_is_ok = FALSE(0);924goto indexing_done;925}926 927switch(k->key_type) {928case OID_KEY_TYPE_WRONG: {929proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);930oid_info_is_ok = FALSE(0);931goto indexing_done;932}933case OID_KEY_TYPE_INTEGER: {934if (FT_IS_INT(k->ft_type)(((k->ft_type) == FT_INT8 || (k->ft_type) == FT_INT16 ||
(k->ft_type) == FT_INT24 || (k->ft_type) == FT_INT32) ||
((k->ft_type) == FT_INT40 || (k->ft_type) == FT_INT48 ||
(k->ft_type) == FT_INT56 || (k->ft_type) == FT_INT64))
) {935proto_tree_add_int(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);936} else { /* if it's not an unsigned int let proto_tree_add_uint throw a warning */937proto_tree_add_uint64(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);938}939key_start++;940key_len--;941continue; /* k->next */942}943case OID_KEY_TYPE_IMPLIED_OID:944suboid_len = key_len;945 946goto show_oid_index;947 948case OID_KEY_TYPE_OID: {949guint8* suboid_buf;950guint suboid_buf_len;951guint32* suboid;952 953suboid_len = subids[key_start++];954key_len--;955 956show_oid_index:957suboid = &(subids[key_start]);958 959if( suboid_len == 0 ) {960proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_len0,tvb,0,0);961oid_info_is_ok = FALSE(0);962goto indexing_done;963}964 965if( key_len < suboid_len ) {966proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_long,tvb,0,0);967oid_info_is_ok = FALSE(0);968goto indexing_done;969}970 971suboid_buf_len = oid_subid2encoded(actx->pinfo->pool, suboid_len, suboid, &suboid_buf);972 973DISSECTOR_ASSERT(suboid_buf_len)((void) ((suboid_buf_len) ? (void)0 : (proto_report_dissector_bug
("%s:%u: failed assertion \"%s\"", "epan/dissectors/packet-snmp.c"
, 973, "suboid_buf_len"))))
;974 975proto_tree_add_oid(pt_name,k->hfid,tvb,name_offset, suboid_buf_len, suboid_buf);976 977key_start += suboid_len;978key_len -= suboid_len + 1;979continue; /* k->next */980}981default: {982guint8* buf;983guint buf_len;984guint32* suboid;985guint i;986 987 988switch (k->key_type) {989case OID_KEY_TYPE_IPADDR:990suboid = &(subids[key_start]);991buf_len = 4;992break;993case OID_KEY_TYPE_IMPLIED_STRING:994case OID_KEY_TYPE_IMPLIED_BYTES:995case OID_KEY_TYPE_ETHER:996suboid = &(subids[key_start]);997buf_len = key_len;998break;999default:1000buf_len = k->num_subids;1001suboid = &(subids[key_start]);1002 1003if(!buf_len) {1004buf_len = *suboid++;1005key_len--;1006key_start++;1007}1008break;1009}1010 1011if( key_len < buf_len ) {1012proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_string_too_long,tvb,0,0);1013oid_info_is_ok = FALSE(0);1014goto indexing_done;1015}1016 1017buf = (guint8*)wmem_alloc(actx->pinfo->pool, buf_len+1);1018for (i = 0; i < buf_len; i++)1019buf[i] = (guint8)suboid[i];1020buf[i] = '\0';1021 1022switch(k->key_type) {1023case OID_KEY_TYPE_STRING:1024case OID_KEY_TYPE_IMPLIED_STRING:1025proto_tree_add_string(pt_name,k->hfid,tvb,name_offset,buf_len, buf);1026break;1027case OID_KEY_TYPE_BYTES:1028case OID_KEY_TYPE_NSAP:1029case OID_KEY_TYPE_IMPLIED_BYTES:1030proto_tree_add_bytes(pt_name,k->hfid,tvb,name_offset,buf_len, buf);1031break;1032case OID_KEY_TYPE_ETHER:1033proto_tree_add_ether(pt_name,k->hfid,tvb,name_offset,buf_len, buf);1034break;1035case OID_KEY_TYPE_IPADDR: {1036guint32* ipv4_p = (guint32*)buf;1037proto_tree_add_ipv4(pt_name,k->hfid,tvb,name_offset,buf_len, *ipv4_p);1038}1039break;1040default:1041DISSECTOR_ASSERT_NOT_REACHED()(proto_report_dissector_bug("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\""
, "epan/dissectors/packet-snmp.c", 1041))
;1042break;1043}1044 1045key_start += buf_len;1046key_len -= buf_len;1047continue; /* k->next*/1048}1049}1050}1051goto indexing_done;1052} else {1053proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);1054oid_info_is_ok = FALSE(0);1055goto indexing_done;1056}1057} else {1058proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_column_parent_not_row,tvb,0,0);1059oid_info_is_ok = FALSE(0);1060goto indexing_done;1061}1062default: {1063/*proto_tree_add_expert (pt_name,actx->pinfo,PI_MALFORMED, PI_WARN,tvb,0,0,"This kind OID should have no value"); */1064oid_info_is_ok = FALSE(0);1065goto indexing_done;1066}1067}1068indexing_done:1069 1070if (oid_info_is_ok

18.1

'oid_info_is_ok' is false
&& oid_info->value_type) {1071if (ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {1072pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);1073} else {1074/* Provide a tree_item to attach errors to, if needed. */1075pi_value = pi_name;1076 1077if ((oid_info->value_type->ber_class != BER_CLASS_ANY99) &&1078(ber_class != oid_info->value_type->ber_class))1079format_error = BER_WRONG_TAG;1080else if ((oid_info->value_type->ber_tag != BER_TAG_ANY-1) &&1081(tag != oid_info->value_type->ber_tag))1082format_error = BER_WRONG_TAG;1083else {1084max_len = oid_info->value_type->max_len == -1 ? 0xffffff : oid_info->value_type->max_len;1085min_len = oid_info->value_type->min_len;1086 1087if ((int)value_len < min_len || (int)value_len > max_len)1088format_error = BER_WRONG_LENGTH;1089}1090 1091if (format_error == BER_NO_ERROR) {1092/* Special case DATE AND TIME */1093if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){1094pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, oid_info->value_hfid, tvb, value_offset, value_len);1095} else {1096pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);1097}1098}1099}1100} else {1101switch(ber_class|(tag<<4)) {

19

Control jumps to 'case 32:' at line 1102

1102case BER_CLASS_UNI0|(BER_UNI_TAG_INTEGER2<<4):1103{1104gint64 val=0;1105unsigned int int_val_offset = value_offset;1106unsigned int i;1107 1108max_len = 4; min_len = 1;1109if (value_len > (guint)max_len || value_len < (guint)min_len) {

20

Assuming 'value_len' is <= 'max_len'

21

Assuming 'value_len' is >= 'min_len'

22

Taking false branch

1110hfid = hf_snmp_integer32_value;1111format_error = BER_WRONG_LENGTH;1112break;1113}1114 1115if(value_len

22.1

'value_len' is > 0
> 0) {

23

Taking true branch

1116/* extend sign bit */1117if(tvb_get_guint8(tvb, int_val_offset)&0x80) {

24

Assuming the condition is true

25

Taking true branch

1118val=-1;

26

The value -1 is assigned to 'val'

1119}1120for(i=0;i

26.1

'i' is < 'value_len'
<value_len;i++) {

27

Loop condition is true. Entering loop body

1121val=(val<<8)|tvb_get_guint8(tvb, int_val_offset);

28

The result of the left shift is undefined because the left operand is negative
1122int_val_offset++;1123}1124}1125pi_value = proto_tree_add_int64(pt_varbind, hf_snmp_integer32_value, tvb,value_offset,value_len, val);1126 1127goto already_added;1128}1129case BER_CLASS_UNI0|(BER_UNI_TAG_OCTETSTRING4<<4):1130if(oid_info->value_hfid> -1){1131hfid = oid_info->value_hfid;1132}else{1133hfid = hf_snmp_octetstring_value;1134}1135break;1136case BER_CLASS_UNI0|(BER_UNI_TAG_OID6<<4):1137max_len = -1; min_len = 1;1138if (value_len < (guint)min_len) format_error = BER_WRONG_LENGTH;1139hfid = hf_snmp_oid_value;1140break;1141case BER_CLASS_UNI0|(BER_UNI_TAG_NULL5<<4):1142max_len = 0; min_len = 0;1143if (value_len != 0) format_error = BER_WRONG_LENGTH;1144hfid = hf_snmp_null_value;1145break;1146case BER_CLASS_APP1: /* | (SNMP_IPA<<4)*/1147switch(value_len) {1148case 4: hfid = hf_snmp_ipv4_value; break;1149case 16: hfid = hf_snmp_ipv6_value; break;1150default: hfid = hf_snmp_anyaddress_value; break;1151}1152break;1153case BER_CLASS_APP1|(SNMP_U327<<4):1154hfid = hf_snmp_unsigned32_value;1155break;1156case BER_CLASS_APP1|(SNMP_GGE2<<4):1157hfid = hf_snmp_gauge32_value;1158break;1159case BER_CLASS_APP1|(SNMP_CNT1<<4):1160hfid = hf_snmp_counter_value;1161break;1162case BER_CLASS_APP1|(SNMP_TIT3<<4):1163hfid = hf_snmp_timeticks_value;1164break;1165case BER_CLASS_APP1|(SNMP_OPQ4<<4):1166hfid = hf_snmp_opaque_value;1167break;1168case BER_CLASS_APP1|(SNMP_NSP5<<4):1169hfid = hf_snmp_nsap_value;1170break;1171case BER_CLASS_APP1|(SNMP_C646<<4):1172hfid = hf_snmp_big_counter_value;1173break;1174default:1175hfid = hf_snmp_unknown_value;1176break;1177}1178if (value_len > 8) {1179/*1180 * Too long for an FT_UINT64 or an FT_INT64.1181 */1182header_field_info *hfinfo = proto_registrar_get_nth(hfid);1183if (hfinfo->type == FT_UINT64) {1184/*1185 * Check if this is an unsigned int64 with1186 * a big value.1187 */1188if (value_len > 9 || tvb_get_guint8(tvb, value_offset) != 0) {1189/* It is. Fail. */1190proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_uint_too_large,tvb,value_offset,value_len,"Integral value too large");1191goto already_added;1192}1193/* Cheat and skip the leading 0 byte */1194value_len--;1195value_offset++;1196} else if (hfinfo->type == FT_INT64) {1197/*1198 * For now, just reject these.1199 */1200proto_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");1201goto already_added;1202}1203} else if (value_len == 0) {1204/*1205 * X.690 section 8.3.1 "Encoding of an integer value":1206 * "The encoding of an integer value shall be1207 * primitive. The contents octets shall consist of1208 * one or more octets."1209 *1210 * Zero is not "one or more".1211 */1212header_field_info *hfinfo = proto_registrar_get_nth(hfid);1213if (hfinfo->type == FT_UINT64 || hfinfo->type == FT_INT64) {1214proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_integral_value0,tvb,value_offset,value_len,"Integral value is zero-length");1215goto already_added;1216}1217}1218/* Special case DATE AND TIME */1219if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){1220pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, hfid, tvb, value_offset, value_len);1221}else{1222pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);1223}1224if (format_error != BER_NO_ERROR) {1225expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib);1226}1227 1228}1229already_added:1230pt_value = proto_item_add_subtree(pi_value,ett_value);1231 1232if (value_len > 0 && oid_string) {1233tvbuff_t* sub_tvb = tvb_new_subset_length(tvb, value_offset, value_len);1234 1235next_tvb_add_string(var_list, sub_tvb, (snmp_var_in_tree) ? pt_value : NULL((void*)0), value_sub_dissectors_table, oid_string);1236}1237 1238 1239set_label:1240if (pi_value) proto_item_fill_label(PITEM_FINFO(pi_value)((pi_value)->finfo), label);1241 1242if (oid_info && oid_info->name) {1243if (oid_left >= 1) {1244repr = wmem_strdup_printf(actx->pinfo->pool, "%s.%s (%s)", oid_info->name,1245oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left),1246oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left));1247info_oid = wmem_strdup_printf(actx->pinfo->pool, "%s.%s", oid_info->name,1248oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left));1249} else {1250repr = wmem_strdup_printf(actx->pinfo->pool, "%s (%s)", oid_info->name,1251oid_subid2string(actx->pinfo->pool, subids,oid_matched));1252info_oid = oid_info->name;1253}1254} else if (oid_string) {1255repr = wmem_strdup(actx->pinfo->pool, oid_string);1256info_oid = oid_string;1257} else {1258repr = wmem_strdup(actx->pinfo->pool, "[Bad OID]");1259}1260 1261valstr = strstr(label,": ");1262valstr = valstr ? valstr+2 : label;1263 1264proto_item_set_text(pi_varbind,"%s: %s",repr,valstr);1265 1266if (display_oid && info_oid) {1267col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", info_oid);1268}1269 1270switch (format_error) {1271case BER_WRONG_LENGTH: {1272proto_item* pi;1273proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);1274pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,1275 "Wrong value length: %u expecting: %u <= len <= %u",1276 value_len, min_len, max_len == -1 ? 0xFFFFFF : max_len);1277expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_length_value);1278return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);1279}1280case BER_WRONG_TAG: {1281proto_item* pi;1282proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);1283pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,1284 "Wrong class/tag for Value expected: %d,%d got: %d,%d",1285 oid_info->value_type->ber_class, oid_info->value_type->ber_tag,1286 ber_class, tag);1287expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_class_tag);1288return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);1289}1290default:1291break;1292}1293 1294return seq_offset + seq_len;1295}1296 1297 1298#define F_SNMP_ENGINEID_CONFORM0x80 0x801299#define SNMP_ENGINEID_RFC19100x00 0x001300#define SNMP_ENGINEID_RFC34110x01 0x011301 1302static const true_false_string tfs_snmp_engineid_conform = {1303"RFC3411 (SNMPv3)",1304"RFC1910 (Non-SNMPv3)"1305};1306 1307#define SNMP_ENGINEID_FORMAT_IPV40x01 0x011308#define SNMP_ENGINEID_FORMAT_IPV60x02 0x021309#define SNMP_ENGINEID_FORMAT_MACADDRESS0x03 0x031310#define SNMP_ENGINEID_FORMAT_TEXT0x04 0x041311#define SNMP_ENGINEID_FORMAT_OCTETS0x05 0x051312#define SNMP_ENGINEID_FORMAT_LOCAL0x06 0x061313 1314static const value_string snmp_engineid_format_vals[] = {1315{ SNMP_ENGINEID_FORMAT_IPV40x01,"IPv4 address" },1316{ SNMP_ENGINEID_FORMAT_IPV60x02,"IPv6 address" },1317{ SNMP_ENGINEID_FORMAT_MACADDRESS0x03,"MAC address" },1318{ SNMP_ENGINEID_FORMAT_TEXT0x04,"Text, administratively assigned" },1319{ SNMP_ENGINEID_FORMAT_OCTETS0x05,"Octets, administratively assigned" },1320{ SNMP_ENGINEID_FORMAT_LOCAL0x06, "Local engine" },1321{ 0,NULL((void*)0) }1322};1323 1324#define SNMP_ENGINEID_CISCO_AGENT0x00 0x001325#define SNMP_ENGINEID_CISCO_MANAGER0x01 0x011326 1327static const value_string snmp_engineid_cisco_type_vals[] = {1328{ SNMP_ENGINEID_CISCO_AGENT0x00,"Agent" },1329{ SNMP_ENGINEID_CISCO_MANAGER0x01,"Manager" },1330{ 0,NULL((void*)0) }1331};1332 1333/*1334 * SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)1335 * or historic RFC 1910 (AgentID)1336 */1337int1338dissect_snmp_engineid(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, int len)1339{1340proto_item *item = NULL((void*)0);1341guint8 conformance, format;1342guint32 enterpriseid;1343time_t seconds;1344nstime_t ts;1345int len_remain = len;1346 1347/* first bit: engine id conformance */1348if (len_remain<1) return offset;1349conformance = ((tvb_get_guint8(tvb, offset)>>7) & 0x01);1350proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);1351 1352/* 4-byte enterprise number/name */1353if (len_remain<4) return offset;1354enterpriseid = tvb_get_ntohl(tvb, offset);1355if (conformance)1356enterpriseid -= 0x80000000; /* ignore first bit */1357proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);1358offset+=4;1359len_remain-=4;1360 1361switch(conformance) {1362 1363case SNMP_ENGINEID_RFC19100x00:1364/* 12-byte AgentID w/ 8-byte trailer */1365if (len_remain==8) {1366proto_tree_add_item(tree, hf_snmp_agentid_trailer, tvb, offset, 8, ENC_NA0x00000000);1367offset+=8;1368len_remain-=8;1369} else {1370proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain);1371return offset;1372}1373break;1374 1375case SNMP_ENGINEID_RFC34110x01: /* variable length: 5..32 */1376 1377/* 1-byte format specifier */1378if (len_remain<1) return offset;1379format = tvb_get_guint8(tvb, offset);1380item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)",1381 val_to_str_const(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"),1382 format);1383offset+=1;1384len_remain-=1;1385 1386switch(format) {1387case SNMP_ENGINEID_FORMAT_IPV40x01:1388/* 4-byte IPv4 address */1389if (len_remain==4) {1390proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);1391offset+=4;1392len_remain=0;1393}1394break;1395case SNMP_ENGINEID_FORMAT_IPV60x02:1396/* 16-byte IPv6 address */1397if (len_remain==16) {1398proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA0x00000000);1399offset+=16;1400len_remain=0;1401}1402break;1403case SNMP_ENGINEID_FORMAT_MACADDRESS0x03:1404/* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */1405if ((enterpriseid==9)&&(len_remain==7)) {1406proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);1407offset++;1408len_remain--;1409}1410/* 6-byte MAC address */1411if (len_remain==6) {1412proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_NA0x00000000);1413offset+=6;1414len_remain=0;1415}1416break;1417case SNMP_ENGINEID_FORMAT_TEXT0x04:1418/* max. 27-byte string, administratively assigned */1419if (len_remain<=27) {1420proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII0x00000000);1421offset+=len_remain;1422len_remain=0;1423}1424break;1425case SNMP_ENGINEID_FORMAT_LOCAL0x06:1426break;1427case 128:1428/* most common enterprise-specific format: (ucd|net)-snmp random */1429if ((enterpriseid==2021)||(enterpriseid==8072)) {1430proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");1431/* demystify: 4B random, 4B/8B epoch seconds */1432if ((len_remain==8) || (len_remain==12)) {1433proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA0x00000000);1434if (len_remain==8) {1435seconds = (time_t)tvb_get_letohl(tvb, offset + 4);1436} else {1437seconds = (time_t)tvb_get_letohi64(tvb, offset + 4);1438}1439ts.secs = seconds;1440ts.nsecs = 0;1441proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset + 4, len_remain - 4,1442 &ts, "%s",1443 abs_time_secs_to_str(pinfo->pool, seconds, ABSOLUTE_TIME_LOCAL, TRUE)abs_time_secs_to_str_ex(pinfo->pool, seconds, ABSOLUTE_TIME_LOCAL
, ((!(0))) ? (1U << 0) : 0)
);1444offset+=len_remain;1445len_remain=0;1446}1447break;1448}1449/* fall through */1450case SNMP_ENGINEID_FORMAT_OCTETS0x05:1451default:1452/* max. 27 bytes, administratively assigned or unknown format */1453if (len_remain>0 && len_remain<=27) {1454proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA0x00000000);1455offset+=len_remain;1456len_remain=0;1457}1458break;1459}1460}1461 1462if (len_remain>0) {1463proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain);1464offset+=len_remain;1465}1466return offset;1467}1468 1469 1470static void set_ue_keys(snmp_ue_assoc_t* n ) {1471guint key_size = auth_hash_len[n->user.authModel];1472 1473n->user.authKey.data = (guint8 *)g_malloc(key_size);1474n->user.authKey.len = key_size;1475snmp_usm_password_to_key(n->user.authModel,1476 n->user.authPassword.data,1477 n->user.authPassword.len,1478 n->engine.data,1479 n->engine.len,1480 n->user.authKey.data);1481 1482if (n->priv_proto == PRIV_AES1281 || n->priv_proto == PRIV_AES1922 || n->priv_proto == PRIV_AES2563) {1483guint need_key_len =1484(n->priv_proto == PRIV_AES1281) ? 16 :1485(n->priv_proto == PRIV_AES1922) ? 24 :1486(n->priv_proto == PRIV_AES2563) ? 32 :14870;1488 1489guint key_len = key_size;1490 1491while (key_len < need_key_len)1492key_len += key_size;1493 1494n->user.privKey.data = (guint8 *)g_malloc(key_len);1495n->user.privKey.len = need_key_len;1496 1497snmp_usm_password_to_key(n->user.authModel,1498 n->user.privPassword.data,1499 n->user.privPassword.len,1500 n->engine.data,1501 n->engine.len,1502 n->user.privKey.data);1503 1504key_len = key_size;1505 1506/* extend key if needed */1507while (key_len < need_key_len) {1508snmp_usm_password_to_key(n->user.authModel,1509 n->user.privKey.data,1510 key_len,1511 n->engine.data,1512 n->engine.len,1513 n->user.privKey.data + key_len);1514 1515key_len += key_size;1516}1517 1518} else {1519n->user.privKey.data = (guint8 *)g_malloc(key_size);1520n->user.privKey.len = key_size;1521snmp_usm_password_to_key(n->user.authModel,1522 n->user.privPassword.data,1523 n->user.privPassword.len,1524 n->engine.data,1525 n->engine.len,1526 n->user.privKey.data);1527}1528}1529 1530static snmp_ue_assoc_t*1531ue_dup(snmp_ue_assoc_t* o)1532{1533snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));1534 1535d->user.authModel = o->user.authModel;1536 1537d->user.privProtocol = o->user.privProtocol;1538 1539d->user.userName.data = (guint8 *)g_memdup2(o->user.userName.data,o->user.userName.len);1540d->user.userName.len = o->user.userName.len;1541 1542d->user.authPassword.data = o->user.authPassword.data ? (guint8 *)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL((void*)0);1543d->user.authPassword.len = o->user.authPassword.len;1544 1545d->user.privPassword.data = o->user.privPassword.data ? (guint8 *)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL((void*)0);1546d->user.privPassword.len = o->user.privPassword.len;1547 1548d->engine.len = o->engine.len;1549 1550if (d->engine.len) {1551d->engine.data = (guint8 *)g_memdup2(o->engine.data,o->engine.len);1552set_ue_keys(d);1553}1554 1555return d;1556 1557}1558 1559static void*1560snmp_users_copy_cb(void* dest, const void* orig, size_t len _U___attribute__((unused)))1561{1562const snmp_ue_assoc_t* o = (const snmp_ue_assoc_t*)orig;1563snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)dest;1564 1565d->auth_model = o->auth_model;1566d->user.authModel = (snmp_usm_auth_model_t) o->auth_model;1567 1568d->priv_proto = o->priv_proto;1569d->user.privProtocol = priv_protos[o->priv_proto];1570 1571d->user.userName.data = (guint8*)g_memdup2(o->user.userName.data,o->user.userName.len);1572d->user.userName.len = o->user.userName.len;1573 1574d->user.authPassword.data = o->user.authPassword.data ? (guint8*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL((void*)0);1575d->user.authPassword.len = o->user.authPassword.len;1576 1577d->user.privPassword.data = o->user.privPassword.data ? (guint8*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL((void*)0);1578d->user.privPassword.len = o->user.privPassword.len;1579 1580d->engine.len = o->engine.len;1581if (o->engine.data) {1582d->engine.data = (guint8*)g_memdup2(o->engine.data,o->engine.len);1583}1584 1585d->user.authKey.data = o->user.authKey.data ? (guint8*)g_memdup2(o->user.authKey.data,o->user.authKey.len) : NULL((void*)0);1586d->user.authKey.len = o->user.authKey.len;1587 1588d->user.privKey.data = o->user.privKey.data ? (guint8*)g_memdup2(o->user.privKey.data,o->user.privKey.len) : NULL((void*)0);1589d->user.privKey.len = o->user.privKey.len;1590 1591return d;1592}1593 1594static void1595snmp_users_free_cb(void* p)1596{1597snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;1598g_free(ue->user.userName.data);1599g_free(ue->user.authPassword.data);1600g_free(ue->user.privPassword.data);1601g_free(ue->user.authKey.data);1602g_free(ue->user.privKey.data);1603g_free(ue->engine.data);1604}1605 1606static bool_Bool1607snmp_users_update_cb(void* p _U___attribute__((unused)), char** err)1608{1609snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;1610GString* es = g_string_new("");1611unsigned int i;1612 1613*err = NULL((void*)0);1614 1615if (! ue->user.userName.len) {1616g_string_append_printf(es,"no userName\n");1617} else if ((ue->engine.len > 0) && (ue->engine.len < 5 || ue->engine.len > 32)) {1618/* RFC 3411 section 5 */1619g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", ue->engine.len);1620} else if (num_ueas) {1621for (i=0; i<num_ueas-1; i++) {1622snmp_ue_assoc_t* u = &(ueas[i]);1623 1624if ( u->user.userName.len == ue->user.userName.len1625&& u->engine.len == ue->engine.len && (u != ue)) {1626 1627if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {1628if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {1629/* XXX: make a string for the engineId */1630g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);1631break;1632}1633}1634 1635if (u->engine.len == 0) {1636if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {1637g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);1638break;1639}1640}1641}1642}1643}1644 1645if (es->len) {1646es = g_string_truncate(es,es->len-1);1647*err = g_string_free(es, FALSE(0));1648return FALSE(0);1649}1650 1651return TRUE(!(0));1652}1653 1654static void1655free_ue_cache(snmp_ue_assoc_t **cache)1656{1657static snmp_ue_assoc_t *a, *nxt;1658 1659for (a = *cache; a; a = nxt) {1660nxt = a->next;1661snmp_users_free_cb(a);1662g_free(a);1663}1664 1665*cache = NULL((void*)0);1666}1667 1668#define CACHE_INSERT(c,a)if (c) { snmp_ue_assoc_t* t = c; c = a; c->next = t; } else
{ c = a; a->next = ((void*)0); }
if (c) { snmp_ue_assoc_t* t = c; c = a; c->next = t; } else { c = a; a->next = NULL((void*)0); }
1669 1670static void1671init_ue_cache(void)1672{1673guint i;1674 1675for (i = 0; i < num_ueas; i++) {1676snmp_ue_assoc_t* a = ue_dup(&(ueas[i]));1677 1678if (a->engine.len) {1679CACHE_INSERT(localized_ues,a)if (localized_ues) { snmp_ue_assoc_t* t = localized_ues; localized_ues
= a; localized_ues->next = t; } else { localized_ues = a;
a->next = ((void*)0); }
;1680 1681} else {1682CACHE_INSERT(unlocalized_ues,a)if (unlocalized_ues) { snmp_ue_assoc_t* t = unlocalized_ues; unlocalized_ues
= a; unlocalized_ues->next = t; } else { unlocalized_ues =
a; a->next = ((void*)0); }
;1683}1684 1685}1686}1687 1688static void1689cleanup_ue_cache(void)1690{1691free_ue_cache(&localized_ues);1692free_ue_cache(&unlocalized_ues);1693}1694 1695/* Called when the user applies changes to UAT preferences. */1696static void1697renew_ue_cache(void)1698{1699cleanup_ue_cache();1700init_ue_cache();1701}1702 1703 1704static snmp_ue_assoc_t*1705localize_ue( snmp_ue_assoc_t* o, const guint8* engine, guint engine_len )1706{1707snmp_ue_assoc_t* n = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));1708 1709n->user.userName.data = (guint8*)g_memdup2(o->user.userName.data,o->user.userName.len);1710n->user.authModel = o->user.authModel;1711n->user.authPassword.data = (guint8*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len);1712n->user.authPassword.len = o->user.authPassword.len;1713n->user.privPassword.data = (guint8*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len);1714n->user.privPassword.len = o->user.privPassword.len;1715n->user.authKey.data = (guint8*)g_memdup2(o->user.authKey.data,o->user.authKey.len);1716n->user.privKey.data = (guint8*)g_memdup2(o->user.privKey.data,o->user.privKey.len);1717n->engine.data = (guint8*)g_memdup2(engine,engine_len);1718n->engine.len = engine_len;1719n->priv_proto = o->priv_proto;1720 1721set_ue_keys(n);1722 1723return n;1724}1725 1726 1727#define localized_match(a,u,ul,e,el)( a->user.userName.len == ul && a->engine.len ==
el && memcmp( a->user.userName.data, u, ul ) == 0
&& memcmp( a->engine.data, e, el ) == 0 )
\
1728( a->user.userName.len == ul \1729&& a->engine.len == el \1730&& memcmp( a->user.userName.data, u, ul ) == 0 \1731&& memcmp( a->engine.data, e, el ) == 0 )1732 1733#define unlocalized_match(a,u,l)( a->user.userName.len == l && memcmp( a->user.
userName.data, u, l) == 0 )
\
1734( a->user.userName.len == l && memcmp( a->user.userName.data, u, l) == 0 )1735 1736static snmp_ue_assoc_t*1737get_user_assoc(tvbuff_t* engine_tvb, tvbuff_t* user_tvb, packet_info *pinfo)1738{1739static snmp_ue_assoc_t* a;1740guint given_username_len;1741guint8* given_username;1742guint given_engine_len = 0;1743guint8* given_engine = NULL((void*)0);1744 1745if ( ! (localized_ues || unlocalized_ues ) ) return NULL((void*)0);1746 1747if (! ( user_tvb && engine_tvb ) ) return NULL((void*)0);1748 1749given_username_len = tvb_captured_length(user_tvb);1750given_engine_len = tvb_captured_length(engine_tvb);1751if (! ( given_engine_len && given_username_len ) ) return NULL((void*)0);1752given_username = (guint8*)tvb_memdup(pinfo->pool,user_tvb,0,-1);1753given_engine = (guint8*)tvb_memdup(pinfo->pool,engine_tvb,0,-1);1754 1755for (a = localized_ues; a; a = a->next) {1756if ( localized_match(a, given_username, given_username_len, given_engine, given_engine_len)( a->user.userName.len == given_username_len && a->
engine.len == given_engine_len && memcmp( a->user.
userName.data, given_username, given_username_len ) == 0 &&
memcmp( a->engine.data, given_engine, given_engine_len ) ==
0 )
) {1757return a;1758}1759}1760 1761for (a = unlocalized_ues; a; a = a->next) {1762if ( unlocalized_match(a, given_username, given_username_len)( a->user.userName.len == given_username_len && memcmp
( a->user.userName.data, given_username, given_username_len
) == 0 )
) {1763snmp_ue_assoc_t* n = localize_ue( a, given_engine, given_engine_len );1764CACHE_INSERT(localized_ues,n)if (localized_ues) { snmp_ue_assoc_t* t = localized_ues; localized_ues
= n; localized_ues->next = t; } else { localized_ues = n;
n->next = ((void*)0); }
;1765return n;1766}1767}1768 1769return NULL((void*)0);1770}1771 1772static bool_Bool1773snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, guint8** calc_auth_p,1774guint* calc_auth_len_p, gchar const** error)1775{1776gint msg_len;1777guint8* msg;1778guint auth_len;1779guint8* auth;1780guint8* key;1781guint key_len;1782guint8 *calc_auth;1783guint start;1784guint end;1785guint i;1786 1787if (!p->auth_tvb) {1788*error = "No Authenticator";1789return FALSE(0);1790}1791 1792key = p->user_assoc->user.authKey.data;1793key_len = p->user_assoc->user.authKey.len;1794 1795if (! key ) {1796*error = "User has no authKey";1797return FALSE(0);1798}1799 1800auth_len = tvb_captured_length(p->auth_tvb);1801 1802if (auth_len != auth_tag_len[model]) {1803*error = "Authenticator length wrong";1804return FALSE(0);1805}1806 1807msg_len = tvb_captured_length(p->msg_tvb);1808if (msg_len <= 0) {1809*error = "Not enough data remaining";1810return FALSE(0);1811}1812msg = (guint8*)tvb_memdup(pinfo->pool,p->msg_tvb,0,msg_len);1813 1814auth = (guint8*)tvb_memdup(pinfo->pool,p->auth_tvb,0,auth_len);1815 1816start = p->auth_offset - p->start_offset;1817end = start + auth_len;1818 1819/* fill the authenticator with zeros */1820for ( i = start ; i < end ; i++ ) {1821msg[i] = '\0';1822}1823 1824calc_auth = (guint8*)wmem_alloc(pinfo->pool, auth_hash_len[model]);1825 1826if (ws_hmac_buffer(auth_hash_algo[model], calc_auth, msg, msg_len, key, key_len)) {1827return FALSE(0);1828}1829 1830if (calc_auth_p) *calc_auth_p = calc_auth;1831if (calc_auth_len_p) *calc_auth_len_p = auth_len;1832 1833return ( memcmp(auth,calc_auth,auth_len) != 0 ) ? FALSE(0) : TRUE(!(0));1834}1835 1836static tvbuff_t*1837snmp_usm_priv_des(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)1838{1839gcry_error_t err;1840gcry_cipher_hd_t hd = NULL((void*)0);1841 1842guint8* cleartext;1843guint8* des_key = p->user_assoc->user.privKey.data; /* first 8 bytes */1844guint8* pre_iv = &(p->user_assoc->user.privKey.data[8]); /* last 8 bytes */1845guint8* salt;1846gint salt_len;1847gint cryptgrm_len;1848guint8* cryptgrm;1849tvbuff_t* clear_tvb;1850guint8 iv[8];1851guint i;1852 1853 1854salt_len = tvb_captured_length(p->priv_tvb);1855 1856if (salt_len != 8) {1857*error = "decryptionError: msgPrivacyParameters length != 8";1858return NULL((void*)0);1859}1860 1861salt = (guint8*)tvb_memdup(pinfo->pool,p->priv_tvb,0,salt_len);1862 1863/*1864 The resulting "salt" is XOR-ed with the pre-IV to obtain the IV.1865 */1866for (i=0; i<8; i++) {1867iv[i] = pre_iv[i] ^ salt[i];1868}1869 1870cryptgrm_len = tvb_captured_length(encryptedData);1871 1872if ((cryptgrm_len <= 0) || (cryptgrm_len % 8)) {1873*error = "decryptionError: the length of the encrypted data is not a multiple of 8 octets";1874return NULL((void*)0);1875}1876 1877cryptgrm = (guint8*)tvb_memdup(pinfo->pool,encryptedData,0,-1);1878 1879cleartext = (guint8*)wmem_alloc(pinfo->pool, cryptgrm_len);1880 1881err = gcry_cipher_open(&hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_CBC, 0);1882if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1883 1884err = gcry_cipher_setiv(hd, iv, 8);1885if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1886 1887err = gcry_cipher_setkey(hd,des_key,8);1888if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1889 1890err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);1891if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1892 1893gcry_cipher_close(hd);1894 1895clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);1896 1897return clear_tvb;1898 1899on_gcry_error:1900*error = (const gchar *)gcry_strerror(err);1901if (hd) gcry_cipher_close(hd);1902return NULL((void*)0);1903}1904 1905static tvbuff_t*1906snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error, int algo)1907{1908gcry_error_t err;1909gcry_cipher_hd_t hd = NULL((void*)0);1910 1911guint8* cleartext;1912guint8* aes_key = p->user_assoc->user.privKey.data;1913int aes_key_len = p->user_assoc->user.privKey.len;1914guint8 iv[16];1915gint priv_len;1916gint cryptgrm_len;1917guint8* cryptgrm;1918tvbuff_t* clear_tvb;1919 1920priv_len = tvb_captured_length(p->priv_tvb);1921 1922if (priv_len != 8) {1923*error = "decryptionError: msgPrivacyParameters length != 8";1924return NULL((void*)0);1925}1926 1927iv[0] = (p->boots & 0xff000000) >> 24;1928iv[1] = (p->boots & 0x00ff0000) >> 16;1929iv[2] = (p->boots & 0x0000ff00) >> 8;1930iv[3] = (p->boots & 0x000000ff);1931iv[4] = (p->snmp_time & 0xff000000) >> 24;1932iv[5] = (p->snmp_time & 0x00ff0000) >> 16;1933iv[6] = (p->snmp_time & 0x0000ff00) >> 8;1934iv[7] = (p->snmp_time & 0x000000ff);1935tvb_memcpy(p->priv_tvb,&(iv[8]),0,8);1936 1937cryptgrm_len = tvb_captured_length(encryptedData);1938if (cryptgrm_len <= 0) {1939*error = "Not enough data remaining";1940return NULL((void*)0);1941}1942cryptgrm = (guint8*)tvb_memdup(pinfo->pool,encryptedData,0,-1);1943 1944cleartext = (guint8*)wmem_alloc(pinfo->pool, cryptgrm_len);1945 1946err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);1947if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1948 1949err = gcry_cipher_setiv(hd, iv, 16);1950if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1951 1952err = gcry_cipher_setkey(hd,aes_key,aes_key_len);1953if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1954 1955err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);1956if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1957 1958gcry_cipher_close(hd);1959 1960clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);1961 1962return clear_tvb;1963 1964on_gcry_error:1965*error = (const gchar *)gcry_strerror(err);1966if (hd) gcry_cipher_close(hd);1967return NULL((void*)0);1968}1969 1970static tvbuff_t*1971snmp_usm_priv_aes128(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)1972{1973return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES);1974}1975 1976static tvbuff_t*1977snmp_usm_priv_aes192(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)1978{1979return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES192);1980}1981 1982static tvbuff_t*1983snmp_usm_priv_aes256(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)1984{1985return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES256);1986}1987 1988static gboolean1989check_ScopedPdu(tvbuff_t* tvb)1990{1991int offset;1992gint8 ber_class;1993bool_Bool pc;1994gint32 tag;1995int hoffset, eoffset;1996guint32 len;1997 1998offset = get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);1999offset = get_ber_length(tvb, offset, NULL((void*)0), NULL((void*)0));2000 2001if ( ! (((ber_class!=BER_CLASS_APP1) && (ber_class!=BER_CLASS_PRI3) )2002&& ( (!pc) || (ber_class!=BER_CLASS_UNI0) || (tag!=BER_UNI_TAG_ENUMERATED10) )2003)) return FALSE(0);2004 2005if((tvb_get_guint8(tvb, offset)==0)&&(tvb_get_guint8(tvb, offset+1)==0))2006return TRUE(!(0));2007 2008hoffset = offset;2009 2010offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);2011offset = get_ber_length(tvb, offset, &len, NULL((void*)0));2012eoffset = offset + len;2013 2014if (eoffset <= hoffset) return FALSE(0);2015 2016if ((ber_class!=BER_CLASS_APP1)&&(ber_class!=BER_CLASS_PRI3))2017if( (ber_class!=BER_CLASS_UNI0)2018||((tag<BER_UNI_TAG_NumericString18)&&(tag!=BER_UNI_TAG_OCTETSTRING4)&&(tag!=BER_UNI_TAG_UTF8String12)) )2019return FALSE(0);2020 2021return TRUE(!(0));2022 2023}2024 2025 2026 2027 2028static int2029dissect_snmp_EnterpriseOID(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2030const gchar* name;2031 2032 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &enterprise_oid);2033 2034 2035if (display_oid && enterprise_oid) {2036name = oid_resolved_from_string(actx->pinfo->pool, enterprise_oid);2037if (name) {2038col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", name);2039}2040}2041 2042 2043 return offset;2044}2045 2046 2047 2048static int2049dissect_snmp_OCTET_STRING_SIZE_4(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2050 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2051 NULL((void*)0));2052 2053 return offset;2054}2055 2056 2057 2058static int2059dissect_snmp_NetworkAddress(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2060 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2061 hf_index, BER_CLASS_APP1, 0, TRUE(!(0)), dissect_snmp_OCTET_STRING_SIZE_4);2062 2063 return offset;2064}2065 2066 2067 2068static int2069dissect_snmp_INTEGER_0_4294967295(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2070 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2071 NULL((void*)0));2072 2073 return offset;2074}2075 2076 2077 2078static int2079dissect_snmp_TimeTicks(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2080 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2081 hf_index, BER_CLASS_APP1, 3, TRUE(!(0)), dissect_snmp_INTEGER_0_4294967295);2082 2083 return offset;2084}2085 2086 2087 2088static int2089dissect_snmp_Integer32(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2090 2091 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2092 &RequestID);2093 2094 2095 2096 return offset;2097}2098 2099 2100 2101static int2102dissect_snmp_ObjectName(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2103 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL((void*)0));2104 2105 return offset;2106}2107 2108 2109static const value_string snmp_Version_vals[] = {2110 { 0, "version-1" },2111 { 1, "v2c" },2112 { 2, "v2u" },2113 { 3, "snmpv3" },2114 { 0, NULL((void*)0) }2115};2116 2117 2118static int2119dissect_snmp_Version(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2120 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2121 &snmp_version);2122 2123 return offset;2124}2125 2126 2127 2128static int2129dissect_snmp_Community(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2130 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2131 NULL((void*)0));2132 2133 return offset;2134}2135 2136 2137 2138static int2139dissect_snmp_T_request_id(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2140 2141 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2142 &RequestID);2143 2144 2145 2146 return offset;2147}2148 2149 2150static const value_string snmp_T_error_status_vals[] = {2151 { 0, "noError" },2152 { 1, "tooBig" },2153 { 2, "noSuchName" },2154 { 3, "badValue" },2155 { 4, "readOnly" },2156 { 5, "genErr" },2157 { 6, "noAccess" },2158 { 7, "wrongType" },2159 { 8, "wrongLength" },2160 { 9, "wrongEncoding" },2161 { 10, "wrongValue" },2162 { 11, "noCreation" },2163 { 12, "inconsistentValue" },2164 { 13, "resourceUnavailable" },2165 { 14, "commitFailed" },2166 { 15, "undoFailed" },2167 { 16, "authorizationError" },2168 { 17, "notWritable" },2169 { 18, "inconsistentName" },2170 { 0, NULL((void*)0) }2171};2172 2173 2174static int2175dissect_snmp_T_error_status(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2176 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2177 NULL((void*)0));2178 2179 return offset;2180}2181 2182 2183 2184static int2185dissect_snmp_INTEGER(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2186 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2187 NULL((void*)0));2188 2189 return offset;2190}2191 2192 2193 2194static const ber_sequence_t VarBindList_sequence_of[1] = {2195 { &hf_snmp_VarBindList_item, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBind },2196};2197 2198static int2199dissect_snmp_VarBindList(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2200 offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,2201 VarBindList_sequence_of, hf_index, ett_snmp_VarBindList);2202 2203 return offset;2204}2205 2206 2207static const ber_sequence_t PDU_sequence[] = {2208 { &hf_snmp_request_id , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_request_id },2209 { &hf_snmp_error_status , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_error_status },2210 { &hf_snmp_error_index , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER },2211 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },2212 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2213};2214 2215static int2216dissect_snmp_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2217 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2218 PDU_sequence, hf_index, ett_snmp_PDU);2219 2220 return offset;2221}2222 2223 2224 2225static int2226dissect_snmp_GetRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2227 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2228 hf_index, BER_CLASS_CON2, 0, TRUE(!(0)), dissect_snmp_PDU);2229 2230 return offset;2231}2232 2233 2234 2235static int2236dissect_snmp_GetNextRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2237 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2238 hf_index, BER_CLASS_CON2, 1, TRUE(!(0)), dissect_snmp_PDU);2239 2240 return offset;2241}2242 2243 2244 2245static int2246dissect_snmp_GetResponse_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2247 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2248 hf_index, BER_CLASS_CON2, 2, TRUE(!(0)), dissect_snmp_PDU);2249 2250 return offset;2251}2252 2253 2254 2255static int2256dissect_snmp_SetRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2257 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2258 hf_index, BER_CLASS_CON2, 3, TRUE(!(0)), dissect_snmp_PDU);2259 2260 return offset;2261}2262 2263 2264static const value_string snmp_GenericTrap_vals[] = {2265 { 0, "coldStart" },2266 { 1, "warmStart" },2267 { 2, "linkDown" },2268 { 3, "linkUp" },2269 { 4, "authenticationFailure" },2270 { 5, "egpNeighborLoss" },2271 { 6, "enterpriseSpecific" },2272 { 0, NULL((void*)0) }2273};2274 2275 2276static int2277dissect_snmp_GenericTrap(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2278 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2279 &generic_trap);2280 2281 return offset;2282}2283 2284 2285 2286static int2287dissect_snmp_SpecificTrap(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2288 guint specific_trap;2289 2290 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2291 &specific_trap);2292 2293 2294if (generic_trap == 6) { /* enterprise specific */2295const gchar *specific_str = snmp_lookup_specific_trap (specific_trap);2296if (specific_str) {2297proto_item_append_text(actx->created_item, " (%s)", specific_str);2298}2299}2300 2301 return offset;2302}2303 2304 2305static const ber_sequence_t Trap_PDU_U_sequence[] = {2306 { &hf_snmp_enterprise , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_EnterpriseOID },2307 { &hf_snmp_agent_addr , BER_CLASS_APP1, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_NetworkAddress },2308 { &hf_snmp_generic_trap , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GenericTrap },2309 { &hf_snmp_specific_trap , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SpecificTrap },2310 { &hf_snmp_time_stamp , BER_CLASS_APP1, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_TimeTicks },2311 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },2312 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2313};2314 2315static int2316dissect_snmp_Trap_PDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2317generic_trap = 0;2318enterprise_oid = NULL((void*)0);2319 2320 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2321 Trap_PDU_U_sequence, hf_index, ett_snmp_Trap_PDU_U);2322 2323 2324 if (snmp_version != 0) {2325 expert_add_info(actx->pinfo, tree, &ei_snmp_trap_pdu_obsolete);2326 }2327 2328 2329 return offset;2330}2331 2332 2333 2334static int2335dissect_snmp_Trap_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2336 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2337 hf_index, BER_CLASS_CON2, 4, TRUE(!(0)), dissect_snmp_Trap_PDU_U);2338 2339 return offset;2340}2341 2342 2343 2344static int2345dissect_snmp_INTEGER_0_2147483647(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2346 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2347 NULL((void*)0));2348 2349 return offset;2350}2351 2352 2353static const ber_sequence_t BulkPDU_sequence[] = {2354 { &hf_snmp_bulkPDU_request_id, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Integer32 },2355 { &hf_snmp_non_repeaters , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },2356 { &hf_snmp_max_repetitions, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },2357 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },2358 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2359};2360 2361static int2362dissect_snmp_BulkPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2363 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2364 BulkPDU_sequence, hf_index, ett_snmp_BulkPDU);2365 2366 return offset;2367}2368 2369 2370 2371static int2372dissect_snmp_GetBulkRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2373 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2374 hf_index, BER_CLASS_CON2, 5, TRUE(!(0)), dissect_snmp_BulkPDU);2375 2376 return offset;2377}2378 2379 2380 2381static int2382dissect_snmp_InformRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2383 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2384 hf_index, BER_CLASS_CON2, 6, TRUE(!(0)), dissect_snmp_PDU);2385 2386 return offset;2387}2388 2389 2390 2391static int2392dissect_snmp_SNMPv2_Trap_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2393 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2394 hf_index, BER_CLASS_CON2, 7, TRUE(!(0)), dissect_snmp_PDU);2395 2396 return offset;2397}2398 2399 2400 2401static int2402dissect_snmp_Report_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2403 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2404 hf_index, BER_CLASS_CON2, 8, TRUE(!(0)), dissect_snmp_PDU);2405 2406 return offset;2407}2408 2409 2410static const value_string snmp_PDUs_vals[] = {2411 { 0, "get-request" },2412 { 1, "get-next-request" },2413 { 2, "get-response" },2414 { 3, "set-request" },2415 { 4, "trap" },2416 { 5, "getBulkRequest" },2417 { 6, "informRequest" },2418 { 7, "snmpV2-trap" },2419 { 8, "report" },2420 { 0, NULL((void*)0) }2421};2422 2423static const ber_choice_t PDUs_choice[] = {2424 { 0, &hf_snmp_get_request , BER_CLASS_CON2, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetRequest_PDU },2425 { 1, &hf_snmp_get_next_request, BER_CLASS_CON2, 1, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetNextRequest_PDU },2426 { 2, &hf_snmp_get_response , BER_CLASS_CON2, 2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetResponse_PDU },2427 { 3, &hf_snmp_set_request , BER_CLASS_CON2, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SetRequest_PDU },2428 { 4, &hf_snmp_trap , BER_CLASS_CON2, 4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Trap_PDU },2429 { 5, &hf_snmp_getBulkRequest , BER_CLASS_CON2, 5, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetBulkRequest_PDU },2430 { 6, &hf_snmp_informRequest , BER_CLASS_CON2, 6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_InformRequest_PDU },2431 { 7, &hf_snmp_snmpV2_trap , BER_CLASS_CON2, 7, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SNMPv2_Trap_PDU },2432 { 8, &hf_snmp_report , BER_CLASS_CON2, 8, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Report_PDU },2433 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2434};2435 2436static int2437dissect_snmp_PDUs(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2438gint pdu_type=-1;2439 2440snmp_request_response_t *srrp;2441snmp_conv_info_t *snmp_info = (snmp_conv_info_t *)actx->private_data;2442 2443col_clear(actx->pinfo->cinfo, COL_INFO);2444 2445 offset = dissect_ber_choice(actx, tree, tvb, offset,2446 PDUs_choice, hf_index, ett_snmp_PDUs,2447 &pdu_type);2448 2449if( (pdu_type!=-1) && snmp_PDUs_vals[pdu_type].strptr ){2450col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%s", snmp_PDUs_vals[pdu_type].strptr);2451 2452/* pdu_type is the index, not the tag so convert it to the tag value */2453pdu_type = snmp_PDUs_vals[pdu_type].value;2454 2455srrp=snmp_match_request_response(tvb, actx->pinfo, tree, RequestID, pdu_type, snmp_info);2456if (srrp) {2457tap_queue_packet(snmp_tap, actx->pinfo, srrp);2458}2459}2460 2461 2462 2463 return offset;2464}2465 2466 2467static const ber_sequence_t Message_sequence[] = {2468 { &hf_snmp_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },2469 { &hf_snmp_community , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Community },2470 { &hf_snmp_data , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_PDUs },2471 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2472};2473 2474static int2475dissect_snmp_Message(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2476 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2477 Message_sequence, hf_index, ett_snmp_Message);2478 2479 return offset;2480}2481 2482 2483 2484static int2485dissect_snmp_OCTET_STRING(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2486 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2487 NULL((void*)0));2488 2489 return offset;2490}2491 2492 2493static const value_string snmp_T_datav2u_vals[] = {2494 { 0, "plaintext" },2495 { 1, "encrypted" },2496 { 0, NULL((void*)0) }2497};2498 2499static const ber_choice_t T_datav2u_choice[] = {2500 { 0, &hf_snmp_v2u_plaintext , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_PDUs },2501 { 1, &hf_snmp_encrypted , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2502 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2503};2504 2505static int2506dissect_snmp_T_datav2u(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2507 offset = dissect_ber_choice(actx, tree, tvb, offset,2508 T_datav2u_choice, hf_index, ett_snmp_T_datav2u,2509 NULL((void*)0));2510 2511 return offset;2512}2513 2514 2515static const ber_sequence_t Messagev2u_sequence[] = {2516 { &hf_snmp_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },2517 { &hf_snmp_parameters , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2518 { &hf_snmp_datav2u , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_T_datav2u },2519 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2520};2521 2522static int2523dissect_snmp_Messagev2u(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2524 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2525 Messagev2u_sequence, hf_index, ett_snmp_Messagev2u);2526 2527 return offset;2528}2529 2530 2531 2532static int2533dissect_snmp_SnmpEngineID(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2534tvbuff_t* param_tvb = NULL((void*)0);2535 2536offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &param_tvb);2537 if (param_tvb) {2538proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);2539dissect_snmp_engineid(engine_tree, actx->pinfo, param_tvb, 0, tvb_reported_length_remaining(param_tvb,0));2540}2541 2542 2543 return offset;2544}2545 2546 2547 2548static int2549dissect_snmp_T_msgAuthoritativeEngineID(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2550 2551offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &usm_p.engine_tvb);2552 if (usm_p.engine_tvb) {2553proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);2554dissect_snmp_engineid(engine_tree, actx->pinfo, usm_p.engine_tvb, 0, tvb_reported_length_remaining(usm_p.engine_tvb,0));2555}2556 2557 2558 return offset;2559}2560 2561 2562 2563static int2564dissect_snmp_T_msgAuthoritativeEngineBoots(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2565 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2566 &usm_p.boots);2567 2568 return offset;2569}2570 2571 2572 2573static int2574dissect_snmp_T_msgAuthoritativeEngineTime(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2575 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2576 &usm_p.snmp_time);2577 2578 return offset;2579}2580 2581 2582 2583static int2584dissect_snmp_T_msgUserName(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2585 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2586 &usm_p.user_tvb);2587 2588 return offset;2589}2590 2591 2592 2593static int2594dissect_snmp_T_msgAuthenticationParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2595offset = dissect_ber_octet_string(FALSE(0), actx, tree, tvb, offset, hf_index, &usm_p.auth_tvb);2596if (usm_p.auth_tvb) {2597usm_p.auth_item = actx->created_item;2598usm_p.auth_offset = tvb_offset_from_real_beginning(usm_p.auth_tvb);2599}2600 2601 return offset;2602}2603 2604 2605 2606static int2607dissect_snmp_T_msgPrivacyParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2608 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2609 &usm_p.priv_tvb);2610 2611 return offset;2612}2613 2614 2615static const ber_sequence_t UsmSecurityParameters_sequence[] = {2616 { &hf_snmp_msgAuthoritativeEngineID, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineID },2617 { &hf_snmp_msgAuthoritativeEngineBoots, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineBoots },2618 { &hf_snmp_msgAuthoritativeEngineTime, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineTime },2619 { &hf_snmp_msgUserName , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgUserName },2620 { &hf_snmp_msgAuthenticationParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthenticationParameters },2621 { &hf_snmp_msgPrivacyParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgPrivacyParameters },2622 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2623};2624 2625static int2626dissect_snmp_UsmSecurityParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2627 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2628 UsmSecurityParameters_sequence, hf_index, ett_snmp_UsmSecurityParameters);2629 2630 return offset;2631}2632 2633 2634 2635static int2636dissect_snmp_INTEGER_484_2147483647(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2637 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2638 NULL((void*)0));2639 2640 return offset;2641}2642 2643 2644 2645static int2646dissect_snmp_T_msgFlags(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2647tvbuff_t *parameter_tvb = NULL((void*)0);2648 2649 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2650 &parameter_tvb);2651 2652if (parameter_tvb){2653guint8 v3_flags = tvb_get_guint8(parameter_tvb, 0);2654proto_tree* flags_tree = proto_item_add_subtree(actx->created_item,ett_msgFlags);2655 2656proto_tree_add_item(flags_tree, hf_snmp_v3_flags_report, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);2657proto_tree_add_item(flags_tree, hf_snmp_v3_flags_crypt, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);2658proto_tree_add_item(flags_tree, hf_snmp_v3_flags_auth, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);2659 2660usm_p.encrypted = v3_flags & TH_CRYPT0x02 ? TRUE(!(0)) : FALSE(0);2661usm_p.authenticated = v3_flags & TH_AUTH0x01 ? TRUE(!(0)) : FALSE(0);2662}2663 2664 2665 2666 return offset;2667}2668 2669 2670 2671static int2672dissect_snmp_T_msgSecurityModel(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2673 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2674 &MsgSecurityModel);2675 2676 return offset;2677}2678 2679 2680static const ber_sequence_t HeaderData_sequence[] = {2681 { &hf_snmp_msgID , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },2682 { &hf_snmp_msgMaxSize , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_484_2147483647 },2683 { &hf_snmp_msgFlags , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgFlags },2684 { &hf_snmp_msgSecurityModel, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgSecurityModel },2685 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2686};2687 2688static int2689dissect_snmp_HeaderData(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2690 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2691 HeaderData_sequence, hf_index, ett_snmp_HeaderData);2692 2693 return offset;2694}2695 2696 2697 2698static int2699dissect_snmp_T_msgSecurityParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2700 2701switch(MsgSecurityModel){2702case SNMP_SEC_USM3:/* 3 */2703offset = get_ber_identifier(tvb, offset, NULL((void*)0), NULL((void*)0), NULL((void*)0));2704offset = get_ber_length(tvb, offset, NULL((void*)0), NULL((void*)0));2705offset = dissect_snmp_UsmSecurityParameters(FALSE(0), tvb, offset, actx, tree, -1);2706usm_p.user_assoc = get_user_assoc(usm_p.engine_tvb, usm_p.user_tvb, actx->pinfo);2707break;2708case SNMP_SEC_ANY0:/* 0 */2709case SNMP_SEC_V11:/* 1 */2710case SNMP_SEC_V2C2:/* 2 */2711default:2712 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2713 NULL((void*)0));2714 2715break;2716}2717 2718 2719 return offset;2720}2721 2722 2723static const ber_sequence_t ScopedPDU_sequence[] = {2724 { &hf_snmp_contextEngineID, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SnmpEngineID },2725 { &hf_snmp_contextName , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2726 { &hf_snmp_data , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_PDUs },2727 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2728};2729 2730static int2731dissect_snmp_ScopedPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2732 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2733 ScopedPDU_sequence, hf_index, ett_snmp_ScopedPDU);2734 2735 return offset;2736}2737 2738 2739 2740static int2741dissect_snmp_T_encryptedPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2742tvbuff_t* crypt_tvb;2743offset = dissect_ber_octet_string(FALSE(0), actx, tree, tvb, offset, hf_snmp_encryptedPDU, &crypt_tvb);2744 2745if( usm_p.encrypted && crypt_tvb2746&& usm_p.user_assoc2747&& usm_p.user_assoc->user.privProtocol ) {2748 2749const gchar* error = NULL((void*)0);2750proto_tree* encryptedpdu_tree = proto_item_add_subtree(actx->created_item,ett_encryptedPDU);2751tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, actx->pinfo, &error );2752 2753if (! cleartext_tvb) {2754proto_tree_add_expert_format(encryptedpdu_tree, actx->pinfo, &ei_snmp_failed_decrypted_data_pdu,2755crypt_tvb, 0, -1, "Failed to decrypt encryptedPDU: %s", error);2756 2757col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");2758 2759return offset;2760} else {2761proto_item* decrypted_item;2762proto_tree* decrypted_tree;2763 2764if (! check_ScopedPdu(cleartext_tvb)) {2765proto_tree_add_expert(encryptedpdu_tree, actx->pinfo, &ei_snmp_decrypted_data_bad_formatted, cleartext_tvb, 0, -1);2766 2767col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");2768 2769return offset;2770}2771 2772 2773add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");2774 2775decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,ENC_NA0x00000000);2776decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);2777dissect_snmp_ScopedPDU(FALSE(0), cleartext_tvb, 0, actx, decrypted_tree, -1);2778}2779} else {2780col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: privKey Unknown");2781}2782 2783 2784 return offset;2785}2786 2787 2788static const value_string snmp_ScopedPduData_vals[] = {2789 { 0, "plaintext" },2790 { 1, "encryptedPDU" },2791 { 0, NULL((void*)0) }2792};2793 2794static const ber_choice_t ScopedPduData_choice[] = {2795 { 0, &hf_snmp_plaintext , BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ScopedPDU },2796 { 1, &hf_snmp_encryptedPDU , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_encryptedPDU },2797 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2798};2799 2800static int2801dissect_snmp_ScopedPduData(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2802 offset = dissect_ber_choice(actx, tree, tvb, offset,2803 ScopedPduData_choice, hf_index, ett_snmp_ScopedPduData,2804 NULL((void*)0));2805 2806 return offset;2807}2808 2809 2810static const ber_sequence_t SNMPv3Message_sequence[] = {2811 { &hf_snmp_msgVersion , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },2812 { &hf_snmp_msgGlobalData , BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_HeaderData },2813 { &hf_snmp_msgSecurityParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgSecurityParameters },2814 { &hf_snmp_msgData , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_ScopedPduData },2815 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2816};2817 2818static int2819dissect_snmp_SNMPv3Message(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2820 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2821 SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);2822 2823 2824if( usm_p.authenticated2825&& usm_p.user_assoc ) {2826const gchar* error = NULL((void*)0);2827proto_item* authen_item;2828proto_tree* authen_tree = proto_item_add_subtree(usm_p.auth_item,ett_authParameters);2829guint8* calc_auth = NULL((void*)0);2830guint calc_auth_len = 0;2831 2832usm_p.authOK = snmp_usm_auth(actx->pinfo, usm_p.user_assoc->user.authModel, &usm_p, &calc_auth, &calc_auth_len, &error );2833 2834if (error) {2835expert_add_info_format( actx->pinfo, usm_p.auth_item, &ei_snmp_verify_authentication_error, "Error while verifying Message authenticity: %s", error );2836} else {2837expert_field* expert;2838 2839authen_item = proto_tree_add_boolean(authen_tree, hf_snmp_msgAuthentication, tvb, 0, 0, usm_p.authOK);2840proto_item_set_generated(authen_item);2841 2842if (usm_p.authOK) {2843expert = &ei_snmp_authentication_ok;2844} else {2845const gchar* calc_auth_str = bytes_to_str_punct(actx->pinfo->pool, calc_auth,calc_auth_len,' ')bytes_to_str_punct_maxlen(actx->pinfo->pool, calc_auth,
calc_auth_len, ' ', 24)
;2846proto_item_append_text(authen_item, " calculated = %s", calc_auth_str);2847expert = &ei_snmp_authentication_error;2848}2849 2850expert_add_info( actx->pinfo, authen_item, expert);2851}2852}2853 2854 return offset;2855}2856 2857 2858static const value_string snmp_T_smux_version_vals[] = {2859 { 0, "version-1" },2860 { 0, NULL((void*)0) }2861};2862 2863 2864static int2865dissect_snmp_T_smux_version(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2866 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2867 NULL((void*)0));2868 2869 return offset;2870}2871 2872 2873 2874static int2875dissect_snmp_OBJECT_IDENTIFIER(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2876 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL((void*)0));2877 2878 return offset;2879}2880 2881 2882 2883static int2884dissect_snmp_DisplayString(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2885 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2886 NULL((void*)0));2887 2888 return offset;2889}2890 2891 2892static const ber_sequence_t SimpleOpen_U_sequence[] = {2893 { &hf_snmp_smux_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_smux_version },2894 { &hf_snmp_identity , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OBJECT_IDENTIFIER },2895 { &hf_snmp_description , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_DisplayString },2896 { &hf_snmp_password , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2897 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2898};2899 2900static int2901dissect_snmp_SimpleOpen_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2902 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2903 SimpleOpen_U_sequence, hf_index, ett_snmp_SimpleOpen_U);2904 2905 return offset;2906}2907 2908 2909 2910static int2911dissect_snmp_SimpleOpen(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2912 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2913 hf_index, BER_CLASS_APP1, 0, TRUE(!(0)), dissect_snmp_SimpleOpen_U);2914 2915 return offset;2916}2917 2918 2919static const value_string snmp_OpenPDU_vals[] = {2920 { 0, "smux-simple" },2921 { 0, NULL((void*)0) }2922};2923 2924static const ber_choice_t OpenPDU_choice[] = {2925 { 0, &hf_snmp_smux_simple , BER_CLASS_APP1, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SimpleOpen },2926 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2927};2928 2929static int2930dissect_snmp_OpenPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2931 offset = dissect_ber_choice(actx, tree, tvb, offset,2932 OpenPDU_choice, hf_index, ett_snmp_OpenPDU,2933 NULL((void*)0));2934 2935 return offset;2936}2937 2938 2939static const value_string snmp_ClosePDU_U_vals[] = {2940 { 0, "goingDown" },2941 { 1, "unsupportedVersion" },2942 { 2, "packetFormat" },2943 { 3, "protocolError" },2944 { 4, "internalError" },2945 { 5, "authenticationFailure" },2946 { 0, NULL((void*)0) }2947};2948 2949 2950static int2951dissect_snmp_ClosePDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2952 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2953 NULL((void*)0));2954 2955 return offset;2956}2957 2958 2959 2960static int2961dissect_snmp_ClosePDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2962 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2963 hf_index, BER_CLASS_APP1, 1, TRUE(!(0)), dissect_snmp_ClosePDU_U);2964 2965 return offset;2966}2967 2968 2969 2970static int2971dissect_snmp_INTEGER_M1_2147483647(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2972 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2973 NULL((void*)0));2974 2975 return offset;2976}2977 2978 2979static const value_string snmp_T_operation_vals[] = {2980 { 0, "delete" },2981 { 1, "readOnly" },2982 { 2, "readWrite" },2983 { 0, NULL((void*)0) }2984};2985 2986 2987static int2988dissect_snmp_T_operation(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {2989 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2990 NULL((void*)0));2991 2992 return offset;2993}2994 2995 2996static const ber_sequence_t RReqPDU_U_sequence[] = {2997 { &hf_snmp_subtree , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ObjectName },2998 { &hf_snmp_priority , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_M1_2147483647 },2999 { &hf_snmp_operation , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_operation },3000 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }3001};3002 3003static int3004dissect_snmp_RReqPDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3005 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,3006 RReqPDU_U_sequence, hf_index, ett_snmp_RReqPDU_U);3007 3008 return offset;3009}3010 3011 3012 3013static int3014dissect_snmp_RReqPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3015 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3016 hf_index, BER_CLASS_APP1, 2, TRUE(!(0)), dissect_snmp_RReqPDU_U);3017 3018 return offset;3019}3020 3021 3022static const value_string snmp_RRspPDU_U_vals[] = {3023 { -1, "failure" },3024 { 0, NULL((void*)0) }3025};3026 3027 3028static int3029dissect_snmp_RRspPDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3030 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,3031 NULL((void*)0));3032 3033 return offset;3034}3035 3036 3037 3038static int3039dissect_snmp_RRspPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3040 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3041 hf_index, BER_CLASS_APP1, 3, TRUE(!(0)), dissect_snmp_RRspPDU_U);3042 3043 return offset;3044}3045 3046 3047static const value_string snmp_RegisterResponse_vals[] = {3048 { 0, "rRspPDU" },3049 { 1, "pDUs" },3050 { 0, NULL((void*)0) }3051};3052 3053static const ber_choice_t RegisterResponse_choice[] = {3054 { 0, &hf_snmp_rRspPDU , BER_CLASS_APP1, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RRspPDU },3055 { 1, &hf_snmp_pDUs , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_PDUs },3056 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }3057};3058 3059static int3060dissect_snmp_RegisterResponse(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3061 offset = dissect_ber_choice(actx, tree, tvb, offset,3062 RegisterResponse_choice, hf_index, ett_snmp_RegisterResponse,3063 NULL((void*)0));3064 3065 return offset;3066}3067 3068 3069static const value_string snmp_SOutPDU_U_vals[] = {3070 { 0, "commit" },3071 { 1, "rollback" },3072 { 0, NULL((void*)0) }3073};3074 3075 3076static int3077dissect_snmp_SOutPDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3078 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,3079 NULL((void*)0));3080 3081 return offset;3082}3083 3084 3085 3086static int3087dissect_snmp_SOutPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3088 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3089 hf_index, BER_CLASS_APP1, 4, TRUE(!(0)), dissect_snmp_SOutPDU_U);3090 3091 return offset;3092}3093 3094 3095static const value_string snmp_SMUX_PDUs_vals[] = {3096 { 0, "open" },3097 { 1, "close" },3098 { 2, "registerRequest" },3099 { 3, "registerResponse" },3100 { 4, "commitOrRollback" },3101 { 0, NULL((void*)0) }3102};3103 3104static const ber_choice_t SMUX_PDUs_choice[] = {3105 { 0, &hf_snmp_open , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OpenPDU },3106 { 1, &hf_snmp_close , BER_CLASS_APP1, 1, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ClosePDU },3107 { 2, &hf_snmp_registerRequest, BER_CLASS_APP1, 2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RReqPDU },3108 { 3, &hf_snmp_registerResponse, BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RegisterResponse },3109 { 4, &hf_snmp_commitOrRollback, BER_CLASS_APP1, 4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SOutPDU },3110 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }3111};3112 3113static int3114dissect_snmp_SMUX_PDUs(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), int offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {3115 3116snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(actx->pinfo);3117 3118actx->private_data = snmp_info;3119 3120 offset = dissect_ber_choice(actx, tree, tvb, offset,3121 SMUX_PDUs_choice, hf_index, ett_snmp_SMUX_PDUs,3122 NULL((void*)0));3123 3124 return offset;3125}3126 3127/*--- PDUs ---*/3128 3129static int dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U___attribute__((unused)), packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), void *data _U___attribute__((unused))) {3130 int offset = 0;3131 asn1_ctx_t asn1_ctx;3132 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE(!(0)), pinfo);3133 offset = dissect_snmp_SMUX_PDUs(FALSE(0), tvb, offset, &asn1_ctx, tree, hf_snmp_SMUX_PDUs_PDU);3134 return offset;3135}3136 3137 3138static snmp_conv_info_t*3139snmp_find_conversation_and_get_conv_data(packet_info *pinfo) {3140 3141conversation_t *conversation = NULL((void*)0);3142snmp_conv_info_t *snmp_info = NULL((void*)0);3143 3144/* Get the conversation with the wildcarded port, if it exists3145 * and is associated with SNMP, so that requests and responses3146 * can be matched even if the response comes from a different,3147 * ephemeral, source port, as originally done in OS/400.3148 * On UDP, we do not automatically call conversation_set_port2()3149 * and we do not want to do so. Possibly this should eventually3150 * use find_conversation_full and separate the "SNMP conversation"3151 * from "the transport layer conversation that carries SNMP."3152 */3153if (pinfo->destport == UDP_PORT_SNMP161) {3154conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),3155pinfo->srcport, 0, NO_PORT_B0x00020000);3156} else if (pinfo->srcport == UDP_PORT_SNMP161) {3157conversation = find_conversation(pinfo->fd->num, &pinfo->dst, &pinfo->src, conversation_pt_to_conversation_type(pinfo->ptype),3158pinfo->destport, 0, NO_PORT_B0x00020000);3159}3160if ((conversation == NULL((void*)0)) || (conversation_get_dissector(conversation, pinfo->num) != snmp_handle)) {3161conversation = find_or_create_conversation(pinfo);3162}3163 3164snmp_info = (snmp_conv_info_t *)conversation_get_proto_data(conversation, proto_snmp);3165if (snmp_info == NULL((void*)0)) {3166snmp_info = wmem_new0(wmem_file_scope(), snmp_conv_info_t)((snmp_conv_info_t*)wmem_alloc0((wmem_file_scope()), sizeof(snmp_conv_info_t
)))
;3167snmp_info->request_response=wmem_map_new(wmem_file_scope(), g_int_hash, g_int_equal);3168 3169conversation_add_proto_data(conversation, proto_snmp, snmp_info);3170}3171return snmp_info;3172}3173 3174guint3175dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,3176 proto_tree *tree, int proto, gint ett, gboolean is_tcp)3177{3178 3179guint length_remaining;3180gint8 ber_class;3181bool_Bool pc, ind = 0;3182gint32 tag;3183guint32 len;3184guint message_length;3185int start_offset = offset;3186guint32 version = 0;3187tvbuff_t*next_tvb;3188 3189proto_tree *snmp_tree = NULL((void*)0);3190proto_item *item = NULL((void*)0);3191 3192snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(pinfo);3193 3194asn1_ctx_t asn1_ctx;3195asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE(!(0)), pinfo);3196 3197asn1_ctx.private_data = snmp_info;3198 3199usm_p.msg_tvb = tvb;3200usm_p.start_offset = tvb_offset_from_real_beginning(tvb);3201usm_p.engine_tvb = NULL((void*)0);3202usm_p.user_tvb = NULL((void*)0);3203usm_p.auth_item = NULL((void*)0);3204usm_p.auth_tvb = NULL((void*)0);3205usm_p.auth_offset = 0;3206usm_p.priv_tvb = NULL((void*)0);3207usm_p.user_assoc = NULL((void*)0);3208usm_p.authenticated = FALSE(0);3209usm_p.encrypted = FALSE(0);3210usm_p.boots = 0;3211usm_p.snmp_time = 0;3212usm_p.authOK = FALSE(0);3213 3214/*3215 * This will throw an exception if we don't have any data left.3216 * That's what we want. (See "tcp_dissect_pdus()", which is3217 * similar, but doesn't have to deal with ASN.1.3218 * XXX - can we make "tcp_dissect_pdus()" provide enough3219 * information to the "get_pdu_len" routine so that we could3220 * have that routine deal with ASN.1, and just use3221 * "tcp_dissect_pdus()"?)3222 */3223length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);3224 3225/* NOTE: we have to parse the message piece by piece, since the3226 * capture length may be less than the message length: a 'global'3227 * parsing is likely to fail.3228 */3229 3230/*3231 * If this is SNMP-over-TCP, we might have to do reassembly3232 * in order to read the "Sequence Of" header.3233 */3234if (is_tcp && snmp_desegment && pinfo->can_desegment) {3235/*3236 * This is TCP, and we should, and can, do reassembly.3237 *3238 * Is the "Sequence Of" header split across segment3239 * boundaries? We require at least 6 bytes for the3240 * header, which allows for a 4-byte length (ASN.13241 * BER).3242 */3243if (length_remaining < 6) {3244/*3245 * Yes. Tell the TCP dissector where the data3246 * for this message starts in the data it handed3247 * us and that we need "some more data." Don't tell3248 * it exactly how many bytes we need because if/when3249 * we ask for even more (after the header) that will3250 * break reassembly.3251 */3252pinfo->desegment_offset = offset;3253pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT0x0fffffff;3254return 0;3255}3256}3257 3258/*3259 * OK, try to read the "Sequence Of" header; this gets the total3260 * length of the SNMP message.3261 */3262offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);3263/*Get the total octet length of the SNMP data*/3264offset = get_ber_length(tvb, offset, &len, &ind);3265message_length = len + offset;3266 3267/*Get the SNMP version data*/3268/*offset =*/ dissect_ber_integer(FALSE(0), &asn1_ctx, 0, tvb, offset, -1, &version);3269 3270 3271/*3272 * If this is SNMP-over-TCP, we might have to do reassembly3273 * to get all of this message.3274 */3275if (is_tcp && snmp_desegment && pinfo->can_desegment) {3276/*3277 * Yes - is the message split across segment boundaries?3278 */3279if (length_remaining < message_length) {3280/*3281 * Yes. Tell the TCP dissector where the data3282 * for this message starts in the data it handed3283 * us, and how many more bytes we need, and3284 * return.3285 */3286pinfo->desegment_offset = start_offset;3287pinfo->desegment_len =3288message_length - length_remaining;3289 3290/*3291 * Return 0, which means "I didn't dissect anything3292 * because I don't have enough data - we need3293 * to desegment".3294 */3295return 0;3296}3297}3298 3299var_list = next_tvb_list_new(pinfo->pool);3300 3301col_set_str(pinfo->cinfo, COL_PROTOCOL, proto_get_protocol_short_name(find_protocol_by_id(proto)));3302 3303item = proto_tree_add_item(tree, proto, tvb, start_offset, message_length, ENC_BIG_ENDIAN0x00000000);3304snmp_tree = proto_item_add_subtree(item, ett);3305 3306switch (version) {3307case 0: /* v1 */3308case 1: /* v2c */3309offset = dissect_snmp_Message(FALSE(0) , tvb, start_offset, &asn1_ctx, snmp_tree, -1);3310break;3311case 2: /* v2u */3312offset = dissect_snmp_Messagev2u(FALSE(0) , tvb, start_offset, &asn1_ctx, snmp_tree, -1);3313break;3314/* v3 */3315case 3:3316offset = dissect_snmp_SNMPv3Message(FALSE(0) , tvb, start_offset, &asn1_ctx, snmp_tree, -1);3317break;3318default:3319/*3320 * Return the length remaining in the tvbuff, so3321 * if this is SNMP-over-TCP, our caller thinks there's3322 * nothing left to dissect.3323 */3324expert_add_info(pinfo, item, &ei_snmp_version_unknown);3325return length_remaining;3326break;3327}3328 3329/* There may be appended data after the SNMP data, so treat as raw3330 * data which needs to be dissected in case of UDP as UDP is PDU oriented.3331 */3332if((!is_tcp) && (length_remaining > (guint)offset)) {3333next_tvb = tvb_new_subset_remaining(tvb, offset);3334call_dissector(data_handle, next_tvb, pinfo, tree);3335} else {3336next_tvb_call(var_list, pinfo, tree, NULL((void*)0), data_handle);3337}3338 3339return offset;3340}3341 3342static gint3343dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U___attribute__((unused)))3344{3345int offset;3346gint8 tmp_class;3347bool_Bool tmp_pc;3348gint32 tmp_tag;3349guint32 tmp_length;3350bool_Bool tmp_ind;3351 3352/*3353 * See if this looks like SNMP or not. if not, return 0 so3354 * wireshark can try some other dissector instead.3355 */3356/* All SNMP packets are BER encoded and consist of a SEQUENCE3357 * that spans the entire PDU. The first item is an INTEGER that3358 * has the values 0-2 (version 1-3).3359 * if not it is not snmp.3360 */3361/* SNMP starts with a SEQUENCE */3362offset = get_ber_identifier(tvb, 0, &tmp_class, &tmp_pc, &tmp_tag);3363if((tmp_class!=BER_CLASS_UNI0)||(tmp_tag!=BER_UNI_TAG_SEQUENCE16)) {3364return 0;3365}3366/* then comes a length which spans the rest of the tvb */3367offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);3368/* Loosen the heuristic a bit to handle the case where data has intentionally3369 * been added after the snmp PDU ( UDP case) (#3684)3370 * If this is fragmented or carried in ICMP, we don't expect the tvb to3371 * have the full legnth, so don't check.3372 */3373if (!pinfo->fragmented && !pinfo->flags.in_error_pkt) {3374 if ( pinfo->ptype == PT_UDP ) {3375 if(tmp_length>(guint32)tvb_reported_length_remaining(tvb, offset)) {3376 return 0;3377 }3378 }else{3379 if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)) {3380 return 0;3381 }3382 }3383}3384/* then comes an INTEGER (version)*/3385get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);3386if((tmp_class!=BER_CLASS_UNI0)||(tmp_tag!=BER_UNI_TAG_INTEGER2)) {3387return 0;3388}3389/* do we need to test that version is 0 - 2 (version1-3) ? */3390 3391 3392/*3393 * The IBM i (OS/400) SNMP agent, at least originally, would3394 * send responses back from some *other* UDP port, an ephemeral3395 * port above 5000, going back to the same IP address and port3396 * from which the request came, similar to TFTP. This only happens3397 * with the agent port, 161, not with the trap port, etc. As of3398 * 2015 with the latest fixes applied, it no longer does this:3399 * https://www.ibm.com/support/pages/ptf/SI554873400 * https://www.ibm.com/support/pages/ptf/SI555373401 *3402 * The SNMP RFCs are silent on this (cf. L2TP RFC 2661, which3403 * supports using either the well-known port or an ephemeral3404 * port as the source port for responses, while noting that3405 * the latter can cause issues with firewalls and NATs.) so3406 * possibly some other implementations could do this.3407 *3408 * If this packet went to the SNMP port, we check to see if3409 * there's already a conversation with one address/port pair3410 * matching the source IP address and port of this packet,3411 * the other address matching the destination IP address of this3412 * packet, and any destination port.3413 *3414 * If not, we create one, with its address 1/port 1 pair being3415 * the source address/port of this packet, its address 2 being3416 * the destination address of this packet, and its port 2 being3417 * wildcarded, and give it the SNMP dissector as a dissector.3418 */3419 3420if (pinfo->destport == UDP_PORT_SNMP161) {3421conversation_t *conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),3422pinfo->srcport, 0, NO_PORT_B0x00020000);3423 3424if( (conversation == NULL((void*)0)) || (conversation_get_dissector(conversation, pinfo->num)!=snmp_handle) ) {3425conversation = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),3426pinfo->srcport, 0, NO_PORT20x02);3427conversation_set_dissector(conversation, snmp_handle);3428}3429}3430 3431return dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, FALSE(0));3432}3433 3434static int3435dissect_snmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused)))3436{3437int offset = 0;3438guint message_len;3439 3440while (tvb_reported_length_remaining(tvb, offset) > 0) {3441message_len = dissect_snmp_pdu(tvb, offset, pinfo, tree, proto_snmp, ett_snmp, TRUE(!(0)));3442if (message_len == 0) {3443/*3444 * We don't have all the data for that message,3445 * so we need to do desegmentation;3446 * "dissect_snmp_pdu()" has set that up.3447 */3448break;3449}3450offset += message_len;3451}3452return tvb_captured_length(tvb);3453}3454 3455static int3456dissect_smux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)3457{3458proto_tree *smux_tree = NULL((void*)0);3459proto_item *item = NULL((void*)0);3460 3461var_list = next_tvb_list_new(pinfo->pool);3462 3463col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMUX");3464 3465item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, ENC_NA0x00000000);3466smux_tree = proto_item_add_subtree(item, ett_smux);3467 3468return dissect_SMUX_PDUs_PDU(tvb, pinfo, smux_tree, data);3469}3470 3471/*3472 MD5 Password to Key Algorithm from RFC 3414 A.2.13473 SHA1 Password to Key Algorithm from RFC 3414 A.2.23474 SHA2 Password to Key Algorithm from RFC 7860 9.33475*/3476static void3477snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const guint8 *password,3478guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key)3479{3480gcry_md_hd_thash_handle;3481guint8 *cp, password_buf[64];3482guint32 password_index = 0;3483guint32 count = 0, i;3484guint hash_len;3485 3486if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {3487return;3488}3489 3490hash_len = auth_hash_len[model];3491 3492/**********************************************/3493/* Use while loop until we've done 1 Megabyte */3494/**********************************************/3495while (count < 1048576) {3496cp = password_buf;3497if (passwordlen != 0) {3498for (i = 0; i < 64; i++) {3499/*************************************************/3500/* Take the next octet of the password, wrapping */3501/* to the beginning of the password as necessary.*/3502/*************************************************/3503*cp++ = password[password_index++ % passwordlen];3504}3505} else {3506*cp = 0;3507}3508gcry_md_write(hash_handle, password_buf, 64);3509count += 64;3510}3511memcpy(key, gcry_md_read(hash_handle, 0), hash_len);3512gcry_md_close(hash_handle);3513 3514/*****************************************************/3515/* Now localise the key with the engineID and pass */3516/* through hash function to produce final key */3517/* We ignore invalid engineLengths here. More strict */3518/* checking is done in snmp_users_update_cb. */3519/*****************************************************/3520if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {3521return;3522}3523gcry_md_write(hash_handle, key, hash_len);3524gcry_md_write(hash_handle, engineID, engineLength);3525gcry_md_write(hash_handle, key, hash_len);3526memcpy(key, gcry_md_read(hash_handle, 0), hash_len);3527gcry_md_close(hash_handle);3528return;3529}3530 3531static void3532process_prefs(void)3533{3534}3535 3536UAT_LSTRING_CB_DEF(snmp_users,userName,snmp_ue_assoc_t,user.userName.data,user.userName.len)static void snmp_users_userName_set_cb(void* rec, const char*
buf, unsigned len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { char* new_val = uat_unesc
(buf,len,&(((snmp_ue_assoc_t*)rec)->user.userName.len)
); g_free((((snmp_ue_assoc_t*)rec)->user.userName.data)); (
((snmp_ue_assoc_t*)rec)->user.userName.data) = new_val; } static
void snmp_users_userName_tostr_cb(void* rec, char** out_ptr,
unsigned* out_len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { if (((snmp_ue_assoc_t*)rec
)->user.userName.data ) { *out_ptr = uat_esc(((snmp_ue_assoc_t
*)rec)->user.userName.data, (((snmp_ue_assoc_t*)rec)->user
.userName.len)); *out_len = (unsigned)strlen(*out_ptr); } else
{ *out_ptr = g_strdup(""); *out_len = 0; } }
3537UAT_LSTRING_CB_DEF(snmp_users,authPassword,snmp_ue_assoc_t,user.authPassword.data,user.authPassword.len)static void snmp_users_authPassword_set_cb(void* rec, const char
* buf, unsigned len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { char* new_val = uat_unesc
(buf,len,&(((snmp_ue_assoc_t*)rec)->user.authPassword.
len)); g_free((((snmp_ue_assoc_t*)rec)->user.authPassword.
data)); (((snmp_ue_assoc_t*)rec)->user.authPassword.data) =
new_val; } static void snmp_users_authPassword_tostr_cb(void
* rec, char** out_ptr, unsigned* out_len, const void* u1 __attribute__
((unused)), const void* u2 __attribute__((unused))) { if (((snmp_ue_assoc_t
*)rec)->user.authPassword.data ) { *out_ptr = uat_esc(((snmp_ue_assoc_t
*)rec)->user.authPassword.data, (((snmp_ue_assoc_t*)rec)->
user.authPassword.len)); *out_len = (unsigned)strlen(*out_ptr
); } else { *out_ptr = g_strdup(""); *out_len = 0; } }
3538UAT_LSTRING_CB_DEF(snmp_users,privPassword,snmp_ue_assoc_t,user.privPassword.data,user.privPassword.len)static void snmp_users_privPassword_set_cb(void* rec, const char
* buf, unsigned len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { char* new_val = uat_unesc
(buf,len,&(((snmp_ue_assoc_t*)rec)->user.privPassword.
len)); g_free((((snmp_ue_assoc_t*)rec)->user.privPassword.
data)); (((snmp_ue_assoc_t*)rec)->user.privPassword.data) =
new_val; } static void snmp_users_privPassword_tostr_cb(void
* rec, char** out_ptr, unsigned* out_len, const void* u1 __attribute__
((unused)), const void* u2 __attribute__((unused))) { if (((snmp_ue_assoc_t
*)rec)->user.privPassword.data ) { *out_ptr = uat_esc(((snmp_ue_assoc_t
*)rec)->user.privPassword.data, (((snmp_ue_assoc_t*)rec)->
user.privPassword.len)); *out_len = (unsigned)strlen(*out_ptr
); } else { *out_ptr = g_strdup(""); *out_len = 0; } }
3539UAT_BUFFER_CB_DEF(snmp_users,engine_id,snmp_ue_assoc_t,engine.data,engine.len)static void snmp_users_engine_id_set_cb(void* rec, const char
* buf, unsigned len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { unsigned char* new_buf =
len ? (unsigned char *)g_memdup2(buf,len) : ((void*)0); g_free
((((snmp_ue_assoc_t*)rec)->engine.data)); (((snmp_ue_assoc_t
*)rec)->engine.data) = new_buf; (((snmp_ue_assoc_t*)rec)->
engine.len) = len; } static void snmp_users_engine_id_tostr_cb
(void* rec, char** out_ptr, unsigned* out_len, const void* u1
__attribute__((unused)), const void* u2 __attribute__((unused
))) { *out_ptr = ((snmp_ue_assoc_t*)rec)->engine.data ? (char
*)g_memdup2(((snmp_ue_assoc_t*)rec)->engine.data,((snmp_ue_assoc_t
*)rec)->engine.len) : g_strdup(""); *out_len = ((snmp_ue_assoc_t
*)rec)->engine.len; }
3540UAT_VS_DEF(snmp_users,auth_model,snmp_ue_assoc_t,guint,0,"MD5")static void snmp_users_auth_model_set_cb(void* rec, const char
* buf, unsigned len, const void* vs, const void* u2 __attribute__
((unused))) { unsigned i; char* str = g_strndup(buf,len); const
char* cstr; ((snmp_ue_assoc_t*)rec)->auth_model = 0; for(
i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { if
(g_str_equal(cstr,str)) { ((snmp_ue_assoc_t*)rec)->auth_model
= (guint)((const value_string*)vs)[i].value; g_free(str); return
; } } g_free(str); } static void snmp_users_auth_model_tostr_cb
(void* rec, char** out_ptr, unsigned* out_len, const void* vs
, const void* u2 __attribute__((unused))) { unsigned i; for(i
=0;((const value_string*)vs)[i].strptr;i++) { if ( ((const value_string
*)vs)[i].value == ((snmp_ue_assoc_t*)rec)->auth_model ) { *
out_ptr = g_strdup(((const value_string*)vs)[i].strptr); *out_len
= (unsigned)strlen(*out_ptr); return; } } *out_ptr = g_strdup
("MD5"); *out_len = (unsigned)strlen("MD5"); }
3541UAT_VS_DEF(snmp_users,priv_proto,snmp_ue_assoc_t,guint,0,"DES")static void snmp_users_priv_proto_set_cb(void* rec, const char
* buf, unsigned len, const void* vs, const void* u2 __attribute__
((unused))) { unsigned i; char* str = g_strndup(buf,len); const
char* cstr; ((snmp_ue_assoc_t*)rec)->priv_proto = 0; for(
i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { if
(g_str_equal(cstr,str)) { ((snmp_ue_assoc_t*)rec)->priv_proto
= (guint)((const value_string*)vs)[i].value; g_free(str); return
; } } g_free(str); } static void snmp_users_priv_proto_tostr_cb
(void* rec, char** out_ptr, unsigned* out_len, const void* vs
, const void* u2 __attribute__((unused))) { unsigned i; for(i
=0;((const value_string*)vs)[i].strptr;i++) { if ( ((const value_string
*)vs)[i].value == ((snmp_ue_assoc_t*)rec)->priv_proto ) { *
out_ptr = g_strdup(((const value_string*)vs)[i].strptr); *out_len
= (unsigned)strlen(*out_ptr); return; } } *out_ptr = g_strdup
("DES"); *out_len = (unsigned)strlen("DES"); }
3542 3543static void *3544snmp_specific_trap_copy_cb(void *dest, const void *orig, size_t len _U___attribute__((unused)))3545{3546snmp_st_assoc_t *u = (snmp_st_assoc_t *)dest;3547const snmp_st_assoc_t *o = (const snmp_st_assoc_t *)orig;3548 3549u->enterprise = g_strdup(o->enterprise);3550u->trap = o->trap;3551u->desc = g_strdup(o->desc);3552 3553return dest;3554}3555 3556static void3557snmp_specific_trap_free_cb(void *r)3558{3559snmp_st_assoc_t *u = (snmp_st_assoc_t *)r;3560 3561g_free(u->enterprise);3562g_free(u->desc);3563}3564 3565UAT_CSTRING_CB_DEF(specific_traps, enterprise, snmp_st_assoc_t)static void specific_traps_enterprise_set_cb(void* rec, const
char* buf, unsigned len, const void* u1 __attribute__((unused
)), const void* u2 __attribute__((unused))) { char* new_buf =
g_strndup(buf,len); g_free((((snmp_st_assoc_t*)rec)->enterprise
)); (((snmp_st_assoc_t*)rec)->enterprise) = new_buf; } static
void specific_traps_enterprise_tostr_cb(void* rec, char** out_ptr
, unsigned* out_len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { if (((snmp_st_assoc_t*)rec
)->enterprise ) { *out_ptr = g_strdup((((snmp_st_assoc_t*)
rec)->enterprise)); *out_len = (unsigned)strlen((((snmp_st_assoc_t
*)rec)->enterprise)); } else { *out_ptr = g_strdup(""); *out_len
= 0; } }
3566UAT_DEC_CB_DEF(specific_traps, trap, snmp_st_assoc_t)static void specific_traps_trap_set_cb(void* rec, const char*
buf, unsigned len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { char* tmp_str = g_strndup
(buf,len); ws_strtou32(tmp_str, ((void*)0), &((snmp_st_assoc_t
*)rec)->trap); g_free(tmp_str); } static void specific_traps_trap_tostr_cb
(void* rec, char** out_ptr, unsigned* out_len, const void* u1
__attribute__((unused)), const void* u2 __attribute__((unused
))) { *out_ptr = wmem_strdup_printf(((void*)0), "%u",((snmp_st_assoc_t
*)rec)->trap); *out_len = (unsigned)strlen(*out_ptr); }
3567UAT_CSTRING_CB_DEF(specific_traps, desc, snmp_st_assoc_t)static void specific_traps_desc_set_cb(void* rec, const char*
buf, unsigned len, const void* u1 __attribute__((unused)), const
void* u2 __attribute__((unused))) { char* new_buf = g_strndup
(buf,len); g_free((((snmp_st_assoc_t*)rec)->desc)); (((snmp_st_assoc_t
*)rec)->desc) = new_buf; } static void specific_traps_desc_tostr_cb
(void* rec, char** out_ptr, unsigned* out_len, const void* u1
__attribute__((unused)), const void* u2 __attribute__((unused
))) { if (((snmp_st_assoc_t*)rec)->desc ) { *out_ptr = g_strdup
((((snmp_st_assoc_t*)rec)->desc)); *out_len = (unsigned)strlen
((((snmp_st_assoc_t*)rec)->desc)); } else { *out_ptr = g_strdup
(""); *out_len = 0; } }
3568 3569/*--- proto_register_snmp -------------------------------------------*/3570void proto_register_snmp(void) {3571/* List of fields */3572static hf_register_info hf[] = {3573{ &hf_snmp_response_in,3574{ "Response In", "snmp.response_in", FT_FRAMENUM, BASE_NONE, NULL((void*)0), 0x0,3575"The response to this SNMP request is in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3576{ &hf_snmp_response_to,3577{ "Response To", "snmp.response_to", FT_FRAMENUM, BASE_NONE, NULL((void*)0), 0x0,3578"This is a response to the SNMP request in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3579{ &hf_snmp_time,3580{ "Time", "snmp.time", FT_RELATIVE_TIME, BASE_NONE, NULL((void*)0), 0x0,3581"The time between the Request and the Response", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3582{ &hf_snmp_v3_flags_auth,3583{ "Authenticated", "snmp.v3.flags.auth", FT_BOOLEAN, 8,3584 TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset
))))
, TH_AUTH0x01, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3585{ &hf_snmp_v3_flags_crypt,3586{ "Encrypted", "snmp.v3.flags.crypt", FT_BOOLEAN, 8,3587 TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset
))))
, TH_CRYPT0x02, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3588{ &hf_snmp_v3_flags_report,3589{ "Reportable", "snmp.v3.flags.report", FT_BOOLEAN, 8,3590 TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset
))))
, TH_REPORT0x04, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3591{ &hf_snmp_engineid_conform, {3592 "Engine ID Conformance", "snmp.engineid.conform", FT_BOOLEAN, 8,3593 TFS(&tfs_snmp_engineid_conform)((0 ? (const struct true_false_string*)0 : ((&tfs_snmp_engineid_conform
))))
, F_SNMP_ENGINEID_CONFORM0x80, "Engine ID RFC3411 Conformance", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3594{ &hf_snmp_engineid_enterprise, {3595 "Engine Enterprise ID", "snmp.engineid.enterprise", FT_UINT32, BASE_ENTERPRISESBASE_CUSTOM,3596 STRINGS_ENTERPRISES((const void *) (gsize) (enterprises_base_custom)), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3597{ &hf_snmp_engineid_format, {3598 "Engine ID Format", "snmp.engineid.format", FT_UINT8, BASE_DEC,3599 VALS(snmp_engineid_format_vals)((0 ? (const struct _value_string*)0 : ((snmp_engineid_format_vals
))))
, 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3600{ &hf_snmp_engineid_ipv4, {3601 "Engine ID Data: IPv4 address", "snmp.engineid.ipv4", FT_IPv4, BASE_NONE,3602 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3603{ &hf_snmp_engineid_ipv6, {3604 "Engine ID Data: IPv6 address", "snmp.engineid.ipv6", FT_IPv6, BASE_NONE,3605 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3606{ &hf_snmp_engineid_cisco_type, {3607 "Engine ID Data: Cisco type", "snmp.engineid.cisco.type", FT_UINT8, BASE_HEX,3608 VALS(snmp_engineid_cisco_type_vals)((0 ? (const struct _value_string*)0 : ((snmp_engineid_cisco_type_vals
))))
, 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3609{ &hf_snmp_engineid_mac, {3610 "Engine ID Data: MAC address", "snmp.engineid.mac", FT_ETHER, BASE_NONE,3611 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3612{ &hf_snmp_engineid_text, {3613 "Engine ID Data: Text", "snmp.engineid.text", FT_STRING, BASE_NONE,3614 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3615{ &hf_snmp_engineid_time, {3616 "Engine ID Data: Creation Time", "snmp.engineid.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,3617 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3618{ &hf_snmp_engineid_data, {3619 "Engine ID Data", "snmp.engineid.data", FT_BYTES, BASE_NONE,3620 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3621{ &hf_snmp_msgAuthentication, {3622 "Authentication", "snmp.v3.auth", FT_BOOLEAN, BASE_NONE,3623 TFS(&auth_flags)((0 ? (const struct true_false_string*)0 : ((&auth_flags)
)))
, 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3624{ &hf_snmp_decryptedPDU, {3625 "Decrypted ScopedPDU", "snmp.decrypted_pdu", FT_BYTES, BASE_NONE,3626 NULL((void*)0), 0, "Decrypted PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3627{ &hf_snmp_noSuchObject, {3628 "noSuchObject", "snmp.noSuchObject", FT_NONE, BASE_NONE,3629 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3630{ &hf_snmp_noSuchInstance, {3631 "noSuchInstance", "snmp.noSuchInstance", FT_NONE, BASE_NONE,3632 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3633{ &hf_snmp_endOfMibView, {3634 "endOfMibView", "snmp.endOfMibView", FT_NONE, BASE_NONE,3635 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3636{ &hf_snmp_unSpecified, {3637 "unSpecified", "snmp.unSpecified", FT_NONE, BASE_NONE,3638 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3639 3640{ &hf_snmp_integer32_value, {3641 "Value (Integer32)", "snmp.value.int", FT_INT64, BASE_DEC,3642 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3643{ &hf_snmp_octetstring_value, {3644 "Value (OctetString)", "snmp.value.octets", FT_BYTES, BASE_SHOW_ASCII_PRINTABLE0x00010000,3645 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3646{ &hf_snmp_oid_value, {3647 "Value (OID)", "snmp.value.oid", FT_OID, BASE_NONE,3648 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3649{ &hf_snmp_null_value, {3650 "Value (Null)", "snmp.value.null", FT_NONE, BASE_NONE,3651 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3652{ &hf_snmp_ipv4_value, {3653 "Value (IpAddress)", "snmp.value.ipv4", FT_IPv4, BASE_NONE,3654 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3655{ &hf_snmp_ipv6_value, {3656 "Value (IpAddress)", "snmp.value.ipv6", FT_IPv6, BASE_NONE,3657 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3658{ &hf_snmp_anyaddress_value, {3659 "Value (IpAddress)", "snmp.value.addr", FT_BYTES, BASE_NONE,3660 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3661{ &hf_snmp_unsigned32_value, {3662 "Value (Unsigned32)", "snmp.value.u32", FT_INT64, BASE_DEC,3663 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3664{ &hf_snmp_gauge32_value, {3665 "Value (Gauge32)", "snmp.value.g32", FT_INT64, BASE_DEC,3666 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3667{ &hf_snmp_unknown_value, {3668 "Value (Unknown)", "snmp.value.unk", FT_BYTES, BASE_NONE,3669 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3670{ &hf_snmp_counter_value, {3671 "Value (Counter32)", "snmp.value.counter", FT_UINT64, BASE_DEC,3672 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3673{ &hf_snmp_big_counter_value, {3674 "Value (Counter64)", "snmp.value.counter", FT_UINT64, BASE_DEC,3675 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3676{ &hf_snmp_nsap_value, {3677 "Value (NSAP)", "snmp.value.nsap", FT_UINT64, BASE_DEC,3678 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3679{ &hf_snmp_timeticks_value, {3680 "Value (Timeticks)", "snmp.value.timeticks", FT_UINT64, BASE_DEC,3681 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3682{ &hf_snmp_opaque_value, {3683 "Value (Opaque)", "snmp.value.opaque", FT_BYTES, BASE_NONE,3684 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3685{ &hf_snmp_objectname, {3686 "Object Name", "snmp.name", FT_OID, BASE_NONE,3687 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3688{ &hf_snmp_scalar_instance_index, {3689 "Scalar Instance Index", "snmp.name.index", FT_UINT64, BASE_DEC,3690 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3691{ &hf_snmp_var_bind_str, {3692 "Variable-binding-string", "snmp.var-bind_str", FT_STRING, BASE_NONE,3693 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3694{ &hf_snmp_agentid_trailer, {3695 "AgentID Trailer", "snmp.agentid_trailer", FT_BYTES, BASE_NONE,3696 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3697 3698 3699 { &hf_snmp_SMUX_PDUs_PDU,3700 { "SMUX-PDUs", "snmp.SMUX_PDUs",3701 FT_UINT32, BASE_DEC, VALS(snmp_SMUX_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_SMUX_PDUs_vals)
)))
, 0,3702 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3703 { &hf_snmp_version,3704 { "version", "snmp.version",3705 FT_INT32, BASE_DEC, VALS(snmp_Version_vals)((0 ? (const struct _value_string*)0 : ((snmp_Version_vals)))
)
, 0,3706 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3707 { &hf_snmp_community,3708 { "community", "snmp.community",3709 FT_STRING, BASE_NONE, NULL((void*)0), 0,3710 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3711 { &hf_snmp_data,3712 { "data", "snmp.data",3713 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,3714 "PDUs", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3715 { &hf_snmp_parameters,3716 { "parameters", "snmp.parameters",3717 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3718 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3719 { &hf_snmp_datav2u,3720 { "datav2u", "snmp.datav2u",3721 FT_UINT32, BASE_DEC, VALS(snmp_T_datav2u_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_datav2u_vals)
)))
, 0,3722 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3723 { &hf_snmp_v2u_plaintext,3724 { "plaintext", "snmp.plaintext",3725 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,3726 "PDUs", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3727 { &hf_snmp_encrypted,3728 { "encrypted", "snmp.encrypted",3729 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3730 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3731 { &hf_snmp_msgAuthoritativeEngineID,3732 { "msgAuthoritativeEngineID", "snmp.msgAuthoritativeEngineID",3733 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3734 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3735 { &hf_snmp_msgAuthoritativeEngineBoots,3736 { "msgAuthoritativeEngineBoots", "snmp.msgAuthoritativeEngineBoots",3737 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3738 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3739 { &hf_snmp_msgAuthoritativeEngineTime,3740 { "msgAuthoritativeEngineTime", "snmp.msgAuthoritativeEngineTime",3741 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3742 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3743 { &hf_snmp_msgUserName,3744 { "msgUserName", "snmp.msgUserName",3745 FT_STRING, BASE_NONE, NULL((void*)0), 0,3746 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3747 { &hf_snmp_msgAuthenticationParameters,3748 { "msgAuthenticationParameters", "snmp.msgAuthenticationParameters",3749 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3750 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3751 { &hf_snmp_msgPrivacyParameters,3752 { "msgPrivacyParameters", "snmp.msgPrivacyParameters",3753 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3754 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3755 { &hf_snmp_msgVersion,3756 { "msgVersion", "snmp.msgVersion",3757 FT_INT32, BASE_DEC, VALS(snmp_Version_vals)((0 ? (const struct _value_string*)0 : ((snmp_Version_vals)))
)
, 0,3758 "Version", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3759 { &hf_snmp_msgGlobalData,3760 { "msgGlobalData", "snmp.msgGlobalData_element",3761 FT_NONE, BASE_NONE, NULL((void*)0), 0,3762 "HeaderData", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3763 { &hf_snmp_msgSecurityParameters,3764 { "msgSecurityParameters", "snmp.msgSecurityParameters",3765 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3766 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3767 { &hf_snmp_msgData,3768 { "msgData", "snmp.msgData",3769 FT_UINT32, BASE_DEC, VALS(snmp_ScopedPduData_vals)((0 ? (const struct _value_string*)0 : ((snmp_ScopedPduData_vals
))))
, 0,3770 "ScopedPduData", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3771 { &hf_snmp_msgID,3772 { "msgID", "snmp.msgID",3773 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3774 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3775 { &hf_snmp_msgMaxSize,3776 { "msgMaxSize", "snmp.msgMaxSize",3777 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3778 "INTEGER_484_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3779 { &hf_snmp_msgFlags,3780 { "msgFlags", "snmp.msgFlags",3781 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3782 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3783 { &hf_snmp_msgSecurityModel,3784 { "msgSecurityModel", "snmp.msgSecurityModel",3785 FT_UINT32, BASE_DEC, VALS(sec_models)((0 ? (const struct _value_string*)0 : ((sec_models)))), 0,3786 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3787 { &hf_snmp_plaintext,3788 { "plaintext", "snmp.plaintext_element",3789 FT_NONE, BASE_NONE, NULL((void*)0), 0,3790 "ScopedPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3791 { &hf_snmp_encryptedPDU,3792 { "encryptedPDU", "snmp.encryptedPDU",3793 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3794 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3795 { &hf_snmp_contextEngineID,3796 { "contextEngineID", "snmp.contextEngineID",3797 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3798 "SnmpEngineID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3799 { &hf_snmp_contextName,3800 { "contextName", "snmp.contextName",3801 FT_STRING, BASE_NONE, NULL((void*)0), 0,3802 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3803 { &hf_snmp_get_request,3804 { "get-request", "snmp.get_request_element",3805 FT_NONE, BASE_NONE, NULL((void*)0), 0,3806 "GetRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3807 { &hf_snmp_get_next_request,3808 { "get-next-request", "snmp.get_next_request_element",3809 FT_NONE, BASE_NONE, NULL((void*)0), 0,3810 "GetNextRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3811 { &hf_snmp_get_response,3812 { "get-response", "snmp.get_response_element",3813 FT_NONE, BASE_NONE, NULL((void*)0), 0,3814 "GetResponse_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3815 { &hf_snmp_set_request,3816 { "set-request", "snmp.set_request_element",3817 FT_NONE, BASE_NONE, NULL((void*)0), 0,3818 "SetRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3819 { &hf_snmp_trap,3820 { "trap", "snmp.trap_element",3821 FT_NONE, BASE_NONE, NULL((void*)0), 0,3822 "Trap_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3823 { &hf_snmp_getBulkRequest,3824 { "getBulkRequest", "snmp.getBulkRequest_element",3825 FT_NONE, BASE_NONE, NULL((void*)0), 0,3826 "GetBulkRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3827 { &hf_snmp_informRequest,3828 { "informRequest", "snmp.informRequest_element",3829 FT_NONE, BASE_NONE, NULL((void*)0), 0,3830 "InformRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3831 { &hf_snmp_snmpV2_trap,3832 { "snmpV2-trap", "snmp.snmpV2_trap_element",3833 FT_NONE, BASE_NONE, NULL((void*)0), 0,3834 "SNMPv2_Trap_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3835 { &hf_snmp_report,3836 { "report", "snmp.report_element",3837 FT_NONE, BASE_NONE, NULL((void*)0), 0,3838 "Report_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3839 { &hf_snmp_request_id,3840 { "request-id", "snmp.request_id",3841 FT_INT32, BASE_DEC, NULL((void*)0), 0,3842 "T_request_id", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3843 { &hf_snmp_error_status,3844 { "error-status", "snmp.error_status",3845 FT_INT32, BASE_DEC, VALS(snmp_T_error_status_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_error_status_vals
))))
, 0,3846 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3847 { &hf_snmp_error_index,3848 { "error-index", "snmp.error_index",3849 FT_INT32, BASE_DEC, NULL((void*)0), 0,3850 "INTEGER", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3851 { &hf_snmp_variable_bindings,3852 { "variable-bindings", "snmp.variable_bindings",3853 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3854 "VarBindList", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3855 { &hf_snmp_bulkPDU_request_id,3856 { "request-id", "snmp.request_id",3857 FT_INT32, BASE_DEC, NULL((void*)0), 0,3858 "Integer32", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3859 { &hf_snmp_non_repeaters,3860 { "non-repeaters", "snmp.non_repeaters",3861 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3862 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3863 { &hf_snmp_max_repetitions,3864 { "max-repetitions", "snmp.max_repetitions",3865 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3866 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3867 { &hf_snmp_enterprise,3868 { "enterprise", "snmp.enterprise",3869 FT_OID, BASE_NONE, NULL((void*)0), 0,3870 "EnterpriseOID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3871 { &hf_snmp_agent_addr,3872 { "agent-addr", "snmp.agent_addr",3873 FT_IPv4, BASE_NONE, NULL((void*)0), 0,3874 "NetworkAddress", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3875 { &hf_snmp_generic_trap,3876 { "generic-trap", "snmp.generic_trap",3877 FT_INT32, BASE_DEC, VALS(snmp_GenericTrap_vals)((0 ? (const struct _value_string*)0 : ((snmp_GenericTrap_vals
))))
, 0,3878 "GenericTrap", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3879 { &hf_snmp_specific_trap,3880 { "specific-trap", "snmp.specific_trap",3881 FT_INT32, BASE_DEC, NULL((void*)0), 0,3882 "SpecificTrap", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3883 { &hf_snmp_time_stamp,3884 { "time-stamp", "snmp.time_stamp",3885 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3886 "TimeTicks", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3887 { &hf_snmp_name,3888 { "name", "snmp.name",3889 FT_OID, BASE_NONE, NULL((void*)0), 0,3890 "ObjectName", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3891 { &hf_snmp_valueType,3892 { "valueType", "snmp.valueType_element",3893 FT_NONE, BASE_NONE, NULL((void*)0), 0,3894 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3895 { &hf_snmp_VarBindList_item,3896 { "VarBind", "snmp.VarBind_element",3897 FT_NONE, BASE_NONE, NULL((void*)0), 0,3898 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3899 { &hf_snmp_open,3900 { "open", "snmp.open",3901 FT_UINT32, BASE_DEC, VALS(snmp_OpenPDU_vals)((0 ? (const struct _value_string*)0 : ((snmp_OpenPDU_vals)))
)
, 0,3902 "OpenPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3903 { &hf_snmp_close,3904 { "close", "snmp.close",3905 FT_INT32, BASE_DEC, VALS(snmp_ClosePDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_ClosePDU_U_vals
))))
, 0,3906 "ClosePDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3907 { &hf_snmp_registerRequest,3908 { "registerRequest", "snmp.registerRequest_element",3909 FT_NONE, BASE_NONE, NULL((void*)0), 0,3910 "RReqPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3911 { &hf_snmp_registerResponse,3912 { "registerResponse", "snmp.registerResponse",3913 FT_UINT32, BASE_DEC, VALS(snmp_RegisterResponse_vals)((0 ? (const struct _value_string*)0 : ((snmp_RegisterResponse_vals
))))
, 0,3914 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3915 { &hf_snmp_commitOrRollback,3916 { "commitOrRollback", "snmp.commitOrRollback",3917 FT_INT32, BASE_DEC, VALS(snmp_SOutPDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_SOutPDU_U_vals)
)))
, 0,3918 "SOutPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3919 { &hf_snmp_rRspPDU,3920 { "rRspPDU", "snmp.rRspPDU",3921 FT_INT32, BASE_DEC, VALS(snmp_RRspPDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_RRspPDU_U_vals)
)))
, 0,3922 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3923 { &hf_snmp_pDUs,3924 { "pDUs", "snmp.pDUs",3925 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,3926 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3927 { &hf_snmp_smux_simple,3928 { "smux-simple", "snmp.smux_simple_element",3929 FT_NONE, BASE_NONE, NULL((void*)0), 0,3930 "SimpleOpen", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3931 { &hf_snmp_smux_version,3932 { "smux-version", "snmp.smux_version",3933 FT_INT32, BASE_DEC, VALS(snmp_T_smux_version_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_smux_version_vals
))))
, 0,3934 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3935 { &hf_snmp_identity,3936 { "identity", "snmp.identity",3937 FT_OID, BASE_NONE, NULL((void*)0), 0,3938 "OBJECT_IDENTIFIER", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3939 { &hf_snmp_description,3940 { "description", "snmp.description",3941 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3942 "DisplayString", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3943 { &hf_snmp_password,3944 { "password", "snmp.password",3945 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3946 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3947 { &hf_snmp_subtree,3948 { "subtree", "snmp.subtree",3949 FT_OID, BASE_NONE, NULL((void*)0), 0,3950 "ObjectName", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3951 { &hf_snmp_priority,3952 { "priority", "snmp.priority",3953 FT_INT32, BASE_DEC, NULL((void*)0), 0,3954 "INTEGER_M1_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3955 { &hf_snmp_operation,3956 { "operation", "snmp.operation",3957 FT_INT32, BASE_DEC, VALS(snmp_T_operation_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_operation_vals
))))
, 0,3958 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3959};3960 3961/* List of subtrees */3962static gint *ett[] = {3963&ett_snmp,3964&ett_engineid,3965&ett_msgFlags,3966&ett_encryptedPDU,3967&ett_decrypted,3968&ett_authParameters,3969&ett_internet,3970&ett_varbind,3971&ett_name,3972&ett_value,3973&ett_decoding_error,3974 &ett_snmp_Message,3975 &ett_snmp_Messagev2u,3976 &ett_snmp_T_datav2u,3977 &ett_snmp_UsmSecurityParameters,3978 &ett_snmp_SNMPv3Message,3979 &ett_snmp_HeaderData,3980 &ett_snmp_ScopedPduData,3981 &ett_snmp_ScopedPDU,3982 &ett_snmp_PDUs,3983 &ett_snmp_PDU,3984 &ett_snmp_BulkPDU,3985 &ett_snmp_Trap_PDU_U,3986 &ett_snmp_VarBind,3987 &ett_snmp_VarBindList,3988 &ett_snmp_SMUX_PDUs,3989 &ett_snmp_RegisterResponse,3990 &ett_snmp_OpenPDU,3991 &ett_snmp_SimpleOpen_U,3992 &ett_snmp_RReqPDU_U,3993};3994static ei_register_info ei[] = {3995{ &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Failed to decrypt encryptedPDU", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},3996{ &ei_snmp_decrypted_data_bad_formatted, { "snmp.decrypted_data_bad_formatted", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Decrypted data not formatted as expected, wrong key?", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},3997{ &ei_snmp_verify_authentication_error, { "snmp.verify_authentication_error", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Error while verifying Message authenticity", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},3998{ &ei_snmp_authentication_ok, { "snmp.authentication_ok", PI_CHECKSUM0x01000000, PI_CHAT0x00200000, "SNMP Authentication OK", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},3999{ &ei_snmp_authentication_error, { "snmp.authentication_error", PI_CHECKSUM0x01000000, PI_WARN0x00600000, "SNMP Authentication Error", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4000{ &ei_snmp_varbind_not_uni_class_seq, { "snmp.varbind.not_uni_class_seq", PI_MALFORMED0x07000000, PI_WARN0x00600000, "VarBind is not an universal class sequence", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4001{ &ei_snmp_varbind_has_indicator, { "snmp.varbind.has_indicator", PI_MALFORMED0x07000000, PI_WARN0x00600000, "VarBind has indicator set", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4002{ &ei_snmp_objectname_not_oid, { "snmp.objectname_not_oid", PI_MALFORMED0x07000000, PI_WARN0x00600000, "ObjectName not an OID", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4003{ &ei_snmp_objectname_has_indicator, { "snmp.objectname_has_indicator", PI_MALFORMED0x07000000, PI_WARN0x00600000, "ObjectName has indicator set", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4004{ &ei_snmp_value_not_primitive_encoding, { "snmp.value_not_primitive_encoding", PI_MALFORMED0x07000000, PI_WARN0x00600000, "value not in primitive encoding", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4005{ &ei_snmp_invalid_oid, { "snmp.invalid_oid", PI_MALFORMED0x07000000, PI_WARN0x00600000, "invalid oid", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4006{ &ei_snmp_varbind_wrong_tag, { "snmp.varbind.wrong_tag", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong tag for SNMP VarBind error value", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4007{ &ei_snmp_varbind_response, { "snmp.varbind.response", PI_RESPONSE_CODE0x03000000, PI_NOTE0x00400000, "Response", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4008{ &ei_snmp_no_instance_subid, { "snmp.no_instance_subid", PI_MALFORMED0x07000000, PI_WARN0x00600000, "No instance sub-id in scalar value", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4009{ &ei_snmp_wrong_num_of_subids, { "snmp.wrong_num_of_subids", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong number of instance sub-ids in scalar value", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4010{ &ei_snmp_index_suboid_too_short, { "snmp.index_suboid_too_short", PI_MALFORMED0x07000000, PI_WARN0x00600000, "index sub-oid shorter than expected", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4011{ &ei_snmp_unimplemented_instance_index, { "snmp.unimplemented_instance_index", PI_UNDECODED0x05000000, PI_WARN0x00600000, "OID instances not handled, if you want this implemented please contact the wireshark developers", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4012{ &ei_snmp_index_suboid_len0, { "snmp.ndex_suboid_len0", PI_MALFORMED0x07000000, PI_WARN0x00600000, "an index sub-oid OID cannot be 0 bytes long!", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4013{ &ei_snmp_index_suboid_too_long, { "snmp.index_suboid_too_long", PI_MALFORMED0x07000000, PI_WARN0x00600000, "index sub-oid should not be longer than remaining oid size", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4014{ &ei_snmp_index_string_too_long, { "snmp.index_string_too_long", PI_MALFORMED0x07000000, PI_WARN0x00600000, "index string should not be longer than remaining oid size", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4015{ &ei_snmp_column_parent_not_row, { "snmp.column_parent_not_row", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "COLUMNS's parent is not a ROW", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4016{ &ei_snmp_uint_too_large, { "snmp.uint_too_large", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Unsigned integer value > 2^64 - 1", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4017{ &ei_snmp_int_too_large, { "snmp.int_too_large", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Signed integer value > 2^63 - 1 or <= -2^63", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4018{ &ei_snmp_integral_value0, { "snmp.integral_value0", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Integral value is zero-length", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4019{ &ei_snmp_missing_mib, { "snmp.missing_mib", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Unresolved value, Missing MIB", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4020{ &ei_snmp_varbind_wrong_length_value, { "snmp.varbind.wrong_length_value", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong length for SNMP VarBind/value", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4021{ &ei_snmp_varbind_wrong_class_tag, { "snmp.varbind.wrong_class_tag", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong class/tag for SNMP VarBind/value", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4022{ &ei_snmp_rfc1910_non_conformant, { "snmp.rfc1910_non_conformant", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Data not conforming to RFC1910", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4023{ &ei_snmp_rfc3411_non_conformant, { "snmp.rfc3411_non_conformant", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Data not conforming to RFC3411", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4024{ &ei_snmp_version_unknown, { "snmp.version.unknown", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Unknown version", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4025{ &ei_snmp_trap_pdu_obsolete, { "snmp.trap_pdu_obsolete", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Trap-PDU is obsolete in this SNMP version", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},4026 4027};4028 4029expert_module_t* expert_snmp;4030module_t *snmp_module;4031 4032static uat_field_t users_fields[] = {4033UAT_FLD_BUFFER(snmp_users,engine_id,"Engine ID","Engine-id for this entry (empty = any)"){"engine_id", "Engine ID", PT_TXTMOD_HEXBYTES,{0,snmp_users_engine_id_set_cb
,snmp_users_engine_id_tostr_cb},{0,0,0},0,"Engine-id for this entry (empty = any)"
,((void*)0)}
,4034UAT_FLD_LSTRING(snmp_users,userName,"Username","The username"){"userName", "Username", PT_TXTMOD_STRING,{0,snmp_users_userName_set_cb
,snmp_users_userName_tostr_cb},{0,0,0},0,"The username",((void
*)0)}
,4035UAT_FLD_VS(snmp_users,auth_model,"Authentication model",auth_types,"Algorithm to be used for authentication."){"auth_model", "Authentication model", PT_TXTMOD_ENUM,{uat_fld_chk_enum
,snmp_users_auth_model_set_cb,snmp_users_auth_model_tostr_cb}
,{&(auth_types),&(auth_types),&(auth_types)},&
(auth_types),"Algorithm to be used for authentication.",((void
*)0)}
,4036UAT_FLD_LSTRING(snmp_users,authPassword,"Password","The password used for authenticating packets for this entry"){"authPassword", "Password", PT_TXTMOD_STRING,{0,snmp_users_authPassword_set_cb
,snmp_users_authPassword_tostr_cb},{0,0,0},0,"The password used for authenticating packets for this entry"
,((void*)0)}
,4037UAT_FLD_VS(snmp_users,priv_proto,"Privacy protocol",priv_types,"Algorithm to be used for privacy."){"priv_proto", "Privacy protocol", PT_TXTMOD_ENUM,{uat_fld_chk_enum
,snmp_users_priv_proto_set_cb,snmp_users_priv_proto_tostr_cb}
,{&(priv_types),&(priv_types),&(priv_types)},&
(priv_types),"Algorithm to be used for privacy.",((void*)0)}
,4038UAT_FLD_LSTRING(snmp_users,privPassword,"Privacy password","The password used for encrypting packets for this entry"){"privPassword", "Privacy password", PT_TXTMOD_STRING,{0,snmp_users_privPassword_set_cb
,snmp_users_privPassword_tostr_cb},{0,0,0},0,"The password used for encrypting packets for this entry"
,((void*)0)}
,4039UAT_END_FIELDS{((void*)0),((void*)0),PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,((void
*)0)}
4040};4041 4042uat_t *assocs_uat = uat_new("SNMP Users",4043 sizeof(snmp_ue_assoc_t),4044 "snmp_users",4045 TRUE(!(0)),4046 &ueas,4047 &num_ueas,4048 UAT_AFFECTS_DISSECTION0x00000001,/* affects dissection of packets, but not set of named fields */4049 "ChSNMPUsersSection",4050 snmp_users_copy_cb,4051 snmp_users_update_cb,4052 snmp_users_free_cb,4053 renew_ue_cache,4054 NULL((void*)0),4055 users_fields);4056 4057static uat_field_t specific_traps_flds[] = {4058UAT_FLD_CSTRING(specific_traps,enterprise,"Enterprise OID","Enterprise Object Identifier"){"enterprise", "Enterprise OID", PT_TXTMOD_STRING,{uat_fld_chk_str
,specific_traps_enterprise_set_cb,specific_traps_enterprise_tostr_cb
},{0,0,0},0,"Enterprise Object Identifier",((void*)0)}
,4059UAT_FLD_DEC(specific_traps,trap,"Trap Id","The specific-trap value"){"trap", "Trap Id", PT_TXTMOD_STRING,{uat_fld_chk_num_dec,specific_traps_trap_set_cb
,specific_traps_trap_tostr_cb},{0,0,0},0,"The specific-trap value"
,((void*)0)}
,4060UAT_FLD_CSTRING(specific_traps,desc,"Description","Trap type description"){"desc", "Description", PT_TXTMOD_STRING,{uat_fld_chk_str,specific_traps_desc_set_cb
,specific_traps_desc_tostr_cb},{0,0,0},0,"Trap type description"
,((void*)0)}
,4061UAT_END_FIELDS{((void*)0),((void*)0),PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,((void
*)0)}
4062};4063 4064uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types",4065 sizeof(snmp_st_assoc_t),4066 "snmp_specific_traps",4067 TRUE(!(0)),4068 &specific_traps,4069 &num_specific_traps,4070 UAT_AFFECTS_DISSECTION0x00000001, /* affects dissection of packets, but not set of named fields */4071 "ChSNMPEnterpriseSpecificTrapTypes",4072 snmp_specific_trap_copy_cb,4073 NULL((void*)0),4074 snmp_specific_trap_free_cb,4075 NULL((void*)0),4076 NULL((void*)0),4077 specific_traps_flds);4078 4079/* Register protocol */4080proto_snmp = proto_register_protocol(PNAME"Simple Network Management Protocol", PSNAME"SNMP", PFNAME"snmp");4081snmp_handle = register_dissector("snmp", dissect_snmp, proto_snmp);4082 4083/* Register fields and subtrees */4084proto_register_field_array(proto_snmp, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));4085proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));4086expert_snmp = expert_register_protocol(proto_snmp);4087expert_register_field_array(expert_snmp, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0]));4088 4089/* Register dissector */4090snmp_tcp_handle = register_dissector("snmp.tcp", dissect_snmp_tcp, proto_snmp);4091 4092/* Register configuration preferences */4093snmp_module = prefs_register_protocol(proto_snmp, process_prefs);4094prefs_register_bool_preference(snmp_module, "display_oid",4095"Show SNMP OID in info column",4096"Whether the SNMP OID should be shown in the info column",4097&display_oid);4098 4099prefs_register_obsolete_preference(snmp_module, "mib_modules");4100prefs_register_obsolete_preference(snmp_module, "users_file");4101 4102prefs_register_bool_preference(snmp_module, "desegment",4103"Reassemble SNMP-over-TCP messages spanning multiple TCP segments",4104"Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."4105" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",4106&snmp_desegment);4107 4108prefs_register_bool_preference(snmp_module, "var_in_tree",4109"Display dissected variables inside SNMP tree",4110"ON - display dissected variables inside SNMP tree, OFF - display dissected variables in root tree after SNMP",4111&snmp_var_in_tree);4112 4113prefs_register_uat_preference(snmp_module, "users_table",4114"Users Table",4115"Table of engine-user associations used for authentication and decryption",4116assocs_uat);4117 4118prefs_register_uat_preference(snmp_module, "specific_traps_table",4119"Enterprise Specific Trap Types",4120"Table of enterprise specific-trap type descriptions",4121specific_traps_uat);4122 4123#ifdef HAVE_LIBSMI14124prefs_register_static_text_preference(snmp_module, "info_mibs",4125"MIB settings can be changed in the Name Resolution preferences",4126"MIB settings can be changed in the Name Resolution preferences");4127#endif4128 4129value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", proto_snmp, FT_STRING, STRING_CASE_SENSITIVE0);4130 4131register_init_routine(init_ue_cache);4132register_cleanup_routine(cleanup_ue_cache);4133 4134register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp);4135 4136snmp_tap=register_tap("snmp");4137 4138register_srt_table(proto_snmp, NULL((void*)0), 1, snmpstat_packet, snmpstat_init, NULL((void*)0));4139}4140 4141 4142/*--- proto_reg_handoff_snmp ---------------------------------------*/4143void proto_reg_handoff_snmp(void) {4144 4145dissector_add_uint_with_preference("udp.port", UDP_PORT_SNMP161, snmp_handle);4146dissector_add_uint("ethertype", ETHERTYPE_SNMP0x814C, snmp_handle);4147dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_AGENT0x900F, snmp_handle);4148dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_SINK0x9010, snmp_handle);4149dissector_add_uint("hpext.dxsap", HPEXT_SNMP0x165A, snmp_handle);4150 4151dissector_add_uint_with_preference("tcp.port", TCP_PORT_SNMP161, snmp_tcp_handle);4152/* Since "regular" SNMP port and "trap" SNMP port use the same handler,4153 the "trap" port doesn't really need a separate preference. Just register4154 normally */4155dissector_add_uint("tcp.port", TCP_PORT_SNMP_TRAP162, snmp_tcp_handle);4156dissector_add_uint("udp.port", UDP_PORT_SNMP_TRAP162, snmp_handle);4157dissector_add_uint("udp.port", UDP_PORT_SNMP_PATROL8161, snmp_handle);4158 4159data_handle = find_dissector("data");4160 4161/* SNMPv2-MIB sysDescr "1.3.6.1.2.1.1.1.0" */4162dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.1.0",4163create_dissector_handle(dissect_snmp_variable_string, proto_snmp));4164/* SNMPv2-MIB::sysName.0 (1.3.6.1.2.1.1.5.0) */4165dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.5.0",4166create_dissector_handle(dissect_snmp_variable_string, proto_snmp));4167 4168/*4169 * Process preference settings.4170 *4171 * We can't do this in the register routine, as preferences aren't4172 * read until all dissector register routines have been called (so4173 * that all dissector preferences have been registered).4174 */4175process_prefs();4176 4177}4178 4179void4180proto_register_smux(void)4181{4182static gint *ett[] = {4183&ett_smux,4184};4185 4186proto_smux = proto_register_protocol("SNMP Multiplex Protocol",4187 "SMUX", "smux");4188 4189proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));4190 4191smux_handle = register_dissector("smux", dissect_smux, proto_smux);4192}4193 4194void4195proto_reg_handoff_smux(void)4196{4197dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMUX199, smux_handle);4198}4199 4200/*4201 * Editor modelines - https://www.wireshark.org/tools/modelines.html4202 *4203 * Local variables:4204 * c-basic-offset: 84205 * tab-width: 84206 * indent-tabs-mode: t4207 * End:4208 *4209 * vi: set shiftwidth=8 tabstop=8 noexpandtab:4210 * :indentSize=8:tabSize=8:noTabs=false:4211 */
/builds/wireshark/wireshark/epan/dissectors/packet-snmp.c (2024)
Top Articles
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 5496

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.