OID comparision in callback handler

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-...


Go Back   Usenet Forums > Networking and Network Related > SNMP Coders

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-24-2005
Yeo Siow Vic
 
Posts: n/a
Default OID comparision in callback handler

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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I&nbsp;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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>How&nbsp;should i compare the OID in =
callback=20
handler?? </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i can't figure out. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>if (requests-&gt;requestvb-&gt;name =
=3D=3D=20
........)&nbsp; /*??? what should be here*/</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>int<BR>dot11PhyTable_handler(netsnmp_mib_ handler=20
*handler,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;=20
netsnmp_handler_registration=20
*reginfo,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;=20
netsnmp_agent_request_info=20
*reqinfo,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;=20
netsnmp_request_info *requests)<BR>{<BR>&nbsp;&nbsp;&nbsp; u_long *=20
curChannel_cache =3D NULL;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; int =
channel;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>printf("[cb handler] channel=20
%d\n",channel);<BR>&nbsp;&nbsp;&nbsp; /*<BR>&nbsp;&nbsp;&nbsp;&nbsp; * =
perform=20
anything here that you need to do.&nbsp; The requests=20
have<BR>&nbsp;&nbsp;&nbsp;&nbsp; * already been processed by the master=20
table_dataset handler, but<BR>&nbsp;&nbsp;&nbsp;&nbsp; * this gives you =
chance=20
to act on the request in some other way<BR>&nbsp;&nbsp;&nbsp;&nbsp; * if =
need=20
be. <BR>&nbsp;&nbsp;&nbsp;&nbsp; */</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>printf("Oid is %s\n",=20
requests-&gt;requestvb-&gt;name);<BR>printf("Oid length is %d\n",=20
(requests-&gt;requestvb-&gt;name_length));</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; switch =
(reqinfo-&gt;mode)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=2 0
/*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp; * registering as =
an=20
instance means we don't need to deal=20
with<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; * getnext =
processing,=20
so we don't handle it here at=20
all.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; *=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; * However, since =
the=20
instance handler already reset the=20
mode<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; * back to =
GETNEXT from=20
the faked GET mode, we need to do=20
the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp; * same thing in =
both=20
cases.&nbsp; This should be fixed in=20
future<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp; * versions of =

net-snmp hopefully. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; =

*/<BR>&nbsp;&nbsp;&nbsp; case MODE_GET:<BR>&nbsp;&nbsp;&nbsp; case=20
MODE_GETNEXT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;=20
/*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp; * return the =
curren=20
value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;=20
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=2 0
snmp_set_var_typed_value(requests-&gt;requestvb,<BR>&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
ASN_INTEGER,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
(u_char *)=20
&amp;channel,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;=20
sizeof(channel));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;=20
break;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; case=20
MODE_SET_ACTION:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
/*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp; * update current =
value=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;=20
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; channel =3D=20
*(requests-&gt;requestvb-&gt;val.integer);<BR>printf("[cb handler] =
updated=20
channel is %d\n", =
channel);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;=20
break;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
default:</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;=20
break;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp; 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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:05 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0