gtpc1m2m | Transmission Control Protocol/Internet Protocol |
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:
See Operator Procedures for TCP/IP Native Stack Support for more information about CDLC IP addresses and OSA-Express and VIPA support.
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); }