Simple network management protocol. More...
Data Structures | |
struct | _viewEntry |
struct | _communityEntry |
struct | _SNMPVAR |
struct | _SNMP_VARLIST |
struct | SNMP_PDU |
struct | SNMP_SESSION |
struct | _SUBTREE |
Defines | |
#define | SNMP_PORT 161 |
Standard UDP port for SNMP agents to receive requests messages. | |
#define | SNMP_TRAP_PORT 162 |
Standard UDP port for SNMP managers to receive notificaion messages. | |
#define | SNMP_MAX_LEN 500 |
Default maximum message size. | |
#define | SNMP_VERSION_1 0 |
SNMPv1. | |
#define | SNMP_VERSION_2C 1 |
SNMPv2c. | |
#define | SNMP_VERSION_3 3 |
SNMPv3. | |
#define | SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) |
#define | SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) |
#define | SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) |
#define | SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) |
#define | SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) |
#define | SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) |
#define | SNMP_MSG_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) |
#define | SNMP_MSG_TRAP2 (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) |
#define | SNMP_MSG_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) |
#define | SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) |
#define | SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) |
#define | SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) |
#define | SNMP_ERR_NOERROR 0 |
#define | SNMP_ERR_TOOBIG 1 |
#define | SNMP_ERR_NOSUCHNAME 2 |
#define | SNMP_ERR_BADVALUE 3 |
#define | SNMP_ERR_READONLY 4 |
#define | SNMP_ERR_GENERR 5 |
#define | SNMP_ERR_NOACCESS 6 |
#define | SNMP_ERR_WRONGTYPE 7 |
#define | SNMP_ERR_WRONGLENGTH 8 |
#define | SNMP_ERR_WRONGENCODING 9 |
#define | SNMP_ERR_WRONGVALUE 10 |
#define | SNMP_ERR_NOCREATION 11 |
#define | SNMP_ERR_INCONSISTENTVALUE 12 |
#define | SNMP_ERR_RESOURCEUNAVAILABLE 13 |
#define | SNMP_ERR_COMMITFAILED 14 |
#define | SNMP_ERR_UNDOFAILED 15 |
#define | SNMP_ERR_AUTHORIZATIONERROR 16 |
#define | SNMP_ERR_NOTWRITABLE 17 |
#define | SNMP_ERR_INCONSISTENTNAME 18 |
#define | SNMP_TRAP_COLDSTART 0 |
#define | SNMP_TRAP_WARMSTART 1 |
#define | SNMP_TRAP_LINKDOWN 2 |
#define | SNMP_TRAP_LINKUP 3 |
#define | SNMP_TRAP_AUTHFAIL 4 |
#define | SNMP_TRAP_EGPNEIGHBORLOSS 5 |
#define | SNMP_TRAP_ENTERPRISESPECIFIC 6 |
#define | SNMP_OID_INTERNET 1, 3, 6, 1 |
#define | SNMP_OID_ENTERPRISES SNMP_OID_INTERNET, 4, 1 |
#define | SNMP_OID_MIB2 SNMP_OID_INTERNET, 2, 1 |
#define | SNMP_OID_SNMPV2 SNMP_OID_INTERNET, 6 |
#define | SNMP_OID_SNMPMODULES SNMP_OID_SNMPV2, 3 |
#define | SNMP_PARSE_ERROR -1 |
#define | SNMP_BUILD_ERROR -2 |
#define | MAX_SID_LEN 32 |
Maximum length of a community name. | |
#define | MAX_NAME_LEN 128 |
Maximum number of sub IDs in an OID. | |
#define | SNMP_ACT_RESERVE1 0 |
#define | SNMP_ACT_RESERVE2 1 |
#define | SNMP_ACT_COMMIT 2 |
#define | SNMP_ACT_ACTION 3 |
#define | SNMP_ACT_FREE 4 |
#define | SNMP_MAX_MSG_SIZE 1472 |
#define | SNMP_STAT_INPKTS 0 |
#define | SNMP_STAT_OUTPKTS 1 |
#define | SNMP_STAT_INBADVERSIONS 2 |
#define | SNMP_STAT_INBADCOMMUNITYNAMES 3 |
#define | SNMP_STAT_INBADCOMMUNITYUSES 4 |
#define | SNMP_STAT_INASNPARSEERRS 5 |
#define | SNMP_STAT_INTOOBIGS 6 |
#define | SNMP_STAT_INNOSUCHNAMES 7 |
#define | SNMP_STAT_INBADVALUES 8 |
#define | SNMP_STAT_INREADONLYS 9 |
#define | SNMP_STAT_INGENERRS 10 |
#define | SNMP_STAT_INTOTALREQVARS 11 |
#define | SNMP_STAT_INTOTALSETVARS 12 |
#define | SNMP_STAT_INGETREQUESTS 13 |
#define | SNMP_STAT_INGETNEXTS 14 |
#define | SNMP_STAT_INSETREQUESTS 15 |
#define | SNMP_STAT_INGETRESPONSES 16 |
#define | SNMP_STAT_INTRAPS 17 |
#define | SNMP_STAT_OUTTOOBIGS 18 |
#define | SNMP_STAT_OUTNOSUCHNAMES 19 |
#define | SNMP_STAT_OUTBADVALUES 20 |
#define | SNMP_STAT_OUTGENERRS 21 |
#define | SNMP_STAT_OUTGETREQUESTS 22 |
#define | SNMP_STAT_OUTGETNEXTS 23 |
#define | SNMP_STAT_OUTSETREQUESTS 24 |
#define | SNMP_STAT_OUTGETRESPONSES 25 |
#define | SNMP_STAT_OUTTRAPS 26 |
#define | SNMP_STAT_ENABLEAUTHENTRAPS 27 |
#define | SNMP_STAT_MAX 28 |
#define | SNMP_VIEW_INCLUDED 1 |
#define | SNMP_VIEW_EXCLUDED 2 |
Typedefs | |
typedef struct _viewEntry | VIEW_LIST |
typedef struct _communityEntry | COMMUNITY_LIST |
typedef int( | WMETHOD )(int, uint8_t *, uint8_t, size_t, OID *, size_t) |
typedef struct _SNMPVAR | SNMPVAR |
typedef struct _SNMP_VARLIST | SNMP_VARLIST |
typedef struct _SUBTREE | SUBTREE |
Functions | |
CONST uint8_t * | SnmpVarParse (CONST uint8_t *data, size_t *dlen, OID *name, size_t *nlen, uint8_t *type, uint8_t **value, size_t *vlen) |
Parse an SNMP variable. | |
uint8_t * | SnmpVarBuild (uint8_t *data, size_t *dlen, CONST OID *name, size_t nlen, uint8_t type, CONST uint8_t *value, size_t vlen) |
Build an SNMP variable. | |
int | SnmpAgentProcessRequest (SNMP_SESSION *sess, CONST uint8_t *in_data, size_t in_len, uint8_t *out_data, size_t *out_len) |
Parse incoming and create outgoing packet. | |
int | SnmpAgent (UDPSOCKET *sock) |
Run SNMP agent. | |
int | SnmpOidLenCmp (CONST OID *name1, CONST OID *name2, size_t len) |
Compare object identifiers up to a specified length. | |
int | SnmpOidCmp (CONST OID *name1, size_t len1, CONST OID *name2, size_t len2) |
Compare object identifiers. | |
int | SnmpOidTreeCmp (CONST OID *objid, size_t objlen, CONST OID *treeid, size_t treelen) |
Compare object identifier with tree element. | |
int | SnmpOidCmpIdx (CONST OID *name1, size_t len1, CONST OID *name2, size_t len2, OID index) |
Compare object identifiers with index added. | |
int | SnmpOidEquals (CONST OID *name1, size_t len1, CONST OID *name2, size_t len2) |
void | SnmpStatsInc (int which) |
uint32_t | SnmpStatsGet (int which) |
void | SnmpStatsSet (int which, uint32_t value) |
CONST uint8_t * | SnmpAuthParse (CONST uint8_t *data, size_t *length, uint8_t *sidp, size_t *slen, long *version) |
Parse header of community string based message. | |
uint8_t * | SnmpAuthBuild (SNMP_SESSION *session, uint8_t *data, size_t *length, size_t messagelen) |
Build header of community string based message. | |
int | SnmpViewCreate (CONST char *name, CONST OID *subtree, size_t subtreelen, int type) |
int | SnmpViewFind (char *name) |
int | SnmpCommunityFind (CONST char *name, int *readView, int *writeView) |
Find community entry by name. | |
int | SnmpCommunityCreate (CONST char *name, int readView, int writeView) |
Create a community entry. | |
int | SnmpMibRegister (OID basename[], size_t baselen, SNMPVAR *vars, int num) |
Register MIB variables. | |
uint8_t * | SnmpMibFind (OID *name, size_t *namelen, uint8_t *type, size_t *len, uint16_t *acl, int exact, WMETHOD **wmethod, int *no_obj) |
Find MIB variable. | |
SNMP_PDU * | SnmpPduCreate (int cmd, CONST OID *name, size_t nlen) |
Create PDU with a given type and object ID. | |
int | SnmpPduAddVariable (SNMP_PDU *pdu, OID *name, size_t nlen, uint8_t type, uint8_t *value, size_t vlen) |
Add variable to PDU. | |
void | SnmpPduDestroy (SNMP_PDU *pdu) |
Destroy PDU. | |
SNMP_SESSION * | SnmpSessionOpen (uint32_t ip, uint16_t port, uint8_t *id, size_t idlen) |
Open SNMP session. | |
void | SnmpSessionClose (SNMP_SESSION *session) |
Close SNMP session. | |
int | SnmpSessionSendPdu (SNMP_SESSION *session, SNMP_PDU *pdu) |
Send PDU. |
Simple network management protocol.
#define SNMP_PORT 161 |
Standard UDP port for SNMP agents to receive requests messages.
Definition at line 56 of file snmp.h.
Referenced by main().
#define SNMP_TRAP_PORT 162 |
#define SNMP_MAX_LEN 500 |
Default maximum message size.
Definition at line 68 of file snmp.h.
Referenced by SnmpAgent(), and SnmpSessionSendPdu().
#define SNMP_VERSION_1 0 |
SNMPv1.
The original version, defined by RFC 1157.
Definition at line 75 of file snmp.h.
Referenced by SnmpAgentProcessRequest(), and SnmpAuthParse().
#define SNMP_VERSION_2C 1 |
SNMPv2c.
Community string-based SNMPv2, which was an attempt to combine the protocol operations of SNMPv2 with the security of SNMPv1, defined by RFCs 1901, 1905, and 1906.
Partly supplied by this code, work is in progress.
Definition at line 85 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_VERSION_3 3 |
#define SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) |
Definition at line 100 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) |
Definition at line 101 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) |
Definition at line 102 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) |
Definition at line 103 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) |
Definition at line 108 of file snmp.h.
Referenced by SnmpSessionSendPdu().
#define SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) |
Definition at line 113 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) |
#define SNMP_MSG_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) |
#define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) |
Definition at line 125 of file snmp.h.
Referenced by SnmpVarBuild().
#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) |
Definition at line 126 of file snmp.h.
Referenced by SnmpVarBuild().
#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) |
Definition at line 127 of file snmp.h.
Referenced by SnmpVarBuild().
#define SNMP_OID_INTERNET 1, 3, 6, 1 |
#define MAX_NAME_LEN 128 |
#define SNMP_ACT_RESERVE1 0 |
Definition at line 186 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_RESERVE2 1 |
Definition at line 187 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_COMMIT 2 |
Definition at line 188 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_ACTION 3 |
Definition at line 189 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_FREE 4 |
Definition at line 190 of file snmp.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_MAX_MSG_SIZE 1472 |
#define SNMP_STAT_INPKTS 0 |
Definition at line 59 of file snmp_api.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_OUTPKTS 1 |
Definition at line 60 of file snmp_api.h.
Referenced by SnmpAgent().
#define SNMP_STAT_INBADVERSIONS 2 |
Definition at line 61 of file snmp_api.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_INBADCOMMUNITYNAMES 3 |
Definition at line 62 of file snmp_api.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_INBADCOMMUNITYUSES 4 |
Definition at line 63 of file snmp_api.h.
#define SNMP_STAT_INASNPARSEERRS 5 |
Definition at line 64 of file snmp_api.h.
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_INTOOBIGS 6 |
Definition at line 65 of file snmp_api.h.
#define SNMP_STAT_INNOSUCHNAMES 7 |
Definition at line 66 of file snmp_api.h.
#define SNMP_STAT_INBADVALUES 8 |
Definition at line 67 of file snmp_api.h.
#define SNMP_STAT_INREADONLYS 9 |
Definition at line 68 of file snmp_api.h.
#define SNMP_STAT_INGENERRS 10 |
Definition at line 69 of file snmp_api.h.
#define SNMP_STAT_INTOTALREQVARS 11 |
Definition at line 70 of file snmp_api.h.
#define SNMP_STAT_INTOTALSETVARS 12 |
Definition at line 71 of file snmp_api.h.
#define SNMP_STAT_INGETREQUESTS 13 |
Definition at line 72 of file snmp_api.h.
#define SNMP_STAT_INGETNEXTS 14 |
Definition at line 73 of file snmp_api.h.
#define SNMP_STAT_INSETREQUESTS 15 |
Definition at line 74 of file snmp_api.h.
#define SNMP_STAT_INGETRESPONSES 16 |
Definition at line 75 of file snmp_api.h.
#define SNMP_STAT_INTRAPS 17 |
Definition at line 76 of file snmp_api.h.
#define SNMP_STAT_OUTTOOBIGS 18 |
Definition at line 77 of file snmp_api.h.
Referenced by SnmpVarBuild().
#define SNMP_STAT_OUTNOSUCHNAMES 19 |
Definition at line 78 of file snmp_api.h.
#define SNMP_STAT_OUTBADVALUES 20 |
Definition at line 79 of file snmp_api.h.
Referenced by SnmpVarBuild().
#define SNMP_STAT_OUTGENERRS 21 |
Definition at line 80 of file snmp_api.h.
#define SNMP_STAT_OUTGETREQUESTS 22 |
Definition at line 81 of file snmp_api.h.
#define SNMP_STAT_OUTGETNEXTS 23 |
Definition at line 82 of file snmp_api.h.
#define SNMP_STAT_OUTSETREQUESTS 24 |
Definition at line 83 of file snmp_api.h.
#define SNMP_STAT_OUTGETRESPONSES 25 |
Definition at line 84 of file snmp_api.h.
#define SNMP_STAT_OUTTRAPS 26 |
Definition at line 85 of file snmp_api.h.
#define SNMP_STAT_ENABLEAUTHENTRAPS 27 |
Definition at line 86 of file snmp_api.h.
#define SNMP_STAT_MAX 28 |
Definition at line 88 of file snmp_api.h.
Referenced by SnmpStatsGet(), SnmpStatsInc(), and SnmpStatsSet().
#define SNMP_VIEW_INCLUDED 1 |
#define SNMP_VIEW_EXCLUDED 2 |
Definition at line 57 of file snmp_config.h.
typedef struct _viewEntry VIEW_LIST |
typedef struct _communityEntry COMMUNITY_LIST |
Definition at line 53 of file snmp_mib.h.
typedef struct _SNMP_VARLIST SNMP_VARLIST |
Definition at line 54 of file snmp_pdu.h.
CONST uint8_t* SnmpVarParse | ( | CONST uint8_t * | data, |
size_t * | dlen, | ||
OID * | name, | ||
size_t * | nlen, | ||
uint8_t * | type, | ||
uint8_t ** | value, | ||
size_t * | vlen | ||
) |
Parse an SNMP variable.
data | Pointer to start of the name/value pair. |
dlen | Contains the number of valid bytes following the start of the variable. On exit, it is returned as the number of valid bytes following the end of this variable. |
name | Pointer to a buffer that receives the name (OID). |
nlen | On entry, this contains the maximum number of sub IDs accepted for the name. On exit, it is returned as the actual number sub IDs found in the name. |
type | Pointer to the variable that receives the ASN type of the value. |
value | Pointer to variable that receives a pointer to the ASN1 encoded value of variable. |
vlen | Pointer to the variable that receives the length of the value. |
Definition at line 65 of file snmp.c.
References ASN_CONSTRUCTOR, ASN_OBJECT_ID, ASN_PRIMITIVE, ASN_SEQUENCE, ASN_UNIVERSAL, AsnHeaderParse(), AsnOidParse(), AsnSequenceParse(), and CONST.
uint8_t* SnmpVarBuild | ( | uint8_t * | data, |
size_t * | dlen, | ||
CONST OID * | name, | ||
size_t | nlen, | ||
uint8_t | type, | ||
CONST uint8_t * | value, | ||
size_t | vlen | ||
) |
Build an SNMP variable.
data | Pointer to start of the output buffer. |
dlen | Contains the number of valid bytes following the start of the variable. On exit, it is returned as the number of valid bytes following the end of this variable. |
name | Name (OID). |
nlen | Number of sub IDs of the name. |
type | ASN type of the value. |
value | Pointer to the value. |
vlen | Length of the value. |
Definition at line 114 of file snmp.c.
References ASN_BIT_STR, ASN_CONSTRUCTOR, ASN_COUNTER, ASN_COUNTER64, ASN_GAUGE, ASN_INTEGER, ASN_IPADDRESS, ASN_NSAP, ASN_NULL, ASN_OBJECT_ID, ASN_OCTET_STR, ASN_OPAQUE, ASN_PRIMITIVE, ASN_SEQUENCE, ASN_TIMETICKS, ASN_UINTEGER, ASN_UNIVERSAL, AsnBitStringBuild(), AsnIntegerBuild(), AsnNullBuild(), AsnOctetStringBuild(), AsnOidBuild(), AsnSequenceBuild(), AsnUnsigned64Build(), AsnUnsignedBuild(), SNMP_ENDOFMIBVIEW, SNMP_NOSUCHINSTANCE, SNMP_NOSUCHOBJECT, SNMP_STAT_OUTBADVALUES, SNMP_STAT_OUTTOOBIGS, and SnmpStatsInc().
int SnmpAgentProcessRequest | ( | SNMP_SESSION * | sess, |
CONST uint8_t * | in_data, | ||
size_t | in_len, | ||
uint8_t * | out_data, | ||
size_t * | out_len | ||
) |
Parse incoming and create outgoing packet.
in_data | Pointer to the incoming packet. |
in_len | Number of valid bytes in the incoming packet. |
out_data | Pointer to a buffer for the outgoing packet. |
out_len | Pointer to the variable that receives the number of bytes in the outgoing packet. |
out_len | Pointer to a variable which contains the size of the output buffer on entry. On exit, it is returned as the number of valid bytes in the output buffer. |
Definition at line 307 of file snmp_agent.c.
References ASN_INTEGER, ASN_PRIMITIVE, ASN_UNIVERSAL, AsnHeaderParse(), AsnIntegerBuild(), AsnIntegerParse(), AsnSequenceBuild(), CONST, SNMP_SESSION::sess_id, SNMP_SESSION::sess_id_len, SNMP_SESSION::sess_read_view, SNMP_SESSION::sess_version, SNMP_SESSION::sess_write_view, SNMP_ACT_ACTION, SNMP_ACT_COMMIT, SNMP_ACT_FREE, SNMP_ACT_RESERVE1, SNMP_ACT_RESERVE2, SNMP_MSG_GET, SNMP_MSG_GETBULK, SNMP_MSG_GETNEXT, SNMP_MSG_RESPONSE, SNMP_MSG_SET, SNMP_STAT_INASNPARSEERRS, SNMP_STAT_INBADCOMMUNITYNAMES, SNMP_STAT_INBADVERSIONS, SNMP_STAT_INPKTS, SNMP_VERSION_1, SNMP_VERSION_2C, SnmpAuthBuild(), SnmpAuthParse(), SnmpCommunityFind(), and SnmpStatsInc().
Referenced by SnmpAgent().
int SnmpAgent | ( | UDPSOCKET * | sock | ) |
Run SNMP agent.
Normally runs in an endless loop, which is only left in case of an error.
sock | UDP socket to use. |
Definition at line 468 of file snmp_agent.c.
References free(), malloc(), memset(), NutUdpReceiveFrom(), NutUdpSendTo(), SNMP_MAX_LEN, SNMP_STAT_OUTPKTS, SnmpAgentProcessRequest(), and SnmpStatsInc().
Referenced by main().
Compare object identifiers up to a specified length.
name1 | First object identifier. |
name2 | Second object identifier. |
len | Number of sub identifiers to compare. |
Definition at line 56 of file snmp_api.c.
Referenced by SnmpOidCmp(), SnmpOidCmpIdx(), and SnmpOidTreeCmp().
Compare object identifiers.
name1 | First object identifier. |
len1 | Length of first object identifier. |
name2 | Second object identifier. |
len2 | Length of second object identifier. |
Definition at line 84 of file snmp_api.c.
References SnmpOidLenCmp().
Referenced by SnmpMibRegister().
Compare object identifier with tree element.
name1 | Object identifier. |
len1 | Length of object identifier. |
name2 | Tree identifier. |
len2 | Length of tree identifier. |
Definition at line 111 of file snmp_api.c.
References SnmpOidLenCmp().
Referenced by SnmpMibFind().
Compare object identifiers with index added.
name1 | First object identifier. |
len1 | Length of first object identifier. |
name2 | Second object identifier. |
len2 | Length of second object identifier. |
index | Index sub identifier. |
Definition at line 134 of file snmp_api.c.
References SnmpOidLenCmp().
Definition at line 172 of file snmp_api.c.
References memcmp().
void SnmpStatsInc | ( | int | which | ) |
Definition at line 181 of file snmp_api.c.
References SNMP_STAT_MAX.
Referenced by SnmpAgent(), SnmpAgentProcessRequest(), and SnmpVarBuild().
uint32_t SnmpStatsGet | ( | int | which | ) |
Definition at line 188 of file snmp_api.c.
References SNMP_STAT_MAX.
void SnmpStatsSet | ( | int | which, |
uint32_t | value | ||
) |
Definition at line 196 of file snmp_api.c.
References SNMP_STAT_MAX.
CONST uint8_t* SnmpAuthParse | ( | CONST uint8_t * | data, |
size_t * | length, | ||
uint8_t * | sidp, | ||
size_t * | slen, | ||
long * | version | ||
) |
Parse header of community string based message.
Retrieves version and community.
data | Points to the message. |
length | Bytes left in message. |
sidp | Pointer to a buffer that receives the community string. |
slen | Length of the community string. |
version | Message version |
Definition at line 54 of file snmp_auth.c.
References ASN_CONSTRUCTOR, ASN_SEQUENCE, AsnIntegerParse(), AsnOctetStringParse(), AsnSequenceParse(), and SNMP_VERSION_1.
Referenced by SnmpAgentProcessRequest().
uint8_t* SnmpAuthBuild | ( | SNMP_SESSION * | session, |
uint8_t * | data, | ||
size_t * | length, | ||
size_t | messagelen | ||
) |
Build header of community string based message.
Definition at line 81 of file snmp_auth.c.
References ASN_CONSTRUCTOR, ASN_INTEGER, ASN_OCTET_STR, ASN_PRIMITIVE, ASN_SEQUENCE, ASN_UNIVERSAL, AsnIntegerBuild(), AsnOctetStringBuild(), AsnSequenceBuild(), SNMP_SESSION::sess_id, SNMP_SESSION::sess_id_len, and SNMP_SESSION::sess_version.
Referenced by SnmpAgentProcessRequest().
int SnmpViewCreate | ( | CONST char * | name, |
CONST OID * | subtree, | ||
size_t | subtreelen, | ||
int | type | ||
) |
name | Symbolic name of this view. |
type | Either SNMP_VIEW_INCLUDED or SNMP_VIEW_EXCLUDED. |
Definition at line 56 of file snmp_config.c.
References malloc(), memset(), _viewEntry::next, strcmp(), strcpy(), strlen(), _viewEntry::view_index, _viewEntry::view_name, _viewEntry::view_subtree, _viewEntry::view_subtree_len, and _viewEntry::view_type.
Referenced by main().
int SnmpViewFind | ( | char * | name | ) |
Definition at line 98 of file snmp_config.c.
References _viewEntry::next, strcmp(), _viewEntry::view_index, and _viewEntry::view_name.
int SnmpCommunityFind | ( | CONST char * | name, |
int * | readView, | ||
int * | writeView | ||
) |
Find community entry by name.
name | Community name. |
readView | Pointer to a variable that receives the view index for read access. |
writeView | Pointer to a variable that receives the view index for write access. |
Definition at line 124 of file snmp_config.c.
References _communityEntry::comm_name, _communityEntry::comm_read_view, _communityEntry::comm_write_view, _communityEntry::next, and strcmp().
Referenced by SnmpAgentProcessRequest().
int SnmpCommunityCreate | ( | CONST char * | name, |
int | readView, | ||
int | writeView | ||
) |
Create a community entry.
name | Community name. |
readView | View index for read access, obtained from a previous call to SnmpViewCreate(). |
writeView | View index for write access, obtained from a previous call to SnmpViewCreate(). |
Definition at line 153 of file snmp_config.c.
References _communityEntry::comm_name, _communityEntry::comm_read_view, _communityEntry::comm_write_view, malloc(), memset(), _communityEntry::next, strcmp(), strcpy(), and strlen().
Referenced by main().
Register MIB variables.
Definition at line 75 of file snmp_mib.c.
References malloc(), memcpy(), SnmpOidCmp(), _SUBTREE::sub_name, _SUBTREE::sub_namelen, _SUBTREE::sub_next, _SUBTREE::sub_numvars, and _SUBTREE::sub_vars.
Referenced by MibRegisterIfVars(), and MibRegisterSysVars().
uint8_t* SnmpMibFind | ( | OID * | name, |
size_t * | namelen, | ||
uint8_t * | type, | ||
size_t * | len, | ||
uint16_t * | acl, | ||
int | exact, | ||
WMETHOD ** | wmethod, | ||
int * | no_obj | ||
) |
Find MIB variable.
name | |
namelen | |
type | |
len | |
acl | |
exact | |
wmethod | |
no_obj |
Definition at line 114 of file snmp_mib.c.
References access(), free(), malloc(), memcpy(), SnmpOidTreeCmp(), _SUBTREE::sub_name, _SUBTREE::sub_namelen, _SUBTREE::sub_next, _SUBTREE::sub_numvars, _SUBTREE::sub_vars, _SNMPVAR::var_acl, _SNMPVAR::var_get, _SNMPVAR::var_name, _SNMPVAR::var_namelen, and _SNMPVAR::var_type.
Create PDU with a given type and object ID.
cmd | PDU type. |
name | Object identifier. |
nlen | Number of sub IDs of the object identifier. |
Definition at line 53 of file snmp_pdu.c.
References calloc, free(), malloc(), memcpy(), SNMP_PDU::pdu_cmd, SNMP_PDU::pdu_enterprise, and SNMP_PDU::pdu_enterprise_length.
int SnmpPduAddVariable | ( | SNMP_PDU * | pdu, |
OID * | name, | ||
size_t | nlen, | ||
uint8_t | type, | ||
uint8_t * | value, | ||
size_t | vlen | ||
) |
Add variable to PDU.
pdu | Pointer to the PDU. |
name | Variable name. |
nlen | Number of sub IDs of the variable name. |
type | Variable type. |
value | Pointer to the variable's value. |
vlen | Length of the variable value in byts. |
Definition at line 83 of file snmp_pdu.c.
References ASN_COUNTER, ASN_GAUGE, ASN_INTEGER, ASN_TIMETICKS, ASN_UINTEGER, calloc, free(), malloc(), memcpy(), SNMP_PDU::pdu_variables, _SNMP_VARLIST::var_name, _SNMP_VARLIST::var_next, _SNMP_VARLIST::var_nlen, _SNMP_VARLIST::var_type, _SNMP_VARLIST::var_val, _SNMP_VARLIST::var_vlen, and _SNMP_VARLIST::var_vptr.
void SnmpPduDestroy | ( | SNMP_PDU * | pdu | ) |
Destroy PDU.
pdu | Pointer to the PDU info, obtained by a call to SnmpPduCreate(). |
Definition at line 137 of file snmp_pdu.c.
References free(), SNMP_PDU::pdu_enterprise, SNMP_PDU::pdu_variables, _SNMP_VARLIST::var_name, _SNMP_VARLIST::var_next, _SNMP_VARLIST::var_val, and _SNMP_VARLIST::var_vptr.
SNMP_SESSION* SnmpSessionOpen | ( | uint32_t | ip, |
uint16_t | port, | ||
uint8_t * | id, | ||
size_t | idlen | ||
) |
Open SNMP session.
ip | Remote IP address. |
port | Remote port number. |
id | Community name. |
idlen | Length of the community name. |
Definition at line 61 of file snmp_session.c.
References calloc, free(), memcpy(), NutUdpCreateSocket(), SNMP_SESSION::sess_id, SNMP_SESSION::sess_id_len, SNMP_SESSION::sess_rem_addr, SNMP_SESSION::sess_rem_port, and SNMP_SESSION::sess_sock.
void SnmpSessionClose | ( | SNMP_SESSION * | session | ) |
Close SNMP session.
session | Points to the session info, obtained by calling SnmpSessionOpen(). |
Definition at line 90 of file snmp_session.c.
References free(), NutUdpDestroySocket(), and SNMP_SESSION::sess_sock.
int SnmpSessionSendPdu | ( | SNMP_SESSION * | session, |
SNMP_PDU * | pdu | ||
) |
Send PDU.
session | Points to the session info, obtained by calling SnmpSessionOpen(). |
pdu | Points to the PDU info, obtained by calling SnmpPduCreate(). |
Definition at line 256 of file snmp_session.c.
References free(), malloc(), NutUdpSendTo(), SNMP_PDU::pdu_cmd, SNMP_PDU::pdu_reqid, SNMP_SESSION::sess_rem_addr, SNMP_SESSION::sess_rem_port, SNMP_SESSION::sess_sock, SNMP_MAX_LEN, and SNMP_MSG_TRAP.