Thanks for the answer here is the code maybe something will ring a bell. You
may send me the code for your trivial MIB and I can follow on that...
Shuki
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "ifTable.h"
#include "ifNumber.h"
#include "networkHelper.hxx"
/** Initializes the ifTable module */
void
init_ifTable(void)
{
/*
* here we initialize all the tables we're planning on supporting
*/
initialize_table_ifTable();
}
/** Initialize the ifTable table by defining its contents and how it's
structured */
void
initialize_table_ifTable(void)
{
static oid ifTable_oid[] = { 1, 3, 6, 1, 2, 1, 2, 2 };
size_t ifTable_oid_len = OID_LENGTH(ifTable_oid);
netsnmp_handler_registration *reg;
//netsnmp_table_data *table_data;
netsnmp_table_registration_info *table_info;
reg = netsnmp_create_handler_registration("ifTable", ifTable_handler,
ifTable_oid, ifTable_oid_len,
HANDLER_CAN_RWRITE);
//table_data = netsnmp_create_table_data("ifTable");
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index:
ifIndex */
0);
table_info->min_column = COLUMN_IFINDEX;
table_info->min_column = COLUMN_IFSPECIFIC;
netsnmp_register_table(reg ,
table_info);//netsnmp_register_table_data(reg, table_data, table_info);
/*
* Initialise the contents of the table here
*/
}
/** handles requests for the ifTable table */
int
ifTable_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
// netsnmp_table_data *table_data;
// netsnmp_table_row *table_row;
SnmpdifTableEntry entry;
SnmpdifTableEntry *table_entry=&entry;
//struct ifTable_entry *table_entry;
switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:
case MODE_GETNEXT:
for (request = requests; request; request = request->next) {
//table_entry = (struct ifTable_entry *)
table_info = netsnmp_extract_table_info(request);
if(table_entry ==NULL || table_info==NULL) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
if(!extract_if_table_entry(table_info,entry,reqinfo->mode))
{//netsnmp_extract_table_row_data(request);
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
switch (table_info->colnum) {
case COLUMN_IFINDEX:
snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
(const
u_char*)&(table_entry->ifIndex),
sizeof(table_entry->ifIndex));
break;
case COLUMN_IFDESCR:
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
(const
u_char*)&(table_entry->ifDescr),
sizeof(table_entry->ifDescr));
break;
case COLUMN_IFTYPE:
snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
(const
u_char*)&(table_entry->ifType),
sizeof(table_entry->ifType));
break;
case COLUMN_IFMTU:
snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
(const
u_char*)&(table_entry->ifMtu),
sizeof(table_entry->ifMtu));
break;
case COLUMN_IFSPEED:
snmp_set_var_typed_value(request->requestvb, ASN_GAUGE,
(const
u_char*)&(table_entry->ifSpeed),
sizeof(table_entry->ifSpeed));
break;
case COLUMN_IFPHYSADDRESS:
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
(const
u_char*)&(table_entry->ifPhysAddress),
sizeof(table_entry->
ifPhysAddress));
break;
case COLUMN_IFADMINSTATUS:
snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
(const
u_char*)&(table_entry->ifAdminStatus),
sizeof(table_entry->
ifAdminStatus));
break;
case COLUMN_IFOPERSTATUS:
snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
(const
u_char*)&(table_entry->ifOperStatus),
sizeof(table_entry->
ifOperStatus));
break;
case COLUMN_IFLASTCHANGE:
snmp_set_var_typed_value(request->requestvb, ASN_TIMETICKS,
(const
u_char*)&(table_entry->ifLastChange),
sizeof(table_entry->
ifLastChange));
break;
case COLUMN_IFINOCTETS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifInOctets),
sizeof(table_entry->ifInOctets));
break;
case COLUMN_IFINUCASTPKTS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifInUcastPkts),
sizeof(table_entry->
ifInUcastPkts));
break;
case COLUMN_IFINNUCASTPKTS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifInNUcastPkts),
sizeof(table_entry->
ifInNUcastPkts));
break;
case COLUMN_IFINDISCARDS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifInDiscards),
sizeof(table_entry->
ifInDiscards));
break;
case COLUMN_IFINERRORS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifInErrors),
sizeof(table_entry->ifInErrors));
break;
case COLUMN_IFINUNKNOWNPROTOS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifInUnknownProtos),
sizeof(table_entry->
ifInUnknownProtos));
break;
case COLUMN_IFOUTOCTETS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifOutOctets),
sizeof(table_entry->ifOutOctets));
break;
case COLUMN_IFOUTUCASTPKTS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifOutUcastPkts),
sizeof(table_entry->
ifOutUcastPkts));
break;
case COLUMN_IFOUTNUCASTPKTS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifOutNUcastPkts),
sizeof(table_entry->
ifOutNUcastPkts));
break;
case COLUMN_IFOUTDISCARDS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifOutDiscards),
sizeof(table_entry->
ifOutDiscards));
break;
case COLUMN_IFOUTERRORS:
snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
(const
u_char*)&(table_entry->ifOutErrors),
sizeof(table_entry->ifOutErrors));
break;
case COLUMN_IFOUTQLEN:
snmp_set_var_typed_value(request->requestvb, ASN_GAUGE,
(const
u_char*)&(table_entry->ifOutQLen),
sizeof(table_entry->ifOutQLen));
break;
case COLUMN_IFSPECIFIC:
snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
(const
u_char*)&(table_entry->ifSpecific),
sizeof(table_entry->ifSpecific));
break;
}
}
break;
/*
* Write-support
*/
case MODE_SET_RESERVE1:
for (request = requests; request; request = request->next) {
// table_entry = (struct ifTable_entry *)
// netsnmp_extract_table_row_data(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_IFADMINSTATUS:
if (request->requestvb->type != ASN_INTEGER) {
netsnmp_set_request_error(reqinfo, request,
SNMP_ERR_WRONGTYPE);
return SNMP_ERR_NOERROR;
}
/*
* Also may need to check size/value
*/
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_ERR_NOTWRITABLE);
return SNMP_ERR_NOERROR;
}
}
break;
case MODE_SET_RESERVE2:
break;
case MODE_SET_FREE:
break;
#if 0
case MODE_SET_ACTION:
for (request = requests; request; request = request->next) {
//table_entry = (struct ifTable_entry *)
// netsnmp_extract_table_row_data(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_IFADMINSTATUS:
/*
* Need to save old 'table_entry->ifAdminStatus' value.
* May need to use 'memcpy'
*/
table_entry->old_ifAdminStatus =
table_entry->ifAdminStatus;
table_entry->ifAdminStatus = request->requestvb->val.YYY;
break;
}
}
break;
case MODE_SET_UNDO:
for (request = requests; request; request = request->next) {
table_entry = (struct ifTable_entry *)
netsnmp_extract_table_row_data(request);
table_row = (netsnmp_table_row *)
netsnmp_extract_table_row(request);
table_data = netsnmp_extract_table(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_IFADMINSTATUS:
/*
* Need to restore old 'table_entry->ifAdminStatus' value.
* May need to use 'memcpy'
*/
table_entry->ifAdminStatus =
table_entry->old_ifAdminStatus;
break;
}
}
break;
case MODE_SET_COMMIT:
break;
#endif
}
return SNMP_ERR_NOERROR;
}
-----Original Message-----
From: Dave Shield [mailto:[EMAIL PROTECTED]
Sent: Friday, October 07, 2005 12:01 PM
To: sasson, shuki
Cc: [email protected]
Subject: RE: Cannot find an adquest mib2c configuration file for travesing
large tables. --- Does Net-SNMP fit to real time environment?
On Fri, 2005-10-07 at 11:56 -0400, sasson, shuki wrote:
> I have tried snmpget to query a get request and snmpwalk for getNext.
In which case I can't explain your results.
However, as I said - I've just tried this with a simple
table of my own, and it *does* work as expected.
I suggest you try again with a trivial table.
If you still run into problems, try posting the code
for this table, and we can have a look at it.
Dave
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders