1 /* Do not modify this file. */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler */
4 /* ../../tools/asn2wrs.py -b -e -p snmp -c snmp.cnf -s packet-snmp-template snmp.asn */
6 /* Input file: packet-snmp-template.c */
8 #line 1 "packet-snmp-template.c"
10 * Routines for SNMP (simple network management protocol)
11 * Copyright (C) 1998 Didier Jorand
13 * See RFC 1157 for SNMPv1.
15 * See RFCs 1901, 1905, and 1906 for SNMPv2c.
17 * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u [historic].
19 * See RFCs 2570-2576 for SNMPv3
20 * Updated to use the asn2wrs compiler made by Tomas Kukosa
21 * Copyright (C) 2005 - 2006 Anders Broman [AT] ericsson.com
26 * Wireshark - Network traffic analyzer
27 * By Gerald Combs <gerald@wireshark.org>
28 * Copyright 1998 Gerald Combs
32 * GXSNMP -- An snmp mangament application
33 * Copyright (C) 1998 Gregory McLean & Jochen Friedrich
34 * Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP group
36 * This program is free software; you can redistribute it and/or
37 * modify it under the terms of the GNU General Public License
38 * as published by the Free Software Foundation; either version 2
39 * of the License, or (at your option) any later version.
41 * This program is distributed in the hope that it will be useful,
42 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 * GNU General Public License for more details.
46 * You should have received a copy of the GNU General Public License
47 * along with this program; if not, write to the Free Software
48 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
61 #include <epan/packet.h>
62 #include <epan/strutil.h>
63 #include <epan/conversation.h>
65 #include <epan/prefs.h>
66 #include <epan/sminmpec.h>
67 #include <epan/emem.h>
68 #include <epan/next_tvb.h>
69 #include "packet-ipx.h"
70 #include "packet-hpext.h"
73 #include "packet-ber.h"
78 # include <net-snmp/net-snmp-config.h>
79 # include <net-snmp/mib_api.h>
80 # include <net-snmp/library/default_store.h>
81 # include <net-snmp/config_api.h>
82 #else /* HAVE_NET_SNMP */
83 # include <ucd-snmp/ucd-snmp-config.h>
84 # include <ucd-snmp/asn1.h>
85 # include <ucd-snmp/snmp_api.h>
86 # include <ucd-snmp/snmp_impl.h>
87 # include <ucd-snmp/mib.h>
88 # include <ucd-snmp/default_store.h>
89 # include <ucd-snmp/read_config.h>
90 # include <ucd-snmp/tools.h>
91 #endif /* HAVE_NET_SNMP */
93 #ifndef NETSNMP_DS_LIBRARY_ID
94 # define NETSNMP_DS_LIBRARY_ID DS_LIBRARY_ID
95 # define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS DS_LIB_NO_TOKEN_WARNINGS
96 # define NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY DS_LIB_PRINT_SUFFIX_ONLY
97 # define netsnmp_ds_set_boolean ds_set_boolean
98 # define netsnmp_ds_set_int ds_set_int
102 # include <epan/filesystem.h>
106 * Define values "sprint_realloc_value()" expects.
108 # define VALTYPE_INTEGER ASN_INTEGER
109 # define VALTYPE_COUNTER ASN_COUNTER
110 # define VALTYPE_GAUGE ASN_GAUGE
111 # define VALTYPE_TIMETICKS ASN_TIMETICKS
112 # define VALTYPE_STRING ASN_OCTET_STR
113 # define VALTYPE_IPADDR ASN_IPADDRESS
114 # define VALTYPE_OPAQUE ASN_OPAQUE
115 # define VALTYPE_NSAP ASN_NSAP
116 # define VALTYPE_OBJECTID ASN_OBJECT_ID
117 # define VALTYPE_BITSTR ASN_BIT_STR
118 # define VALTYPE_COUNTER64 ASN_COUNTER64
120 #endif /* HAVE_SOME_SNMP */
122 #include "packet-snmp.h"
123 #include "format-oid.h"
125 /* Take a pointer that may be null and return a pointer that's not null
126 by turning null pointers into pointers to the above null string,
127 and, if the argument pointer wasn't null, make sure we handle
128 non-printable characters in the string by escaping them. */
129 #define SAFE_STRING(s, l) (((s) != NULL) ? format_text((s), (l)) : "")
131 #define PNAME "Simple Network Management Protocol"
132 #define PSNAME "SNMP"
133 #define PFNAME "snmp"
135 #define UDP_PORT_SNMP 161
136 #define UDP_PORT_SNMP_TRAP 162
137 #define TCP_PORT_SNMP 161
138 #define TCP_PORT_SNMP_TRAP 162
139 #define TCP_PORT_SMUX 199
141 /* Initialize the protocol and registered fields */
142 static int proto_snmp = -1;
143 static int proto_smux = -1;
145 /* Default MIB modules to load */
147 * XXX - According to Wes Hardaker, we shouldn't do this:
148 * http://www.ethereal.com/lists/ethereal-dev/200412/msg00222.html
151 # define DEF_MIB_MODULES "IP-MIB;IF-MIB;TCP-MIB;UDP-MIB;SNMPv2-MIB;RFC1213-MIB;UCD-SNMP-MIB"
152 # define IMPORT_SEPARATOR ":"
154 # define DEF_MIB_MODULES "IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:SNMPv2-MIB:RFC1213-MIB:UCD-SNMP-MIB"
155 # define IMPORT_SEPARATOR ";"
158 static const gchar *mib_modules = DEF_MIB_MODULES;
159 static gboolean display_oid = TRUE;
160 static gboolean snmp_var_in_tree = TRUE;
162 /* Subdissector tables */
163 static dissector_table_t variable_oid_dissector_table;
166 #define TH_CRYPT 0x02
167 #define TH_REPORT 0x04
169 /* desegmentation of SNMP-over-TCP */
170 static gboolean snmp_desegment = TRUE;
172 /* Global variables */
174 guint32 MsgSecurityModel;
175 tvbuff_t *oid_tvb=NULL;
176 tvbuff_t *value_tvb=NULL;
178 static dissector_handle_t snmp_handle;
179 static dissector_handle_t data_handle;
181 static next_tvb_list_t var_list;
183 static int hf_snmp_v3_flags_auth = -1;
184 static int hf_snmp_v3_flags_crypt = -1;
185 static int hf_snmp_v3_flags_report = -1;
187 static int hf_snmp_engineid_conform = -1;
188 static int hf_snmp_engineid_enterprise = -1;
189 static int hf_snmp_engineid_format = -1;
190 static int hf_snmp_engineid_ipv4 = -1;
191 static int hf_snmp_engineid_ipv6 = -1;
192 static int hf_snmp_engineid_mac = -1;
193 static int hf_snmp_engineid_text = -1;
194 static int hf_snmp_engineid_time = -1;
195 static int hf_snmp_engineid_data = -1;
196 static int hf_snmp_counter64 = -1;
199 /*--- Included file: packet-snmp-hf.c ---*/
200 #line 1 "packet-snmp-hf.c"
201 static int hf_snmp_SMUX_PDUs_PDU = -1; /* SMUX_PDUs */
202 static int hf_snmp_simple = -1; /* SimpleSyntax */
203 static int hf_snmp_application_wide = -1; /* ApplicationSyntax */
204 static int hf_snmp_integer_value = -1; /* Integer_value */
205 static int hf_snmp_string_value = -1; /* String_value */
206 static int hf_snmp_objectID_value = -1; /* ObjectID_value */
207 static int hf_snmp_empty = -1; /* Empty */
208 static int hf_snmp_ipAddress_value = -1; /* IpAddress */
209 static int hf_snmp_counter_value = -1; /* Counter32 */
210 static int hf_snmp_timeticks_value = -1; /* TimeTicks */
211 static int hf_snmp_arbitrary_value = -1; /* Opaque */
212 static int hf_snmp_big_counter_value = -1; /* Counter64 */
213 static int hf_snmp_unsigned_integer_value = -1; /* Unsigned32 */
214 static int hf_snmp_internet = -1; /* IpAddress */
215 static int hf_snmp_version = -1; /* Version */
216 static int hf_snmp_community = -1; /* OCTET_STRING */
217 static int hf_snmp_data = -1; /* PDUs */
218 static int hf_snmp_parameters = -1; /* OCTET_STRING */
219 static int hf_snmp_datav2u = -1; /* T_datav2u */
220 static int hf_snmp_v2u_plaintext = -1; /* PDUs */
221 static int hf_snmp_encrypted = -1; /* OCTET_STRING */
222 static int hf_snmp_msgAuthoritativeEngineID = -1; /* SnmpEngineID */
223 static int hf_snmp_msgAuthoritativeEngineBoots = -1; /* INTEGER_0_2147483647 */
224 static int hf_snmp_msgAuthoritativeEngineTime = -1; /* INTEGER_0_2147483647 */
225 static int hf_snmp_msgUserName = -1; /* OCTET_STRING_SIZE_1_32 */
226 static int hf_snmp_msgAuthenticationParameters = -1; /* OCTET_STRING */
227 static int hf_snmp_msgPrivacyParameters = -1; /* OCTET_STRING */
228 static int hf_snmp_msgVersion = -1; /* Version */
229 static int hf_snmp_msgGlobalData = -1; /* HeaderData */
230 static int hf_snmp_msgSecurityParameters = -1; /* T_msgSecurityParameters */
231 static int hf_snmp_msgData = -1; /* ScopedPduData */
232 static int hf_snmp_msgID = -1; /* INTEGER_0_2147483647 */
233 static int hf_snmp_msgMaxSize = -1; /* INTEGER_484_2147483647 */
234 static int hf_snmp_msgFlags = -1; /* T_msgFlags */
235 static int hf_snmp_msgSecurityModel = -1; /* T_msgSecurityModel */
236 static int hf_snmp_plaintext = -1; /* ScopedPDU */
237 static int hf_snmp_encryptedPDU = -1; /* OCTET_STRING */
238 static int hf_snmp_contextEngineID = -1; /* OCTET_STRING */
239 static int hf_snmp_contextName = -1; /* OCTET_STRING */
240 static int hf_snmp_get_request = -1; /* T_get_request */
241 static int hf_snmp_get_next_request = -1; /* T_get_next_request */
242 static int hf_snmp_get_response = -1; /* T_get_response */
243 static int hf_snmp_set_request = -1; /* T_set_request */
244 static int hf_snmp_trap = -1; /* T_trap */
245 static int hf_snmp_getBulkRequest = -1; /* T_getBulkRequest */
246 static int hf_snmp_informRequest = -1; /* T_informRequest */
247 static int hf_snmp_sNMPv2_Trap = -1; /* T_sNMPv2_Trap */
248 static int hf_snmp_report = -1; /* T_report */
249 static int hf_snmp_request_id = -1; /* INTEGER */
250 static int hf_snmp_error_status = -1; /* T_error_status */
251 static int hf_snmp_error_index = -1; /* INTEGER */
252 static int hf_snmp_variable_bindings = -1; /* VarBindList */
253 static int hf_snmp_bulkPDU_request_id = -1; /* Integer32 */
254 static int hf_snmp_non_repeaters = -1; /* INTEGER_0_2147483647 */
255 static int hf_snmp_max_repetitions = -1; /* INTEGER_0_2147483647 */
256 static int hf_snmp_enterprise = -1; /* OBJECT_IDENTIFIER */
257 static int hf_snmp_agent_addr = -1; /* NetworkAddress */
258 static int hf_snmp_generic_trap = -1; /* T_generic_trap */
259 static int hf_snmp_specific_trap = -1; /* INTEGER */
260 static int hf_snmp_time_stamp = -1; /* TimeTicks */
261 static int hf_snmp_name = -1; /* ObjectName */
262 static int hf_snmp_valueType = -1; /* ValueType */
263 static int hf_snmp_value = -1; /* ObjectSyntax */
264 static int hf_snmp_unSpecified = -1; /* NULL */
265 static int hf_snmp_noSuchObject = -1; /* NULL */
266 static int hf_snmp_noSuchInstance = -1; /* NULL */
267 static int hf_snmp_endOfMibView = -1; /* NULL */
268 static int hf_snmp_VarBindList_item = -1; /* VarBind */
269 static int hf_snmp_open = -1; /* OpenPDU */
270 static int hf_snmp_close = -1; /* ClosePDU */
271 static int hf_snmp_registerRequest = -1; /* RReqPDU */
272 static int hf_snmp_registerResponse = -1; /* RegisterResponse */
273 static int hf_snmp_commitOrRollback = -1; /* SOutPDU */
274 static int hf_snmp_rRspPDU = -1; /* RRspPDU */
275 static int hf_snmp_pDUs = -1; /* PDUs */
276 static int hf_snmp_smux_simple = -1; /* SimpleOpen */
277 static int hf_snmp_smux_version = -1; /* T_smux_version */
278 static int hf_snmp_identity = -1; /* OBJECT_IDENTIFIER */
279 static int hf_snmp_description = -1; /* DisplayString */
280 static int hf_snmp_password = -1; /* OCTET_STRING */
281 static int hf_snmp_subtree = -1; /* ObjectName */
282 static int hf_snmp_priority = -1; /* INTEGER_M1_2147483647 */
283 static int hf_snmp_operation = -1; /* T_operation */
285 /*--- End of included file: packet-snmp-hf.c ---*/
286 #line 191 "packet-snmp-template.c"
288 static int hf_smux_version = -1;
289 static int hf_smux_pdutype = -1;
291 /* Initialize the subtree pointers */
292 static gint ett_smux = -1;
293 static gint ett_snmp = -1;
294 static gint ett_engineid = -1;
295 static gint ett_msgFlags = -1;
298 /*--- Included file: packet-snmp-ett.c ---*/
299 #line 1 "packet-snmp-ett.c"
300 static gint ett_snmp_ObjectSyntax = -1;
301 static gint ett_snmp_SimpleSyntax = -1;
302 static gint ett_snmp_ApplicationSyntax = -1;
303 static gint ett_snmp_NetworkAddress = -1;
304 static gint ett_snmp_Message = -1;
305 static gint ett_snmp_Messagev2u = -1;
306 static gint ett_snmp_T_datav2u = -1;
307 static gint ett_snmp_UsmSecurityParameters = -1;
308 static gint ett_snmp_SNMPv3Message = -1;
309 static gint ett_snmp_HeaderData = -1;
310 static gint ett_snmp_ScopedPduData = -1;
311 static gint ett_snmp_ScopedPDU = -1;
312 static gint ett_snmp_PDUs = -1;
313 static gint ett_snmp_PDU = -1;
314 static gint ett_snmp_BulkPDU = -1;
315 static gint ett_snmp_Trap_PDU = -1;
316 static gint ett_snmp_VarBind = -1;
317 static gint ett_snmp_ValueType = -1;
318 static gint ett_snmp_VarBindList = -1;
319 static gint ett_snmp_SMUX_PDUs = -1;
320 static gint ett_snmp_RegisterResponse = -1;
321 static gint ett_snmp_OpenPDU = -1;
322 static gint ett_snmp_SimpleOpen = -1;
323 static gint ett_snmp_RReqPDU = -1;
325 /*--- End of included file: packet-snmp-ett.c ---*/
326 #line 202 "packet-snmp-template.c"
328 /* defined in net-SNMP; include/net-snmp/library/snmp.h */
331 #undef SNMP_MSG_GETNEXT
332 #undef SNMP_MSG_RESPONSE
334 #undef SNMP_MSG_GETBULK
335 #undef SNMP_MSG_INFORM
336 #undef SNMP_MSG_TRAP2
337 #undef SNMP_MSG_REPORT
338 #undef SNMP_NOSUCHOBJECT
339 #undef SNMP_NOSUCHINSTANCE
340 #undef SNMP_ENDOFMIBVIEW
342 /* Security Models */
344 #define SNMP_SEC_ANY 0
345 #define SNMP_SEC_V1 1
346 #define SNMP_SEC_V2C 2
347 #define SNMP_SEC_USM 3
349 static const value_string sec_models[] = {
350 { SNMP_SEC_ANY, "Any" },
351 { SNMP_SEC_V1, "V1" },
352 { SNMP_SEC_V2C, "V2C" },
353 { SNMP_SEC_USM, "USM" },
358 #define SMUX_MSG_OPEN 0
359 #define SMUX_MSG_CLOSE 1
360 #define SMUX_MSG_RREQ 2
361 #define SMUX_MSG_RRSP 3
362 #define SMUX_MSG_SOUT 4
364 static const value_string smux_types[] = {
365 { SMUX_MSG_OPEN, "Open" },
366 { SMUX_MSG_CLOSE, "Close" },
367 { SMUX_MSG_RREQ, "Registration Request" },
368 { SMUX_MSG_RRSP, "Registration Response" },
369 { SMUX_MSG_SOUT, "Commit Or Rollback" },
375 #define SNMP_IPA 0 /* IP Address */
376 #define SNMP_CNT 1 /* Counter (Counter32) */
377 #define SNMP_GGE 2 /* Gauge (Gauge32) */
378 #define SNMP_TIT 3 /* TimeTicks */
379 #define SNMP_OPQ 4 /* Opaque */
380 #define SNMP_NSP 5 /* NsapAddress */
381 #define SNMP_C64 6 /* Counter64 */
382 #define SNMP_U32 7 /* Uinteger32 */
391 #define SNMP_INTEGER 1 /* l */
392 #define SNMP_OCTETSTR 2 /* c */
393 #define SNMP_DISPLAYSTR 2 /* c */
394 #define SNMP_OBJECTID 3 /* ul */
395 #define SNMP_IPADDR 4 /* uc */
396 #define SNMP_COUNTER 5 /* ul */
397 #define SNMP_GAUGE 6 /* ul */
398 #define SNMP_TIMETICKS 7 /* ul */
399 #define SNMP_OPAQUE 8 /* c */
401 /* additional SNMPv2 Types */
403 #define SNMP_UINTEGER 5 /* ul */
404 #define SNMP_BITSTR 9 /* uc */
405 #define SNMP_NSAP 10 /* uc */
406 #define SNMP_COUNTER64 11 /* ul */
407 #define SNMP_NOSUCHOBJECT 12
408 #define SNMP_NOSUCHINSTANCE 13
409 #define SNMP_ENDOFMIBVIEW 14
412 typedef struct _SNMP_CNV SNMP_CNV;
422 static SNMP_CNV SnmpCnv [] =
424 {BER_CLASS_UNI, BER_UNI_TAG_NULL, SNMP_NULL, "NULL"},
425 {BER_CLASS_UNI, BER_UNI_TAG_INTEGER, SNMP_INTEGER, "INTEGER"},
426 {BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, SNMP_OCTETSTR, "OCTET STRING"},
427 {BER_CLASS_UNI, BER_UNI_TAG_OID, SNMP_OBJECTID, "OBJECTID"},
428 {BER_CLASS_APP, SNMP_IPA, SNMP_IPADDR, "IPADDR"},
429 {BER_CLASS_APP, SNMP_CNT, SNMP_COUNTER, "COUNTER"}, /* Counter32 */
430 {BER_CLASS_APP, SNMP_GGE, SNMP_GAUGE, "GAUGE"}, /* Gauge32 == Unsigned32 */
431 {BER_CLASS_APP, SNMP_TIT, SNMP_TIMETICKS, "TIMETICKS"},
432 {BER_CLASS_APP, SNMP_OPQ, SNMP_OPAQUE, "OPAQUE"},
434 /* SNMPv2 data types and errors */
436 {BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, SNMP_BITSTR, "BITSTR"},
437 {BER_CLASS_APP, SNMP_C64, SNMP_COUNTER64, "COUNTER64"},
438 {BER_CLASS_CON, SERR_NSO, SNMP_NOSUCHOBJECT, "NOSUCHOBJECT"},
439 {BER_CLASS_CON, SERR_NSI, SNMP_NOSUCHINSTANCE, "NOSUCHINSTANCE"},
440 {BER_CLASS_CON, SERR_EOM, SNMP_ENDOFMIBVIEW, "ENDOFMIBVIEW"},
445 * NAME: g_snmp_tag_cls2syntax
446 * SYNOPSIS: gboolean g_snmp_tag_cls2syntax
452 * DESCRIPTION: Converts ASN1 tag and class to Syntax tag and name.
453 * See SnmpCnv for conversion.
454 * RETURNS: name on success, NULL on failure
458 snmp_tag_cls2syntax ( guint tag, guint cls, gushort *syntax)
463 while (cnv->syntax != -1)
465 if (cnv->tag == tag && cnv->class == cls)
467 *syntax = cnv->syntax;
475 int oid_to_subid_buf(const guint8 *oid, gint oid_len, subid_t *buf, int buf_len) {
481 value=0; out_len = 0; byte =0; is_first = TRUE;
482 for (i=0; i<oid_len; i++){
483 if (out_len >= buf_len)
486 value = (value << 7) | (byte & 0x7F);
494 }else if ( value < 80 ){
504 buf[out_len++] = value;
513 format_oid(subid_t *oid, guint oid_length)
520 #ifdef HAVE_SOME_SNMP
522 size_t oid_string_len;
526 result_len = oid_length * 22;
528 #ifdef HAVE_SOME_SNMP
530 * Get the decoded form of the OID, and add its length to the
531 * length of the result string.
533 * XXX - check for "sprint_realloc_objid()" failure.
535 oid_string_len = 1024;
536 oid_string = ep_alloc(oid_string_len);
539 /* We pass an ep allocated block here, NOT a malloced block
540 * so we MUST NOT allow reallocation, hence the fourth
541 * parameter MUST be 0/FALSE
543 sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, FALSE,
545 result_len += strlen(oid_string) + 3;
548 result = ep_alloc(result_len + 1);
550 len = g_snprintf(buf, result_len + 1 - (buf-result), "%lu", (unsigned long)oid[0]);
552 for (i = 1; i < oid_length;i++) {
553 len = g_snprintf(buf, result_len + 1 - (buf-result), ".%lu", (unsigned long)oid[i]);
557 #ifdef HAVE_SOME_SNMP
559 * Append the decoded form of the OID.
561 g_snprintf(buf, result_len + 1 -(buf-result), " (%s)", oid_string);
567 /* returns the decoded (can be NULL) and non_decoded OID strings */
569 new_format_oid(subid_t *oid, guint oid_length,
570 gchar **non_decoded, gchar **decoded)
576 #ifdef HAVE_SOME_SNMP
578 size_t oid_string_len;
582 if (oid == NULL || oid_length < 1) {
587 #ifdef HAVE_SOME_SNMP
589 * Get the decoded form of the OID, and add its length to the
590 * length of the result string.
594 * XXX - if we convert this to ep_alloc(), make sure the fourth
595 * argument to sprint_realloc_objid() is FALSE.
598 oid_string_len = 1024;
599 oid_string = ep_alloc(oid_string_len);
600 if (oid_string != NULL) {
603 /* We pass an ep allocated block here, NOT a malloced block
604 * so we MUST NOT allow reallocation, hence the fourth
605 * parameter MUST be 0/FALSE
607 sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, FALSE,
610 *decoded = oid_string;
615 non_decoded_len = oid_length * 22 + 1;
616 *non_decoded = ep_alloc(non_decoded_len);
618 len = g_snprintf(buf, non_decoded_len-(buf-*non_decoded), "%lu", (unsigned long)oid[0]);
620 for (i = 1; i < oid_length; i++) {
621 len = g_snprintf(buf, non_decoded_len-(buf-*non_decoded), ".%lu", (unsigned long)oid[i]);
626 #ifdef HAVE_SOME_SNMP
628 check_var_length(guint vb_length, guint required_length, guchar **errmsg)
631 static const char badlen_fmt[] = "Length is %u, should be %u";
633 if (vb_length != required_length) {
634 /* Enough room for the largest "Length is XXX,
635 should be XXX" message - 10 digits for each
637 buf = ep_alloc(sizeof badlen_fmt + 10 + 10);
639 g_snprintf(buf, sizeof badlen_fmt + 10 + 10,
640 badlen_fmt, vb_length, required_length);
645 return TRUE; /* length is OK */
649 format_var(struct variable_list *variable, subid_t *variable_oid,
650 guint variable_oid_length, gushort vb_type, guint val_len)
656 if (variable_oid == NULL || variable_oid_length == 0)
662 /* Length has to be 4 bytes. */
663 if (!check_var_length(val_len, 4, &buf))
664 return buf; /* it's not 4 bytes */
668 /* not all counters are encoded as a full 64bit integer */
670 /* Length has to be 8 bytes. */
671 if (!check_var_length(val_len, 8, &buf))
672 return buf; /* it's not 8 bytes */
679 variable->next_variable = NULL;
680 variable->name = variable_oid;
681 variable->name_length = variable_oid_length;
685 variable->type = VALTYPE_INTEGER;
689 variable->type = VALTYPE_COUNTER;
693 variable->type = VALTYPE_GAUGE;
697 variable->type = VALTYPE_TIMETICKS;
701 variable->type = VALTYPE_STRING;
705 variable->type = VALTYPE_IPADDR;
709 variable->type = VALTYPE_OPAQUE;
713 variable->type = VALTYPE_NSAP;
717 variable->type = VALTYPE_OBJECTID;
721 variable->type = VALTYPE_BITSTR;
725 variable->type = VALTYPE_COUNTER64;
728 variable->val_len = val_len;
731 * XXX - check for "sprint_realloc_objid()" failure.
735 buf = ep_alloc(buf_len);
739 /* We pass an ep allocated block here, NOT a malloced block
740 * so we MUST NOT allow reallocation, hence the fourth
741 * parameter MUST be 0/FALSE
743 sprint_realloc_value(&buf, &buf_len, &out_len, FALSE,
744 variable_oid, variable_oid_length, variable);
751 #define F_SNMP_ENGINEID_CONFORM 0x80
752 #define SNMP_ENGINEID_RFC1910 0x00
753 #define SNMP_ENGINEID_RFC3411 0x01
755 static const true_false_string tfs_snmp_engineid_conform = {
757 "RFC1910 (Non-SNMPv3)"
760 #define SNMP_ENGINEID_FORMAT_IPV4 0x01
761 #define SNMP_ENGINEID_FORMAT_IPV6 0x02
762 #define SNMP_ENGINEID_FORMAT_MACADDRESS 0x03
763 #define SNMP_ENGINEID_FORMAT_TEXT 0x04
764 #define SNMP_ENGINEID_FORMAT_OCTETS 0x05
766 static const value_string snmp_engineid_format_vals[] = {
767 { SNMP_ENGINEID_FORMAT_IPV4, "IPv4 address" },
768 { SNMP_ENGINEID_FORMAT_IPV6, "IPv6 address" },
769 { SNMP_ENGINEID_FORMAT_MACADDRESS, "MAC address" },
770 { SNMP_ENGINEID_FORMAT_TEXT, "Text, administratively assigned" },
771 { SNMP_ENGINEID_FORMAT_OCTETS, "Octets, administratively assigned" },
776 * SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)
777 * or historic RFC 1910 (AgentID)
780 dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
782 proto_item *item = NULL;
783 guint8 conformance, format;
784 guint32 enterpriseid, seconds;
786 int len_remain = len;
788 /* first bit: engine id conformance */
789 if (len_remain<4) return offset;
790 conformance = ((tvb_get_guint8(tvb, offset)>>7) && 0x01);
791 proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, FALSE);
793 /* 4-byte enterprise number/name */
794 if (len_remain<4) return offset;
795 enterpriseid = tvb_get_ntohl(tvb, offset);
797 enterpriseid -= 0x80000000; /* ignore first bit */
798 proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);
802 switch(conformance) {
804 case SNMP_ENGINEID_RFC1910:
805 /* 12-byte AgentID w/ 8-byte trailer */
807 proto_tree_add_text(tree, tvb, offset, 8, "AgentID Trailer: 0x%s",
808 tvb_bytes_to_str(tvb, offset, 8));
812 proto_tree_add_text(tree, tvb, offset, len_remain, "<Data not conforming to RFC1910>");
817 case SNMP_ENGINEID_RFC3411: /* variable length: 5..32 */
819 /* 1-byte format specifier */
820 if (len_remain<1) return offset;
821 format = tvb_get_guint8(tvb, offset);
822 item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)",
823 val_to_str(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"), format);
828 case SNMP_ENGINEID_FORMAT_IPV4:
829 /* 4-byte IPv4 address */
831 proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, FALSE);
836 case SNMP_ENGINEID_FORMAT_IPV6:
837 /* 16-byte IPv6 address */
838 if (len_remain==16) {
839 proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, FALSE);
844 case SNMP_ENGINEID_FORMAT_MACADDRESS:
845 /* 6-byte MAC address */
847 proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, FALSE);
852 case SNMP_ENGINEID_FORMAT_TEXT:
853 /* max. 27-byte string, administratively assigned */
854 if (len_remain<=27) {
855 proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, FALSE);
861 /* most common enterprise-specific format: (ucd|net)-snmp random */
862 if ((enterpriseid==2021)||(enterpriseid==8072)) {
863 proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");
864 /* demystify: 4B random, 4B epoch seconds */
866 proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, FALSE);
867 seconds = tvb_get_letohl(tvb, offset+4);
869 proto_tree_add_time_format(tree, hf_snmp_engineid_time, tvb, offset+4, 4,
870 &ts, "Engine ID Data: Creation Time: %s",
871 abs_time_secs_to_str(seconds));
877 case SNMP_ENGINEID_FORMAT_OCTETS:
879 /* max. 27 bytes, administratively assigned or unknown format */
880 if (len_remain<=27) {
881 proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, FALSE);
890 proto_tree_add_text(tree, tvb, offset, len_remain, "<Data not conforming to RFC3411>");
896 /* This code is copied from the original SNMP dissector with minor changes to adapt it to use packet-ber.c routines
898 * - Rewrite it completly as OID as subid_t could be returned from dissect_ber_objectidentifier
899 * - vb_type_name is known when calling this routine(?)
900 * - All branches not needed(?)
905 snmp_variable_decode(tvbuff_t *tvb, proto_tree *snmp_tree, packet_info *pinfo,tvbuff_t *oid_tvb,
906 int offset, guint *lengthp, tvbuff_t **out_tvb)
908 int start, vb_value_start;
912 const gchar *vb_type_name;
913 gint32 vb_integer_value;
914 guint32 vb_uinteger_value;
915 guint8 *vb_octet_string;
916 const guint8 *oid_buf;
919 gchar *vb_display_string = NULL;
920 subid_t *variable_oid = NULL;
922 guint variable_oid_length = 0;
923 const guint8 *var_oid_buf;
924 #ifdef HAVE_SOME_SNMP
925 struct variable_list variable;
932 gboolean pc, ind = 0;
936 /* parse the type of the object */
937 offset = dissect_ber_identifier(pinfo, snmp_tree, tvb, start, &class, &pc, &ber_tag);
938 offset = dissect_ber_length(pinfo, snmp_tree, tvb, offset, &vb_length, &ind);
941 length = offset - start;
946 vb_value_start = offset;
948 /* Convert the class, constructed flag, and tag to a type. */
949 vb_type_name = snmp_tag_cls2syntax(ber_tag, class, &vb_type);
951 if (vb_type_name == NULL) {
954 * Dissect the value as an opaque string of octets.
956 vb_type_name = "unsupported type";
957 vb_type = SNMP_OPAQUE;
959 /* construct subid_t variable_oid from oid_tvb */
961 oid_len = tvb_length_remaining(oid_tvb,0);
962 var_oid_buf = tvb_get_ptr(oid_tvb, 0, oid_len);
963 variable_oid = ep_alloc((oid_len+1) * sizeof(gulong));
964 variable_oid_length = oid_to_subid_buf(var_oid_buf, oid_len, variable_oid, ((oid_len+1) * sizeof(gulong)));
966 /* parse the value */
970 offset = dissect_ber_integer(FALSE, pinfo, NULL, tvb, start, -1, &vb_integer_value);
971 length = offset - vb_value_start;
973 #ifdef HAVE_SOME_SNMP
974 value = vb_integer_value;
975 variable.val.integer = &value;
976 vb_display_string = format_var(&variable,
977 variable_oid, variable_oid_length, vb_type,
980 vb_display_string = NULL;
982 if (vb_display_string != NULL) {
983 proto_tree_add_text(snmp_tree, tvb,
984 vb_value_start, length,
985 "Value: %s", vb_display_string);
987 proto_tree_add_text(snmp_tree,tvb,
988 vb_value_start, length,
989 "Value: %s: %d (%#x)", vb_type_name,
990 vb_integer_value, vb_integer_value);
998 offset = dissect_ber_integer(FALSE, pinfo, NULL, tvb, start, -1, &vb_uinteger_value);
999 length = offset - vb_value_start;
1001 #ifdef HAVE_SOME_SNMP
1002 value = vb_uinteger_value;
1003 variable.val.integer = &value;
1004 vb_display_string = format_var(&variable,
1005 variable_oid, variable_oid_length, vb_type,
1008 vb_display_string = NULL;
1010 if (vb_display_string != NULL) {
1011 proto_tree_add_text(snmp_tree, tvb,
1012 vb_value_start, length,
1013 "Value: %s", vb_display_string);
1015 proto_tree_add_text(snmp_tree, tvb,
1016 vb_value_start, length,
1017 "Value: %s: %u (%#x)", vb_type_name,
1018 vb_uinteger_value, vb_uinteger_value);
1022 case SNMP_COUNTER64:
1023 offset=dissect_ber_integer64(TRUE, pinfo, snmp_tree, tvb, offset, hf_snmp_counter64, NULL);
1030 offset = dissect_ber_octet_string(FALSE, pinfo, NULL, tvb, start, -1, out_tvb);
1031 vb_octet_string = ep_tvb_memdup(tvb, vb_value_start, vb_length);
1033 length = offset - vb_value_start;
1035 #ifdef HAVE_SOME_SNMP
1036 variable.val.string = vb_octet_string;
1037 vb_display_string = format_var(&variable,
1038 variable_oid, variable_oid_length, vb_type,
1041 vb_display_string = NULL;
1043 if (vb_display_string != NULL) {
1044 proto_tree_add_text(snmp_tree, tvb,
1045 vb_value_start, length,
1046 "Value: %s", vb_display_string);
1049 * If some characters are not printable,
1050 * display the string as bytes.
1052 for (i = 0; i < vb_length; i++) {
1053 if (!(isprint(vb_octet_string[i])
1054 || isspace(vb_octet_string[i])))
1057 if (i < vb_length) {
1059 * We stopped, due to a non-printable
1060 * character, before we got to the end
1063 vb_display_string = ep_alloc(4*vb_length);
1064 buf = vb_display_string;
1065 len = g_snprintf(buf, 4*vb_length, "%03u", vb_octet_string[0]);
1067 for (i = 1; i < vb_length; i++) {
1068 len = g_snprintf(buf, 4*vb_length-(buf-vb_display_string), ".%03u",
1069 vb_octet_string[i]);
1072 proto_tree_add_text(snmp_tree, tvb, vb_value_start,
1074 "Value: %s: %s", vb_type_name,
1077 proto_tree_add_text(snmp_tree, tvb, vb_value_start,
1079 "Value: %s: %s", vb_type_name,
1080 SAFE_STRING(vb_octet_string, vb_length));
1087 dissect_ber_null(FALSE, pinfo, NULL, tvb, start, -1);
1088 length = offset - vb_value_start;
1090 proto_tree_add_text(snmp_tree, tvb, vb_value_start, length,
1091 "Value: %s", vb_type_name);
1096 /* XXX Redo this using dissect_ber_object_identifier when
1097 it returns tvb or some other binary form of an OID */
1098 oid_buf = tvb_get_ptr(tvb, vb_value_start, vb_length);
1099 vb_oid = ep_alloc((vb_length+1) * sizeof(gulong));
1100 vb_oid_length = oid_to_subid_buf(oid_buf, vb_length, vb_oid, ((vb_length+1) * sizeof(gulong)));
1102 offset = offset + vb_length;
1103 length = offset - vb_value_start;
1105 #ifdef HAVE_SOME_SNMP
1106 variable.val.objid = vb_oid;
1107 vb_display_string = format_var(&variable,
1108 variable_oid, variable_oid_length, vb_type,
1109 vb_oid_length * sizeof (subid_t));
1110 if (vb_display_string != NULL) {
1111 proto_tree_add_text(snmp_tree, tvb,
1112 vb_value_start, length,
1113 "Value: %s", vb_display_string);
1115 proto_tree_add_text(snmp_tree, tvb,
1116 vb_value_start, length,
1117 "Value: %s: [Out of memory]", vb_type_name);
1119 #else /* HAVE_SOME_SNMP */
1120 vb_display_string = format_oid(vb_oid, vb_oid_length);
1121 if (vb_display_string != NULL) {
1122 proto_tree_add_text(snmp_tree, tvb,
1123 vb_value_start, length,
1124 "Value: %s: %s", vb_type_name,
1127 proto_tree_add_text(snmp_tree, tvb,
1128 vb_value_start, length,
1129 "Value: %s: [Out of memory]", vb_type_name);
1131 #endif /* HAVE_SOME_SNMP */
1135 case SNMP_NOSUCHOBJECT:
1136 length = offset - start;
1138 proto_tree_add_text(snmp_tree, tvb, offset, length,
1139 "Value: %s: no such object", vb_type_name);
1143 case SNMP_NOSUCHINSTANCE:
1144 length = offset - start;
1146 proto_tree_add_text(snmp_tree, tvb, offset, length,
1147 "Value: %s: no such instance", vb_type_name);
1151 case SNMP_ENDOFMIBVIEW:
1152 length = offset - start;
1154 proto_tree_add_text(snmp_tree, tvb, offset, length,
1155 "Value: %s: end of mib view", vb_type_name);
1160 DISSECTOR_ASSERT_NOT_REACHED();
1163 length = offset - start;
1169 /*--- Included file: packet-snmp-fn.c ---*/
1170 #line 1 "packet-snmp-fn.c"
1171 /*--- Fields for imported types ---*/
1177 dissect_snmp_ObjectName(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1178 offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, hf_index, &oid_tvb);
1182 static int dissect_name(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1183 return dissect_snmp_ObjectName(FALSE, tvb, offset, pinfo, tree, hf_snmp_name);
1185 static int dissect_subtree(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1186 return dissect_snmp_ObjectName(FALSE, tvb, offset, pinfo, tree, hf_snmp_subtree);
1192 dissect_snmp_NotificationName(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1193 offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
1201 dissect_snmp_Integer_value(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1202 #line 233 "snmp.cnf"
1205 snmp_variable_decode(tvb, tree, pinfo, oid_tvb, offset, &length, NULL);
1206 offset = offset + length;
1212 static int dissect_integer_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1213 return dissect_snmp_Integer_value(FALSE, tvb, offset, pinfo, tree, hf_snmp_integer_value);
1219 dissect_snmp_String_value(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1220 #line 227 "snmp.cnf"
1223 snmp_variable_decode(tvb, tree, pinfo, oid_tvb, offset, &length, &value_tvb);
1224 offset = offset + length;
1230 static int dissect_string_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1231 return dissect_snmp_String_value(FALSE, tvb, offset, pinfo, tree, hf_snmp_string_value);
1237 dissect_snmp_ObjectID_value(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1238 #line 239 "snmp.cnf"
1241 snmp_variable_decode(tvb, tree, pinfo, oid_tvb, offset, &length, NULL);
1242 offset = offset + length;
1248 static int dissect_objectID_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1249 return dissect_snmp_ObjectID_value(FALSE, tvb, offset, pinfo, tree, hf_snmp_objectID_value);
1255 dissect_snmp_Empty(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1256 #line 245 "snmp.cnf"
1259 snmp_variable_decode(tvb, tree, pinfo, oid_tvb, offset, &length, NULL);
1260 offset = offset + length;
1268 static int dissect_empty(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1269 return dissect_snmp_Empty(FALSE, tvb, offset, pinfo, tree, hf_snmp_empty);
1273 static const value_string snmp_SimpleSyntax_vals[] = {
1274 { 0, "integer-value" },
1275 { 1, "string-value" },
1276 { 2, "objectID-value" },
1281 static const ber_choice_t SimpleSyntax_choice[] = {
1282 { 0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_integer_value },
1283 { 1, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_string_value },
1284 { 2, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_objectID_value },
1285 { 3, BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_empty },
1286 { 0, 0, 0, 0, NULL }
1290 dissect_snmp_SimpleSyntax(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1291 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1292 SimpleSyntax_choice, hf_index, ett_snmp_SimpleSyntax,
1297 static int dissect_simple(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1298 return dissect_snmp_SimpleSyntax(FALSE, tvb, offset, pinfo, tree, hf_snmp_simple);
1304 dissect_snmp_IpAddress(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1305 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1310 static int dissect_ipAddress_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1311 return dissect_snmp_IpAddress(FALSE, tvb, offset, pinfo, tree, hf_snmp_ipAddress_value);
1313 static int dissect_internet(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1314 return dissect_snmp_IpAddress(FALSE, tvb, offset, pinfo, tree, hf_snmp_internet);
1320 dissect_snmp_Counter32(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1321 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1326 static int dissect_counter_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1327 return dissect_snmp_Counter32(FALSE, tvb, offset, pinfo, tree, hf_snmp_counter_value);
1333 dissect_snmp_TimeTicks(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1334 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1339 static int dissect_timeticks_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1340 return dissect_snmp_TimeTicks(FALSE, tvb, offset, pinfo, tree, hf_snmp_timeticks_value);
1342 static int dissect_time_stamp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1343 return dissect_snmp_TimeTicks(FALSE, tvb, offset, pinfo, tree, hf_snmp_time_stamp);
1349 dissect_snmp_Opaque(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1350 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1355 static int dissect_arbitrary_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1356 return dissect_snmp_Opaque(FALSE, tvb, offset, pinfo, tree, hf_snmp_arbitrary_value);
1362 dissect_snmp_Counter64(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1363 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1368 static int dissect_big_counter_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1369 return dissect_snmp_Counter64(FALSE, tvb, offset, pinfo, tree, hf_snmp_big_counter_value);
1375 dissect_snmp_Unsigned32(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1376 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1381 static int dissect_unsigned_integer_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1382 return dissect_snmp_Unsigned32(FALSE, tvb, offset, pinfo, tree, hf_snmp_unsigned_integer_value);
1386 static const value_string snmp_ApplicationSyntax_vals[] = {
1387 { 0, "ipAddress-value" },
1388 { 1, "counter-value" },
1389 { 3, "timeticks-value" },
1390 { 4, "arbitrary-value" },
1391 { 6, "big-counter-value" },
1392 { 2, "unsigned-integer-value" },
1396 static const ber_choice_t ApplicationSyntax_choice[] = {
1397 { 0, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_ipAddress_value },
1398 { 1, BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_counter_value },
1399 { 3, BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_timeticks_value },
1400 { 4, BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_arbitrary_value },
1401 { 6, BER_CLASS_APP, 6, BER_FLAGS_NOOWNTAG, dissect_big_counter_value },
1402 { 2, BER_CLASS_APP, 2, BER_FLAGS_NOOWNTAG, dissect_unsigned_integer_value },
1403 { 0, 0, 0, 0, NULL }
1407 dissect_snmp_ApplicationSyntax(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1408 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1409 ApplicationSyntax_choice, hf_index, ett_snmp_ApplicationSyntax,
1414 static int dissect_application_wide(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1415 return dissect_snmp_ApplicationSyntax(FALSE, tvb, offset, pinfo, tree, hf_snmp_application_wide);
1419 static const value_string snmp_ObjectSyntax_vals[] = {
1420 { -1/*choice*/, "simple" },
1421 { -1/*choice*/, "application-wide" },
1425 static const ber_choice_t ObjectSyntax_choice[] = {
1426 { -1/*choice*/, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_simple },
1427 { -1/*choice*/, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_application_wide },
1428 { 0, 0, 0, 0, NULL }
1432 dissect_snmp_ObjectSyntax(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1433 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1434 ObjectSyntax_choice, hf_index, ett_snmp_ObjectSyntax,
1439 static int dissect_value(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1440 return dissect_snmp_ObjectSyntax(FALSE, tvb, offset, pinfo, tree, hf_snmp_value);
1446 dissect_snmp_Integer32(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1447 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1452 static int dissect_bulkPDU_request_id(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1453 return dissect_snmp_Integer32(FALSE, tvb, offset, pinfo, tree, hf_snmp_bulkPDU_request_id);
1457 static const value_string snmp_NetworkAddress_vals[] = {
1462 static const ber_choice_t NetworkAddress_choice[] = {
1463 { 0, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_internet },
1464 { 0, 0, 0, 0, NULL }
1468 dissect_snmp_NetworkAddress(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1469 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1470 NetworkAddress_choice, hf_index, ett_snmp_NetworkAddress,
1475 static int dissect_agent_addr(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1476 return dissect_snmp_NetworkAddress(FALSE, tvb, offset, pinfo, tree, hf_snmp_agent_addr);
1482 dissect_snmp_Gauge32(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1483 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1490 static const value_string snmp_Version_vals[] = {
1500 dissect_snmp_Version(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1501 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1506 static int dissect_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1507 return dissect_snmp_Version(FALSE, tvb, offset, pinfo, tree, hf_snmp_version);
1509 static int dissect_msgVersion(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1510 return dissect_snmp_Version(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgVersion);
1516 dissect_snmp_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1517 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1522 static int dissect_community(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1523 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_community);
1525 static int dissect_parameters(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1526 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_parameters);
1528 static int dissect_encrypted(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1529 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_encrypted);
1531 static int dissect_msgAuthenticationParameters(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1532 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgAuthenticationParameters);
1534 static int dissect_msgPrivacyParameters(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1535 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgPrivacyParameters);
1537 static int dissect_encryptedPDU(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1538 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_encryptedPDU);
1540 static int dissect_contextEngineID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1541 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_contextEngineID);
1543 static int dissect_contextName(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1544 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_contextName);
1546 static int dissect_password(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1547 return dissect_snmp_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_snmp_password);
1553 dissect_snmp_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1554 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1559 static int dissect_request_id(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1560 return dissect_snmp_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_snmp_request_id);
1562 static int dissect_error_index(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1563 return dissect_snmp_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_snmp_error_index);
1565 static int dissect_specific_trap(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1566 return dissect_snmp_INTEGER(FALSE, tvb, offset, pinfo, tree, hf_snmp_specific_trap);
1570 static const value_string snmp_T_error_status_vals[] = {
1573 { 2, "noSuchName" },
1579 { 8, "wrongLength" },
1580 { 9, "wrongEncoding" },
1581 { 10, "wrongValue" },
1582 { 11, "noCreation" },
1583 { 12, "inconsistentValue" },
1584 { 13, "resourceUnavailable" },
1585 { 14, "commitFailed" },
1586 { 15, "undoFailed" },
1587 { 16, "authorizationError" },
1588 { 17, "notWritable" },
1589 { 18, "inconsistentName" },
1595 dissect_snmp_T_error_status(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1596 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1601 static int dissect_error_status(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1602 return dissect_snmp_T_error_status(FALSE, tvb, offset, pinfo, tree, hf_snmp_error_status);
1608 dissect_snmp_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1609 offset = dissect_ber_null(implicit_tag, pinfo, tree, tvb, offset, hf_index);
1613 static int dissect_unSpecified(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1614 return dissect_snmp_NULL(FALSE, tvb, offset, pinfo, tree, hf_snmp_unSpecified);
1616 static int dissect_noSuchObject_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1617 return dissect_snmp_NULL(TRUE, tvb, offset, pinfo, tree, hf_snmp_noSuchObject);
1619 static int dissect_noSuchInstance_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1620 return dissect_snmp_NULL(TRUE, tvb, offset, pinfo, tree, hf_snmp_noSuchInstance);
1622 static int dissect_endOfMibView_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1623 return dissect_snmp_NULL(TRUE, tvb, offset, pinfo, tree, hf_snmp_endOfMibView);
1627 static const value_string snmp_ValueType_vals[] = {
1629 { 1, "unSpecified" },
1630 { 2, "noSuchObject" },
1631 { 3, "noSuchInstance" },
1632 { 4, "endOfMibView" },
1636 static const ber_choice_t ValueType_choice[] = {
1637 { 0, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_value },
1638 { 1, BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_unSpecified },
1639 { 2, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_noSuchObject_impl },
1640 { 3, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_noSuchInstance_impl },
1641 { 4, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_endOfMibView_impl },
1642 { 0, 0, 0, 0, NULL }
1646 dissect_snmp_ValueType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1647 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1648 ValueType_choice, hf_index, ett_snmp_ValueType,
1653 static int dissect_valueType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1654 return dissect_snmp_ValueType(FALSE, tvb, offset, pinfo, tree, hf_snmp_valueType);
1658 static const ber_sequence_t VarBind_sequence[] = {
1659 { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_name },
1660 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_valueType },
1665 dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1666 #line 213 "snmp.cnf"
1669 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1670 VarBind_sequence, hf_index, ett_snmp_VarBind);
1672 if (oid_tvb && value_tvb) {
1673 next_tvb_add_string(&var_list, value_tvb, (snmp_var_in_tree) ? tree : NULL,
1674 variable_oid_dissector_table,
1675 oid_to_str(tvb_get_ptr(oid_tvb, 0, tvb_length(oid_tvb)), tvb_length(oid_tvb)));
1682 static int dissect_VarBindList_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1683 return dissect_snmp_VarBind(FALSE, tvb, offset, pinfo, tree, hf_snmp_VarBindList_item);
1687 static const ber_sequence_t VarBindList_sequence_of[1] = {
1688 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_VarBindList_item },
1692 dissect_snmp_VarBindList(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1693 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1694 VarBindList_sequence_of, hf_index, ett_snmp_VarBindList);
1698 static int dissect_variable_bindings(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1699 return dissect_snmp_VarBindList(FALSE, tvb, offset, pinfo, tree, hf_snmp_variable_bindings);
1703 static const ber_sequence_t PDU_sequence[] = {
1704 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_request_id },
1705 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_error_status },
1706 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_error_index },
1707 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_variable_bindings },
1712 dissect_snmp_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1713 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1714 PDU_sequence, hf_index, ett_snmp_PDU);
1722 dissect_snmp_GetRequest_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1723 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1731 dissect_snmp_T_get_request(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1734 gboolean pc, ind_field;
1739 /* XXX asn2wrs can not yet handle tagged assignment yes so this
1740 * XXX is some conformance file magic to work around that bug
1742 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
1743 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
1745 offset = dissect_snmp_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
1751 static int dissect_get_request(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1752 return dissect_snmp_T_get_request(FALSE, tvb, offset, pinfo, tree, hf_snmp_get_request);
1758 dissect_snmp_GetNextRequest_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1759 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1767 dissect_snmp_T_get_next_request(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1770 gboolean pc, ind_field;
1775 /* XXX asn2wrs can not yet handle tagged assignment yes so this
1776 * XXX is some conformance file magic to work around that bug
1778 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
1779 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
1781 offset = dissect_snmp_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
1787 static int dissect_get_next_request(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1788 return dissect_snmp_T_get_next_request(FALSE, tvb, offset, pinfo, tree, hf_snmp_get_next_request);
1794 dissect_snmp_GetResponse_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1795 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1803 dissect_snmp_T_get_response(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1806 gboolean pc, ind_field;
1811 /* XXX asn2wrs can not yet handle tagged assignment yes so this
1812 * XXX is some conformance file magic to work around that bug
1814 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
1815 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
1817 offset = dissect_snmp_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
1823 static int dissect_get_response(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1824 return dissect_snmp_T_get_response(FALSE, tvb, offset, pinfo, tree, hf_snmp_get_response);
1830 dissect_snmp_SetRequest_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1831 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1839 dissect_snmp_T_set_request(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1842 gboolean pc, ind_field;
1847 /* XXX asn2wrs can not yet handle tagged assignment yes so this
1848 * XXX is some conformance file magic to work around that bug
1850 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
1851 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
1853 offset = dissect_snmp_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
1860 static int dissect_set_request(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1861 return dissect_snmp_T_set_request(FALSE, tvb, offset, pinfo, tree, hf_snmp_set_request);
1867 dissect_snmp_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1868 offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
1872 static int dissect_enterprise(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1873 return dissect_snmp_OBJECT_IDENTIFIER(FALSE, tvb, offset, pinfo, tree, hf_snmp_enterprise);
1875 static int dissect_identity(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1876 return dissect_snmp_OBJECT_IDENTIFIER(FALSE, tvb, offset, pinfo, tree, hf_snmp_identity);
1880 static const value_string snmp_T_generic_trap_vals[] = {
1885 { 4, "authenticationFailure" },
1886 { 5, "egpNeighborLoss" },
1887 { 6, "enterpriseSpecific" },
1893 dissect_snmp_T_generic_trap(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1894 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1899 static int dissect_generic_trap(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1900 return dissect_snmp_T_generic_trap(FALSE, tvb, offset, pinfo, tree, hf_snmp_generic_trap);
1904 static const ber_sequence_t Trap_PDU_sequence[] = {
1905 { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_enterprise },
1906 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_agent_addr },
1907 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_generic_trap },
1908 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_specific_trap },
1909 { BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_time_stamp },
1910 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_variable_bindings },
1915 dissect_snmp_Trap_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1916 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1917 Trap_PDU_sequence, hf_index, ett_snmp_Trap_PDU);
1925 dissect_snmp_T_trap(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1928 gboolean pc, ind_field;
1933 /* XXX asn2wrs can not yet handle tagged assignment yes so this
1934 * XXX is some conformance file magic to work around that bug
1936 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
1937 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
1939 offset = dissect_snmp_Trap_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
1945 static int dissect_trap(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1946 return dissect_snmp_T_trap(FALSE, tvb, offset, pinfo, tree, hf_snmp_trap);
1952 dissect_snmp_INTEGER_0_2147483647(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1953 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1958 static int dissect_msgAuthoritativeEngineBoots(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1959 return dissect_snmp_INTEGER_0_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgAuthoritativeEngineBoots);
1961 static int dissect_msgAuthoritativeEngineTime(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1962 return dissect_snmp_INTEGER_0_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgAuthoritativeEngineTime);
1964 static int dissect_msgID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1965 return dissect_snmp_INTEGER_0_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgID);
1967 static int dissect_non_repeaters(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1968 return dissect_snmp_INTEGER_0_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_non_repeaters);
1970 static int dissect_max_repetitions(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1971 return dissect_snmp_INTEGER_0_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_max_repetitions);
1975 static const ber_sequence_t BulkPDU_sequence[] = {
1976 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_bulkPDU_request_id },
1977 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_non_repeaters },
1978 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_max_repetitions },
1979 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_variable_bindings },
1984 dissect_snmp_BulkPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1985 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1986 BulkPDU_sequence, hf_index, ett_snmp_BulkPDU);
1994 dissect_snmp_GetBulkRequest_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1995 offset = dissect_snmp_BulkPDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2003 dissect_snmp_T_getBulkRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2004 #line 107 "snmp.cnf"
2006 gboolean pc, ind_field;
2011 /* XXX asn2wrs can not yet handle tagged assignment yes so this
2012 * XXX is some conformance file magic to work around that bug
2014 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
2015 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
2017 offset = dissect_snmp_GetBulkRequest_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
2023 static int dissect_getBulkRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2024 return dissect_snmp_T_getBulkRequest(FALSE, tvb, offset, pinfo, tree, hf_snmp_getBulkRequest);
2030 dissect_snmp_InformRequest_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2031 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2039 dissect_snmp_T_informRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2040 #line 122 "snmp.cnf"
2042 gboolean pc, ind_field;
2047 /* XXX asn2wrs can not yet handle tagged assignment yes so this
2048 * XXX is some conformance file magic to work around that bug
2050 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
2051 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
2053 offset = dissect_snmp_InformRequest_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
2059 static int dissect_informRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2060 return dissect_snmp_T_informRequest(FALSE, tvb, offset, pinfo, tree, hf_snmp_informRequest);
2066 dissect_snmp_SNMPv2_Trap_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2067 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2075 dissect_snmp_T_sNMPv2_Trap(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2076 #line 137 "snmp.cnf"
2078 gboolean pc, ind_field;
2083 /* XXX asn2wrs can not yet handle tagged assignment yes so this
2084 * XXX is some conformance file magic to work around that bug
2086 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
2087 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
2089 offset = dissect_snmp_SNMPv2_Trap_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
2095 static int dissect_sNMPv2_Trap(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2096 return dissect_snmp_T_sNMPv2_Trap(FALSE, tvb, offset, pinfo, tree, hf_snmp_sNMPv2_Trap);
2102 dissect_snmp_Report_PDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2103 offset = dissect_snmp_PDU(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2111 dissect_snmp_T_report(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2112 #line 152 "snmp.cnf"
2114 gboolean pc, ind_field;
2119 /* XXX asn2wrs can not yet handle tagged assignment yes so this
2120 * XXX is some conformance file magic to work around that bug
2122 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
2123 offset = get_ber_length(tree, tvb, offset, &len1, &ind_field);
2125 offset = dissect_snmp_Report_PDU(TRUE, tvb, offset, pinfo, tree, hf_index);
2131 static int dissect_report(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2132 return dissect_snmp_T_report(FALSE, tvb, offset, pinfo, tree, hf_snmp_report);
2136 static const value_string snmp_PDUs_vals[] = {
2137 { 0, "get-request" },
2138 { 1, "get-next-request" },
2139 { 2, "get-response" },
2140 { 3, "set-request" },
2142 { 5, "getBulkRequest" },
2143 { 6, "informRequest" },
2144 { 7, "sNMPv2-Trap" },
2149 static const ber_choice_t PDUs_choice[] = {
2150 { 0, BER_CLASS_CON, 0, BER_FLAGS_NOOWNTAG, dissect_get_request },
2151 { 1, BER_CLASS_CON, 1, BER_FLAGS_NOOWNTAG, dissect_get_next_request },
2152 { 2, BER_CLASS_CON, 2, BER_FLAGS_NOOWNTAG, dissect_get_response },
2153 { 3, BER_CLASS_CON, 3, BER_FLAGS_NOOWNTAG, dissect_set_request },
2154 { 4, BER_CLASS_CON, 4, BER_FLAGS_NOOWNTAG, dissect_trap },
2155 { 5, BER_CLASS_CON, 5, BER_FLAGS_NOOWNTAG, dissect_getBulkRequest },
2156 { 6, BER_CLASS_CON, 6, BER_FLAGS_NOOWNTAG, dissect_informRequest },
2157 { 7, BER_CLASS_CON, 7, BER_FLAGS_NOOWNTAG, dissect_sNMPv2_Trap },
2158 { 8, BER_CLASS_CON, 8, BER_FLAGS_NOOWNTAG, dissect_report },
2159 { 0, 0, 0, 0, NULL }
2163 dissect_snmp_PDUs(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2168 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2169 PDUs_choice, hf_index, ett_snmp_PDUs,
2172 if (check_col(pinfo->cinfo, COL_INFO))
2173 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(pdu_type, snmp_PDUs_vals,"Unknown PDU type (%u)"));
2179 static int dissect_data(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2180 return dissect_snmp_PDUs(FALSE, tvb, offset, pinfo, tree, hf_snmp_data);
2182 static int dissect_v2u_plaintext(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2183 return dissect_snmp_PDUs(FALSE, tvb, offset, pinfo, tree, hf_snmp_v2u_plaintext);
2185 static int dissect_pDUs(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2186 return dissect_snmp_PDUs(FALSE, tvb, offset, pinfo, tree, hf_snmp_pDUs);
2190 static const ber_sequence_t Message_sequence[] = {
2191 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
2192 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_community },
2193 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_data },
2198 dissect_snmp_Message(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2199 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2200 Message_sequence, hf_index, ett_snmp_Message);
2206 static const value_string snmp_T_datav2u_vals[] = {
2212 static const ber_choice_t T_datav2u_choice[] = {
2213 { 0, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_v2u_plaintext },
2214 { 1, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_encrypted },
2215 { 0, 0, 0, 0, NULL }
2219 dissect_snmp_T_datav2u(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2220 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2221 T_datav2u_choice, hf_index, ett_snmp_T_datav2u,
2226 static int dissect_datav2u(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2227 return dissect_snmp_T_datav2u(FALSE, tvb, offset, pinfo, tree, hf_snmp_datav2u);
2231 static const ber_sequence_t Messagev2u_sequence[] = {
2232 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
2233 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_parameters },
2234 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_datav2u },
2239 dissect_snmp_Messagev2u(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2240 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2241 Messagev2u_sequence, hf_index, ett_snmp_Messagev2u);
2249 dissect_snmp_SnmpEngineID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2250 #line 189 "snmp.cnf"
2251 tvbuff_t *parameter_tvb = NULL;
2252 proto_tree *engineid_tree = NULL;
2253 proto_item *item = NULL;
2255 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2259 dissect_snmp_engineid(tree, parameter_tvb, 0, tvb_length_remaining(parameter_tvb,0));
2265 static int dissect_msgAuthoritativeEngineID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2266 return dissect_snmp_SnmpEngineID(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgAuthoritativeEngineID);
2272 dissect_snmp_OCTET_STRING_SIZE_1_32(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2273 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2278 static int dissect_msgUserName(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2279 return dissect_snmp_OCTET_STRING_SIZE_1_32(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgUserName);
2283 static const ber_sequence_t UsmSecurityParameters_sequence[] = {
2284 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_msgAuthoritativeEngineID },
2285 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_msgAuthoritativeEngineBoots },
2286 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_msgAuthoritativeEngineTime },
2287 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_msgUserName },
2288 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_msgAuthenticationParameters },
2289 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_msgPrivacyParameters },
2294 dissect_snmp_UsmSecurityParameters(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2295 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2296 UsmSecurityParameters_sequence, hf_index, ett_snmp_UsmSecurityParameters);
2304 dissect_snmp_INTEGER_484_2147483647(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2305 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2310 static int dissect_msgMaxSize(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2311 return dissect_snmp_INTEGER_484_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgMaxSize);
2317 dissect_snmp_T_msgFlags(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2318 #line 202 "snmp.cnf"
2319 tvbuff_t *parameter_tvb = NULL;
2321 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2326 proto_tree_add_item(tree, hf_snmp_v3_flags_report, parameter_tvb, 0, 1, FALSE);
2327 proto_tree_add_item(tree, hf_snmp_v3_flags_crypt, parameter_tvb, 0, 1, FALSE);
2328 proto_tree_add_item(tree, hf_snmp_v3_flags_auth, parameter_tvb, 0, 1, FALSE);
2335 static int dissect_msgFlags(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2336 return dissect_snmp_T_msgFlags(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgFlags);
2342 dissect_snmp_T_msgSecurityModel(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2343 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2348 static int dissect_msgSecurityModel(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2349 return dissect_snmp_T_msgSecurityModel(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgSecurityModel);
2353 static const ber_sequence_t HeaderData_sequence[] = {
2354 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_msgID },
2355 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_msgMaxSize },
2356 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_msgFlags },
2357 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_msgSecurityModel },
2362 dissect_snmp_HeaderData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2363 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2364 HeaderData_sequence, hf_index, ett_snmp_HeaderData);
2368 static int dissect_msgGlobalData(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2369 return dissect_snmp_HeaderData(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgGlobalData);
2375 dissect_snmp_T_msgSecurityParameters(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2376 #line 171 "snmp.cnf"
2378 switch(MsgSecurityModel){
2379 case SNMP_SEC_USM: /* 3 */
2380 offset = dissect_snmp_UsmSecurityParameters(FALSE, tvb, offset+2, pinfo, tree, -1);
2382 case SNMP_SEC_ANY: /* 0 */
2383 case SNMP_SEC_V1: /* 1 */
2384 case SNMP_SEC_V2C: /* 2 */
2386 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2396 static int dissect_msgSecurityParameters(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2397 return dissect_snmp_T_msgSecurityParameters(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgSecurityParameters);
2401 static const ber_sequence_t ScopedPDU_sequence[] = {
2402 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_contextEngineID },
2403 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_contextName },
2404 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_data },
2409 dissect_snmp_ScopedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2410 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2411 ScopedPDU_sequence, hf_index, ett_snmp_ScopedPDU);
2415 static int dissect_plaintext(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2416 return dissect_snmp_ScopedPDU(FALSE, tvb, offset, pinfo, tree, hf_snmp_plaintext);
2420 static const value_string snmp_ScopedPduData_vals[] = {
2422 { 1, "encryptedPDU" },
2426 static const ber_choice_t ScopedPduData_choice[] = {
2427 { 0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_plaintext },
2428 { 1, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_encryptedPDU },
2429 { 0, 0, 0, 0, NULL }
2433 dissect_snmp_ScopedPduData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2434 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2435 ScopedPduData_choice, hf_index, ett_snmp_ScopedPduData,
2440 static int dissect_msgData(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2441 return dissect_snmp_ScopedPduData(FALSE, tvb, offset, pinfo, tree, hf_snmp_msgData);
2445 static const ber_sequence_t SNMPv3Message_sequence[] = {
2446 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_msgVersion },
2447 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_msgGlobalData },
2448 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_msgSecurityParameters },
2449 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_msgData },
2454 dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2455 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2456 SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);
2462 static const value_string snmp_T_smux_version_vals[] = {
2469 dissect_snmp_T_smux_version(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2470 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2475 static int dissect_smux_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2476 return dissect_snmp_T_smux_version(FALSE, tvb, offset, pinfo, tree, hf_snmp_smux_version);
2482 dissect_snmp_DisplayString(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2483 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2488 static int dissect_description(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2489 return dissect_snmp_DisplayString(FALSE, tvb, offset, pinfo, tree, hf_snmp_description);
2493 static const ber_sequence_t SimpleOpen_sequence[] = {
2494 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smux_version },
2495 { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_identity },
2496 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_description },
2497 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_password },
2502 dissect_snmp_SimpleOpen(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2503 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2504 SimpleOpen_sequence, hf_index, ett_snmp_SimpleOpen);
2508 static int dissect_smux_simple(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2509 return dissect_snmp_SimpleOpen(FALSE, tvb, offset, pinfo, tree, hf_snmp_smux_simple);
2513 static const value_string snmp_OpenPDU_vals[] = {
2514 { 0, "smux-simple" },
2518 static const ber_choice_t OpenPDU_choice[] = {
2519 { 0, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_smux_simple },
2520 { 0, 0, 0, 0, NULL }
2524 dissect_snmp_OpenPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2525 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2526 OpenPDU_choice, hf_index, ett_snmp_OpenPDU,
2531 static int dissect_open(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2532 return dissect_snmp_OpenPDU(FALSE, tvb, offset, pinfo, tree, hf_snmp_open);
2536 static const value_string snmp_ClosePDU_vals[] = {
2538 { 1, "unsupportedVersion" },
2539 { 2, "packetFormat" },
2540 { 3, "protocolError" },
2541 { 4, "internalError" },
2542 { 5, "authenticationFailure" },
2548 dissect_snmp_ClosePDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2549 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2554 static int dissect_close(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2555 return dissect_snmp_ClosePDU(FALSE, tvb, offset, pinfo, tree, hf_snmp_close);
2561 dissect_snmp_INTEGER_M1_2147483647(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2562 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2567 static int dissect_priority(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2568 return dissect_snmp_INTEGER_M1_2147483647(FALSE, tvb, offset, pinfo, tree, hf_snmp_priority);
2572 static const value_string snmp_T_operation_vals[] = {
2581 dissect_snmp_T_operation(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2582 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2587 static int dissect_operation(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2588 return dissect_snmp_T_operation(FALSE, tvb, offset, pinfo, tree, hf_snmp_operation);
2592 static const ber_sequence_t RReqPDU_sequence[] = {
2593 { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_subtree },
2594 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_priority },
2595 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_operation },
2600 dissect_snmp_RReqPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2601 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2602 RReqPDU_sequence, hf_index, ett_snmp_RReqPDU);
2606 static int dissect_registerRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2607 return dissect_snmp_RReqPDU(FALSE, tvb, offset, pinfo, tree, hf_snmp_registerRequest);
2611 static const value_string snmp_RRspPDU_vals[] = {
2618 dissect_snmp_RRspPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2619 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2624 static int dissect_rRspPDU(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2625 return dissect_snmp_RRspPDU(FALSE, tvb, offset, pinfo, tree, hf_snmp_rRspPDU);
2629 static const value_string snmp_RegisterResponse_vals[] = {
2635 static const ber_choice_t RegisterResponse_choice[] = {
2636 { 0, BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_rRspPDU },
2637 { 1, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_pDUs },
2638 { 0, 0, 0, 0, NULL }
2642 dissect_snmp_RegisterResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2643 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2644 RegisterResponse_choice, hf_index, ett_snmp_RegisterResponse,
2649 static int dissect_registerResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2650 return dissect_snmp_RegisterResponse(FALSE, tvb, offset, pinfo, tree, hf_snmp_registerResponse);
2654 static const value_string snmp_SOutPDU_vals[] = {
2662 dissect_snmp_SOutPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2663 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2668 static int dissect_commitOrRollback(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2669 return dissect_snmp_SOutPDU(FALSE, tvb, offset, pinfo, tree, hf_snmp_commitOrRollback);
2673 static const value_string snmp_SMUX_PDUs_vals[] = {
2676 { 2, "registerRequest" },
2677 { 3, "registerResponse" },
2678 { 4, "commitOrRollback" },
2682 static const ber_choice_t SMUX_PDUs_choice[] = {
2683 { 0, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_open },
2684 { 1, BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_close },
2685 { 2, BER_CLASS_APP, 2, BER_FLAGS_NOOWNTAG, dissect_registerRequest },
2686 { 3, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_registerResponse },
2687 { 4, BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_commitOrRollback },
2688 { 0, 0, 0, 0, NULL }
2692 dissect_snmp_SMUX_PDUs(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2693 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2694 SMUX_PDUs_choice, hf_index, ett_snmp_SMUX_PDUs,
2702 static void dissect_SMUX_PDUs_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
2703 dissect_snmp_SMUX_PDUs(FALSE, tvb, 0, pinfo, tree, hf_snmp_SMUX_PDUs_PDU);
2707 /*--- End of included file: packet-snmp-fn.c ---*/
2708 #line 1044 "packet-snmp-template.c"
2711 dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
2712 proto_tree *tree, int proto, gint ett, gboolean is_tcp)
2715 guint length_remaining;
2717 gboolean pc, ind = 0;
2720 guint message_length;
2721 int start_offset = offset;
2722 guint32 version = 0;
2724 proto_tree *snmp_tree = NULL;
2725 proto_item *item = NULL;
2728 * This will throw an exception if we don't have any data left.
2729 * That's what we want. (See "tcp_dissect_pdus()", which is
2730 * similar, but doesn't have to deal with ASN.1.
2731 * XXX - can we make "tcp_dissect_pdus()" provide enough
2732 * information to the "get_pdu_len" routine so that we could
2733 * have that routine deal with ASN.1, and just use
2734 * "tcp_dissect_pdus()"?)
2736 length_remaining = tvb_ensure_length_remaining(tvb, offset);
2738 /* NOTE: we have to parse the message piece by piece, since the
2739 * capture length may be less than the message length: a 'global'
2740 * parsing is likely to fail.
2744 * If this is SNMP-over-TCP, we might have to do reassembly
2745 * in order to read the "Sequence Of" header.
2747 if (is_tcp && snmp_desegment && pinfo->can_desegment) {
2749 * This is TCP, and we should, and can, do reassembly.
2751 * Is the "Sequence Of" header split across segment
2752 * boundaries? We requre at least 6 bytes for the
2753 * header, which allows for a 4-byte length (ASN.1
2756 if (length_remaining < 6) {
2757 pinfo->desegment_offset = offset;
2758 pinfo->desegment_len = 6 - length_remaining;
2761 * Return 0, which means "I didn't dissect anything
2762 * because I don't have enough data - we need
2770 * OK, try to read the "Sequence Of" header; this gets the total
2771 * length of the SNMP message.
2773 /* Set tree to 0 to not display internakl BER fields if option used.*/
2774 offset = dissect_ber_identifier(pinfo, 0, tvb, offset, &class, &pc, &tag);
2775 offset = dissect_ber_length(pinfo, 0, tvb, offset, &len, &ind);
2777 message_length = len + 2;
2778 offset = dissect_ber_integer(FALSE, pinfo, 0, tvb, offset, -1, &version);
2782 * If this is SNMP-over-TCP, we might have to do reassembly
2783 * to get all of this message.
2785 if (is_tcp && snmp_desegment && pinfo->can_desegment) {
2787 * Yes - is the message split across segment boundaries?
2789 if (length_remaining < message_length) {
2791 * Yes. Tell the TCP dissector where the data
2792 * for this message starts in the data it handed
2793 * us, and how many more bytes we need, and
2796 pinfo->desegment_offset = start_offset;
2797 pinfo->desegment_len =
2798 message_length - length_remaining;
2801 * Return 0, which means "I didn't dissect anything
2802 * because I don't have enough data - we need
2809 next_tvb_init(&var_list);
2811 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
2812 col_set_str(pinfo->cinfo, COL_PROTOCOL,
2813 proto_get_protocol_short_name(find_protocol_by_id(proto)));
2817 item = proto_tree_add_item(tree, proto, tvb, offset,
2818 message_length, FALSE);
2819 snmp_tree = proto_item_add_subtree(item, ett);
2825 offset = dissect_snmp_Message(FALSE , tvb, start_offset, pinfo, snmp_tree, -1);
2828 offset = dissect_snmp_Messagev2u(FALSE , tvb, start_offset, pinfo, snmp_tree, -1);
2832 offset = dissect_snmp_SNMPv3Message(FALSE , tvb, start_offset, pinfo, snmp_tree, -1);
2836 * Return the length remaining in the tvbuff, so
2837 * if this is SNMP-over-TCP, our caller thinks there's
2838 * nothing left to dissect.
2840 proto_tree_add_text(snmp_tree, tvb, offset, -1,"Unknown version");
2841 return length_remaining;
2845 next_tvb_call(&var_list, pinfo, tree, NULL, data_handle);
2851 dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2853 conversation_t *conversation;
2862 * See if this looks like SNMP or not. if not, return 0 so
2863 * wireshark can try som other dissector instead.
2865 /* All SNMP packets are BER encoded and consist of a SEQUENCE
2866 * that spans the entire PDU. The first item is an INTEGER that
2867 * has the values 0-2 (version 1-3).
2868 * if not it is not snmp.
2870 /* SNMP starts with a SEQUENCE */
2871 offset = get_ber_identifier(tvb, 0, &tmp_class, &tmp_pc, &tmp_tag);
2872 if((tmp_class!=BER_CLASS_UNI)||(tmp_tag!=BER_UNI_TAG_SEQUENCE)){
2875 /* then comes a length which spans the rest of the tvb */
2876 offset = get_ber_length(NULL, tvb, offset, &tmp_length, &tmp_ind);
2877 if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)){
2880 /* then comes an INTEGER (version)*/
2881 offset = get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
2882 if((tmp_class!=BER_CLASS_UNI)||(tmp_tag!=BER_UNI_TAG_INTEGER)){
2885 /* do we need to test that version is 0 - 2 (version1-3) ? */
2889 * The first SNMP packet goes to the SNMP port; the second one
2890 * may come from some *other* port, but goes back to the same
2891 * IP address and port as the ones from which the first packet
2892 * came; all subsequent packets presumably go between those two
2893 * IP addresses and ports.
2895 * If this packet went to the SNMP port, we check to see if
2896 * there's already a conversation with one address/port pair
2897 * matching the source IP address and port of this packet,
2898 * the other address matching the destination IP address of this
2899 * packet, and any destination port.
2901 * If not, we create one, with its address 1/port 1 pair being
2902 * the source address/port of this packet, its address 2 being
2903 * the destination address of this packet, and its port 2 being
2904 * wildcarded, and give it the SNMP dissector as a dissector.
2906 if (pinfo->destport == UDP_PORT_SNMP) {
2907 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
2908 pinfo->srcport, 0, NO_PORT_B);
2909 if( (conversation == NULL) || (conversation->dissector_handle!=snmp_handle) ){
2910 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
2911 pinfo->srcport, 0, NO_PORT2);
2912 conversation_set_dissector(conversation, snmp_handle);
2916 return dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, FALSE);
2919 dissect_snmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2924 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2925 message_len = dissect_snmp_pdu(tvb, 0, pinfo, tree,
2926 proto_snmp, ett_snmp, TRUE);
2927 if (message_len == 0) {
2929 * We don't have all the data for that message,
2930 * so we need to do desegmentation;
2931 * "dissect_snmp_pdu()" has set that up.
2935 offset += message_len;
2940 dissect_smux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2942 proto_tree *smux_tree = NULL;
2943 proto_item *item = NULL;
2945 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2946 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMUX");
2949 item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, FALSE);
2950 smux_tree = proto_item_add_subtree(item, ett_smux);
2953 dissect_SMUX_PDUs_PDU(tvb, pinfo, tree);
2959 #ifdef HAVE_SOME_SNMP
2960 gchar *tmp_mib_modules;
2961 static gboolean mibs_loaded = FALSE;
2965 * Unload the MIBs, as we'll be reloading them based on
2966 * the current preference setting.
2968 shutdown_mib(); /* unload MIBs */
2972 * Cannot check if MIBS is already set, as it could be set by Wireshark.
2974 * If we have a list of modules to load, put that list in MIBS,
2975 * otherwise clear MIBS.
2977 if (mib_modules != NULL) {
2978 tmp_mib_modules = g_strconcat("MIBS=", mib_modules, NULL);
2980 * Try to be clever and replace colons for semicolons under
2981 * Windows. Do the converse on non-Windows systems. This
2982 * handles cases where we've copied a preferences file
2983 * between a non-Windows box and a Windows box or upgraded
2984 * from an older version of Wireshark under Windows.
2986 g_strdelimit(tmp_mib_modules, IMPORT_SEPARATOR, ENV_SEPARATOR_CHAR);
2989 _putenv(tmp_mib_modules);
2991 putenv(tmp_mib_modules);
3004 register_mib_handlers();
3005 read_premib_configs();
3009 #endif /* HAVE_SOME_SNMP */
3011 /*--- proto_register_snmp -------------------------------------------*/
3012 void proto_register_snmp(void) {
3014 #if defined(_WIN32) && defined(HAVE_SOME_SNMP)
3017 #define MIB_PATH_APPEND "snmp\\mibs"
3019 gchar *tmp_mib_modules;
3021 /* List of fields */
3022 static hf_register_info hf[] = {
3023 { &hf_snmp_v3_flags_auth,
3024 { "Authenticated", "snmp.v3.flags.auth", FT_BOOLEAN, 8,
3025 TFS(&flags_set_truth), TH_AUTH, "", HFILL }},
3026 { &hf_snmp_v3_flags_crypt,
3027 { "Encrypted", "snmp.v3.flags.crypt", FT_BOOLEAN, 8,
3028 TFS(&flags_set_truth), TH_CRYPT, "", HFILL }},
3029 { &hf_snmp_v3_flags_report,
3030 { "Reportable", "snmp.v3.flags.report", FT_BOOLEAN, 8,
3031 TFS(&flags_set_truth), TH_REPORT, "", HFILL }},
3032 { &hf_snmp_engineid_conform, {
3033 "Engine ID Conformance", "snmp.engineid.conform", FT_BOOLEAN, 8,
3034 TFS(&tfs_snmp_engineid_conform), F_SNMP_ENGINEID_CONFORM, "Engine ID RFC3411 Conformance", HFILL }},
3035 { &hf_snmp_engineid_enterprise, {
3036 "Engine Enterprise ID", "snmp.engineid.enterprise", FT_UINT32, BASE_DEC,
3037 VALS(sminmpec_values), 0, "Engine Enterprise ID", HFILL }},
3038 { &hf_snmp_engineid_format, {
3039 "Engine ID Format", "snmp.engineid.format", FT_UINT8, BASE_DEC,
3040 VALS(snmp_engineid_format_vals), 0, "Engine ID Format", HFILL }},
3041 { &hf_snmp_engineid_ipv4, {
3042 "Engine ID Data: IPv4 address", "snmp.engineid.ipv4", FT_IPv4, BASE_NONE,
3043 NULL, 0, "Engine ID Data: IPv4 address", HFILL }},
3044 { &hf_snmp_engineid_ipv6, {
3045 "Engine ID Data: IPv6 address", "snmp.engineid.ipv6", FT_IPv6, BASE_NONE,
3046 NULL, 0, "Engine ID Data: IPv6 address", HFILL }},
3047 { &hf_snmp_engineid_mac, {
3048 "Engine ID Data: MAC address", "snmp.engineid.mac", FT_ETHER, BASE_NONE,
3049 NULL, 0, "Engine ID Data: MAC address", HFILL }},
3050 { &hf_snmp_engineid_text, {
3051 "Engine ID Data: Text", "snmp.engineid.text", FT_STRING, BASE_NONE,
3052 NULL, 0, "Engine ID Data: Text", HFILL }},
3053 { &hf_snmp_engineid_time, {
3054 "Engine ID Data: Time", "snmp.engineid.time", FT_ABSOLUTE_TIME, BASE_NONE,
3055 NULL, 0, "Engine ID Data: Time", HFILL }},
3056 { &hf_snmp_engineid_data, {
3057 "Engine ID Data", "snmp.engineid.data", FT_BYTES, BASE_HEX,
3058 NULL, 0, "Engine ID Data", HFILL }},
3059 { &hf_snmp_counter64, {
3060 "Value", "snmp.counter64", FT_INT64, BASE_DEC,
3061 NULL, 0, "A counter64 value", HFILL }},
3064 /*--- Included file: packet-snmp-hfarr.c ---*/
3065 #line 1 "packet-snmp-hfarr.c"
3066 { &hf_snmp_SMUX_PDUs_PDU,
3067 { "SMUX-PDUs", "snmp.SMUX_PDUs",
3068 FT_UINT32, BASE_DEC, VALS(snmp_SMUX_PDUs_vals), 0,
3069 "snmp.SMUX_PDUs", HFILL }},
3071 { "simple", "snmp.simple",
3072 FT_UINT32, BASE_DEC, VALS(snmp_SimpleSyntax_vals), 0,
3073 "snmp.SimpleSyntax", HFILL }},
3074 { &hf_snmp_application_wide,
3075 { "application-wide", "snmp.application_wide",
3076 FT_UINT32, BASE_DEC, VALS(snmp_ApplicationSyntax_vals), 0,
3077 "snmp.ApplicationSyntax", HFILL }},
3078 { &hf_snmp_integer_value,
3079 { "integer-value", "snmp.integer_value",
3080 FT_INT32, BASE_DEC, NULL, 0,
3081 "snmp.Integer_value", HFILL }},
3082 { &hf_snmp_string_value,
3083 { "string-value", "snmp.string_value",
3084 FT_BYTES, BASE_HEX, NULL, 0,
3085 "snmp.String_value", HFILL }},
3086 { &hf_snmp_objectID_value,
3087 { "objectID-value", "snmp.objectID_value",
3088 FT_OID, BASE_NONE, NULL, 0,
3089 "snmp.ObjectID_value", HFILL }},
3091 { "empty", "snmp.empty",
3092 FT_NONE, BASE_NONE, NULL, 0,
3093 "snmp.Empty", HFILL }},
3094 { &hf_snmp_ipAddress_value,
3095 { "ipAddress-value", "snmp.ipAddress_value",
3096 FT_IPv4, BASE_NONE, NULL, 0,
3097 "snmp.IpAddress", HFILL }},
3098 { &hf_snmp_counter_value,
3099 { "counter-value", "snmp.counter_value",
3100 FT_UINT32, BASE_DEC, NULL, 0,
3101 "snmp.Counter32", HFILL }},
3102 { &hf_snmp_timeticks_value,
3103 { "timeticks-value", "snmp.timeticks_value",
3104 FT_UINT32, BASE_DEC, NULL, 0,
3105 "snmp.TimeTicks", HFILL }},
3106 { &hf_snmp_arbitrary_value,
3107 { "arbitrary-value", "snmp.arbitrary_value",
3108 FT_BYTES, BASE_HEX, NULL, 0,
3109 "snmp.Opaque", HFILL }},
3110 { &hf_snmp_big_counter_value,
3111 { "big-counter-value", "snmp.big_counter_value",
3112 FT_UINT64, BASE_DEC, NULL, 0,
3113 "snmp.Counter64", HFILL }},
3114 { &hf_snmp_unsigned_integer_value,
3115 { "unsigned-integer-value", "snmp.unsigned_integer_value",
3116 FT_UINT32, BASE_DEC, NULL, 0,
3117 "snmp.Unsigned32", HFILL }},
3118 { &hf_snmp_internet,
3119 { "internet", "snmp.internet",
3120 FT_IPv4, BASE_NONE, NULL, 0,
3121 "snmp.IpAddress", HFILL }},
3123 { "version", "snmp.version",
3124 FT_INT32, BASE_DEC, VALS(snmp_Version_vals), 0,
3125 "snmp.Version", HFILL }},
3126 { &hf_snmp_community,
3127 { "community", "snmp.community",
3128 FT_STRING, BASE_HEX, NULL, 0,
3129 "snmp.OCTET_STRING", HFILL }},
3131 { "data", "snmp.data",
3132 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals), 0,
3133 "snmp.PDUs", HFILL }},
3134 { &hf_snmp_parameters,
3135 { "parameters", "snmp.parameters",
3136 FT_BYTES, BASE_HEX, NULL, 0,
3137 "snmp.OCTET_STRING", HFILL }},
3139 { "datav2u", "snmp.datav2u",
3140 FT_UINT32, BASE_DEC, VALS(snmp_T_datav2u_vals), 0,
3141 "snmp.T_datav2u", HFILL }},
3142 { &hf_snmp_v2u_plaintext,
3143 { "plaintext", "snmp.plaintext",
3144 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals), 0,
3145 "snmp.PDUs", HFILL }},
3146 { &hf_snmp_encrypted,
3147 { "encrypted", "snmp.encrypted",
3148 FT_BYTES, BASE_HEX, NULL, 0,
3149 "snmp.OCTET_STRING", HFILL }},
3150 { &hf_snmp_msgAuthoritativeEngineID,
3151 { "msgAuthoritativeEngineID", "snmp.msgAuthoritativeEngineID",
3152 FT_BYTES, BASE_HEX, NULL, 0,
3153 "snmp.SnmpEngineID", HFILL }},
3154 { &hf_snmp_msgAuthoritativeEngineBoots,
3155 { "msgAuthoritativeEngineBoots", "snmp.msgAuthoritativeEngineBoots",
3156 FT_UINT32, BASE_DEC, NULL, 0,
3157 "snmp.INTEGER_0_2147483647", HFILL }},
3158 { &hf_snmp_msgAuthoritativeEngineTime,
3159 { "msgAuthoritativeEngineTime", "snmp.msgAuthoritativeEngineTime",
3160 FT_UINT32, BASE_DEC, NULL, 0,
3161 "snmp.INTEGER_0_2147483647", HFILL }},
3162 { &hf_snmp_msgUserName,
3163 { "msgUserName", "snmp.msgUserName",
3164 FT_STRING, BASE_HEX, NULL, 0,
3165 "snmp.OCTET_STRING_SIZE_1_32", HFILL }},
3166 { &hf_snmp_msgAuthenticationParameters,
3167 { "msgAuthenticationParameters", "snmp.msgAuthenticationParameters",
3168 FT_BYTES, BASE_HEX, NULL, 0,
3169 "snmp.OCTET_STRING", HFILL }},
3170 { &hf_snmp_msgPrivacyParameters,
3171 { "msgPrivacyParameters", "snmp.msgPrivacyParameters",
3172 FT_BYTES, BASE_HEX, NULL, 0,
3173 "snmp.OCTET_STRING", HFILL }},
3174 { &hf_snmp_msgVersion,
3175 { "msgVersion", "snmp.msgVersion",
3176 FT_INT32, BASE_DEC, VALS(snmp_Version_vals), 0,
3177 "snmp.Version", HFILL }},
3178 { &hf_snmp_msgGlobalData,
3179 { "msgGlobalData", "snmp.msgGlobalData",
3180 FT_NONE, BASE_NONE, NULL, 0,
3181 "snmp.HeaderData", HFILL }},
3182 { &hf_snmp_msgSecurityParameters,
3183 { "msgSecurityParameters", "snmp.msgSecurityParameters",
3184 FT_BYTES, BASE_HEX, NULL, 0,
3185 "snmp.T_msgSecurityParameters", HFILL }},
3187 { "msgData", "snmp.msgData",
3188 FT_UINT32, BASE_DEC, VALS(snmp_ScopedPduData_vals), 0,
3189 "snmp.ScopedPduData", HFILL }},
3191 { "msgID", "snmp.msgID",
3192 FT_UINT32, BASE_DEC, NULL, 0,
3193 "snmp.INTEGER_0_2147483647", HFILL }},
3194 { &hf_snmp_msgMaxSize,
3195 { "msgMaxSize", "snmp.msgMaxSize",
3196 FT_UINT32, BASE_DEC, NULL, 0,
3197 "snmp.INTEGER_484_2147483647", HFILL }},
3198 { &hf_snmp_msgFlags,
3199 { "msgFlags", "snmp.msgFlags",
3200 FT_BYTES, BASE_HEX, NULL, 0,
3201 "snmp.T_msgFlags", HFILL }},
3202 { &hf_snmp_msgSecurityModel,
3203 { "msgSecurityModel", "snmp.msgSecurityModel",
3204 FT_UINT32, BASE_DEC, VALS(sec_models), 0,
3205 "snmp.T_msgSecurityModel", HFILL }},
3206 { &hf_snmp_plaintext,
3207 { "plaintext", "snmp.plaintext",
3208 FT_NONE, BASE_NONE, NULL, 0,
3209 "snmp.ScopedPDU", HFILL }},
3210 { &hf_snmp_encryptedPDU,
3211 { "encryptedPDU", "snmp.encryptedPDU",
3212 FT_BYTES, BASE_HEX, NULL, 0,
3213 "snmp.OCTET_STRING", HFILL }},
3214 { &hf_snmp_contextEngineID,
3215 { "contextEngineID", "snmp.contextEngineID",
3216 FT_BYTES, BASE_HEX, NULL, 0,
3217 "snmp.OCTET_STRING", HFILL }},
3218 { &hf_snmp_contextName,
3219 { "contextName", "snmp.contextName",
3220 FT_BYTES, BASE_HEX, NULL, 0,
3221 "snmp.OCTET_STRING", HFILL }},
3222 { &hf_snmp_get_request,
3223 { "get-request", "snmp.get_request",
3224 FT_NONE, BASE_NONE, NULL, 0,
3225 "snmp.T_get_request", HFILL }},
3226 { &hf_snmp_get_next_request,
3227 { "get-next-request", "snmp.get_next_request",
3228 FT_NONE, BASE_NONE, NULL, 0,
3229 "snmp.T_get_next_request", HFILL }},
3230 { &hf_snmp_get_response,
3231 { "get-response", "snmp.get_response",
3232 FT_NONE, BASE_NONE, NULL, 0,
3233 "snmp.T_get_response", HFILL }},
3234 { &hf_snmp_set_request,
3235 { "set-request", "snmp.set_request",
3236 FT_NONE, BASE_NONE, NULL, 0,
3237 "snmp.T_set_request", HFILL }},
3239 { "trap", "snmp.trap",
3240 FT_NONE, BASE_NONE, NULL, 0,
3241 "snmp.T_trap", HFILL }},
3242 { &hf_snmp_getBulkRequest,
3243 { "getBulkRequest", "snmp.getBulkRequest",
3244 FT_NONE, BASE_NONE, NULL, 0,
3245 "snmp.T_getBulkRequest", HFILL }},
3246 { &hf_snmp_informRequest,
3247 { "informRequest", "snmp.informRequest",
3248 FT_NONE, BASE_NONE, NULL, 0,
3249 "snmp.T_informRequest", HFILL }},
3250 { &hf_snmp_sNMPv2_Trap,
3251 { "sNMPv2-Trap", "snmp.sNMPv2_Trap",
3252 FT_NONE, BASE_NONE, NULL, 0,
3253 "snmp.T_sNMPv2_Trap", HFILL }},
3255 { "report", "snmp.report",
3256 FT_NONE, BASE_NONE, NULL, 0,
3257 "snmp.T_report", HFILL }},
3258 { &hf_snmp_request_id,
3259 { "request-id", "snmp.request_id",
3260 FT_INT32, BASE_DEC, NULL, 0,
3261 "snmp.INTEGER", HFILL }},
3262 { &hf_snmp_error_status,
3263 { "error-status", "snmp.error_status",
3264 FT_INT32, BASE_DEC, VALS(snmp_T_error_status_vals), 0,
3265 "snmp.T_error_status", HFILL }},
3266 { &hf_snmp_error_index,
3267 { "error-index", "snmp.error_index",
3268 FT_INT32, BASE_DEC, NULL, 0,
3269 "snmp.INTEGER", HFILL }},
3270 { &hf_snmp_variable_bindings,
3271 { "variable-bindings", "snmp.variable_bindings",
3272 FT_UINT32, BASE_DEC, NULL, 0,
3273 "snmp.VarBindList", HFILL }},
3274 { &hf_snmp_bulkPDU_request_id,
3275 { "request-id", "snmp.request_id",
3276 FT_INT32, BASE_DEC, NULL, 0,
3277 "snmp.Integer32", HFILL }},
3278 { &hf_snmp_non_repeaters,
3279 { "non-repeaters", "snmp.non_repeaters",
3280 FT_UINT32, BASE_DEC, NULL, 0,
3281 "snmp.INTEGER_0_2147483647", HFILL }},
3282 { &hf_snmp_max_repetitions,
3283 { "max-repetitions", "snmp.max_repetitions",
3284 FT_UINT32, BASE_DEC, NULL, 0,
3285 "snmp.INTEGER_0_2147483647", HFILL }},
3286 { &hf_snmp_enterprise,
3287 { "enterprise", "snmp.enterprise",
3288 FT_OID, BASE_NONE, NULL, 0,
3289 "snmp.OBJECT_IDENTIFIER", HFILL }},
3290 { &hf_snmp_agent_addr,
3291 { "agent-addr", "snmp.agent_addr",
3292 FT_UINT32, BASE_DEC, VALS(snmp_NetworkAddress_vals), 0,
3293 "snmp.NetworkAddress", HFILL }},
3294 { &hf_snmp_generic_trap,
3295 { "generic-trap", "snmp.generic_trap",
3296 FT_INT32, BASE_DEC, VALS(snmp_T_generic_trap_vals), 0,
3297 "snmp.T_generic_trap", HFILL }},
3298 { &hf_snmp_specific_trap,
3299 { "specific-trap", "snmp.specific_trap",
3300 FT_INT32, BASE_DEC, NULL, 0,
3301 "snmp.INTEGER", HFILL }},
3302 { &hf_snmp_time_stamp,
3303 { "time-stamp", "snmp.time_stamp",
3304 FT_UINT32, BASE_DEC, NULL, 0,
3305 "snmp.TimeTicks", HFILL }},
3307 { "name", "snmp.name",
3308 FT_OID, BASE_NONE, NULL, 0,
3309 "snmp.ObjectName", HFILL }},
3310 { &hf_snmp_valueType,
3311 { "valueType", "snmp.valueType",
3312 FT_UINT32, BASE_DEC, VALS(snmp_ValueType_vals), 0,
3313 "snmp.ValueType", HFILL }},
3315 { "value", "snmp.value",
3316 FT_UINT32, BASE_DEC, VALS(snmp_ObjectSyntax_vals), 0,
3317 "snmp.ObjectSyntax", HFILL }},
3318 { &hf_snmp_unSpecified,
3319 { "unSpecified", "snmp.unSpecified",
3320 FT_NONE, BASE_NONE, NULL, 0,
3321 "snmp.NULL", HFILL }},
3322 { &hf_snmp_noSuchObject,
3323 { "noSuchObject", "snmp.noSuchObject",
3324 FT_NONE, BASE_NONE, NULL, 0,
3325 "snmp.NULL", HFILL }},
3326 { &hf_snmp_noSuchInstance,
3327 { "noSuchInstance", "snmp.noSuchInstance",
3328 FT_NONE, BASE_NONE, NULL, 0,
3329 "snmp.NULL", HFILL }},
3330 { &hf_snmp_endOfMibView,
3331 { "endOfMibView", "snmp.endOfMibView",
3332 FT_NONE, BASE_NONE, NULL, 0,
3333 "snmp.NULL", HFILL }},
3334 { &hf_snmp_VarBindList_item,
3335 { "Item", "snmp.VarBindList_item",
3336 FT_NONE, BASE_NONE, NULL, 0,
3337 "snmp.VarBind", HFILL }},
3339 { "open", "snmp.open",
3340 FT_UINT32, BASE_DEC, VALS(snmp_OpenPDU_vals), 0,
3341 "snmp.OpenPDU", HFILL }},
3343 { "close", "snmp.close",
3344 FT_INT32, BASE_DEC, VALS(snmp_ClosePDU_vals), 0,
3345 "snmp.ClosePDU", HFILL }},
3346 { &hf_snmp_registerRequest,
3347 { "registerRequest", "snmp.registerRequest",
3348 FT_NONE, BASE_NONE, NULL, 0,
3349 "snmp.RReqPDU", HFILL }},
3350 { &hf_snmp_registerResponse,
3351 { "registerResponse", "snmp.registerResponse",
3352 FT_UINT32, BASE_DEC, VALS(snmp_RegisterResponse_vals), 0,
3353 "snmp.RegisterResponse", HFILL }},
3354 { &hf_snmp_commitOrRollback,
3355 { "commitOrRollback", "snmp.commitOrRollback",
3356 FT_INT32, BASE_DEC, VALS(snmp_SOutPDU_vals), 0,
3357 "snmp.SOutPDU", HFILL }},
3359 { "rRspPDU", "snmp.rRspPDU",
3360 FT_INT32, BASE_DEC, VALS(snmp_RRspPDU_vals), 0,
3361 "snmp.RRspPDU", HFILL }},
3363 { "pDUs", "snmp.pDUs",
3364 FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals), 0,
3365 "snmp.PDUs", HFILL }},
3366 { &hf_snmp_smux_simple,
3367 { "smux-simple", "snmp.smux_simple",
3368 FT_NONE, BASE_NONE, NULL, 0,
3369 "snmp.SimpleOpen", HFILL }},
3370 { &hf_snmp_smux_version,
3371 { "smux-version", "snmp.smux_version",
3372 FT_INT32, BASE_DEC, VALS(snmp_T_smux_version_vals), 0,
3373 "snmp.T_smux_version", HFILL }},
3374 { &hf_snmp_identity,
3375 { "identity", "snmp.identity",
3376 FT_OID, BASE_NONE, NULL, 0,
3377 "snmp.OBJECT_IDENTIFIER", HFILL }},
3378 { &hf_snmp_description,
3379 { "description", "snmp.description",
3380 FT_BYTES, BASE_HEX, NULL, 0,
3381 "snmp.DisplayString", HFILL }},
3382 { &hf_snmp_password,
3383 { "password", "snmp.password",
3384 FT_BYTES, BASE_HEX, NULL, 0,
3385 "snmp.OCTET_STRING", HFILL }},
3387 { "subtree", "snmp.subtree",
3388 FT_OID, BASE_NONE, NULL, 0,
3389 "snmp.ObjectName", HFILL }},
3390 { &hf_snmp_priority,
3391 { "priority", "snmp.priority",
3392 FT_INT32, BASE_DEC, NULL, 0,
3393 "snmp.INTEGER_M1_2147483647", HFILL }},
3394 { &hf_snmp_operation,
3395 { "operation", "snmp.operation",
3396 FT_INT32, BASE_DEC, VALS(snmp_T_operation_vals), 0,
3397 "snmp.T_operation", HFILL }},
3399 /*--- End of included file: packet-snmp-hfarr.c ---*/
3400 #line 1399 "packet-snmp-template.c"
3403 /* List of subtrees */
3404 static gint *ett[] = {
3410 /*--- Included file: packet-snmp-ettarr.c ---*/
3411 #line 1 "packet-snmp-ettarr.c"
3412 &ett_snmp_ObjectSyntax,
3413 &ett_snmp_SimpleSyntax,
3414 &ett_snmp_ApplicationSyntax,
3415 &ett_snmp_NetworkAddress,
3417 &ett_snmp_Messagev2u,
3418 &ett_snmp_T_datav2u,
3419 &ett_snmp_UsmSecurityParameters,
3420 &ett_snmp_SNMPv3Message,
3421 &ett_snmp_HeaderData,
3422 &ett_snmp_ScopedPduData,
3423 &ett_snmp_ScopedPDU,
3429 &ett_snmp_ValueType,
3430 &ett_snmp_VarBindList,
3431 &ett_snmp_SMUX_PDUs,
3432 &ett_snmp_RegisterResponse,
3434 &ett_snmp_SimpleOpen,
3437 /*--- End of included file: packet-snmp-ettarr.c ---*/
3438 #line 1408 "packet-snmp-template.c"
3440 module_t *snmp_module;
3442 #ifdef HAVE_SOME_SNMP
3445 /* Set MIBDIRS so that the SNMP library can find its mibs. */
3446 /* XXX - Should we set MIBS or MIBFILES as well? */
3447 mib_path_len=strlen(get_datafile_dir()) + strlen(MIB_PATH_APPEND) + 20;
3448 mib_path = ep_alloc (mib_path_len);
3449 g_snprintf (mib_path, mib_path_len, "MIBDIRS=%s\\%s", get_datafile_dir(), MIB_PATH_APPEND);
3450 /* Amazingly enough, Windows does not provide setenv(). */
3451 if (getenv("MIBDIRS") == NULL)
3457 * Suppress warnings about unknown tokens - we aren't initializing
3458 * UCD SNMP in its entirety, we're just initializing the
3459 * MIB-handling part because that's all we're using, which
3460 * means that entries in the configuration file for other
3461 * pars of the library will not be handled, and we don't want
3462 * the config file reading code to whine about that.
3464 netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
3465 NETSNMP_DS_LIB_NO_TOKEN_WARNINGS, TRUE);
3466 netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
3467 NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY, 2);
3468 #endif /* HAVE_SOME_SNMP */
3471 /* Register protocol */
3472 proto_snmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
3473 new_register_dissector("snmp", dissect_snmp, proto_snmp);
3475 /* Register fields and subtrees */
3476 proto_register_field_array(proto_snmp, hf, array_length(hf));
3477 proto_register_subtree_array(ett, array_length(ett));
3480 /* Register configuration preferences */
3481 snmp_module = prefs_register_protocol(proto_snmp, process_prefs);
3482 prefs_register_bool_preference(snmp_module, "display_oid",
3483 "Show SNMP OID in info column",
3484 "Whether the SNMP OID should be shown in the info column",
3488 * Set the default value of "mib_modules".
3490 * If the MIBS environment variable is set, make its value
3491 * the value of "mib_modules", otherwise, set "mib_modules"
3492 * to DEF_MIB_MODULES.
3494 tmp_mib_modules = getenv("MIBS");
3495 if (tmp_mib_modules != NULL)
3496 mib_modules = tmp_mib_modules;
3497 prefs_register_string_preference(snmp_module, "mib_modules",
3498 "MIB modules to load",
3499 "List of MIB modules to load (the list is set to environment variable MIBS if the variable is not already set)"
3500 "The list must be separated by colons (:) on non-Windows systems and semicolons (;) on Windows systems",
3502 prefs_register_bool_preference(snmp_module, "desegment",
3503 "Reassemble SNMP-over-TCP messages\nspanning multiple TCP segments",
3504 "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."
3505 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3508 prefs_register_bool_preference(snmp_module, "var_in_tree",
3509 "Display dissected variables inside SNMP tree",
3510 "ON - display dissected variables inside SNMP tree, OFF - display dissected variables in root tree after SNMP",
3513 variable_oid_dissector_table =
3514 register_dissector_table("snmp.variable_oid",
3515 "SNMP Variable OID", FT_STRING, BASE_NONE);
3519 /*--- proto_reg_handoff_snmp ---------------------------------------*/
3520 void proto_reg_handoff_snmp(void) {
3521 dissector_handle_t snmp_tcp_handle;
3523 snmp_handle = find_dissector("snmp");
3525 dissector_add("udp.port", UDP_PORT_SNMP, snmp_handle);
3526 dissector_add("udp.port", UDP_PORT_SNMP_TRAP, snmp_handle);
3527 dissector_add("ethertype", ETHERTYPE_SNMP, snmp_handle);
3528 dissector_add("ipx.socket", IPX_SOCKET_SNMP_AGENT, snmp_handle);
3529 dissector_add("ipx.socket", IPX_SOCKET_SNMP_SINK, snmp_handle);
3530 dissector_add("hpext.dxsap", HPEXT_SNMP, snmp_handle);
3532 snmp_tcp_handle = create_dissector_handle(dissect_snmp_tcp, proto_snmp);
3533 dissector_add("tcp.port", TCP_PORT_SNMP, snmp_tcp_handle);
3534 dissector_add("tcp.port", TCP_PORT_SNMP_TRAP, snmp_tcp_handle);
3536 data_handle = find_dissector("data");
3539 * Process preference settings.
3541 * We can't do this in the register routine, as preferences aren't
3542 * read until all dissector register routines have been called (so
3543 * that all dissector preferences have been registered).
3550 proto_register_smux(void)
3552 static hf_register_info hf[] = {
3554 { "Version", "smux.version", FT_UINT8, BASE_DEC, NULL,
3557 { "PDU type", "smux.pdutype", FT_UINT8, BASE_DEC, VALS(smux_types),
3560 static gint *ett[] = {
3564 proto_smux = proto_register_protocol("SNMP Multiplex Protocol",
3566 proto_register_field_array(proto_smux, hf, array_length(hf));
3567 proto_register_subtree_array(ett, array_length(ett));
3572 proto_reg_handoff_smux(void)
3574 dissector_handle_t smux_handle;
3576 smux_handle = create_dissector_handle(dissect_smux, proto_smux);
3577 dissector_add("tcp.port", TCP_PORT_SMUX, smux_handle);