### Bug Summary

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

### Annotated Source Code

Press '?' to see keyboard shortcuts

Show analyzer invocation
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-21/lib/clang/21 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/epan -D 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-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-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 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2026-05-20-100323-3659-1 -x c /builds/wireshark/wireshark/epan/dissectors/packet-snmp.c

Keyboard shortcuts:

- Use 'j/k' keys for keyboard navigation
- Use 'Shift+S' to show/hide relevant lines
- Use '?' to toggle this window

Close
Show only relevant lines Show control flow arrows

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