Functions to communicate with the Trap Manager. More...
Functions | |
netStatus | netSNMP_Trap (const NET_ADDR *addr, uint8_t generic, uint8_t specific, const uint16_t *obj_list) |
Send a trap message to the Trap Manager. [thread-safe]. | |
netStatus | netSNMP_SetCommunity (const char *community) |
Change SNMP community to a new community. [thread-safe]. | |
netStatus | netSNMP_SetMIB_Table (const NET_SNMP_MIB_INFO *info, uint32_t size) |
Register MIB table to SNMP Agent. [thread-safe]. | |
Functions to communicate with the Trap Manager.
To notify the SNMP manager of significant events, so called traps are used. The Network Component's netSNMP_Trap function is used to send these unsolicited messages to the manager. The SNMP community string is a kind of password that is used to authenticate the SNMP agent (SNMP v1 and v2 only; SNMP v3 has dedicated username/password protection). To change the SNMP community string, use netSNMP_SetCommunity.
netStatus netSNMP_SetCommunity | ( | const char * | community | ) |
Change SNMP community to a new community. [thread-safe].
[in] | community | new community, a null-terminated string. |
The function netSNMP_SetCommunity changes the SNMP community to a new community identified by community.
The argument community is a pointer to a null-terminated string. The function copies the content of the community to the SNMP community. The maximum length of the community string is limited to 18 characters.
Possible netStatus return values:
Code Example
netStatus netSNMP_SetMIB_Table | ( | const NET_SNMP_MIB_INFO * | info, |
uint32_t | size | ||
) |
Register MIB table to SNMP Agent. [thread-safe].
[in] | info | pointer to MIB table. |
[in] | size | size of MIB table in bytes. |
The function netSNMP_SetMIB_Table registers SNMP-MIB table in SNMP Agent. Until a valid SNMP-MIB table is registered in SNMP Agent, the Agent is not active and does not respond to SNMP requests.
The argument info points to a buffer containing the SNMP-MIB entry info.
The argument size is a size of the SNMP-MIB table.
Possible netStatus return values:
Code Example
netStatus netSNMP_Trap | ( | const NET_ADDR * | addr, |
uint8_t | generic, | ||
uint8_t | specific, | ||
const uint16_t * | obj_list | ||
) |
Send a trap message to the Trap Manager. [thread-safe].
[in] | addr | structure containing IP address of the Trap server.
|
[in] | generic | generic trap type:
|
[in] | specific | specific trap type for generic enterpriseSpecific trap:
|
[in] | obj_list | object list included in trap message. |
The function netSNMP_Trap sends a message to the Trap Manager.
The argument addr points to the IP address and port of the Trap server. If the IP address of the Trap Manager is NULL, then the IP address of Trap Server configured in Net_Config_SNMP_Agent.h is used.
The argument generic specifies the generic trap type:
Type | Description |
---|---|
0 | coldStart trap |
1 | warmStart trap |
2 | linkDown trap |
3 | linkUp trap |
4 | authenticationFailure trap |
5 | egpNeighborLoss trap |
6 | enterpriseSpecific trap |
The argument specific denotes a specific trap type. It must be set to 0 for all generic traps from 0..5. It defines a specific trap type for generic enterpriseSpecific trap.
The argument obj_list points to the objects from the MIB table, which will be included in the trap message variable-bindings. This argument is a pointer to the object list array. This array is of variable size. The first element specifies the count of objects in the object list array, followed by the object MIB index values.
Array Index | Array Value |
---|---|
obj[0] | number of objects n |
obj[1] | MIB index of first object |
obj[2] | MIB index of second object |
.. | .. |
obj[n] | MIB index of last object |
If obj_list is NULL, or obj[0] = 0, then no object values will be bound to the trap message.
Possible netStatus return values:
Code Example