Bug Summary

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