title: snmpbulkwalk in c
body: <p>is it possible to create an snmpbulkwalk in C with netsnmp?</p>
  
  <p>A snmpget is quite easy - but I cannot find an example to send an snmpbulkwalk...</p>
  
  <p>Here is a little example for an snmpget:</p>
  
  <pre><code>    #include &lt;net-snmp/net-snmp-config.h&gt;
      #include &lt;net-snmp/net-snmp-includes.h&gt;
      #include &lt;string.h&gt;
  
      int snmp_get(struct snmp_session *sess_handle){
              struct snmp_pdu *pdu;
              struct snmp_pdu *response;
              struct variable_list *vars;
  
              oid id_oid[MAX_OID_LEN];
              oid serial_oid[MAX_OID_LEN];
              size_t id_len = MAX_OID_LEN;
              size_t serial_len = MAX_OID_LEN;
              int status;
  
              pdu = snmp_pdu_create(SNMP_MSG_GET);
              read_objid("SNMPv2-MIB::sysName.0", id_oid, &amp;id_len);
              snmp_add_null_var(pdu, id_oid, id_len);
              read_objid(".1.3.6.1.2.1.1.3.0", serial_oid, &amp;serial_len);
              snmp_add_null_var(pdu, serial_oid, serial_len);
  
              status = snmp_synch_response(sess_handle, pdu, &amp;response);
  
              for(vars = response-&gt;variables; vars; vars = vars-&gt;next_variable)
                      print_value(vars-&gt;name, vars-&gt;name_length, vars);
  
              snmp_free_pdu(response);
  
              return status;
  
  
      }
  
      struct snmp_session *setup_snmp_session(int version, char* community, char* host){
  
                      struct snmp_session session;
                      struct snmp_session *sess_handle;
  
                      init_snmp("poller");
                      snmp_sess_init( &amp;session );
                      session.version = version;
                      session.community = community;
                      session.community_len = strlen(session.community);
                      session.peername = host;
                      sess_handle = snmp_open(&amp;session);
                      return sess_handle;
  
      }
  
      int main(int argc, char ** argv)
      {
              if(argv[1] == NULL){
              printf("Please supply a hostname\n");
              exit(1);
              }
  struct snmp_session   *sess_handle=setup_snmp_session(SNMP_VERSION_2c,"asdf",argv[1]);
  snmp_get(sess_handle);
  snmp_close(sess_handle);
  
          return (0);
  }
  </code></pre>
  
  <p>I am looking for something equal - just doing an snmpbulkwalk!
  Thx for your help!</p>
  
  <p>br,
  roegi</p>