Bug Summary

File:builds/wireshark/wireshark/epan/dissectors/packet-snmp.c
Warning:line 3543, column 11
Assigned value is uninitialized

Annotated Source Code

Press '?' to see keyboard shortcuts

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-22/lib/clang/22 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/epan -D CARES_NO_DEPRECATED -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-22/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../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-nonliteral -std=gnu17 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -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 -faddrsig -fdwarf2-cfi-asm -o /builds/wireshark/wireshark/sbout/2026-11-04-100346-3662-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.c
7 * Routines for SNMP (simple network management protocol)
8 * Copyright (C) 1998 Didier Jorand
9 *
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 SNMPv3
17 * Updated to use the asn2wrs compiler made by Tomas Kukosa
18 * Copyright (C) 2005 - 2006 Anders Broman [AT] ericsson.com
19 *
20 * See RFC 3414 for User-based Security Model for SNMPv3
21 * See RFC 3826 for (AES) Cipher Algorithm in the SNMP USM
22 * See RFC 2578 for Structure of Management Information Version 2 (SMIv2)
23 * Copyright (C) 2007 Luis E. Garcia Ontanon <[email protected]>
24 *
25 * Wireshark - Network traffic analyzer
26 * By Gerald Combs <[email protected]>
27 * Copyright 1998 Gerald Combs
28 *
29 * Some stuff from:
30 *
31 * GXSNMP -- An snmp management application
32 * Copyright (C) 1998 Gregory McLean & Jochen Friedrich
33 * Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP group
34 *
35 * SPDX-License-Identifier: GPL-2.0-or-later
36 */
37
38#if 0
39#include <stdio.h>
40#define D(args) do {printf args; fflush(stdoutstdout); } while(0)
41#endif
42
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 UDP_PORT_SNMP161 161
67#define UDP_PORT_SNMP_TRAP162 162
68#define TCP_PORT_SNMP161 161
69#define TCP_PORT_SNMP_TRAP162 162
70#define TCP_PORT_SMUX199 199
71#define UDP_PORT_SNMP_PATROL8161 8161
72#define SNMP_NUM_PROCEDURES8 8
73
74/* Initialize the protocol and registered fields */
75static int snmp_tap;
76static int proto_snmp;
77static int proto_smux;
78
79static bool_Bool display_oid = true1;
80static bool_Bool snmp_var_in_tree = true1;
81
82void proto_register_snmp(void);
83void proto_reg_handoff_snmp(void);
84void proto_register_smux(void);
85void proto_reg_handoff_smux(void);
86
87static void snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const uint8_t *password, unsigned passwordlen,
88 const uint8_t *engineID, unsigned engineLength, uint8_t *key);
89
90static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);
91static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);
92static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);
93static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, char const**);
94
95static 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**);
96
97static const value_string auth_types[] = {
98 {SNMP_USM_AUTH_MD5,"MD5"},
99 {SNMP_USM_AUTH_SHA1,"SHA1"},
100 {SNMP_USM_AUTH_SHA2_224,"SHA2-224"},
101 {SNMP_USM_AUTH_SHA2_256,"SHA2-256"},
102 {SNMP_USM_AUTH_SHA2_384,"SHA2-384"},
103 {SNMP_USM_AUTH_SHA2_512,"SHA2-512"},
104 {0,NULL((void*)0)}
105};
106
107static const unsigned auth_hash_len[] = {
108 HASH_MD5_LENGTH16,
109 HASH_SHA1_LENGTH20,
110 HASH_SHA2_224_LENGTH28,
111 HASH_SHA2_256_LENGTH32,
112 HASH_SHA2_384_LENGTH48,
113 HASH_SHA2_512_LENGTH64
114};
115
116static const unsigned auth_tag_len[] = {
117 12,
118 12,
119 16,
120 24,
121 32,
122 48
123};
124
125static const enum gcry_md_algos auth_hash_algo[] = {
126 GCRY_MD_MD5,
127 GCRY_MD_SHA1,
128 GCRY_MD_SHA224,
129 GCRY_MD_SHA256,
130 GCRY_MD_SHA384,
131 GCRY_MD_SHA512
132};
133
134#define PRIV_DES0 0
135#define PRIV_AES1281 1
136#define PRIV_AES1922 2
137#define PRIV_AES2563 3
138
139static const value_string priv_types[] = {
140 { PRIV_DES0, "DES" },
141 { PRIV_AES1281, "AES" },
142 { PRIV_AES1922, "AES192" },
143 { PRIV_AES2563, "AES256" },
144 { 0, NULL((void*)0)}
145};
146static snmp_usm_decoder_t priv_protos[] = {
147 snmp_usm_priv_des,
148 snmp_usm_priv_aes128,
149 snmp_usm_priv_aes192,
150 snmp_usm_priv_aes256
151};
152
153#define PRIVKEYEXP_USM_3DESDESEDE_000 0
154#define PRIVKEYEXP_AGENTPP1 1
155
156static const value_string priv_key_exp_types[] = {
157 { PRIVKEYEXP_USM_3DESDESEDE_000, "draft-reeder-snmpv3-usm-3desede-00" },
158 { PRIVKEYEXP_AGENTPP1, "AGENT++" },
159 { 0, NULL((void*)0) }
160};
161
162static snmp_ue_assoc_t* ueas;
163static unsigned num_ueas;
164static snmp_ue_assoc_t* localized_ues;
165static snmp_ue_assoc_t* unlocalized_ues;
166/****/
167
168/* Variables used for handling enterprise specific trap types */
169typedef struct _snmp_st_assoc_t {
170 char *enterprise;
171 unsigned trap;
172 char *desc;
173} snmp_st_assoc_t;
174static unsigned num_specific_traps;
175static snmp_st_assoc_t *specific_traps;
176static const char *enterprise_oid;
177static unsigned generic_trap;
178static uint32_t snmp_version;
179static uint32_t RequestID = -1;
180
181static snmp_usm_params_t usm_p;
182
183#define TH_AUTH0x01 0x01
184#define TH_CRYPT0x02 0x02
185#define TH_REPORT0x04 0x04
186
187/* desegmentation of SNMP-over-TCP */
188static bool_Bool snmp_desegment = true1;
189
190/* Global variables */
191
192static uint32_t MsgSecurityModel;
193
194static dissector_handle_t snmp_handle;
195static dissector_handle_t snmp_tcp_handle;
196static dissector_handle_t data_handle;
197static dissector_handle_t smux_handle;
198
199static next_tvb_list_t *var_list;
200
201static int hf_snmp_response_in;
202static int hf_snmp_response_to;
203static int hf_snmp_time;
204
205static int hf_snmp_v3_flags_auth;
206static int hf_snmp_v3_flags_crypt;
207static int hf_snmp_v3_flags_report;
208
209static int hf_snmp_engineid_conform;
210static int hf_snmp_engineid_enterprise;
211static int hf_snmp_engineid_format;
212static int hf_snmp_engineid_ipv4;
213static int hf_snmp_engineid_ipv6;
214static int hf_snmp_engineid_cisco_type;
215static int hf_snmp_engineid_mac;
216static int hf_snmp_engineid_text;
217static int hf_snmp_engineid_time;
218static int hf_snmp_engineid_data;
219static int hf_snmp_decryptedPDU;
220static int hf_snmp_msgAuthentication;
221
222static int hf_snmp_noSuchObject;
223static int hf_snmp_noSuchInstance;
224static int hf_snmp_endOfMibView;
225static int hf_snmp_unSpecified;
226
227static int hf_snmp_integer32_value;
228static int hf_snmp_octetstring_value;
229static int hf_snmp_oid_value;
230static int hf_snmp_null_value;
231static int hf_snmp_ipv4_value;
232static int hf_snmp_ipv6_value;
233static int hf_snmp_anyaddress_value;
234static int hf_snmp_unsigned32_value;
235static int hf_snmp_unknown_value;
236static int hf_snmp_opaque_value;
237static int hf_snmp_nsap_value;
238static int hf_snmp_counter_value;
239static int hf_snmp_timeticks_value;
240static int hf_snmp_big_counter_value;
241static int hf_snmp_gauge32_value;
242
243static int hf_snmp_objectname;
244static int hf_snmp_scalar_instance_index;
245
246static int hf_snmp_var_bind_str;
247static int hf_snmp_agentid_trailer;
248
249static int hf_snmp_SMUX_PDUs_PDU; /* SMUX_PDUs */
250static int hf_snmp_version; /* Version */
251static int hf_snmp_community; /* Community */
252static int hf_snmp_data; /* PDUs */
253static int hf_snmp_parameters; /* OCTET_STRING */
254static int hf_snmp_datav2u; /* T_datav2u */
255static int hf_snmp_v2u_plaintext; /* PDUs */
256static int hf_snmp_encrypted; /* OCTET_STRING */
257static int hf_snmp_msgAuthoritativeEngineID; /* T_msgAuthoritativeEngineID */
258static int hf_snmp_msgAuthoritativeEngineBoots; /* T_msgAuthoritativeEngineBoots */
259static int hf_snmp_msgAuthoritativeEngineTime; /* T_msgAuthoritativeEngineTime */
260static int hf_snmp_msgUserName; /* T_msgUserName */
261static int hf_snmp_msgAuthenticationParameters; /* T_msgAuthenticationParameters */
262static int hf_snmp_msgPrivacyParameters; /* T_msgPrivacyParameters */
263static int hf_snmp_msgVersion; /* Version */
264static int hf_snmp_msgGlobalData; /* HeaderData */
265static int hf_snmp_msgSecurityParameters; /* T_msgSecurityParameters */
266static int hf_snmp_msgData; /* ScopedPduData */
267static int hf_snmp_msgID; /* INTEGER_0_2147483647 */
268static int hf_snmp_msgMaxSize; /* INTEGER_484_2147483647 */
269static int hf_snmp_msgFlags; /* T_msgFlags */
270static int hf_snmp_msgSecurityModel; /* T_msgSecurityModel */
271static int hf_snmp_plaintext; /* ScopedPDU */
272static int hf_snmp_encryptedPDU; /* T_encryptedPDU */
273static int hf_snmp_contextEngineID; /* SnmpEngineID */
274static int hf_snmp_contextName; /* OCTET_STRING */
275static int hf_snmp_get_request; /* GetRequest_PDU */
276static int hf_snmp_get_next_request; /* GetNextRequest_PDU */
277static int hf_snmp_get_response; /* GetResponse_PDU */
278static int hf_snmp_set_request; /* SetRequest_PDU */
279static int hf_snmp_trap; /* Trap_PDU */
280static int hf_snmp_getBulkRequest; /* GetBulkRequest_PDU */
281static int hf_snmp_informRequest; /* InformRequest_PDU */
282static int hf_snmp_snmpV2_trap; /* SNMPv2_Trap_PDU */
283static int hf_snmp_report; /* Report_PDU */
284static int hf_snmp_request_id; /* T_request_id */
285static int hf_snmp_error_status; /* T_error_status */
286static int hf_snmp_error_index; /* INTEGER */
287static int hf_snmp_variable_bindings; /* VarBindList */
288static int hf_snmp_request_id_01; /* Integer32 */
289static int hf_snmp_non_repeaters; /* INTEGER_0_2147483647 */
290static int hf_snmp_max_repetitions; /* INTEGER_0_2147483647 */
291static int hf_snmp_enterprise; /* EnterpriseOID */
292static int hf_snmp_agent_addr; /* NetworkAddress */
293static int hf_snmp_generic_trap; /* GenericTrap */
294static int hf_snmp_specific_trap; /* SpecificTrap */
295static int hf_snmp_time_stamp; /* TimeTicks */
296static int hf_snmp_name; /* ObjectName */
297static int hf_snmp_valueType; /* T_valueType */
298static int hf_snmp_VarBindList_item; /* VarBind */
299static int hf_snmp_open; /* OpenPDU */
300static int hf_snmp_close; /* ClosePDU */
301static int hf_snmp_registerRequest; /* RReqPDU */
302static int hf_snmp_registerResponse; /* RegisterResponse */
303static int hf_snmp_commitOrRollback; /* SOutPDU */
304static int hf_snmp_rRspPDU; /* RRspPDU */
305static int hf_snmp_pDUs; /* PDUs */
306static int hf_snmp_smux_simple; /* SimpleOpen */
307static int hf_snmp_smux_version; /* T_smux_version */
308static int hf_snmp_identity; /* OBJECT_IDENTIFIER */
309static int hf_snmp_description; /* DisplayString */
310static int hf_snmp_password; /* OCTET_STRING */
311static int hf_snmp_subtree; /* ObjectName */
312static int hf_snmp_priority; /* INTEGER_M1_2147483647 */
313static int hf_snmp_operation; /* T_operation */
314
315/* Initialize the subtree pointers */
316static int ett_smux;
317static int ett_snmp;
318static int ett_engineid;
319static int ett_msgFlags;
320static int ett_encryptedPDU;
321static int ett_decrypted;
322static int ett_authParameters;
323static int ett_internet;
324static int ett_varbind;
325static int ett_name;
326static int ett_value;
327static int ett_decoding_error;
328
329static int ett_snmp_Message;
330static int ett_snmp_Messagev2u;
331static int ett_snmp_T_datav2u;
332static int ett_snmp_UsmSecurityParameters;
333static int ett_snmp_SNMPv3Message;
334static int ett_snmp_HeaderData;
335static int ett_snmp_ScopedPduData;
336static int ett_snmp_ScopedPDU;
337static int ett_snmp_PDUs;
338static int ett_snmp_PDU;
339static int ett_snmp_BulkPDU;
340static int ett_snmp_Trap_PDU_U;
341static int ett_snmp_VarBind;
342static int ett_snmp_VarBindList;
343static int ett_snmp_SMUX_PDUs;
344static int ett_snmp_RegisterResponse;
345static int ett_snmp_OpenPDU;
346static int ett_snmp_SimpleOpen_U;
347static int ett_snmp_RReqPDU_U;
348
349static expert_field ei_snmp_failed_decrypted_data_pdu;
350static expert_field ei_snmp_decrypted_data_bad_formatted;
351static expert_field ei_snmp_verify_authentication_error;
352static expert_field ei_snmp_authentication_ok;
353static expert_field ei_snmp_authentication_error;
354static expert_field ei_snmp_varbind_not_uni_class_seq;
355static expert_field ei_snmp_varbind_has_indicator;
356static expert_field ei_snmp_objectname_not_oid;
357static expert_field ei_snmp_objectname_has_indicator;
358static expert_field ei_snmp_value_not_primitive_encoding;
359static expert_field ei_snmp_invalid_oid;
360static expert_field ei_snmp_varbind_wrong_tag;
361static expert_field ei_snmp_varbind_response;
362static expert_field ei_snmp_no_instance_subid;
363static expert_field ei_snmp_wrong_num_of_subids;
364static expert_field ei_snmp_index_suboid_too_short;
365static expert_field ei_snmp_unimplemented_instance_index;
366static expert_field ei_snmp_index_suboid_len0;
367static expert_field ei_snmp_index_suboid_too_long;
368static expert_field ei_snmp_index_string_too_long;
369static expert_field ei_snmp_column_parent_not_row;
370static expert_field ei_snmp_uint_too_large;
371static expert_field ei_snmp_int_too_large;
372static expert_field ei_snmp_integral_value0;
373static expert_field ei_snmp_missing_mib;
374static expert_field ei_snmp_varbind_wrong_length_value;
375static expert_field ei_snmp_varbind_wrong_class_tag;
376static expert_field ei_snmp_rfc1910_non_conformant;
377static expert_field ei_snmp_rfc3411_non_conformant;
378static expert_field ei_snmp_version_unknown;
379static expert_field ei_snmp_trap_pdu_obsolete;
380
381static const true_false_string auth_flags = {
382 "OK",
383 "Failed"
384};
385
386/* Security Models */
387
388#define SNMP_SEC_ANY0 0
389#define SNMP_SEC_V11 1
390#define SNMP_SEC_V2C2 2
391#define SNMP_SEC_USM3 3
392
393static const value_string sec_models[] = {
394 { SNMP_SEC_ANY0, "Any" },
395 { SNMP_SEC_V11, "V1" },
396 { SNMP_SEC_V2C2, "V2C" },
397 { SNMP_SEC_USM3, "USM" },
398 { 0, NULL((void*)0) }
399};
400
401#if 0
402/* SMUX PDU types */
403#define SMUX_MSG_OPEN 0
404#define SMUX_MSG_CLOSE 1
405#define SMUX_MSG_RREQ 2
406#define SMUX_MSG_RRSP 3
407#define SMUX_MSG_SOUT 4
408
409static const value_string smux_types[] = {
410 { SMUX_MSG_OPEN, "Open" },
411 { SMUX_MSG_CLOSE, "Close" },
412 { SMUX_MSG_RREQ, "Registration Request" },
413 { SMUX_MSG_RRSP, "Registration Response" },
414 { SMUX_MSG_SOUT, "Commit Or Rollback" },
415 { 0, NULL((void*)0) }
416};
417#endif
418
419/* Procedure names (used in Service Response Time) */
420static const value_string snmp_procedure_names[] = {
421 { 0, "Get" },
422 { 1, "GetNext" },
423 { 3, "Set" },
424 { 4, "Register" },
425 { 5, "Bulk" },
426 { 6, "Inform" },
427 { 0, NULL((void*)0) }
428};
429
430#define SNMP_IPA0 0 /* IP Address */
431#define SNMP_CNT1 1 /* Counter (Counter32) */
432#define SNMP_GGE2 2 /* Gauge (Gauge32) */
433#define SNMP_TIT3 3 /* TimeTicks */
434#define SNMP_OPQ4 4 /* Opaque */
435#define SNMP_NSP5 5 /* NsapAddress */
436#define SNMP_C646 6 /* Counter64 */
437#define SNMP_U327 7 /* Uinteger32 */
438
439#define SERR_NSO0 0
440#define SERR_NSI1 1
441#define SERR_EOM2 2
442
443
444static dissector_table_t value_sub_dissectors_table;
445
446/*
447 * Data structure attached to a conversation, request/response information
448 */
449typedef struct snmp_conv_info_t {
450 wmem_map_t *request_response;
451} snmp_conv_info_t;
452
453static snmp_conv_info_t*
454snmp_find_conversation_and_get_conv_data(packet_info *pinfo);
455
456static snmp_request_response_t *
457snmp_get_request_response_pointer(wmem_map_t *map, uint32_t requestId)
458{
459 snmp_request_response_t *srrp=(snmp_request_response_t *)wmem_map_lookup(map, &requestId);
460 if (!srrp) {
461 srrp=wmem_new0(wmem_file_scope(), snmp_request_response_t)((snmp_request_response_t*)wmem_alloc0((wmem_file_scope()), sizeof
(snmp_request_response_t)))
;
462 srrp->requestId=requestId;
463 wmem_map_insert(map, &(srrp->requestId), (void *)srrp);
464 }
465
466 return srrp;
467}
468
469static snmp_request_response_t*
470snmp_match_request_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned requestId, unsigned procedure_id, snmp_conv_info_t *snmp_info)
471{
472 snmp_request_response_t *srrp=NULL((void*)0);
473
474 DISSECTOR_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"
, 474, "snmp_info", "No SNMP info from ASN1 context"))))
;
475
476 /* get or create request/response pointer based on request id */
477 srrp=(snmp_request_response_t *)snmp_get_request_response_pointer(snmp_info->request_response, requestId);
478
479 // if not visited fill the request/response data
480 if (!PINFO_FD_VISITED(pinfo)((pinfo)->fd->visited)) {
481 switch(procedure_id)
482 {
483 case SNMP_REQ_GET0:
484 case SNMP_REQ_GETNEXT1:
485 case SNMP_REQ_SET3:
486 case SNMP_REQ_GETBULK5:
487 case SNMP_REQ_INFORM6:
488 srrp->request_frame_id=pinfo->fd->num;
489 srrp->response_frame_id=0;
490 srrp->request_time=pinfo->abs_ts;
491 srrp->request_procedure_id=procedure_id;
492 break;
493 case SNMP_RES_GET2:
494 srrp->response_frame_id=pinfo->fd->num;
495 break;
496 default:
497 return NULL((void*)0);
498 }
499 }
500
501 /* if request and response was matched */
502 if (srrp->request_frame_id!=0 && srrp->response_frame_id!=0)
503 {
504 proto_item *it;
505
506 // if it is the response
507 if (srrp->response_frame_id == pinfo->fd->num)
508 {
509 nstime_t ns;
510 it=proto_tree_add_uint(tree, hf_snmp_response_to, tvb, 0, 0, srrp->request_frame_id);
511 proto_item_set_generated(it);
512 nstime_delta(&ns, &pinfo->abs_ts, &srrp->request_time);
513 it=proto_tree_add_time(tree, hf_snmp_time, tvb, 0, 0, &ns);
514 proto_item_set_generated(it);
515
516 return srrp;
517 } else {
518 it=proto_tree_add_uint(tree, hf_snmp_response_in, tvb, 0, 0, srrp->response_frame_id);
519 proto_item_set_generated(it);
520 }
521 }
522
523 return NULL((void*)0);
524}
525
526static void
527snmpstat_init(struct register_srt* srt _U___attribute__((unused)), GArray* srt_array)
528{
529 srt_stat_table *snmp_srt_table;
530 uint32_t i;
531
532 snmp_srt_table = init_srt_table("SNMP Commands", NULL((void*)0), srt_array, SNMP_NUM_PROCEDURES8, NULL((void*)0), "snmp.data", NULL((void*)0));
533 for (i = 0; i < SNMP_NUM_PROCEDURES8; i++)
534 {
535 init_srt_table_row(snmp_srt_table, i, val_to_str_const(i, snmp_procedure_names, "<unknown>"));
536 }
537}
538
539/* This is called only if request and response was matched -> no need to return anything than TAP_PACKET_REDRAW */
540static tap_packet_status
541snmpstat_packet(void *psnmp, packet_info *pinfo, epan_dissect_t *edt _U___attribute__((unused)), const void *psi, tap_flags_t flags _U___attribute__((unused)))
542{
543 unsigned i = 0;
544 srt_stat_table *snmp_srt_table;
545 const snmp_request_response_t *snmp=(const snmp_request_response_t *)psi;
546 srt_data_t *data = (srt_data_t *)psnmp;
547
548 snmp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i)(((srt_stat_table**) (void *) (data->srt_array)->data) [
(i)])
;
549
550 add_srt_table_data(snmp_srt_table, snmp->request_procedure_id, &snmp->request_time, pinfo);
551 return TAP_PACKET_REDRAW;
552}
553
554static const char *
555snmp_lookup_specific_trap (unsigned specific_trap)
556{
557 unsigned i;
558
559 for (i = 0; i < num_specific_traps; i++) {
560 snmp_st_assoc_t *u = &(specific_traps[i]);
561
562 if ((u->trap == specific_trap) &&
563 (strcmp (u->enterprise, enterprise_oid) == 0))
564 {
565 return u->desc;
566 }
567 }
568
569 return NULL((void*)0);
570}
571
572static int
573dissect_snmp_variable_string(tvbuff_t *tvb, packet_info *pinfo _U___attribute__((unused)), proto_tree *tree, void *data _U___attribute__((unused)))
574{
575
576 proto_tree_add_item(tree, hf_snmp_var_bind_str, tvb, 0, -1, ENC_ASCII0x00000000);
577
578 return tvb_captured_length(tvb);
579}
580
581/*
582DateAndTime ::= TEXTUAL-CONVENTION
583 DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"
584 STATUS current
585 DESCRIPTION
586 "A date-time specification.
587
588 field octets contents range
589 ----- ------ -------- -----
590 1 1-2 year* 0..65536
591 2 3 month 1..12
592 3 4 day 1..31
593 4 5 hour 0..23
594 5 6 minutes 0..59
595 6 7 seconds 0..60
596 (use 60 for leap-second)
597 7 8 deci-seconds 0..9
598 8 9 direction from UTC '+' / '-'
599 9 10 hours from UTC* 0..13
600 10 11 minutes from UTC 0..59
601
602 * Notes:
603 - the value of year is in network-byte order
604 - daylight saving time in New Zealand is +13
605
606 For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be
607 displayed as:
608
609 1992-5-26,13:30:15.0,-4:0
610
611 Note that if only local time is known, then timezone
612 information (fields 8-10) is not present."
613 SYNTAX OCTET STRING (SIZE (8 | 11))
614*/
615static proto_item *
616dissect_snmp_variable_date_and_time(proto_tree *tree, packet_info *pinfo, int hfid, tvbuff_t *tvb, int offset, int length)
617{
618 uint16_t year;
619 uint8_t month;
620 uint8_t day;
621 uint8_t hour;
622 uint8_t minutes;
623 uint8_t seconds;
624 uint8_t deci_seconds;
625 uint8_t hour_from_utc;
626 uint8_t min_from_utc;
627 char *str;
628
629 year = tvb_get_ntohs(tvb,offset);
630 month = tvb_get_uint8(tvb,offset+2);
631 day = tvb_get_uint8(tvb,offset+3);
632 hour = tvb_get_uint8(tvb,offset+4);
633 minutes = tvb_get_uint8(tvb,offset+5);
634 seconds = tvb_get_uint8(tvb,offset+6);
635 deci_seconds = tvb_get_uint8(tvb,offset+7);
636 if(length > 8){
637 hour_from_utc = tvb_get_uint8(tvb,offset+9);
638 min_from_utc = tvb_get_uint8(tvb,offset+10);
639
640 str = wmem_strdup_printf(pinfo->pool,
641 "%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u",
642 year,
643 month,
644 day,
645 hour,
646 minutes,
647 seconds,
648 deci_seconds,
649 tvb_get_string_enc(pinfo->pool,tvb,offset+8,1,ENC_ASCII0x00000000|ENC_NA0x00000000),
650 hour_from_utc,
651 min_from_utc);
652 }else{
653 str = wmem_strdup_printf(pinfo->pool,
654 "%u-%u-%u, %u:%u:%u.%u",
655 year,
656 month,
657 day,
658 hour,
659 minutes,
660 seconds,
661 deci_seconds);
662 }
663
664 return proto_tree_add_string(tree, hfid, tvb, offset, length, str);
665
666}
667
668/*
669 * dissect_snmp_VarBind
670 * this routine dissects variable bindings, looking for the oid information in our oid repository
671 * to format and add the value adequately.
672 *
673 * The choice to handwrite this code instead of using the asn compiler is to avoid having tons
674 * of uses of global variables distributed in very different parts of the code.
675 * Other than that there's a cosmetic thing: the tree from ASN generated code would be so
676 * convoluted due to the nesting of CHOICEs in the definition of VarBind/value.
677 *
678 * XXX: the length of this function (~400 lines) is an aberration!
679 * oid_key_t:key_type could become a series of callbacks instead of an enum
680 * the (! oid_info_is_ok) switch could be made into an array (would be slower)
681 *
682
683 NetworkAddress ::= CHOICE { internet IpAddress }
684 IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))
685 TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)
686 Integer32 ::= INTEGER (-2147483648..2147483647)
687 ObjectName ::= OBJECT IDENTIFIER
688 Counter32 ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295)
689 Gauge32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)
690 Unsigned32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)
691 Integer-value ::= INTEGER (-2147483648..2147483647)
692 Integer32 ::= INTEGER (-2147483648..2147483647)
693 ObjectID-value ::= OBJECT IDENTIFIER
694 Empty ::= NULL
695 TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)
696 Opaque ::= [APPLICATION 4] IMPLICIT OCTET STRING
697 Counter64 ::= [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615)
698
699 ObjectSyntax ::= CHOICE {
700 simple SimpleSyntax,
701 application-wide ApplicationSyntax
702 }
703
704 SimpleSyntax ::= CHOICE {
705 integer-value Integer-value,
706 string-value String-value,
707 objectID-value ObjectID-value,
708 empty Empty
709 }
710
711 ApplicationSyntax ::= CHOICE {
712 ipAddress-value IpAddress,
713 counter-value Counter32,
714 timeticks-value TimeTicks,
715 arbitrary-value Opaque,
716 big-counter-value Counter64,
717 unsigned-integer-value Unsigned32
718 }
719
720 ValueType ::= CHOICE {
721 value ObjectSyntax,
722 unSpecified NULL,
723 noSuchObject[0] IMPLICIT NULL,
724 noSuchInstance[1] IMPLICIT NULL,
725 endOfMibView[2] IMPLICIT NULL
726 }
727
728 VarBind ::= SEQUENCE {
729 name ObjectName,
730 valueType ValueType
731 }
732
733 */
734
735static unsigned
736dissect_snmp_VarBind(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb, unsigned offset,
737 asn1_ctx_t *actx, proto_tree *tree, int hf_index _U___attribute__((unused)))
738{
739 int seq_offset, name_offset, value_offset, value_start;
740 uint32_t seq_len, name_len, value_len;
741 int8_t ber_class;
742 bool_Bool pc;
743 int32_t tag;
744 bool_Bool ind;
745 uint32_t* subids;
746 uint8_t* oid_bytes;
747 oid_info_t* oid_info = NULL((void*)0);
748 unsigned oid_matched, oid_left;
749 proto_item *pi_name, *pi_varbind, *pi_value = NULL((void*)0);
750 proto_tree *pt, *pt_varbind, *pt_name, *pt_value;
751 char label[ITEM_LABEL_LENGTH240];
752 const char* repr = NULL((void*)0);
753 const char* info_oid = NULL((void*)0);
754 char* valstr;
755 int hfid = -1;
756 int min_len = 0, max_len = 0;
757 bool_Bool oid_info_is_ok;
758 const char* oid_string = NULL((void*)0);
759 enum {BER_NO_ERROR, BER_WRONG_LENGTH, BER_WRONG_TAG} format_error = BER_NO_ERROR;
760
761 seq_offset = offset;
762
763 /* first have the VarBind's sequence header */
764 offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
765 offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &seq_len, &ind);
766
767 if (!pc && ber_class==BER_CLASS_UNI0 && tag==BER_UNI_TAG_SEQUENCE16) {
768 proto_item* pi;
769 pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),
770 ett_decoding_error, &pi, "VarBind must be an universal class sequence");
771 expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_not_uni_class_seq);
772 return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
773 }
774
775 if (ind) {
776 proto_item* pi;
777 pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),
778 ett_decoding_error, &pi, "Indicator must be clear in VarBind");
779 expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_has_indicator);
780 return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
781 }
782
783 /* we add the varbind tree root with a dummy label we'll fill later on */
784 pt_varbind = proto_tree_add_subtree(tree,tvb,offset,seq_len,ett_varbind,&pi_varbind,"VarBind");
785 *label = '\0';
786
787 seq_len += offset - seq_offset;
788
789 /* then we have the ObjectName's header */
790
791 offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);
792 name_offset = offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &name_len, &ind);
793
794 if (! ( !pc && ber_class==BER_CLASS_UNI0 && tag==BER_UNI_TAG_OID6) ) {
795 proto_item* pi;
796 pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,
797 ett_decoding_error, &pi, "ObjectName must be an OID in primitive encoding");
798 expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_not_oid);
799 return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
800 }
801
802 if (ind) {
803 proto_item* pi;
804 pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,
805 ett_decoding_error, &pi, "Indicator must be clear in ObjectName");
806 expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_has_indicator);
807 return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
808 }
809
810 pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,ENC_NA0x00000000);
811 pt_name = proto_item_add_subtree(pi_name,ett_name);
812
813 offset += name_len;
814 value_start = offset;
815 /* then we have the value's header */
816 offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);
817 value_offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &value_len, &ind);
818
819 if (! (!pc) ) {
820 proto_item* pi;
821 pt = proto_tree_add_subtree(pt_varbind, tvb, value_start, value_len,
822 ett_decoding_error, &pi, "the value must be in primitive encoding");
823 expert_add_info(actx->pinfo, pi, &ei_snmp_value_not_primitive_encoding);
824 return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
825 }
826
827 /* Now, we know where everything is */
828
829 /* fetch ObjectName and its relative oid_info */
830 oid_bytes = (uint8_t*)tvb_memdup(actx->pinfo->pool, tvb, name_offset, name_len);
831 oid_info = oid_get_from_encoded(actx->pinfo->pool, oid_bytes, name_len, &subids, &oid_matched, &oid_left);
832
833 add_oid_debug_subtree(oid_info,pt_name)((void)0);
834
835 if (!subids) {
836 proto_item* pi;
837
838 repr = oid_encoded2string(actx->pinfo->pool, oid_bytes, name_len);
839 pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr);
840 expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr);
841 return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt);
842 }
843
844 if (oid_matched+oid_left) {
845 oid_string = oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left);
846 }
847
848 if (ber_class == BER_CLASS_CON2) {
849 /* if we have an error value just add it and get out the way ASAP */
850 proto_item* pi;
851 const char* note;
852
853 if (value_len != 0) {
854 min_len = max_len = 0;
855 format_error = BER_WRONG_LENGTH;
856 }
857
858 switch (tag) {
859 case SERR_NSO0:
860 hfid = hf_snmp_noSuchObject;
861 note = "noSuchObject";
862 break;
863 case SERR_NSI1:
864 hfid = hf_snmp_noSuchInstance;
865 note = "noSuchInstance";
866 break;
867 case SERR_EOM2:
868 hfid = hf_snmp_endOfMibView;
869 note = "endOfMibView";
870 break;
871 default: {
872 pt = proto_tree_add_subtree_format(pt_varbind,tvb,0,0,ett_decoding_error,&pi,
873 "Wrong tag for Error Value: expected 0, 1, or 2 but got: %d",tag);
874 expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_tag);
875 return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
876 }
877 }
878
879 pi = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);
880 expert_add_info_format(actx->pinfo, pi, &ei_snmp_varbind_response, "%s",note);
881 (void) g_strlcpy (label, note, ITEM_LABEL_LENGTH240);
882 goto set_label;
883 }
884
885 /* 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 */
886 switch (oid_info->kind) {
887 case OID_KIND_SCALAR:
888 if (oid_left == 1) {
889 /* OK: we got the instance sub-id */
890 proto_tree_add_uint64(pt_name,hf_snmp_scalar_instance_index,tvb,name_offset,name_len,subids[oid_matched]);
891 oid_info_is_ok = true1;
892 goto indexing_done;
893 } else if (oid_left == 0) {
894 if (ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {
895 /* unSpecified does not require an instance sub-id add the new value and get off the way! */
896 pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);
897 goto set_label;
898 } else {
899 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_no_instance_subid,tvb,0,0);
900 oid_info_is_ok = false0;
901 goto indexing_done;
902 }
903 } else {
904 proto_tree_add_expert_format(pt_name,actx->pinfo,&ei_snmp_wrong_num_of_subids,tvb,0,0,"A scalar should have only one instance sub-id this has: %d",oid_left);
905 oid_info_is_ok = false0;
906 goto indexing_done;
907 }
908 break;
909 case OID_KIND_COLUMN:
910 if ( oid_info->parent->kind == OID_KIND_ROW) {
911 oid_key_t* k = oid_info->parent->key;
912 unsigned key_start = oid_matched;
913 unsigned key_len = oid_left;
914 oid_info_is_ok = true1;
915
916 if ( key_len == 0 && ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {
917 /* unSpecified does not require an instance sub-id add the new value and get off the way! */
918 pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);
919 goto set_label;
920 }
921
922 if (k) {
923 for (;k;k = k->next) {
924 unsigned suboid_len;
925
926 if (key_start >= oid_matched+oid_left) {
927 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_short,tvb,0,0);
928 oid_info_is_ok = false0;
929 goto indexing_done;
930 }
931
932 switch(k->key_type) {
933 case OID_KEY_TYPE_WRONG: {
934 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);
935 oid_info_is_ok = false0;
936 goto indexing_done;
937 }
938 case OID_KEY_TYPE_INTEGER: {
939 if (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))
) {
940 proto_tree_add_int(pt_name,k->hfid,tvb,name_offset,name_len,(unsigned)subids[key_start]);
941 } else { /* if it's not an unsigned int let proto_tree_add_uint throw a warning */
942 proto_tree_add_uint64(pt_name,k->hfid,tvb,name_offset,name_len,(unsigned)subids[key_start]);
943 }
944 key_start++;
945 key_len--;
946 continue; /* k->next */
947 }
948 case OID_KEY_TYPE_IMPLIED_OID:
949 suboid_len = key_len;
950
951 goto show_oid_index;
952
953 case OID_KEY_TYPE_OID: {
954 uint8_t* suboid_buf;
955 unsigned suboid_buf_len;
956 uint32_t* suboid;
957
958 suboid_len = subids[key_start++];
959 key_len--;
960
961show_oid_index:
962 suboid = &(subids[key_start]);
963
964 if( suboid_len == 0 ) {
965 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_len0,tvb,0,0);
966 oid_info_is_ok = false0;
967 goto indexing_done;
968 }
969
970 if( key_len < suboid_len ) {
971 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_long,tvb,0,0);
972 oid_info_is_ok = false0;
973 goto indexing_done;
974 }
975
976 suboid_buf_len = oid_subid2encoded(actx->pinfo->pool, suboid_len, suboid, &suboid_buf);
977
978 DISSECTOR_ASSERT(suboid_buf_len)((void) ((suboid_buf_len) ? (void)0 : (proto_report_dissector_bug
("%s:%u: failed assertion \"%s\"", "epan/dissectors/packet-snmp.c"
, 978, "suboid_buf_len"))))
;
979
980 proto_tree_add_oid(pt_name,k->hfid,tvb,name_offset, suboid_buf_len, suboid_buf);
981
982 key_start += suboid_len;
983 key_len -= suboid_len + 1;
984 continue; /* k->next */
985 }
986 default: {
987 uint8_t* buf;
988 unsigned buf_len;
989 uint32_t* suboid;
990 unsigned i;
991
992
993 switch (k->key_type) {
994 case OID_KEY_TYPE_IPADDR:
995 suboid = &(subids[key_start]);
996 buf_len = 4;
997 break;
998 case OID_KEY_TYPE_IMPLIED_STRING:
999 case OID_KEY_TYPE_IMPLIED_BYTES:
1000 case OID_KEY_TYPE_ETHER:
1001 suboid = &(subids[key_start]);
1002 buf_len = key_len;
1003 break;
1004 default:
1005 buf_len = k->num_subids;
1006 suboid = &(subids[key_start]);
1007
1008 if(!buf_len) {
1009 buf_len = *suboid++;
1010 key_len--;
1011 key_start++;
1012 }
1013 break;
1014 }
1015
1016 if( key_len < buf_len ) {
1017 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_string_too_long,tvb,0,0);
1018 oid_info_is_ok = false0;
1019 goto indexing_done;
1020 }
1021
1022 buf = (uint8_t*)wmem_alloc(actx->pinfo->pool, buf_len+1);
1023 for (i = 0; i < buf_len; i++)
1024 buf[i] = (uint8_t)suboid[i];
1025 buf[i] = '\0';
1026
1027 switch(k->key_type) {
1028 case OID_KEY_TYPE_STRING:
1029 case OID_KEY_TYPE_IMPLIED_STRING:
1030 proto_tree_add_string(pt_name,k->hfid,tvb,name_offset,buf_len, (char*)buf);
1031 break;
1032 case OID_KEY_TYPE_BYTES:
1033 case OID_KEY_TYPE_NSAP:
1034 case OID_KEY_TYPE_IMPLIED_BYTES:
1035 proto_tree_add_bytes(pt_name,k->hfid,tvb,name_offset,buf_len, buf);
1036 break;
1037 case OID_KEY_TYPE_ETHER:
1038 proto_tree_add_ether(pt_name,k->hfid,tvb,name_offset,buf_len, buf);
1039 break;
1040 case OID_KEY_TYPE_IPADDR: {
1041 uint32_t* ipv4_p = (uint32_t*)buf;
1042 proto_tree_add_ipv4(pt_name,k->hfid,tvb,name_offset,buf_len, *ipv4_p);
1043 }
1044 break;
1045 default:
1046 DISSECTOR_ASSERT_NOT_REACHED()(proto_report_dissector_bug("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\""
, "epan/dissectors/packet-snmp.c", 1046))
;
1047 break;
1048 }
1049
1050 key_start += buf_len;
1051 key_len -= buf_len;
1052 continue; /* k->next*/
1053 }
1054 }
1055 }
1056 goto indexing_done;
1057 } else {
1058 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);
1059 oid_info_is_ok = false0;
1060 goto indexing_done;
1061 }
1062 } else {
1063 proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_column_parent_not_row,tvb,0,0);
1064 oid_info_is_ok = false0;
1065 goto indexing_done;
1066 }
1067 default: {
1068/* proto_tree_add_expert (pt_name,actx->pinfo,PI_MALFORMED, PI_WARN,tvb,0,0,"This kind OID should have no value"); */
1069 oid_info_is_ok = false0;
1070 goto indexing_done;
1071 }
1072 }
1073indexing_done:
1074
1075 if (oid_info_is_ok && oid_info->value_type) {
1076 if (ber_class == BER_CLASS_UNI0 && tag == BER_UNI_TAG_NULL5) {
1077 pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA0x00000000);
1078 } else {
1079 /* Provide a tree_item to attach errors to, if needed. */
1080 pi_value = pi_name;
1081
1082 if ((oid_info->value_type->ber_class != BER_CLASS_ANY99) &&
1083 (ber_class != oid_info->value_type->ber_class))
1084 format_error = BER_WRONG_TAG;
1085 else if ((oid_info->value_type->ber_tag != BER_TAG_ANY-1) &&
1086 (tag != oid_info->value_type->ber_tag))
1087 format_error = BER_WRONG_TAG;
1088 else {
1089 max_len = oid_info->value_type->max_len == -1 ? 0xffffff : oid_info->value_type->max_len;
1090 min_len = oid_info->value_type->min_len;
1091
1092 if ((int)value_len < min_len || (int)value_len > max_len)
1093 format_error = BER_WRONG_LENGTH;
1094 }
1095
1096 if (format_error == BER_NO_ERROR) {
1097 /* Special case DATE AND TIME */
1098 if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){
1099 pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, oid_info->value_hfid, tvb, value_offset, value_len);
1100 } else {
1101 pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);
1102 }
1103 }
1104 }
1105 } else {
1106 switch(ber_class|(tag<<4)) {
1107 case BER_CLASS_UNI0|(BER_UNI_TAG_INTEGER2<<4):
1108 {
1109 int64_t val=0;
1110 unsigned int int_val_offset = value_offset;
1111 unsigned int i;
1112
1113 max_len = 4; min_len = 1;
1114 if (value_len > (unsigned)max_len || value_len < (unsigned)min_len) {
1115 hfid = hf_snmp_integer32_value;
1116 format_error = BER_WRONG_LENGTH;
1117 break;
1118 }
1119
1120 if(value_len > 0) {
1121 /* extend sign bit */
1122 if(tvb_get_uint8(tvb, int_val_offset)&0x80) {
1123 val=-1;
1124 }
1125 for(i=0;i<value_len;i++) {
1126 val=(val<<8)|tvb_get_uint8(tvb, int_val_offset);
1127 int_val_offset++;
1128 }
1129 }
1130 pi_value = proto_tree_add_int64(pt_varbind, hf_snmp_integer32_value, tvb,value_offset,value_len, val);
1131
1132 goto already_added;
1133 }
1134 case BER_CLASS_UNI0|(BER_UNI_TAG_OCTETSTRING4<<4):
1135 if(oid_info->value_hfid> -1){
1136 hfid = oid_info->value_hfid;
1137 }else{
1138 hfid = hf_snmp_octetstring_value;
1139 }
1140 break;
1141 case BER_CLASS_UNI0|(BER_UNI_TAG_OID6<<4):
1142 max_len = -1; min_len = 1;
1143 if (value_len < (unsigned)min_len) format_error = BER_WRONG_LENGTH;
1144 hfid = hf_snmp_oid_value;
1145 break;
1146 case BER_CLASS_UNI0|(BER_UNI_TAG_NULL5<<4):
1147 max_len = 0; min_len = 0;
1148 if (value_len != 0) format_error = BER_WRONG_LENGTH;
1149 hfid = hf_snmp_null_value;
1150 break;
1151 case BER_CLASS_APP1: /* | (SNMP_IPA<<4)*/
1152 switch(value_len) {
1153 case 4: hfid = hf_snmp_ipv4_value; break;
1154 case 16: hfid = hf_snmp_ipv6_value; break;
1155 default: hfid = hf_snmp_anyaddress_value; break;
1156 }
1157 break;
1158 case BER_CLASS_APP1|(SNMP_U327<<4):
1159 hfid = hf_snmp_unsigned32_value;
1160 break;
1161 case BER_CLASS_APP1|(SNMP_GGE2<<4):
1162 hfid = hf_snmp_gauge32_value;
1163 break;
1164 case BER_CLASS_APP1|(SNMP_CNT1<<4):
1165 hfid = hf_snmp_counter_value;
1166 break;
1167 case BER_CLASS_APP1|(SNMP_TIT3<<4):
1168 hfid = hf_snmp_timeticks_value;
1169 break;
1170 case BER_CLASS_APP1|(SNMP_OPQ4<<4):
1171 hfid = hf_snmp_opaque_value;
1172 break;
1173 case BER_CLASS_APP1|(SNMP_NSP5<<4):
1174 hfid = hf_snmp_nsap_value;
1175 break;
1176 case BER_CLASS_APP1|(SNMP_C646<<4):
1177 hfid = hf_snmp_big_counter_value;
1178 break;
1179 default:
1180 hfid = hf_snmp_unknown_value;
1181 break;
1182 }
1183 if (value_len > 8) {
1184 /*
1185 * Too long for an FT_UINT64 or an FT_INT64.
1186 */
1187 header_field_info *hfinfo = proto_registrar_get_nth(hfid);
1188 if (hfinfo->type == FT_UINT64) {
1189 /*
1190 * Check if this is an unsigned int64 with
1191 * a big value.
1192 */
1193 if (value_len > 9 || tvb_get_uint8(tvb, value_offset) != 0) {
1194 /* It is. Fail. */
1195 proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_uint_too_large,tvb,value_offset,value_len,"Integral value too large");
1196 goto already_added;
1197 }
1198 /* Cheat and skip the leading 0 byte */
1199 value_len--;
1200 value_offset++;
1201 } else if (hfinfo->type == FT_INT64) {
1202 /*
1203 * For now, just reject these.
1204 */
1205 proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_int_too_large,tvb,value_offset,value_len,"Integral value too large or too small");
1206 goto already_added;
1207 }
1208 } else if (value_len == 0) {
1209 /*
1210 * X.690 section 8.3.1 "Encoding of an integer value":
1211 * "The encoding of an integer value shall be
1212 * primitive. The contents octets shall consist of
1213 * one or more octets."
1214 *
1215 * Zero is not "one or more".
1216 */
1217 header_field_info *hfinfo = proto_registrar_get_nth(hfid);
1218 if (hfinfo->type == FT_UINT64 || hfinfo->type == FT_INT64) {
1219 proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_integral_value0,tvb,value_offset,value_len,"Integral value is zero-length");
1220 goto already_added;
1221 }
1222 }
1223 /* Special case DATE AND TIME */
1224 if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){
1225 pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, hfid, tvb, value_offset, value_len);
1226 }else{
1227 pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN0x00000000);
1228 }
1229 if (format_error != BER_NO_ERROR) {
1230 expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib);
1231 }
1232
1233 }
1234already_added:
1235 pt_value = proto_item_add_subtree(pi_value,ett_value);
1236
1237 if (value_len > 0 && oid_string) {
1238 tvbuff_t* sub_tvb = tvb_new_subset_length(tvb, value_offset, value_len);
1239
1240 next_tvb_add_string(var_list, sub_tvb, (snmp_var_in_tree) ? pt_value : NULL((void*)0), value_sub_dissectors_table, oid_string);
1241 }
1242
1243
1244set_label:
1245 if (pi_value) proto_item_fill_label(PITEM_FINFO(pi_value)((pi_value)->finfo), label, NULL((void*)0));
1246
1247 if (oid_info && oid_info->name) {
1248 if (oid_left >= 1) {
1249 repr = wmem_strdup_printf(actx->pinfo->pool, "%s.%s (%s)", oid_info->name,
1250 oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left),
1251 oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left));
1252 info_oid = wmem_strdup_printf(actx->pinfo->pool, "%s.%s", oid_info->name,
1253 oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left));
1254 } else {
1255 repr = wmem_strdup_printf(actx->pinfo->pool, "%s (%s)", oid_info->name,
1256 oid_subid2string(actx->pinfo->pool, subids,oid_matched));
1257 info_oid = oid_info->name;
1258 }
1259 } else if (oid_string) {
1260 repr = wmem_strdup(actx->pinfo->pool, oid_string);
1261 info_oid = oid_string;
1262 } else {
1263 repr = wmem_strdup(actx->pinfo->pool, "[Bad OID]");
1264 }
1265
1266 valstr = strstr(label,": ");
1267 valstr = valstr ? valstr+2 : label;
1268
1269 proto_item_set_text(pi_varbind,"%s: %s",repr,valstr);
1270
1271 if (display_oid && info_oid) {
1272 col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", info_oid);
1273 }
1274
1275 switch (format_error) {
1276 case BER_WRONG_LENGTH: {
1277 proto_item* pi;
1278 proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);
1279 pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,
1280 "Wrong value length: %u expecting: %u <= len <= %u",
1281 value_len, min_len, max_len == -1 ? 0xFFFFFF : max_len);
1282 expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_length_value);
1283 return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
1284 }
1285 case BER_WRONG_TAG: {
1286 proto_item* pi;
1287 proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);
1288 pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,
1289 "Wrong class/tag for Value expected: %d,%d got: %d,%d",
1290 oid_info->value_type->ber_class, oid_info->value_type->ber_tag,
1291 ber_class, tag);
1292 expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_class_tag);
1293 return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
1294 }
1295 default:
1296 break;
1297 }
1298
1299 return seq_offset + seq_len;
1300}
1301
1302
1303#define F_SNMP_ENGINEID_CONFORM0x80 0x80
1304#define SNMP_ENGINEID_RFC19100x00 0x00
1305#define SNMP_ENGINEID_RFC34110x01 0x01
1306
1307static const true_false_string tfs_snmp_engineid_conform = {
1308 "RFC3411 (SNMPv3)",
1309 "RFC1910 (Non-SNMPv3)"
1310};
1311
1312#define SNMP_ENGINEID_FORMAT_IPV40x01 0x01
1313#define SNMP_ENGINEID_FORMAT_IPV60x02 0x02
1314#define SNMP_ENGINEID_FORMAT_MACADDRESS0x03 0x03
1315#define SNMP_ENGINEID_FORMAT_TEXT0x04 0x04
1316#define SNMP_ENGINEID_FORMAT_OCTETS0x05 0x05
1317#define SNMP_ENGINEID_FORMAT_LOCAL0x06 0x06
1318
1319static const value_string snmp_engineid_format_vals[] = {
1320 { SNMP_ENGINEID_FORMAT_IPV40x01, "IPv4 address" },
1321 { SNMP_ENGINEID_FORMAT_IPV60x02, "IPv6 address" },
1322 { SNMP_ENGINEID_FORMAT_MACADDRESS0x03, "MAC address" },
1323 { SNMP_ENGINEID_FORMAT_TEXT0x04, "Text, administratively assigned" },
1324 { SNMP_ENGINEID_FORMAT_OCTETS0x05, "Octets, administratively assigned" },
1325 { SNMP_ENGINEID_FORMAT_LOCAL0x06, "Local engine" },
1326 { 0, NULL((void*)0) }
1327};
1328
1329#define SNMP_ENGINEID_CISCO_AGENT0x00 0x00
1330#define SNMP_ENGINEID_CISCO_MANAGER0x01 0x01
1331
1332static const value_string snmp_engineid_cisco_type_vals[] = {
1333 { SNMP_ENGINEID_CISCO_AGENT0x00, "Agent" },
1334 { SNMP_ENGINEID_CISCO_MANAGER0x01, "Manager" },
1335 { 0, NULL((void*)0) }
1336};
1337
1338/*
1339 * SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)
1340 * or historic RFC 1910 (AgentID)
1341 */
1342int
1343dissect_snmp_engineid(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, int len)
1344{
1345 proto_item *item = NULL((void*)0);
1346 uint8_t conformance, format;
1347 uint32_t enterpriseid;
1348 time_t seconds;
1349 nstime_t ts;
1350 int len_remain = len;
1351
1352 /* first bit: engine id conformance */
1353 if (len_remain<1) return offset;
1354 conformance = ((tvb_get_uint8(tvb, offset)>>7) & 0x01);
1355 proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1356
1357 /* 4-byte enterprise number/name */
1358 if (len_remain<4) return offset;
1359 enterpriseid = tvb_get_ntohl(tvb, offset);
1360 if (conformance)
1361 enterpriseid -= 0x80000000; /* ignore first bit */
1362 proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);
1363 offset+=4;
1364 len_remain-=4;
1365
1366 switch(conformance) {
1367
1368 case SNMP_ENGINEID_RFC19100x00:
1369 /* 12-byte AgentID w/ 8-byte trailer */
1370 if (len_remain==8) {
1371 proto_tree_add_item(tree, hf_snmp_agentid_trailer, tvb, offset, 8, ENC_NA0x00000000);
1372 offset+=8;
1373 len_remain-=8;
1374 } else {
1375 proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain);
1376 return offset;
1377 }
1378 break;
1379
1380 case SNMP_ENGINEID_RFC34110x01: /* variable length: 5..32 */
1381
1382 /* 1-byte format specifier */
1383 if (len_remain<1) return offset;
1384 format = tvb_get_uint8(tvb, offset);
1385 item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)",
1386 val_to_str_const(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"),
1387 format);
1388 offset+=1;
1389 len_remain-=1;
1390
1391 switch(format) {
1392 case SNMP_ENGINEID_FORMAT_IPV40x01:
1393 /* 4-byte IPv4 address */
1394 if (len_remain==4) {
1395 proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
1396 offset+=4;
1397 len_remain=0;
1398 }
1399 break;
1400 case SNMP_ENGINEID_FORMAT_IPV60x02:
1401 /* 16-byte IPv6 address */
1402 if (len_remain==16) {
1403 proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA0x00000000);
1404 offset+=16;
1405 len_remain=0;
1406 }
1407 break;
1408 case SNMP_ENGINEID_FORMAT_MACADDRESS0x03:
1409 /* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */
1410 if ((enterpriseid==9)&&(len_remain==7)) {
1411 proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
1412 offset++;
1413 len_remain--;
1414 }
1415 /* 6-byte MAC address */
1416 if (len_remain==6) {
1417 proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_NA0x00000000);
1418 offset+=6;
1419 len_remain=0;
1420 }
1421 break;
1422 case SNMP_ENGINEID_FORMAT_TEXT0x04:
1423 /* max. 27-byte string, administratively assigned */
1424 if (len_remain<=27) {
1425 proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII0x00000000);
1426 offset+=len_remain;
1427 len_remain=0;
1428 }
1429 break;
1430 case SNMP_ENGINEID_FORMAT_LOCAL0x06:
1431 break;
1432 case 128:
1433 /* most common enterprise-specific format: (ucd|net)-snmp random */
1434 if ((enterpriseid==2021)||(enterpriseid==8072)) {
1435 proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");
1436 /* demystify: 4B random, 4B/8B epoch seconds */
1437 if ((len_remain==8) || (len_remain==12)) {
1438 proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA0x00000000);
1439 if (len_remain==8) {
1440 seconds = (time_t)tvb_get_letohl(tvb, offset + 4);
1441 } else {
1442 seconds = (time_t)tvb_get_letohi64(tvb, offset + 4);
1443 }
1444 ts.secs = seconds;
1445 ts.nsecs = 0;
1446 proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset + 4, len_remain - 4,
1447 &ts, "%s",
1448 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)
);
1449 offset+=len_remain;
1450 len_remain=0;
1451 }
1452 break;
1453 }
1454 /* fall through */
1455 case SNMP_ENGINEID_FORMAT_OCTETS0x05:
1456 default:
1457 /* max. 27 bytes, administratively assigned or unknown format */
1458 if (len_remain>0 && len_remain<=27) {
1459 proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA0x00000000);
1460 offset+=len_remain;
1461 len_remain=0;
1462 }
1463 break;
1464 }
1465 }
1466
1467 if (len_remain>0) {
1468 proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain);
1469 offset+=len_remain;
1470 }
1471 return offset;
1472}
1473
1474
1475static void set_ue_keys(snmp_ue_assoc_t* n ) {
1476 unsigned const key_size = auth_hash_len[n->user.authModel];
1477
1478 n->user.authKey.data = (uint8_t *)g_malloc(key_size);
1479 n->user.authKey.len = key_size;
1480 snmp_usm_password_to_key(n->user.authModel,
1481 n->user.authPassword.data,
1482 n->user.authPassword.len,
1483 n->engine.data,
1484 n->engine.len,
1485 n->user.authKey.data);
1486
1487 if (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
1488 unsigned need_key_len =
1489 (n->priv_proto
19.1
Field 'priv_proto' is not equal to PRIV_AES128
== PRIV_AES1281) ? 16 :
1490 (n->priv_proto
19.2
Field 'priv_proto' is not equal to PRIV_AES192
== PRIV_AES1922) ? 24 :
1491 (n->priv_proto
19.3
Field 'priv_proto' is equal to PRIV_AES256
== PRIV_AES2563) ? 32 :
20
'?' condition is true
1492 0;
1493
1494 unsigned key_len = key_size;
1495
1496 while (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 1499
1497 key_len += key_size;
1498
1499 n->user.privKey.data = (uint8_t *)g_malloc(key_len);
25
Storing uninitialized value
1500 n->user.privKey.len = need_key_len;
1501
1502 snmp_usm_password_to_key(n->user.authModel,
26
Calling 'snmp_usm_password_to_key'
30
Returning from 'snmp_usm_password_to_key'
1503 n->user.privPassword.data,
1504 n->user.privPassword.len,
1505 n->engine.data,
1506 n->engine.len,
1507 n->user.privKey.data);
1508
1509 key_len = key_size;
1510
1511 /* extend key if needed */
1512 while (key_len
30.1
'key_len' is < 'need_key_len'
< need_key_len) {
31
Loop condition is true. Entering loop body
1513 switch (n->priv_key_exp) {
32
Control jumps to 'case 0:' at line 1515
1514 /* Baed on draft-reeder-snmpv3-usm-3desede-00, section 2.1 */
1515 case PRIVKEYEXP_USM_3DESDESEDE_000:
1516 {
1517 snmp_usm_password_to_key(n->user.authModel,
33
Calling 'snmp_usm_password_to_key'
1518 n->user.privKey.data + (key_len - key_size),
1519 key_size,
1520 n->engine.data,
1521 n->engine.len,
1522 n->user.privKey.data + key_len);
1523 break;
1524 }
1525 /* Based on snmp++ method PrivAES::extend_short_key in Agent++ */
1526 case PRIVKEYEXP_AGENTPP1:
1527 {
1528 /* Key expansion in Agent++
1529 * K1 = key
1530 * K2 = hash(K1)
1531 * K3 = hash(K1 | K2)
1532 * localized_key = K1 | K2 | K3
1533 */
1534 gcry_md_hd_t hash_handle;
1535
1536 if (gcry_md_open(&hash_handle, auth_hash_algo[n->user.authModel], 0)) {
1537 return;
1538 }
1539
1540 gcry_md_write(hash_handle, n->user.privKey.data, key_len);
1541 memcpy(n->user.privKey.data + key_len, gcry_md_read(hash_handle, 0), key_size);
1542 gcry_md_close(hash_handle);
1543
1544 break;
1545 }
1546
1547 default:
1548 break;
1549 }
1550
1551 key_len += key_size;
1552 }
1553
1554 } else {
1555 n->user.privKey.data = (uint8_t *)g_malloc(key_size);
1556 n->user.privKey.len = key_size;
1557 snmp_usm_password_to_key(n->user.authModel,
1558 n->user.privPassword.data,
1559 n->user.privPassword.len,
1560 n->engine.data,
1561 n->engine.len,
1562 n->user.privKey.data);
1563 }
1564}
1565
1566static snmp_ue_assoc_t*
1567ue_dup(snmp_ue_assoc_t* o)
1568{
1569 snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));
1570
1571 d->user.authModel = o->user.authModel;
1572
1573 d->user.privProtocol = o->user.privProtocol;
1574
1575 d->user.userName.data = (uint8_t *)g_memdup2(o->user.userName.data,o->user.userName.len);
1576 d->user.userName.len = o->user.userName.len;
1577
1578 d->user.authPassword.data = o->user.authPassword.data ? (uint8_t *)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL((void*)0);
1579 d->user.authPassword.len = o->user.authPassword.len;
1580
1581 d->user.privPassword.data = o->user.privPassword.data ? (uint8_t *)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL((void*)0);
1582 d->user.privPassword.len = o->user.privPassword.len;
1583
1584 d->engine.len = o->engine.len;
1585
1586 if (d->engine.len) {
1587 d->engine.data = (uint8_t *)g_memdup2(o->engine.data,o->engine.len);
1588 set_ue_keys(d);
1589 }
1590
1591 return d;
1592
1593}
1594
1595static void*
1596snmp_users_copy_cb(void* dest, const void* orig, size_t len _U___attribute__((unused)))
1597{
1598 const snmp_ue_assoc_t* o = (const snmp_ue_assoc_t*)orig;
1599 snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)dest;
1600
1601 d->auth_model = o->auth_model;
1602 d->user.authModel = (snmp_usm_auth_model_t) o->auth_model;
1603
1604 d->priv_proto = o->priv_proto;
1605 d->user.privProtocol = priv_protos[o->priv_proto];
1606
1607 d->user.userName.data = (uint8_t*)g_memdup2(o->user.userName.data,o->user.userName.len);
1608 d->user.userName.len = o->user.userName.len;
1609
1610 d->user.authPassword.data = o->user.authPassword.data ? (uint8_t*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL((void*)0);
1611 d->user.authPassword.len = o->user.authPassword.len;
1612
1613 d->user.privPassword.data = o->user.privPassword.data ? (uint8_t*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL((void*)0);
1614 d->user.privPassword.len = o->user.privPassword.len;
1615
1616 d->engine.len = o->engine.len;
1617 if (o->engine.data) {
1618 d->engine.data = (uint8_t*)g_memdup2(o->engine.data,o->engine.len);
1619 }
1620
1621 d->user.authKey.data = o->user.authKey.data ? (uint8_t*)g_memdup2(o->user.authKey.data,o->user.authKey.len) : NULL((void*)0);
1622 d->user.authKey.len = o->user.authKey.len;
1623
1624 d->user.privKey.data = o->user.privKey.data ? (uint8_t*)g_memdup2(o->user.privKey.data,o->user.privKey.len) : NULL((void*)0);
1625 d->user.privKey.len = o->user.privKey.len;
1626
1627 return d;
1628}
1629
1630static void
1631snmp_users_free_cb(void* p)
1632{
1633 snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
1634 g_free(ue->user.userName.data)(__builtin_object_size ((ue->user.userName.data), 0) != ((
size_t) - 1)) ? g_free_sized (ue->user.userName.data, __builtin_object_size
((ue->user.userName.data), 0)) : (g_free) (ue->user.userName
.data)
;
1635 g_free(ue->user.authPassword.data)(__builtin_object_size ((ue->user.authPassword.data), 0) !=
((size_t) - 1)) ? g_free_sized (ue->user.authPassword.data
, __builtin_object_size ((ue->user.authPassword.data), 0))
: (g_free) (ue->user.authPassword.data)
;
1636 g_free(ue->user.privPassword.data)(__builtin_object_size ((ue->user.privPassword.data), 0) !=
((size_t) - 1)) ? g_free_sized (ue->user.privPassword.data
, __builtin_object_size ((ue->user.privPassword.data), 0))
: (g_free) (ue->user.privPassword.data)
;
1637 g_free(ue->user.authKey.data)(__builtin_object_size ((ue->user.authKey.data), 0) != ((size_t
) - 1)) ? g_free_sized (ue->user.authKey.data, __builtin_object_size
((ue->user.authKey.data), 0)) : (g_free) (ue->user.authKey
.data)
;
1638 g_free(ue->user.privKey.data)(__builtin_object_size ((ue->user.privKey.data), 0) != ((size_t
) - 1)) ? g_free_sized (ue->user.privKey.data, __builtin_object_size
((ue->user.privKey.data), 0)) : (g_free) (ue->user.privKey
.data)
;
1639 g_free(ue->engine.data)(__builtin_object_size ((ue->engine.data), 0) != ((size_t)
- 1)) ? g_free_sized (ue->engine.data, __builtin_object_size
((ue->engine.data), 0)) : (g_free) (ue->engine.data)
;
1640}
1641
1642static bool_Bool
1643snmp_users_update_cb(void* p _U___attribute__((unused)), char** err)
1644{
1645 snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
1646 GString* es = g_string_new("");
1647 unsigned int i;
1648
1649 *err = NULL((void*)0);
1650
1651 if (! ue->user.userName.len) {
1652 g_string_append_printf(es,"no userName\n");
1653 } else if ((ue->engine.len > 0) && (ue->engine.len < 5 || ue->engine.len > 32)) {
1654 /* RFC 3411 section 5 */
1655 g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", ue->engine.len);
1656 } else if (num_ueas) {
1657 for (i=0; i<num_ueas-1; i++) {
1658 snmp_ue_assoc_t* u = &(ueas[i]);
1659
1660 if ( u->user.userName.len == ue->user.userName.len
1661 && u->engine.len == ue->engine.len && (u != ue)) {
1662
1663 if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {
1664 if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
1665 /* XXX: make a string for the engineId */
1666 g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
1667 break;
1668 }
1669 }
1670
1671 if (u->engine.len == 0) {
1672 if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
1673 g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
1674 break;
1675 }
1676 }
1677 }
1678 }
1679 }
1680
1681 if (es->len) {
1682 es = g_string_truncate(es,es->len-1)g_string_truncate_inline (es, es->len-1);
1683 *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))))
;
1684 return false0;
1685 }
1686
1687 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)))))
;
1688 return true1;
1689}
1690
1691static void
1692free_ue_cache(snmp_ue_assoc_t **cache)
1693{
1694 static snmp_ue_assoc_t *a, *nxt;
1695
1696 for (a = *cache; a; a = nxt) {
1697 nxt = a->next;
1698 snmp_users_free_cb(a);
1699 g_free(a)(__builtin_object_size ((a), 0) != ((size_t) - 1)) ? g_free_sized
(a, __builtin_object_size ((a), 0)) : (g_free) (a)
;
1700 }
1701
1702 *cache = NULL((void*)0);
1703}
1704
1705#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); }
1706
1707static void
1708init_ue_cache(void)
1709{
1710 unsigned i;
1711
1712 for (i = 0; i < num_ueas; i++) {
1713 snmp_ue_assoc_t* a = ue_dup(&(ueas[i]));
1714
1715 if (a->engine.len) {
1716 CACHE_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); }
;
1717
1718 } else {
1719 CACHE_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); }
;
1720 }
1721
1722 }
1723}
1724
1725static void
1726cleanup_ue_cache(void)
1727{
1728 free_ue_cache(&localized_ues);
1729 free_ue_cache(&unlocalized_ues);
1730}
1731
1732/* Called when the user applies changes to UAT preferences. */
1733static void
1734renew_ue_cache(void)
1735{
1736 cleanup_ue_cache();
1737 init_ue_cache();
1738}
1739
1740
1741static snmp_ue_assoc_t*
1742localize_ue( snmp_ue_assoc_t* o, const uint8_t* engine, unsigned engine_len )
1743{
1744 snmp_ue_assoc_t* n = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));
1745
1746 n->user.userName.data = (uint8_t*)g_memdup2(o->user.userName.data,o->user.userName.len);
1747 n->user.authModel = o->user.authModel;
1748 n->user.authPassword.data = (uint8_t*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len);
1749 n->user.authPassword.len = o->user.authPassword.len;
1750 n->user.privPassword.data = (uint8_t*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len);
1751 n->user.privPassword.len = o->user.privPassword.len;
1752 n->user.authKey.data = (uint8_t*)g_memdup2(o->user.authKey.data,o->user.authKey.len);
1753 n->user.privKey.data = (uint8_t*)g_memdup2(o->user.privKey.data,o->user.privKey.len);
1754 n->engine.data = (uint8_t*)g_memdup2(engine,engine_len);
1755 n->engine.len = engine_len;
1756 n->priv_proto = o->priv_proto;
1757
1758 set_ue_keys(n);
16
Calling 'set_ue_keys'
1759
1760 return n;
1761}
1762
1763
1764#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 )
\
1765 ( a->user.userName.len == ul \
1766 && a->engine.len == el \
1767 && memcmp( a->user.userName.data, u, ul ) == 0 \
1768 && memcmp( a->engine.data, e, el ) == 0 )
1769
1770#define unlocalized_match(a,u,l)( a->user.userName.len == l && memcmp( a->user.
userName.data, u, l) == 0 )
\
1771 ( a->user.userName.len == l && memcmp( a->user.userName.data, u, l) == 0 )
1772
1773static snmp_ue_assoc_t*
1774get_user_assoc(tvbuff_t* engine_tvb, tvbuff_t* user_tvb, packet_info *pinfo)
1775{
1776 static snmp_ue_assoc_t* a;
1777 unsigned given_username_len;
1778 uint8_t* given_username;
1779 unsigned given_engine_len = 0;
1780 uint8_t* given_engine = NULL((void*)0);
1781
1782 if ( ! (localized_ues || unlocalized_ues ) ) return NULL((void*)0);
3
Assuming 'localized_ues' is non-null
1783
1784 if (! ( 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
1785
1786 given_username_len = tvb_captured_length(user_tvb);
1787 given_engine_len = tvb_captured_length(engine_tvb);
1788 if (! ( 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
1789 given_username = (uint8_t*)tvb_memdup(pinfo->pool, user_tvb, 0, given_username_len);
1790 given_engine = (uint8_t*)tvb_memdup(pinfo->pool, engine_tvb, 0, given_engine_len);
1791
1792 for (a = localized_ues; a; a = a->next) {
10
Loop condition is false. Execution continues on line 1798
1793 if ( 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 )
) {
1794 return a;
1795 }
1796 }
1797
1798 for (a = unlocalized_ues; a; a = a->next) {
1799 if ( 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
1800 snmp_ue_assoc_t* n = localize_ue( a, given_engine, given_engine_len );
15
Calling 'localize_ue'
1801 CACHE_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); }
;
1802 return n;
1803 }
1804 }
1805
1806 return NULL((void*)0);
1807}
1808
1809static bool_Bool
1810snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, uint8_t** calc_auth_p,
1811 unsigned* calc_auth_len_p, char const** error)
1812{
1813 int msg_len;
1814 uint8_t* msg;
1815 unsigned auth_len;
1816 uint8_t* auth;
1817 uint8_t* key;
1818 unsigned key_len;
1819 uint8_t *calc_auth;
1820 unsigned start;
1821 unsigned end;
1822 unsigned i;
1823
1824 if (!p->auth_tvb) {
1825 *error = "No Authenticator";
1826 return false0;
1827 }
1828
1829 key = p->user_assoc->user.authKey.data;
1830 key_len = p->user_assoc->user.authKey.len;
1831
1832 if (! key ) {
1833 *error = "User has no authKey";
1834 return false0;
1835 }
1836
1837 auth_len = tvb_captured_length(p->auth_tvb);
1838
1839 if (auth_len != auth_tag_len[model]) {
1840 *error = "Authenticator length wrong";
1841 return false0;
1842 }
1843
1844 msg_len = tvb_captured_length(p->msg_tvb);
1845 if (msg_len <= 0) {
1846 *error = "Not enough data remaining";
1847 return false0;
1848 }
1849 msg = (uint8_t*)tvb_memdup(pinfo->pool,p->msg_tvb,0,msg_len);
1850
1851 auth = (uint8_t*)tvb_memdup(pinfo->pool,p->auth_tvb,0,auth_len);
1852
1853 start = p->auth_offset - p->start_offset;
1854 end = start + auth_len;
1855
1856 /* fill the authenticator with zeros */
1857 for ( i = start ; i < end ; i++ ) {
1858 msg[i] = '\0';
1859 }
1860
1861 calc_auth = (uint8_t*)wmem_alloc(pinfo->pool, auth_hash_len[model]);
1862
1863 if (ws_hmac_buffer(auth_hash_algo[model], calc_auth, msg, msg_len, key, key_len)) {
1864 return false0;
1865 }
1866
1867 if (calc_auth_p) *calc_auth_p = calc_auth;
1868 if (calc_auth_len_p) *calc_auth_len_p = auth_len;
1869
1870 return ( memcmp(auth,calc_auth,auth_len) != 0 ) ? false0 : true1;
1871}
1872
1873static tvbuff_t*
1874snmp_usm_priv_des(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)
1875{
1876 gcry_error_t err;
1877 gcry_cipher_hd_t hd = NULL((void*)0);
1878
1879 uint8_t* cleartext;
1880 uint8_t* des_key = p->user_assoc->user.privKey.data; /* first 8 bytes */
1881 uint8_t* pre_iv = &(p->user_assoc->user.privKey.data[8]); /* last 8 bytes */
1882 uint8_t* salt;
1883 int salt_len;
1884 int cryptgrm_len;
1885 uint8_t* cryptgrm;
1886 tvbuff_t* clear_tvb;
1887 uint8_t iv[8];
1888 unsigned i;
1889
1890
1891 salt_len = tvb_captured_length(p->priv_tvb);
1892
1893 if (salt_len != 8) {
1894 *error = "decryptionError: msgPrivacyParameters length != 8";
1895 return NULL((void*)0);
1896 }
1897
1898 salt = (uint8_t*)tvb_memdup(pinfo->pool,p->priv_tvb,0,salt_len);
1899
1900 /*
1901 The resulting "salt" is XOR-ed with the pre-IV to obtain the IV.
1902 */
1903 for (i=0; i<8; i++) {
1904 iv[i] = pre_iv[i] ^ salt[i];
1905 }
1906
1907 cryptgrm_len = tvb_captured_length(encryptedData);
1908
1909 if ((cryptgrm_len <= 0) || (cryptgrm_len % 8)) {
1910 *error = "decryptionError: the length of the encrypted data is not a multiple of 8 octets";
1911 return NULL((void*)0);
1912 }
1913
1914 cryptgrm = (uint8_t*)tvb_memdup(pinfo->pool, encryptedData, 0, cryptgrm_len);
1915
1916 cleartext = (uint8_t*)wmem_alloc(pinfo->pool, cryptgrm_len);
1917
1918 err = gcry_cipher_open(&hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_CBC, 0);
1919 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1920
1921 err = gcry_cipher_setiv(hd, iv, 8);
1922 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1923
1924 err = gcry_cipher_setkey(hd,des_key,8);
1925 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1926
1927 err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);
1928 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1929
1930 gcry_cipher_close(hd);
1931
1932 clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
1933
1934 return clear_tvb;
1935
1936on_gcry_error:
1937 *error = (const char *)gcry_strerror(err);
1938 if (hd) gcry_cipher_close(hd);
1939 return NULL((void*)0);
1940}
1941
1942static tvbuff_t*
1943snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error, int algo)
1944{
1945 gcry_error_t err;
1946 gcry_cipher_hd_t hd = NULL((void*)0);
1947
1948 uint8_t* cleartext;
1949 uint8_t* aes_key = p->user_assoc->user.privKey.data;
1950 int aes_key_len = p->user_assoc->user.privKey.len;
1951 uint8_t iv[16];
1952 int priv_len;
1953 int cryptgrm_len;
1954 uint8_t* cryptgrm;
1955 tvbuff_t* clear_tvb;
1956
1957 priv_len = tvb_captured_length(p->priv_tvb);
1958
1959 if (priv_len != 8) {
1960 *error = "decryptionError: msgPrivacyParameters length != 8";
1961 return NULL((void*)0);
1962 }
1963
1964 iv[0] = (p->boots & 0xff000000) >> 24;
1965 iv[1] = (p->boots & 0x00ff0000) >> 16;
1966 iv[2] = (p->boots & 0x0000ff00) >> 8;
1967 iv[3] = (p->boots & 0x000000ff);
1968 iv[4] = (p->snmp_time & 0xff000000) >> 24;
1969 iv[5] = (p->snmp_time & 0x00ff0000) >> 16;
1970 iv[6] = (p->snmp_time & 0x0000ff00) >> 8;
1971 iv[7] = (p->snmp_time & 0x000000ff);
1972 tvb_memcpy(p->priv_tvb,&(iv[8]),0,8);
1973
1974 cryptgrm_len = tvb_captured_length(encryptedData);
1975 if (cryptgrm_len <= 0) {
1976 *error = "Not enough data remaining";
1977 return NULL((void*)0);
1978 }
1979 cryptgrm = (uint8_t*)tvb_memdup(pinfo->pool, encryptedData, 0, cryptgrm_len);
1980
1981 cleartext = (uint8_t*)wmem_alloc(pinfo->pool, cryptgrm_len);
1982
1983 err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);
1984 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1985
1986 err = gcry_cipher_setiv(hd, iv, 16);
1987 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1988
1989 err = gcry_cipher_setkey(hd,aes_key,aes_key_len);
1990 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1991
1992 err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);
1993 if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
1994
1995 gcry_cipher_close(hd);
1996
1997 clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
1998
1999 return clear_tvb;
2000
2001on_gcry_error:
2002 *error = (const char *)gcry_strerror(err);
2003 if (hd) gcry_cipher_close(hd);
2004 return NULL((void*)0);
2005}
2006
2007static tvbuff_t*
2008snmp_usm_priv_aes128(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)
2009{
2010 return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES);
2011}
2012
2013static tvbuff_t*
2014snmp_usm_priv_aes192(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)
2015{
2016 return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES192);
2017}
2018
2019static tvbuff_t*
2020snmp_usm_priv_aes256(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, char const** error)
2021{
2022 return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES256);
2023}
2024
2025static bool_Bool
2026check_ScopedPdu(tvbuff_t* tvb)
2027{
2028 int offset;
2029 int8_t ber_class;
2030 bool_Bool pc;
2031 int32_t tag;
2032 int hoffset, eoffset;
2033 uint32_t len;
2034
2035 offset = get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);
2036 offset = get_ber_length(tvb, offset, NULL((void*)0), NULL((void*)0));
2037
2038 if ( ! (((ber_class!=BER_CLASS_APP1) && (ber_class!=BER_CLASS_PRI3) )
2039 && ( (!pc) || (ber_class!=BER_CLASS_UNI0) || (tag!=BER_UNI_TAG_ENUMERATED10) )
2040 )) return false0;
2041
2042 if((tvb_get_uint8(tvb, offset)==0)&&(tvb_get_uint8(tvb, offset+1)==0))
2043 return true1;
2044
2045 hoffset = offset;
2046
2047 offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
2048 offset = get_ber_length(tvb, offset, &len, NULL((void*)0));
2049 eoffset = offset + len;
2050
2051 if (eoffset <= hoffset) return false0;
2052
2053 if ((ber_class!=BER_CLASS_APP1)&&(ber_class!=BER_CLASS_PRI3))
2054 if( (ber_class!=BER_CLASS_UNI0)
2055 ||((tag<BER_UNI_TAG_NumericString18)&&(tag!=BER_UNI_TAG_OCTETSTRING4)&&(tag!=BER_UNI_TAG_UTF8String12)) )
2056 return false0;
2057
2058 return true1;
2059
2060}
2061
2062
2063
2064
2065static unsigned
2066dissect_snmp_EnterpriseOID(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2067 const char* name;
2068
2069 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &enterprise_oid);
2070
2071
2072 if (display_oid && enterprise_oid) {
2073 name = oid_resolved_from_string(actx->pinfo->pool, enterprise_oid);
2074 if (name) {
2075 col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", name);
2076 }
2077 }
2078
2079
2080 return offset;
2081}
2082
2083
2084
2085static unsigned
2086dissect_snmp_OCTET_STRING_SIZE_4(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2087 offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset,
2088 4, 4, hf_index, NULL((void*)0));
2089
2090 return offset;
2091}
2092
2093
2094
2095static unsigned
2096dissect_snmp_NetworkAddress(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2097 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2098 hf_index, BER_CLASS_APP1, 0, true1, dissect_snmp_OCTET_STRING_SIZE_4);
2099
2100 return offset;
2101}
2102
2103
2104
2105static unsigned
2106dissect_snmp_INTEGER_0_4294967295(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2107 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2108 0U, 4294967295U, hf_index, NULL((void*)0));
2109
2110 return offset;
2111}
2112
2113
2114
2115static unsigned
2116dissect_snmp_TimeTicks(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2117 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2118 hf_index, BER_CLASS_APP1, 3, true1, dissect_snmp_INTEGER_0_4294967295);
2119
2120 return offset;
2121}
2122
2123
2124
2125static unsigned
2126dissect_snmp_Integer32(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2127
2128 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2129 INT32_MIN(-2147483647-1), 2147483647U, hf_index, &RequestID);
2130
2131
2132
2133 return offset;
2134}
2135
2136
2137
2138static unsigned
2139dissect_snmp_ObjectName(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2140 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL((void*)0));
2141
2142 return offset;
2143}
2144
2145
2146static const value_string snmp_Version_vals[] = {
2147 { 0, "version-1" },
2148 { 1, "v2c" },
2149 { 2, "v2u" },
2150 { 3, "snmpv3" },
2151 { 0, NULL((void*)0) }
2152};
2153
2154
2155static unsigned
2156dissect_snmp_Version(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2157 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2158 &snmp_version);
2159
2160 return offset;
2161}
2162
2163
2164
2165static unsigned
2166dissect_snmp_Community(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2167 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2168 NULL((void*)0));
2169
2170 return offset;
2171}
2172
2173
2174
2175static unsigned
2176dissect_snmp_T_request_id(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2177
2178 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2179 &RequestID);
2180
2181
2182
2183 return offset;
2184}
2185
2186
2187static const value_string snmp_T_error_status_vals[] = {
2188 { 0, "noError" },
2189 { 1, "tooBig" },
2190 { 2, "noSuchName" },
2191 { 3, "badValue" },
2192 { 4, "readOnly" },
2193 { 5, "genErr" },
2194 { 6, "noAccess" },
2195 { 7, "wrongType" },
2196 { 8, "wrongLength" },
2197 { 9, "wrongEncoding" },
2198 { 10, "wrongValue" },
2199 { 11, "noCreation" },
2200 { 12, "inconsistentValue" },
2201 { 13, "resourceUnavailable" },
2202 { 14, "commitFailed" },
2203 { 15, "undoFailed" },
2204 { 16, "authorizationError" },
2205 { 17, "notWritable" },
2206 { 18, "inconsistentName" },
2207 { 0, NULL((void*)0) }
2208};
2209
2210
2211static unsigned
2212dissect_snmp_T_error_status(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2213 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2214 NULL((void*)0));
2215
2216 return offset;
2217}
2218
2219
2220
2221static unsigned
2222dissect_snmp_INTEGER(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2223 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2224 NULL((void*)0));
2225
2226 return offset;
2227}
2228
2229
2230
2231
2232static const ber_sequence_t VarBindList_sequence_of[1] = {
2233 { &hf_snmp_VarBindList_item, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBind },
2234};
2235
2236static unsigned
2237dissect_snmp_VarBindList(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2238 offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2239 VarBindList_sequence_of, hf_index, ett_snmp_VarBindList);
2240
2241 return offset;
2242}
2243
2244
2245static const ber_sequence_t PDU_sequence[] = {
2246 { &hf_snmp_request_id , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_request_id },
2247 { &hf_snmp_error_status , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_error_status },
2248 { &hf_snmp_error_index , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER },
2249 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },
2250 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2251};
2252
2253static unsigned
2254dissect_snmp_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2255 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2256 PDU_sequence, hf_index, ett_snmp_PDU);
2257
2258 return offset;
2259}
2260
2261
2262
2263static unsigned
2264dissect_snmp_GetRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2265 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2266 hf_index, BER_CLASS_CON2, 0, true1, dissect_snmp_PDU);
2267
2268 return offset;
2269}
2270
2271
2272
2273static unsigned
2274dissect_snmp_GetNextRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2275 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2276 hf_index, BER_CLASS_CON2, 1, true1, dissect_snmp_PDU);
2277
2278 return offset;
2279}
2280
2281
2282
2283static unsigned
2284dissect_snmp_GetResponse_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2285 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2286 hf_index, BER_CLASS_CON2, 2, true1, dissect_snmp_PDU);
2287
2288 return offset;
2289}
2290
2291
2292
2293static unsigned
2294dissect_snmp_SetRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2295 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2296 hf_index, BER_CLASS_CON2, 3, true1, dissect_snmp_PDU);
2297
2298 return offset;
2299}
2300
2301
2302static const value_string snmp_GenericTrap_vals[] = {
2303 { 0, "coldStart" },
2304 { 1, "warmStart" },
2305 { 2, "linkDown" },
2306 { 3, "linkUp" },
2307 { 4, "authenticationFailure" },
2308 { 5, "egpNeighborLoss" },
2309 { 6, "enterpriseSpecific" },
2310 { 0, NULL((void*)0) }
2311};
2312
2313
2314static unsigned
2315dissect_snmp_GenericTrap(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2316 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2317 &generic_trap);
2318
2319 return offset;
2320}
2321
2322
2323
2324static unsigned
2325dissect_snmp_SpecificTrap(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2326 unsigned specific_trap;
2327
2328 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2329 &specific_trap);
2330
2331
2332 if (generic_trap == 6) { /* enterprise specific */
2333 const char *specific_str = snmp_lookup_specific_trap (specific_trap);
2334 if (specific_str) {
2335 proto_item_append_text(actx->created_item, " (%s)", specific_str);
2336 }
2337 }
2338
2339 return offset;
2340}
2341
2342
2343static const ber_sequence_t Trap_PDU_U_sequence[] = {
2344 { &hf_snmp_enterprise , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_EnterpriseOID },
2345 { &hf_snmp_agent_addr , BER_CLASS_APP1, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_NetworkAddress },
2346 { &hf_snmp_generic_trap , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GenericTrap },
2347 { &hf_snmp_specific_trap , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SpecificTrap },
2348 { &hf_snmp_time_stamp , BER_CLASS_APP1, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_TimeTicks },
2349 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },
2350 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2351};
2352
2353static unsigned
2354dissect_snmp_Trap_PDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2355 generic_trap = 0;
2356 enterprise_oid = NULL((void*)0);
2357
2358 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2359 Trap_PDU_U_sequence, hf_index, ett_snmp_Trap_PDU_U);
2360
2361
2362 if (snmp_version != 0) {
2363 expert_add_info(actx->pinfo, tree, &ei_snmp_trap_pdu_obsolete);
2364 }
2365
2366
2367 return offset;
2368}
2369
2370
2371
2372static unsigned
2373dissect_snmp_Trap_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2374 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2375 hf_index, BER_CLASS_CON2, 4, true1, dissect_snmp_Trap_PDU_U);
2376
2377 return offset;
2378}
2379
2380
2381
2382static unsigned
2383dissect_snmp_INTEGER_0_2147483647(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2384 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2385 0U, 2147483647U, hf_index, NULL((void*)0));
2386
2387 return offset;
2388}
2389
2390
2391static const ber_sequence_t BulkPDU_sequence[] = {
2392 { &hf_snmp_request_id_01 , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Integer32 },
2393 { &hf_snmp_non_repeaters , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },
2394 { &hf_snmp_max_repetitions, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },
2395 { &hf_snmp_variable_bindings, BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_VarBindList },
2396 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2397};
2398
2399static unsigned
2400dissect_snmp_BulkPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2401 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2402 BulkPDU_sequence, hf_index, ett_snmp_BulkPDU);
2403
2404 return offset;
2405}
2406
2407
2408
2409static unsigned
2410dissect_snmp_GetBulkRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2411 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2412 hf_index, BER_CLASS_CON2, 5, true1, dissect_snmp_BulkPDU);
2413
2414 return offset;
2415}
2416
2417
2418
2419static unsigned
2420dissect_snmp_InformRequest_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2421 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2422 hf_index, BER_CLASS_CON2, 6, true1, dissect_snmp_PDU);
2423
2424 return offset;
2425}
2426
2427
2428
2429static unsigned
2430dissect_snmp_SNMPv2_Trap_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2431 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2432 hf_index, BER_CLASS_CON2, 7, true1, dissect_snmp_PDU);
2433
2434 return offset;
2435}
2436
2437
2438
2439static unsigned
2440dissect_snmp_Report_PDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2441 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2442 hf_index, BER_CLASS_CON2, 8, true1, dissect_snmp_PDU);
2443
2444 return offset;
2445}
2446
2447
2448static const value_string snmp_PDUs_vals[] = {
2449 { 0, "get-request" },
2450 { 1, "get-next-request" },
2451 { 2, "get-response" },
2452 { 3, "set-request" },
2453 { 4, "trap" },
2454 { 5, "getBulkRequest" },
2455 { 6, "informRequest" },
2456 { 7, "snmpV2-trap" },
2457 { 8, "report" },
2458 { 0, NULL((void*)0) }
2459};
2460
2461static const ber_choice_t PDUs_choice[] = {
2462 { 0, &hf_snmp_get_request , BER_CLASS_CON2, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetRequest_PDU },
2463 { 1, &hf_snmp_get_next_request, BER_CLASS_CON2, 1, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetNextRequest_PDU },
2464 { 2, &hf_snmp_get_response , BER_CLASS_CON2, 2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetResponse_PDU },
2465 { 3, &hf_snmp_set_request , BER_CLASS_CON2, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SetRequest_PDU },
2466 { 4, &hf_snmp_trap , BER_CLASS_CON2, 4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Trap_PDU },
2467 { 5, &hf_snmp_getBulkRequest , BER_CLASS_CON2, 5, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_GetBulkRequest_PDU },
2468 { 6, &hf_snmp_informRequest , BER_CLASS_CON2, 6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_InformRequest_PDU },
2469 { 7, &hf_snmp_snmpV2_trap , BER_CLASS_CON2, 7, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SNMPv2_Trap_PDU },
2470 { 8, &hf_snmp_report , BER_CLASS_CON2, 8, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Report_PDU },
2471 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2472};
2473
2474static unsigned
2475dissect_snmp_PDUs(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2476 int pdu_type=-1;
2477
2478 snmp_request_response_t *srrp;
2479 snmp_conv_info_t *snmp_info = (snmp_conv_info_t *)actx->private_data;
2480
2481 col_clear(actx->pinfo->cinfo, COL_INFO);
2482
2483 offset = dissect_ber_choice(actx, tree, tvb, offset,
2484 PDUs_choice, hf_index, ett_snmp_PDUs,
2485 &pdu_type);
2486
2487 if( (pdu_type!=-1) && snmp_PDUs_vals[pdu_type].strptr ){
2488 col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%s", snmp_PDUs_vals[pdu_type].strptr);
2489
2490 /* pdu_type is the index, not the tag so convert it to the tag value */
2491 pdu_type = snmp_PDUs_vals[pdu_type].value;
2492
2493 srrp=snmp_match_request_response(tvb, actx->pinfo, tree, RequestID, pdu_type, snmp_info);
2494 if (srrp) {
2495 tap_queue_packet(snmp_tap, actx->pinfo, srrp);
2496 }
2497 }
2498
2499
2500
2501 return offset;
2502}
2503
2504
2505static const ber_sequence_t Message_sequence[] = {
2506 { &hf_snmp_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },
2507 { &hf_snmp_community , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Community },
2508 { &hf_snmp_data , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_PDUs },
2509 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2510};
2511
2512static unsigned
2513dissect_snmp_Message(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2514 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2515 Message_sequence, hf_index, ett_snmp_Message);
2516
2517 return offset;
2518}
2519
2520
2521
2522static unsigned
2523dissect_snmp_OCTET_STRING(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2524 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2525 NULL((void*)0));
2526
2527 return offset;
2528}
2529
2530
2531static const value_string snmp_T_datav2u_vals[] = {
2532 { 0, "plaintext" },
2533 { 1, "encrypted" },
2534 { 0, NULL((void*)0) }
2535};
2536
2537static const ber_choice_t T_datav2u_choice[] = {
2538 { 0, &hf_snmp_v2u_plaintext , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_PDUs },
2539 { 1, &hf_snmp_encrypted , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },
2540 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2541};
2542
2543static unsigned
2544dissect_snmp_T_datav2u(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2545 offset = dissect_ber_choice(actx, tree, tvb, offset,
2546 T_datav2u_choice, hf_index, ett_snmp_T_datav2u,
2547 NULL((void*)0));
2548
2549 return offset;
2550}
2551
2552
2553static const ber_sequence_t Messagev2u_sequence[] = {
2554 { &hf_snmp_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },
2555 { &hf_snmp_parameters , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },
2556 { &hf_snmp_datav2u , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_T_datav2u },
2557 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2558};
2559
2560static unsigned
2561dissect_snmp_Messagev2u(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2562 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2563 Messagev2u_sequence, hf_index, ett_snmp_Messagev2u);
2564
2565 return offset;
2566}
2567
2568
2569
2570static unsigned
2571dissect_snmp_SnmpEngineID(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2572 tvbuff_t* param_tvb = NULL((void*)0);
2573
2574 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &param_tvb);
2575 if (param_tvb) {
2576 proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);
2577 dissect_snmp_engineid(engine_tree, actx->pinfo, param_tvb, 0, tvb_reported_length_remaining(param_tvb,0));
2578 }
2579
2580
2581 return offset;
2582}
2583
2584
2585
2586static unsigned
2587dissect_snmp_T_msgAuthoritativeEngineID(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2588
2589 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &usm_p.engine_tvb);
2590 if (usm_p.engine_tvb) {
2591 proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);
2592 dissect_snmp_engineid(engine_tree, actx->pinfo, usm_p.engine_tvb, 0, tvb_reported_length_remaining(usm_p.engine_tvb,0));
2593 }
2594
2595
2596 return offset;
2597}
2598
2599
2600
2601static unsigned
2602dissect_snmp_T_msgAuthoritativeEngineBoots(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2603 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2604 0U, 2147483647U, hf_index, &usm_p.boots);
2605
2606 return offset;
2607}
2608
2609
2610
2611static unsigned
2612dissect_snmp_T_msgAuthoritativeEngineTime(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2613 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2614 0U, 2147483647U, hf_index, &usm_p.snmp_time);
2615
2616 return offset;
2617}
2618
2619
2620
2621static unsigned
2622dissect_snmp_T_msgUserName(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2623 offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset,
2624 1, 32, hf_index, &usm_p.user_tvb);
2625
2626 return offset;
2627}
2628
2629
2630
2631static unsigned
2632dissect_snmp_T_msgAuthenticationParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2633 offset = dissect_ber_octet_string(false0, actx, tree, tvb, offset, hf_index, &usm_p.auth_tvb);
2634 if (usm_p.auth_tvb) {
2635 usm_p.auth_item = actx->created_item;
2636 usm_p.auth_offset = tvb_offset_from_real_beginning(usm_p.auth_tvb);
2637 }
2638
2639 return offset;
2640}
2641
2642
2643
2644static unsigned
2645dissect_snmp_T_msgPrivacyParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2646 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2647 &usm_p.priv_tvb);
2648
2649 return offset;
2650}
2651
2652
2653static const ber_sequence_t UsmSecurityParameters_sequence[] = {
2654 { &hf_snmp_msgAuthoritativeEngineID, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineID },
2655 { &hf_snmp_msgAuthoritativeEngineBoots, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineBoots },
2656 { &hf_snmp_msgAuthoritativeEngineTime, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthoritativeEngineTime },
2657 { &hf_snmp_msgUserName , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgUserName },
2658 { &hf_snmp_msgAuthenticationParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgAuthenticationParameters },
2659 { &hf_snmp_msgPrivacyParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgPrivacyParameters },
2660 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2661};
2662
2663static unsigned
2664dissect_snmp_UsmSecurityParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2665 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2666 UsmSecurityParameters_sequence, hf_index, ett_snmp_UsmSecurityParameters);
2667
2668 return offset;
2669}
2670
2671
2672
2673static unsigned
2674dissect_snmp_INTEGER_484_2147483647(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2675 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2676 484U, 2147483647U, hf_index, NULL((void*)0));
2677
2678 return offset;
2679}
2680
2681
2682
2683static unsigned
2684dissect_snmp_T_msgFlags(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2685 tvbuff_t *parameter_tvb = NULL((void*)0);
2686
2687 offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset,
2688 1, 1, hf_index, &parameter_tvb);
2689
2690 if (parameter_tvb){
2691 uint8_t v3_flags = tvb_get_uint8(parameter_tvb, 0);
2692 proto_tree* flags_tree = proto_item_add_subtree(actx->created_item,ett_msgFlags);
2693
2694 proto_tree_add_item(flags_tree, hf_snmp_v3_flags_report, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);
2695 proto_tree_add_item(flags_tree, hf_snmp_v3_flags_crypt, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);
2696 proto_tree_add_item(flags_tree, hf_snmp_v3_flags_auth, parameter_tvb, 0, 1, ENC_BIG_ENDIAN0x00000000);
2697
2698 usm_p.encrypted = v3_flags & TH_CRYPT0x02 ? true1 : false0;
2699 usm_p.authenticated = v3_flags & TH_AUTH0x01 ? true1 : false0;
2700 }
2701
2702
2703
2704 return offset;
2705}
2706
2707
2708
2709static unsigned
2710dissect_snmp_T_msgSecurityModel(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2711 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
2712 1U, 2147483647U, hf_index, &MsgSecurityModel);
2713
2714 return offset;
2715}
2716
2717
2718static const ber_sequence_t HeaderData_sequence[] = {
2719 { &hf_snmp_msgID , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_0_2147483647 },
2720 { &hf_snmp_msgMaxSize , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_484_2147483647 },
2721 { &hf_snmp_msgFlags , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgFlags },
2722 { &hf_snmp_msgSecurityModel, BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgSecurityModel },
2723 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2724};
2725
2726static unsigned
2727dissect_snmp_HeaderData(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2728 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2729 HeaderData_sequence, hf_index, ett_snmp_HeaderData);
2730
2731 return offset;
2732}
2733
2734
2735
2736static unsigned
2737dissect_snmp_T_msgSecurityParameters(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2738
2739 switch(MsgSecurityModel){
1
Control jumps to 'case 3:' at line 2740
2740 case SNMP_SEC_USM3: /* 3 */
2741 offset = get_ber_identifier(tvb, offset, NULL((void*)0), NULL((void*)0), NULL((void*)0));
2742 offset = get_ber_length(tvb, offset, NULL((void*)0), NULL((void*)0));
2743 offset = dissect_snmp_UsmSecurityParameters(false0, tvb, offset, actx, tree, -1);
2744 usm_p.user_assoc = get_user_assoc(usm_p.engine_tvb, usm_p.user_tvb, actx->pinfo);
2
Calling 'get_user_assoc'
2745 break;
2746 case SNMP_SEC_ANY0: /* 0 */
2747 case SNMP_SEC_V11: /* 1 */
2748 case SNMP_SEC_V2C2: /* 2 */
2749 default:
2750 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2751 NULL((void*)0));
2752
2753 break;
2754 }
2755
2756
2757 return offset;
2758}
2759
2760
2761static const ber_sequence_t ScopedPDU_sequence[] = {
2762 { &hf_snmp_contextEngineID, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SnmpEngineID },
2763 { &hf_snmp_contextName , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },
2764 { &hf_snmp_data , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_PDUs },
2765 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2766};
2767
2768static unsigned
2769dissect_snmp_ScopedPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2770 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2771 ScopedPDU_sequence, hf_index, ett_snmp_ScopedPDU);
2772
2773 return offset;
2774}
2775
2776
2777
2778static unsigned
2779dissect_snmp_T_encryptedPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2780 tvbuff_t* crypt_tvb;
2781 offset = dissect_ber_octet_string(false0, actx, tree, tvb, offset, hf_snmp_encryptedPDU, &crypt_tvb);
2782
2783 if( usm_p.encrypted && crypt_tvb
2784 && usm_p.user_assoc
2785 && usm_p.user_assoc->user.privProtocol ) {
2786
2787 const char* error = NULL((void*)0);
2788 proto_tree* encryptedpdu_tree = proto_item_add_subtree(actx->created_item,ett_encryptedPDU);
2789 tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, actx->pinfo, &error );
2790
2791 if (! cleartext_tvb) {
2792 proto_tree_add_expert_format_remaining(encryptedpdu_tree, actx->pinfo, &ei_snmp_failed_decrypted_data_pdu,
2793 crypt_tvb, 0, "Failed to decrypt encryptedPDU: %s", error);
2794
2795 col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");
2796
2797 return offset;
2798 } else {
2799 proto_item* decrypted_item;
2800 proto_tree* decrypted_tree;
2801
2802 if (! check_ScopedPdu(cleartext_tvb)) {
2803 proto_tree_add_expert_remaining(encryptedpdu_tree, actx->pinfo, &ei_snmp_decrypted_data_bad_formatted, cleartext_tvb, 0);
2804
2805 col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");
2806
2807 return offset;
2808 }
2809
2810
2811 add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");
2812
2813 decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,ENC_NA0x00000000);
2814 decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);
2815 dissect_snmp_ScopedPDU(false0, cleartext_tvb, 0, actx, decrypted_tree, -1);
2816 }
2817 } else {
2818 col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: privKey Unknown");
2819 }
2820
2821
2822 return offset;
2823}
2824
2825
2826static const value_string snmp_ScopedPduData_vals[] = {
2827 { 0, "plaintext" },
2828 { 1, "encryptedPDU" },
2829 { 0, NULL((void*)0) }
2830};
2831
2832static const ber_choice_t ScopedPduData_choice[] = {
2833 { 0, &hf_snmp_plaintext , BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ScopedPDU },
2834 { 1, &hf_snmp_encryptedPDU , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_encryptedPDU },
2835 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2836};
2837
2838static unsigned
2839dissect_snmp_ScopedPduData(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2840 offset = dissect_ber_choice(actx, tree, tvb, offset,
2841 ScopedPduData_choice, hf_index, ett_snmp_ScopedPduData,
2842 NULL((void*)0));
2843
2844 return offset;
2845}
2846
2847
2848static const ber_sequence_t SNMPv3Message_sequence[] = {
2849 { &hf_snmp_msgVersion , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_Version },
2850 { &hf_snmp_msgGlobalData , BER_CLASS_UNI0, BER_UNI_TAG_SEQUENCE16, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_HeaderData },
2851 { &hf_snmp_msgSecurityParameters, BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_msgSecurityParameters },
2852 { &hf_snmp_msgData , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004|BER_FLAGS_NOTCHKTAG0x00000008, dissect_snmp_ScopedPduData },
2853 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2854};
2855
2856static unsigned
2857dissect_snmp_SNMPv3Message(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2858 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2859 SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);
2860
2861
2862 if( usm_p.authenticated
2863 && usm_p.user_assoc ) {
2864 const char* error = NULL((void*)0);
2865 proto_item* authen_item;
2866 proto_tree* authen_tree = proto_item_add_subtree(usm_p.auth_item,ett_authParameters);
2867 uint8_t* calc_auth = NULL((void*)0);
2868 unsigned calc_auth_len = 0;
2869
2870 usm_p.authOK = snmp_usm_auth(actx->pinfo, usm_p.user_assoc->user.authModel, &usm_p, &calc_auth, &calc_auth_len, &error );
2871
2872 if (error) {
2873 expert_add_info_format( actx->pinfo, usm_p.auth_item, &ei_snmp_verify_authentication_error, "Error while verifying Message authenticity: %s", error );
2874 } else {
2875 expert_field* expert;
2876
2877 authen_item = proto_tree_add_boolean(authen_tree, hf_snmp_msgAuthentication, tvb, 0, 0, usm_p.authOK);
2878 proto_item_set_generated(authen_item);
2879
2880 if (usm_p.authOK) {
2881 expert = &ei_snmp_authentication_ok;
2882 } else {
2883 const 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)
;
2884 proto_item_append_text(authen_item, " calculated = %s", calc_auth_str);
2885 expert = &ei_snmp_authentication_error;
2886 }
2887
2888 expert_add_info( actx->pinfo, authen_item, expert);
2889 }
2890 }
2891
2892 return offset;
2893}
2894
2895
2896static const value_string snmp_T_smux_version_vals[] = {
2897 { 0, "version-1" },
2898 { 0, NULL((void*)0) }
2899};
2900
2901
2902static unsigned
2903dissect_snmp_T_smux_version(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2904 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2905 NULL((void*)0));
2906
2907 return offset;
2908}
2909
2910
2911
2912static unsigned
2913dissect_snmp_OBJECT_IDENTIFIER(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2914 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL((void*)0));
2915
2916 return offset;
2917}
2918
2919
2920
2921static unsigned
2922dissect_snmp_DisplayString(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2923 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2924 NULL((void*)0));
2925
2926 return offset;
2927}
2928
2929
2930static const ber_sequence_t SimpleOpen_U_sequence[] = {
2931 { &hf_snmp_smux_version , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_smux_version },
2932 { &hf_snmp_identity , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OBJECT_IDENTIFIER },
2933 { &hf_snmp_description , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_DisplayString },
2934 { &hf_snmp_password , BER_CLASS_UNI0, BER_UNI_TAG_OCTETSTRING4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OCTET_STRING },
2935 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2936};
2937
2938static unsigned
2939dissect_snmp_SimpleOpen_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2940 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2941 SimpleOpen_U_sequence, hf_index, ett_snmp_SimpleOpen_U);
2942
2943 return offset;
2944}
2945
2946
2947
2948static unsigned
2949dissect_snmp_SimpleOpen(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2950 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2951 hf_index, BER_CLASS_APP1, 0, true1, dissect_snmp_SimpleOpen_U);
2952
2953 return offset;
2954}
2955
2956
2957static const value_string snmp_OpenPDU_vals[] = {
2958 { 0, "smux-simple" },
2959 { 0, NULL((void*)0) }
2960};
2961
2962static const ber_choice_t OpenPDU_choice[] = {
2963 { 0, &hf_snmp_smux_simple , BER_CLASS_APP1, 0, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SimpleOpen },
2964 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }
2965};
2966
2967static unsigned
2968dissect_snmp_OpenPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2969 offset = dissect_ber_choice(actx, tree, tvb, offset,
2970 OpenPDU_choice, hf_index, ett_snmp_OpenPDU,
2971 NULL((void*)0));
2972
2973 return offset;
2974}
2975
2976
2977static const value_string snmp_ClosePDU_U_vals[] = {
2978 { 0, "goingDown" },
2979 { 1, "unsupportedVersion" },
2980 { 2, "packetFormat" },
2981 { 3, "protocolError" },
2982 { 4, "internalError" },
2983 { 5, "authenticationFailure" },
2984 { 0, NULL((void*)0) }
2985};
2986
2987
2988static unsigned
2989dissect_snmp_ClosePDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
2990 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2991 NULL((void*)0));
2992
2993 return offset;
2994}
2995
2996
2997
2998static unsigned
2999dissect_snmp_ClosePDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3000 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3001 hf_index, BER_CLASS_APP1, 1, true1, dissect_snmp_ClosePDU_U);
3002
3003 return offset;
3004}
3005
3006
3007
3008static unsigned
3009dissect_snmp_INTEGER_M1_2147483647(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3010 offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
3011 -1, 2147483647U, hf_index, NULL((void*)0));
3012
3013 return offset;
3014}
3015
3016
3017static const value_string snmp_T_operation_vals[] = {
3018 { 0, "delete" },
3019 { 1, "readOnly" },
3020 { 2, "readWrite" },
3021 { 0, NULL((void*)0) }
3022};
3023
3024
3025static unsigned
3026dissect_snmp_T_operation(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3027 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3028 NULL((void*)0));
3029
3030 return offset;
3031}
3032
3033
3034static const ber_sequence_t RReqPDU_U_sequence[] = {
3035 { &hf_snmp_subtree , BER_CLASS_UNI0, BER_UNI_TAG_OID6, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ObjectName },
3036 { &hf_snmp_priority , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_INTEGER_M1_2147483647 },
3037 { &hf_snmp_operation , BER_CLASS_UNI0, BER_UNI_TAG_INTEGER2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_T_operation },
3038 { NULL((void*)0), 0, 0, 0, NULL((void*)0) }
3039};
3040
3041static unsigned
3042dissect_snmp_RReqPDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3043 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3044 RReqPDU_U_sequence, hf_index, ett_snmp_RReqPDU_U);
3045
3046 return offset;
3047}
3048
3049
3050
3051static unsigned
3052dissect_snmp_RReqPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3053 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3054 hf_index, BER_CLASS_APP1, 2, true1, dissect_snmp_RReqPDU_U);
3055
3056 return offset;
3057}
3058
3059
3060static const value_string snmp_RRspPDU_U_vals[] = {
3061 { -1, "failure" },
3062 { 0, NULL((void*)0) }
3063};
3064
3065
3066static unsigned
3067dissect_snmp_RRspPDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3068 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3069 NULL((void*)0));
3070
3071 return offset;
3072}
3073
3074
3075
3076static unsigned
3077dissect_snmp_RRspPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3078 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3079 hf_index, BER_CLASS_APP1, 3, true1, dissect_snmp_RRspPDU_U);
3080
3081 return offset;
3082}
3083
3084
3085static const value_string snmp_RegisterResponse_vals[] = {
3086 { 0, "rRspPDU" },
3087 { 1, "pDUs" },
3088 { 0, NULL((void*)0) }
3089};
3090
3091static const ber_choice_t RegisterResponse_choice[] = {
3092 { 0, &hf_snmp_rRspPDU , BER_CLASS_APP1, 3, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RRspPDU },
3093 { 1, &hf_snmp_pDUs , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_PDUs },
3094 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }
3095};
3096
3097static unsigned
3098dissect_snmp_RegisterResponse(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3099 offset = dissect_ber_choice(actx, tree, tvb, offset,
3100 RegisterResponse_choice, hf_index, ett_snmp_RegisterResponse,
3101 NULL((void*)0));
3102
3103 return offset;
3104}
3105
3106
3107static const value_string snmp_SOutPDU_U_vals[] = {
3108 { 0, "commit" },
3109 { 1, "rollback" },
3110 { 0, NULL((void*)0) }
3111};
3112
3113
3114static unsigned
3115dissect_snmp_SOutPDU_U(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3116 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3117 NULL((void*)0));
3118
3119 return offset;
3120}
3121
3122
3123
3124static unsigned
3125dissect_snmp_SOutPDU(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3126 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3127 hf_index, BER_CLASS_APP1, 4, true1, dissect_snmp_SOutPDU_U);
3128
3129 return offset;
3130}
3131
3132
3133static const value_string snmp_SMUX_PDUs_vals[] = {
3134 { 0, "open" },
3135 { 1, "close" },
3136 { 2, "registerRequest" },
3137 { 3, "registerResponse" },
3138 { 4, "commitOrRollback" },
3139 { 0, NULL((void*)0) }
3140};
3141
3142static const ber_choice_t SMUX_PDUs_choice[] = {
3143 { 0, &hf_snmp_open , BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_OpenPDU },
3144 { 1, &hf_snmp_close , BER_CLASS_APP1, 1, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_ClosePDU },
3145 { 2, &hf_snmp_registerRequest, BER_CLASS_APP1, 2, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RReqPDU },
3146 { 3, &hf_snmp_registerResponse, BER_CLASS_ANY99/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_RegisterResponse },
3147 { 4, &hf_snmp_commitOrRollback, BER_CLASS_APP1, 4, BER_FLAGS_NOOWNTAG0x00000004, dissect_snmp_SOutPDU },
3148 { 0, NULL((void*)0), 0, 0, 0, NULL((void*)0) }
3149};
3150
3151static unsigned
3152dissect_snmp_SMUX_PDUs(bool_Bool implicit_tag _U___attribute__((unused)), tvbuff_t *tvb _U___attribute__((unused)), unsigned offset _U___attribute__((unused)), asn1_ctx_t *actx _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)), int hf_index _U___attribute__((unused))) {
3153
3154 snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(actx->pinfo);
3155
3156 actx->private_data = snmp_info;
3157
3158 offset = dissect_ber_choice(actx, tree, tvb, offset,
3159 SMUX_PDUs_choice, hf_index, ett_snmp_SMUX_PDUs,
3160 NULL((void*)0));
3161
3162 return offset;
3163}
3164
3165/*--- PDUs ---*/
3166
3167static 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))) {
3168 unsigned offset = 0;
3169 asn1_ctx_t asn1_ctx;
3170 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true1, pinfo);
3171 offset = dissect_snmp_SMUX_PDUs(false0, tvb, offset, &asn1_ctx, tree, hf_snmp_SMUX_PDUs_PDU);
3172 return offset;
3173}
3174
3175
3176static snmp_conv_info_t*
3177snmp_find_conversation_and_get_conv_data(packet_info *pinfo) {
3178
3179 conversation_t *conversation = NULL((void*)0);
3180 snmp_conv_info_t *snmp_info = NULL((void*)0);
3181
3182 /* Get the conversation with the wildcarded port, if it exists
3183 * and is associated with SNMP, so that requests and responses
3184 * can be matched even if the response comes from a different,
3185 * ephemeral, source port, as originally done in OS/400.
3186 * On UDP, we do not automatically call conversation_set_port2()
3187 * and we do not want to do so. Possibly this should eventually
3188 * use find_conversation_full and separate the "SNMP conversation"
3189 * from "the transport layer conversation that carries SNMP."
3190 */
3191 if (pinfo->destport == UDP_PORT_SNMP161) {
3192 conversation = find_conversation_strat(pinfo, conversation_pt_to_conversation_type(pinfo->ptype), NO_PORT_B0x00020000, 0);
3193 } else {
3194 conversation = find_conversation_strat(pinfo, conversation_pt_to_conversation_type(pinfo->ptype), NO_PORT_B0x00020000, 1);
3195 }
3196 if ( (conversation == NULL((void*)0)) || (conversation_get_dissector(conversation, pinfo->num)!=snmp_handle) ) {
3197 conversation = conversation_new_strat(pinfo, conversation_pt_to_conversation_type(pinfo->ptype), NO_PORT20x02);
3198 conversation_set_dissector(conversation, snmp_handle);
3199
3200 conversation = conversation_new_strat(pinfo, CONVERSATION_SNMP, NO_PORT20x02);
3201 }
3202
3203 snmp_info = (snmp_conv_info_t *)conversation_get_proto_data(conversation, proto_snmp);
3204 if (snmp_info == NULL((void*)0)) {
3205 snmp_info = wmem_new0(wmem_file_scope(), snmp_conv_info_t)((snmp_conv_info_t*)wmem_alloc0((wmem_file_scope()), sizeof(snmp_conv_info_t
)))
;
3206 snmp_info->request_response=wmem_map_new(wmem_file_scope(), g_int_hash, g_int_equal);
3207
3208 conversation_add_proto_data(conversation, proto_snmp, snmp_info);
3209 }
3210 return snmp_info;
3211}
3212
3213unsigned
3214dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
3215 proto_tree *tree, int proto, int ett, bool_Bool is_tcp)
3216{
3217
3218 unsigned length_remaining;
3219 int8_t ber_class;
3220 bool_Bool pc, ind = 0;
3221 int32_t tag;
3222 uint32_t len;
3223 unsigned message_length;
3224 int start_offset = offset;
3225 uint32_t version = 0;
3226 tvbuff_t *next_tvb;
3227
3228 proto_tree *snmp_tree = NULL((void*)0);
3229 proto_item *item = NULL((void*)0);
3230
3231 snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(pinfo);
3232
3233 asn1_ctx_t asn1_ctx;
3234 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true1, pinfo);
3235
3236 asn1_ctx.private_data = snmp_info;
3237
3238 usm_p.msg_tvb = tvb;
3239 usm_p.start_offset = tvb_offset_from_real_beginning(tvb);
3240 usm_p.engine_tvb = NULL((void*)0);
3241 usm_p.user_tvb = NULL((void*)0);
3242 usm_p.auth_item = NULL((void*)0);
3243 usm_p.auth_tvb = NULL((void*)0);
3244 usm_p.auth_offset = 0;
3245 usm_p.priv_tvb = NULL((void*)0);
3246 usm_p.user_assoc = NULL((void*)0);
3247 usm_p.authenticated = false0;
3248 usm_p.encrypted = false0;
3249 usm_p.boots = 0;
3250 usm_p.snmp_time = 0;
3251 usm_p.authOK = false0;
3252
3253 /*
3254 * This will throw an exception if we don't have any data left.
3255 * That's what we want. (See "tcp_dissect_pdus()", which is
3256 * similar, but doesn't have to deal with ASN.1.
3257 * XXX - can we make "tcp_dissect_pdus()" provide enough
3258 * information to the "get_pdu_len" routine so that we could
3259 * have that routine deal with ASN.1, and just use
3260 * "tcp_dissect_pdus()"?)
3261 */
3262 length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);
3263
3264 /* NOTE: we have to parse the message piece by piece, since the
3265 * capture length may be less than the message length: a 'global'
3266 * parsing is likely to fail.
3267 */
3268
3269 /*
3270 * If this is SNMP-over-TCP, we might have to do reassembly
3271 * in order to read the "Sequence Of" header.
3272 */
3273 if (is_tcp && snmp_desegment && pinfo->can_desegment) {
3274 /*
3275 * This is TCP, and we should, and can, do reassembly.
3276 *
3277 * Is the "Sequence Of" header split across segment
3278 * boundaries? We require at least 6 bytes for the
3279 * header, which allows for a 4-byte length (ASN.1
3280 * BER).
3281 */
3282 if (length_remaining < 6) {
3283 /*
3284 * Yes. Tell the TCP dissector where the data
3285 * for this message starts in the data it handed
3286 * us and that we need "some more data." Don't tell
3287 * it exactly how many bytes we need because if/when
3288 * we ask for even more (after the header) that will
3289 * break reassembly.
3290 */
3291 pinfo->desegment_offset = offset;
3292 pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT0x0fffffff;
3293 return 0;
3294 }
3295 }
3296
3297 /*
3298 * OK, try to read the "Sequence Of" header; this gets the total
3299 * length of the SNMP message.
3300 */
3301 offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
3302 /*Get the total octet length of the SNMP data*/
3303 offset = get_ber_length(tvb, offset, &len, &ind);
3304 message_length = len + offset;
3305
3306 /*Get the SNMP version data*/
3307 /*offset =*/ dissect_ber_integer(false0, &asn1_ctx, 0, tvb, offset, -1, &version);
3308
3309
3310 /*
3311 * If this is SNMP-over-TCP, we might have to do reassembly
3312 * to get all of this message.
3313 */
3314 if (is_tcp && snmp_desegment && pinfo->can_desegment) {
3315 /*
3316 * Yes - is the message split across segment boundaries?
3317 */
3318 if (length_remaining < message_length) {
3319 /*
3320 * Yes. Tell the TCP dissector where the data
3321 * for this message starts in the data it handed
3322 * us, and how many more bytes we need, and
3323 * return.
3324 */
3325 pinfo->desegment_offset = start_offset;
3326 pinfo->desegment_len =
3327 message_length - length_remaining;
3328
3329 /*
3330 * Return 0, which means "I didn't dissect anything
3331 * because I don't have enough data - we need
3332 * to desegment".
3333 */
3334 return 0;
3335 }
3336 }
3337
3338 var_list = next_tvb_list_new(pinfo->pool);
3339
3340 col_set_str(pinfo->cinfo, COL_PROTOCOL, proto_get_protocol_short_name(find_protocol_by_id(proto)));
3341
3342 item = proto_tree_add_item(tree, proto, tvb, start_offset, message_length, ENC_BIG_ENDIAN0x00000000);
3343 snmp_tree = proto_item_add_subtree(item, ett);
3344
3345 switch (version) {
3346 case 0: /* v1 */
3347 case 1: /* v2c */
3348 offset = dissect_snmp_Message(false0 , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
3349 break;
3350 case 2: /* v2u */
3351 offset = dissect_snmp_Messagev2u(false0 , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
3352 break;
3353 /* v3 */
3354 case 3:
3355 offset = dissect_snmp_SNMPv3Message(false0 , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
3356 break;
3357 default:
3358 /*
3359 * Return the length remaining in the tvbuff, so
3360 * if this is SNMP-over-TCP, our caller thinks there's
3361 * nothing left to dissect.
3362 */
3363 expert_add_info(pinfo, item, &ei_snmp_version_unknown);
3364 return length_remaining;
3365 }
3366
3367 /* There may be appended data after the SNMP data, so treat as raw
3368 * data which needs to be dissected in case of UDP as UDP is PDU oriented.
3369 */
3370 if((!is_tcp) && (length_remaining > (unsigned)offset)) {
3371 next_tvb = tvb_new_subset_remaining(tvb, offset);
3372 call_dissector(data_handle, next_tvb, pinfo, tree);
3373 } else {
3374 next_tvb_call(var_list, pinfo, tree, NULL((void*)0), data_handle);
3375 }
3376
3377 return offset;
3378}
3379
3380static int
3381dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U___attribute__((unused)))
3382{
3383 int offset;
3384 int8_t tmp_class;
3385 bool_Bool tmp_pc;
3386 int32_t tmp_tag;
3387 uint32_t tmp_length;
3388 bool_Bool tmp_ind;
3389
3390 /*
3391 * See if this looks like SNMP or not. if not, return 0 so
3392 * wireshark can try some other dissector instead.
3393 */
3394 /* All SNMP packets are BER encoded and consist of a SEQUENCE
3395 * that spans the entire PDU. The first item is an INTEGER that
3396 * has the values 0-2 (version 1-3).
3397 * if not it is not snmp.
3398 */
3399 /* SNMP starts with a SEQUENCE */
3400 offset = get_ber_identifier(tvb, 0, &tmp_class, &tmp_pc, &tmp_tag);
3401 if((tmp_class!=BER_CLASS_UNI0)||(tmp_tag!=BER_UNI_TAG_SEQUENCE16)) {
3402 return 0;
3403 }
3404 /* then comes a length which spans the rest of the tvb */
3405 offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);
3406 /* Loosen the heuristic a bit to handle the case where data has intentionally
3407 * been added after the snmp PDU ( UDP case) (#3684)
3408 * If this is fragmented or carried in ICMP, we don't expect the tvb to
3409 * have the full length, so don't check.
3410 */
3411 if (!pinfo->fragmented && !pinfo->flags.in_error_pkt) {
3412 if ( pinfo->ptype == PT_UDP ) {
3413 if(tmp_length>(uint32_t)tvb_reported_length_remaining(tvb, offset)) {
3414 return 0;
3415 }
3416 }else{
3417 if(tmp_length!=(uint32_t)tvb_reported_length_remaining(tvb, offset)) {
3418 return 0;
3419 }
3420 }
3421 }
3422 /* then comes an INTEGER (version)*/
3423 get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
3424 if((tmp_class!=BER_CLASS_UNI0)||(tmp_tag!=BER_UNI_TAG_INTEGER2)) {
3425 return 0;
3426 }
3427 /* do we need to test that version is 0 - 2 (version1-3) ? */
3428
3429
3430 /*
3431 * The IBM i (OS/400) SNMP agent, at least originally, would
3432 * send responses back from some *other* UDP port, an ephemeral
3433 * port above 5000, going back to the same IP address and port
3434 * from which the request came, similar to TFTP. This only happens
3435 * with the agent port, 161, not with the trap port, etc. As of
3436 * 2015 with the latest fixes applied, it no longer does this:
3437 * https://www.ibm.com/support/pages/ptf/SI55487
3438 * https://www.ibm.com/support/pages/ptf/SI55537
3439 *
3440 * The SNMP RFCs are silent on this (cf. L2TP RFC 2661, which
3441 * supports using either the well-known port or an ephemeral
3442 * port as the source port for responses, while noting that
3443 * the latter can cause issues with firewalls and NATs.) so
3444 * possibly some other implementations could do this.
3445 *
3446 * If this packet went to the SNMP port, we check to see if
3447 * there's already a conversation with one address/port pair
3448 * matching the source IP address and port of this packet,
3449 * the other address matching the destination IP address of this
3450 * packet, and any destination port.
3451 *
3452 * If not, we create one, with its address 1/port 1 pair being
3453 * the source address/port of this packet, its address 2 being
3454 * the destination address of this packet, and its port 2 being
3455 * wildcarded, and give it the SNMP dissector as a dissector.
3456 */
3457
3458 if (pinfo->destport == UDP_PORT_SNMP161) {
3459 conversation_t *conversation = find_conversation_strat(pinfo, conversation_pt_to_conversation_type(pinfo->ptype), NO_PORT_B0x00020000|NO_GREEDY0x00100000, 0);
3460
3461 if (conversation == NULL((void*)0)) {
3462 conversation = conversation_new_strat(pinfo, conversation_pt_to_conversation_type(pinfo->ptype), NO_PORT20x02);
3463
3464 conversation_set_dissector(conversation, snmp_handle);
3465 }
3466 else if (conversation_get_dissector(conversation,pinfo->num)!=snmp_handle) {
3467 conversation_set_dissector(conversation, snmp_handle);
3468 }
3469 }
3470
3471 return dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, false0);
3472}
3473
3474static int
3475dissect_snmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused)))
3476{
3477 unsigned offset = 0;
3478 unsigned message_len;
3479
3480 while (tvb_reported_length_remaining(tvb, offset) > 0) {
3481 message_len = dissect_snmp_pdu(tvb, offset, pinfo, tree, proto_snmp, ett_snmp, true1);
3482 if (message_len == 0) {
3483 /*
3484 * We don't have all the data for that message,
3485 * so we need to do desegmentation;
3486 * "dissect_snmp_pdu()" has set that up.
3487 */
3488 break;
3489 }
3490 offset += message_len;
3491 }
3492 return tvb_captured_length(tvb);
3493}
3494
3495static int
3496dissect_smux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
3497{
3498 proto_tree *smux_tree = NULL((void*)0);
3499 proto_item *item = NULL((void*)0);
3500
3501 var_list = next_tvb_list_new(pinfo->pool);
3502
3503 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMUX");
3504
3505 item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, ENC_NA0x00000000);
3506 smux_tree = proto_item_add_subtree(item, ett_smux);
3507
3508 return dissect_SMUX_PDUs_PDU(tvb, pinfo, smux_tree, data);
3509}
3510
3511/*
3512 MD5 Password to Key Algorithm from RFC 3414 A.2.1
3513 SHA1 Password to Key Algorithm from RFC 3414 A.2.2
3514 SHA2 Password to Key Algorithm from RFC 7860 9.3
3515*/
3516static void
3517snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const uint8_t *password,
3518 unsigned passwordlen, const uint8_t *engineID, unsigned engineLength, uint8_t *key)
3519{
3520 gcry_md_hd_t hash_handle;
3521 uint8_t *cp, password_buf[64];
3522 uint32_t password_index = 0;
3523 uint32_t count = 0, i;
3524 unsigned hash_len;
3525
3526 if (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
3527 return;
29
Returning without writing to '*key'
3528 }
3529
3530 hash_len = auth_hash_len[model];
3531
3532 /**********************************************/
3533 /* Use while loop until we've done 1 Megabyte */
3534 /**********************************************/
3535 while (count < 1048576) {
36
Loop condition is true. Entering loop body
3536 cp = password_buf;
3537 if (passwordlen
36.1
'passwordlen' is not equal to 0
!= 0) {
37
Taking true branch
3538 for (i = 0; i < 64; i++) {
38
Loop condition is true. Entering loop body
3539 /*************************************************/
3540 /* Take the next octet of the password, wrapping */
3541 /* to the beginning of the password as necessary.*/
3542 /*************************************************/
3543 *cp++ = password[password_index++ % passwordlen];
39
Assigned value is uninitialized
3544 }
3545 } else {
3546 *cp = 0;
3547 }
3548 gcry_md_write(hash_handle, password_buf, 64);
3549 count += 64;
3550 }
3551 memcpy(key, gcry_md_read(hash_handle, 0), hash_len);
3552 gcry_md_close(hash_handle);
3553
3554 /*****************************************************/
3555 /* Now localise the key with the engineID and pass */
3556 /* through hash function to produce final key */
3557 /* We ignore invalid engineLengths here. More strict */
3558 /* checking is done in snmp_users_update_cb. */
3559 /*****************************************************/
3560 if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {
3561 return;
3562 }
3563 gcry_md_write(hash_handle, key, hash_len);
3564 gcry_md_write(hash_handle, engineID, engineLength);
3565 gcry_md_write(hash_handle, key, hash_len);
3566 memcpy(key, gcry_md_read(hash_handle, 0), hash_len);
3567 gcry_md_close(hash_handle);
3568 return;
3569}
3570
3571static void
3572process_prefs(void)
3573{
3574}
3575
3576UAT_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))) { uint8_t* new_val = uat_unesc
(buf,len,&(((snmp_ue_assoc_t*)rec)->user.userName.len)
); (__builtin_object_size (((((snmp_ue_assoc_t*)rec)->user
.userName.data)), 0) != ((size_t) - 1)) ? g_free_sized ((((snmp_ue_assoc_t
*)rec)->user.userName.data), __builtin_object_size (((((snmp_ue_assoc_t
*)rec)->user.userName.data)), 0)) : (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; } }
3577UAT_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))) { uint8_t* new_val = uat_unesc
(buf,len,&(((snmp_ue_assoc_t*)rec)->user.authPassword.
len)); (__builtin_object_size (((((snmp_ue_assoc_t*)rec)->
user.authPassword.data)), 0) != ((size_t) - 1)) ? g_free_sized
((((snmp_ue_assoc_t*)rec)->user.authPassword.data), __builtin_object_size
(((((snmp_ue_assoc_t*)rec)->user.authPassword.data)), 0))
: (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; } }
3578UAT_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))) { uint8_t* new_val = uat_unesc
(buf,len,&(((snmp_ue_assoc_t*)rec)->user.privPassword.
len)); (__builtin_object_size (((((snmp_ue_assoc_t*)rec)->
user.privPassword.data)), 0) != ((size_t) - 1)) ? g_free_sized
((((snmp_ue_assoc_t*)rec)->user.privPassword.data), __builtin_object_size
(((((snmp_ue_assoc_t*)rec)->user.privPassword.data)), 0))
: (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; } }
3579UAT_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); (__builtin_object_size
(((((snmp_ue_assoc_t*)rec)->engine.data)), 0) != ((size_t
) - 1)) ? g_free_sized ((((snmp_ue_assoc_t*)rec)->engine.data
), __builtin_object_size (((((snmp_ue_assoc_t*)rec)->engine
.data)), 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; }
3580UAT_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; (__builtin_object_size ((str), 0
) != ((size_t) - 1)) ? g_free_sized (str, __builtin_object_size
((str), 0)) : (g_free) (str); return; } } (__builtin_object_size
((str), 0) != ((size_t) - 1)) ? g_free_sized (str, __builtin_object_size
((str), 0)) : (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"
); }
3581UAT_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; (__builtin_object_size ((str), 0
) != ((size_t) - 1)) ? g_free_sized (str, __builtin_object_size
((str), 0)) : (g_free) (str); return; } } (__builtin_object_size
((str), 0) != ((size_t) - 1)) ? g_free_sized (str, __builtin_object_size
((str), 0)) : (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"
); }
3582UAT_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; (__builtin_object_size ((str), 0
) != ((size_t) - 1)) ? g_free_sized (str, __builtin_object_size
((str), 0)) : (g_free) (str); return; } } (__builtin_object_size
((str), 0) != ((size_t) - 1)) ? g_free_sized (str, __builtin_object_size
((str), 0)) : (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"); }
3583
3584static void *
3585snmp_specific_trap_copy_cb(void *dest, const void *orig, size_t len _U___attribute__((unused)))
3586{
3587 snmp_st_assoc_t *u = (snmp_st_assoc_t *)dest;
3588 const snmp_st_assoc_t *o = (const snmp_st_assoc_t *)orig;
3589
3590 u->enterprise = g_strdup(o->enterprise)g_strdup_inline (o->enterprise);
3591 u->trap = o->trap;
3592 u->desc = g_strdup(o->desc)g_strdup_inline (o->desc);
3593
3594 return dest;
3595}
3596
3597static void
3598snmp_specific_trap_free_cb(void *r)
3599{
3600 snmp_st_assoc_t *u = (snmp_st_assoc_t *)r;
3601
3602 g_free(u->enterprise)(__builtin_object_size ((u->enterprise), 0) != ((size_t) -
1)) ? g_free_sized (u->enterprise, __builtin_object_size (
(u->enterprise), 0)) : (g_free) (u->enterprise)
;
3603 g_free(u->desc)(__builtin_object_size ((u->desc), 0) != ((size_t) - 1)) ?
g_free_sized (u->desc, __builtin_object_size ((u->desc
), 0)) : (g_free) (u->desc)
;
3604}
3605
3606UAT_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); (__builtin_object_size (((((snmp_st_assoc_t
*)rec)->enterprise)), 0) != ((size_t) - 1)) ? g_free_sized
((((snmp_st_assoc_t*)rec)->enterprise), __builtin_object_size
(((((snmp_st_assoc_t*)rec)->enterprise)), 0)) : (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; }
}
3607UAT_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); (__builtin_object_size ((tmp_str), 0) != ((
size_t) - 1)) ? g_free_sized (tmp_str, __builtin_object_size (
(tmp_str), 0)) : (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); }
3608UAT_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); (__builtin_object_size (((((snmp_st_assoc_t*)rec)->
desc)), 0) != ((size_t) - 1)) ? g_free_sized ((((snmp_st_assoc_t
*)rec)->desc), __builtin_object_size (((((snmp_st_assoc_t*
)rec)->desc)), 0)) : (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; } }
3609
3610 /*--- proto_register_snmp -------------------------------------------*/
3611void proto_register_snmp(void) {
3612 /* List of fields */
3613 static hf_register_info hf[] = {
3614 { &hf_snmp_response_in,
3615 { "Response In", "snmp.response_in", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE)((gpointer) (glong) (FT_FRAMENUM_RESPONSE)), 0x0,
3616 "The response to this SNMP request is in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3617 { &hf_snmp_response_to,
3618 { "Response To", "snmp.response_to", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST)((gpointer) (glong) (FT_FRAMENUM_REQUEST)), 0x0,
3619 "This is a response to the SNMP request in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3620 { &hf_snmp_time,
3621 { "Time", "snmp.time", FT_RELATIVE_TIME, BASE_NONE, NULL((void*)0), 0x0,
3622 "The time between the Request and the Response", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3623 { &hf_snmp_v3_flags_auth,
3624 { "Authenticated", "snmp.v3.flags.auth", FT_BOOLEAN, 8,
3625 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) }},
3626 { &hf_snmp_v3_flags_crypt,
3627 { "Encrypted", "snmp.v3.flags.crypt", FT_BOOLEAN, 8,
3628 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) }},
3629 { &hf_snmp_v3_flags_report,
3630 { "Reportable", "snmp.v3.flags.report", FT_BOOLEAN, 8,
3631 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) }},
3632 { &hf_snmp_engineid_conform, {
3633 "Engine ID Conformance", "snmp.engineid.conform", FT_BOOLEAN, 8,
3634 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) }},
3635 { &hf_snmp_engineid_enterprise, {
3636 "Engine Enterprise ID", "snmp.engineid.enterprise", FT_UINT32, BASE_ENTERPRISESBASE_CUSTOM,
3637 STRINGS_ENTERPRISES((const void *) (size_t) (enterprises_base_custom)), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3638 { &hf_snmp_engineid_format, {
3639 "Engine ID Format", "snmp.engineid.format", FT_UINT8, BASE_DEC,
3640 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) }},
3641 { &hf_snmp_engineid_ipv4, {
3642 "Engine ID Data: IPv4 address", "snmp.engineid.ipv4", FT_IPv4, BASE_NONE,
3643 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3644 { &hf_snmp_engineid_ipv6, {
3645 "Engine ID Data: IPv6 address", "snmp.engineid.ipv6", FT_IPv6, BASE_NONE,
3646 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3647 { &hf_snmp_engineid_cisco_type, {
3648 "Engine ID Data: Cisco type", "snmp.engineid.cisco.type", FT_UINT8, BASE_HEX,
3649 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) }},
3650 { &hf_snmp_engineid_mac, {
3651 "Engine ID Data: MAC address", "snmp.engineid.mac", FT_ETHER, BASE_NONE,
3652 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3653 { &hf_snmp_engineid_text, {
3654 "Engine ID Data: Text", "snmp.engineid.text", FT_STRING, BASE_NONE,
3655 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3656 { &hf_snmp_engineid_time, {
3657 "Engine ID Data: Creation Time", "snmp.engineid.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
3658 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3659 { &hf_snmp_engineid_data, {
3660 "Engine ID Data", "snmp.engineid.data", FT_BYTES, BASE_NONE,
3661 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3662 { &hf_snmp_msgAuthentication, {
3663 "Authentication", "snmp.v3.auth", FT_BOOLEAN, BASE_NONE,
3664 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) }},
3665 { &hf_snmp_decryptedPDU, {
3666 "Decrypted ScopedPDU", "snmp.decrypted_pdu", FT_BYTES, BASE_NONE,
3667 NULL((void*)0), 0, "Decrypted PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3668 { &hf_snmp_noSuchObject, {
3669 "noSuchObject", "snmp.noSuchObject", FT_NONE, BASE_NONE,
3670 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3671 { &hf_snmp_noSuchInstance, {
3672 "noSuchInstance", "snmp.noSuchInstance", FT_NONE, BASE_NONE,
3673 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3674 { &hf_snmp_endOfMibView, {
3675 "endOfMibView", "snmp.endOfMibView", FT_NONE, BASE_NONE,
3676 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3677 { &hf_snmp_unSpecified, {
3678 "unSpecified", "snmp.unSpecified", FT_NONE, BASE_NONE,
3679 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3680
3681 { &hf_snmp_integer32_value, {
3682 "Value (Integer32)", "snmp.value.int", FT_INT64, BASE_DEC,
3683 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3684 { &hf_snmp_octetstring_value, {
3685 "Value (OctetString)", "snmp.value.octets", FT_BYTES, BASE_SHOW_ASCII_PRINTABLE0x00010000,
3686 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3687 { &hf_snmp_oid_value, {
3688 "Value (OID)", "snmp.value.oid", FT_OID, BASE_NONE,
3689 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3690 { &hf_snmp_null_value, {
3691 "Value (Null)", "snmp.value.null", FT_NONE, BASE_NONE,
3692 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3693 { &hf_snmp_ipv4_value, {
3694 "Value (IpAddress)", "snmp.value.ipv4", FT_IPv4, BASE_NONE,
3695 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3696 { &hf_snmp_ipv6_value, {
3697 "Value (IpAddress)", "snmp.value.ipv6", FT_IPv6, BASE_NONE,
3698 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3699 { &hf_snmp_anyaddress_value, {
3700 "Value (IpAddress)", "snmp.value.addr", FT_BYTES, BASE_NONE,
3701 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3702 { &hf_snmp_unsigned32_value, {
3703 "Value (Unsigned32)", "snmp.value.u32", FT_INT64, BASE_DEC,
3704 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3705 { &hf_snmp_gauge32_value, {
3706 "Value (Gauge32)", "snmp.value.g32", FT_INT64, BASE_DEC,
3707 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3708 { &hf_snmp_unknown_value, {
3709 "Value (Unknown)", "snmp.value.unk", FT_BYTES, BASE_NONE,
3710 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3711 { &hf_snmp_counter_value, {
3712 "Value (Counter32)", "snmp.value.counter", FT_UINT64, BASE_DEC,
3713 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3714 { &hf_snmp_big_counter_value, {
3715 "Value (Counter64)", "snmp.value.counter", FT_UINT64, BASE_DEC,
3716 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3717 { &hf_snmp_nsap_value, {
3718 "Value (NSAP)", "snmp.value.nsap", FT_UINT64, BASE_DEC,
3719 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3720 { &hf_snmp_timeticks_value, {
3721 "Value (Timeticks)", "snmp.value.timeticks", FT_UINT64, BASE_DEC,
3722 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3723 { &hf_snmp_opaque_value, {
3724 "Value (Opaque)", "snmp.value.opaque", FT_BYTES, BASE_NONE,
3725 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3726 { &hf_snmp_objectname, {
3727 "Object Name", "snmp.name", FT_OID, BASE_NONE,
3728 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3729 { &hf_snmp_scalar_instance_index, {
3730 "Scalar Instance Index", "snmp.name.index", FT_UINT64, BASE_DEC,
3731 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3732 { &hf_snmp_var_bind_str, {
3733 "Variable-binding-string", "snmp.var-bind_str", FT_STRING, BASE_NONE,
3734 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3735 { &hf_snmp_agentid_trailer, {
3736 "AgentID Trailer", "snmp.agentid_trailer", FT_BYTES, BASE_NONE,
3737 NULL((void*)0), 0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3738
3739
3740 { &hf_snmp_SMUX_PDUs_PDU,
3741 { "SMUX-PDUs", "snmp.SMUX_PDUs",
3742 FT_UINT32, BASE_DEC, VALS(snmp_SMUX_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_SMUX_PDUs_vals)
)))
, 0,
3743 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3744 { &hf_snmp_version,
3745 { "version", "snmp.version",
3746 FT_INT32, BASE_DEC, VALS(snmp_Version_vals)((0 ? (const struct _value_string*)0 : ((snmp_Version_vals)))
)
, 0,
3747 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3748 { &hf_snmp_community,
3749 { "community", "snmp.community",
3750 FT_STRING, BASE_NONE, NULL((void*)0), 0,
3751 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3752 { &hf_snmp_data,
3753 { "data", "snmp.data",
3754 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,
3755 "PDUs", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3756 { &hf_snmp_parameters,
3757 { "parameters", "snmp.parameters",
3758 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3759 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3760 { &hf_snmp_datav2u,
3761 { "datav2u", "snmp.datav2u",
3762 FT_UINT32, BASE_DEC, VALS(snmp_T_datav2u_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_datav2u_vals)
)))
, 0,
3763 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3764 { &hf_snmp_v2u_plaintext,
3765 { "plaintext", "snmp.v2u_plaintext",
3766 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,
3767 "PDUs", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3768 { &hf_snmp_encrypted,
3769 { "encrypted", "snmp.encrypted",
3770 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3771 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3772 { &hf_snmp_msgAuthoritativeEngineID,
3773 { "msgAuthoritativeEngineID", "snmp.msgAuthoritativeEngineID",
3774 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3775 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3776 { &hf_snmp_msgAuthoritativeEngineBoots,
3777 { "msgAuthoritativeEngineBoots", "snmp.msgAuthoritativeEngineBoots",
3778 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3779 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3780 { &hf_snmp_msgAuthoritativeEngineTime,
3781 { "msgAuthoritativeEngineTime", "snmp.msgAuthoritativeEngineTime",
3782 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3783 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3784 { &hf_snmp_msgUserName,
3785 { "msgUserName", "snmp.msgUserName",
3786 FT_STRING, BASE_NONE, NULL((void*)0), 0,
3787 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3788 { &hf_snmp_msgAuthenticationParameters,
3789 { "msgAuthenticationParameters", "snmp.msgAuthenticationParameters",
3790 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3791 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3792 { &hf_snmp_msgPrivacyParameters,
3793 { "msgPrivacyParameters", "snmp.msgPrivacyParameters",
3794 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3795 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3796 { &hf_snmp_msgVersion,
3797 { "msgVersion", "snmp.msgVersion",
3798 FT_INT32, BASE_DEC, VALS(snmp_Version_vals)((0 ? (const struct _value_string*)0 : ((snmp_Version_vals)))
)
, 0,
3799 "Version", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3800 { &hf_snmp_msgGlobalData,
3801 { "msgGlobalData", "snmp.msgGlobalData_element",
3802 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3803 "HeaderData", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3804 { &hf_snmp_msgSecurityParameters,
3805 { "msgSecurityParameters", "snmp.msgSecurityParameters",
3806 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3807 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3808 { &hf_snmp_msgData,
3809 { "msgData", "snmp.msgData",
3810 FT_UINT32, BASE_DEC, VALS(snmp_ScopedPduData_vals)((0 ? (const struct _value_string*)0 : ((snmp_ScopedPduData_vals
))))
, 0,
3811 "ScopedPduData", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3812 { &hf_snmp_msgID,
3813 { "msgID", "snmp.msgID",
3814 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3815 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3816 { &hf_snmp_msgMaxSize,
3817 { "msgMaxSize", "snmp.msgMaxSize",
3818 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3819 "INTEGER_484_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3820 { &hf_snmp_msgFlags,
3821 { "msgFlags", "snmp.msgFlags",
3822 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3823 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3824 { &hf_snmp_msgSecurityModel,
3825 { "msgSecurityModel", "snmp.msgSecurityModel",
3826 FT_UINT32, BASE_DEC, VALS(sec_models)((0 ? (const struct _value_string*)0 : ((sec_models)))), 0,
3827 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3828 { &hf_snmp_plaintext,
3829 { "plaintext", "snmp.plaintext_element",
3830 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3831 "ScopedPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3832 { &hf_snmp_encryptedPDU,
3833 { "encryptedPDU", "snmp.encryptedPDU",
3834 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3835 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3836 { &hf_snmp_contextEngineID,
3837 { "contextEngineID", "snmp.contextEngineID",
3838 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3839 "SnmpEngineID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3840 { &hf_snmp_contextName,
3841 { "contextName", "snmp.contextName",
3842 FT_STRING, BASE_NONE, NULL((void*)0), 0,
3843 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3844 { &hf_snmp_get_request,
3845 { "get-request", "snmp.get_request_element",
3846 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3847 "GetRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3848 { &hf_snmp_get_next_request,
3849 { "get-next-request", "snmp.get_next_request_element",
3850 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3851 "GetNextRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3852 { &hf_snmp_get_response,
3853 { "get-response", "snmp.get_response_element",
3854 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3855 "GetResponse_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3856 { &hf_snmp_set_request,
3857 { "set-request", "snmp.set_request_element",
3858 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3859 "SetRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3860 { &hf_snmp_trap,
3861 { "trap", "snmp.trap_element",
3862 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3863 "Trap_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3864 { &hf_snmp_getBulkRequest,
3865 { "getBulkRequest", "snmp.getBulkRequest_element",
3866 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3867 "GetBulkRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3868 { &hf_snmp_informRequest,
3869 { "informRequest", "snmp.informRequest_element",
3870 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3871 "InformRequest_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3872 { &hf_snmp_snmpV2_trap,
3873 { "snmpV2-trap", "snmp.snmpV2_trap_element",
3874 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3875 "SNMPv2_Trap_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3876 { &hf_snmp_report,
3877 { "report", "snmp.report_element",
3878 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3879 "Report_PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3880 { &hf_snmp_request_id,
3881 { "request-id", "snmp.request_id",
3882 FT_INT32, BASE_DEC, NULL((void*)0), 0,
3883 "T_request_id", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3884 { &hf_snmp_error_status,
3885 { "error-status", "snmp.error_status",
3886 FT_INT32, BASE_DEC, VALS(snmp_T_error_status_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_error_status_vals
))))
, 0,
3887 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3888 { &hf_snmp_error_index,
3889 { "error-index", "snmp.error_index",
3890 FT_INT32, BASE_DEC, NULL((void*)0), 0,
3891 "INTEGER", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3892 { &hf_snmp_variable_bindings,
3893 { "variable-bindings", "snmp.variable_bindings",
3894 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3895 "VarBindList", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3896 { &hf_snmp_request_id_01,
3897 { "request-id", "snmp.request_id",
3898 FT_INT32, BASE_DEC, NULL((void*)0), 0,
3899 "Integer32", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3900 { &hf_snmp_non_repeaters,
3901 { "non-repeaters", "snmp.non_repeaters",
3902 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3903 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3904 { &hf_snmp_max_repetitions,
3905 { "max-repetitions", "snmp.max_repetitions",
3906 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3907 "INTEGER_0_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3908 { &hf_snmp_enterprise,
3909 { "enterprise", "snmp.enterprise",
3910 FT_OID, BASE_NONE, NULL((void*)0), 0,
3911 "EnterpriseOID", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3912 { &hf_snmp_agent_addr,
3913 { "agent-addr", "snmp.agent_addr",
3914 FT_IPv4, BASE_NONE, NULL((void*)0), 0,
3915 "NetworkAddress", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3916 { &hf_snmp_generic_trap,
3917 { "generic-trap", "snmp.generic_trap",
3918 FT_INT32, BASE_DEC, VALS(snmp_GenericTrap_vals)((0 ? (const struct _value_string*)0 : ((snmp_GenericTrap_vals
))))
, 0,
3919 "GenericTrap", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3920 { &hf_snmp_specific_trap,
3921 { "specific-trap", "snmp.specific_trap",
3922 FT_INT32, BASE_DEC, NULL((void*)0), 0,
3923 "SpecificTrap", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3924 { &hf_snmp_time_stamp,
3925 { "time-stamp", "snmp.time_stamp",
3926 FT_UINT32, BASE_DEC, NULL((void*)0), 0,
3927 "TimeTicks", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3928 { &hf_snmp_name,
3929 { "name", "snmp.name",
3930 FT_OID, BASE_NONE, NULL((void*)0), 0,
3931 "ObjectName", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3932 { &hf_snmp_valueType,
3933 { "valueType", "snmp.valueType_element",
3934 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3935 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3936 { &hf_snmp_VarBindList_item,
3937 { "VarBind", "snmp.VarBind_element",
3938 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3939 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3940 { &hf_snmp_open,
3941 { "open", "snmp.open",
3942 FT_UINT32, BASE_DEC, VALS(snmp_OpenPDU_vals)((0 ? (const struct _value_string*)0 : ((snmp_OpenPDU_vals)))
)
, 0,
3943 "OpenPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3944 { &hf_snmp_close,
3945 { "close", "snmp.close",
3946 FT_INT32, BASE_DEC, VALS(snmp_ClosePDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_ClosePDU_U_vals
))))
, 0,
3947 "ClosePDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3948 { &hf_snmp_registerRequest,
3949 { "registerRequest", "snmp.registerRequest_element",
3950 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3951 "RReqPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3952 { &hf_snmp_registerResponse,
3953 { "registerResponse", "snmp.registerResponse",
3954 FT_UINT32, BASE_DEC, VALS(snmp_RegisterResponse_vals)((0 ? (const struct _value_string*)0 : ((snmp_RegisterResponse_vals
))))
, 0,
3955 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3956 { &hf_snmp_commitOrRollback,
3957 { "commitOrRollback", "snmp.commitOrRollback",
3958 FT_INT32, BASE_DEC, VALS(snmp_SOutPDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_SOutPDU_U_vals)
)))
, 0,
3959 "SOutPDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3960 { &hf_snmp_rRspPDU,
3961 { "rRspPDU", "snmp.rRspPDU",
3962 FT_INT32, BASE_DEC, VALS(snmp_RRspPDU_U_vals)((0 ? (const struct _value_string*)0 : ((snmp_RRspPDU_U_vals)
)))
, 0,
3963 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3964 { &hf_snmp_pDUs,
3965 { "pDUs", "snmp.pDUs",
3966 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals)((0 ? (const struct _value_string*)0 : ((snmp_PDUs_vals)))), 0,
3967 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3968 { &hf_snmp_smux_simple,
3969 { "smux-simple", "snmp.smux_simple_element",
3970 FT_NONE, BASE_NONE, NULL((void*)0), 0,
3971 "SimpleOpen", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3972 { &hf_snmp_smux_version,
3973 { "smux-version", "snmp.smux_version",
3974 FT_INT32, BASE_DEC, VALS(snmp_T_smux_version_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_smux_version_vals
))))
, 0,
3975 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3976 { &hf_snmp_identity,
3977 { "identity", "snmp.identity",
3978 FT_OID, BASE_NONE, NULL((void*)0), 0,
3979 "OBJECT_IDENTIFIER", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3980 { &hf_snmp_description,
3981 { "description", "snmp.description",
3982 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3983 "DisplayString", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3984 { &hf_snmp_password,
3985 { "password", "snmp.password",
3986 FT_BYTES, BASE_NONE, NULL((void*)0), 0,
3987 "OCTET_STRING", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3988 { &hf_snmp_subtree,
3989 { "subtree", "snmp.subtree",
3990 FT_OID, BASE_NONE, NULL((void*)0), 0,
3991 "ObjectName", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3992 { &hf_snmp_priority,
3993 { "priority", "snmp.priority",
3994 FT_INT32, BASE_DEC, NULL((void*)0), 0,
3995 "INTEGER_M1_2147483647", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
3996 { &hf_snmp_operation,
3997 { "operation", "snmp.operation",
3998 FT_INT32, BASE_DEC, VALS(snmp_T_operation_vals)((0 ? (const struct _value_string*)0 : ((snmp_T_operation_vals
))))
, 0,
3999 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
4000 };
4001
4002 /* List of subtrees */
4003 static int *ett[] = {
4004 &ett_snmp,
4005 &ett_engineid,
4006 &ett_msgFlags,
4007 &ett_encryptedPDU,
4008 &ett_decrypted,
4009 &ett_authParameters,
4010 &ett_internet,
4011 &ett_varbind,
4012 &ett_name,
4013 &ett_value,
4014 &ett_decoding_error,
4015 &ett_snmp_Message,
4016 &ett_snmp_Messagev2u,
4017 &ett_snmp_T_datav2u,
4018 &ett_snmp_UsmSecurityParameters,
4019 &ett_snmp_SNMPv3Message,
4020 &ett_snmp_HeaderData,
4021 &ett_snmp_ScopedPduData,
4022 &ett_snmp_ScopedPDU,
4023 &ett_snmp_PDUs,
4024 &ett_snmp_PDU,
4025 &ett_snmp_BulkPDU,
4026 &ett_snmp_Trap_PDU_U,
4027 &ett_snmp_VarBind,
4028 &ett_snmp_VarBindList,
4029 &ett_snmp_SMUX_PDUs,
4030 &ett_snmp_RegisterResponse,
4031 &ett_snmp_OpenPDU,
4032 &ett_snmp_SimpleOpen_U,
4033 &ett_snmp_RReqPDU_U,
4034 };
4035 static ei_register_info ei[] = {
4036 { &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Failed to decrypt encryptedPDU", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
4037 { &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, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
4038 { &ei_snmp_verify_authentication_error, { "snmp.verify_authentication_error", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Error while verifying Message authenticity", EXPFILL0, ((void*)0), 0, ((void*)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_authentication_ok, { "snmp.authentication_ok", PI_CHECKSUM0x01000000, PI_CHAT0x00200000, "SNMP Authentication OK", EXPFILL0, ((void*)0), 0, ((void*)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_authentication_error, { "snmp.authentication_error", PI_CHECKSUM0x01000000, PI_WARN0x00600000, "SNMP Authentication Error", EXPFILL0, ((void*)0), 0, ((void*)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_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, ((void*)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_varbind_has_indicator, { "snmp.varbind.has_indicator", PI_MALFORMED0x07000000, PI_WARN0x00600000, "VarBind has indicator set", EXPFILL0, ((void*)0), 0, ((void*)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_objectname_not_oid, { "snmp.objectname_not_oid", PI_MALFORMED0x07000000, PI_WARN0x00600000, "ObjectName not an OID", EXPFILL0, ((void*)0), 0, ((void*)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_objectname_has_indicator, { "snmp.objectname_has_indicator", PI_MALFORMED0x07000000, PI_WARN0x00600000, "ObjectName has indicator set", EXPFILL0, ((void*)0), 0, ((void*)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_value_not_primitive_encoding, { "snmp.value_not_primitive_encoding", PI_MALFORMED0x07000000, PI_WARN0x00600000, "value not in primitive encoding", EXPFILL0, ((void*)0), 0, ((void*)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_invalid_oid, { "snmp.invalid_oid", PI_MALFORMED0x07000000, PI_WARN0x00600000, "invalid oid", EXPFILL0, ((void*)0), 0, ((void*)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_varbind_wrong_tag, { "snmp.varbind.wrong_tag", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong tag for SNMP VarBind error value", EXPFILL0, ((void*)0), 0, ((void*)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_varbind_response, { "snmp.varbind.response", PI_RESPONSE_CODE0x03000000, PI_NOTE0x00400000, "Response", EXPFILL0, ((void*)0), 0, ((void*)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_no_instance_subid, { "snmp.no_instance_subid", PI_MALFORMED0x07000000, PI_WARN0x00600000, "No instance sub-id in scalar value", EXPFILL0, ((void*)0), 0, ((void*)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_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, ((void*)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_index_suboid_too_short, { "snmp.index_suboid_too_short", PI_MALFORMED0x07000000, PI_WARN0x00600000, "index sub-oid shorter than expected", EXPFILL0, ((void*)0), 0, ((void*)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_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, ((void*)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_len0, { "snmp.ndex_suboid_len0", PI_MALFORMED0x07000000, PI_WARN0x00600000, "an index sub-oid OID cannot be 0 bytes long!", EXPFILL0, ((void*)0), 0, ((void*)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_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, ((void*)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_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, ((void*)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_column_parent_not_row, { "snmp.column_parent_not_row", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "COLUMNS's parent is not a ROW", EXPFILL0, ((void*)0), 0, ((void*)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_uint_too_large, { "snmp.uint_too_large", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Unsigned integer value > 2^64 - 1", EXPFILL0, ((void*)0), 0, ((void*)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_int_too_large, { "snmp.int_too_large", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Signed integer value > 2^63 - 1 or <= -2^63", EXPFILL0, ((void*)0), 0, ((void*)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_integral_value0, { "snmp.integral_value0", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Integral value is zero-length", EXPFILL0, ((void*)0), 0, ((void*)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_missing_mib, { "snmp.missing_mib", PI_UNDECODED0x05000000, PI_NOTE0x00400000, "Unresolved value, Missing MIB", EXPFILL0, ((void*)0), 0, ((void*)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_varbind_wrong_length_value, { "snmp.varbind.wrong_length_value", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong length for SNMP VarBind/value", EXPFILL0, ((void*)0), 0, ((void*)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_varbind_wrong_class_tag, { "snmp.varbind.wrong_class_tag", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong class/tag for SNMP VarBind/value", EXPFILL0, ((void*)0), 0, ((void*)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_rfc1910_non_conformant, { "snmp.rfc1910_non_conformant", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Data not conforming to RFC1910", EXPFILL0, ((void*)0), 0, ((void*)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_rfc3411_non_conformant, { "snmp.rfc3411_non_conformant", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Data not conforming to RFC3411", EXPFILL0, ((void*)0), 0, ((void*)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_version_unknown, { "snmp.version.unknown", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Unknown version", EXPFILL0, ((void*)0), 0, ((void*)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_trap_pdu_obsolete, { "snmp.trap_pdu_obsolete", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Trap-PDU is obsolete in this SNMP version", EXPFILL0, ((void*)0), 0, ((void*)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
4068 };
4069
4070 expert_module_t* expert_snmp;
4071 module_t *snmp_module;
4072
4073 static uat_field_t users_fields[] = {
4074 UAT_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)}
,
4075 UAT_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)}
,
4076 UAT_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)}
,
4077 UAT_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)}
,
4078 UAT_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)}
,
4079 UAT_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)}
,
4080 UAT_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)}
,
4081 UAT_END_FIELDS{((void*)0),((void*)0),PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,((void
*)0)}
4082 };
4083
4084 uat_t *assocs_uat = uat_new("SNMP Users",
4085 sizeof(snmp_ue_assoc_t),
4086 "snmp_users",
4087 true1,
4088 &ueas,
4089 &num_ueas,
4090 UAT_AFFECTS_DISSECTION0x00000001, /* affects dissection of packets, but not set of named fields */
4091 "ChSNMPUsersSection",
4092 snmp_users_copy_cb,
4093 snmp_users_update_cb,
4094 snmp_users_free_cb,
4095 renew_ue_cache,
4096 NULL((void*)0),
4097 users_fields);
4098
4099 static const char *assocs_uat_defaults[] = {
4100 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), "draft-reeder-snmpv3-usm-3desede-00"};
4101 uat_set_default_values(assocs_uat, assocs_uat_defaults);
4102
4103 static uat_field_t specific_traps_flds[] = {
4104 UAT_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)}
,
4105 UAT_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)}
,
4106 UAT_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)}
,
4107 UAT_END_FIELDS{((void*)0),((void*)0),PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,((void
*)0)}
4108 };
4109
4110 uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types",
4111 sizeof(snmp_st_assoc_t),
4112 "snmp_specific_traps",
4113 true1,
4114 &specific_traps,
4115 &num_specific_traps,
4116 UAT_AFFECTS_DISSECTION0x00000001, /* affects dissection of packets, but not set of named fields */
4117 "ChSNMPEnterpriseSpecificTrapTypes",
4118 snmp_specific_trap_copy_cb,
4119 NULL((void*)0),
4120 snmp_specific_trap_free_cb,
4121 NULL((void*)0),
4122 NULL((void*)0),
4123 specific_traps_flds);
4124
4125 /* Register protocol */
4126 proto_snmp = proto_register_protocol("Simple Network Management Protocol", "SNMP", "snmp");
4127 snmp_handle = register_dissector("snmp", dissect_snmp, proto_snmp);
4128
4129 /* Register fields and subtrees */
4130 proto_register_field_array(proto_snmp, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));
4131 proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));
4132 expert_snmp = expert_register_protocol(proto_snmp);
4133 expert_register_field_array(expert_snmp, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0]));
4134
4135 /* Register dissector */
4136 snmp_tcp_handle = register_dissector("snmp.tcp", dissect_snmp_tcp, proto_snmp);
4137
4138 /* Register configuration preferences */
4139 snmp_module = prefs_register_protocol(proto_snmp, process_prefs);
4140 prefs_register_bool_preference(snmp_module, "display_oid",
4141 "Show SNMP OID in info column",
4142 "Whether the SNMP OID should be shown in the info column",
4143 &display_oid);
4144
4145 prefs_register_obsolete_preference(snmp_module, "mib_modules");
4146 prefs_register_obsolete_preference(snmp_module, "users_file");
4147
4148 prefs_register_bool_preference(snmp_module, "desegment",
4149 "Reassemble SNMP-over-TCP messages spanning multiple TCP segments",
4150 "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."
4151 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
4152 &snmp_desegment);
4153
4154 prefs_register_bool_preference(snmp_module, "var_in_tree",
4155 "Display dissected variables inside SNMP tree",
4156 "ON - display dissected variables inside SNMP tree, OFF - display dissected variables in root tree after SNMP",
4157 &snmp_var_in_tree);
4158
4159 prefs_register_uat_preference(snmp_module, "users_table",
4160 "Users Table",
4161 "Table of engine-user associations used for authentication and decryption",
4162 assocs_uat);
4163
4164 prefs_register_uat_preference(snmp_module, "specific_traps_table",
4165 "Enterprise Specific Trap Types",
4166 "Table of enterprise specific-trap type descriptions",
4167 specific_traps_uat);
4168
4169#ifdef HAVE_LIBSMI1
4170 prefs_register_static_text_preference(snmp_module, "info_mibs",
4171 "MIB settings can be changed in the Name Resolution preferences",
4172 "MIB settings can be changed in the Name Resolution preferences");
4173#endif
4174
4175 value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", proto_snmp, FT_STRING, STRING_CASE_SENSITIVE0);
4176
4177 register_init_routine(init_ue_cache);
4178 register_cleanup_routine(cleanup_ue_cache);
4179
4180 register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp);
4181
4182 snmp_tap=register_tap("snmp");
4183
4184 register_srt_table(proto_snmp, NULL((void*)0), 1, snmpstat_packet, snmpstat_init, NULL((void*)0));
4185}
4186
4187
4188/*--- proto_reg_handoff_snmp ---------------------------------------*/
4189void proto_reg_handoff_snmp(void) {
4190
4191 dissector_add_uint_with_preference("udp.port", UDP_PORT_SNMP161, snmp_handle);
4192 dissector_add_uint("ethertype", ETHERTYPE_SNMP0x814C, snmp_handle);
4193 dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_AGENT0x900F, snmp_handle);
4194 dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_SINK0x9010, snmp_handle);
4195 dissector_add_uint("hpext.dxsap", HPEXT_SNMP0x165A, snmp_handle);
4196
4197 dissector_add_uint_with_preference("tcp.port", TCP_PORT_SNMP161, snmp_tcp_handle);
4198 /* Since "regular" SNMP port and "trap" SNMP port use the same handler,
4199 the "trap" port doesn't really need a separate preference. Just register
4200 normally */
4201 dissector_add_uint("tcp.port", TCP_PORT_SNMP_TRAP162, snmp_tcp_handle);
4202 dissector_add_uint("udp.port", UDP_PORT_SNMP_TRAP162, snmp_handle);
4203 dissector_add_uint("udp.port", UDP_PORT_SNMP_PATROL8161, snmp_handle);
4204
4205 data_handle = find_dissector("data");
4206
4207 /* SNMPv2-MIB sysDescr "1.3.6.1.2.1.1.1.0" */
4208 dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.1.0",
4209 create_dissector_handle(dissect_snmp_variable_string, proto_snmp));
4210 /* SNMPv2-MIB::sysName.0 (1.3.6.1.2.1.1.5.0) */
4211 dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.5.0",
4212 create_dissector_handle(dissect_snmp_variable_string, proto_snmp));
4213
4214 /*
4215 * Process preference settings.
4216 *
4217 * We can't do this in the register routine, as preferences aren't
4218 * read until all dissector register routines have been called (so
4219 * that all dissector preferences have been registered).
4220 */
4221 process_prefs();
4222
4223}
4224
4225void
4226proto_register_smux(void)
4227{
4228 static int *ett[] = {
4229 &ett_smux,
4230 };
4231
4232 proto_smux = proto_register_protocol("SNMP Multiplex Protocol",
4233 "SMUX", "smux");
4234
4235 proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));
4236
4237 smux_handle = register_dissector("smux", dissect_smux, proto_smux);
4238}
4239
4240void
4241proto_reg_handoff_smux(void)
4242{
4243 dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMUX199, smux_handle);
4244}
4245
4246/*
4247 * Editor modelines - https://www.wireshark.org/tools/modelines.html
4248 *
4249 * Local variables:
4250 * c-basic-offset: 8
4251 * tab-width: 8
4252 * indent-tabs-mode: t
4253 * End:
4254 *
4255 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
4256 * :indentSize=8:tabSize=8:noTabs=false:
4257 */