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