/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 -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -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 -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-18/lib/clang/18 -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 -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../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-format-truncation -Wno-format-nonliteral -Wno-pointer-sign -std=gnu11 -ferror-limit 19 -fvisibility=hidden -fwrapv -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -dwarf-debug-flags /usr/lib/llvm-18/bin/clang -### --analyze -x c -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 -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 -fvisibility=hidden -fexcess-precision=fast -fstrict-flex-arrays=3 -fstack-clash-protection -fcf-protection=full -D _GLIBCXX_ASSERTIONS -fstack-protector-strong -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -fexceptions -Wno-format-truncation -Wno-format-nonliteral -fdiagnostics-color=always -Wno-pointer-sign -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -std=gnu11 -fPIC /builds/wireshark/wireshark/epan/dissectors/packet-snmp.c -o /builds/wireshark/wireshark/sbout/2024-10-04-100303-3896-1 -Xclang -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2024-10-04-100303-3896-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 <epan/tfs.h>59#include <wsutil/array.h>60#include "packet-ipx.h"61#include "packet-hpext.h"62#include "packet-ber.h"63#include "packet-snmp.h"64#include <wsutil/wsgcrypt.h>65 66#define PNAME"Simple Network Management Protocol" "Simple Network Management Protocol"67#define PSNAME"SNMP" "SNMP"68#define PFNAME"snmp" "snmp"69 70#define UDP_PORT_SNMP16116171#define UDP_PORT_SNMP_TRAP16216272#define TCP_PORT_SNMP16116173#define TCP_PORT_SNMP_TRAP16216274#define TCP_PORT_SMUX19919975#define UDP_PORT_SNMP_PATROL8161 816176#define SNMP_NUM_PROCEDURES8 877 78/* Initialize the protocol and registered fields */79static int snmp_tap;80static int proto_snmp;81static int proto_smux;82 83static bool_Bool display_oid = true1;84static bool_Bool snmp_var_in_tree = true1;85 86void proto_register_snmp(void);87void proto_reg_handoff_snmp(void);88void proto_register_smux(void);89void proto_reg_handoff_smux(void);90 91static void snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const uint8_t *password, unsigned passwordlen,92const uint8_t *engineID, unsigned engineLength, uint8_t *key);93 94static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);95static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);96static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);97static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);98 99static bool_Bool snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, uint8_t**, unsigned*, char const**);100 101static const value_string auth_types[] = {102{SNMP_USM_AUTH_MD5,"MD5"},103{SNMP_USM_AUTH_SHA1,"SHA1"},104{SNMP_USM_AUTH_SHA2_224,"SHA2-224"},105{SNMP_USM_AUTH_SHA2_256,"SHA2-256"},106{SNMP_USM_AUTH_SHA2_384,"SHA2-384"},107{SNMP_USM_AUTH_SHA2_512,"SHA2-512"},108{0,NULL((void*)0)}109};110 111static const unsigned auth_hash_len[] = {112HASH_MD5_LENGTH16,113HASH_SHA1_LENGTH20,114HASH_SHA2_224_LENGTH28,115HASH_SHA2_256_LENGTH32,116HASH_SHA2_384_LENGTH48,117HASH_SHA2_512_LENGTH64118};119 120static const unsigned auth_tag_len[] = {12112,12212,12316,12424,12532,12648127};128 129static const enum gcry_md_algos auth_hash_algo[] = {130GCRY_MD_MD5,131GCRY_MD_SHA1,132GCRY_MD_SHA224,133GCRY_MD_SHA256,134GCRY_MD_SHA384,135GCRY_MD_SHA512136};137 138#define PRIV_DES00139#define PRIV_AES12811140#define PRIV_AES19222141#define PRIV_AES25633142 143static const value_string priv_types[] = {144{ PRIV_DES0, "DES" },145{ PRIV_AES1281, "AES" },146{ PRIV_AES1922, "AES192" },147{ PRIV_AES2563, "AES256" },148{ 0, NULL((void*)0)}149};150static snmp_usm_decoder_t priv_protos[] = {151snmp_usm_priv_des,152snmp_usm_priv_aes128,153snmp_usm_priv_aes192,154snmp_usm_priv_aes256155};156 157#define PRIVKEYEXP_USM_3DESDESEDE_0000158#define PRIVKEYEXP_AGENTPP11159 160static const value_string priv_key_exp_types[] = {161{ PRIVKEYEXP_USM_3DESDESEDE_000, "draft-reeder-snmpv3-usm-3desede-00" },162{ PRIVKEYEXP_AGENTPP1, "AGENT++" },163{ 0, NULL((void*)0) }164};165 166static snmp_ue_assoc_t* ueas;167static unsigned num_ueas;168static snmp_ue_assoc_t* localized_ues;169static snmp_ue_assoc_t* unlocalized_ues;170/****/171 172/* Variables used for handling enterprise specific trap types */173typedef struct _snmp_st_assoc_t {174char *enterprise;175unsigned trap;176char *desc;177} snmp_st_assoc_t;178static unsigned num_specific_traps;179static snmp_st_assoc_t *specific_traps;180static const char *enterprise_oid;181static unsigned generic_trap;182static uint32_t snmp_version;183static uint32_t RequestID = -1;184 185static snmp_usm_params_t usm_p;186 187#define TH_AUTH0x01 0x01188#define TH_CRYPT0x02 0x02189#define TH_REPORT0x04 0x04190 191/* desegmentation of SNMP-over-TCP */192static bool_Bool snmp_desegment = true1;193 194/* Global variables */195 196uint32_t MsgSecurityModel;197tvbuff_t *oid_tvb=NULL((void*)0);198tvbuff_t *value_tvb=NULL((void*)0);199 200static dissector_handle_t snmp_handle;201static dissector_handle_t snmp_tcp_handle;202static dissector_handle_t data_handle;203static dissector_handle_t smux_handle;204 205static next_tvb_list_t *var_list;206 207static int hf_snmp_response_in;208static int hf_snmp_response_to;209static int hf_snmp_time;210 211static int hf_snmp_v3_flags_auth;212static int hf_snmp_v3_flags_crypt;213static int hf_snmp_v3_flags_report;214 215static int hf_snmp_engineid_conform;216static int hf_snmp_engineid_enterprise;217static int hf_snmp_engineid_format;218static int hf_snmp_engineid_ipv4;219static int hf_snmp_engineid_ipv6;220static int hf_snmp_engineid_cisco_type;221static int hf_snmp_engineid_mac;222static int hf_snmp_engineid_text;223static int hf_snmp_engineid_time;224static int hf_snmp_engineid_data;225static int hf_snmp_decryptedPDU;226static int hf_snmp_msgAuthentication;227 228static int hf_snmp_noSuchObject;229static int hf_snmp_noSuchInstance;230static int hf_snmp_endOfMibView;231static int hf_snmp_unSpecified;232 233static int hf_snmp_integer32_value;234static int hf_snmp_octetstring_value;235static int hf_snmp_oid_value;236static int hf_snmp_null_value;237static int hf_snmp_ipv4_value;238static int hf_snmp_ipv6_value;239static int hf_snmp_anyaddress_value;240static int hf_snmp_unsigned32_value;241static int hf_snmp_unknown_value;242static int hf_snmp_opaque_value;243static int hf_snmp_nsap_value;244static int hf_snmp_counter_value;245static int hf_snmp_timeticks_value;246static int hf_snmp_big_counter_value;247static int hf_snmp_gauge32_value;248 249static int hf_snmp_objectname;250static int hf_snmp_scalar_instance_index;251 252static int hf_snmp_var_bind_str;253static int hf_snmp_agentid_trailer;254 255static int hf_snmp_SMUX_PDUs_PDU; /* SMUX_PDUs */256static int hf_snmp_version; /* Version */257static int hf_snmp_community; /* Community */258static int hf_snmp_data; /* PDUs */259static int hf_snmp_parameters; /* OCTET_STRING */260static int hf_snmp_datav2u; /* T_datav2u */261static int hf_snmp_v2u_plaintext; /* PDUs */262static int hf_snmp_encrypted; /* OCTET_STRING */263static int hf_snmp_msgAuthoritativeEngineID; /* T_msgAuthoritativeEngineID */264static int hf_snmp_msgAuthoritativeEngineBoots; /* T_msgAuthoritativeEngineBoots */265static int hf_snmp_msgAuthoritativeEngineTime; /* T_msgAuthoritativeEngineTime */266static int hf_snmp_msgUserName; /* T_msgUserName */267static int hf_snmp_msgAuthenticationParameters; /* T_msgAuthenticationParameters */268static int hf_snmp_msgPrivacyParameters; /* T_msgPrivacyParameters */269static int hf_snmp_msgVersion; /* Version */270static int hf_snmp_msgGlobalData; /* HeaderData */271static int hf_snmp_msgSecurityParameters; /* T_msgSecurityParameters */272static int hf_snmp_msgData; /* ScopedPduData */273static int hf_snmp_msgID; /* INTEGER_0_2147483647 */274static int hf_snmp_msgMaxSize; /* INTEGER_484_2147483647 */275static int hf_snmp_msgFlags; /* T_msgFlags */276static int hf_snmp_msgSecurityModel; /* T_msgSecurityModel */277static int hf_snmp_plaintext; /* ScopedPDU */278static int hf_snmp_encryptedPDU; /* T_encryptedPDU */279static int hf_snmp_contextEngineID; /* SnmpEngineID */280static int hf_snmp_contextName; /* OCTET_STRING */281static int hf_snmp_get_request; /* GetRequest_PDU */282static int hf_snmp_get_next_request; /* GetNextRequest_PDU */283static int hf_snmp_get_response; /* GetResponse_PDU */284static int hf_snmp_set_request; /* SetRequest_PDU */285static int hf_snmp_trap; /* Trap_PDU */286static int hf_snmp_getBulkRequest; /* GetBulkRequest_PDU */287static int hf_snmp_informRequest; /* InformRequest_PDU */288static int hf_snmp_snmpV2_trap; /* SNMPv2_Trap_PDU */289static int hf_snmp_report; /* Report_PDU */290static int hf_snmp_request_id; /* T_request_id */291static int hf_snmp_error_status; /* T_error_status */292static int hf_snmp_error_index; /* INTEGER */293static int hf_snmp_variable_bindings; /* VarBindList */294static int hf_snmp_bulkPDU_request_id; /* Integer32 */295static int hf_snmp_non_repeaters; /* INTEGER_0_2147483647 */296static int hf_snmp_max_repetitions; /* INTEGER_0_2147483647 */297static int hf_snmp_enterprise; /* EnterpriseOID */298static int hf_snmp_agent_addr; /* NetworkAddress */299static int hf_snmp_generic_trap; /* GenericTrap */300static int hf_snmp_specific_trap; /* SpecificTrap */301static int hf_snmp_time_stamp; /* TimeTicks */302static int hf_snmp_name; /* ObjectName */303static int hf_snmp_valueType; /* ValueType */304static int hf_snmp_VarBindList_item; /* VarBind */305static int hf_snmp_open; /* OpenPDU */306static int hf_snmp_close; /* ClosePDU */307static int hf_snmp_registerRequest; /* RReqPDU */308static int hf_snmp_registerResponse; /* RegisterResponse */309static int hf_snmp_commitOrRollback; /* SOutPDU */310static int hf_snmp_rRspPDU; /* RRspPDU */311static int hf_snmp_pDUs; /* PDUs */312static int hf_snmp_smux_simple; /* SimpleOpen */313static int hf_snmp_smux_version; /* T_smux_version */314static int hf_snmp_identity; /* OBJECT_IDENTIFIER */315static int hf_snmp_description; /* DisplayString */316static int hf_snmp_password; /* OCTET_STRING */317static int hf_snmp_subtree; /* ObjectName */318static int hf_snmp_priority; /* INTEGER_M1_2147483647 */319static int hf_snmp_operation; /* T_operation */320 321/* Initialize the subtree pointers */322static int ett_smux;323static int ett_snmp;324static int ett_engineid;325static int ett_msgFlags;326static int ett_encryptedPDU;327static int ett_decrypted;328static int ett_authParameters;329static int ett_internet;330static int ett_varbind;331static int ett_name;332static int ett_value;333static int ett_decoding_error;334 335static int ett_snmp_Message;336static int ett_snmp_Messagev2u;337static int ett_snmp_T_datav2u;338static int ett_snmp_UsmSecurityParameters;339static int ett_snmp_SNMPv3Message;340static int ett_snmp_HeaderData;341static int ett_snmp_ScopedPduData;342static int ett_snmp_ScopedPDU;343static int ett_snmp_PDUs;344static int ett_snmp_PDU;345static int ett_snmp_BulkPDU;346static int ett_snmp_Trap_PDU_U;347static int ett_snmp_VarBind;348static int ett_snmp_VarBindList;349static int ett_snmp_SMUX_PDUs;350static int ett_snmp_RegisterResponse;351static int ett_snmp_OpenPDU;352static int ett_snmp_SimpleOpen_U;353static int ett_snmp_RReqPDU_U;354 355static expert_field ei_snmp_failed_decrypted_data_pdu;356static expert_field ei_snmp_decrypted_data_bad_formatted;357static expert_field ei_snmp_verify_authentication_error;358static expert_field ei_snmp_authentication_ok;359static expert_field ei_snmp_authentication_error;360static expert_field ei_snmp_varbind_not_uni_class_seq;361static expert_field ei_snmp_varbind_has_indicator;362static expert_field ei_snmp_objectname_not_oid;363static expert_field ei_snmp_objectname_has_indicator;364static expert_field ei_snmp_value_not_primitive_encoding;365static expert_field ei_snmp_invalid_oid;366static expert_field ei_snmp_varbind_wrong_tag;367static expert_field ei_snmp_varbind_response;368static expert_field ei_snmp_no_instance_subid;369static expert_field ei_snmp_wrong_num_of_subids;370static expert_field ei_snmp_index_suboid_too_short;371static expert_field ei_snmp_unimplemented_instance_index;372static expert_field ei_snmp_index_suboid_len0;373static expert_field ei_snmp_index_suboid_too_long;374static expert_field ei_snmp_index_string_too_long;375static expert_field ei_snmp_column_parent_not_row;376static expert_field ei_snmp_uint_too_large;377static expert_field ei_snmp_int_too_large;378static expert_field ei_snmp_integral_value0;379static expert_field ei_snmp_missing_mib;380static expert_field ei_snmp_varbind_wrong_length_value;381static expert_field ei_snmp_varbind_wrong_class_tag;382static expert_field ei_snmp_rfc1910_non_conformant;383static expert_field ei_snmp_rfc3411_non_conformant;384static expert_field ei_snmp_version_unknown;385static expert_field ei_snmp_trap_pdu_obsolete;386 387static const true_false_string auth_flags = {388"OK",389"Failed"390};391 392/* Security Models */393 394#define SNMP_SEC_ANY00395#define SNMP_SEC_V111396#define SNMP_SEC_V2C22397#define SNMP_SEC_USM33398 399static const value_string sec_models[] = {400{ SNMP_SEC_ANY0,"Any" },401{ SNMP_SEC_V11,"V1" },402{ SNMP_SEC_V2C2,"V2C" },403{ SNMP_SEC_USM3,"USM" },404{ 0,NULL((void*)0) }405};406 407#if 0408/* SMUX PDU types */409#define SMUX_MSG_OPEN 0410#define SMUX_MSG_CLOSE1411#define SMUX_MSG_RREQ2412#define SMUX_MSG_RRSP3413#define SMUX_MSG_SOUT4414 415static const value_string smux_types[] = {416{ SMUX_MSG_OPEN,"Open" },417{ SMUX_MSG_CLOSE,"Close" },418{ SMUX_MSG_RREQ,"Registration Request" },419{ SMUX_MSG_RRSP,"Registration Response" },420{ SMUX_MSG_SOUT,"Commit Or Rollback" },421{ 0,NULL((void*)0) }422};423#endif424 425/* Procedure names (used in Service Response Time) */426static const value_string snmp_procedure_names[] = {427{ 0,"Get" },428{ 1,"GetNext" },429{ 3,"Set" },430{ 4,"Register" },431{ 5,"Bulk" },432{ 6,"Inform" },433{ 0,NULL((void*)0) }434};435 436#define SNMP_IPA0 0/* IP Address */437#define SNMP_CNT1 1/* Counter (Counter32) */438#define SNMP_GGE2 2/* Gauge (Gauge32) */439#define SNMP_TIT3 3/* TimeTicks */440#define SNMP_OPQ4 4/* Opaque */441#define SNMP_NSP5 5/* NsapAddress */442#define SNMP_C646 6/* Counter64 */443#define SNMP_U327 7/* Uinteger32 */444 445#define SERR_NSO0 0446#define SERR_NSI1 1447#define SERR_EOM2 2448 449 450dissector_table_t value_sub_dissectors_table;451 452/*453 * Data structure attached to a conversation, request/response information454 */455typedef struct snmp_conv_info_t {456wmem_map_t *request_response;457} snmp_conv_info_t;458 459static snmp_conv_info_t*460snmp_find_conversation_and_get_conv_data(packet_info *pinfo);461 462static snmp_request_response_t *463snmp_get_request_response_pointer(wmem_map_t *map, uint32_t requestId)464{465snmp_request_response_t *srrp=(snmp_request_response_t *)wmem_map_lookup(map, &requestId);466if (!srrp) {467srrp=wmem_new0(wmem_file_scope(), snmp_request_response_t)((snmp_request_response_t*)wmem_alloc0((wmem_file_scope()), sizeof
(snmp_request_response_t)))
;468srrp->requestId=requestId;469wmem_map_insert(map, &(srrp->requestId), (void *)srrp);470}471 472return srrp;473}474 475static snmp_request_response_t*476snmp_match_request_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned requestId, unsigned procedure_id, snmp_conv_info_t *snmp_info)477{478snmp_request_response_t *srrp=NULL((void*)0);479 480DISSECTOR_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"
, 480, "snmp_info", "No SNMP info from ASN1 context"))))
;481 482/* get or create request/response pointer based on request id */483srrp=(snmp_request_response_t *)snmp_get_request_response_pointer(snmp_info->request_response, requestId);484 485// if not visited fill the request/response data486if (!PINFO_FD_VISITED(pinfo)((pinfo)->fd->visited)) {487switch(procedure_id)488{489case SNMP_REQ_GET0:490case SNMP_REQ_GETNEXT1:491case SNMP_REQ_SET3:492case SNMP_REQ_GETBULK5:493case SNMP_REQ_INFORM6:494srrp->request_frame_id=pinfo->fd->num;495srrp->response_frame_id=0;496srrp->request_time=pinfo->abs_ts;497srrp->request_procedure_id=procedure_id;498break;499case SNMP_RES_GET2:500srrp->response_frame_id=pinfo->fd->num;501break;502default:503return NULL((void*)0);504}505}506 507/* if request and response was matched */508if (srrp->request_frame_id!=0 && srrp->response_frame_id!=0)509{510proto_item *it;511 512// if it is the response513if (srrp->response_frame_id == pinfo->fd->num)514{515nstime_t ns;516it=proto_tree_add_uint(tree, hf_snmp_response_to, tvb, 0, 0, srrp->request_frame_id);517proto_item_set_generated(it);518nstime_delta(&ns, &pinfo->abs_ts, &srrp->request_time);519it=proto_tree_add_time(tree, hf_snmp_time, tvb, 0, 0, &ns);520proto_item_set_generated(it);521 522return srrp;523} else {524it=proto_tree_add_uint(tree, hf_snmp_response_in, tvb, 0, 0, srrp->response_frame_id);525proto_item_set_generated(it);526}527}528 529return NULL((void*)0);530}531 532static void533snmpstat_init(struct register_srt* srt _U___attribute__((unused)), GArray* srt_array)534{535srt_stat_table *snmp_srt_table;536uint32_t i;537 538snmp_srt_table = init_srt_table("SNMP Commands", NULL((void*)0), srt_array, SNMP_NUM_PROCEDURES8, NULL((void*)0), "snmp.data", NULL((void*)0));539for (i = 0; i < SNMP_NUM_PROCEDURES8; i++)540{541init_srt_table_row(snmp_srt_table, i, val_to_str_const(i, snmp_procedure_names, "<unknown>"));542}543}544 545/* This is called only if request and response was matched -> no need to return anything than TAP_PACKET_REDRAW */546static tap_packet_status547snmpstat_packet(void *psnmp, packet_info *pinfo, epan_dissect_t *edt _U___attribute__((unused)), const void *psi, tap_flags_t flags _U___attribute__((unused)))548{549unsigned i = 0;550srt_stat_table *snmp_srt_table;551const snmp_request_response_t *snmp=(const snmp_request_response_t *)psi;552srt_data_t *data = (srt_data_t *)psnmp;553 554snmp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i)(((srt_stat_table**) (void *) (data->srt_array)->data) [
(i)])
;555 556add_srt_table_data(snmp_srt_table, snmp->request_procedure_id, &snmp->request_time, pinfo);557return TAP_PACKET_REDRAW;558}559 560static const char *561snmp_lookup_specific_trap (unsigned specific_trap)562{563unsigned i;564 565for (i = 0; i < num_specific_traps; i++) {566snmp_st_assoc_t *u = &(specific_traps[i]);567 568if ((u->trap == specific_trap) &&569 (strcmp (u->enterprise, enterprise_oid) == 0))570{571return u->desc;572}573}574 575return NULL((void*)0);576}577 578static int579dissect_snmp_variable_string(tvbuff_t *tvb, packet_info *pinfo _U___attribute__((unused)), proto_tree *tree, void *data _U___attribute__((unused)))580{581 582proto_tree_add_item(tree, hf_snmp_var_bind_str, tvb, 0, -1, ENC_ASCII0x00000000);583 584return tvb_captured_length(tvb);585}586 587/*588DateAndTime ::= TEXTUAL-CONVENTION589 DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"590 STATUS current591 DESCRIPTION592 "A date-time specification.593 594 field octets contents range595 ----- ------ -------- -----596 1 1-2 year* 0..65536597 2 3 month 1..12598 3 4 day 1..31599 4 5 hour 0..23600 5 6 minutes 0..59601 6 7 seconds 0..60602 (use 60 for leap-second)603 7 8 deci-seconds 0..9604 8 9 direction from UTC '+' / '-'605 9 10 hours from UTC* 0..13606 10 11 minutes from UTC 0..59607 608 * Notes:609 - the value of year is in network-byte order610 - daylight saving time in New Zealand is +13611 612 For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be613 displayed as:614 615 1992-5-26,13:30:15.0,-4:0616 617 Note that if only local time is known, then timezone618 information (fields 8-10) is not present."619 SYNTAX OCTET STRING (SIZE (8 | 11))620*/621static proto_item *622dissect_snmp_variable_date_and_time(proto_tree *tree, packet_info *pinfo, int hfid, tvbuff_t *tvb, int offset, int length)623{624uint16_t year;625uint8_t month;626uint8_t day;627uint8_t hour;628uint8_t minutes;629uint8_t seconds;630uint8_t deci_seconds;631uint8_t hour_from_utc;632uint8_t min_from_utc;633char *str;634 635year= tvb_get_ntohs(tvb,offset);636month= tvb_get_uint8(tvb,offset+2);637day= tvb_get_uint8(tvb,offset+3);638hour= tvb_get_uint8(tvb,offset+4);639minutes= tvb_get_uint8(tvb,offset+5);640seconds= tvb_get_uint8(tvb,offset+6);641deci_seconds= tvb_get_uint8(tvb,offset+7);642if(length > 8){643hour_from_utc= tvb_get_uint8(tvb,offset+9);644min_from_utc= tvb_get_uint8(tvb,offset+10);645 646str = wmem_strdup_printf(pinfo->pool,647 "%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u",648 year,649 month,650 day,651 hour,652 minutes,653 seconds,654 deci_seconds,655 tvb_get_string_enc(pinfo->pool,tvb,offset+8,1,ENC_ASCII0x00000000|ENC_NA0x00000000),656 hour_from_utc,657 min_from_utc);658}else{659 str = wmem_strdup_printf(pinfo->pool,660 "%u-%u-%u, %u:%u:%u.%u",661 year,662 month,663 day,664 hour,665 minutes,666 seconds,667 deci_seconds);668}669 670return proto_tree_add_string(tree, hfid, tvb, offset, length, str);671 672}673 674/*675 * dissect_snmp_VarBind676 * this routine dissects variable bindings, looking for the oid information in our oid reporsitory677 * to format and add the value adequatelly.678 *679 * The choice to handwrite this code instead of using the asn compiler is to avoid having tons680 * of uses of global variables distributed in very different parts of the code.681 * Other than that there's a cosmetic thing: the tree from ASN generated code would be so682 * convoluted due to the nesting of CHOICEs in the definition of VarBind/value.683 *684 * XXX: the length of this function (~400 lines) is an aberration!685 * oid_key_t:key_type could become a series of callbacks instead of an enum686 * the (! oid_info_is_ok) switch could be made into an array (would be slower)687 *688 689NetworkAddress ::= CHOICE { internet IpAddress }690IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))691TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)692Integer32 ::= INTEGER (-2147483648..2147483647)693ObjectName ::= OBJECT IDENTIFIER694Counter32 ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295)695Gauge32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)696Unsigned32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)697Integer-value ::= INTEGER (-2147483648..2147483647)698Integer32 ::= INTEGER (-2147483648..2147483647)699ObjectID-value ::= OBJECT IDENTIFIER700Empty ::= NULL701TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)702Opaque ::= [APPLICATION 4] IMPLICIT OCTET STRING703Counter64 ::= [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615)704 705ObjectSyntax ::= CHOICE {706 simple SimpleSyntax,707 application-wide ApplicationSyntax708}709 710SimpleSyntax ::= CHOICE {711 integer-value Integer-value,712 string-value String-value,713 objectID-value ObjectID-value,714 empty Empty715}716 717ApplicationSyntax ::= CHOICE {718 ipAddress-value IpAddress,719 counter-value Counter32,720 timeticks-value TimeTicks,721 arbitrary-value Opaque,722 big-counter-value Counter64,723 unsigned-integer-value Unsigned32724}725 726ValueType ::= CHOICE {727 value ObjectSyntax,728 unSpecified NULL,729 noSuchObject[0] IMPLICIT NULL,730 noSuchInstance[1] IMPLICIT NULL,731 endOfMibView[2] IMPLICIT NULL732}733 734VarBind ::= SEQUENCE {735 name ObjectName,736 valueType ValueType737}738 739 */740 741static int742dissect_snmp_VarBind(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb, int offset,743 asn1_ctx_t *actx, proto_tree *tree, int hf_index _U___attribute__((unused)))744{745int seq_offset, name_offset, value_offset, value_start;746uint32_t seq_len, name_len, value_len;747int8_t ber_class;748bool_Bool pc;749int32_t tag;750bool_Bool ind;751uint32_t* subids;752uint8_t* oid_bytes;753oid_info_t* oid_info = NULL((void*)0);754unsigned oid_matched, oid_left;755proto_item *pi_name, *pi_varbind, *pi_value = NULL((void*)0);756proto_tree *pt, *pt_varbind, *pt_name, *pt_value;757char label[ITEM_LABEL_LENGTH240];758const char* repr = NULL((void*)0);759const char* info_oid = NULL((void*)0);760char* valstr;761int hfid = -1;762int min_len = 0, max_len = 0;763bool_Bool oid_info_is_ok;764const char* oid_string = NULL((void*)0);765enum {BER_NO_ERROR, BER_WRONG_LENGTH, BER_WRONG_TAG} format_error = BER_NO_ERROR;766 767seq_offset = offset;768 769/* first have the VarBind's sequence header */770offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);771offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &seq_len, &ind);772 773if (!pc && ber_class==BER_CLASS_UNI0 && tag==BER_UNI_TAG_SEQUENCE16) {774proto_item* pi;775pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),776ett_decoding_error, &pi, "VarBind must be an universal class sequence");777expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_not_uni_class_seq);778return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);779}780 781if (ind) {782proto_item* pi;783pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),784ett_decoding_error, &pi, "Indicator must be clear in VarBind");785expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_has_indicator);786return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);787}788 789/* we add the varbind tree root with a dummy label we'll fill later on */790pt_varbind = proto_tree_add_subtree(tree,tvb,offset,seq_len,ett_varbind,&pi_varbind,"VarBind");791*label = '\0';792 793seq_len += offset - seq_offset;794 795/* then we have the ObjectName's header */796 797offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);798name_offset = offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &name_len, &ind);799 800if (! ( !pc && ber_class==BER_CLASS_UNI0 && tag==BER_UNI_TAG_OID6) ) {801proto_item* pi;802pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,803ett_decoding_error, &pi, "ObjectName must be an OID in primitive encoding");804expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_not_oid);805return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);806}807 808if (ind) {809proto_item* pi;810pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,811ett_decoding_error, &pi, "Indicator must be clear in ObjectName");812expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_has_indicator);813return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);814}815 816pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,ENC_NA0x00000000);817pt_name = proto_item_add_subtree(pi_name,ett_name);818 819offset += name_len;820value_start = offset;821/* then we have the value's header */822offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);823value_offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &value_len, &ind);824 825if (! (!pc) ) {826proto_item* pi;827pt = proto_tree_add_subtree(pt_varbind, tvb, value_start, value_len,828ett_decoding_error, &pi, "the value must be in primitive encoding");829expert_add_info(actx->pinfo, pi, &ei_snmp_value_not_primitive_encoding);830return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);831}832 833/* Now, we know where everything is */834 835/* fetch ObjectName and its relative oid_info */836oid_bytes = (uint8_t*)tvb_memdup(actx->pinfo->pool, tvb, name_offset, name_len);837oid_info = oid_get_from_encoded(actx->pinfo->pool, oid_bytes, name_len, &subids, &oid_matched, &oid_left);838 839add_oid_debug_subtree(oid_info,pt_name)((void)0);840 841if (!subids) {842proto_item* pi;843 844repr = oid_encoded2string(actx->pinfo->pool, oid_bytes, name_len);845pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr);846expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr);847return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt);848}849 850if (oid_matched+oid_left) {851oid_string = oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left);852}853 854if (ber_class == BER_CLASS_CON2) {855/* if we have an error value just add it and get out the way ASAP */856proto_item* pi;857const char* note;858 859if (value_len != 0) {860min_len = max_len = 0;861format_error = BER_WRONG_LENGTH;862}863 864switch (tag) {865case SERR_NSO0:866hfid = hf_snmp_noSuchObject;867note = "noSuchObject";868break;869case SERR_NSI1:870hfid = hf_snmp_noSuchInstance;871note = "noSuchInstance";872break;873case SERR_EOM2:874hfid = hf_snmp_endOfMibView;875note = "endOfMibView";876break;877default: {878pt = proto_tree_add_subtree_format(pt_varbind,tvb,0,0,ett_decoding_error,&pi,879"Wrong tag for Error Value: expected 0, 1, or 2 but got: %d",tag);880expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_tag);881return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);882}883}884 885pi = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);886expert_add_info_format(actx->pinfo, pi, &ei_snmp_varbind_response, "%s",note);887(void) g_strlcpy (label, note, ITEM_LABEL_LENGTH240);888goto set_label;889}890 891/* 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 */892switch (oid_info->kind) {893case OID_KIND_SCALAR:894if (oid_left == 1) {895/* OK: we got the instance sub-id */896proto_tree_add_uint64(pt_name,hf_snmp_scalar_instance_index,tvb,name_offset,name_len,subids[oid_matched]);897oid_info_is_ok = true1;898goto indexing_done;899} else if (oid_left == 0) {900if (ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {901/* unSpecified does not require an instance sub-id add the new value and get off the way! */902pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);903goto set_label;904} else {905proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_no_instance_subid,tvb,0,0);906oid_info_is_ok = false0;907goto indexing_done;908}909} else {910proto_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);911oid_info_is_ok = false0;912goto indexing_done;913}914break;915case OID_KIND_COLUMN:916if ( oid_info->parent->kind == OID_KIND_ROW) {917oid_key_t* k = oid_info->parent->key;918unsigned key_start = oid_matched;919unsigned key_len = oid_left;920oid_info_is_ok = true1;921 922if ( key_len == 0 && ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {923/* unSpecified does not require an instance sub-id add the new value and get off the way! */924pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);925goto set_label;926}927 928if (k) {929for (;k;k = k->next) {930unsigned suboid_len;931 932if (key_start >= oid_matched+oid_left) {933proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_short,tvb,0,0);934oid_info_is_ok = false0;935goto indexing_done;936}937 938switch(k->key_type) {939case OID_KEY_TYPE_WRONG: {940proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);941oid_info_is_ok = false0;942goto indexing_done;943}944case OID_KEY_TYPE_INTEGER: {945if (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))
) {946proto_tree_add_int(pt_name,k->hfid,tvb,name_offset,name_len,(unsigned)subids[key_start]);947} else { /* if it's not an unsigned int let proto_tree_add_uint throw a warning */948proto_tree_add_uint64(pt_name,k->hfid,tvb,name_offset,name_len,(unsigned)subids[key_start]);949}950key_start++;951key_len--;952continue; /* k->next */953}954case OID_KEY_TYPE_IMPLIED_OID:955suboid_len = key_len;956 957goto show_oid_index;958 959case OID_KEY_TYPE_OID: {960uint8_t* suboid_buf;961unsigned suboid_buf_len;962uint32_t* suboid;963 964suboid_len = subids[key_start++];965key_len--;966 967show_oid_index:968suboid = &(subids[key_start]);969 970if( suboid_len == 0 ) {971proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_len0,tvb,0,0);972oid_info_is_ok = false0;973goto indexing_done;974}975 976if( key_len < suboid_len ) {977proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_long,tvb,0,0);978oid_info_is_ok = false0;979goto indexing_done;980}981 982suboid_buf_len = oid_subid2encoded(actx->pinfo->pool, suboid_len, suboid, &suboid_buf);983 984DISSECTOR_ASSERT(suboid_buf_len)((void) ((suboid_buf_len) ? (void)0 : (proto_report_dissector_bug
("%s:%u: failed assertion \"%s\"", "epan/dissectors/packet-snmp.c"
, 984, "suboid_buf_len"))))
;985 986proto_tree_add_oid(pt_name,k->hfid,tvb,name_offset, suboid_buf_len, suboid_buf);987 988key_start += suboid_len;989key_len -= suboid_len + 1;990continue; /* k->next */991}992default: {993uint8_t* buf;994unsigned buf_len;995uint32_t* suboid;996unsigned i;997 998 999switch (k->key_type) {1000case OID_KEY_TYPE_IPADDR:1001suboid = &(subids[key_start]);1002buf_len = 4;1003break;1004case OID_KEY_TYPE_IMPLIED_STRING:1005case OID_KEY_TYPE_IMPLIED_BYTES:1006case OID_KEY_TYPE_ETHER:1007suboid = &(subids[key_start]);1008buf_len = key_len;1009break;1010default:1011buf_len = k->num_subids;1012suboid = &(subids[key_start]);1013 1014if(!buf_len) {1015buf_len = *suboid++;1016key_len--;1017key_start++;1018}1019break;1020}1021 1022if( key_len < buf_len ) {1023proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_string_too_long,tvb,0,0);1024oid_info_is_ok = false0;1025goto indexing_done;1026}1027 1028buf = (uint8_t*)wmem_alloc(actx->pinfo->pool, buf_len+1);1029for (i = 0; i < buf_len; i++)1030buf[i] = (uint8_t)suboid[i];1031buf[i] = '\0';1032 1033switch(k->key_type) {1034case OID_KEY_TYPE_STRING:1035case OID_KEY_TYPE_IMPLIED_STRING:1036proto_tree_add_string(pt_name,k->hfid,tvb,name_offset,buf_len, buf);1037break;1038case OID_KEY_TYPE_BYTES:1039case OID_KEY_TYPE_NSAP:1040case OID_KEY_TYPE_IMPLIED_BYTES:1041proto_tree_add_bytes(pt_name,k->hfid,tvb,name_offset,buf_len, buf);1042break;1043case OID_KEY_TYPE_ETHER:1044proto_tree_add_ether(pt_name,k->hfid,tvb,name_offset,buf_len, buf);1045break;1046case OID_KEY_TYPE_IPADDR: {1047uint32_t* ipv4_p = (uint32_t*)buf;1048proto_tree_add_ipv4(pt_name,k->hfid,tvb,name_offset,buf_len, *ipv4_p);1049}1050break;1051default:1052DISSECTOR_ASSERT_NOT_REACHED()(proto_report_dissector_bug("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\""
, "epan/dissectors/packet-snmp.c", 1052))
;1053break;1054}1055 1056key_start += buf_len;1057key_len -= buf_len;1058continue; /* k->next*/1059}1060}1061}1062goto indexing_done;1063} else {1064proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);1065oid_info_is_ok = false0;1066goto indexing_done;1067}1068} else {1069proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_column_parent_not_row,tvb,0,0);1070oid_info_is_ok = false0;1071goto indexing_done;1072}1073default: {1074/*proto_tree_add_expert (pt_name,actx->pinfo,PI_MALFORMED, PI_WARN,tvb,0,0,"This kind OID should have no value"); */1075oid_info_is_ok = false0;1076goto indexing_done;1077}1078}1079indexing_done:1080 1081if (oid_info_is_ok && oid_info->value_type) {1082if (ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {1083pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);1084} else {1085/* Provide a tree_item to attach errors to, if needed. */1086pi_value = pi_name;1087 1088if ((oid_info->value_type->ber_class != BER_CLASS_ANY99) &&1089(ber_class != oid_info->value_type->ber_class))1090format_error = BER_WRONG_TAG;1091else if ((oid_info->value_type->ber_tag != BER_TAG_ANY-1) &&1092(tag != oid_info->value_type->ber_tag))1093format_error = BER_WRONG_TAG;1094else {1095max_len = oid_info->value_type->max_len == -1 ? 0xffffff : oid_info->value_type->max_len;1096min_len = oid_info->value_type->min_len;1097 1098if ((int)value_len < min_len || (int)value_len > max_len)1099format_error = BER_WRONG_LENGTH;1100}1101 1102if (format_error == BER_NO_ERROR) {1103/* Special case DATE AND TIME */1104if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){1105pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, oid_info->value_hfid, tvb, value_offset, value_len);1106} else {1107pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);1108}1109}1110}1111} else {1112switch(ber_class|(tag<<4)) {1113case BER_CLASS_UNI0|(BER_UNI_TAG_INTEGER2<<4):1114{1115int64_t val=0;1116unsigned int int_val_offset = value_offset;1117unsigned int i;1118 1119max_len = 4; min_len = 1;1120if (value_len > (unsigned)max_len || value_len < (unsigned)min_len) {1121hfid = hf_snmp_integer32_value;1122format_error = BER_WRONG_LENGTH;1123break;1124}1125 1126if(value_len > 0) {1127/* extend sign bit */1128if(tvb_get_uint8(tvb, int_val_offset)&0x80) {1129val=-1;1130}1131for(i=0;i<value_len;i++) {1132val=(val<<8)|tvb_get_uint8(tvb, int_val_offset);1133int_val_offset++;1134}1135}1136pi_value = proto_tree_add_int64(pt_varbind, hf_snmp_integer32_value, tvb,value_offset,value_len, val);1137 1138goto already_added;1139}1140case BER_CLASS_UNI0|(BER_UNI_TAG_OCTETSTRING4<<4):1141if(oid_info->value_hfid> -1){1142hfid = oid_info->value_hfid;1143}else{1144hfid = hf_snmp_octetstring_value;1145}1146break;1147case BER_CLASS_UNI0|(BER_UNI_TAG_OID6<<4):1148max_len = -1; min_len = 1;1149if (value_len < (unsigned)min_len) format_error = BER_WRONG_LENGTH;1150hfid = hf_snmp_oid_value;1151break;1152case BER_CLASS_UNI0|(BER_UNI_TAG_NULL5<<4):1153max_len = 0; min_len = 0;1154if (value_len != 0) format_error = BER_WRONG_LENGTH;1155hfid = hf_snmp_null_value;1156break;1157case BER_CLASS_APP1: /* | (SNMP_IPA<<4)*/1158switch(value_len) {1159case 4: hfid = hf_snmp_ipv4_value; break;1160case 16: hfid = hf_snmp_ipv6_value; break;1161default: hfid = hf_snmp_anyaddress_value; break;1162}1163break;1164case BER_CLASS_APP1|(SNMP_U327<<4):1165hfid = hf_snmp_unsigned32_value;1166break;1167case BER_CLASS_APP1|(SNMP_GGE2<<4):1168hfid = hf_snmp_gauge32_value;1169break;1170case BER_CLASS_APP1|(SNMP_CNT1<<4):1171hfid = hf_snmp_counter_value;1172break;1173case BER_CLASS_APP1|(SNMP_TIT3<<4):1174hfid = hf_snmp_timeticks_value;1175break;1176case BER_CLASS_APP1|(SNMP_OPQ4<<4):1177hfid = hf_snmp_opaque_value;1178break;1179case BER_CLASS_APP1|(SNMP_NSP5<<4):1180hfid = hf_snmp_nsap_value;1181break;1182case BER_CLASS_APP1|(SNMP_C646<<4):1183hfid = hf_snmp_big_counter_value;1184break;1185default:1186hfid = hf_snmp_unknown_value;1187break;1188}1189if (value_len > 8) {1190/*1191 * Too long for an FT_UINT64 or an FT_INT64.1192 */1193header_field_info *hfinfo = proto_registrar_get_nth(hfid);1194if (hfinfo->type == FT_UINT64) {1195/*1196 * Check if this is an unsigned int64 with1197 * a big value.1198 */1199if (value_len > 9 || tvb_get_uint8(tvb, value_offset) != 0) {1200/* It is. Fail. */1201proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_uint_too_large,tvb,value_offset,value_len,"Integral value too large");1202goto already_added;1203}1204/* Cheat and skip the leading 0 byte */1205value_len--;1206value_offset++;1207} else if (hfinfo->type == FT_INT64) {1208/*1209 * For now, just reject these.1210 */1211proto_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");1212goto already_added;1213}1214} else if (value_len == 0) {1215/*1216 * X.690 section 8.3.1 "Encoding of an integer value":1217 * "The encoding of an integer value shall be1218 * primitive. The contents octets shall consist of1219 * one or more octets."1220 *1221 * Zero is not "one or more".1222 */1223header_field_info *hfinfo = proto_registrar_get_nth(hfid);1224if (hfinfo->type == FT_UINT64 || hfinfo->type == FT_INT64) {1225proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_integral_value0,tvb,value_offset,value_len,"Integral value is zero-length");1226goto already_added;1227}1228}1229/* Special case DATE AND TIME */1230if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){1231pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, hfid, tvb, value_offset, value_len);1232}else{1233pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);1234}1235if (format_error != BER_NO_ERROR) {1236expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib);1237}1238 1239}1240already_added:1241pt_value = proto_item_add_subtree(pi_value,ett_value);1242 1243if (value_len > 0 && oid_string) {1244tvbuff_t* sub_tvb = tvb_new_subset_length(tvb, value_offset, value_len);1245 1246next_tvb_add_string(var_list, sub_tvb, (snmp_var_in_tree) ? pt_value : NULL((void*)0), value_sub_dissectors_table, oid_string);1247}1248 1249 1250set_label:1251if (pi_value) proto_item_fill_label(PITEM_FINFO(pi_value)((pi_value)->finfo), label, NULL((void*)0));1252 1253if (oid_info && oid_info->name) {1254if (oid_left >= 1) {1255repr = wmem_strdup_printf(actx->pinfo->pool, "%s.%s (%s)", oid_info->name,1256oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left),1257oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left));1258info_oid = wmem_strdup_printf(actx->pinfo->pool, "%s.%s", oid_info->name,1259oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left));1260} else {1261repr = wmem_strdup_printf(actx->pinfo->pool, "%s (%s)", oid_info->name,1262oid_subid2string(actx->pinfo->pool, subids,oid_matched));1263info_oid = oid_info->name;1264}1265} else if (oid_string) {1266repr = wmem_strdup(actx->pinfo->pool, oid_string);1267info_oid = oid_string;1268} else {1269repr = wmem_strdup(actx->pinfo->pool, "[Bad OID]");1270}1271 1272valstr = strstr(label,": ");1273valstr = valstr ? valstr+2 : label;1274 1275proto_item_set_text(pi_varbind,"%s: %s",repr,valstr);1276 1277if (display_oid && info_oid) {1278col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", info_oid);1279}1280 1281switch (format_error) {1282case BER_WRONG_LENGTH: {1283proto_item* pi;1284proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);1285pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,1286 "Wrong value length: %u expecting: %u <= len <= %u",1287 value_len, min_len, max_len == -1 ? 0xFFFFFF : max_len);1288expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_length_value);1289return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);1290}1291case BER_WRONG_TAG: {1292proto_item* pi;1293proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);1294pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,1295 "Wrong class/tag for Value expected: %d,%d got: %d,%d",1296 oid_info->value_type->ber_class, oid_info->value_type->ber_tag,1297 ber_class, tag);1298expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_class_tag);1299return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);1300}1301default:1302break;1303}1304 1305return seq_offset + seq_len;1306}1307 1308 1309#define F_SNMP_ENGINEID_CONFORM0x80 0x801310#define SNMP_ENGINEID_RFC19100x00 0x001311#define SNMP_ENGINEID_RFC34110x01 0x011312 1313static const true_false_string tfs_snmp_engineid_conform = {1314"RFC3411 (SNMPv3)",1315"RFC1910 (Non-SNMPv3)"1316};1317 1318#define SNMP_ENGINEID_FORMAT_IPV40x01 0x011319#define SNMP_ENGINEID_FORMAT_IPV60x02 0x021320#define SNMP_ENGINEID_FORMAT_MACADDRESS0x03 0x031321#define SNMP_ENGINEID_FORMAT_TEXT0x04 0x041322#define SNMP_ENGINEID_FORMAT_OCTETS0x05 0x051323#define SNMP_ENGINEID_FORMAT_LOCAL0x06 0x061324 1325static const value_string snmp_engineid_format_vals[] = {1326{ SNMP_ENGINEID_FORMAT_IPV40x01,"IPv4 address" },1327{ SNMP_ENGINEID_FORMAT_IPV60x02,"IPv6 address" },1328{ SNMP_ENGINEID_FORMAT_MACADDRESS0x03,"MAC address" },1329{ SNMP_ENGINEID_FORMAT_TEXT0x04,"Text, administratively assigned" },1330{ SNMP_ENGINEID_FORMAT_OCTETS0x05,"Octets, administratively assigned" },1331{ SNMP_ENGINEID_FORMAT_LOCAL0x06, "Local engine" },1332{ 0,NULL((void*)0) }1333};1334 1335#define SNMP_ENGINEID_CISCO_AGENT0x00 0x001336#define SNMP_ENGINEID_CISCO_MANAGER0x01 0x011337 1338static const value_string snmp_engineid_cisco_type_vals[] = {1339{ SNMP_ENGINEID_CISCO_AGENT0x00,"Agent" },1340{ SNMP_ENGINEID_CISCO_MANAGER0x01,"Manager" },1341{ 0,NULL((void*)0) }1342};1343 1344/*1345 * SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)1346 * or historic RFC 1910 (AgentID)1347 */1348int1349dissect_snmp_engineid(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, int len)1350{1351proto_item *item = NULL((void*)0);1352uint8_t conformance, format;1353uint32_t enterpriseid;1354time_t seconds;1355nstime_t ts;1356int len_remain = len;1357 1358/* first bit: engine id conformance */1359if (len_remain<1) return offset;1360conformance = ((tvb_get_uint8(tvb, offset)>>7) & 0x01);1361proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);1362 1363/* 4-byte enterprise number/name */1364if (len_remain<4) return offset;1365enterpriseid = tvb_get_ntohl(tvb, offset);1366if (conformance)1367enterpriseid -= 0x80000000; /* ignore first bit */1368proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);1369offset+=4;1370len_remain-=4;1371 1372switch(conformance) {1373 1374case SNMP_ENGINEID_RFC19100x00:1375/* 12-byte AgentID w/ 8-byte trailer */1376if (len_remain==8) {1377proto_tree_add_item(tree, hf_snmp_agentid_trailer, tvb, offset, 8, ENC_NA0x00000000);1378offset+=8;1379len_remain-=8;1380} else {1381proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain);1382return offset;1383}1384break;1385 1386case SNMP_ENGINEID_RFC34110x01: /* variable length: 5..32 */1387 1388/* 1-byte format specifier */1389if (len_remain<1) return offset;1390format = tvb_get_uint8(tvb, offset);1391item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)",1392 val_to_str_const(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"),1393 format);1394offset+=1;1395len_remain-=1;1396 1397switch(format) {1398case SNMP_ENGINEID_FORMAT_IPV40x01:1399/* 4-byte IPv4 address */1400if (len_remain==4) {1401proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);1402offset+=4;1403len_remain=0;1404}1405break;1406case SNMP_ENGINEID_FORMAT_IPV60x02:1407/* 16-byte IPv6 address */1408if (len_remain==16) {1409proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA0x00000000);1410offset+=16;1411len_remain=0;1412}1413break;1414case SNMP_ENGINEID_FORMAT_MACADDRESS0x03:1415/* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */1416if ((enterpriseid==9)&&(len_remain==7)) {1417proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);1418offset++;1419len_remain--;1420}1421/* 6-byte MAC address */1422if (len_remain==6) {1423proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_NA0x00000000);1424offset+=6;1425len_remain=0;1426}1427break;1428case SNMP_ENGINEID_FORMAT_TEXT0x04:1429/* max. 27-byte string, administratively assigned */1430if (len_remain<=27) {1431proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII0x00000000);1432offset+=len_remain;1433len_remain=0;1434}1435break;1436case SNMP_ENGINEID_FORMAT_LOCAL0x06:1437break;1438case 128:1439/* most common enterprise-specific format: (ucd|net)-snmp random */1440if ((enterpriseid==2021)||(enterpriseid==8072)) {1441proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");1442/* demystify: 4B random, 4B/8B epoch seconds */1443if ((len_remain==8) || (len_remain==12)) {1444proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA0x00000000);1445if (len_remain==8) {1446seconds = (time_t)tvb_get_letohl(tvb, offset + 4);1447} else {1448seconds = (time_t)tvb_get_letohi64(tvb, offset + 4);1449}1450ts.secs = seconds;1451ts.nsecs = 0;1452proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset + 4, len_remain - 4,1453 &ts, "%s",1454 abs_time_secs_to_str(pinfo->pool, seconds, ABSOLUTE_TIME_LOCAL, true)abs_time_secs_to_str_ex(pinfo->pool, seconds, ABSOLUTE_TIME_LOCAL
, (1) ? (1U << 0) : 0)
);1455offset+=len_remain;1456len_remain=0;1457}1458break;1459}1460/* fall through */1461case SNMP_ENGINEID_FORMAT_OCTETS0x05:1462default:1463/* max. 27 bytes, administratively assigned or unknown format */1464if (len_remain>0 && len_remain<=27) {1465proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA0x00000000);1466offset+=len_remain;1467len_remain=0;1468}1469break;1470}1471}1472 1473if (len_remain>0) {1474proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain);1475offset+=len_remain;1476}1477return offset;1478}1479 1480 1481static void set_ue_keys(snmp_ue_assoc_t* n ) {1482unsigned const key_size = auth_hash_len[n->user.authModel];1483 1484n->user.authKey.data = (uint8_t *)g_malloc(key_size);1485n->user.authKey.len = key_size;1486snmp_usm_password_to_key(n->user.authModel,1487 n->user.authPassword.data,1488 n->user.authPassword.len,1489 n->engine.data,1490 n->engine.len,1491 n->user.authKey.data);1492 1493if (n->priv_proto == PRIV_AES1281 || n->priv_proto == PRIV_AES1922 || n->priv_proto == PRIV_AES2563) {

17

Assuming field 'priv_proto' is not equal to PRIV_AES128

18

Assuming field 'priv_proto' is not equal to PRIV_AES192

19

Assuming field 'priv_proto' is equal to PRIV_AES256

1494unsigned need_key_len =1495(n->priv_proto

19.1

Field 'priv_proto' is not equal to PRIV_AES128
== PRIV_AES1281) ? 16 :1496(n->priv_proto

19.2

Field 'priv_proto' is not equal to PRIV_AES192
== PRIV_AES1922) ? 24 :1497(n->priv_proto

19.3

Field 'priv_proto' is equal to PRIV_AES256
== PRIV_AES2563) ? 32 :

20

'?' condition is true

14980;1499 1500unsigned key_len = key_size;1501 1502while (key_len < need_key_len)

21

Assuming 'key_len' is < 'need_key_len'

22

Loop condition is true. Entering loop body

23

Assuming 'key_len' is >= 'need_key_len'

24

Loop condition is false. Execution continues on line 1505

1503key_len += key_size;1504 1505n->user.privKey.data = (uint8_t *)g_malloc(key_len);1506n->user.privKey.len = need_key_len;1507 1508snmp_usm_password_to_key(n->user.authModel,

26

Calling 'snmp_usm_password_to_key'

30

Returning from 'snmp_usm_password_to_key'

1509 n->user.privPassword.data,1510 n->user.privPassword.len,1511 n->engine.data,1512 n->engine.len,1513 n->user.privKey.data);1514 1515key_len = key_size;1516 1517/* extend key if needed */1518while (key_len

30.1

'key_len' is < 'need_key_len'
< need_key_len) {

31

Loop condition is true. Entering loop body

1519switch (n->priv_key_exp) {

32

Control jumps to 'case 0:' at line 1521

1520/* Baed on draft-reeder-snmpv3-usm-3desede-00, section 2.1 */1521case PRIVKEYEXP_USM_3DESDESEDE_000:1522{1523snmp_usm_password_to_key(n->user.authModel,

33

Calling 'snmp_usm_password_to_key'

1524n->user.privKey.data + (key_len - key_size),1525key_size,1526n->engine.data,1527n->engine.len,1528n->user.privKey.data + key_len);1529break;1530}1531/* Based on snmp++ method PrivAES::extend_short_key in Agent++ */1532case PRIVKEYEXP_AGENTPP1:1533{1534/* Key expansion in Agent++1535 * K1 = key1536 * K2 = hash(K1)1537 * K3 = hash(K1 | K2)1538 * localized_key = K1 | K2 | K31539 */1540gcry_md_hd_t hash_handle;1541 1542if (gcry_md_open(&hash_handle, auth_hash_algo[n->user.authModel], 0)) {1543return;1544}1545 1546gcry_md_write(hash_handle, n->user.privKey.data, key_len);1547memcpy(n->user.privKey.data + key_len, gcry_md_read(hash_handle, 0), key_size);1548gcry_md_close(hash_handle);1549 1550break;1551}1552 1553default:1554break;1555}1556 1557key_len += key_size;1558}1559 1560} else {1561n->user.privKey.data = (uint8_t *)g_malloc(key_size);1562n->user.privKey.len = key_size;1563snmp_usm_password_to_key(n->user.authModel,1564 n->user.privPassword.data,1565 n->user.privPassword.len,1566 n->engine.data,1567 n->engine.len,1568 n->user.privKey.data);1569}1570}1571 1572static snmp_ue_assoc_t*1573ue_dup(snmp_ue_assoc_t* o)1574{1575snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));1576 1577d->user.authModel = o->user.authModel;1578 1579d->user.privProtocol = o->user.privProtocol;1580 1581d->user.userName.data = (uint8_t *)g_memdup2(o->user.userName.data,o->user.userName.len);1582d->user.userName.len = o->user.userName.len;1583 1584d->user.authPassword.data = o->user.authPassword.data ? (uint8_t *)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL((void*)0);1585d->user.authPassword.len = o->user.authPassword.len;1586 1587d->user.privPassword.data = o->user.privPassword.data ? (uint8_t *)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL((void*)0);1588d->user.privPassword.len = o->user.privPassword.len;1589 1590d->engine.len = o->engine.len;1591 1592if (d->engine.len) {1593d->engine.data = (uint8_t *)g_memdup2(o->engine.data,o->engine.len);1594set_ue_keys(d);1595}1596 1597return d;1598 1599}1600 1601static void*1602snmp_users_copy_cb(void* dest, const void* orig, size_t len _U___attribute__((unused)))1603{1604const snmp_ue_assoc_t* o = (const snmp_ue_assoc_t*)orig;1605snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)dest;1606 1607d->auth_model = o->auth_model;1608d->user.authModel = (snmp_usm_auth_model_t) o->auth_model;1609 1610d->priv_proto = o->priv_proto;1611d->user.privProtocol = priv_protos[o->priv_proto];1612 1613d->user.userName.data = (uint8_t*)g_memdup2(o->user.userName.data,o->user.userName.len);1614d->user.userName.len = o->user.userName.len;1615 1616d->user.authPassword.data = o->user.authPassword.data ? (uint8_t*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL((void*)0);1617d->user.authPassword.len = o->user.authPassword.len;1618 1619d->user.privPassword.data = o->user.privPassword.data ? (uint8_t*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL((void*)0);1620d->user.privPassword.len = o->user.privPassword.len;1621 1622d->engine.len = o->engine.len;1623if (o->engine.data) {1624d->engine.data = (uint8_t*)g_memdup2(o->engine.data,o->engine.len);1625}1626 1627d->user.authKey.data = o->user.authKey.data ? (uint8_t*)g_memdup2(o->user.authKey.data,o->user.authKey.len) : NULL((void*)0);1628d->user.authKey.len = o->user.authKey.len;1629 1630d->user.privKey.data = o->user.privKey.data ? (uint8_t*)g_memdup2(o->user.privKey.data,o->user.privKey.len) : NULL((void*)0);1631d->user.privKey.len = o->user.privKey.len;1632 1633return d;1634}1635 1636static void1637snmp_users_free_cb(void* p)1638{1639snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;1640g_free(ue->user.userName.data);1641g_free(ue->user.authPassword.data);1642g_free(ue->user.privPassword.data);1643g_free(ue->user.authKey.data);1644g_free(ue->user.privKey.data);1645g_free(ue->engine.data);1646}1647 1648static bool_Bool1649snmp_users_update_cb(void* p _U___attribute__((unused)), char** err)1650{1651snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;1652GString* es = g_string_new("");1653unsigned int i;1654 1655*err = NULL((void*)0);1656 1657if (! ue->user.userName.len) {1658g_string_append_printf(es,"no userName\n");1659} else if ((ue->engine.len > 0) && (ue->engine.len < 5 || ue->engine.len > 32)) {1660/* RFC 3411 section 5 */1661g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", ue->engine.len);1662} else if (num_ueas) {1663for (i=0; i<num_ueas-1; i++) {1664snmp_ue_assoc_t* u = &(ueas[i]);1665 1666if ( u->user.userName.len == ue->user.userName.len1667&& u->engine.len == ue->engine.len && (u != ue)) {1668 1669if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {1670if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {1671/* XXX: make a string for the engineId */1672g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);1673break;1674}1675}1676 1677if (u->engine.len == 0) {1678if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {1679g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);1680break;1681}1682}1683}1684}1685}1686 1687if (es->len) {1688es = g_string_truncate(es,es->len-1)g_string_truncate_inline (es, es->len-1);1689*err = g_string_free(es, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((es),
((0))) : g_string_free_and_steal (es)) : (g_string_free) ((es
), ((0))))
;1690return false0;1691}1692 1693 g_string_free(es, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(es), ((!(0)))) : g_string_free_and_steal (es)) : (g_string_free
) ((es), ((!(0)))))
;1694return true1;1695}1696 1697static void1698free_ue_cache(snmp_ue_assoc_t **cache)1699{1700static snmp_ue_assoc_t *a, *nxt;1701 1702for (a = *cache; a; a = nxt) {1703nxt = a->next;1704snmp_users_free_cb(a);1705g_free(a);1706}1707 1708*cache = NULL((void*)0);1709}1710 1711#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); }
1712 1713static void1714init_ue_cache(void)1715{1716unsigned i;1717 1718for (i = 0; i < num_ueas; i++) {1719snmp_ue_assoc_t* a = ue_dup(&(ueas[i]));1720 1721if (a->engine.len) {1722CACHE_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); }
;1723 1724} else {1725CACHE_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); }
;1726}1727 1728}1729}1730 1731static void1732cleanup_ue_cache(void)1733{1734free_ue_cache(&localized_ues);1735free_ue_cache(&unlocalized_ues);1736}1737 1738/* Called when the user applies changes to UAT preferences. */1739static void1740renew_ue_cache(void)1741{1742cleanup_ue_cache();1743init_ue_cache();1744}1745 1746 1747static snmp_ue_assoc_t*1748localize_ue( snmp_ue_assoc_t* o, const uint8_t* engine, unsigned engine_len )1749{1750snmp_ue_assoc_t* n = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));1751 1752n->user.userName.data = (uint8_t*)g_memdup2(o->user.userName.data,o->user.userName.len);1753n->user.authModel = o->user.authModel;1754n->user.authPassword.data = (uint8_t*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len);1755n->user.authPassword.len = o->user.authPassword.len;1756n->user.privPassword.data = (uint8_t*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len);1757n->user.privPassword.len = o->user.privPassword.len;1758n->user.authKey.data = (uint8_t*)g_memdup2(o->user.authKey.data,o->user.authKey.len);1759n->user.privKey.data = (uint8_t*)g_memdup2(o->user.privKey.data,o->user.privKey.len);1760n->engine.data = (uint8_t*)g_memdup2(engine,engine_len);1761n->engine.len = engine_len;1762n->priv_proto = o->priv_proto;1763 1764set_ue_keys(n);

16

Calling 'set_ue_keys'

1765 1766return n;1767}1768 1769 1770#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 )
\
1771( a->user.userName.len == ul \1772&& a->engine.len == el \1773&& memcmp( a->user.userName.data, u, ul ) == 0 \1774&& memcmp( a->engine.data, e, el ) == 0 )1775 1776#define unlocalized_match(a,u,l)( a->user.userName.len == l && memcmp( a->user.
userName.data, u, l) == 0 )
\
1777( a->user.userName.len == l && memcmp( a->user.userName.data, u, l) == 0 )1778 1779static snmp_ue_assoc_t*1780get_user_assoc(tvbuff_t* engine_tvb, tvbuff_t* user_tvb, packet_info *pinfo)1781{1782static snmp_ue_assoc_t* a;1783unsigned given_username_len;1784uint8_t* given_username;1785unsigned given_engine_len = 0;1786uint8_t* given_engine = NULL((void*)0);1787 1788if ( ! (localized_ues || unlocalized_ues ) ) return NULL((void*)0);

3

Assuming 'localized_ues' is non-null

1789 1790if (! ( user_tvb && engine_tvb ) ) return NULL((void*)0);

4

Assuming 'user_tvb' is non-null

5

Assuming the condition is false

6

Taking false branch

1791 1792given_username_len = tvb_captured_length(user_tvb);1793given_engine_len = tvb_captured_length(engine_tvb);1794if (! ( given_engine_len && given_username_len ) ) return NULL((void*)0);

7

Assuming 'given_engine_len' is not equal to 0

8

Assuming the condition is false

9

Taking false branch

1795given_username = (uint8_t*)tvb_memdup(pinfo->pool,user_tvb,0,-1);1796given_engine = (uint8_t*)tvb_memdup(pinfo->pool,engine_tvb,0,-1);1797 1798for (a = localized_ues; a; a = a->next) {

10

Loop condition is false. Execution continues on line 1804

1799if ( 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 )
) {1800return a;1801}1802}1803 1804for (a = unlocalized_ues; a; a = a->next) {1805if ( 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 )
) {

11

Loop condition is true. Entering loop body

12

Assuming 'given_username_len' is equal to field 'len'

13

Assuming the condition is true

14

Taking true branch

1806snmp_ue_assoc_t* n = localize_ue( a, given_engine, given_engine_len );

15

Calling 'localize_ue'

1807CACHE_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); }
;1808return n;1809}1810}1811 1812return NULL((void*)0);1813}1814 1815static bool_Bool1816snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, uint8_t** calc_auth_p,1817unsigned* calc_auth_len_p, char const** error)1818{1819int msg_len;1820uint8_t* msg;1821unsigned auth_len;1822uint8_t* auth;1823uint8_t* key;1824unsigned key_len;1825uint8_t *calc_auth;1826unsigned start;1827unsigned end;1828unsigned i;1829 1830if (!p->auth_tvb) {1831*error = "No Authenticator";1832return false0;1833}1834 1835key = p->user_assoc->user.authKey.data;1836key_len = p->user_assoc->user.authKey.len;1837 1838if (! key ) {1839*error = "User has no authKey";1840return false0;1841}1842 1843auth_len = tvb_captured_length(p->auth_tvb);1844 1845if (auth_len != auth_tag_len[model]) {1846*error = "Authenticator length wrong";1847return false0;1848}1849 1850msg_len = tvb_captured_length(p->msg_tvb);1851if (msg_len <= 0) {1852*error = "Not enough data remaining";1853return false0;1854}1855msg = (uint8_t*)tvb_memdup(pinfo->pool,p->msg_tvb,0,msg_len);1856 1857auth = (uint8_t*)tvb_memdup(pinfo->pool,p->auth_tvb,0,auth_len);1858 1859start = p->auth_offset - p->start_offset;1860end = start + auth_len;1861 1862/* fill the authenticator with zeros */1863for ( i = start ; i < end ; i++ ) {1864msg[i] = '\0';1865}1866 1867calc_auth = (uint8_t*)wmem_alloc(pinfo->pool, auth_hash_len[model]);1868 1869if (ws_hmac_buffer(auth_hash_algo[model], calc_auth, msg, msg_len, key, key_len)) {1870return false0;1871}1872 1873if (calc_auth_p) *calc_auth_p = calc_auth;1874if (calc_auth_len_p) *calc_auth_len_p = auth_len;1875 1876return ( memcmp(auth,calc_auth,auth_len) != 0 ) ? false0 : true1;1877}1878 1879static tvbuff_t*1880snmp_usm_priv_des(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)1881{1882gcry_error_t err;1883gcry_cipher_hd_t hd = NULL((void*)0);1884 1885uint8_t* cleartext;1886uint8_t* des_key = p->user_assoc->user.privKey.data; /* first 8 bytes */1887uint8_t* pre_iv = &(p->user_assoc->user.privKey.data[8]); /* last 8 bytes */1888uint8_t* salt;1889int salt_len;1890int cryptgrm_len;1891uint8_t* cryptgrm;1892tvbuff_t* clear_tvb;1893uint8_t iv[8];1894unsigned i;1895 1896 1897salt_len = tvb_captured_length(p->priv_tvb);1898 1899if (salt_len != 8) {1900*error = "decryptionError: msgPrivacyParameters length != 8";1901return NULL((void*)0);1902}1903 1904salt = (uint8_t*)tvb_memdup(pinfo->pool,p->priv_tvb,0,salt_len);1905 1906/*1907 The resulting "salt" is XOR-ed with the pre-IV to obtain the IV.1908 */1909for (i=0; i<8; i++) {1910iv[i] = pre_iv[i] ^ salt[i];1911}1912 1913cryptgrm_len = tvb_captured_length(encryptedData);1914 1915if ((cryptgrm_len <= 0) || (cryptgrm_len % 8)) {1916*error = "decryptionError: the length of the encrypted data is not a multiple of 8 octets";1917return NULL((void*)0);1918}1919 1920cryptgrm = (uint8_t*)tvb_memdup(pinfo->pool,encryptedData,0,-1);1921 1922cleartext = (uint8_t*)wmem_alloc(pinfo->pool, cryptgrm_len);1923 1924err = gcry_cipher_open(&hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_CBC, 0);1925if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1926 1927err = gcry_cipher_setiv(hd, iv, 8);1928if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1929 1930err = gcry_cipher_setkey(hd,des_key,8);1931if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1932 1933err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);1934if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1935 1936gcry_cipher_close(hd);1937 1938clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);1939 1940return clear_tvb;1941 1942on_gcry_error:1943*error = (const char *)gcry_strerror(err);1944if (hd) gcry_cipher_close(hd);1945return NULL((void*)0);1946}1947 1948static tvbuff_t*1949snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error, int algo)1950{1951gcry_error_t err;1952gcry_cipher_hd_t hd = NULL((void*)0);1953 1954uint8_t* cleartext;1955uint8_t* aes_key = p->user_assoc->user.privKey.data;1956int aes_key_len = p->user_assoc->user.privKey.len;1957uint8_t iv[16];1958int priv_len;1959int cryptgrm_len;1960uint8_t* cryptgrm;1961tvbuff_t* clear_tvb;1962 1963priv_len = tvb_captured_length(p->priv_tvb);1964 1965if (priv_len != 8) {1966*error = "decryptionError: msgPrivacyParameters length != 8";1967return NULL((void*)0);1968}1969 1970iv[0] = (p->boots & 0xff000000) >> 24;1971iv[1] = (p->boots & 0x00ff0000) >> 16;1972iv[2] = (p->boots & 0x0000ff00) >> 8;1973iv[3] = (p->boots & 0x000000ff);1974iv[4] = (p->snmp_time & 0xff000000) >> 24;1975iv[5] = (p->snmp_time & 0x00ff0000) >> 16;1976iv[6] = (p->snmp_time & 0x0000ff00) >> 8;1977iv[7] = (p->snmp_time & 0x000000ff);1978tvb_memcpy(p->priv_tvb,&(iv[8]),0,8);1979 1980cryptgrm_len = tvb_captured_length(encryptedData);1981if (cryptgrm_len <= 0) {1982*error = "Not enough data remaining";1983return NULL((void*)0);1984}1985cryptgrm = (uint8_t*)tvb_memdup(pinfo->pool,encryptedData,0,-1);1986 1987cleartext = (uint8_t*)wmem_alloc(pinfo->pool, cryptgrm_len);1988 1989err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);1990if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1991 1992err = gcry_cipher_setiv(hd, iv, 16);1993if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1994 1995err = gcry_cipher_setkey(hd,aes_key,aes_key_len);1996if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;1997 1998err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);1999if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;2000 2001gcry_cipher_close(hd);2002 2003clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);2004 2005return clear_tvb;2006 2007on_gcry_error:2008*error = (const char *)gcry_strerror(err);2009if (hd) gcry_cipher_close(hd);2010return NULL((void*)0);2011}2012 2013static tvbuff_t*2014snmp_usm_priv_aes128(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)2015{2016return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES);2017}2018 2019static tvbuff_t*2020snmp_usm_priv_aes192(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)2021{2022return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES192);2023}2024 2025static tvbuff_t*2026snmp_usm_priv_aes256(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)2027{2028return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES256);2029}2030 2031static bool_Bool2032check_ScopedPdu(tvbuff_t* tvb)2033{2034int offset;2035int8_t ber_class;2036bool_Bool pc;2037int32_t tag;2038int hoffset, eoffset;2039uint32_t len;2040 2041offset = get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);2042offset = get_ber_length(tvb, offset, NULL((void*)0), NULL((void*)0));2043 2044if ( ! (((ber_class!=BER_CLASS_APP1) && (ber_class!=BER_CLASS_PRI3) )2045&& ( (!pc) || (ber_class!=BER_CLASS_UNI0) || (tag!=BER_UNI_TAG_ENUMERATED10) )2046)) return false0;2047 2048if((tvb_get_uint8(tvb, offset)==0)&&(tvb_get_uint8(tvb, offset+1)==0))2049return true1;2050 2051hoffset = offset;2052 2053offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);2054offset = get_ber_length(tvb, offset, &len, NULL((void*)0));2055eoffset = offset + len;2056 2057if (eoffset <= hoffset) return false0;2058 2059if ((ber_class!=BER_CLASS_APP1)&&(ber_class!=BER_CLASS_PRI3))2060if( (ber_class!=BER_CLASS_UNI0)2061||((tag<BER_UNI_TAG_NumericString18)&&(tag!=BER_UNI_TAG_OCTETSTRING4)&&(tag!=BER_UNI_TAG_UTF8String12)) )2062return false0;2063 2064return true1;2065 2066}2067 2068 2069 2070 2071static int2072dissect_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))) {2073const char* name;2074 2075 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &enterprise_oid);2076 2077 2078if (display_oid && enterprise_oid) {2079name = oid_resolved_from_string(actx->pinfo->pool, enterprise_oid);2080if (name) {2081col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", name);2082}2083}2084 2085 2086 return offset;2087}2088 2089 2090 2091static int2092dissect_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))) {2093 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2094 NULL((void*)0));2095 2096 return offset;2097}2098 2099 2100 2101static int2102dissect_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))) {2103 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2104 hf_index, BER_CLASS_APP1, 0, true1, dissect_snmp_OCTET_STRING_SIZE_4);2105 2106 return offset;2107}2108 2109 2110 2111static int2112dissect_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))) {2113 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2114 NULL((void*)0));2115 2116 return offset;2117}2118 2119 2120 2121static int2122dissect_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))) {2123 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2124 hf_index, BER_CLASS_APP1, 3, true1, dissect_snmp_INTEGER_0_4294967295);2125 2126 return offset;2127}2128 2129 2130 2131static int2132dissect_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))) {2133 2134 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2135 &RequestID);2136 2137 2138 2139 return offset;2140}2141 2142 2143 2144static int2145dissect_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))) {2146 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL((void*)0));2147 2148 return offset;2149}2150 2151 2152static const value_string snmp_Version_vals[] = {2153 { 0, "version-1" },2154 { 1, "v2c" },2155 { 2, "v2u" },2156 { 3, "snmpv3" },2157 { 0, NULL((void*)0) }2158};2159 2160 2161static int2162dissect_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))) {2163 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2164 &snmp_version);2165 2166 return offset;2167}2168 2169 2170 2171static int2172dissect_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))) {2173 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2174 NULL((void*)0));2175 2176 return offset;2177}2178 2179 2180 2181static int2182dissect_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))) {2183 2184 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2185 &RequestID);2186 2187 2188 2189 return offset;2190}2191 2192 2193static const value_string snmp_T_error_status_vals[] = {2194 { 0, "noError" },2195 { 1, "tooBig" },2196 { 2, "noSuchName" },2197 { 3, "badValue" },2198 { 4, "readOnly" },2199 { 5, "genErr" },2200 { 6, "noAccess" },2201 { 7, "wrongType" },2202 { 8, "wrongLength" },2203 { 9, "wrongEncoding" },2204 { 10, "wrongValue" },2205 { 11, "noCreation" },2206 { 12, "inconsistentValue" },2207 { 13, "resourceUnavailable" },2208 { 14, "commitFailed" },2209 { 15, "undoFailed" },2210 { 16, "authorizationError" },2211 { 17, "notWritable" },2212 { 18, "inconsistentName" },2213 { 0, NULL((void*)0) }2214};2215 2216 2217static int2218dissect_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))) {2219 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2220 NULL((void*)0));2221 2222 return offset;2223}2224 2225 2226 2227static int2228dissect_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))) {2229 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2230 NULL((void*)0));2231 2232 return offset;2233}2234 2235 2236 2237static const ber_sequence_t VarBindList_sequence_of[1] = {2238 { &hf_snmp_VarBindList_item, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBind },2239};2240 2241static int2242dissect_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))) {2243 offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,2244 VarBindList_sequence_of, hf_index, ett_snmp_VarBindList);2245 2246 return offset;2247}2248 2249 2250static const ber_sequence_t PDU_sequence[] = {2251 { &hf_snmp_request_id , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_request_id },2252 { &hf_snmp_error_status , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_error_status },2253 { &hf_snmp_error_index , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER },2254 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },2255 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2256};2257 2258static int2259dissect_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))) {2260 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2261 PDU_sequence, hf_index, ett_snmp_PDU);2262 2263 return offset;2264}2265 2266 2267 2268static int2269dissect_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))) {2270 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2271 hf_index, BER_CLASS_CON2, 0, true1, dissect_snmp_PDU);2272 2273 return offset;2274}2275 2276 2277 2278static int2279dissect_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))) {2280 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2281 hf_index, BER_CLASS_CON2, 1, true1, dissect_snmp_PDU);2282 2283 return offset;2284}2285 2286 2287 2288static int2289dissect_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))) {2290 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2291 hf_index, BER_CLASS_CON2, 2, true1, dissect_snmp_PDU);2292 2293 return offset;2294}2295 2296 2297 2298static int2299dissect_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))) {2300 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2301 hf_index, BER_CLASS_CON2, 3, true1, dissect_snmp_PDU);2302 2303 return offset;2304}2305 2306 2307static const value_string snmp_GenericTrap_vals[] = {2308 { 0, "coldStart" },2309 { 1, "warmStart" },2310 { 2, "linkDown" },2311 { 3, "linkUp" },2312 { 4, "authenticationFailure" },2313 { 5, "egpNeighborLoss" },2314 { 6, "enterpriseSpecific" },2315 { 0, NULL((void*)0) }2316};2317 2318 2319static int2320dissect_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))) {2321 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2322 &generic_trap);2323 2324 return offset;2325}2326 2327 2328 2329static int2330dissect_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))) {2331 unsigned specific_trap;2332 2333 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2334 &specific_trap);2335 2336 2337if (generic_trap == 6) { /* enterprise specific */2338const char *specific_str = snmp_lookup_specific_trap (specific_trap);2339if (specific_str) {2340proto_item_append_text(actx->created_item, " (%s)", specific_str);2341}2342}2343 2344 return offset;2345}2346 2347 2348static const ber_sequence_t Trap_PDU_U_sequence[] = {2349 { &hf_snmp_enterprise , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_EnterpriseOID },2350 { &hf_snmp_agent_addr , BER_CLASS_APP1, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_NetworkAddress },2351 { &hf_snmp_generic_trap , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GenericTrap },2352 { &hf_snmp_specific_trap , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SpecificTrap },2353 { &hf_snmp_time_stamp , BER_CLASS_APP1, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_TimeTicks },2354 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },2355 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2356};2357 2358static int2359dissect_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))) {2360generic_trap = 0;2361enterprise_oid = NULL((void*)0);2362 2363 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2364 Trap_PDU_U_sequence, hf_index, ett_snmp_Trap_PDU_U);2365 2366 2367 if (snmp_version != 0) {2368 expert_add_info(actx->pinfo, tree, &ei_snmp_trap_pdu_obsolete);2369 }2370 2371 2372 return offset;2373}2374 2375 2376 2377static int2378dissect_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))) {2379 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2380 hf_index, BER_CLASS_CON2, 4, true1, dissect_snmp_Trap_PDU_U);2381 2382 return offset;2383}2384 2385 2386 2387static int2388dissect_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))) {2389 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2390 NULL((void*)0));2391 2392 return offset;2393}2394 2395 2396static const ber_sequence_t BulkPDU_sequence[] = {2397 { &hf_snmp_bulkPDU_request_id, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Integer32 },2398 { &hf_snmp_non_repeaters , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },2399 { &hf_snmp_max_repetitions, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },2400 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },2401 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2402};2403 2404static int2405dissect_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))) {2406 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2407 BulkPDU_sequence, hf_index, ett_snmp_BulkPDU);2408 2409 return offset;2410}2411 2412 2413 2414static int2415dissect_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))) {2416 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2417 hf_index, BER_CLASS_CON2, 5, true1, dissect_snmp_BulkPDU);2418 2419 return offset;2420}2421 2422 2423 2424static int2425dissect_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))) {2426 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2427 hf_index, BER_CLASS_CON2, 6, true1, dissect_snmp_PDU);2428 2429 return offset;2430}2431 2432 2433 2434static int2435dissect_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))) {2436 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2437 hf_index, BER_CLASS_CON2, 7, true1, dissect_snmp_PDU);2438 2439 return offset;2440}2441 2442 2443 2444static int2445dissect_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))) {2446 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2447 hf_index, BER_CLASS_CON2, 8, true1, dissect_snmp_PDU);2448 2449 return offset;2450}2451 2452 2453static const value_string snmp_PDUs_vals[] = {2454 { 0, "get-request" },2455 { 1, "get-next-request" },2456 { 2, "get-response" },2457 { 3, "set-request" },2458 { 4, "trap" },2459 { 5, "getBulkRequest" },2460 { 6, "informRequest" },2461 { 7, "snmpV2-trap" },2462 { 8, "report" },2463 { 0, NULL((void*)0) }2464};2465 2466static const ber_choice_t PDUs_choice[] = {2467 { 0, &hf_snmp_get_request , BER_CLASS_CON2, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetRequest_PDU },2468 { 1, &hf_snmp_get_next_request, BER_CLASS_CON2, 1, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetNextRequest_PDU },2469 { 2, &hf_snmp_get_response , BER_CLASS_CON2, 2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetResponse_PDU },2470 { 3, &hf_snmp_set_request , BER_CLASS_CON2, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SetRequest_PDU },2471 { 4, &hf_snmp_trap , BER_CLASS_CON2, 4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Trap_PDU },2472 { 5, &hf_snmp_getBulkRequest , BER_CLASS_CON2, 5, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetBulkRequest_PDU },2473 { 6, &hf_snmp_informRequest , BER_CLASS_CON2, 6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_InformRequest_PDU },2474 { 7, &hf_snmp_snmpV2_trap , BER_CLASS_CON2, 7, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SNMPv2_Trap_PDU },2475 { 8, &hf_snmp_report , BER_CLASS_CON2, 8, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Report_PDU },2476 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2477};2478 2479static int2480dissect_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))) {2481int pdu_type=-1;2482 2483snmp_request_response_t *srrp;2484snmp_conv_info_t *snmp_info = (snmp_conv_info_t *)actx->private_data;2485 2486col_clear(actx->pinfo->cinfo, COL_INFO);2487 2488 offset = dissect_ber_choice(actx, tree, tvb, offset,2489 PDUs_choice, hf_index, ett_snmp_PDUs,2490 &pdu_type);2491 2492if( (pdu_type!=-1) && snmp_PDUs_vals[pdu_type].strptr ){2493col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%s", snmp_PDUs_vals[pdu_type].strptr);2494 2495/* pdu_type is the index, not the tag so convert it to the tag value */2496pdu_type = snmp_PDUs_vals[pdu_type].value;2497 2498srrp=snmp_match_request_response(tvb, actx->pinfo, tree, RequestID, pdu_type, snmp_info);2499if (srrp) {2500tap_queue_packet(snmp_tap, actx->pinfo, srrp);2501}2502}2503 2504 2505 2506 return offset;2507}2508 2509 2510static const ber_sequence_t Message_sequence[] = {2511 { &hf_snmp_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },2512 { &hf_snmp_community , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Community },2513 { &hf_snmp_data , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_PDUs },2514 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2515};2516 2517static int2518dissect_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))) {2519 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2520 Message_sequence, hf_index, ett_snmp_Message);2521 2522 return offset;2523}2524 2525 2526 2527static int2528dissect_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))) {2529 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2530 NULL((void*)0));2531 2532 return offset;2533}2534 2535 2536static const value_string snmp_T_datav2u_vals[] = {2537 { 0, "plaintext" },2538 { 1, "encrypted" },2539 { 0, NULL((void*)0) }2540};2541 2542static const ber_choice_t T_datav2u_choice[] = {2543 { 0, &hf_snmp_v2u_plaintext , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_PDUs },2544 { 1, &hf_snmp_encrypted , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2545 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2546};2547 2548static int2549dissect_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))) {2550 offset = dissect_ber_choice(actx, tree, tvb, offset,2551 T_datav2u_choice, hf_index, ett_snmp_T_datav2u,2552 NULL((void*)0));2553 2554 return offset;2555}2556 2557 2558static const ber_sequence_t Messagev2u_sequence[] = {2559 { &hf_snmp_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },2560 { &hf_snmp_parameters , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2561 { &hf_snmp_datav2u , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_T_datav2u },2562 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2563};2564 2565static int2566dissect_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))) {2567 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2568 Messagev2u_sequence, hf_index, ett_snmp_Messagev2u);2569 2570 return offset;2571}2572 2573 2574 2575static int2576dissect_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))) {2577tvbuff_t* param_tvb = NULL((void*)0);2578 2579offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &param_tvb);2580 if (param_tvb) {2581proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);2582dissect_snmp_engineid(engine_tree, actx->pinfo, param_tvb, 0, tvb_reported_length_remaining(param_tvb,0));2583}2584 2585 2586 return offset;2587}2588 2589 2590 2591static int2592dissect_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))) {2593 2594offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &usm_p.engine_tvb);2595 if (usm_p.engine_tvb) {2596proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);2597dissect_snmp_engineid(engine_tree, actx->pinfo, usm_p.engine_tvb, 0, tvb_reported_length_remaining(usm_p.engine_tvb,0));2598}2599 2600 2601 return offset;2602}2603 2604 2605 2606static int2607dissect_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))) {2608 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2609 &usm_p.boots);2610 2611 return offset;2612}2613 2614 2615 2616static int2617dissect_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))) {2618 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2619 &usm_p.snmp_time);2620 2621 return offset;2622}2623 2624 2625 2626static int2627dissect_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))) {2628 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2629 &usm_p.user_tvb);2630 2631 return offset;2632}2633 2634 2635 2636static int2637dissect_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))) {2638offset = dissect_ber_octet_string(false0, actx, tree, tvb, offset, hf_index, &usm_p.auth_tvb);2639if (usm_p.auth_tvb) {2640usm_p.auth_item = actx->created_item;2641usm_p.auth_offset = tvb_offset_from_real_beginning(usm_p.auth_tvb);2642}2643 2644 return offset;2645}2646 2647 2648 2649static int2650dissect_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))) {2651 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2652 &usm_p.priv_tvb);2653 2654 return offset;2655}2656 2657 2658static const ber_sequence_t UsmSecurityParameters_sequence[] = {2659 { &hf_snmp_msgAuthoritativeEngineID, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineID },2660 { &hf_snmp_msgAuthoritativeEngineBoots, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineBoots },2661 { &hf_snmp_msgAuthoritativeEngineTime, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineTime },2662 { &hf_snmp_msgUserName , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgUserName },2663 { &hf_snmp_msgAuthenticationParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthenticationParameters },2664 { &hf_snmp_msgPrivacyParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgPrivacyParameters },2665 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2666};2667 2668static int2669dissect_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))) {2670 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2671 UsmSecurityParameters_sequence, hf_index, ett_snmp_UsmSecurityParameters);2672 2673 return offset;2674}2675 2676 2677 2678static int2679dissect_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))) {2680 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2681 NULL((void*)0));2682 2683 return offset;2684}2685 2686 2687 2688static int2689dissect_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))) {2690tvbuff_t *parameter_tvb = NULL((void*)0);2691 2692 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2693 &parameter_tvb);2694 2695if (parameter_tvb){2696uint8_t v3_flags = tvb_get_uint8(parameter_tvb, 0);2697proto_tree* flags_tree = proto_item_add_subtree(actx->created_item,ett_msgFlags);2698 2699proto_tree_add_item(flags_tree, hf_snmp_v3_flags_report, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);2700proto_tree_add_item(flags_tree, hf_snmp_v3_flags_crypt, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);2701proto_tree_add_item(flags_tree, hf_snmp_v3_flags_auth, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);2702 2703usm_p.encrypted = v3_flags & TH_CRYPT0x02 ? true1 : false0;2704usm_p.authenticated = v3_flags & TH_AUTH0x01 ? true1 : false0;2705}2706 2707 2708 2709 return offset;2710}2711 2712 2713 2714static int2715dissect_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))) {2716 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2717 &MsgSecurityModel);2718 2719 return offset;2720}2721 2722 2723static const ber_sequence_t HeaderData_sequence[] = {2724 { &hf_snmp_msgID , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },2725 { &hf_snmp_msgMaxSize , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_484_2147483647 },2726 { &hf_snmp_msgFlags , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgFlags },2727 { &hf_snmp_msgSecurityModel, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgSecurityModel },2728 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2729};2730 2731static int2732dissect_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))) {2733 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2734 HeaderData_sequence, hf_index, ett_snmp_HeaderData);2735 2736 return offset;2737}2738 2739 2740 2741static int2742dissect_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))) {2743 2744switch(MsgSecurityModel){

1

Control jumps to 'case 3:' at line 2745

2745case SNMP_SEC_USM3:/* 3 */2746offset = get_ber_identifier(tvb, offset, NULL((void*)0), NULL((void*)0), NULL((void*)0));2747offset = get_ber_length(tvb, offset, NULL((void*)0), NULL((void*)0));2748offset = dissect_snmp_UsmSecurityParameters(false0, tvb, offset, actx, tree, -1);2749usm_p.user_assoc = get_user_assoc(usm_p.engine_tvb, usm_p.user_tvb, actx->pinfo);

2

Calling 'get_user_assoc'

2750break;2751case SNMP_SEC_ANY0:/* 0 */2752case SNMP_SEC_V11:/* 1 */2753case SNMP_SEC_V2C2:/* 2 */2754default:2755 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2756 NULL((void*)0));2757 2758break;2759}2760 2761 2762 return offset;2763}2764 2765 2766static const ber_sequence_t ScopedPDU_sequence[] = {2767 { &hf_snmp_contextEngineID, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SnmpEngineID },2768 { &hf_snmp_contextName , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2769 { &hf_snmp_data , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_PDUs },2770 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2771};2772 2773static int2774dissect_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))) {2775 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2776 ScopedPDU_sequence, hf_index, ett_snmp_ScopedPDU);2777 2778 return offset;2779}2780 2781 2782 2783static int2784dissect_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))) {2785tvbuff_t* crypt_tvb;2786offset = dissect_ber_octet_string(false0, actx, tree, tvb, offset, hf_snmp_encryptedPDU, &crypt_tvb);2787 2788if( usm_p.encrypted && crypt_tvb2789&& usm_p.user_assoc2790&& usm_p.user_assoc->user.privProtocol ) {2791 2792const char* error = NULL((void*)0);2793proto_tree* encryptedpdu_tree = proto_item_add_subtree(actx->created_item,ett_encryptedPDU);2794tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, actx->pinfo, &error );2795 2796if (! cleartext_tvb) {2797proto_tree_add_expert_format(encryptedpdu_tree, actx->pinfo, &ei_snmp_failed_decrypted_data_pdu,2798crypt_tvb, 0, -1, "Failed to decrypt encryptedPDU: %s", error);2799 2800col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");2801 2802return offset;2803} else {2804proto_item* decrypted_item;2805proto_tree* decrypted_tree;2806 2807if (! check_ScopedPdu(cleartext_tvb)) {2808proto_tree_add_expert(encryptedpdu_tree, actx->pinfo, &ei_snmp_decrypted_data_bad_formatted, cleartext_tvb, 0, -1);2809 2810col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");2811 2812return offset;2813}2814 2815 2816add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");2817 2818decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,ENC_NA0x00000000);2819decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);2820dissect_snmp_ScopedPDU(false0, cleartext_tvb, 0, actx, decrypted_tree, -1);2821}2822} else {2823col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: privKey Unknown");2824}2825 2826 2827 return offset;2828}2829 2830 2831static const value_string snmp_ScopedPduData_vals[] = {2832 { 0, "plaintext" },2833 { 1, "encryptedPDU" },2834 { 0, NULL((void*)0) }2835};2836 2837static const ber_choice_t ScopedPduData_choice[] = {2838 { 0, &hf_snmp_plaintext , BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ScopedPDU },2839 { 1, &hf_snmp_encryptedPDU , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_encryptedPDU },2840 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2841};2842 2843static int2844dissect_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))) {2845 offset = dissect_ber_choice(actx, tree, tvb, offset,2846 ScopedPduData_choice, hf_index, ett_snmp_ScopedPduData,2847 NULL((void*)0));2848 2849 return offset;2850}2851 2852 2853static const ber_sequence_t SNMPv3Message_sequence[] = {2854 { &hf_snmp_msgVersion , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },2855 { &hf_snmp_msgGlobalData , BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_HeaderData },2856 { &hf_snmp_msgSecurityParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgSecurityParameters },2857 { &hf_snmp_msgData , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_ScopedPduData },2858 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2859};2860 2861static int2862dissect_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))) {2863 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2864 SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);2865 2866 2867if( usm_p.authenticated2868&& usm_p.user_assoc ) {2869const char* error = NULL((void*)0);2870proto_item* authen_item;2871proto_tree* authen_tree = proto_item_add_subtree(usm_p.auth_item,ett_authParameters);2872uint8_t* calc_auth = NULL((void*)0);2873unsigned calc_auth_len = 0;2874 2875usm_p.authOK = snmp_usm_auth(actx->pinfo, usm_p.user_assoc->user.authModel, &usm_p, &calc_auth, &calc_auth_len, &error );2876 2877if (error) {2878expert_add_info_format( actx->pinfo, usm_p.auth_item, &ei_snmp_verify_authentication_error, "Error while verifying Message authenticity: %s", error );2879} else {2880expert_field* expert;2881 2882authen_item = proto_tree_add_boolean(authen_tree, hf_snmp_msgAuthentication, tvb, 0, 0, usm_p.authOK);2883proto_item_set_generated(authen_item);2884 2885if (usm_p.authOK) {2886expert = &ei_snmp_authentication_ok;2887} else {2888const char* 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)
;2889proto_item_append_text(authen_item, " calculated = %s", calc_auth_str);2890expert = &ei_snmp_authentication_error;2891}2892 2893expert_add_info( actx->pinfo, authen_item, expert);2894}2895}2896 2897 return offset;2898}2899 2900 2901static const value_string snmp_T_smux_version_vals[] = {2902 { 0, "version-1" },2903 { 0, NULL((void*)0) }2904};2905 2906 2907static int2908dissect_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))) {2909 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2910 NULL((void*)0));2911 2912 return offset;2913}2914 2915 2916 2917static int2918dissect_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))) {2919 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL((void*)0));2920 2921 return offset;2922}2923 2924 2925 2926static int2927dissect_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))) {2928 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,2929 NULL((void*)0));2930 2931 return offset;2932}2933 2934 2935static const ber_sequence_t SimpleOpen_U_sequence[] = {2936 { &hf_snmp_smux_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_smux_version },2937 { &hf_snmp_identity , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OBJECT_IDENTIFIER },2938 { &hf_snmp_description , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_DisplayString },2939 { &hf_snmp_password , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },2940 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }2941};2942 2943static int2944dissect_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))) {2945 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,2946 SimpleOpen_U_sequence, hf_index, ett_snmp_SimpleOpen_U);2947 2948 return offset;2949}2950 2951 2952 2953static int2954dissect_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))) {2955 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,2956 hf_index, BER_CLASS_APP1, 0, true1, dissect_snmp_SimpleOpen_U);2957 2958 return offset;2959}2960 2961 2962static const value_string snmp_OpenPDU_vals[] = {2963 { 0, "smux-simple" },2964 { 0, NULL((void*)0) }2965};2966 2967static const ber_choice_t OpenPDU_choice[] = {2968 { 0, &hf_snmp_smux_simple , BER_CLASS_APP1, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SimpleOpen },2969 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }2970};2971 2972static int2973dissect_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))) {2974 offset = dissect_ber_choice(actx, tree, tvb, offset,2975 OpenPDU_choice, hf_index, ett_snmp_OpenPDU,2976 NULL((void*)0));2977 2978 return offset;2979}2980 2981 2982static const value_string snmp_ClosePDU_U_vals[] = {2983 { 0, "goingDown" },2984 { 1, "unsupportedVersion" },2985 { 2, "packetFormat" },2986 { 3, "protocolError" },2987 { 4, "internalError" },2988 { 5, "authenticationFailure" },2989 { 0, NULL((void*)0) }2990};2991 2992 2993static int2994dissect_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))) {2995 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,2996 NULL((void*)0));2997 2998 return offset;2999}3000 3001 3002 3003static int3004dissect_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))) {3005 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3006 hf_index, BER_CLASS_APP1, 1, true1, dissect_snmp_ClosePDU_U);3007 3008 return offset;3009}3010 3011 3012 3013static int3014dissect_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))) {3015 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,3016 NULL((void*)0));3017 3018 return offset;3019}3020 3021 3022static const value_string snmp_T_operation_vals[] = {3023 { 0, "delete" },3024 { 1, "readOnly" },3025 { 2, "readWrite" },3026 { 0, NULL((void*)0) }3027};3028 3029 3030static int3031dissect_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))) {3032 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,3033 NULL((void*)0));3034 3035 return offset;3036}3037 3038 3039static const ber_sequence_t RReqPDU_U_sequence[] = {3040 { &hf_snmp_subtree , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ObjectName },3041 { &hf_snmp_priority , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_M1_2147483647 },3042 { &hf_snmp_operation , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_operation },3043 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }3044};3045 3046static int3047dissect_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))) {3048 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,3049 RReqPDU_U_sequence, hf_index, ett_snmp_RReqPDU_U);3050 3051 return offset;3052}3053 3054 3055 3056static int3057dissect_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))) {3058 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3059 hf_index, BER_CLASS_APP1, 2, true1, dissect_snmp_RReqPDU_U);3060 3061 return offset;3062}3063 3064 3065static const value_string snmp_RRspPDU_U_vals[] = {3066 { -1, "failure" },3067 { 0, NULL((void*)0) }3068};3069 3070 3071static int3072dissect_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))) {3073 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,3074 NULL((void*)0));3075 3076 return offset;3077}3078 3079 3080 3081static int3082dissect_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))) {3083 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3084 hf_index, BER_CLASS_APP1, 3, true1, dissect_snmp_RRspPDU_U);3085 3086 return offset;3087}3088 3089 3090static const value_string snmp_RegisterResponse_vals[] = {3091 { 0, "rRspPDU" },3092 { 1, "pDUs" },3093 { 0, NULL((void*)0) }3094};3095 3096static const ber_choice_t RegisterResponse_choice[] = {3097 { 0, &hf_snmp_rRspPDU , BER_CLASS_APP1, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RRspPDU },3098 { 1, &hf_snmp_pDUs , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_PDUs },3099 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }3100};3101 3102static int3103dissect_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))) {3104 offset = dissect_ber_choice(actx, tree, tvb, offset,3105 RegisterResponse_choice, hf_index, ett_snmp_RegisterResponse,3106 NULL((void*)0));3107 3108 return offset;3109}3110 3111 3112static const value_string snmp_SOutPDU_U_vals[] = {3113 { 0, "commit" },3114 { 1, "rollback" },3115 { 0, NULL((void*)0) }3116};3117 3118 3119static int3120dissect_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))) {3121 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,3122 NULL((void*)0));3123 3124 return offset;3125}3126 3127 3128 3129static int3130dissect_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))) {3131 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,3132 hf_index, BER_CLASS_APP1, 4, true1, dissect_snmp_SOutPDU_U);3133 3134 return offset;3135}3136 3137 3138static const value_string snmp_SMUX_PDUs_vals[] = {3139 { 0, "open" },3140 { 1, "close" },3141 { 2, "registerRequest" },3142 { 3, "registerResponse" },3143 { 4, "commitOrRollback" },3144 { 0, NULL((void*)0) }3145};3146 3147static const ber_choice_t SMUX_PDUs_choice[] = {3148 { 0, &hf_snmp_open , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OpenPDU },3149 { 1, &hf_snmp_close , BER_CLASS_APP1, 1, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ClosePDU },3150 { 2, &hf_snmp_registerRequest, BER_CLASS_APP1, 2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RReqPDU },3151 { 3, &hf_snmp_registerResponse, BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RegisterResponse },3152 { 4, &hf_snmp_commitOrRollback, BER_CLASS_APP1, 4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SOutPDU },3153 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }3154};3155 3156static int3157dissect_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))) {3158 3159snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(actx->pinfo);3160 3161actx->private_data = snmp_info;3162 3163 offset = dissect_ber_choice(actx, tree, tvb, offset,3164 SMUX_PDUs_choice, hf_index, ett_snmp_SMUX_PDUs,3165 NULL((void*)0));3166 3167 return offset;3168}3169 3170/*--- PDUs ---*/3171 3172static 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))) {3173 int offset = 0;3174 asn1_ctx_t asn1_ctx;3175 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true1, pinfo);3176 offset = dissect_snmp_SMUX_PDUs(false0, tvb, offset, &asn1_ctx, tree, hf_snmp_SMUX_PDUs_PDU);3177 return offset;3178}3179 3180 3181static snmp_conv_info_t*3182snmp_find_conversation_and_get_conv_data(packet_info *pinfo) {3183 3184conversation_t *conversation = NULL((void*)0);3185snmp_conv_info_t *snmp_info = NULL((void*)0);3186 3187/* Get the conversation with the wildcarded port, if it exists3188 * and is associated with SNMP, so that requests and responses3189 * can be matched even if the response comes from a different,3190 * ephemeral, source port, as originally done in OS/400.3191 * On UDP, we do not automatically call conversation_set_port2()3192 * and we do not want to do so. Possibly this should eventually3193 * use find_conversation_full and separate the "SNMP conversation"3194 * from "the transport layer conversation that carries SNMP."3195 */3196if (pinfo->destport == UDP_PORT_SNMP161) {3197conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),3198pinfo->srcport, 0, NO_PORT_B0x00020000);3199} else if (pinfo->srcport == UDP_PORT_SNMP161) {3200conversation = find_conversation(pinfo->fd->num, &pinfo->dst, &pinfo->src, conversation_pt_to_conversation_type(pinfo->ptype),3201pinfo->destport, 0, NO_PORT_B0x00020000);3202}3203if ((conversation == NULL((void*)0)) || (conversation_get_dissector(conversation, pinfo->num) != snmp_handle)) {3204conversation = find_or_create_conversation(pinfo);3205}3206 3207snmp_info = (snmp_conv_info_t *)conversation_get_proto_data(conversation, proto_snmp);3208if (snmp_info == NULL((void*)0)) {3209snmp_info = wmem_new0(wmem_file_scope(), snmp_conv_info_t)((snmp_conv_info_t*)wmem_alloc0((wmem_file_scope()), sizeof(snmp_conv_info_t
)))
;3210snmp_info->request_response=wmem_map_new(wmem_file_scope(), g_int_hash, g_int_equal);3211 3212conversation_add_proto_data(conversation, proto_snmp, snmp_info);3213}3214return snmp_info;3215}3216 3217unsigned3218dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,3219 proto_tree *tree, int proto, int ett, bool_Bool is_tcp)3220{3221 3222unsigned length_remaining;3223int8_t ber_class;3224bool_Bool pc, ind = 0;3225int32_t tag;3226uint32_t len;3227unsigned message_length;3228int start_offset = offset;3229uint32_t version = 0;3230tvbuff_t*next_tvb;3231 3232proto_tree *snmp_tree = NULL((void*)0);3233proto_item *item = NULL((void*)0);3234 3235snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(pinfo);3236 3237asn1_ctx_t asn1_ctx;3238asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true1, pinfo);3239 3240asn1_ctx.private_data = snmp_info;3241 3242usm_p.msg_tvb = tvb;3243usm_p.start_offset = tvb_offset_from_real_beginning(tvb);3244usm_p.engine_tvb = NULL((void*)0);3245usm_p.user_tvb = NULL((void*)0);3246usm_p.auth_item = NULL((void*)0);3247usm_p.auth_tvb = NULL((void*)0);3248usm_p.auth_offset = 0;3249usm_p.priv_tvb = NULL((void*)0);3250usm_p.user_assoc = NULL((void*)0);3251usm_p.authenticated = false0;3252usm_p.encrypted = false0;3253usm_p.boots = 0;3254usm_p.snmp_time = 0;3255usm_p.authOK = false0;3256 3257/*3258 * This will throw an exception if we don't have any data left.3259 * That's what we want. (See "tcp_dissect_pdus()", which is3260 * similar, but doesn't have to deal with ASN.1.3261 * XXX - can we make "tcp_dissect_pdus()" provide enough3262 * information to the "get_pdu_len" routine so that we could3263 * have that routine deal with ASN.1, and just use3264 * "tcp_dissect_pdus()"?)3265 */3266length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);3267 3268/* NOTE: we have to parse the message piece by piece, since the3269 * capture length may be less than the message length: a 'global'3270 * parsing is likely to fail.3271 */3272 3273/*3274 * If this is SNMP-over-TCP, we might have to do reassembly3275 * in order to read the "Sequence Of" header.3276 */3277if (is_tcp && snmp_desegment && pinfo->can_desegment) {3278/*3279 * This is TCP, and we should, and can, do reassembly.3280 *3281 * Is the "Sequence Of" header split across segment3282 * boundaries? We require at least 6 bytes for the3283 * header, which allows for a 4-byte length (ASN.13284 * BER).3285 */3286if (length_remaining < 6) {3287/*3288 * Yes. Tell the TCP dissector where the data3289 * for this message starts in the data it handed3290 * us and that we need "some more data." Don't tell3291 * it exactly how many bytes we need because if/when3292 * we ask for even more (after the header) that will3293 * break reassembly.3294 */3295pinfo->desegment_offset = offset;3296pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT0x0fffffff;3297return 0;3298}3299}3300 3301/*3302 * OK, try to read the "Sequence Of" header; this gets the total3303 * length of the SNMP message.3304 */3305offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);3306/*Get the total octet length of the SNMP data*/3307offset = get_ber_length(tvb, offset, &len, &ind);3308message_length = len + offset;3309 3310/*Get the SNMP version data*/3311/*offset =*/ dissect_ber_integer(false0, &asn1_ctx, 0, tvb, offset, -1, &version);3312 3313 3314/*3315 * If this is SNMP-over-TCP, we might have to do reassembly3316 * to get all of this message.3317 */3318if (is_tcp && snmp_desegment && pinfo->can_desegment) {3319/*3320 * Yes - is the message split across segment boundaries?3321 */3322if (length_remaining < message_length) {3323/*3324 * Yes. Tell the TCP dissector where the data3325 * for this message starts in the data it handed3326 * us, and how many more bytes we need, and3327 * return.3328 */3329pinfo->desegment_offset = start_offset;3330pinfo->desegment_len =3331message_length - length_remaining;3332 3333/*3334 * Return 0, which means "I didn't dissect anything3335 * because I don't have enough data - we need3336 * to desegment".3337 */3338return 0;3339}3340}3341 3342var_list = next_tvb_list_new(pinfo->pool);3343 3344col_set_str(pinfo->cinfo, COL_PROTOCOL, proto_get_protocol_short_name(find_protocol_by_id(proto)));3345 3346item = proto_tree_add_item(tree, proto, tvb, start_offset, message_length, ENC_BIG_ENDIAN0x00000000);3347snmp_tree = proto_item_add_subtree(item, ett);3348 3349switch (version) {3350case 0: /* v1 */3351case 1: /* v2c */3352offset = dissect_snmp_Message(false0 , tvb, start_offset, &asn1_ctx, snmp_tree, -1);3353break;3354case 2: /* v2u */3355offset = dissect_snmp_Messagev2u(false0 , tvb, start_offset, &asn1_ctx, snmp_tree, -1);3356break;3357/* v3 */3358case 3:3359offset = dissect_snmp_SNMPv3Message(false0 , tvb, start_offset, &asn1_ctx, snmp_tree, -1);3360break;3361default:3362/*3363 * Return the length remaining in the tvbuff, so3364 * if this is SNMP-over-TCP, our caller thinks there's3365 * nothing left to dissect.3366 */3367expert_add_info(pinfo, item, &ei_snmp_version_unknown);3368return length_remaining;3369}3370 3371/* There may be appended data after the SNMP data, so treat as raw3372 * data which needs to be dissected in case of UDP as UDP is PDU oriented.3373 */3374if((!is_tcp) && (length_remaining > (unsigned)offset)) {3375next_tvb = tvb_new_subset_remaining(tvb, offset);3376call_dissector(data_handle, next_tvb, pinfo, tree);3377} else {3378next_tvb_call(var_list, pinfo, tree, NULL((void*)0), data_handle);3379}3380 3381return offset;3382}3383 3384static int3385dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U___attribute__((unused)))3386{3387int offset;3388int8_t tmp_class;3389bool_Bool tmp_pc;3390int32_t tmp_tag;3391uint32_t tmp_length;3392bool_Bool tmp_ind;3393 3394/*3395 * See if this looks like SNMP or not. if not, return 0 so3396 * wireshark can try some other dissector instead.3397 */3398/* All SNMP packets are BER encoded and consist of a SEQUENCE3399 * that spans the entire PDU. The first item is an INTEGER that3400 * has the values 0-2 (version 1-3).3401 * if not it is not snmp.3402 */3403/* SNMP starts with a SEQUENCE */3404offset = get_ber_identifier(tvb, 0, &tmp_class, &tmp_pc, &tmp_tag);3405if((tmp_class!=BER_CLASS_UNI0)||(tmp_tag!=BER_UNI_TAG_SEQUENCE16)) {3406return 0;3407}3408/* then comes a length which spans the rest of the tvb */3409offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);3410/* Loosen the heuristic a bit to handle the case where data has intentionally3411 * been added after the snmp PDU ( UDP case) (#3684)3412 * If this is fragmented or carried in ICMP, we don't expect the tvb to3413 * have the full legnth, so don't check.3414 */3415if (!pinfo->fragmented && !pinfo->flags.in_error_pkt) {3416 if ( pinfo->ptype == PT_UDP ) {3417 if(tmp_length>(uint32_t)tvb_reported_length_remaining(tvb, offset)) {3418 return 0;3419 }3420 }else{3421 if(tmp_length!=(uint32_t)tvb_reported_length_remaining(tvb, offset)) {3422 return 0;3423 }3424 }3425}3426/* then comes an INTEGER (version)*/3427get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);3428if((tmp_class!=BER_CLASS_UNI0)||(tmp_tag!=BER_UNI_TAG_INTEGER2)) {3429return 0;3430}3431/* do we need to test that version is 0 - 2 (version1-3) ? */3432 3433 3434/*3435 * The IBM i (OS/400) SNMP agent, at least originally, would3436 * send responses back from some *other* UDP port, an ephemeral3437 * port above 5000, going back to the same IP address and port3438 * from which the request came, similar to TFTP. This only happens3439 * with the agent port, 161, not with the trap port, etc. As of3440 * 2015 with the latest fixes applied, it no longer does this:3441 * https://www.ibm.com/support/pages/ptf/SI554873442 * https://www.ibm.com/support/pages/ptf/SI555373443 *3444 * The SNMP RFCs are silent on this (cf. L2TP RFC 2661, which3445 * supports using either the well-known port or an ephemeral3446 * port as the source port for responses, while noting that3447 * the latter can cause issues with firewalls and NATs.) so3448 * possibly some other implementations could do this.3449 *3450 * If this packet went to the SNMP port, we check to see if3451 * there's already a conversation with one address/port pair3452 * matching the source IP address and port of this packet,3453 * the other address matching the destination IP address of this3454 * packet, and any destination port.3455 *3456 * If not, we create one, with its address 1/port 1 pair being3457 * the source address/port of this packet, its address 2 being3458 * the destination address of this packet, and its port 2 being3459 * wildcarded, and give it the SNMP dissector as a dissector.3460 */3461 3462if (pinfo->destport == UDP_PORT_SNMP161) {3463conversation_t *conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),3464pinfo->srcport, 0, NO_PORT_B0x00020000);3465 3466if( (conversation == NULL((void*)0)) || (conversation_get_dissector(conversation, pinfo->num)!=snmp_handle) ) {3467conversation = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),3468pinfo->srcport, 0, NO_PORT20x02);3469conversation_set_dissector(conversation, snmp_handle);3470}3471}3472 3473return dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, false0);3474}3475 3476static int3477dissect_snmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused)))3478{3479int offset = 0;3480unsigned message_len;3481 3482while (tvb_reported_length_remaining(tvb, offset) > 0) {3483message_len = dissect_snmp_pdu(tvb, offset, pinfo, tree, proto_snmp, ett_snmp, true1);3484if (message_len == 0) {3485/*3486 * We don't have all the data for that message,3487 * so we need to do desegmentation;3488 * "dissect_snmp_pdu()" has set that up.3489 */3490break;3491}3492offset += message_len;3493}3494return tvb_captured_length(tvb);3495}3496 3497static int3498dissect_smux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)3499{3500proto_tree *smux_tree = NULL((void*)0);3501proto_item *item = NULL((void*)0);3502 3503var_list = next_tvb_list_new(pinfo->pool);3504 3505col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMUX");3506 3507item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, ENC_NA0x00000000);3508smux_tree = proto_item_add_subtree(item, ett_smux);3509 3510return dissect_SMUX_PDUs_PDU(tvb, pinfo, smux_tree, data);3511}3512 3513/*3514 MD5 Password to Key Algorithm from RFC 3414 A.2.13515 SHA1 Password to Key Algorithm from RFC 3414 A.2.23516 SHA2 Password to Key Algorithm from RFC 7860 9.33517*/3518static void3519snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const uint8_t *password,3520unsigned passwordlen, const uint8_t *engineID, unsigned engineLength, uint8_t *key)3521{3522gcry_md_hd_thash_handle;3523uint8_t *cp, password_buf[64];3524uint32_t password_index = 0;3525uint32_t count = 0, i;3526unsigned hash_len;3527 3528if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {

27

Assuming the condition is true

28

Taking true branch

34

Assuming the condition is false

35

Taking false branch

3529return;

29

Returning without writing to '*key'

3530}3531 3532hash_len = auth_hash_len[model];3533 3534/**********************************************/3535/* Use while loop until we've done 1 Megabyte */3536/**********************************************/3537while (count < 1048576) {

36

Loop condition is true. Entering loop body

3538cp = password_buf;3539if (passwordlen

36.1

'passwordlen' is not equal to 0
!= 0) {

37

Taking true branch

3540for (i = 0; i < 64; i++) {

38

Loop condition is true. Entering loop body

3541/*************************************************/3542/* Take the next octet of the password, wrapping */3543/* to the beginning of the password as necessary.*/3544/*************************************************/3545*cp++ = password[password_index++ % passwordlen];

39

Assigned value is garbage or undefined
3546}3547} else {3548*cp = 0;3549}3550gcry_md_write(hash_handle, password_buf, 64);3551count += 64;3552}3553memcpy(key, gcry_md_read(hash_handle, 0), hash_len);3554gcry_md_close(hash_handle);3555 3556/*****************************************************/3557/* Now localise the key with the engineID and pass */3558/* through hash function to produce final key */3559/* We ignore invalid engineLengths here. More strict */3560/* checking is done in snmp_users_update_cb. */3561/*****************************************************/3562if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {3563return;3564}3565gcry_md_write(hash_handle, key, hash_len);3566gcry_md_write(hash_handle, engineID, engineLength);3567gcry_md_write(hash_handle, key, hash_len);3568memcpy(key, gcry_md_read(hash_handle, 0), hash_len);3569gcry_md_close(hash_handle);3570return;3571}3572 3573static void3574process_prefs(void)3575{3576}3577 3578UAT_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_inline (""); *out_len = 0; } }
3579UAT_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_inline (""); *out_len = 0; } }
3580UAT_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_inline (""); *out_len = 0; } }
3581UAT_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_inline (""); *out_len = ((snmp_ue_assoc_t
*)rec)->engine.len; }
3582UAT_VS_DEF(snmp_users,auth_model,snmp_ue_assoc_t,unsigned,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
((strcmp ((const char *) (cstr), (const char *) (str)) == 0)
) { ((snmp_ue_assoc_t*)rec)->auth_model = (unsigned)((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_inline
(((const value_string*)vs)[i].strptr); *out_len = (unsigned)
strlen(*out_ptr); return; } } *out_ptr = g_strdup_inline ("MD5"
); *out_len = (unsigned)strlen("MD5"); }
3583UAT_VS_DEF(snmp_users,priv_proto,snmp_ue_assoc_t,unsigned,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
((strcmp ((const char *) (cstr), (const char *) (str)) == 0)
) { ((snmp_ue_assoc_t*)rec)->priv_proto = (unsigned)((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_inline
(((const value_string*)vs)[i].strptr); *out_len = (unsigned)
strlen(*out_ptr); return; } } *out_ptr = g_strdup_inline ("DES"
); *out_len = (unsigned)strlen("DES"); }
3584UAT_VS_DEF(snmp_users,priv_key_exp,snmp_ue_assoc_t,unsigned,0,"draft-reeder-snmpv3-usm-3desede-00")static void snmp_users_priv_key_exp_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_key_exp = 0; for
(i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { if
((strcmp ((const char *) (cstr), (const char *) (str)) == 0)
) { ((snmp_ue_assoc_t*)rec)->priv_key_exp = (unsigned)((const
value_string*)vs)[i].value; g_free(str); return; } } g_free(
str); } static void snmp_users_priv_key_exp_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_key_exp ) { *out_ptr = g_strdup_inline
(((const value_string*)vs)[i].strptr); *out_len = (unsigned)
strlen(*out_ptr); return; } } *out_ptr = g_strdup_inline ("draft-reeder-snmpv3-usm-3desede-00"
); *out_len = (unsigned)strlen("draft-reeder-snmpv3-usm-3desede-00"
); }
3585 3586static void *3587snmp_specific_trap_copy_cb(void *dest, const void *orig, size_t len _U___attribute__((unused)))3588{3589snmp_st_assoc_t *u = (snmp_st_assoc_t *)dest;3590const snmp_st_assoc_t *o = (const snmp_st_assoc_t *)orig;3591 3592u->enterprise = g_strdup(o->enterprise)g_strdup_inline (o->enterprise);3593u->trap = o->trap;3594u->desc = g_strdup(o->desc)g_strdup_inline (o->desc);3595 3596return dest;3597}3598 3599static void3600snmp_specific_trap_free_cb(void *r)3601{3602snmp_st_assoc_t *u = (snmp_st_assoc_t *)r;3603 3604g_free(u->enterprise);3605g_free(u->desc);3606}3607 3608UAT_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_inline ((((snmp_st_assoc_t
*)rec)->enterprise)); *out_len = (unsigned)strlen((((snmp_st_assoc_t
*)rec)->enterprise)); } else { *out_ptr = g_strdup_inline (
""); *out_len = 0; } }
3609UAT_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); }
3610UAT_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_inline
((((snmp_st_assoc_t*)rec)->desc)); *out_len = (unsigned)strlen
((((snmp_st_assoc_t*)rec)->desc)); } else { *out_ptr = g_strdup_inline
(""); *out_len = 0; } }
3611 3612/*--- proto_register_snmp -------------------------------------------*/3613void proto_register_snmp(void) {3614/* List of fields */3615static hf_register_info hf[] = {3616{ &hf_snmp_response_in,3617{ "Response In", "snmp.response_in", FT_FRAMENUM, BASE_NONE, NULL((void*)0), 0x0,3618"The response to this SNMP request is in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3619{ &hf_snmp_response_to,3620{ "Response To", "snmp.response_to", FT_FRAMENUM, BASE_NONE, NULL((void*)0), 0x0,3621"This is a response to the SNMP request in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3622{ &hf_snmp_time,3623{ "Time", "snmp.time", FT_RELATIVE_TIME, BASE_NONE, NULL((void*)0), 0x0,3624"The time between the Request and the Response", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3625{ &hf_snmp_v3_flags_auth,3626{ "Authenticated", "snmp.v3.flags.auth", FT_BOOLEAN, 8,3627 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) }},3628{ &hf_snmp_v3_flags_crypt,3629{ "Encrypted", "snmp.v3.flags.crypt", FT_BOOLEAN, 8,3630 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) }},3631{ &hf_snmp_v3_flags_report,3632{ "Reportable", "snmp.v3.flags.report", FT_BOOLEAN, 8,3633 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) }},3634{ &hf_snmp_engineid_conform, {3635 "Engine ID Conformance", "snmp.engineid.conform", FT_BOOLEAN, 8,3636 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) }},3637{ &hf_snmp_engineid_enterprise, {3638 "Engine Enterprise ID", "snmp.engineid.enterprise", FT_UINT32, BASE_ENTERPRISESBASE_CUSTOM,3639 STRINGS_ENTERPRISES((const void *) (size_t) (enterprises_base_custom)), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3640{ &hf_snmp_engineid_format, {3641 "Engine ID Format", "snmp.engineid.format", FT_UINT8, BASE_DEC,3642 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) }},3643{ &hf_snmp_engineid_ipv4, {3644 "Engine ID Data: IPv4 address", "snmp.engineid.ipv4", FT_IPv4, BASE_NONE,3645 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3646{ &hf_snmp_engineid_ipv6, {3647 "Engine ID Data: IPv6 address", "snmp.engineid.ipv6", FT_IPv6, BASE_NONE,3648 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3649{ &hf_snmp_engineid_cisco_type, {3650 "Engine ID Data: Cisco type", "snmp.engineid.cisco.type", FT_UINT8, BASE_HEX,3651 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) }},3652{ &hf_snmp_engineid_mac, {3653 "Engine ID Data: MAC address", "snmp.engineid.mac", FT_ETHER, BASE_NONE,3654 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3655{ &hf_snmp_engineid_text, {3656 "Engine ID Data: Text", "snmp.engineid.text", FT_STRING, BASE_NONE,3657 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3658{ &hf_snmp_engineid_time, {3659 "Engine ID Data: Creation Time", "snmp.engineid.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,3660 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3661{ &hf_snmp_engineid_data, {3662 "Engine ID Data", "snmp.engineid.data", FT_BYTES, BASE_NONE,3663 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3664{ &hf_snmp_msgAuthentication, {3665 "Authentication", "snmp.v3.auth", FT_BOOLEAN, BASE_NONE,3666 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) }},3667{ &hf_snmp_decryptedPDU, {3668 "Decrypted ScopedPDU", "snmp.decrypted_pdu", FT_BYTES, BASE_NONE,3669 NULL((void*)0), 0, "Decrypted PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3670{ &hf_snmp_noSuchObject, {3671 "noSuchObject", "snmp.noSuchObject", FT_NONE, BASE_NONE,3672 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3673{ &hf_snmp_noSuchInstance, {3674 "noSuchInstance", "snmp.noSuchInstance", FT_NONE, BASE_NONE,3675 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3676{ &hf_snmp_endOfMibView, {3677 "endOfMibView", "snmp.endOfMibView", FT_NONE, BASE_NONE,3678 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3679{ &hf_snmp_unSpecified, {3680 "unSpecified", "snmp.unSpecified", FT_NONE, BASE_NONE,3681 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3682 3683{ &hf_snmp_integer32_value, {3684 "Value (Integer32)", "snmp.value.int", FT_INT64, BASE_DEC,3685 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3686{ &hf_snmp_octetstring_value, {3687 "Value (OctetString)", "snmp.value.octets", FT_BYTES, BASE_SHOW_ASCII_PRINTABLE0x00010000,3688 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3689{ &hf_snmp_oid_value, {3690 "Value (OID)", "snmp.value.oid", FT_OID, BASE_NONE,3691 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3692{ &hf_snmp_null_value, {3693 "Value (Null)", "snmp.value.null", FT_NONE, BASE_NONE,3694 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3695{ &hf_snmp_ipv4_value, {3696 "Value (IpAddress)", "snmp.value.ipv4", FT_IPv4, BASE_NONE,3697 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3698{ &hf_snmp_ipv6_value, {3699 "Value (IpAddress)", "snmp.value.ipv6", FT_IPv6, BASE_NONE,3700 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3701{ &hf_snmp_anyaddress_value, {3702 "Value (IpAddress)", "snmp.value.addr", FT_BYTES, BASE_NONE,3703 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3704{ &hf_snmp_unsigned32_value, {3705 "Value (Unsigned32)", "snmp.value.u32", FT_INT64, BASE_DEC,3706 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3707{ &hf_snmp_gauge32_value, {3708 "Value (Gauge32)", "snmp.value.g32", FT_INT64, BASE_DEC,3709 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3710{ &hf_snmp_unknown_value, {3711 "Value (Unknown)", "snmp.value.unk", FT_BYTES, BASE_NONE,3712 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3713{ &hf_snmp_counter_value, {3714 "Value (Counter32)", "snmp.value.counter", FT_UINT64, BASE_DEC,3715 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3716{ &hf_snmp_big_counter_value, {3717 "Value (Counter64)", "snmp.value.counter", FT_UINT64, BASE_DEC,3718 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3719{ &hf_snmp_nsap_value, {3720 "Value (NSAP)", "snmp.value.nsap", FT_UINT64, BASE_DEC,3721 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3722{ &hf_snmp_timeticks_value, {3723 "Value (Timeticks)", "snmp.value.timeticks", FT_UINT64, BASE_DEC,3724 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3725{ &hf_snmp_opaque_value, {3726 "Value (Opaque)", "snmp.value.opaque", FT_BYTES, BASE_NONE,3727 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3728{ &hf_snmp_objectname, {3729 "Object Name", "snmp.name", FT_OID, BASE_NONE,3730 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3731{ &hf_snmp_scalar_instance_index, {3732 "Scalar Instance Index", "snmp.name.index", FT_UINT64, BASE_DEC,3733 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3734{ &hf_snmp_var_bind_str, {3735 "Variable-binding-string", "snmp.var-bind_str", FT_STRING, BASE_NONE,3736 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3737{ &hf_snmp_agentid_trailer, {3738 "AgentID Trailer", "snmp.agentid_trailer", FT_BYTES, BASE_NONE,3739 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3740 3741 3742 { &hf_snmp_SMUX_PDUs_PDU,3743 { "SMUX-PDUs", "snmp.SMUX_PDUs",3744 FT_UINT32, BASE_DEC, VALS(snmp_SMUX_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_SMUX_PDUs_vals)
)))
, 0,3745 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3746 { &hf_snmp_version,3747 { "version", "snmp.version",3748 FT_INT32, BASE_DEC, VALS(snmp_Version_vals)((0 ? (const struct _value_string*)0 : ((snmp_Version_vals)))
)
, 0,3749 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3750 { &hf_snmp_community,3751 { "community", "snmp.community",3752 FT_STRING, BASE_NONE, NULL((void*)0), 0,3753 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3754 { &hf_snmp_data,3755 { "data", "snmp.data",3756 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,3757 "PDUs", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3758 { &hf_snmp_parameters,3759 { "parameters", "snmp.parameters",3760 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3761 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3762 { &hf_snmp_datav2u,3763 { "datav2u", "snmp.datav2u",3764 FT_UINT32, BASE_DEC, VALS(snmp_T_datav2u_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_datav2u_vals)
)))
, 0,3765 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3766 { &hf_snmp_v2u_plaintext,3767 { "plaintext", "snmp.plaintext",3768 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,3769 "PDUs", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3770 { &hf_snmp_encrypted,3771 { "encrypted", "snmp.encrypted",3772 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3773 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3774 { &hf_snmp_msgAuthoritativeEngineID,3775 { "msgAuthoritativeEngineID", "snmp.msgAuthoritativeEngineID",3776 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3777 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3778 { &hf_snmp_msgAuthoritativeEngineBoots,3779 { "msgAuthoritativeEngineBoots", "snmp.msgAuthoritativeEngineBoots",3780 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3781 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3782 { &hf_snmp_msgAuthoritativeEngineTime,3783 { "msgAuthoritativeEngineTime", "snmp.msgAuthoritativeEngineTime",3784 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3785 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3786 { &hf_snmp_msgUserName,3787 { "msgUserName", "snmp.msgUserName",3788 FT_STRING, BASE_NONE, NULL((void*)0), 0,3789 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3790 { &hf_snmp_msgAuthenticationParameters,3791 { "msgAuthenticationParameters", "snmp.msgAuthenticationParameters",3792 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3793 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3794 { &hf_snmp_msgPrivacyParameters,3795 { "msgPrivacyParameters", "snmp.msgPrivacyParameters",3796 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3797 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3798 { &hf_snmp_msgVersion,3799 { "msgVersion", "snmp.msgVersion",3800 FT_INT32, BASE_DEC, VALS(snmp_Version_vals)((0 ? (const struct _value_string*)0 : ((snmp_Version_vals)))
)
, 0,3801 "Version", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3802 { &hf_snmp_msgGlobalData,3803 { "msgGlobalData", "snmp.msgGlobalData_element",3804 FT_NONE, BASE_NONE, NULL((void*)0), 0,3805 "HeaderData", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3806 { &hf_snmp_msgSecurityParameters,3807 { "msgSecurityParameters", "snmp.msgSecurityParameters",3808 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3809 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3810 { &hf_snmp_msgData,3811 { "msgData", "snmp.msgData",3812 FT_UINT32, BASE_DEC, VALS(snmp_ScopedPduData_vals)((0 ? (const struct _value_string*)0 : ((snmp_ScopedPduData_vals
))))
, 0,3813 "ScopedPduData", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3814 { &hf_snmp_msgID,3815 { "msgID", "snmp.msgID",3816 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3817 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3818 { &hf_snmp_msgMaxSize,3819 { "msgMaxSize", "snmp.msgMaxSize",3820 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3821 "INTEGER_484_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3822 { &hf_snmp_msgFlags,3823 { "msgFlags", "snmp.msgFlags",3824 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3825 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3826 { &hf_snmp_msgSecurityModel,3827 { "msgSecurityModel", "snmp.msgSecurityModel",3828 FT_UINT32, BASE_DEC, VALS(sec_models)((0 ? (const struct _value_string*)0 : ((sec_models)))), 0,3829 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3830 { &hf_snmp_plaintext,3831 { "plaintext", "snmp.plaintext_element",3832 FT_NONE, BASE_NONE, NULL((void*)0), 0,3833 "ScopedPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3834 { &hf_snmp_encryptedPDU,3835 { "encryptedPDU", "snmp.encryptedPDU",3836 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3837 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3838 { &hf_snmp_contextEngineID,3839 { "contextEngineID", "snmp.contextEngineID",3840 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3841 "SnmpEngineID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3842 { &hf_snmp_contextName,3843 { "contextName", "snmp.contextName",3844 FT_STRING, BASE_NONE, NULL((void*)0), 0,3845 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3846 { &hf_snmp_get_request,3847 { "get-request", "snmp.get_request_element",3848 FT_NONE, BASE_NONE, NULL((void*)0), 0,3849 "GetRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3850 { &hf_snmp_get_next_request,3851 { "get-next-request", "snmp.get_next_request_element",3852 FT_NONE, BASE_NONE, NULL((void*)0), 0,3853 "GetNextRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3854 { &hf_snmp_get_response,3855 { "get-response", "snmp.get_response_element",3856 FT_NONE, BASE_NONE, NULL((void*)0), 0,3857 "GetResponse_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3858 { &hf_snmp_set_request,3859 { "set-request", "snmp.set_request_element",3860 FT_NONE, BASE_NONE, NULL((void*)0), 0,3861 "SetRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3862 { &hf_snmp_trap,3863 { "trap", "snmp.trap_element",3864 FT_NONE, BASE_NONE, NULL((void*)0), 0,3865 "Trap_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3866 { &hf_snmp_getBulkRequest,3867 { "getBulkRequest", "snmp.getBulkRequest_element",3868 FT_NONE, BASE_NONE, NULL((void*)0), 0,3869 "GetBulkRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3870 { &hf_snmp_informRequest,3871 { "informRequest", "snmp.informRequest_element",3872 FT_NONE, BASE_NONE, NULL((void*)0), 0,3873 "InformRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3874 { &hf_snmp_snmpV2_trap,3875 { "snmpV2-trap", "snmp.snmpV2_trap_element",3876 FT_NONE, BASE_NONE, NULL((void*)0), 0,3877 "SNMPv2_Trap_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3878 { &hf_snmp_report,3879 { "report", "snmp.report_element",3880 FT_NONE, BASE_NONE, NULL((void*)0), 0,3881 "Report_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3882 { &hf_snmp_request_id,3883 { "request-id", "snmp.request_id",3884 FT_INT32, BASE_DEC, NULL((void*)0), 0,3885 "T_request_id", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3886 { &hf_snmp_error_status,3887 { "error-status", "snmp.error_status",3888 FT_INT32, BASE_DEC, VALS(snmp_T_error_status_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_error_status_vals
))))
, 0,3889 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3890 { &hf_snmp_error_index,3891 { "error-index", "snmp.error_index",3892 FT_INT32, BASE_DEC, NULL((void*)0), 0,3893 "INTEGER", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3894 { &hf_snmp_variable_bindings,3895 { "variable-bindings", "snmp.variable_bindings",3896 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3897 "VarBindList", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3898 { &hf_snmp_bulkPDU_request_id,3899 { "request-id", "snmp.request_id",3900 FT_INT32, BASE_DEC, NULL((void*)0), 0,3901 "Integer32", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3902 { &hf_snmp_non_repeaters,3903 { "non-repeaters", "snmp.non_repeaters",3904 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3905 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3906 { &hf_snmp_max_repetitions,3907 { "max-repetitions", "snmp.max_repetitions",3908 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3909 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3910 { &hf_snmp_enterprise,3911 { "enterprise", "snmp.enterprise",3912 FT_OID, BASE_NONE, NULL((void*)0), 0,3913 "EnterpriseOID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3914 { &hf_snmp_agent_addr,3915 { "agent-addr", "snmp.agent_addr",3916 FT_IPv4, BASE_NONE, NULL((void*)0), 0,3917 "NetworkAddress", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3918 { &hf_snmp_generic_trap,3919 { "generic-trap", "snmp.generic_trap",3920 FT_INT32, BASE_DEC, VALS(snmp_GenericTrap_vals)((0 ? (const struct _value_string*)0 : ((snmp_GenericTrap_vals
))))
, 0,3921 "GenericTrap", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3922 { &hf_snmp_specific_trap,3923 { "specific-trap", "snmp.specific_trap",3924 FT_INT32, BASE_DEC, NULL((void*)0), 0,3925 "SpecificTrap", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3926 { &hf_snmp_time_stamp,3927 { "time-stamp", "snmp.time_stamp",3928 FT_UINT32, BASE_DEC, NULL((void*)0), 0,3929 "TimeTicks", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3930 { &hf_snmp_name,3931 { "name", "snmp.name",3932 FT_OID, BASE_NONE, NULL((void*)0), 0,3933 "ObjectName", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3934 { &hf_snmp_valueType,3935 { "valueType", "snmp.valueType_element",3936 FT_NONE, BASE_NONE, NULL((void*)0), 0,3937 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3938 { &hf_snmp_VarBindList_item,3939 { "VarBind", "snmp.VarBind_element",3940 FT_NONE, BASE_NONE, NULL((void*)0), 0,3941 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3942 { &hf_snmp_open,3943 { "open", "snmp.open",3944 FT_UINT32, BASE_DEC, VALS(snmp_OpenPDU_vals)((0 ? (const struct _value_string*)0 : ((snmp_OpenPDU_vals)))
)
, 0,3945 "OpenPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3946 { &hf_snmp_close,3947 { "close", "snmp.close",3948 FT_INT32, BASE_DEC, VALS(snmp_ClosePDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_ClosePDU_U_vals
))))
, 0,3949 "ClosePDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3950 { &hf_snmp_registerRequest,3951 { "registerRequest", "snmp.registerRequest_element",3952 FT_NONE, BASE_NONE, NULL((void*)0), 0,3953 "RReqPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3954 { &hf_snmp_registerResponse,3955 { "registerResponse", "snmp.registerResponse",3956 FT_UINT32, BASE_DEC, VALS(snmp_RegisterResponse_vals)((0 ? (const struct _value_string*)0 : ((snmp_RegisterResponse_vals
))))
, 0,3957 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3958 { &hf_snmp_commitOrRollback,3959 { "commitOrRollback", "snmp.commitOrRollback",3960 FT_INT32, BASE_DEC, VALS(snmp_SOutPDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_SOutPDU_U_vals)
)))
, 0,3961 "SOutPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3962 { &hf_snmp_rRspPDU,3963 { "rRspPDU", "snmp.rRspPDU",3964 FT_INT32, BASE_DEC, VALS(snmp_RRspPDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_RRspPDU_U_vals)
)))
, 0,3965 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3966 { &hf_snmp_pDUs,3967 { "pDUs", "snmp.pDUs",3968 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,3969 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3970 { &hf_snmp_smux_simple,3971 { "smux-simple", "snmp.smux_simple_element",3972 FT_NONE, BASE_NONE, NULL((void*)0), 0,3973 "SimpleOpen", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3974 { &hf_snmp_smux_version,3975 { "smux-version", "snmp.smux_version",3976 FT_INT32, BASE_DEC, VALS(snmp_T_smux_version_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_smux_version_vals
))))
, 0,3977 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3978 { &hf_snmp_identity,3979 { "identity", "snmp.identity",3980 FT_OID, BASE_NONE, NULL((void*)0), 0,3981 "OBJECT_IDENTIFIER", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3982 { &hf_snmp_description,3983 { "description", "snmp.description",3984 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3985 "DisplayString", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3986 { &hf_snmp_password,3987 { "password", "snmp.password",3988 FT_BYTES, BASE_NONE, NULL((void*)0), 0,3989 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3990 { &hf_snmp_subtree,3991 { "subtree", "snmp.subtree",3992 FT_OID, BASE_NONE, NULL((void*)0), 0,3993 "ObjectName", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3994 { &hf_snmp_priority,3995 { "priority", "snmp.priority",3996 FT_INT32, BASE_DEC, NULL((void*)0), 0,3997 "INTEGER_M1_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},3998 { &hf_snmp_operation,3999 { "operation", "snmp.operation",4000 FT_INT32, BASE_DEC, VALS(snmp_T_operation_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_operation_vals
))))
, 0,4001 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},4002};4003 4004/* List of subtrees */4005static int *ett[] = {4006&ett_snmp,4007&ett_engineid,4008&ett_msgFlags,4009&ett_encryptedPDU,4010&ett_decrypted,4011&ett_authParameters,4012&ett_internet,4013&ett_varbind,4014&ett_name,4015&ett_value,4016&ett_decoding_error,4017 &ett_snmp_Message,4018 &ett_snmp_Messagev2u,4019 &ett_snmp_T_datav2u,4020 &ett_snmp_UsmSecurityParameters,4021 &ett_snmp_SNMPv3Message,4022 &ett_snmp_HeaderData,4023 &ett_snmp_ScopedPduData,4024 &ett_snmp_ScopedPDU,4025 &ett_snmp_PDUs,4026 &ett_snmp_PDU,4027 &ett_snmp_BulkPDU,4028 &ett_snmp_Trap_PDU_U,4029 &ett_snmp_VarBind,4030 &ett_snmp_VarBindList,4031 &ett_snmp_SMUX_PDUs,4032 &ett_snmp_RegisterResponse,4033 &ett_snmp_OpenPDU,4034 &ett_snmp_SimpleOpen_U,4035 &ett_snmp_RReqPDU_U,4036};4037static ei_register_info ei[] = {4038{ &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)}}
}},4039{ &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)}}
}},4040{ &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)}}
}},4041{ &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)}}
}},4042{ &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)}}
}},4043{ &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)}}
}},4044{ &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)}}
}},4045{ &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)}}
}},4046{ &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)}}
}},4047{ &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)}}
}},4048{ &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)}}
}},4049{ &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)}}
}},4050{ &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)}}
}},4051{ &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)}}
}},4052{ &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)}}
}},4053{ &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)}}
}},4054{ &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)}}
}},4055{ &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)}}
}},4056{ &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)}}
}},4057{ &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)}}
}},4058{ &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)}}
}},4059{ &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)}}
}},4060{ &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)}}
}},4061{ &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)}}
}},4062{ &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)}}
}},4063{ &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)}}
}},4064{ &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)}}
}},4065{ &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)}}
}},4066{ &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)}}
}},4067{ &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)}}
}},4068{ &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)}}
}},4069 4070};4071 4072expert_module_t* expert_snmp;4073module_t *snmp_module;4074 4075static uat_field_t users_fields[] = {4076UAT_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)}
,4077UAT_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)}
,4078UAT_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)}
,4079UAT_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)}
,4080UAT_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)}
,4081UAT_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)}
,4082UAT_FLD_VS(snmp_users,priv_key_exp,"Key expansion method",priv_key_exp_types,"Privacy protocol key expansion method"){"priv_key_exp", "Key expansion method", PT_TXTMOD_ENUM,{uat_fld_chk_enum
,snmp_users_priv_key_exp_set_cb,snmp_users_priv_key_exp_tostr_cb
},{&(priv_key_exp_types),&(priv_key_exp_types),&(
priv_key_exp_types)},&(priv_key_exp_types),"Privacy protocol key expansion method"
,((void*)0)}
,4083UAT_END_FIELDS{((void*)0),((void*)0),PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,((void
*)0)}
4084};4085 4086uat_t *assocs_uat = uat_new("SNMP Users",4087 sizeof(snmp_ue_assoc_t),4088 "snmp_users",4089 true1,4090 &ueas,4091 &num_ueas,4092 UAT_AFFECTS_DISSECTION0x00000001,/* affects dissection of packets, but not set of named fields */4093 "ChSNMPUsersSection",4094 snmp_users_copy_cb,4095 snmp_users_update_cb,4096 snmp_users_free_cb,4097 renew_ue_cache,4098 NULL((void*)0),4099 users_fields);4100 4101static const char *assocs_uat_defaults[] = {4102NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), "draft-reeder-snmpv3-usm-3desede-00"};4103uat_set_default_values(assocs_uat, assocs_uat_defaults);4104 4105static uat_field_t specific_traps_flds[] = {4106UAT_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)}
,4107UAT_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)}
,4108UAT_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)}
,4109UAT_END_FIELDS{((void*)0),((void*)0),PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,((void
*)0)}
4110};4111 4112uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types",4113 sizeof(snmp_st_assoc_t),4114 "snmp_specific_traps",4115 true1,4116 &specific_traps,4117 &num_specific_traps,4118 UAT_AFFECTS_DISSECTION0x00000001, /* affects dissection of packets, but not set of named fields */4119 "ChSNMPEnterpriseSpecificTrapTypes",4120 snmp_specific_trap_copy_cb,4121 NULL((void*)0),4122 snmp_specific_trap_free_cb,4123 NULL((void*)0),4124 NULL((void*)0),4125 specific_traps_flds);4126 4127/* Register protocol */4128proto_snmp = proto_register_protocol(PNAME"Simple Network Management Protocol", PSNAME"SNMP", PFNAME"snmp");4129snmp_handle = register_dissector("snmp", dissect_snmp, proto_snmp);4130 4131/* Register fields and subtrees */4132proto_register_field_array(proto_snmp, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));4133proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));4134expert_snmp = expert_register_protocol(proto_snmp);4135expert_register_field_array(expert_snmp, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0]));4136 4137/* Register dissector */4138snmp_tcp_handle = register_dissector("snmp.tcp", dissect_snmp_tcp, proto_snmp);4139 4140/* Register configuration preferences */4141snmp_module = prefs_register_protocol(proto_snmp, process_prefs);4142prefs_register_bool_preference(snmp_module, "display_oid",4143"Show SNMP OID in info column",4144"Whether the SNMP OID should be shown in the info column",4145&display_oid);4146 4147prefs_register_obsolete_preference(snmp_module, "mib_modules");4148prefs_register_obsolete_preference(snmp_module, "users_file");4149 4150prefs_register_bool_preference(snmp_module, "desegment",4151"Reassemble SNMP-over-TCP messages spanning multiple TCP segments",4152"Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."4153" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",4154&snmp_desegment);4155 4156prefs_register_bool_preference(snmp_module, "var_in_tree",4157"Display dissected variables inside SNMP tree",4158"ON - display dissected variables inside SNMP tree, OFF - display dissected variables in root tree after SNMP",4159&snmp_var_in_tree);4160 4161prefs_register_uat_preference(snmp_module, "users_table",4162"Users Table",4163"Table of engine-user associations used for authentication and decryption",4164assocs_uat);4165 4166prefs_register_uat_preference(snmp_module, "specific_traps_table",4167"Enterprise Specific Trap Types",4168"Table of enterprise specific-trap type descriptions",4169specific_traps_uat);4170 4171#ifdef HAVE_LIBSMI14172prefs_register_static_text_preference(snmp_module, "info_mibs",4173"MIB settings can be changed in the Name Resolution preferences",4174"MIB settings can be changed in the Name Resolution preferences");4175#endif4176 4177value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", proto_snmp, FT_STRING, STRING_CASE_SENSITIVE0);4178 4179register_init_routine(init_ue_cache);4180register_cleanup_routine(cleanup_ue_cache);4181 4182register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp);4183 4184snmp_tap=register_tap("snmp");4185 4186register_srt_table(proto_snmp, NULL((void*)0), 1, snmpstat_packet, snmpstat_init, NULL((void*)0));4187}4188 4189 4190/*--- proto_reg_handoff_snmp ---------------------------------------*/4191void proto_reg_handoff_snmp(void) {4192 4193dissector_add_uint_with_preference("udp.port", UDP_PORT_SNMP161, snmp_handle);4194dissector_add_uint("ethertype", ETHERTYPE_SNMP0x814C, snmp_handle);4195dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_AGENT0x900F, snmp_handle);4196dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_SINK0x9010, snmp_handle);4197dissector_add_uint("hpext.dxsap", HPEXT_SNMP0x165A, snmp_handle);4198 4199dissector_add_uint_with_preference("tcp.port", TCP_PORT_SNMP161, snmp_tcp_handle);4200/* Since "regular" SNMP port and "trap" SNMP port use the same handler,4201 the "trap" port doesn't really need a separate preference. Just register4202 normally */4203dissector_add_uint("tcp.port", TCP_PORT_SNMP_TRAP162, snmp_tcp_handle);4204dissector_add_uint("udp.port", UDP_PORT_SNMP_TRAP162, snmp_handle);4205dissector_add_uint("udp.port", UDP_PORT_SNMP_PATROL8161, snmp_handle);4206 4207data_handle = find_dissector("data");4208 4209/* SNMPv2-MIB sysDescr "1.3.6.1.2.1.1.1.0" */4210dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.1.0",4211create_dissector_handle(dissect_snmp_variable_string, proto_snmp));4212/* SNMPv2-MIB::sysName.0 (1.3.6.1.2.1.1.5.0) */4213dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.5.0",4214create_dissector_handle(dissect_snmp_variable_string, proto_snmp));4215 4216/*4217 * Process preference settings.4218 *4219 * We can't do this in the register routine, as preferences aren't4220 * read until all dissector register routines have been called (so4221 * that all dissector preferences have been registered).4222 */4223process_prefs();4224 4225}4226 4227void4228proto_register_smux(void)4229{4230static int *ett[] = {4231&ett_smux,4232};4233 4234proto_smux = proto_register_protocol("SNMP Multiplex Protocol",4235 "SMUX", "smux");4236 4237proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));4238 4239smux_handle = register_dissector("smux", dissect_smux, proto_smux);4240}4241 4242void4243proto_reg_handoff_smux(void)4244{4245dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMUX199, smux_handle);4246}4247 4248/*4249 * Editor modelines - https://www.wireshark.org/tools/modelines.html4250 *4251 * Local variables:4252 * c-basic-offset: 84253 * tab-width: 84254 * indent-tabs-mode: t4255 * End:4256 *4257 * vi: set shiftwidth=8 tabstop=8 noexpandtab:4258 * :indentSize=8:tabSize=8:noTabs=false:4259 */
/builds/wireshark/wireshark/epan/dissectors/packet-snmp.c (2024)
Top Articles
Latest Posts
Recommended Articles
Article information

Author: Ouida Strosin DO

Last Updated:

Views: 5937

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.