SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-77
SNMPSET
if (peertype == -1)
{
fprintf(stdout, "Invalid type\n");
exit(0);
}
if ((p = oid_to_namerec(&base_oid)) != 0) <-- 10
mibtype = p->type;
else
mibtype = 0;
if (peertype == 0 && mibtype == 0)
{
fprintf(stdout, "Could not find type in MIB\n");
exit(0);
}
if (peertype && mibtype && mibtype != peertype)
fprintf(stdout,"WARNING: type supplied disagrees with MIB\n");
peertype = peertype ? peertype : mibtype;
switch (peertype) <-- 11
{
case VT_NUMBER:
rcode = SNMP_Bind_Integer(send_pkt, i, <-- 12
base_oid.num_components,
base_oid.component_list,
strtol(valstr[i], (char **)NULL, 0));
break;
case VT_TIMETICKS:
case VT_GAUGE:
case VT_COUNTER:
rcode = SNMP_Bind_Unsigned_Integer(send_pkt, i, <-- 13
base_oid.num_components,
base_oid.component_list, (OCTET_T) peertype,
strtol(valstr[i], (char **)NULL, 0));
break;
case VT_IPADDRESS: <-- 14
if (isdigit(*valstr[i]))
{
/* error checking of IP address value
* and error checking on inet_addr()
*/
Example 2-9. Contents of snmpsetc (page 6 of 9)