SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-147
SNMPHOST Source Code
 err2 = SNMP_Init_ (&host_int, sizeof(host_int), hostname); <--54
 switch (err2)
 {
  case 0: case 1:
  break;
  default:
  exit(0);
 } /* end switch */
/*************************************************************************/
 /* Now I can override any default. This must be done before the */
 /* call to SNMP_Open_.           */
 if (snmpagt != 0)
 {
  strcpy(host_int.agent_name, snmpagt);
 }
 if (dest_port != SNMP_REQUEST_PORT)
 {
  host_int.dest.sin_port = htons(dest_port);
 }
 if (timeout != 5)
 {
  host_int.timeout = timeout * 100;
 }
 err2 = SNMP_Open_ (&host_int, debug_level); <--55
 if (err2 != 0)
 {
  fprintf(stdout, "SNMP_OPEN_ returned error %i.\n", err2);
  exit(0);
 }
 /* Create the Device table */
 ppTable = InitDevTable (devcnt); <--56
 /* Obtain buffer space for the Device packets */
 need = 2048; <--57
 if ((buffp = (char *)SNMP_memory_alloc(need)) == 0)
Example 2-18. Contents of snmphosc (page 22 of 23)










