SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-62
SNMPGET
  err2 = SNMP_Open_(&host_int, debug_level); <--5
 if (err2 != 0)
 {
  fprintf(stdout, "SNMP_OPEN_ returned error %i.\n", err2);
  exit(0); 
 }
 send_pkt = SNMP_Create_Request(GET_REQUEST_PDU, VERSION_RFC1067, <--6
     strlen(community), community, (INT_32_T)requestid, oidcnt);
 for (i = 0; i < oidcnt; i++)
 {
  if (oidstr_to_oid(oidstr[i], &base_oid) < 0)
  {
   fprintf(stdout, "Bad object identifier: %s\n", oidstr[i]);
   exit(0); 
  }
  if (SNMP_Bind_Null(send_pkt, i,
     base_oid.num_components, base_oid.component_list) < 0)
  {
   fprintf(stdout, "Error binding value\n");
   exit(0); 
  }
 }
 /* Obtain buffer space for the packet */ <--7
 need = 2000;
 if ((buffp = (char *)SNMP_memory_alloc(need)) == 0)
  return (-1);
 EBufferSetup(BFL_IS_DYNAMIC, &ebuff, buffp, need);
 /* Send request and receive response */
 for (j = 0; j <= retrycnt; j++)
 {
  if (j == 0)
  {
   firstid = requestid;
  } else
  {
   fprintf(stdout, "\n---RESENDING PACKET---\n");
Example 2-6. Contents of snmpgetc (page 5 of 6)










