summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 32ebb9e)
raw | patch | inline | side by side (parent: 32ebb9e)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 9 Nov 2009 11:03:20 +0000 (12:03 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 9 Nov 2009 11:03:20 +0000 (12:03 +0100) |
src/snmp.c | patch | blob | history |
diff --git a/src/snmp.c b/src/snmp.c
index 23e199ecf6113ad99ab62e68f54ed0a7f1d5d2bc..d8db544aaed41595c7f1fc24df8fa63bf5040f28 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
double scale, double shift)
{
value_t ret;
- uint64_t temp = 0;
+ uint64_t tmp_unsigned = 0;
+ int64_t tmp_signed = 0;
int defined = 1;
if ((vl->type == ASN_INTEGER)
#endif
|| (vl->type == ASN_GAUGE))
{
- temp = (uint32_t) *vl->val.integer;
- DEBUG ("snmp plugin: Parsed int32 value is %"PRIu64".", temp);
+ tmp_unsigned = (uint32_t) *vl->val.integer;
+ tmp_signed = (int32_t) *vl->val.integer;
+ DEBUG ("snmp plugin: Parsed int32 value is %"PRIi64".", tmp_signed);
}
else if (vl->type == ASN_COUNTER64)
{
- temp = (uint32_t) vl->val.counter64->high;
- temp = temp << 32;
- temp += (uint32_t) vl->val.counter64->low;
- DEBUG ("snmp plugin: Parsed int64 value is %"PRIu64".", temp);
+ tmp_unsigned = (uint32_t) vl->val.counter64->high;
+ tmp_unsigned = tmp_unsigned << 32;
+ tmp_unsigned += (uint32_t) vl->val.counter64->low;
+ tmp_signed = (int64_t) tmp_unsigned;
+ DEBUG ("snmp plugin: Parsed int64 value is %"PRIu64".", tmp_unsigned);
}
else if (vl->type == ASN_OCTET_STR)
{
}
else if (type == DS_TYPE_COUNTER)
{
- ret.counter = temp;
+ ret.counter = tmp_unsigned;
}
else if (type == DS_TYPE_GAUGE)
{
ret.gauge = NAN;
if (defined != 0)
- ret.gauge = (scale * temp) + shift;
+ ret.gauge = (scale * tmp_signed) + shift;
}
return (ret);