title: How to list SMIv1 MIBS with net-snmp MIB API in C/C++?
body: <p>I want to display a list of various MIBS with <em>net-snmp</em> and show other informations related to the SNMP tree structure.</p>
  
  <p>Now it turns out that my customer's SMIv1 MIBS does not show up in the listing, but are correctly loaded by <em>net-snmp</em>.</p>
  
  <p>Sample <em>net-snmp</em> code goes through the MIB structure in memory and assumes that we have the SMIv2 bijection between a MIB and a MODULE-IDENTITY note in the tree. So when we find a MODULE-IDENTITY node, we find a MIB.</p>
  
  <p><strong>Does anybody knows what is the correct method to list SMIv1 MIBS with <em>net-snmp</em> ?</strong> (or any workaround ?)</p>
  
  <pre class="lang-c prettyprint-override"><code>  // Read mibs and obtain memory structures
    struct tree * head = read_all_mibs();
    // Walk down the SNMP tree
    for ( struct tree * tp = head; tp; tp = tp-&gt;next_peer )
    {
       // Module-indentity
       if ( tp-&gt;type == TYPE_MODID )
       {
          // XXX We found a SMIv2 MIB, but SMIv1 MIBs have no MODULE-IDENTITY node
       }
    }
  </code></pre>
  
  <p>NB: I found a converter <em>smidump</em> (a command line tool, or as a web service at <a href="http://www.ibr.cs.tu-bs.de/projects/libsmi/tools/" rel="nofollow">http://www.ibr.cs.tu-bs.de/projects/libsmi/tools/</a>) but it does not adds a MODULE-IDENTITY node to the MIB.</p>
  
  <p><strong>Edit</strong>: Note that any tool that would convert an old SNMP MIB to a more recent one (SMIv2 style), could solve the problem. Any help in that particular direction ?</p>
  
  <p>One suggestion could be, in the absence of MODULE-IDENTIFIER, to find the <em>root</em> OBJECT-IDENTIFIER of the MIB (sometimes the MIB will add node at many different and unrelated places so this would not work). With a <em>root</em> node I could show most of the tree related to that MIB.</p>