Bug Summary

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