Network Component
Version 6.6
MDK-Professional Middleware for IP Networking
|
SNMP Agent routines enable network management features. More...
Structures | |
struct | SNMP_MIB |
SNMP-MIB Entry info. More... | |
Functions | |
netStatus | snmp_trap (const uint8_t *ip_addr, uint8_t generic, uint8_t specific, const uint16_t *obj_list) |
Send a trap message to the Trap Manager. | |
netStatus | snmp_set_community (const char *community) |
Change SNMP community to a new community. | |
SNMP Agent routines enable network management features.
Simple Network Management Protocol (SNMP) is mainly used in network management systems to monitor network-attached devices for conditions that warrant administrative attention. It is the most popular network management protocol in the TCP/IP protocol suite.
The following source code is part of the SNMP_Agent_MIB.c template file. This code template enables the developer to define an application specific MIB data table for the SNMP agent:
struct SNMP_MIB |
SNMP-MIB Entry info.
Data Fields | |
uint8_t | Type |
Object Type. | |
uint8_t | OidLen |
Object ID length. | |
uint8_t | Oid [MIB_OID_SIZE] |
Object ID value. | |
uint8_t | ValSz |
Size of a variable. | |
void * | Val |
Pointer to a variable. | |
void(* | cb_func )(int mode) |
Write/Read event callback function. | |
void(* cb_func)(int mode) |
Write/Read event callback function.
uint8_t Oid[MIB_OID_SIZE] |
Object ID value.
uint8_t OidLen |
Object ID length.
uint8_t Type |
Object Type.
void* Val |
Pointer to a variable.
uint8_t ValSz |
Size of a variable.
netStatus snmp_set_community | ( | const char * | community | ) |
Change SNMP community to a new community.
[in] | community | new community, a null-terminated string. |
The function snmp_set_community changes the SNMP community to a new community identified by community.
The argument community is a pointer to a 0-terminated string. The maximum length of the community string is limited to 18 characters.
Code Example
netStatus snmp_trap | ( | const uint8_t * | ip_addr, |
uint8_t | generic, | ||
uint8_t | specific, | ||
const uint16_t * | obj_list | ||
) |
Send a trap message to the Trap Manager.
[in] | ip_addr | IP address of the Trap server or NULL to use Trap server IP address from system configuration. |
[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 snmp_trap sends a message to the Trap Manager.
The argument ip_addr points to the IP address 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 specifies the 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.
Code Example