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.
Referenced by main().
#define SNMP_TRAP_PORT 162 |
Standard UDP port for SNMP managers to receive notificaion messages.
#define SNMP_MAX_LEN 500 |
Default maximum message size.
Referenced by SnmpAgent(), and SnmpSessionSendPdu().
#define SNMP_VERSION_1 0 |
SNMPv1.
The original version, defined by RFC 1157.
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.
Referenced by SnmpAgentProcessRequest().
#define SNMP_VERSION_3 3 |
SNMPv3.
An attempt by the IETF working group to merge the SNMPv2u and SNMPv2* proposals into a more widely accepted SNMPv3. The original version, defined by RFC 1157.
Not yet supported by this code.
#define SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) |
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) |
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) |
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) |
Referenced by SnmpAgentProcessRequest().
#define SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) |
Referenced by SnmpSessionSendPdu().
#define SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) |
Referenced by SnmpAgentProcessRequest().
#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) |
Referenced by SnmpVarBuild().
#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) |
Referenced by SnmpVarBuild().
#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) |
Referenced by SnmpVarBuild().
#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 |
Referenced by main().
#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 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_RESERVE2 1 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_COMMIT 2 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_ACTION 3 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_ACT_FREE 4 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_MAX_MSG_SIZE 1472 |
Referenced by main().
#define SNMP_STAT_INPKTS 0 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_OUTPKTS 1 |
Referenced by SnmpAgent().
#define SNMP_STAT_INBADVERSIONS 2 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_INBADCOMMUNITYNAMES 3 |
Referenced by SnmpAgentProcessRequest().
#define SNMP_STAT_INBADCOMMUNITYUSES 4 |
#define SNMP_STAT_INASNPARSEERRS 5 |
Referenced by SnmpAgentProcessRequest().
#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 |
Referenced by SnmpVarBuild().
#define SNMP_STAT_OUTNOSUCHNAMES 19 |
#define SNMP_STAT_OUTBADVALUES 20 |
Referenced by SnmpVarBuild().
#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 |
Referenced by SnmpStatsGet(), SnmpStatsInc(), and SnmpStatsSet().
#define SNMP_VIEW_INCLUDED 1 |
Referenced by main().
#define SNMP_VIEW_EXCLUDED 2 |
typedef struct _viewEntry VIEW_LIST |
typedef struct _communityEntry COMMUNITY_LIST |
typedef struct _SNMP_VARLIST SNMP_VARLIST |
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. |
References ASN_CONSTRUCTOR, ASN_OBJECT_ID, ASN_PRIMITIVE, ASN_SEQUENCE, ASN_UNIVERSAL, AsnHeaderParse(), AsnOidParse(), AsnSequenceParse(), and NULL.
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. |
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(), NULL, 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. |
References ASN_INTEGER, ASN_PRIMITIVE, ASN_UNIVERSAL, AsnHeaderParse(), AsnIntegerBuild(), AsnIntegerParse(), AsnSequenceBuild(), NULL, 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. |
References free(), malloc(), memset(), NutUdpReceiveFrom(), NutUdpSendTo(), rc, 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. |
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. |
References rc, and 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. |
References rc, and 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. |
References rc, and SnmpOidLenCmp().
void SnmpStatsInc | ( | int | which | ) |
References SNMP_STAT_MAX.
Referenced by SnmpAgent(), SnmpAgentProcessRequest(), and SnmpVarBuild().
uint32_t SnmpStatsGet | ( | int | which | ) |
References SNMP_STAT_MAX.
void SnmpStatsSet | ( | int | which, |
uint32_t | value | ||
) |
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 |
References ASN_CONSTRUCTOR, ASN_SEQUENCE, AsnIntegerParse(), AsnOctetStringParse(), AsnSequenceParse(), NULL, 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.
References ASN_CONSTRUCTOR, ASN_INTEGER, ASN_OCTET_STR, ASN_PRIMITIVE, ASN_SEQUENCE, ASN_UNIVERSAL, AsnIntegerBuild(), AsnOctetStringBuild(), AsnSequenceBuild(), NULL, 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. |
References malloc(), memset(), _viewEntry::next, NULL, 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 | ) |
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. |
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(). |
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.
References malloc(), memcpy(), NULL, 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 |
References access(), free(), malloc(), memcpy(), NULL, rc, 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. |
References calloc, free(), malloc(), memcpy(), NULL, 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. |
References ASN_COUNTER, ASN_GAUGE, ASN_INTEGER, ASN_TIMETICKS, ASN_UINTEGER, calloc, free(), malloc(), memcpy(), NULL, 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(). |
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. |
References calloc, free(), memcpy(), NULL, 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(). |
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(). |
References free(), malloc(), NutUdpSendTo(), SNMP_PDU::pdu_cmd, SNMP_PDU::pdu_reqid, rc, SNMP_SESSION::sess_rem_addr, SNMP_SESSION::sess_rem_port, SNMP_SESSION::sess_sock, SNMP_MAX_LEN, and SNMP_MSG_TRAP.