### Bug Summary

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