title: How do I use netsnmp_query_walk() or netsnmp_query_get()?
body: <p>I've successfully used the following to read some simple SNMP values from a local snmpd:</p>
  
  <pre><code>snmp_open( &amp;session )
  snmp_pdu_create( SNMP_MSG_GET );
  snmp_add_null_var( pdu, oid, len ); // multiple lines like this
  snmp_sync_response( ss, pdu, &amp;response );
  for ( netsnmp_variable_list *vars = response-&gt;variables; vars; vars = vars-&gt;next_variable )
  {
      // look at vars-&gt;name, vars-&gt;name_length, and vars-&gt;val.integer
  }
  </code></pre>
  
  <p>While this works for a few simple integer scalars, I also have some tables I need to read.  I've tried both the OID of the table and the oid of the table entry in snmp_add_null_var(), but snmp_sync_response() returns with an error code indicating that OID cannot be found.</p>
  
  <p>So browsing the header files I came across these calls.  I suspect one of these is likely to be what I want to be using:</p>
  
  <ol>
  <li><code>netsnmp_query_walk()</code></li>
  <li><code>netsnmp_query_get()</code></li>
  </ol>
  
  <p>However, I cannot figure out how to use them.  This is what I've tried:</p>
  
  <pre><code>netsnmp_variable_list *vb = (netsnmp_variable_list*)SNMP_MALLOC_TYPEDEF( netsnmp_variable_list );
  if ( vb == NULL ) ...
  snmp_set_var_objid( vb, oid, len );
  int rc = netsnmp_query_walk( vb, ss );
  //int rc = netsnmp_query_get( vb, ss );
  </code></pre>
  
  <p>...but at this point, rc is always == -1 which I'm guessing means there was an error.  How do I use these, or, is there a better API I should be using?</p>