gtpc1m2mTransmission Control Protocol/Internet Protocol

SNMP Traps

The SNMP architecture defines a set of system traps, which are the unsolicited messages that are sent out when a significant event occurs on the TCP/IP network node on which the SNMP agent resides. You have the ability to generate your own enterprise-specific traps.

The TPF system sends traps to remote SNMP managers on well-known port 162. You can specify to which managers to send traps by coding them in the /etc/snmp.cfg SNMP configuration file. Traps can be suppressed by specifying a value of NONE on the TRAPIP keyword in the /etc/snmp.cfg SNMP configuration file. The TPF system can send out the following types of SNMP traps:

Authentication failure trap
Generated by the TPF system when an SNMP message is received and verification of the SNMP manager failed. By specifying the appropriate return code when the UCOM user exit is called to validate the SNMP manager, you can choose whether or not the TPF system should send out an authentication failure trap.

Coldstart trap
Generated by the TPF system when you first cycle-up after an IPL when the MIB database is initialized. At this time, notification is sent to the SNMP managers.

Enterprise-specific trap
You have the ability to send enterprise-specific traps by issuing the ITRPC macro or the tpf_itrpc C/C++ function. When you send an enterprise-specific trap by issuing the ITRPC macro or tpf_itrpc C/C++ function, a variable binding list can be supplied to send with the trap. You must correctly encode the variable binding list when issuing the C/C++ function. See TPF General Macros for more information about the ITRPC macro and see the TPF C/C++ Language Support User's Guide for more information about the tpf_itrpc C/C++ function.

Linkdown trap
Generated by the TPF system when an IP address changes from active to inactive state. The linkdown trap includes the interface index from the interface table that has become inactive. This trap is sent for the following conditions:

See Operator Procedures for TCP/IP Native Stack Support for more information about CDLC IP addresses and OSA-Express and VIPA support.

Linkup trap
Generated by the TPF system when an IP address changes its state from inactive to active. The linkup trap includes the interface index from the interface table that has become active. This trap is sent for the following conditions:

The following example sends the enterprise-specific trap defined in spectrap, and containing the variable binding list pointed to by encoded_list, to all the SNMP managers specified in the /etc/snmp.cfg SNMP configuration file.

/**********************************************************************/
/*                 Include files                                      */
/**********************************************************************/
#include <c$snmp.h>
#include <stdlib.h>
#include <string.h>
/**********************************************************************/
/*                      #DEFINES                                      */
/**********************************************************************/
#define  SPECTRAP       4
 
/*********************************************************************/
/*********************************************************************/
extern "C" void QZZ2()
{
 
 int           varlen = 0, spectrap = 0, rc;
 char          object_id[24] = "\x2b\x6\x1\x4\x1\x1";
 char          *temp;
 char          encoded_var[100];
 int           encoded_var_len = 0;
 char          encoded_bind[100];
 int           encoded_bind_len;
 char          encoded_list[100];
 int           encoded_list_len
 int           value=100;
 struct        snmp_struct  encode_struct;
 
 
temp = encoded_var;
 
/*  Encode the OBJECT ID for the Variable Binding */
 
encode_struct.snmp_input_value = object_id
encode_struct.snmp_input_length = strlen(object_id);
encode_struct.snmp_input_type = ISNMP_TYPE_OBJECTID;
encode_struct.snmp_output_value = encoded_var;
 
   if (tpf_snmp_BER_encode(&encode_struct) != 0)
      exit(0);
 
encoded_var_len += encode_struct.snmp_output_length;
temp += encode_struct.snmp_output_length;
 
/* Encode the value and copy the encoded value after the */
/* OBJECT ID.  Increment the size of the VAR-BIND        */
 
encode_struct.snmp_input_value = &value;
encode_struct.snmp_input_length = sizeof(int);
encode_struct.snmp_input_type = ISNMP_TYPE_INTEGER;
encode_struct.snmp_output_value = temp;
 
   if (tpf_snmp_BER_encode(&encode_struct) != 0)
      exit(0);
 
 
encoded_var_len = encode_struct.snmp_output_length;
 
 
/* Encode the variable bind as a SEQUENCE_OF            */
 
encode_struct.snmp_input_value = encoded_var;
encode_struct.snmp_input_length = encoded_var_len;
encode_struct.snmp_input_type = ISNMP_TYPE_SEQUENCE_OF;
encode_struct.snmp_output_value = encoded_bind;
 
   if (tpf_snmp_BER_encode(&encode_struct) != 0)
      exit(0);
 
 
encoded_bind_len = encode_struct.snmp_output_length;
 
 
/* Variable Binding complete.  Encode the entire        */
/* variable binding list as a sequence of               */
 
encode_struct.snmp_input_value = encoded_bind;
encode_struct.snmp_input_length = encoded_bind_len;
encode_struct.snmp_input_type = ISNMP_TYPE_SEQUENCE_OF;
encode_struct.snmp_output_value = encoded_list;
 
   if (tpf_snmp_BER_encode(&encode_struct) != 0)
      exit(0);
 
 
encoded_list_len = encode_struct.snmp_output_length;
 
/* Fill in the specific TRAP information and call       */
/* tpf_itrpc passing the variable binding list and      */
/* length                                               */
 
 spectrap = SPECTRAP;
 
 rc = tpf_itrpc(encoded_list, encoded_list_len, spectrap);
 
 exit(0);
}