In order to learn how to use NetSNMP I was reading through the MFD ifTable
tutorial. Part of the code generated for the "ifTable" table (when using the
"mib2c" command with the MFD configuration file) is the following:
if ((rowreq_ctx->data.ifDescr == NULL) ||
(rowreq_ctx->data.ifDescr_len < (ifDescr_len * sizeof(ifDescr[0])))) {
snmp_log(LOG_ERR, "not enough space for value\n");
return MFD_ERROR;
}
rowreq_ctx->data.ifDescr_len = ifDescr_len * sizeof(ifDescr[0]);
memcpy(rowreq_ctx->data.ifDescr, ifDescr, ifDescr_len * sizeof(ifDescr[0]));
When runnnig this code I get the "not enough space for value" error being
produced. The reason why it fails is due to the length check which is being
performed (shown below):
(rowreq_ctx->data.ifDescr_len < (ifDescr_len * sizeof(ifDescr[0])))
It seems to me that this will always fail since the
"rowreq_ctx->data.ifDescr_len" variable does not get populated until "after"
the "If" check is performed (see code snipet above).
Question:
What am I missing? How can this check (which is generated for me automatically
using mib2c) actually ever work?
PS: Keep in mind that before the code supplied above, I am populating the
"ifDescr_len" variable with a valid length value.
---------------------------------
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders