SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-104
SNMPTRAP
  if (asn1type && mibtype && mibtype != asn1type)
   fprintf(stderr,"WARNING: ASN.1 type supplied disagrees with MIB\n");
  asn1type = asn1type ? asn1type : mibtype;
  switch (asn1type) <--12
  {
   case VT_NUMBER:
   rcode = SNMP_Bind_Integer(send_pkt, i,
       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,
       base_oid.num_components,
       base_oid.component_list,
       (OCTET_T) asn1type,
       strtol(valstr[i], (char **)NULL, 0));
   break;
   case VT_IPADDRESS:
   if (isdigit(*valstr[i]))
   {
/*
 *   error checking of IP address value
 *  and error checking on inet_addr()
 */
    name = valstr[i];
    dots = 0;
    while ((ptr = strchr(name, '.')) != NULL)
    {
     dots++;  /* keep track of no. of dots */
     memset(id, NULL, 20);
     strncpy(id, name, ptr - name);
     byte = atoi(id);
     if ( byte < 0 || byte > 255)
     {
     fprintf(stderr, "Invalid IP address %s\n", valstr[i]);
     exit(0);
     }
Example 2-13. Contents of snmptrpc (page 8 of 10)










