/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "XXXTable.h"
#include "cvn_global.h"
#include "libspid.h"
#include "cvn_dvm_public.h"
#include "cvn_topo.h"
#include "cvn_mapi.h"
#if 0
#include <ipc_protocol.h>
#include "nscrtv.h"
#include "libmme.h"
#endif
/** Initializes the eocExtCnuTableCVN module */
void
init_XXXTable(void)
{
initialize_table_XXXTable();
}
/** Initialize the eocExtCnuTable table by defining its contents and how it's structured */
void
initialize_table_xxxTable(void) //初始化表函数
{
const oid eocExtCnuTable_oid[] =
{ 1, 3, 6, 1, 4, 1, 17409, 2, 1, 1, 258, 2, 1 }; //定义静态列表 OID 号
const size_t eocExtCnuTable_oid_len =
OID_LENGTH(eocExtCnuTable_oid); //取OID号的长度
netsnmp_handler_registration *reg; //注册信息结构体,包含注册名,根节点号,优先级等信息
netsnmp_iterator_info *iinfo; //迭代信息结构体
netsnmp_table_registration_info *table_info; //节点信息结构体,包含节点数量,min/max宏序号等信息
DEBUGMSGTL(("eocExtCnuTable:init",
"initializing table eocExtCnuTable\n"));
reg =
netsnmp_create_handler_registration("XXXTable", //列表信息注册函数,传入表名、处理函数、OID 、读写权限
XXXTableCVN_handler,
XXXTable_oid,
XXXTable_oid_len,
HANDLER_CAN_RWRITE);//此处要注意修改
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);//为表申请地址空间
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: eocExtCnuCBATCardIndex */
ASN_INTEGER, /* index: eocExtCnuIndex */
0); //增加表索引的函数,有几个索引就加几个
table_info->min_column = COLUMN_XXX; //最小可操作节点
table_info->max_column = COLUMN_XXX; //最大可操作节点
iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info); //申请迭代信息地址空间
iinfo->get_first_data_point = eocExtCnuTableCVN_get_first_data_point;
iinfo->get_next_data_point = eocExtCnuTableCVN_get_next_data_point;
iinfo->table_reginfo = table_info; //迭代信息结构体赋值
netsnmp_register_table_iterator(reg, iinfo);//注册迭代列表,使之运行
/*
* Initialise the contents of the table here
*/
}
struct XXXTable_entry { //列表结构体声明
/*
* Index values
*/
long XXXIndex; //索引
long XXXIndex;
/*
* Column values
*/
long eocExtCnuMacLimit;
long old_eocExtCnuMacLimit;//具体节点信息
/*
* Illustrate using a simple linked list
*/
int valid;
struct XXXTable_entry *next; //将其定义为循环链表
};
struct XXXTable_entry *XXXTable_head; //定义链表头
/*
* create a new row in the (unsorted) table
*/
struct XXXTable_entry *
XXXTable_createEntry(long XXXIndex, //传递索引
long XXXIndex)
{
struct XXXTable_entry *entry;
entry = SNMP_MALLOC_TYPEDEF(struct XXXTable_entry); //申请链表的地址空间
if (!entry)
return NULL; //未申请成功,退出
entry->XXXIndex = XXXIndex; //赋索引号
entry->XXXIndex = XXXIndex; //赋索引号
entry->next = XXXTable_head; //产生链表
XXXTable_head = entry;
return entry;
}
/*
* remove a row from the table
*/
void
XXXTable_removeEntry(struct XXXTable_entry *entry)
{
struct XXXTable_entry *ptr, *prev;
if (!entry)
return; /* Nothing to remove */ //空链表,直接退出
for (ptr = XXXTable_head, prev = NULL; //链表搜索,清楚全部
ptr != NULL; prev = ptr, ptr = ptr->next) {
if (ptr == entry) //已为最后一项,跳出
break;
}
if (!ptr) //无最后一项,返回
return; /* Can't find it */
if (prev == NULL) //目前为位置为第一项,连接至下一项
XXXTable_head = ptr->next;
else
prev->next = ptr->next; //连接至下一项
SNMP_FREE(entry); //移除链表中的该项
}
/*
* Example iterator hook routines - using 'get_next' to do
MIB的table的.c文件编程框架
最新推荐文章于 2023-06-04 21:47:01 发布
本文详细介绍了如何在C语言中编程实现MIB的table结构,涵盖了从基本概念到具体代码框架的建立,帮助读者理解如何在SNMP协议下创建和管理MIB表格。
摘要由CSDN通过智能技术生成