C Code using SNMP_MSG_GET to 'walk' OIDs

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


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2006
McCAWLEY Gregory C
 
Posts: n/a
Default C Code using SNMP_MSG_GET to 'walk' OIDs

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>&nbsp;</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>&nbsp;</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&nbsp;<SPAN =
class=3D661001513-24052006>the=20
snmpget&nbsp;works on exact OIDs, so fails because it lacks <BR> the=20
"instance"&nbsp;of the particular object being =
requested.</SPAN></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway, to create my C code I examined =
snmpwalk.c,=20
and pinched its </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>while (running)=20
{...&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN=20
class=3D661001513-24052006>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
</SPAN>pdu =3D snmp_pdu_create(SNMP_MSG_GETNEXT);<BR>&nbsp;&nbsp; <SPAN=20
class=3D661001513-24052006>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>...=20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;and then stops, =
reporting:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Note. I pinched the Error checking from =
snmpwalk.c=20
too!<BR>&nbsp;;o)</FONT></DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV><SPAN class=3D661001513-24052006><FONT face=3DArial =
size=3D2>PS&nbsp;<SPAN=20
class=3D661001513-24052006>&nbsp;<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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV align=3Dleft>
<DIV align=3Dleft></FONT><FONT face=3DArial size=3D2><FONT face=3DArial =
size=3D2>Internal=20
Telephone:&nbsp; 3778</FONT></DIV></DIV></DIV>
<DIV align=3Dleft>
<DIV align=3Dleft><FONT face=3DArial size=3D2>External Telephone:&nbsp; =
+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>&nbsp;</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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB 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 08:12 PM.


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