OpenVINOTM,给你看得见的未来!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » A question of SNMP agent functions.....

共1条 1/1 1 跳转至

A question of SNMP agent functions.....

菜鸟
2005-10-26 23:15:00    评分

I have already built my private MIB (text.mib) and i can use MIB browser to see my private MIB tree. But here comes another problem. I have study the example from document. It just show the scalar and table variables, such as int,string,OID and so on.

Now i want to built a leaf node that is a scalar node and the syntax is IpAddress. After i built the test_stub.c and i do some modifications in this code. But i still can not get the IP address from MIB browser. It always gets the value of 0.0.0.0 .WHY?

Some one can tell me the correctly way to built the SNMP agent code. Thanks a lot.

/* this code is made by wind manage , and i do some modifications.*/

LOCAL void test_get_value
(
OIDC_T lastmatch,
SNMP_PKT_T * pktp,
VB_T * vbp,
)
{
switch (lastmatch)
{
case LEAF_testIpAddress:
getproc_got_ip_address(pktp, vbp, *(UINT_32_T *)(VB_TO_COOKIE(vbp)));
return;
default:
getproc_error (pktp, vbp, GEN_ERR);
return;
}
}


void
test_get(OIDC_T lastmatch,
int tcount,
OIDC_T *tlist,
SNMP_PKT_T *pktp,
VB_T *vbp)
{
int error;

/* find all the varbinds that share the same getproc and instance */
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);

/* check that the instance is exactly .0 */
if (!((tcount == 1) && (*tlist == 0)))
for ( ; vbp; vbp = vbp->vb_link)
getproc_nosuchins(pktp, vbp);
/* grab the actual data for this variable. this lookup routine will
* probably have to be changed for your system. for scalar variables
* there might not even be any lookup routine. */
else {
/* retrieve all the values from the same data structure */
for ( ; vbp; vbp = vbp->vb_link) {
if ((error = test_get_value(vbp->vb_ml.ml_last_match, pktp, vbp)) != NO_ERROR)
getproc_error(pktp, vbp, error);
}
}
}

void
test_nextproc(OIDC_T lastmatch,
int tcount,
OIDC_T *tlist,
SNMP_PKT_T *pktp,
VB_T *vbp)
{

OIDC_T instance = 0;

/* the only time there's a next for a scalar is if we're given
* no instance at all. */
if (tcount != 0)
nextproc_no_next(pktp, vbp);
/* grab the data for these variables. you'll probably have to change
* this lookup routine for your system. for scalar variables there
* might not even be any lookup routine. */

else {
/* find all the varbinds in this group and retrieve their
* values from the same data structure */
for (group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
vbp; vbp = vbp->vb_link) {
nextproc_next_instance(pktp, vbp, 1, &instance);
test_get_value(vbp->vb_ml.ml_last_match, pktp, vbp);
}
}
}




关键词: question     agent     functions.    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]