SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-103
SNMPTRAP
if (isdigit(*genstr)) <--9
{
generic = strtol(genstr, (char **)NULL, 0);
if (generic < 0 || generic > 6)
{
fprintf(stderr, "Invalid generic trap: %s\n", genstr);
exit(0);
}
} else
{
if ((generic = str_to_trap(genstr)) < 0)
{
fprintf(stderr, "Invalid generic trap: %s\n", genstr);
exit(0);
}
}
send_pkt = SNMP_Create_Trap(VERSION_RFC1067, <--10
strlen(community), community,
base_oid.num_components, base_oid.component_list,
(OCTET_T *)&host_addr, generic, specific, timestamp, oidcnt);
for (i = 0; i < oidcnt; i++) <--11
{
if (oidstr_to_oid(oidstr[i], &base_oid) < 0)
{
fprintf(stderr, "Bad object identifier: %s\n", oidstr[i]);
exit(0);
}
asn1type = longform ? str_to_type(typestr[i]) : 0;
if (asn1type == -1) {
fprintf(stderr, "Invalid ASN.1 type\n");
exit(0);
}
if ((p = oid_to_namerec(&base_oid)) != 0)
mibtype = p->type;
else
mibtype = 0;
if (asn1type == 0 && mibtype == 0)
{
fprintf(stderr, "Could not find ASN.1 type in MIB\n");
exit(0);
}
Example 2-13. Contents of snmptrpc (page 7 of 10)