Hi Bill,
Below is code snippet from snmp_api.c in function snmp_add_va().
I have highlighted the code where Gauge value is processed. At line ltmp =
strtoul(value, &ecp, 10); in below code, “value” is a char pointer which
points to a char array containing integer value.
Note: I still want to emphasize on knowing more on BITSTRING as I don’t know of
its basics on how to use it.
Thanks in advance.
int
snmp_add_var(netsnmp_pdu *pdu,
const oid * name, size_t name_length, char type, const char *value)
{
...
/* some code */
...
switch (type) {
...
/* code continues */
...
case '3':
#ifndef NETSNMP_DISABLE_MIB_LOADING
if (check && tp->type != TYPE_UINTEGER) {
value = "UInteger32";
result = SNMPERR_VALUE;
goto type_error;
}
#endif /* NETSNMP_DISABLE_MIB_LOADING */
ltmp = strtoul(value, &ecp, 10);
if (*value && !*ecp)
snmp_pdu_add_variable(pdu, name, name_length, ASN_UINTEGER,
<mp, sizeof(ltmp));
else
goto fail;
break;
...
/* code continues */
...
}
Regards,
Madhu
From: Bill Fenner [mailto:fen...@gmail.com]
Sent: Wednesday, June 28, 2017 7:58 PM
To: Madhusudhana R <madhusudhan...@in.abb.com>
Cc: net-snmp-coders@lists.sourceforge.net; Pavan Tatavarthi
<pavan.tatavar...@in.abb.com>
Subject: Re: net-snmp5.7.3 non-compliance to RFC2578 on integer overflows for
few trap types
I'm afraid I am not familiar with all of the APIs provided, and I am not
familiar with the one that uses a char array for integers. Can you please be
more specific about what you are doing, or provide some sample code?
Thanks,
Bill
On Wed, Jun 28, 2017 at 1:15 AM, Madhusudhana R
<madhusudhan...@in.abb.com<mailto:madhusudhan...@in.abb.com>> wrote:
Hi Bill,
I am glad for your reply. But need some more clarification.
The integer value greater than UINT32_MAX is fed to netsnmp in the form of
char array and also GAUGE itself defines any value greater than UINT32_MAX will
remain at UINT32_MAX which means we can still provide a large value through
char array.
Point no. 2 and 4 in my queries below seems like a bug as they are not RFC
complaint.
i.e., 1. For GAUGE, negative value should remain at 0 which currently gives
UINT32_MAX.
2. COUNTER64 exceeding UINT64_MAX should wrap around but currently it
remains at UINT64_MAX and does not wrap.
Please comment on these 2 points.
Also I am still not able understand how to use BITSTRING type. I don’t know how
the input value be given to netsnmp. Please help me on this.
Regards,
Madhu
From: Bill Fenner [mailto:fen...@gmail.com<mailto:fen...@gmail.com>]
Sent: Tuesday, June 27, 2017 8:53 PM
To: Madhusudhana R <madhusudhan...@in.abb.com<mailto:madhusudhan...@in.abb.com>>
Cc:
net-snmp-coders@lists.sourceforge.net<mailto:net-snmp-coders@lists.sourceforge.net>
Subject: Re: net-snmp5.7.3 non-compliance to RFC2578 on integer overflows for
few trap types
Madhu,
How are you supplying the values to net-snmp? Many of these can be explained
by net-snmp's internal representation (e.g., using "uint32" for non-negative
types, so supplying -1 turns into UINT32_MAX inside C, without any explicit
behavior on net-snmp's part. A lot of these limitations are up to the MIB
module implementation to enforce, so the issues that you are seeing sound
mostly like GIGO to me.
Bill
On Mon, Jun 19, 2017 at 4:09 AM, Madhusudhana R
<madhusudhan...@in.abb.com<mailto:madhusudhan...@in.abb.com>> wrote:
Hi Coders,
I have below queries regarding trap types where I found little mismatch with
RFC2578 definition and net-snmp5.7.3 behavior on boundary values.
It will be of great help if someone can clarify on this.
For convenience, below definitions are used.
INT32_MAX 2147483647<tel:(214)%20748-3647>
NINT32_MAX -2147483648<tel:(214)%20748-3648>
UINT32_MAX 4294967295
1. INTEGER/INTEGER32
Since RFC 2578 does not mention the behavior for integer overflow, net-snmp
currently sticks to NINT32_MAX or INT32_MAX for integer overflows on both
sides. Please clarify what should be the actual behavior?
2. GAUGE32
RFC2578 says “The Gauge32 type represents a non-negative integer, which may
increase or decrease, but shall never exceed a maximum value, nor fall below a
minimum value. The maximum value cannot be greater than 2^32-1 (4294967295
decimal), and the minimum value cannot be smaller than 0 “
But net-snmp wraps around to 2^31 – 1 for any value less than 0. This does not
conforms to RFC definition. Is this a bug with in net-snmp?
3. UNSIGNED32
RFC2578 says the range lies between 0 to 2^32-1 but there is no information on
overflows. Currently for overflow net-snmp gives UINT32_MAX but for input
value= -1 it wraps around to UINT32_MAX.
What should be the behavior for -1 and integer overflow for this trap type?
4. COUNTER
RFC2578 says counter range is 0 to 2^32-1 and should wrap around for UINT32_MAX
+ 1. But for overflow netsnmp remains at UINT32_MAX which is not RFC2578
complaint. Looks like a bug. Please clarify.
Also for value =-1, net-snmp gives UINT32_MAX which wraps around on other
direction. Is this correct behavior?
5. TIMETICKS
RFC2578 says the range is from 0 to 2^32 which is bit contradictory as it
violates basic unsigned 32 bit integer range. Currently net-snmp stands at
UINT32_MAX for 2^32 input value. Please clarify on this.
6. BITSTRING
This is little bit important query as I am not aware of how it should be used.
Please let me know how the BITSTRING should be used along with few example for
better clarity.
I am aware that my queries are little bit lengthy but it is my humble request
if anybody can answer these questions it will be of great help for me.
Thanks in advance.
Regards,
Madhu
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net<mailto:Net-snmp-coders@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders