lee请进

5 views
Skip to first unread message

sky

unread,
May 21, 2009, 10:03:56 PM5/21/09
to EMS网管开发
group似乎有问题。只能新发帖回答。
我有几个问题需要你确认,然后才能给你建议。
1.get_first_data是你的函数还是net-snmp的函数。
2.死循环是在所有的节点上都会发生,还是只和特定节点发生。换句话说,如果提高get的频率,是否每个节点都会死循环。

lee...@126.com

unread,
May 22, 2009, 1:06:25 AM5/22/09
to EMS网管开发
谢谢sky
1.get_first_data是你的函数还是net-snmp的函数。
这个是mib2C产生的函数,输入net-snmp的函数了。

2.死循环是在所有的节点上都会发生,还是只和特定节点发生。换句话说,如果提高get的频率,是否每个节点都会死循环。
循坏的问题找到了,是部分节点的问题,也不是死循环,是因为我相应的操作花的时间比较长,所以返回timeout,我试着在
get_first_data处控制调用的次数,这个问题出现的次数就减少了。

但是我有个疑问,为啥我在调用上一个表的时候,同时也会调用下一个表呢,按理说这两个表是没有关系的。我也曾重新mib2c,但是问题依然一样的。
您是否遇到类似的问题呢,请帮我分析一下!

sky

unread,
May 22, 2009, 1:14:08 AM5/22/09
to EMS网管开发

如果是这样那么还是要试着优化你的操作时间,又或者可能需要重新设计一下MIB,因为NETSNMP本身的超时阀值应该是一个比较通用的值。
get_first_data是MIB2C产生的函数,那么你把MIB2C产生的代码贴上来我看看吧。

> > 2.死循环是在所有的节点上都会发生,还是只和特定节点发生。换句话说,如果提高get的频率,是否每个节点都会死循环。- 隐藏被引用文字 -
>
> - 显示引用的文字 -

lee...@126.com

unread,
May 22, 2009, 1:17:56 AM5/22/09
to EMS网管开发

/*
* 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 "remotesPolicerVidModeTable.h"
#include "JZ_EPON_SNMP.h"

extern jz_onu_mac_table_t onu_mac_table[MAX_OLT_NUM *
MAX_ONU_NUM_PER_OLT];
void JZ_SNMP_init_remotesPolicerVidModeTable(void);
/** Initializes the remotesPolicerVidModeTable module */
void
init_remotesPolicerVidModeTable(void)
{
/*
* here we initialize all the tables we're planning on supporting
*/
initialize_table_remotesPolicerVidModeTable();
}

/** Initialize the remotesPolicerVidModeTable table by defining its
contents and how it's structured */
void
initialize_table_remotesPolicerVidModeTable(void)
{
static oid remotesPolicerVidModeTable_oid[] =
{ 1, 3, 6, 1, 4, 1, 17409, 2, 1, 5, 2, 3, 5, 1 };
size_t remotesPolicerVidModeTable_oid_len =
OID_LENGTH(remotesPolicerVidModeTable_oid);
netsnmp_handler_registration *reg;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;

reg =
netsnmp_create_handler_registration
("remotesPolicerVidModeTable",

remotesPolicerVidModeTable_handler,

remotesPolicerVidModeTable_oid,

remotesPolicerVidModeTable_oid_len,
HANDLER_CAN_RWRITE);

table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /*
index: remotesPolicerVidModeIndex */
0);
table_info->min_column = COLUMN_REMOTESPOLICERVIDMODEINDEX;
table_info->max_column = COLUMN_POLICERGETVIDRETURNVALUE;

iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
iinfo->get_first_data_point =
remotesPolicerVidModeTable_get_first_data_point;
iinfo->get_next_data_point =
remotesPolicerVidModeTable_get_next_data_point;
iinfo->table_reginfo = table_info;

netsnmp_register_table_iterator(reg, iinfo);

/*
* Initialise the contents of the table here
*/
JZ_SNMP_init_remotesPolicerVidModeTable();
}

/*
* Typical data structure for a row entry
*/
struct remotesPolicerVidModeTable_entry
{
long remotesPolicerVidModeIndex;

long remotesPolicerVidModeDirection;
long old_remotesPolicerVidModeDirection;
long remotesPolicerVidModeVid;
long old_remotesPolicerVidModeVid;
long remotremotesPolicerVidModeEnalePolicer;
long old_remotremotesPolicerVidModeEnalePolicer;
long remotesPolicerVidModeMaxBw;
long old_remotesPolicerVidModeMaxBw;
long remotesPolicerVidModeMaxBurst;
long old_remotesPolicerVidModeMaxBurst;
long policerGetVidReturnValue;
long old_policerGetVidReturnValue;

struct remotesPolicerVidModeTable_entry *next;
};

struct remotesPolicerVidModeTable_entry
*remotesPolicerVidModeTable_head = NULL;

/*
* create a new row in the (unsorted) table
*/
struct remotesPolicerVidModeTable_entry *
remotesPolicerVidModeTable_createEntry(
long
remotesPolicerVidModeIndex,
long
remotesPolicerVidModeDirection,
long
remotesPolicerVidModeVid,
long
remotremotesPolicerVidModeEnalePolicer,
long
remotesPolicerVidModeMaxBw,
long
remotesPolicerVidModeMaxBurst,
long
policerGetVidReturnValue)

{
struct remotesPolicerVidModeTable_entry *entry;

entry = SNMP_MALLOC_TYPEDEF(struct
remotesPolicerVidModeTable_entry);
if (!entry)
return NULL;

entry->remotesPolicerVidModeIndex =
remotesPolicerVidModeIndex;
entry->remotesPolicerVidModeDirection =
remotesPolicerVidModeDirection;
entry->remotesPolicerVidModeVid =
remotesPolicerVidModeVid;
entry->remotremotesPolicerVidModeEnalePolicer =
remotremotesPolicerVidModeEnalePolicer;
entry->remotesPolicerVidModeMaxBw =
remotesPolicerVidModeMaxBw;
entry->remotesPolicerVidModeMaxBurst =
remotesPolicerVidModeMaxBurst;
entry->policerGetVidReturnValue =
policerGetVidReturnValue;

entry->next = remotesPolicerVidModeTable_head;
remotesPolicerVidModeTable_head = entry;
return entry;
}

/*
* remove a row from the table
*/
void
remotesPolicerVidModeTable_removeEntry(struct

remotesPolicerVidModeTable_entry
*entry)
{
struct remotesPolicerVidModeTable_entry *ptr, *prev;

if (!entry)
return; /* Nothing to remove */

for (ptr = remotesPolicerVidModeTable_head, prev = NULL;
ptr != NULL; prev = ptr, ptr = ptr->next) {
if (ptr == entry)
break;
}
if (!ptr)
return; /* Can't find it */

if (prev == NULL)
remotesPolicerVidModeTable_head = ptr->next;
else
prev->next = ptr->next;

SNMP_FREE(entry); /* XXX - release any other internal
resources */
}

/*******************************************************************/
/*To create the table according to the file
parameters. */
/*If the file not exist, to create the entry with default
parameters. */
/*******************************************************************/
struct remotesPolicerVidModeTable_entry *
JZ_create_remotesPolicerVidModeTable(int i)
{
long params[48];
int result = -1;
//read the file according to i
result = read_file_paramters(OLT_I, ONU_I, "5129",
params);
if(result != -1)
return remotesPolicerVidModeTable_createEntry((long)i, params
[0], params[1],
params[2], params[3], params
[4], 1);

else
return remotesPolicerVidModeTable_createEntry((long)i, 0, 0,
0, 0, 0, 1);
}

void JZ_SNMP_init_remotesPolicerVidModeTable(void)
{
int i = 0;
for(i = 0; i < MAX_OLT_NUM * MAX_ONU_NUM_PER_OLT; ++i)
{
if(onu_mac_table[i].init_enable == INIT_END)
{
JZ_create_remotesPolicerVidModeTable(i);
}
}
}

void JZ_update_remotesPolicerVidModeTable(
struct
remotesPolicerVidModeTable_entry *entry)
{
int i = entry->remotesPolicerVidModeIndex;
int result;
PON_pon_network_traffic_direction_t direction;
unsigned short id;
PON_policer_parameters_t params;

result = REMOTE_PASONU_policer_get_vid(OLT_I, ONU_I,

direction,

id,

&params);
entry->remotremotesPolicerVidModeEnalePolicer =
params.enable_policer;
entry->remotesPolicerVidModeMaxBurst = params.max_burst;
entry->remotesPolicerVidModeMaxBw = params.max_bw;
entry->policerGetVidReturnValue = result;
}

/*If the setting is error, must to recovery the data as before.*/
void JZ_recovery_remotesPolicerVidModeTable(
struct
remotesPolicerVidModeTable_entry *entry)
{
entry->remotesPolicerVidModeDirection =
entry->old_remotesPolicerVidModeDirection;
entry->remotesPolicerVidModeVid =
entry->old_remotesPolicerVidModeVid;
entry->remotremotesPolicerVidModeEnalePolicer =
entry->old_remotremotesPolicerVidModeEnalePolicer;
entry->remotesPolicerVidModeMaxBurst =
entry->old_remotesPolicerVidModeMaxBurst;
entry->remotesPolicerVidModeMaxBw=
entry->old_remotesPolicerVidModeMaxBw;
}


void JZ_set_remotesPolicerVidModeTable(
struct
remotesPolicerVidModeTable_entry *entry)
{
int i = entry->remotesPolicerVidModeIndex;
int result;
PON_pon_network_traffic_direction_t direction =
(PON_pon_network_traffic_direction_t)entry-
>remotesPolicerVidModeDirection;
unsigned int id =
(unsigned int)entry->remotesPolicerVidModeVid;
PON_policer_parameters_t params = {
(bool)entry-
>remotremotesPolicerVidModeEnalePolicer,
(unsigned long)entry-
>remotesPolicerVidModeMaxBw,
(unsigned long)entry-
>remotesPolicerVidModeMaxBurst,
};
if(EXIT_OK != (result = REMOTE_PASONU_policer_set_vid(OLT_I,
ONU_I,

direction, id, &params)))
JZ_recovery_remotesPolicerVidModeTable(entry);

entry->policerGetVidReturnValue = result;
}

void JZ_SNMP_renew_remotesPolicerVidModeTable(void)
{
struct remotesPolicerVidModeTable_entry *current = NULL;
struct remotesPolicerVidModeTable_entry *nextItem = NULL;
short int i, sign = 0;

/* If the onu up, but not in the onu_mac_table, add it */
for(i = 0; i < MAX_OLT_NUM * MAX_ONU_NUM_PER_OLT; ++i)
{
sign = 0;
current = remotesPolicerVidModeTable_head;
if(onu_mac_table[i].init_enable == INIT_END)
{
while(current !=NULL)
{
if(i == current->remotesPolicerVidModeIndex)
{
sign = 1;
JZ_update_remotesPolicerVidModeTable(current);
break;
}
current= current->next;
}
if(!sign)
{
JZ_create_remotesPolicerVidModeTable(i);
}
}
else
{
while(current != NULL)
{
if(i == current->remotesPolicerVidModeIndex)
{
nextItem = current->next;
remotesPolicerVidModeTable_removeEntry
(current);
current = nextItem;
break;
}
current= current->next;
}
}
}
}
/*
* Example iterator hook routines - using 'get_next' to do most of the
work
*/
netsnmp_variable_list *
remotesPolicerVidModeTable_get_first_data_point(void
**my_loop_context,
void
**my_data_context,
netsnmp_variable_list
*
put_index_data,
netsnmp_iterator_info
*mydata)
{
*my_loop_context = remotesPolicerVidModeTable_head;
return remotesPolicerVidModeTable_get_next_data_point
(my_loop_context,

my_data_context,

put_index_data,
mydata);
}

netsnmp_variable_list *
remotesPolicerVidModeTable_get_next_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list *
put_index_data,
netsnmp_iterator_info
*mydata)
{
struct remotesPolicerVidModeTable_entry *entry =
(struct remotesPolicerVidModeTable_entry *) *my_loop_context;
netsnmp_variable_list *idx = put_index_data;

if (entry) {
snmp_set_var_typed_integer(idx, ASN_INTEGER,
entry->remotesPolicerVidModeIndex);
idx = idx->next_variable;
*my_data_context = (void *) entry;
*my_loop_context = (void *) entry->next;
return put_index_data;
} else {
return NULL;
}
}


/** handles requests for the remotesPolicerVidModeTable table */
int
remotesPolicerVidModeTable_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration
*reginfo,
netsnmp_agent_request_info
*reqinfo,
netsnmp_request_info *requests)
{
int ret;
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
struct remotesPolicerVidModeTable_entry *table_entry;

switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:
for (request = requests; request; request = request->next) {
table_entry = (struct remotesPolicerVidModeTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);

JZ_SNMP_renew_remotesPolicerVidModeTable();

switch (table_info->colnum) {
case COLUMN_REMOTESPOLICERVIDMODEINDEX:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->

remotesPolicerVidModeIndex);
break;
case COLUMN_REMOTESPOLICERVIDMODEDIRECTION:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->

remotesPolicerVidModeDirection);
break;
case COLUMN_REMOTESPOLICERVIDMODEVID:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->
remotesPolicerVidModeVid);
break;
case COLUMN_REMOTREMOTESPOLICERVIDMODEENALEPOLICER:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->

remotremotesPolicerVidModeEnalePolicer);
break;
case COLUMN_REMOTESPOLICERVIDMODEMAXBW:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->

remotesPolicerVidModeMaxBw);
break;
case COLUMN_REMOTESPOLICERVIDMODEMAXBURST:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->

remotesPolicerVidModeMaxBurst);
break;
case COLUMN_POLICERGETVIDRETURNVALUE:
if (!table_entry) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer(request->requestvb,
ASN_INTEGER,
table_entry->
policerGetVidReturnValue);
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 remotesPolicerVidModeTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);

switch (table_info->colnum) {
case COLUMN_REMOTESPOLICERVIDMODEDIRECTION:
/*
* 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_REMOTESPOLICERVIDMODEVID:
/*
* 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_REMOTREMOTESPOLICERVIDMODEENALEPOLICER:
/*
* 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_REMOTESPOLICERVIDMODEMAXBW:
/*
* 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_REMOTESPOLICERVIDMODEMAXBURST:
/*
* 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_POLICERGETVIDRETURNVALUE:
/*
* 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;
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;

case MODE_SET_ACTION:
for (request = requests; request; request = request->next) {
table_entry = (struct remotesPolicerVidModeTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);

switch (table_info->colnum) {
case COLUMN_REMOTESPOLICERVIDMODEDIRECTION:
table_entry->old_remotesPolicerVidModeDirection =
table_entry->remotesPolicerVidModeDirection;
table_entry->remotesPolicerVidModeDirection =
*request->requestvb->val.integer;
break;
case COLUMN_REMOTESPOLICERVIDMODEVID:
table_entry->old_remotesPolicerVidModeVid =
table_entry->remotesPolicerVidModeVid;
table_entry->remotesPolicerVidModeVid =
*request->requestvb->val.integer;
break;
case COLUMN_REMOTREMOTESPOLICERVIDMODEENALEPOLICER:
table_entry-
>old_remotremotesPolicerVidModeEnalePolicer =
table_entry-
>remotremotesPolicerVidModeEnalePolicer;
table_entry->remotremotesPolicerVidModeEnalePolicer =
*request->requestvb->val.integer;
break;
case COLUMN_REMOTESPOLICERVIDMODEMAXBW:
table_entry->old_remotesPolicerVidModeMaxBw =
table_entry->remotesPolicerVidModeMaxBw;
table_entry->remotesPolicerVidModeMaxBw =
*request->requestvb->val.integer;
break;
case COLUMN_REMOTESPOLICERVIDMODEMAXBURST:
table_entry->old_remotesPolicerVidModeMaxBurst =
table_entry->remotesPolicerVidModeMaxBurst;
table_entry->remotesPolicerVidModeMaxBurst =
*request->requestvb->val.integer;
break;
case COLUMN_POLICERGETVIDRETURNVALUE:
table_entry->old_policerGetVidReturnValue =
table_entry->policerGetVidReturnValue;
table_entry->policerGetVidReturnValue =
*request->requestvb->val.integer;
JZ_set_remotesPolicerVidModeTable(table_entry);
break;
}
}
break;

case MODE_SET_UNDO:
for (request = requests; request; request = request->next) {
table_entry = (struct remotesPolicerVidModeTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);

switch (table_info->colnum) {
case COLUMN_REMOTESPOLICERVIDMODEDIRECTION:
table_entry->remotesPolicerVidModeDirection =
table_entry->old_remotesPolicerVidModeDirection;
table_entry->old_remotesPolicerVidModeDirection = 0;
break;
case COLUMN_REMOTESPOLICERVIDMODEVID:
table_entry->remotesPolicerVidModeVid =
table_entry->old_remotesPolicerVidModeVid;
table_entry->old_remotesPolicerVidModeVid = 0;
break;
case COLUMN_REMOTREMOTESPOLICERVIDMODEENALEPOLICER:
table_entry->remotremotesPolicerVidModeEnalePolicer =
table_entry->
old_remotremotesPolicerVidModeEnalePolicer;
table_entry-
>old_remotremotesPolicerVidModeEnalePolicer =
0;
break;
case COLUMN_REMOTESPOLICERVIDMODEMAXBW:
table_entry->remotesPolicerVidModeMaxBw =
table_entry->old_remotesPolicerVidModeMaxBw;
table_entry->old_remotesPolicerVidModeMaxBw = 0;
break;
case COLUMN_REMOTESPOLICERVIDMODEMAXBURST:
table_entry->remotesPolicerVidModeMaxBurst =
table_entry->old_remotesPolicerVidModeMaxBurst;
table_entry->old_remotesPolicerVidModeMaxBurst = 0;
break;
case COLUMN_POLICERGETVIDRETURNVALUE:
table_entry->policerGetVidReturnValue =
table_entry->old_policerGetVidReturnValue;
table_entry->old_policerGetVidReturnValue = 0;
break;
}
}
break;

case MODE_SET_COMMIT:
break;
}
return SNMP_ERR_NOERROR;
}

sky

unread,
May 22, 2009, 5:29:29 AM5/22/09
to EMS网管开发
没有看见这个函数啊。
> ...
>
> 阅读更多 >>

lee213

unread,
May 22, 2009, 6:08:21 AM5/22/09
to EMS网管开发
remotesPolicerVidModeTable_get_first_data_point
这个就是,在程序的后半段。谢谢了。
> ...
>
> read more >>

sky

unread,
May 25, 2009, 9:51:53 PM5/25/09
to EMS网管开发
回复如果这个函数是NETSNMP自己生成的,那么就只能从你的MIB结构设计和具体实现上去优化了。
> ...
>
> 阅读更多 >>- 隐藏被引用文字 -
>
> - 显示引用的文字 -

lee213

unread,
May 26, 2009, 1:14:35 AM5/26/09
to EMS网管开发
谢谢,我再试试!
> ...
>
> read more >>
Reply all
Reply to author
Forward
0 new messages