Bug Summary

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