This is a discussion on OID comparision in callback handler within the SNMP Coders forums, part of the Networking and Network Related category; This is a multi-part message in MIME format. ------=_NextPart_000_03B3_01C530A8.8C4A0F70 Content-Type: text/plain; charset="big5" Content-...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
This is a multi-part message in MIME format.
------=_NextPart_000_03B3_01C530A8.8C4A0F70 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable hi, I have a MIB table, i use mib2c to create the c file. I want to = customise the processing of the MIB table. Therefore, i have to compare = the OID of eacg incoming request and take action respectively. How should i compare the OID in callback handler??=20 i can't figure out.=20 if (requests->requestvb->name =3D=3D .......) /*??? what should be = here*/ int dot11PhyTable_handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { u_long * curChannel_cache =3D NULL; int channel; printf("[cb handler] channel %d\n",channel); /* * perform anything here that you need to do. The requests have * already been processed by the master table_dataset handler, but * this gives you chance to act on the request in some other way * if need be.=20 */ printf("Oid is %s\n", requests->requestvb->name); printf("Oid length is %d\n", (requests->requestvb->name_length)); switch (reqinfo->mode) { /* * registering as an instance means we don't need to deal with * getnext processing, so we don't handle it here at all. *=20 * However, since the instance handler already reset the mode * back to GETNEXT from the faked GET mode, we need to do the * same thing in both cases. This should be fixed in future * versions of net-snmp hopefully.=20 */ case MODE_GET: case MODE_GETNEXT: /* * return the curren value */ snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &channel, sizeof(channel)); break; case MODE_SET_ACTION: /* * update current value=20 */ channel =3D *(requests->requestvb->val.integer); printf("[cb handler] updated channel is %d\n", channel); break; default: break; } return SNMP_ERR_NOERROR; } ------=_NextPart_000_03B3_01C530A8.8C4A0F70 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5"> <META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>hi,</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I have a MIB table, i use mib2c to = create the=20 c file. I want to customise the processing of the MIB table. Therefore, = i have=20 to compare the OID of eacg incoming request and take action=20 respectively.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>How should i compare the OID in = callback=20 handler?? </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>i can't figure out. </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>if (requests->requestvb->name = =3D=3D=20 ........) /*??? what should be here*/</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial = size=3D2>int<BR>dot11PhyTable_handler(netsnmp_mib_ handler=20 *handler,<BR> & nbsp; = &n bsp; &= nbsp; &nb sp;=20 netsnmp_handler_registration=20 *reginfo,<BR> & nbsp; = &n bsp; &= nbsp; &nb sp;=20 netsnmp_agent_request_info=20 *reqinfo,<BR> & nbsp; = &n bsp; &= nbsp; &nb sp;=20 netsnmp_request_info *requests)<BR>{<BR> u_long *=20 curChannel_cache =3D NULL;</FONT></DIV> <DIV><FONT face=3DArial size=3D2> int = channel;</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>printf("[cb handler] channel=20 %d\n",channel);<BR> /*<BR> * = perform=20 anything here that you need to do. The requests=20 have<BR> * already been processed by the master=20 table_dataset handler, but<BR> * this gives you = chance=20 to act on the request in some other way<BR> * if = need=20 be. <BR> */</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>printf("Oid is %s\n",=20 requests->requestvb->name);<BR>printf("Oid length is %d\n",=20 (requests->requestvb->name_length));</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> switch = (reqinfo->mode)=20 {<BR> =2 0 /*<BR> &nb sp; * registering as = an=20 instance means we don't need to deal=20 with<BR> * getnext = processing,=20 so we don't handle it here at=20 all.<BR> *=20 <BR> &nbs p; * However, since = the=20 instance handler already reset the=20 mode<BR> * back to = GETNEXT from=20 the faked GET mode, we need to do=20 the<BR> & nbsp; * same thing in = both=20 cases. This should be fixed in=20 future<BR> &nbs p; * versions of = net-snmp hopefully. <BR> &nbs p; = */<BR> case MODE_GET:<BR> case=20 MODE_GETNEXT:<BR> &nb sp; =20 /*<BR> &nb sp; * return the = curren=20 value<BR>   ; =20 */<BR> =2 0 snmp_set_var_typed_value(requests->requestvb,<BR> &nb= sp;   ; &nbs= p;  = ; =20 ASN_INTEGER,<BR> &nbs p; &nb= sp;   ; &nbs= p; =20 (u_char *)=20 &channel,<BR> &nb sp; &n= bsp; &nbs p; &nb= sp;   ; =20 sizeof(channel));<BR>   ; =20 break;</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> case=20 MODE_SET_ACTION:<BR> =20 /*<BR> &nb sp; * update current = value=20 <BR> &nbs p;=20 */<BR> channel =3D=20 *(requests->requestvb->val.integer);<BR>printf("[cb handler] = updated=20 channel is %d\n", = channel);<BR> & nbsp;=20 break;</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2> = default:</FONT></DIV> <DIV><FONT face=3DArial = size=3D2>   ;=20 break;</FONT></DIV> <DIV><FONT face=3DArial size=3D2> = }<BR> return=20 SNMP_ERR_NOERROR;<BR>}</FONT></DIV></BODY></HTML> ------=_NextPart_000_03B3_01C530A8.8C4A0F70-- ------------------------------------------------------- This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005 Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows Embedded(r) & Windows Mobile(tm) platforms, applications & content. Register by 3/29 & save $300 http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/...et-snmp-coders |
![]() |
| Thread Tools | |
| Display Modes | |
|
|