4

I want to implement SNMP-agent for PowerPC board using net-snmp. Previously it was implemented using SMASH. SMASH has a parser which could read MIB and generate C code (blank function imlementation)

How do I get started?

PrashantB
  • 309
  • 2
  • 4
  • 13

3 Answers3

2

Try to look at mib2c tool from net-snmp. It will generate the snmp agent C code from the MIB. Then you have to only fulfill the return values to SNMP requests. Skeleton of responding to SNMP requests (get, set, get-next) are automatically done by generating.

srnka
  • 1,275
  • 2
  • 12
  • 16
  • After creating a MIB file I have put it in to the MIB folder and add the same into snmp.conf. After that generate the c code with mib2c tool. Now my questing is where to put that generated c file and header file. – Souvik Bhattacharya Jun 23 '13 at 21:54
2

Do you have a look to Writing a MIB module tutorial.

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
0

I took a different approach to this. In order to better integrate with my C++ ecosystem, and to obtain greater flexibility (particularly at scale), I:

  • Had a pre-build step parse the result of snmptranslate (that is, the MIB tree) into a bunch of C++ maps and other containers for use in code
  • Borrowed Net-SNMP's transport and PDU building functions
  • But serviced requests myself upon receipt, using my C++ maps and the data already available to my application

This made notification generation trivial (I just needed some variant types to generate varbinds, a bit of PDU construction and then left the rest to Net-SNMP's transport feature), although for requests I did then have to implement table walking myself (and GetNext/GetBulk/Set are not trivial unless you avoid all tables, or at least avoid composite-index tables).

The result is a fast, robust and scalable SNMP agent with expressive code that's easy to maintain and to extend.

You don't say you're using C++, but this does give an idea of how you can cherry-pick Net-SNMP functionality without necessarily buying into its entire ecosystem.

Do note that I have no idea how SNMPv3 would fit into this model; I cleverly left the company before it became my problem. :)

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055