Re: what type to use for counter64?

Robert Story <[email protected]>
Newsgroups gmane.network.net-snmp.user
Organization Net-SNMP
Message-ID <20050909172945.17f68e09@aud>
On Tue, 30 Aug 2005 18:38:51 +0800 Jim wrote:
JS>    On the man page of "snmptrap" I found there is type for counter32 but
JS> no counter64 ###

You are right, it's missing. Try this patch against 5.2.1.2, and see if it
helps.

-- 
NOTE: messages sent directly to me, instead of the lists, will be deleted
      unless they are requests for paid consulting services.

Robert Story; NET-SNMP Junkie
Support: <http://www.net-snmp.org/> <irc://irc.freenode.net/#net-snmp>  
Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-users>

You are lost in a twisty maze of little standards, all different.
trap-counter64.patch (text/x-patch, 1.3 KB)
--- ../x-5.2.1.x/snmplib/snmp_api.c	2005-06-30 11:12:53.000000000 -0400
+++ snmplib/snmp_api.c	2005-09-09 17:23:06.325001119 -0400
@@ -6525,8 +6528,8 @@
 #ifdef OPAQUE_SPECIAL_TYPES
     double          dtmp;
     float           ftmp;
-    struct counter64 c64tmp;
 #endif                          /* OPAQUE_SPECIAL_TYPES */
+    struct counter64 c64tmp;
 
 #ifndef DISABLE_MIB_LOADING
     tp = get_tree(name, name_length, get_tree_head());
@@ -6555,6 +6558,9 @@
         case TYPE_COUNTER:
             type = 'c';
             break;
+        case TYPE_COUNTER64:
+            type = 'C';
+            break;
         case TYPE_TIMETICKS:
             type = 't';
             break;
@@ -6663,6 +6669,21 @@
             goto fail;
         break;
 
+    case 'C':
+#ifndef DISABLE_MIB_LOADING
+        if (check && tp->type != TYPE_COUNTER64) {
+            value = "Counter64";
+            result = SNMPERR_VALUE;
+            goto type_error;
+        }
+#endif /* DISABLE_MIB_LOADING */
+        if (read64(&c64tmp, value))
+            snmp_pdu_add_variable(pdu, name, name_length, ASN_COUNTER64,
+                                  (u_char *) & c64tmp, sizeof(c64tmp));
+        else
+            goto fail;
+        break;
+
     case 't':
 #ifndef DISABLE_MIB_LOADING
         if (check && tp->type != TYPE_TIMETICKS) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.