SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-61
SNMPGET
if (argc < 2)
{
fprintf(stdout, usage, whoami);
exit(0);
}
hostname = *argv++; argc--;
for (i = 0; argc > 0; i++)
{
if (i == MAXOIDS)
{
fprintf(stdout, "Exceeded %d object identifiers\n", MAXOIDS);
exit(0);
}
oidstr[i] = *argv++;
argc--;
}
oidcnt = i;
opt2 = SNMP_Init_(&host_int, sizeof(host_int), hostname); <--3
switch (opt2)
{
case 0: case 1:
break;
default:
exit(0);
} /* switch */
/* Now I can override any default. This must be done before the */
/* call to SNMP_Open_. */
if (snmpagt != 0) <--4
{
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;
}
Example 2-6. Contents of snmpgetc (page 4 of 6)