perl agent problem with COUNTER64
"Neptune Ning (plan)" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
HI, All:
I'am recently writing extension using perl. I've came across a problem with
ASN_COUNTER64 type.
when I use COUNTER64 to return a value, I will get a wired value from
snmpwalk. The machine I used is X86_64 and perl was compiled to support a
64bit number.
Even when I uses setValue (ASN_COUNTER64, 1) , the value I get from
snmpwalk is quite large.
I've looked into the code of net-snmp-5.4.2.1 for some answers.
In "perl/agent/agent.xs:833-863": it gets a numeric "utmp" from SvIV or
converts from a string. and call
snmp_set_var_typed_value(request->requestvb, (u_char)type,
(u_char *) &utmp, sizeof(utmp));
I printed the value of "utmp", it was right.
then I followed into "snmp_set_var_value()" which called by
snmp_set_var_typed_value(), between line 916-925 handels COUNTER64 type:
vars->val_len = sizeof(struct counter64);
memmove(vars->val.counter64, value, vars->val_len);
It seemed directly copy the 64bit value into a struct counter64,
but I found the definition of struct counter64 in
"include/net-snmp/library/asn1.h"
struct counter64 {
u_long high;
u_long low;
};
In X86_64 platform sizeof (struct counter64) will be 16 (128bit), therefor
setValue (ASN_COUNTER64, 0x100000002),
might get :
high=0x100000002, low=unexpected value
If I change the definition of struct counter64 into
struct counter64 {
uint32_t low;
uint32_t high;
}
my perl extension which use counter64 will work, but other OIDs like
IF-MIB::ifHCInOctets will be broken. the log was like:
snmp_build: unknown failuresend response: Error building ASN.1
representation (build uint64 size 16: s/b 8)
-- ifHCInOctets.1
Do you have any suggestion? I would appreciate a quick solution because the
time I get for my project is limited.
-------------------
Best regards,
Neptune Ning
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users