This is a discussion on C Code using SNMP_MSG_GET to 'walk' OIDs within the SNMP Users forums, part of the Networking and Network Related category; This is a multi-part message in MIME format. ------_=_NextPart_001_01C67F39.6CC1B88E Content-Type: text/plain; charset="us-ascii&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
This is a multi-part message in MIME format.
------_=_NextPart_001_01C67F39.6CC1B88E Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi I'm an snmp-net newbie. I have snmp-net working on a Linux Server, that works perfectly. I need to create some C code to walk some OIDs. =20 Specifically I want to recover the MAC addresses off Cisco 2900 Switches using OIDs:=20 ..1.3.6.1.2.1.17.4.3.1.1 (dot1dTpFdbAddress) and ..1.3.6.1.2.1.17.4.3.1.2 (dot1dTpFdbPort). =20 The Command line Tools are fine... Using snmpwalk I can traverse these tables and recover the values. I cannot do the same with snmpget - presumably because these 'learnt MACs' are dynamic and the snmpget works on exact OIDs, so fails because it lacks=20 the "instance" of the particular object being requested. =20 Anyway, to create my C code I examined snmpwalk.c, and pinched its=20 =20 while (running) {...=20 pdu =3D snmp_pdu_create(SNMP_MSG_GETNEXT); ... } =20 loop and this works, in the respect that it recovers a single oid e.g. =20 SNMPv2-SMI::mib-2.17.4.3.1.2.0.0.57.112.7.243 =3D INTEGER: 24 =20 and then stops, reporting: =20 "Error: OID not increasing: SNMPv2-SMI::mib-2.17.4.3.1.2.0.0.57.112.7.243". =20 Note. I pinched the Error checking from snmpwalk.c too! ;o) =20 My problem is I cannot get it to increment the OID value, so that I can 'walk' through the rest of the table, surely this must be simple, yet I cannot fathom out how! Many Thanks in anticipation. =20 PS I couldn't find an answer on your archives after much searching :o( Regards =20 Greg =20 G. C. McCawley Senior Analyst/Programmer Academic and External Client Support Group Information Services Staffordshire University =20 Internal Telephone: 3778 External Telephone: +44 (0)1785 353778 Email: g.c.mccawley@staffs.ac.uk=20 The information in this email is confidential and is intended solely for = the addressee. Access to this email by anyone else is unauthorised. =20 If you are not the intended recipient, any disclosure, copying, = distribution or any action taken or omitted to be taken in reliance on = it, except for the purpose of delivery to the addressee, is prohibited = and may be unlawful. Kindly notify the sender and delete the message = and any attachment from your computer. ------_=_NextPart_001_01C67F39.6CC1B88E Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <HTML > <HEAD> <META http-equiv=3D"Content-Type" content=3D"text/html; = charset=3Dus-ascii"> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3DUTF-16"> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3DUTF-16"> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3DUTF-16"> =09 <TITLE>Message</TITLE> <META content=3D"MSHTML 6.00.2800.1543" name=3DGENERATOR> </HEAD> <BODY > <DIV> =09 <DIV><FONT face=3DArial size=3D2>Hi I'm an snmp-net newbie<SPAN=20 class=3D661001513-24052006>.</SPAN></FONT></DIV> <DIV><FONT face=3DArial size=3D2><SPAN = class=3D661001513-24052006></SPAN>I have=20 snmp-net working on a Linux Server, that works perfectly.<BR>I need to = create=20 some C code to walk some OIDs.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Specifically I want to recover the MAC = addresses=20 off Cisco 2900 Switches using OIDs: <BR>.1.3.6.1.2.1.17.4.3.1.1=20 (dot1dTpFdbAddress)<BR>and<BR>.1.3.6.1.2.1.17.4.3. 1.2=20 (dot1dTpFdbPort).</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial size=3D2>The = Command line=20 Tools are fine...</FONT></SPAN></DIV> <DIV><FONT face=3DArial size=3D2>Using snmpwalk I can traverse these = tables and=20 recover the values.<BR>I cannot do the same with snmpget - presumably = because=20 these 'learnt MACs' are dynamic and <SPAN = class=3D661001513-24052006>the=20 snmpget works on exact OIDs, so fails because it lacks <BR> the=20 "instance" of the particular object being = requested.</SPAN></FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Anyway, to create my C code I examined = snmpwalk.c,=20 and pinched its </FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>while (running)=20 {... <BR> <SPAN=20 class=3D661001513-24052006>   ;&nbs= p; =20 </SPAN>pdu =3D snmp_pdu_create(SNMP_MSG_GETNEXT);<BR> <SPAN=20 class=3D661001513-24052006>   ;&nbs= p; </SPAN>...=20 }</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>loop and this works, in the respect = that it=20 recovers a single oid e.g.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial = size=3D2>SNMPv2-SMI::mib-2.17.4.3.1.2.0.0.57.112.7.243 =3D=20 INTEGER: 24</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2> and then stops, = reporting:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>"Error: OID not increasing:=20 SNMPv2-SMI::mib-2.17.4.3.1.2.0.0.57.112.7.243".</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Note. I pinched the Error checking from = snmpwalk.c=20 too!<BR> ;o)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>My problem is I cannot get it to = increment the OID=20 value, so that I can 'walk' through the rest of </FONT><FONT = face=3DArial><FONT=20 size=3D2>the table, surely this must be simple, yet I cannot fathom out=20 how!<BR><SPAN class=3D661001513-24052006>Many Thanks in=20 anticipation.</SPAN></FONT></FONT></DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial=20 size=3D2></FONT></SPAN> </DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial = size=3D2>PS <SPAN=20 class=3D661001513-24052006> <FONT face=3DArial><FONT size=3D2><SPAN = class=3D661001513-24052006>I couldn't find an answer on your archives = after much=20 searching :o(</SPAN></FONT></FONT></SPAN><BR></FONT></SPAN></DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial=20 size=3D2>Regards</FONT></SPAN></DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial=20 size=3D2></FONT></SPAN> </DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial=20 size=3D2>Greg</FONT></SPAN></DIV> <DIV><SPAN class=3D661001513-24052006><FONT face=3DArial=20 size=3D2></FONT></SPAN> </DIV> <DIV align=3Dleft><FONT face=3DArial size=3D2>G. C. = McCawley</FONT></DIV> <DIV align=3Dleft><FONT face=3DArial size=3D2><FONT face=3DArial = size=3D2>Senior=20 Analyst/Programmer</FONT></FONT></DIV><FONT face=3DArial size=3D2> <DIV align=3Dleft><FONT face=3DArial size=3D2></FONT></DIV> <DIV align=3Dleft><FONT face=3DArial size=3D2>Academic and External = Client Support=20 Group</FONT></DIV> <DIV align=3Dleft><FONT face=3DArial size=3D2>Information = Services</FONT></DIV> <DIV align=3Dleft> <DIV align=3Dleft><FONT face=3DArial size=3D2>Staffordshire = University</FONT></DIV> <DIV align=3Dleft><FONT face=3DArial size=3D2></FONT> </DIV> <DIV align=3Dleft> <DIV align=3Dleft></FONT><FONT face=3DArial size=3D2><FONT face=3DArial = size=3D2>Internal=20 Telephone: 3778</FONT></DIV></DIV></DIV> <DIV align=3Dleft> <DIV align=3Dleft><FONT face=3DArial size=3D2>External Telephone: = +44 (0)1785=20 353778</FONT></DIV> <DIV align=3Dleft></FONT><FONT face=3DArial size=3D2>Email: <A=20 href=3D"mailto:g.c.mccawley@staffs.ac.uk">g.c.mcca wley@staffs.ac.uk</A></= FONT></DIV></DIV> <DIV> </DIV> </DIV> <DIV STYLE=3D"FONT-SIZE: 7pt; COLOR: gray; FONT-FAMILY: verdana"> <BR> The information in this email is confidential and is intended solely for = the addressee. Access to this email by anyone else is unauthorised. = <BR><BR> If you are not the intended recipient, any disclosure, copying, = distribution or any action taken or omitted to be taken in reliance on = it, except for the purpose of delivery to the addressee, is prohibited = and may be unlawful. Kindly notify the sender and delete the message = and any attachment from your computer.=20 </DIV> </BODY> </HTML> ------_=_NextPart_001_01C67F39.6CC1B88E-- ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=...729&dat=121642 _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/...net-snmp-users |