hiiiiiiiiii
i generated the ipForwarding_implement.c and .h file by using the
following command
mib2c -c mib2c.vec_scalar_implement.conf -I ipForwarding
and got the following ipForwarding_implement.c file
now i have to implement ipForwarding ipDefaultTTL and ipReasmTimeOut
how can i ???
============================================================================
===============================================================================
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "snmp_ctl_interface.h"
#include "ipForwarding_implement.h"
/** Scalar data access functions for ipForwarding .
* Note:
* These get_ routine MUST return data that will not be freed (ie.
* static or persistent data).
* These set_ routine MUST copy the incoming data and can not take
* ownership of the memory passed in by the val pointer.
*
* SNMP_ERR_NOERROR success code
* SNMP_ERR_TOOBIG
* SNMP_ERR_NOSUCHNAME
* SNMP_ERR_BADVALUE
* SNMP_ERR_READONLY
* SNMP_ERR_GENERR
* SNMP_ERR_NOACCESS
* SNMP_ERR_WRONGTYPE
* SNMP_ERR_WRONGLENGTH
* SNMP_ERR_WRONGENCODING
* SNMP_ERR_WRONGVALUE
* SNMP_ERR_NOCREATION
* SNMP_ERR_INCONSISTENTVALUE
* SNMP_ERR_RESOURCEUNAVAILABLE
* SNMP_ERR_COMMITFAILED
* SNMP_ERR_UNDOFAILED
* SNMP_ERR_AUTHORIZATIONERROR
* SNMP_ERR_NOTWRITABLE
*/
/** Retrieve data from storage and return a pointer to the data
* for the ipForwarding scalar item.
* Set ret_len to its proper size in bytes.
* @param[out] ret_val - pointer to value to be returned.
* @param[out] ret_len - length in bytes of returned data.
* @return return one of the snmp return codes listed above
*/
int
get_scalar_ipForwarding(long ** ret_val, size_t * ret_len)
{
char *result_str = NULL;
void *cache = NULL;
int err = SNMP_ERR_NOERROR;
long *val = NULL;
err = snmp_DbGetValue(IPFORWARDING_TABLE_NAME, 0, NULL,
IPFORWARDING_FIELD_NAME, &result_str, &cache);
if (err == SNMP_ERR_NOERROR)
{
val = calloc(1, sizeof(long));
if (val != NULL)
{
/* XXX - verify conversion */
*val = (long)atol(result_str);
/* val freed in main table function */
*ret_len = sizeof(*val);
*ret_val = val;
}
else
{
err = SNMP_ERR_RESOURCEUNAVAILABLE;
}
/* free result_str since we are not sending back a string */
free(result_str);
}
return err;
}
/** Save the data for the ipForwarding scalar item
* @param[in] val - pointer to value to be saved.
* @param[in] val_len - length of data in bytes.
* @return return one of the snmp return codes listed above
*/
int
set_scalar_ipForwarding(long *val, size_t val_len)
{
char *cmd;
char *cmd_ptr;
int err = SNMP_ERR_NOERROR;
cmd = calloc(1, IPFORWARDING_CMD_LEN);
if (cmd == NULL)
return SNMP_ERR_RESOURCEUNAVAILABLE;
cmd_ptr = cmd;
cmd_ptr += snprintf(cmd_ptr, IPFORWARDING_CMD_LEN - (cmd_ptr - cmd),
"UPDATE %s SET %s = ", IPFORWARDING_TABLE_NAME, IPFORWARDING_FIELD_NAME);
cmd_ptr += snprintf(cmd_ptr, IPFORWARDING_CMD_LEN - (cmd_ptr - cmd) ,
"%ld", *val);
err = snmp_DbExecute(cmd);
free(cmd);
return err;
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders