Nut/OS  5.0.5
API Reference
SNMP

Simple network management protocol. More...

Collaboration diagram for SNMP:

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_tSnmpVarParse (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_tSnmpVarBuild (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_tSnmpAuthParse (const uint8_t *data, size_t *length, uint8_t *sidp, size_t *slen, long *version)
 Parse header of community string based message.
uint8_tSnmpAuthBuild (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_tSnmpMibFind (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_PDUSnmpPduCreate (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_SESSIONSnmpSessionOpen (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.

Detailed Description

Simple network management protocol.


Define Documentation

#define SNMP_PORT   161

Standard UDP port for SNMP agents to receive requests messages.

Examples:
snmpd/snmpd.c.

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
Examples:
snmpd/snmpd.c.

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
Examples:
snmpd/snmpd.c.

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
#define SNMP_VIEW_INCLUDED   1
Examples:
snmpd/snmpd.c.

Referenced by main().

#define SNMP_VIEW_EXCLUDED   2

Typedef Documentation

typedef struct _viewEntry VIEW_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

Function Documentation

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.

Parameters:
dataPointer to start of the name/value pair.
dlenContains 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.
namePointer to a buffer that receives the name (OID).
nlenOn 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.
typePointer to the variable that receives the ASN type of the value.
valuePointer to variable that receives a pointer to the ASN1 encoded value of variable.
vlenPointer to the variable that receives the length of the value.
Returns:
Pointer to the first byte past the end of this name/value pair. Returns NULL on any error.

References ASN_CONSTRUCTOR, ASN_OBJECT_ID, ASN_PRIMITIVE, ASN_SEQUENCE, ASN_UNIVERSAL, AsnHeaderParse(), AsnOidParse(), AsnSequenceParse(), and NULL.

Here is the call graph for this function:

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.

Parameters:
dataPointer to start of the output buffer.
dlenContains 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.
nameName (OID).
nlenNumber of sub IDs of the name.
typeASN type of the value.
valuePointer to the value.
vlenLength of the value.
Returns:
Pointer to the first byte past the end of this name/value pair. Returns NULL on any error.

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().

Here is the call graph for this function:

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.

Parameters:
in_dataPointer to the incoming packet.
in_lenNumber of valid bytes in the incoming packet.
out_dataPointer to a buffer for the outgoing packet.
out_lenPointer to the variable that receives the number of bytes in the outgoing packet.
out_lenPointer 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.
Returns:
0 upon success and -1 upon failure.

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().

Here is the call graph for this function:

int SnmpAgent ( UDPSOCKET sock)

Run SNMP agent.

Normally runs in an endless loop, which is only left in case of an error.

Parameters:
sockUDP socket to use.
Returns:
Always -1.

References free(), malloc(), memset(), NutUdpReceiveFrom(), NutUdpSendTo(), rc, SNMP_MAX_LEN, SNMP_STAT_OUTPKTS, SnmpAgentProcessRequest(), and SnmpStatsInc().

Referenced by main().

Here is the call graph for this function:

int SnmpOidLenCmp ( const OID name1,
const OID name2,
size_t  len 
)

Compare object identifiers up to a specified length.

Parameters:
name1First object identifier.
name2Second object identifier.
lenNumber of sub identifiers to compare.

Referenced by SnmpOidCmp(), SnmpOidCmpIdx(), and SnmpOidTreeCmp().

int SnmpOidCmp ( const OID name1,
size_t  len1,
const OID name2,
size_t  len2 
)

Compare object identifiers.

Parameters:
name1First object identifier.
len1Length of first object identifier.
name2Second object identifier.
len2Length of second object identifier.
Returns:
0 if both are equal, 1 if first element is larger or -1 if first element is lower than the second one.

References rc, and SnmpOidLenCmp().

Referenced by SnmpMibRegister().

Here is the call graph for this function:

int SnmpOidTreeCmp ( const OID objid,
size_t  objlen,
const OID treeid,
size_t  treelen 
)

Compare object identifier with tree element.

Parameters:
name1Object identifier.
len1Length of object identifier.
name2Tree identifier.
len2Length of tree identifier.
Returns:
0 if the object identifier is part of the subtree, -1 if it is located before the tree element or 1 if it is located after the tree element.

References rc, and SnmpOidLenCmp().

Referenced by SnmpMibFind().

Here is the call graph for this function:

int SnmpOidCmpIdx ( const OID name1,
size_t  len1,
const OID name2,
size_t  len2,
OID  index 
)

Compare object identifiers with index added.

Parameters:
name1First object identifier.
len1Length of first object identifier.
name2Second object identifier.
len2Length of second object identifier.
indexIndex sub identifier.
Returns:
0 if both are equal, 1 if first element is larger or -1 if first element is lower than the second one.

References rc, and SnmpOidLenCmp().

Here is the call graph for this function:

int SnmpOidEquals ( const OID name1,
size_t  len1,
const OID name2,
size_t  len2 
)

References memcmp().

Here is the call graph for this function:

void SnmpStatsInc ( int  which)
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.

Parameters:
dataPoints to the message.
lengthBytes left in message.
sidpPointer to a buffer that receives the community string.
slenLength of the community string.
versionMessage version

References ASN_CONSTRUCTOR, ASN_SEQUENCE, AsnIntegerParse(), AsnOctetStringParse(), AsnSequenceParse(), NULL, and SNMP_VERSION_1.

Referenced by SnmpAgentProcessRequest().

Here is the call graph for this function:

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().

Here is the call graph for this function:

int SnmpViewCreate ( const char *  name,
const OID subtree,
size_t  subtreelen,
int  type 
)
Parameters:
nameSymbolic name of this view.
typeEither SNMP_VIEW_INCLUDED or SNMP_VIEW_EXCLUDED.
Returns:
View index on success. Otherwise -1 is returned.

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().

Here is the call graph for this function:

int SnmpViewFind ( char *  name)

References _viewEntry::next, strcmp(), _viewEntry::view_index, and _viewEntry::view_name.

Here is the call graph for this function:

int SnmpCommunityFind ( const char *  name,
int *  readView,
int *  writeView 
)

Find community entry by name.

Parameters:
nameCommunity name.
readViewPointer to a variable that receives the view index for read access.
writeViewPointer to a variable that receives the view index for write access.
Returns:
0 on success, -1 otherwise.

References _communityEntry::comm_name, _communityEntry::comm_read_view, _communityEntry::comm_write_view, _communityEntry::next, and strcmp().

Referenced by SnmpAgentProcessRequest().

Here is the call graph for this function:

int SnmpCommunityCreate ( const char *  name,
int  readView,
int  writeView 
)

Create a community entry.

Parameters:
nameCommunity name.
readViewView index for read access, obtained from a previous call to SnmpViewCreate().
writeViewView index for write access, obtained from a previous call to SnmpViewCreate().
Returns:
0 on success, -1 otherwise.

References _communityEntry::comm_name, _communityEntry::comm_read_view, _communityEntry::comm_write_view, malloc(), memset(), _communityEntry::next, strcmp(), strcpy(), and strlen().

Referenced by main().

Here is the call graph for this function:

int SnmpMibRegister ( OID  basename[],
size_t  baselen,
SNMPVAR vars,
int  num 
)

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().

Here is the call graph for this function:

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.

Parameters:
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.

Here is the call graph for this function:

SNMP_PDU* SnmpPduCreate ( int  cmd,
const OID name,
size_t  nlen 
)

Create PDU with a given type and object ID.

Parameters:
cmdPDU type.
nameObject identifier.
nlenNumber 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.

Here is the call graph for this function:

int SnmpPduAddVariable ( SNMP_PDU pdu,
OID name,
size_t  nlen,
uint8_t  type,
uint8_t value,
size_t  vlen 
)

Add variable to PDU.

Parameters:
pduPointer to the PDU.
nameVariable name.
nlenNumber of sub IDs of the variable name.
typeVariable type.
valuePointer to the variable's value.
vlenLength 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.

Here is the call graph for this function:

void SnmpPduDestroy ( SNMP_PDU pdu)

Destroy PDU.

Parameters:
pduPointer 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.

Here is the call graph for this function:

SNMP_SESSION* SnmpSessionOpen ( uint32_t  ip,
uint16_t  port,
uint8_t id,
size_t  idlen 
)

Open SNMP session.

Parameters:
ipRemote IP address.
portRemote port number.
idCommunity name.
idlenLength of the community name.
Returns:
Pointer to a newly created session info.

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.

Here is the call graph for this function:

void SnmpSessionClose ( SNMP_SESSION session)

Close SNMP session.

Parameters:
sessionPoints to the session info, obtained by calling SnmpSessionOpen().

References free(), NutUdpDestroySocket(), and SNMP_SESSION::sess_sock.

Here is the call graph for this function:

int SnmpSessionSendPdu ( SNMP_SESSION session,
SNMP_PDU pdu 
)

Send PDU.

Parameters:
sessionPoints to the session info, obtained by calling SnmpSessionOpen().
pduPoints to the PDU info, obtained by calling SnmpPduCreate().
Returns:
0 on success, -1 otherwise.

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.

Here is the call graph for this function: