Hi,
The following is my MIB.
| | +--mVgSipDnsServerTable(6)
| | | |
| | | +--mVgSipDnsServerEntry(1)
| | | | Index: mVgSipDnsServerIPAddressType,
mVgSipDnsServerIpAddress
| | | |
| | | +-- ---- EnumVal
mVgSipDnsServerIPAddressType(1)
| | | | Textual Convention: InetAddressType
| | | | Values: unknown(0), ipv4(1), ipv6(2),
ipv4z(3), ipv6z(4), dns(16)
| | | +-- ---- String mVgSipDnsServerIpAddress(2)
| | | | Textual Convention: InetAddress
| | | | Size: 0..255
| | | +-- CR-- INTEGER mVgSipDnsServerPriority(3)
| | | | Range: 1..2
| | | +-- CR-- EnumVal mVgSipDnsServerRowStatus(4)
| | | Textual Convention: RowStatus
| | | Values: active(1), notInService(2),
notReady(3), createAndGo(4), createAndWait(5), destroy(6)
Whenever I am calling
snmpset -c public 127.0.0.1 mVgSipDnsServerRowStatus.1.\"1.1.1.1\" i 4.
the row is getting created.
But when I am trying to modify the column of the created row using the
following command
snmpset -c public 127.0.0.1 mVgSipDnsServerPriority.1.\"1.1.1.1\" i 2
The function mVgSipDnsServerTable_get_next_data_point() returning
NULL,because of which the function
netsnmp_extract_iterator_context() is returning null and I am not able
to modify the contents of the created row.
Can any one please help me.
Please find below the mib2c generated code using mib2c.iterator.conf.
/*
* Typical data structure for a row entry
*/
struct mVgSipDnsServerTable_entry {
/*
* Index values
*/
long mVgSipDnsServerIPAddressType;
char mVgSipDnsServerIpAddress[LengthOfIp];
size_t mVgSipDnsServerIpAddress_len;
// long mVgSipScacIndex;
/*
* Column values
*/
long mVgSipDnsServerPriority;
long old_mVgSipDnsServerPriority;
long mVgSipDnsServerRowStatus;
/*
* Illustrate using a simple linked list
*/
int valid;
struct mVgSipDnsServerTable_entry *next;
};
struct mVgSipDnsServerTable_entry *mVgSipDnsServerTable_head = NULL;
/** Initialize the mVgSipDnsServerTable table by defining its contents
and how it's structured */
void
initialize_table_mVgSipDnsServerTable(void)
{
static oid mVgSipDnsServerTable_oid[] =
{ 1, 3, 6, 1, 4, 1, 1012, 100, 1, 67, 1, 6 };
size_t mVgSipDnsServerTable_oid_len =
OID_LENGTH(mVgSipDnsServerTable_oid);
netsnmp_handler_registration *reg;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;
static unsigned int my_columns[] = {
COLUMN_MVGSIPDNSSERVERPRIORITY,
COLUMN_MVGSIPDNSSERVERROWSTATUS,
0 /* This one is due to the comma above :-) */
};
static netsnmp_column_info valid_columns;
/*
* we only want to process certain columns, and ignore the "holes"
*/
printf("In %s\n",__FUNCTION__);
valid_columns.isRange = 0;
valid_columns.details.list = my_columns;
valid_columns.list_count = (sizeof(my_columns) / sizeof(unsigned
int)) - 1; /* Minus 1 is due to the comma above :-) */
reg =
netsnmp_create_handler_registration("mVgSipDnsServerTable",
mVgSipDnsServerTable_handler,
mVgSipDnsServerTable_oid,
mVgSipDnsServerTable_oid_len,
HANDLER_CAN_RWRITE);
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /*
index: mVgSipDnsServerIPAddressType */
ASN_OCTET_STR, /* index:
mVgSipDnsServerIpAddress */
0);
table_info->min_column = COLUMN_MVGSIPDNSSERVERPRIORITY;
table_info->max_column = COLUMN_MVGSIPDNSSERVERROWSTATUS;
table_info->valid_columns = &valid_columns;
iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
iinfo->get_first_data_point =
mVgSipDnsServerTable_get_first_data_point;
iinfo->get_next_data_point =
mVgSipDnsServerTable_get_next_data_point;
iinfo->table_reginfo = table_info;
netsnmp_register_table_iterator(reg, iinfo);
/*
* Initialise the contents of the table here
*/
}
/*
* create a new row in the (unsorted) table
*/
struct mVgSipDnsServerTable_entry *
mVgSipDnsServerTable_createEntry(long mVgSipDnsServerIPAddressType,
char *mVgSipDnsServerIpAddress,
size_t
mVgSipDnsServerIpAddress_len)//,int mVgSipCnt)
{
struct mVgSipDnsServerTable_entry *entry;
printf("In %s wit iptype = %d,ipaddr =
%s\n",__FUNCTION__,mVgSipDnsServerIPAddressType,mVgSipDnsServerIpAddress
);
entry = SNMP_MALLOC_TYPEDEF(struct mVgSipDnsServerTable_entry);
if (!entry)
return NULL;
/*Wipro: This is for scacIndexing*/
entry->mVgSipDnsServerIPAddressType = mVgSipDnsServerIPAddressType;
memcpy(entry->mVgSipDnsServerIpAddress, mVgSipDnsServerIpAddress,
mVgSipDnsServerIpAddress_len);
entry->mVgSipDnsServerIpAddress_len = mVgSipDnsServerIpAddress_len;
entry->next = mVgSipDnsServerTable_head;
entry->valid = 1;
/*Wipro: This is for scacIndexing*/
// entry->mVgSipScacIndex = mVgSipCnt;
mVgSipDnsServerTable_head = entry;
printf("In %s\n",__FUNCTION__);
return entry;
}
/*
* remove a row from the table
*/
void
mVgSipDnsServerTable_removeEntry(struct mVgSipDnsServerTable_entry
*entry)
{
struct mVgSipDnsServerTable_entry *ptr, *prev;
printf("In %s\n",__FUNCTION__);
if (!entry)
return; /* Nothing to remove */
for (ptr = mVgSipDnsServerTable_head, prev = NULL;
ptr != NULL; prev = ptr, ptr = ptr->next) {
if (ptr == entry)
break;
}
if (!ptr)
return; /* Can't find it */
if (prev == NULL)
mVgSipDnsServerTable_head = ptr->next;
else
prev->next = ptr->next;
SNMP_FREE(entry); /* XXX - release any other internal
resources */
}
/*
* Example iterator hook routines - using 'get_next' to do most of the
work
*/
netsnmp_variable_list *
mVgSipDnsServerTable_get_first_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list *
put_index_data,
netsnmp_iterator_info *mydata)
{
printf("In %s\n",__FUNCTION__);
*my_loop_context = mVgSipDnsServerTable_head;
return mVgSipDnsServerTable_get_next_data_point(my_loop_context,
my_data_context,
put_index_data,
mydata);
}
netsnmp_variable_list *
mVgSipDnsServerTable_get_next_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list *
put_index_data,
netsnmp_iterator_info *mydata)
{
struct mVgSipDnsServerTable_entry *entry =
(struct mVgSipDnsServerTable_entry *) *my_loop_context;
printf("In %s\n",__FUNCTION__);
netsnmp_variable_list *idx = put_index_data;
if (entry) {
snmp_set_var_typed_integer(idx, ASN_INTEGER,
entry->mVgSipDnsServerIPAddressType);
idx = idx->next_variable;
snmp_set_var_value(idx, (const u_char *)
entry->mVgSipDnsServerIpAddress,
sizeof(entry->mVgSipDnsServerIpAddress));
idx = idx->next_variable;
*my_data_context = (void *) entry;
*my_loop_context = (void *) entry->next;
return put_index_data;
} else {
printf("Null returned\n");
return NULL;
}
}
/** handles requests for the mVgSipDnsServerTable table */
int
mVgSipDnsServerTable_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;
struct mVgSipDnsServerTable_entry *table_entry;
opcode scacOpCode;
tableName scacTableName;
int scacIndex=0,scacMask=0,ret;
short scacTempVar = 0;
retCode scacRet = A_SUCCESS;
static int mVgSipCnt = 0;
char scacTempIp[LengthOfIp] = {0};
printf("In %s wid %d\n",__FUNCTION__,reqinfo->mode);
switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERPRIORITY:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
/*Wipro: No need to call scacOperation().We have the data*/
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->
mVgSipDnsServerPriority);
break;
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->
mVgSipDnsServerRowStatus);
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHOBJECT);
break;
}
}
break;
/*
* Write-support
*/
case MODE_SET_RESERVE1:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
if(!table_entry)
printf("Null\n");
else
printf("Not Null\n");
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERPRIORITY:
/*
* or possibly 'netsnmp_check_vb_int_range'
*/
ret = netsnmp_check_vb_int(request->requestvb);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, request, ret);
return SNMP_ERR_NOERROR;
}
break;
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
ret = netsnmp_check_vb_rowstatus(request->requestvb,
(table_entry ?
RS_ACTIVE :
RS_NONEXISTENT));
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, request, ret);
return SNMP_ERR_NOERROR;
}
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_ERR_NOTWRITABLE);
return SNMP_ERR_NOERROR;
}
}
break;
case MODE_SET_RESERVE2:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
switch (*request->requestvb->val.integer) {
case RS_CREATEANDGO:
case RS_CREATEANDWAIT:
table_entry =
mVgSipDnsServerTable_createEntry(*table_info->
indexes->val.
integer,
(char
*)table_info->
indexes->next_variable->val.
string,
table_info->
indexes->next_variable->val_len);
if (table_entry) {
netsnmp_insert_iterator_context(request,
table_entry);
} else {
netsnmp_set_request_error(reqinfo, request,
SNMP_ERR_RESOURCEUNAVAILABLE);
return SNMP_ERR_NOERROR;
}
}
}
}
break;
case MODE_SET_FREE:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
switch (*request->requestvb->val.integer) {
case RS_CREATEANDGO:
case RS_CREATEANDWAIT:
if (table_entry && !table_entry->valid) {
mVgSipDnsServerTable_removeEntry(table_entry);
}
}
}
}
break;
case MODE_SET_ACTION:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
if(!table_entry)
printf("Null\n");
else
printf("Not Null\n");
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERPRIORITY:
table_entry->old_mVgSipDnsServerPriority =
table_entry->mVgSipDnsServerPriority;
table_entry->mVgSipDnsServerPriority =
*request->requestvb->val.integer;
break;
}
}
/*
* Check the internal consistency of an active row
*/
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
switch (*request->requestvb->val.integer) {
case RS_ACTIVE:
case RS_CREATEANDGO:
// if ( /* XXX */ ) {
// netsnmp_set_request_error(reqinfo, request,
//
SNMP_ERR_INCONSISTENTVALUE);
return SNMP_ERR_NOERROR;
// }
}
}
}
break;
case MODE_SET_UNDO:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERPRIORITY:
table_entry->mVgSipDnsServerPriority =
table_entry->old_mVgSipDnsServerPriority;
table_entry->old_mVgSipDnsServerPriority = 0;
break;
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
switch (*request->requestvb->val.integer) {
case RS_CREATEANDGO:
case RS_CREATEANDWAIT:
if (table_entry && !table_entry->valid) {
mVgSipDnsServerTable_removeEntry(table_entry);
}
}
break;
}
}
break;
case MODE_SET_COMMIT:
for (request = requests; request; request = request->next) {
table_entry = (struct mVgSipDnsServerTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
switch (table_info->colnum) {
case COLUMN_MVGSIPDNSSERVERROWSTATUS:
switch (*request->requestvb->val.integer) {
case RS_CREATEANDGO:
table_entry->valid = 1;
/*
* Fall-through
*/
case RS_ACTIVE:
table_entry->mVgSipDnsServerRowStatus = RS_ACTIVE;
break;
case RS_CREATEANDWAIT:
table_entry->valid = 1;
/*
* Fall-through
*/
case RS_NOTINSERVICE:
table_entry->mVgSipDnsServerRowStatus =
RS_NOTINSERVICE;
break;
case RS_DESTROY:
mVgSipDnsServerTable_removeEntry(table_entry);
}
}
}
break;
}
return SNMP_ERR_NOERROR;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.