Tim Culhane
2015-04-27 10:47:08 UTC
Hi,
I believe it is correct for index objects in a mib to be marked as
'not-accessible'. Hence, when doing a walk of the mib such oids should be
skipped over and not returned. If you specifically try to get the object
then it should return ' no such object'.
I have a shared object which is loaded by snmpd voa the dlmod directive and
which has the below function for retrieving column values from a table
defined in my mib:
Hi Fulko,
Originally in my shared object I had the following code to retrieve a
specific column:
***********************************************************************/
/*
* @internal
* Retrieve the value for a particular column
*/
NETSNMP_STATIC_INLINE int
_razorgateSmtpStatusCountersTable_get_column
(razorgateSmtpStatusCountersTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list * var, int column)
{
int rc = SNMPERR_SUCCESS;
DEBUGMSGTL(("internal:razorgateSmtpStatusCountersTable:_mfd_razorgateSmtpSta
tusCountersTable_get_column", "called for %d\n", column));
netsnmp_assert(NULL != rowreq_ctx);
/*
* (INDEX)
razorgateSmtpIPAddress(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/
d/H
*/
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
else if (RAZORGATESMTPSTATUSCOUNTERSTABLE_MIN_COL < column
&& column <= RAZORGATESMTPSTATUSCOUNTERSTABLE_MAX_COL)
{
var->val_len = sizeof(long);
var->type = ASN_INTEGER;
rc = column_value_get(rowreq_ctx,
(long *) var->val.string, column);
}
else
{
snmp_log(LOG_ERR,
"unknown column %d in _razorgateSmtpStatusCountersTable_get_column\n",
column);
}
return rc;
}
However, if I do a talk of the tableall values are returned, including the
index field.
I then removed the if branch dealing with the IPAddress column, e.g.:
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
But then if I do a walk of the table I get the below error:
snmpwalk -v2c -c public 10.128.19.86:161 -Os
razorgateSmtpStatusCountersTable
razorgateSmtpStatusCountersTable = No Such Object available on this agent at
this OID
It seems to be failing on the first oid in the table which is the IPAddress
oid.
Can anybody tell me how I should handle requests for oids in my shared
objects when those oids are 'not-accessible'?
Many thanks,
Tim
I believe it is correct for index objects in a mib to be marked as
'not-accessible'. Hence, when doing a walk of the mib such oids should be
skipped over and not returned. If you specifically try to get the object
then it should return ' no such object'.
I have a shared object which is loaded by snmpd voa the dlmod directive and
which has the below function for retrieving column values from a table
defined in my mib:
Hi Fulko,
Originally in my shared object I had the following code to retrieve a
specific column:
***********************************************************************/
/*
* @internal
* Retrieve the value for a particular column
*/
NETSNMP_STATIC_INLINE int
_razorgateSmtpStatusCountersTable_get_column
(razorgateSmtpStatusCountersTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list * var, int column)
{
int rc = SNMPERR_SUCCESS;
DEBUGMSGTL(("internal:razorgateSmtpStatusCountersTable:_mfd_razorgateSmtpSta
tusCountersTable_get_column", "called for %d\n", column));
netsnmp_assert(NULL != rowreq_ctx);
/*
* (INDEX)
razorgateSmtpIPAddress(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/
d/H
*/
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
else if (RAZORGATESMTPSTATUSCOUNTERSTABLE_MIN_COL < column
&& column <= RAZORGATESMTPSTATUSCOUNTERSTABLE_MAX_COL)
{
var->val_len = sizeof(long);
var->type = ASN_INTEGER;
rc = column_value_get(rowreq_ctx,
(long *) var->val.string, column);
}
else
{
snmp_log(LOG_ERR,
"unknown column %d in _razorgateSmtpStatusCountersTable_get_column\n",
column);
}
return rc;
}
However, if I do a talk of the tableall values are returned, including the
index field.
I then removed the if branch dealing with the IPAddress column, e.g.:
if (COLUMN_RAZORGATESMTPIPADDRESS == column)
{
var->type = ASN_OCTET_STR;
/*
* NOTE: val_len is in bytes, razorgateSmtpIPAddress_len might not be (e.g.
oids)
*/
if (var->val_len <
(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]))) {
var->val.string =
malloc(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.
razorgateSmtpIPAddress[0]));
}
var->val_len =
rowreq_ctx->tbl_idx.razorgateSmtpIPAddress_len *
sizeof(rowreq_ctx->tbl_idx.razorgateSmtpIPAddress[0]);
memcpy(var->val.string, rowreq_ctx->tbl_idx.razorgateSmtpIPAddress,
var->val_len);
}
But then if I do a walk of the table I get the below error:
snmpwalk -v2c -c public 10.128.19.86:161 -Os
razorgateSmtpStatusCountersTable
razorgateSmtpStatusCountersTable = No Such Object available on this agent at
this OID
It seems to be failing on the first oid in the table which is the IPAddress
oid.
Can anybody tell me how I should handle requests for oids in my shared
objects when those oids are 'not-accessible'?
Many thanks,
Tim