[quagga-dev 10944] [PATCH] fix snmp truncating integer value

Ilja Ryndin ilja.ryndin at gmail.com
Wed Dec 4 10:22:43 GMT 2013


Signed-off-by: Ilja Ryndin <ilja.ryndin at gmail.com>
---
 ripd/rip_snmp.c    | 30 +++++++++++++++---------------
 zebra/zebra_snmp.c |  4 ++++
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c
index 090ebfa..58cabef 100644
--- a/ripd/rip_snmp.c
+++ b/ripd/rip_snmp.c
@@ -343,7 +343,7 @@ rip2IfStatEntry (struct variable *v, oid name[], size_t *length,
   struct interface *ifp;
   struct rip_interface *ri;
   static struct in_addr addr;
-  static long valid = SNMP_VALID;
+  static int32_t valid = SNMP_VALID;
 
   if (smux_header_table(v, name, length, exact, var_len, write_method)
       == MATCH_FAILED)
@@ -365,19 +365,19 @@ rip2IfStatEntry (struct variable *v, oid name[], size_t *length,
       return SNMP_IPADDRESS (addr);
       break;
     case RIP2IFSTATRCVBADPACKETS:
-      *var_len = sizeof (long);
+      *var_len = sizeof (int32_t);
       return (u_char *) &ri->recv_badpackets;
 
     case RIP2IFSTATRCVBADROUTES:
-      *var_len = sizeof (long);
+      *var_len = sizeof (int32_t);
       return (u_char *) &ri->recv_badroutes;
 
     case RIP2IFSTATSENTUPDATES:
-      *var_len = sizeof (long);
+      *var_len = sizeof (int32_t);
       return (u_char *) &ri->sent_updates;
 
     case RIP2IFSTATSTATUS:
-      *var_len = sizeof (long);
+      *var_len = sizeof (int32_t);
       v->type = ASN_INTEGER;
       return (u_char *) &valid;
 
@@ -388,7 +388,7 @@ rip2IfStatEntry (struct variable *v, oid name[], size_t *length,
   return NULL;
 }
 
-static long
+static int32_t
 rip2IfConfSend (struct rip_interface *ri)
 {
 #define doNotSend       1
@@ -415,7 +415,7 @@ rip2IfConfSend (struct rip_interface *ri)
   return doNotSend;
 }
 
-static long
+static int32_t
 rip2IfConfReceive (struct rip_interface *ri)
 {
 #define rip1            1
@@ -445,9 +445,9 @@ rip2IfConfAddress (struct variable *v, oid name[], size_t *length,
 	           int exact, size_t *val_len, WriteMethod **write_method)
 {
   static struct in_addr addr;
-  static long valid = SNMP_INVALID;
-  static long domain = 0;
-  static long config = 0;
+  static int32_t valid = SNMP_INVALID;
+  static int32_t domain = 0;
+  static int32_t config = 0;
   static u_int auth = 0;
   struct interface *ifp;
   struct rip_interface *ri;
@@ -478,7 +478,7 @@ rip2IfConfAddress (struct variable *v, oid name[], size_t *length,
 
     case RIP2IFCONFAUTHTYPE:
       auth = ri->auth_type;
-      *val_len = sizeof (long);
+      *val_len = sizeof (int32_t);
       v->type = ASN_INTEGER;
       return (u_char *)&auth;
 
@@ -487,21 +487,21 @@ rip2IfConfAddress (struct variable *v, oid name[], size_t *length,
       return (u_char *) &domain;
     case RIP2IFCONFSEND:
       config = rip2IfConfSend (ri);
-      *val_len = sizeof (long);
+      *val_len = sizeof (int32_t);
       v->type = ASN_INTEGER;
       return (u_char *) &config;
     case RIP2IFCONFRECEIVE:
       config = rip2IfConfReceive (ri);
-      *val_len = sizeof (long);
+      *val_len = sizeof (int32_t);
       v->type = ASN_INTEGER;
       return (u_char *) &config;
 
     case RIP2IFCONFDEFAULTMETRIC:
-      *val_len = sizeof (long);
+      *val_len = sizeof (int32_t);
       v->type = ASN_INTEGER;
       return (u_char *) &ifp->metric;
     case RIP2IFCONFSTATUS:
-      *val_len = sizeof (long);
+      *val_len = sizeof (int32_t);
       v->type = ASN_INTEGER;
       return (u_char *) &valid;
     case RIP2IFCONFSRCADDRESS:
diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c
index e06e144..a4f0f46 100644
--- a/zebra/zebra_snmp.c
+++ b/zebra/zebra_snmp.c
@@ -147,6 +147,8 @@ ipFwNumber (struct variable *v, oid objid[], size_t *objid_len,
   if (! table)
     return NULL;
 
+  *val_len  = sizeof(int32_t);
+
   /* Return number of routing entries. */
   result = 0;
   for (rn = route_top (table); rn; rn = route_next (rn))
@@ -172,6 +174,8 @@ ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len,
   if (! table)
     return 0;
 
+  *val_len  = sizeof(int32_t);
+
   /* Return number of routing entries. */
   result = 0;
   for (rn = route_top (table); rn; rn = route_next (rn))
-- 
1.8.3.2





More information about the Quagga-dev mailing list