On Sat, 2009-08-15 at 18:53 +0200, Magnus Fromreide wrote:
> On Fri, 2009-08-14 at 15:25 -0700, Huang, Jack wrote:
> > Hello,
> >
> > It looks like there is an issue with the range of unsigned32 in the
> > snmptranslate program. The range of unsigned32 is reported as 0 ..
> > 2147483647, instead of 0..4294967295.
> >
> > Please let me know if you need more information.
>
> Thanks, this is quite correct. That code assumes that it is printing a
> signed integer.
Does the attached patch solve the problem you see?
/MF
Index: snmplib/parse.c
===================================================================
--- snmplib/parse.c (revision 17733)
+++ snmplib/parse.c (working copy)
@@ -939,6 +939,32 @@
free((char *) np);
}
+static void
+print_range_value(FILE * fp, int type, struct range_list * rp)
+{
+ switch (type) {
+ case TYPE_INTEGER:
+ case TYPE_INTEGER32:
+ if (rp->low == rp->high)
+ fprintf(fp, "%d", rp->low);
+ else
+ fprintf(fp, "%d..%d", rp->low, rp->high);
+ break;
+ case TYPE_UNSIGNED32:
+ case TYPE_OCTETSTR:
+ case TYPE_GAUGE:
+ case TYPE_UINTEGER:
+ if (rp->low == rp->high)
+ fprintf(fp, "%u", (unsigned)rp->low);
+ else
+ fprintf(fp, "%u..%u", (unsigned)rp->low, (unsigned)rp->high);
+ break;
+ default:
+ /* No other range types allowed */
+ break;
+ }
+}
+
#ifdef TEST
static void
print_nodes(FILE * fp, struct node *root)
@@ -961,10 +987,12 @@
}
}
if (np->ranges) {
- fprintf(fp, " Ranges: \n");
+ fprintf(fp, " Ranges: ");
for (rp = np->ranges; rp; rp = rp->next) {
- fprintf(fp, " %d..%d\n", rp->low, rp->high);
+ fprintf(fp, "\n ");
+ print_range_value(fp, np->type, rp);
}
+ fprintf(fp, "\n");
}
if (np->indexes) {
fprintf(fp, " Indexes: \n");
@@ -5385,10 +5413,7 @@
while (rp) {
if (rp != tp->ranges)
fprintf(f, " | ");
- if (rp->low == rp->high)
- fprintf(f, "%d", rp->low);
- else
- fprintf(f, "%d..%d", rp->low, rp->high);
+ print_range_value(f, tp->type, rp);
rp = rp->next;
}
fprintf(f, "\n");
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders