| Newsgroups |
gmane.network.net-snmp.user |
| Message-ID |
<[email protected]> |
Hi Dave,
Thanks for your reply. I have generated code using mib2c -c
mib2c.create-dataset.conf. I am using the netsnmp_table_data_set helper
.
I am attaching the code .With this code I am able to add rows and get
the rows but not able to delete. When I am setting the row status as 6
the log "INSIDE RS_DESTROY" getting printed but it is not deleting the
row.
Please point out the errors.
Thanks,
Somenath
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.create-dataset.conf,v 5.4 2004/02/02 19:06:53 rstory
Exp $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "mclbModemNetworkCertificateTable.h"
netsnmp_table_data_set *table_set;
/** Initialize the mclbModemNetworkCertificateTable table by defining
its contents and how it's structured */
void
initialize_table_mclbModemNetworkCertificateTable(void)
{
static oid mclbModemNetworkCertificateTable_oid[] =
{ 1, 3, 6, 1, 4, 1, 161, 204, 1, 25, 50, 175, 3 };
size_t mclbModemNetworkCertificateTable_oid_len =
OID_LENGTH(mclbModemNetworkCertificateTable_oid);
/*
* create the table structure itself
*/
table_set =
netsnmp_create_table_data_set("mclbModemNetworkCertificateTable");
/*
* comment this out or delete if you don't support creation of new
rows
*/
table_set->allow_creation = 1;
/***************************************************
* Adding indexes
*/
DEBUGMSGTL(("initialize_table_mclbModemNetworkCertificateTable",
"adding indexes to table
mclbModemNetworkCertificateTable\n"));
netsnmp_table_set_add_indexes(table_set, ASN_INTEGER, /*
index: mclbModemNetworkCertificateIndex */
0);
DEBUGMSGTL(("initialize_table_mclbModemNetworkCertificateTable",
"adding column types to table
mclbModemNetworkCertificateTable\n"));
netsnmp_table_set_multi_add_default_row(table_set,
COLUMN_MCLBMODEMNETWORKCERTIFICATEINDEX,
ASN_INTEGER, 0, NULL, 0,
COLUMN_MCLBMODEMNETWORKCERTIFICATENAME,
ASN_OCTET_STR, 1, NULL, 0,
COLUMN_MCLBMODEMNETWORKCERTIFICATETYPE,
ASN_INTEGER, 1, NULL, 0,
COLUMN_MCLBMODEMNETWORKCERTIFICATEFILENAME,
ASN_OCTET_STR, 1, NULL, 0,
COLUMN_MCLBMODEMNETWORKCERTIFICATEROWSTATUS,
ASN_INTEGER, 1, NULL, 0, 0);
/*
* registering the table with the master agent
*/
/*
* note: if you don't need a subhandler to deal with any aspects
* of the request, change mclbModemNetworkCertificateTable_handler
to "NULL"
*/
netsnmp_register_table_data_set(netsnmp_create_handler_registration
("mclbModemNetworkCertificateTable",
mclbModemNetworkCertificateTable_handler,
mclbModemNetworkCertificateTable_oid,
mclbModemNetworkCertificateTable_oid_len,
HANDLER_CAN_RWRITE), table_set,
NULL);
}
/** Initializes the mclbModemNetworkCertificateTable module */
void
init_mclbModemNetworkCertificateTable(void)
{
/*
* here we initialize all the tables we're planning on supporting
*/
initialize_table_mclbModemNetworkCertificateTable();
}
/** handles requests for the mclbModemNetworkCertificateTable table, if
anything else needs to be done */
int
mclbModemNetworkCertificateTable_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration
*reginfo,
netsnmp_agent_request_info
*reqinfo,
netsnmp_request_info *requests)
{
int create_certificate_status = -1;
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
unsigned int noofindexes = 1, retVal;
netsnmp_table_row *row;
/*
* perform anything here that you need to do. The requests have
* already been processed by the master table_dataset handler, but
* this gives you chance to act on the request in some other way
* if need be.
*/
switch (reqinfo->mode)
{
case MODE_SET_ACTION:
for (request = requests; request; request = request->next) {
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MCLBMODEMNETWORKCERTIFICATEROWSTATUS:
switch (*request->requestvb->val.integer)
{
case RS_CREATEANDGO:
snmp_log (LOG_DEBUG,"INSIDE
RS_CREATEANDGO\n");
break;
case RS_DESTROY:
snmp_log (LOG_DEBUG,"INSIDE RS_DESTROY
\n");
return SNMP_ERR_NOERROR;
break;
default:
netsnmp_set_request_error(reqinfo,
request,
SNMP_ERR_WRONGVALUE);
return SNMP_ERR_NOERROR;
}
break;
}
}
break;
}
return SNMP_ERR_NOERROR;
}
-----Original Message-----
From: Dave Shield [mailto:[email protected]]
Sent: Friday, February 17, 2006 7:02 PM
To: Somenath Pal (WT01 - Broadband Networks)
Cc: [email protected]
Subject: RE: Example of create
On Fri, 2006-02-17 at 18:52 +0530, [email protected] wrote:
> Thanks for replying .I have written the code for create. I am able to
> create and get. But I am not able to delete the row .
But how are you maintaining the table?
The code snippet you included said *NOTHING* about what
approach you are taking! Which helper(s) you might be
using, what the data structure for the table looks like,
what the data structure for an individual row is, nothing.
I do not have the time to try and read your mind, or play
twenty questions to tease out these important details.
Did you generate the code by hand, or using mib2c?
If mib2c, which template did you use?
I *STRONGLY* suggest that you locate an existing table
that uses a similar approach to your current code,
and examine that to understand how it works. You should
then be able to apply the same techniques to your MIB.
Dave