2 * Routines for SNMP (simple network management protocol)
5 * $Id: packet-snmp.c,v 1.14 1999/11/18 07:29:53 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@unicom.net>
9 * Copyright 1998 Didier Jorand
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #if defined(HAVE_UCD_SNMP_SNMP_H)
33 # define WITH_SNMP_UCD 1
34 #elif defined(HAVE_SNMP_SNMP_H)
35 # define WITH_SNMP_CMU 1
38 #if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD)
44 #ifdef HAVE_SYS_TYPES_H
45 # include <sys/types.h>
48 #ifdef HAVE_NETINET_IN_H
49 # include <netinet/in.h>
55 #include "packet-snmp.h"
57 #define in_addr_t u_int
59 static int proto_snmp = -1;
61 static gint ett_snmp = -1;
64 /* should be defined only if supported in ucd-snmp */
65 #define OPAQUE_SPECIAL_TYPES 1
66 #include <ucd-snmp/asn1.h>
67 #include <ucd-snmp/snmp.h>
68 #include <ucd-snmp/snmp_api.h>
69 #include <ucd-snmp/snmp_impl.h>
70 #include <ucd-snmp/mib.h>
72 typedef long SNMP_INT;
73 typedef unsigned long SNMP_UINT;
74 #define OID_FORMAT_STRING "%ld"
75 #define OID_FORMAT_STRING1 ".%ld"
79 #include <snmp/snmp.h>
80 #include <snmp/snmp_impl.h>
84 #define MAX_NAME_LEN SNMP_MAX_LEN
87 #define SNMP_MSG_GET GET_REQ_MSG
88 #define SNMP_MSG_GETNEXT GETNEXT_REQ_MSG
89 #define SNMP_MSG_RESPONSE GET_RSP_MSG
90 #define SNMP_MSG_SET SET_REQ_MSG
91 #define SNMP_MSG_TRAP TRP_REQ_MSG
93 #ifdef GETBULK_REQ_MSG
94 #define SNMP_MSG_GETBULK GETBULK_REQ_MSG
96 #define SNMP_MSG_GETBULK SNMP_PDU_GETBULK
100 #define SNMP_MSG_INFORM INFORM_REQ_MSG
102 #define SNMP_MSG_INFORM SNMP_PDU_INFORM
106 #define SNMP_MSG_TRAP2 TRP2_REQ_MSG
108 #define SNMP_MSG_TRAP2 SNMP_PDU_V2TRAP
112 #define SNMP_MSG_REPORT REPORT_MSG
114 #define SNMP_MSG_REPORT SNMP_PDU_REPORT
118 #ifndef SNMP_VERSION_2c
119 #define SNMP_VERSION_2c 1
121 #ifndef SNMP_VERSION_2u
122 #define SNMP_VERSION_2u 2
124 #ifndef SNMP_VERSION_3
125 #define SNMP_VERSION_3 3
128 #ifdef SNMP_TRAP_AUTHENTICATIONFAILURE
129 #define SNMP_TRAP_AUTHFAIL SNMP_TRAP_AUTHENTICATIONFAILURE
132 #ifndef COMMUNITY_MAX_LEN
133 #define COMMUNITY_MAX_LEN 256
137 #define ASN_INTEGER SMI_INTEGER
139 #ifndef ASN_OCTET_STR
140 #define ASN_OCTET_STR SMI_STRING
142 #ifndef ASN_OBJECT_ID
143 #define ASN_OBJECT_ID SMI_OBJID
146 #define ASN_NULL SMI_NULLOBJ
149 #ifndef ASN_IPADDRESS
151 #define ASN_IPADDRESS IPADDRESS
153 #define ASN_IPADDRESS SMI_IPADDRESS
159 #define ASN_COUNTER COUNTER
161 #define ASN_COUNTER SMI_COUNTER32
167 #define ASN_GAUGE GAUGE
169 #define ASN_GAUGE SMI_GAUGE32
173 #ifndef ASN_TIMETICKS
175 #define ASN_TIMETICKS TIMETICKS
177 #define ASN_TIMETICKS SMI_TIMETICKS
183 #define ASN_OPAQUE OPAQUE
185 #define ASN_OPAQUE SMI_OPAQUE
189 #ifndef ASN_COUNTER64
191 #define ASN_COUNTER64 COUNTER64
193 #define ASN_COUNTER64 SMI_COUNTER64
198 /* historic: should not be used! */
199 #define ASN_UINTEGER (ASN_APPLICATION | 7)
202 /* historic: should not be used! */
203 #define ASN_NSAP (ASN_APPLICATION | 5)
205 #ifndef SNMP_NOSUCHOBJECT
206 #define SNMP_NOSUCHOBJECT SMI_NOSUCHOBJECT
208 #ifndef SNMP_NOSUCHINSTANCE
209 #define SNMP_NOSUCHINSTANCE SMI_NOSUCHINSTANCE
211 #ifndef SNMP_ENDOFMIBVIEW
212 #define SNMP_ENDOFMIBVIEW SMI_ENDOFMIBVIEW
216 typedef int SNMP_INT;
217 typedef unsigned int SNMP_UINT;
218 #define OID_FORMAT_STRING "%d"
219 #define OID_FORMAT_STRING1 ".%d"
223 static const value_string versions[] = {
224 { SNMP_VERSION_1, "VERSION 1" },
225 { SNMP_VERSION_2c, "VERSION 2C" },
226 { SNMP_VERSION_2u, "VERSION 2U" },
227 { SNMP_VERSION_3, "VERSION 3" },
231 static const value_string pdu_types[] = {
232 { SNMP_MSG_GET, "GET" },
233 { SNMP_MSG_GETNEXT, "GET-NEXT" },
234 { SNMP_MSG_SET, "SET" },
235 { SNMP_MSG_RESPONSE, "RESPONSE" },
236 { SNMP_MSG_TRAP, "TRAP-V1" },
237 { SNMP_MSG_GETBULK, "GETBULK" },
238 { SNMP_MSG_INFORM, "INFORM" },
239 { SNMP_MSG_TRAP2, "TRAP-V2" },
240 { SNMP_MSG_REPORT, "REPORT" },
244 static const value_string error_statuses[] = {
245 { SNMP_ERR_NOERROR, "NO ERROR" },
246 { SNMP_ERR_TOOBIG, "ERROR: TOOBIG" },
247 { SNMP_ERR_NOSUCHNAME, "ERROR: NO SUCH NAME" },
248 { SNMP_ERR_BADVALUE, "ERROR: BAD VALUE" },
249 { SNMP_ERR_READONLY, "ERROR: READ ONLY" },
250 { SNMP_ERR_GENERR, "ERROR: GENERIC ERROR" },
251 { SNMP_ERR_NOACCESS, "ERROR: NO ACCESS" },
252 { SNMP_ERR_WRONGTYPE, "ERROR: WRONG TYPE" },
253 { SNMP_ERR_WRONGLENGTH, "ERROR: WRONG LENGTH" },
254 { SNMP_ERR_WRONGENCODING, "ERROR: WRONG ENCODING" },
255 { SNMP_ERR_WRONGVALUE, "ERROR: WRONG VALUE" },
256 { SNMP_ERR_NOCREATION, "ERROR: NO CREATION" },
257 { SNMP_ERR_INCONSISTENTVALUE, "ERROR: INCONSISTENT VALUE" },
258 { SNMP_ERR_RESOURCEUNAVAILABLE, "ERROR: RESOURCE UNAVAILABLE" },
259 { SNMP_ERR_COMMITFAILED, "ERROR: COMMIT FAILED" },
260 { SNMP_ERR_UNDOFAILED, "ERROR: UNDO FAILED" },
261 { SNMP_ERR_AUTHORIZATIONERROR, "ERROR: AUTHORIZATION ERROR" },
262 { SNMP_ERR_NOTWRITABLE, "ERROR: NOT WRITABLE" },
263 { SNMP_ERR_INCONSISTENTNAME, "ERROR: INCONSISTENT NAME" },
267 static const value_string trap_types[] = {
268 { SNMP_TRAP_COLDSTART, "COLD START" },
269 { SNMP_TRAP_WARMSTART, "WARM START" },
270 { SNMP_TRAP_LINKDOWN, "LINK DOWN" },
271 { SNMP_TRAP_LINKUP, "LINK UP" },
272 { SNMP_TRAP_AUTHFAIL, "AUTHENTICATION FAILED" },
273 { SNMP_TRAP_EGPNEIGHBORLOSS, "EGP NEIGHBORLOSS" },
274 { SNMP_TRAP_ENTERPRISESPECIFIC, "ENTERPRISE SPECIFIC" },
279 dissect_snmp_error(const u_char *pd, int offset, frame_data *fd,
280 proto_tree *tree, const char *message)
282 if (check_col(fd, COL_INFO))
283 col_add_str(fd, COL_INFO, message);
285 dissect_data(pd, offset, fd, tree);
289 dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
291 dissect_snmp_pdu(pd, offset, fd, tree, "SNMP", proto_snmp, ett_snmp);
295 dissect_snmp_pdu(const u_char *pd, int offset, frame_data *fd,
296 proto_tree *tree, char *proto_name, int proto, gint ett)
298 int length=fd->pkt_len-offset;
299 u_char *data, *tmp_data;
301 int all_length, header_length;
302 u_char type, pdu_type;
304 SNMP_INT request_id, error_status, error_index;
305 int request_id_length, error_status_length, error_index_length;
308 u_char community[COMMUNITY_MAX_LEN];
309 int community_length = COMMUNITY_MAX_LEN;
311 oid enterprise[MAX_NAME_LEN];
312 int enterprise_length;
313 SNMP_INT trap_type, specific_type;
317 oid vb_name[MAX_NAME_LEN];
321 char vb_string[MAX_NAME_LEN*6]; /* TBC */
322 char vb_string2[2048]; /* TBC */
324 SNMP_INT vb_integer_value;
325 SNMP_UINT vb_unsigned_value;
327 struct counter64 vb_counter64_value;
329 oid vb_oid_value[MAX_NAME_LEN];
330 int vb_oid_value_length;
331 unsigned char vb_string_value[128];
332 int vb_string_value_length;
334 float vb_float_value;
335 double vb_double_value;
340 char *pdu_type_string;
342 proto_tree *snmp_tree=NULL;
343 proto_item *item=NULL;
345 if (check_col(fd, COL_PROTOCOL))
346 col_add_str(fd, COL_PROTOCOL, proto_name);
348 /* NOTE: we have to parse the message piece by piece, since the
349 * capture length may be less than the message length: a 'global'
350 * parsing is likely to fail.
354 /* parse the SNMP header */
355 if(NULL == asn_parse_header((u_char*)&pd[offset], &length, &type)) {
356 dissect_snmp_error(pd, offset, fd, tree,
357 "Couldn't parse SNMP header");
361 if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) {
362 dissect_snmp_error(pd, offset, fd, tree, "Not an SNMP PDU");
366 /* authenticates message */
367 length=fd->pkt_len-offset;
368 header_length=length;
369 data = snmp_comstr_parse((u_char*)&pd[offset], &length, community, &community_length, (long*)&version);
371 dissect_snmp_error(pd, offset, fd, tree,
372 "Couldn't parse authentication");
377 /* initialize length variables */
378 /* length=fd->pkt_len-offset; */
379 header_length=length;
381 /* parse the SNMP header */
382 data = asn_parse_header((u_char*)&pd[offset], &length, &type);
384 dissect_snmp_error(pd, offset, fd, tree,
385 "Couldn't parse SNMP header");
389 if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) {
390 dissect_snmp_error(pd, offset, fd, tree, "Not an SNMP PDU");
394 data = asn_parse_int(data, &length, &type, &version, sizeof(SNMP_INT));
396 dissect_snmp_error(pd, offset, fd, tree,
397 "Couldn't parse SNMP version number");
400 data = asn_parse_string(data, &length, &type, community, &community_length);
402 dissect_snmp_error(pd, offset, fd, tree,
403 "Couldn't parse SNMP community");
406 community[community_length] = '\0';
409 header_length-=length;
410 /* printf("Community is %s, version is %d (header length is %d)\n", community, version, header_length); */
411 if(version != SNMP_VERSION_1) {
412 dissect_snmp_error(pd, offset, fd, tree,
413 "Non-version-1 SNMP PDU");
417 pdu_type_length=length;
418 data = asn_parse_header(data, &length, &pdu_type);
420 dissect_snmp_error(pd, offset, fd, tree,
421 "Couldn't parse PDU type");
424 pdu_type_length-=length;
425 /* printf("pdu type is %#x (length is %d)\n", type, pdu_type_length); */
427 /* get the fields in the PDU preceeding the variable-bindings sequence */
428 if (pdu_type != SNMP_MSG_TRAP) {
431 request_id_length=length;
432 data = asn_parse_int(data, &length, &type, &request_id, sizeof(request_id));
434 dissect_snmp_error(pd, offset, fd, tree,
435 "Couldn't parse request ID");
438 request_id_length-=length;
439 /* printf("request id is %#lx (length is %d)\n", request_id, request_id_length); */
441 /* error status (getbulk non-repeaters) */
442 error_status_length=length;
443 data = asn_parse_int(data, &length, &type, &error_status, sizeof(error_status));
445 dissect_snmp_error(pd, offset, fd, tree,
446 "Couldn't parse error status");
449 error_status_length-=length;
451 /* error index (getbulk max-repetitions) */
452 error_index_length=length;
453 data = asn_parse_int(data, &length, &type, &error_index, sizeof(error_index));
455 dissect_snmp_error(pd, offset, fd, tree,
456 "Couldn't parse error index");
459 error_index_length-=length;
461 pdu_type_string = val_to_str(pdu_type, pdu_types,
462 "Unknown PDU type %#x");
463 if (check_col(fd, COL_INFO))
464 col_add_str(fd, COL_INFO, pdu_type_string);
466 /* all_length=header_length+pdu_type_length+request_id_length+error_status_length+error_index_length; */
467 all_length=fd->pkt_len-offset;
468 item = proto_tree_add_item(tree, proto, offset, all_length, NULL);
469 snmp_tree = proto_item_add_subtree(item, ett);
470 proto_tree_add_text(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, val_to_str(version, versions, "Unknown version %#x"));
471 offset+=header_length;
472 proto_tree_add_text(snmp_tree, offset, pdu_type_length, "%s", pdu_type_string);
473 offset+=pdu_type_length;
474 proto_tree_add_text(snmp_tree, offset, request_id_length, "Request Id.: %#x", (unsigned int)request_id);
475 offset+=request_id_length;
476 proto_tree_add_text(snmp_tree, offset, error_status_length, "Error Status: %s", val_to_str(error_status, error_statuses, "Unknown (%d)"));
477 offset+=error_status_length;
478 proto_tree_add_text(snmp_tree, offset, error_index_length, "Error Index: %d", (int)error_index);
479 offset+=error_index_length;
481 offset+=header_length;
482 offset+=pdu_type_length;
483 offset+=request_id_length;
484 offset+=error_status_length;
485 offset+=error_index_length;
489 /* an SNMPv1 trap PDU */
490 pdu_type_string = val_to_str(pdu_type, pdu_types,
491 "Unknown PDU type %#x");
492 if (check_col(fd, COL_INFO))
493 col_add_str(fd, COL_INFO, pdu_type_string);
495 all_length=fd->pkt_len-offset;
496 item = proto_tree_add_item(tree, proto, offset, all_length, NULL);
497 snmp_tree = proto_item_add_subtree(item, ett);
498 proto_tree_add_text(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, val_to_str(version, versions, "Unknown version %#x"));
499 offset+=header_length;
500 proto_tree_add_text(snmp_tree, offset, pdu_type_length, "Pdu type: %s", pdu_type_string);
501 offset+=pdu_type_length;
503 offset+=header_length;
504 offset+=pdu_type_length;
508 enterprise_length = MAX_NAME_LEN;
510 data = asn_parse_objid(data, &length, &type, enterprise, &enterprise_length);
512 dissect_snmp_error(pd, offset, fd, tree,
513 "Couldn't parse enterprise OID");
518 sprintf(vb_string, OID_FORMAT_STRING, enterprise[0]);
519 for(i=1; i<enterprise_length;i++) {
520 sprintf(tmp_string, OID_FORMAT_STRING1, enterprise[i]);
521 strcat(vb_string,tmp_string);
524 proto_tree_add_text(snmp_tree, offset, tmp_length, "Enterprise: %s", vb_string);
529 vb_string_value_length = 4;
531 data = asn_parse_string(data, &length, &type, vb_string_value, &vb_string_value_length);
533 dissect_snmp_error(pd, offset, fd, tree,
534 "Couldn't parse agent address");
539 proto_tree_add_text(snmp_tree, offset, tmp_length, "Agent address: %d.%d.%d.%d",
540 vb_string_value[0],vb_string_value[1],vb_string_value[2],vb_string_value[3]);
546 data = asn_parse_int(data, &length, &type, &trap_type, sizeof(trap_type));
548 dissect_snmp_error(pd, offset, fd, tree,
549 "Couldn't parse trap type");
554 proto_tree_add_text(snmp_tree, offset, tmp_length, "Trap type: %s", val_to_str(trap_type, trap_types, "Unknown (%d)"));
560 data = asn_parse_int(data, &length, &type, &specific_type, sizeof(specific_type));
562 dissect_snmp_error(pd, offset, fd, tree,
563 "Couldn't parse specific trap type");
568 proto_tree_add_text(snmp_tree, offset, tmp_length, "Specific trap type: %ld (%#lx)", (long)specific_type, (long)specific_type);
574 data = asn_parse_unsigned_int(data, &length, &type, ×tamp, sizeof(timestamp));
576 dissect_snmp_error(pd, offset, fd, tree,
577 "Couldn't parse time stamp");
582 proto_tree_add_text(snmp_tree, offset, tmp_length, "Timestamp: %lu", (unsigned long)timestamp);
587 /* variable bindings */
588 /* get header for variable-bindings sequence */
590 data = asn_parse_header(data, &length, &type);
592 dissect_snmp_error(pd, offset, fd, tree,
593 "Couldn't variable-bindings header");
597 if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)) {
598 dissect_snmp_error(pd, offset, fd, tree,
599 "Bad type for variable-bindings header");
603 /* printf("VB header: offset is %d; length is %d.\n", offset, tmp_length); */
605 /* loop on variable bindings */
609 /* printf("VB index is %d (offset=%d; length=%d).\n", vb_index, offset, length); */
613 data = asn_parse_header(data, &tmp_length, &type);
615 dissect_snmp_error(pd, offset, fd, tree,
616 "Couldn't parse variable-binding header");
619 if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)) {
620 dissect_snmp_error(pd, offset, fd, tree,
621 "Bad type for variable-binding header");
624 tmp_length=(int)(data-tmp_data);
628 /* parse object identifier */
629 vb_name_length=MAX_NAME_LEN;
631 data = asn_parse_objid(data, &length, &type, vb_name, &vb_name_length);
633 dissect_snmp_error(pd, offset, fd, tree,
634 "No object-identifier for variable-binding");
638 if (type != (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID)) {
639 dissect_snmp_error(pd, offset, fd, tree,
640 "Bad type for variable-binding");
646 sprintf(vb_string, OID_FORMAT_STRING, vb_name[0]);
647 for(i=1; i<vb_name_length;i++) {
648 sprintf(tmp_string, OID_FORMAT_STRING1, vb_name[i]);
649 strcat(vb_string,tmp_string);
652 sprint_objid(vb_string2, vb_name, vb_name_length);
654 proto_tree_add_text(snmp_tree, offset, tmp_length, "Object identifier %d: %s (%s)", vb_index, vb_string, vb_string2);
658 /* parse the type of the object */
660 if (NULL == asn_parse_header(data, &tmp_length, &vb_type)){
661 dissect_snmp_error(pd, offset, fd, tree,
662 "Bad type for variable-binding value");
666 /* parse the value */
670 data=asn_parse_null(data, &length, &type);
673 dissect_snmp_error(pd, offset, fd, tree,
674 "Couldn't parse null value");
678 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: NULL");
685 data=asn_parse_int(data, &length, &type, &vb_integer_value, sizeof(vb_integer_value));
688 dissect_snmp_error(pd, offset, fd, tree,
689 "Couldn't parse integer value");
693 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <i> %ld (%#lx)", (long)vb_integer_value, (long)vb_integer_value);
703 data=asn_parse_unsigned_int(data, &length, &type, &vb_unsigned_value, sizeof(vb_unsigned_value));
706 dissect_snmp_error(pd, offset, fd, tree,
707 "Couldn't parse unsigned value");
711 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <u> %lu (%#lx)", (unsigned long)vb_unsigned_value, (unsigned long)vb_unsigned_value);
717 /* only ucd support 64bits types */
719 #ifdef OPAQUE_SPECIAL_TYPES
720 case ASN_OPAQUE_COUNTER64:
722 #endif /* OPAQUE_SPECIAL_TYPES */
724 data=asn_parse_unsigned_int64(data, &length, &type, &vb_counter64_value, sizeof(vb_counter64_value));
727 dissect_snmp_error(pd, offset, fd, tree,
728 "Couldn't parse counter64 value");
732 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <i64> %lu:%lu (%#lx:%lx)",
733 vb_counter64_value.high,
734 vb_counter64_value.low,
735 vb_counter64_value.high,
736 vb_counter64_value.low);
740 #endif /* WITH_SNMP_UCD */
743 vb_oid_value_length = MAX_NAME_LEN;
745 data=asn_parse_objid(data, &length, &type, vb_oid_value, &vb_oid_value_length);
748 dissect_snmp_error(pd, offset, fd, tree,
749 "Couldn't parse OID value");
753 sprintf(vb_string, OID_FORMAT_STRING, vb_oid_value[0]);
754 for(i=1; i<vb_oid_value_length;i++) {
755 sprintf(tmp_string, OID_FORMAT_STRING1, vb_oid_value[i]);
756 strcat(vb_string,tmp_string);
758 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <oid> %s", vb_string);
766 vb_string_value_length=128;
768 data=asn_parse_string(data, &length, &type, vb_string_value, &vb_string_value_length);
771 dissect_snmp_error(pd, offset, fd, tree,
772 "Couldn't parse octet string value");
776 vb_string_value[vb_string_value_length]=0;
777 /* if some characters are not printable, display the string as
779 for(i=0; i<vb_string_value_length; i++) {
780 if(!(isprint(vb_string_value[i]) || isspace(vb_string_value[i]))) break;
782 if(i<vb_string_value_length) {
783 sprintf(vb_string, "%03d", (int)vb_string_value[0]);
784 for(i=1; i<vb_string_value_length; i++) {
785 sprintf(tmp_string, ".%03d", (int)vb_string_value[i]);
786 strcat(vb_string,tmp_string);
788 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string);
790 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string_value);
796 #ifdef OPAQUE_SPECIAL_TYPES
799 data=asn_parse_signed_int64(data, &length, &type, &vb_counter64_value, sizeof(vb_counter64_value));
802 dissect_snmp_error(pd, offset, fd, tree,
803 "Couldn't parse integer64 value");
807 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <i64> %ld:%lu (%#lx:%lx)",
808 vb_counter64_value.high,
809 vb_counter64_value.low,
810 vb_counter64_value.high,
811 vb_counter64_value.low);
817 case ASN_OPAQUE_FLOAT:
819 data=asn_parse_float(data, &length, &type,&vb_float_value, sizeof(vb_float_value));
822 dissect_snmp_error(pd, offset, fd, tree,
823 "Couldn't parse float value");
827 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <f> %f", (double)vb_float_value);
832 case ASN_OPAQUE_DOUBLE:
834 data=asn_parse_double(data, &length, &type,&vb_double_value, sizeof(vb_double_value));
837 dissect_snmp_error(pd, offset, fd, tree,
838 "Couldn't parse double value");
842 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <d> %f", vb_double_value);
846 #endif /* OPAQUE_SPECIAL_TYPES */
848 case SNMP_NOSUCHOBJECT:
850 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <err> no such object");
853 case SNMP_NOSUCHINSTANCE:
855 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <err> no such instance");
858 case SNMP_ENDOFMIBVIEW:
860 proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <err> end of mib view");
865 dissect_snmp_error(pd, offset, fd, tree,
866 "Unsupported type for variable-binding value");
872 #endif /* WITH_SNMP: CMU or UCD */
875 * Allow the stuff that builds "register.c" to scan "packet-snmp.c" even
876 * if we're not enabling SNMP decoding (for "canned" source distributions
877 * such as BSD ports, it may be a pain to arrange that it be scanned only
878 * if SNMP is being used), by having "proto_register_snmp()" always be
879 * defined, but not do anything if SNMP decoding isn't enabled.
882 proto_register_snmp(void)
884 #if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD)
885 /* static hf_register_info hf[] = {
887 { "Name", "snmp.abbreviation", TYPE, VALS_POINTER }},
889 static gint *ett[] = {
894 proto_snmp = proto_register_protocol("Simple Network Management Protocol", "snmp");
895 /* proto_register_field_array(proto_snmp, hf, array_length(hf));*/
896 proto_register_subtree_array(ett, array_length(ett));
897 #endif /* WITH_SNMP: CMU or UCD */