Contiki-NG
Modules | Data Structures | Typedefs | Functions
SNMP (Simple Network Management Protocol)

This is an implementation of the Simple Network Management Protocol. More...

Modules

 SNMP Configurable Defines
 
 SNMP Defines
 
 SNMP Functions
 
 SNMP Structs
 
 This is the SNMP Public API
 This group contains all the functions that can be used outside the OS level.
 

Data Structures

struct  snmp_mib_resource_s
 The MIB Resource struct. More...
 

Typedefs

typedef void(* snmp_mib_resource_handler_t) (snmp_varbind_t *varbind, uint32_t *oid)
 The MIB resource handler typedef. More...
 
typedef struct snmp_mib_resource_s snmp_mib_resource_t
 The MIB Resource struct.
 

Functions

unsigned char * snmp_ber_encode_type (unsigned char *out, uint32_t *out_len, uint8_t type)
 Encodes a type. More...
 
unsigned char * snmp_ber_encode_length (unsigned char *out, uint32_t *out_len, uint8_t length)
 Encodes the length. More...
 
unsigned char * snmp_ber_encode_integer (unsigned char *out, uint32_t *out_len, uint32_t integer)
 Encodes an integer. More...
 
unsigned char * snmp_ber_encode_unsigned_integer (unsigned char *out, uint32_t *out_len, uint8_t type, uint32_t number)
 Encodes an unsigned integer. More...
 
unsigned char * snmp_ber_encode_string_len (unsigned char *out, uint32_t *out_len, const char *str, uint32_t length)
 Encodes a string. More...
 
unsigned char * snmp_ber_encode_null (unsigned char *out, uint32_t *out_len, uint8_t type)
 Encodes a null. More...
 
unsigned char * snmp_ber_decode_type (unsigned char *buff, uint32_t *buff_len, uint8_t *type)
 Decodes a type. More...
 
unsigned char * snmp_ber_decode_length (unsigned char *buff, uint32_t *buff_len, uint8_t *length)
 Decodes a length. More...
 
unsigned char * snmp_ber_decode_integer (unsigned char *buff, uint32_t *buff_len, uint32_t *integer)
 Decodes an integer. More...
 
unsigned char * snmp_ber_decode_unsigned_integer (unsigned char *buff, uint32_t *buff_len, uint8_t expected_type, uint32_t *number)
 Decodes an unsigned number. More...
 
unsigned char * snmp_ber_decode_string_len_buffer (unsigned char *buff, uint32_t *buff_len, const char **str, uint32_t *length)
 Decodes a string. More...
 
unsigned char * snmp_ber_decode_null (unsigned char *buff, uint32_t *buff_len)
 Decodes a null. More...
 
unsigned char * snmp_engine (unsigned char *buff, uint32_t buff_len, unsigned char *out, uint32_t *out_len)
 Process the SNMP packet and prepares the response. More...
 
unsigned char * snmp_message_encode (unsigned char *out, uint32_t *out_len, snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t varbinds_length)
 Encodes a SNMP message. More...
 
uint8_t * snmp_message_decode (uint8_t *buf, uint32_t buf_len, snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t *varbinds_length)
 
snmp_mib_resource_tsnmp_mib_find (uint32_t *oid)
 Finds the MIB Resource for this OID. More...
 
snmp_mib_resource_tsnmp_mib_find_next (uint32_t *oid)
 Finds the next MIB Resource after this OID. More...
 
void snmp_mib_add (snmp_mib_resource_t *resource)
 Adds a resource into the linked list. More...
 
void snmp_mib_init (void)
 Initialize the MIB resources list.
 
int snmp_oid_cmp_oid (uint32_t *oid1, uint32_t *oid2)
 Compares to oids. More...
 
unsigned char * snmp_oid_encode_oid (unsigned char *out, uint32_t *out_len, uint32_t *oid)
 Encodes a Oid. More...
 
unsigned char * snmp_oid_decode_oid (unsigned char *buf, uint32_t *buf_len, uint32_t *oid, uint32_t *oid_len)
 Decodes a Oid. More...
 
void snmp_oid_copy (uint32_t *dst, uint32_t *src)
 Copies a Oid. More...
 
void snmp_oid_print (uint32_t *oid)
 Prints a oid. More...
 

Detailed Description

This is an implementation of the Simple Network Management Protocol.

Typedef Documentation

◆ snmp_mib_resource_handler_t

typedef void(* snmp_mib_resource_handler_t) (snmp_varbind_t *varbind, uint32_t *oid)

The MIB resource handler typedef.

Parameters
varbindThe varbind that is being changed
oidThe oid from the resource

Definition at line 56 of file snmp-mib.h.

Function Documentation

◆ snmp_ber_decode_integer()

unsigned char* snmp_ber_decode_integer ( unsigned char *  buff,
uint32_t *  buff_len,
uint32_t *  integer 
)

Decodes an integer.

Parameters
buffA pointer to the beginning of the buffer
buff_lenA pointer to the buffer length
integerA pointer to the integer
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 147 of file snmp-ber.c.

◆ snmp_ber_decode_length()

unsigned char* snmp_ber_decode_length ( unsigned char *  buff,
uint32_t *  buff_len,
uint8_t *  length 
)

Decodes a length.

Parameters
buffA pointer to the beginning of the buffer
buff_lenA pointer to the buffer length
lengthA pointer to the length
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 138 of file snmp-ber.c.

◆ snmp_ber_decode_null()

unsigned char* snmp_ber_decode_null ( unsigned char *  buff,
uint32_t *  buff_len 
)

Decodes a null.

Parameters
buffA pointer to the beginning of the buffer
buff_lenA pointer to the buffer length
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 264 of file snmp-ber.c.

◆ snmp_ber_decode_string_len_buffer()

unsigned char* snmp_ber_decode_string_len_buffer ( unsigned char *  buff,
uint32_t *  buff_len,
const char **  str,
uint32_t *  length 
)

Decodes a string.

Parameters
buffA pointer to the beginning of the buffer
buff_lenA pointer to the buffer length
strA pointer to the string
lengthA pointer to the string length
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 219 of file snmp-ber.c.

◆ snmp_ber_decode_type()

unsigned char* snmp_ber_decode_type ( unsigned char *  buff,
uint32_t *  buff_len,
uint8_t *  type 
)

Decodes a type.

Parameters
buffA pointer to the beginning of the buffer
buff_lenA pointer to the buffer length
typeA pointer to the type
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 129 of file snmp-ber.c.

◆ snmp_ber_decode_unsigned_integer()

unsigned char* snmp_ber_decode_unsigned_integer ( unsigned char *  buff,
uint32_t *  buff_len,
uint8_t  expected_type,
uint32_t *  number 
)

Decodes an unsigned number.

Parameters
buffA pointer to the beginning of the buffer
buff_lenA pointer to the buffer length
expected_typeThe expected type that represents an unsingned integer
numberA pointer to the number
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 183 of file snmp-ber.c.

◆ snmp_ber_encode_integer()

unsigned char* snmp_ber_encode_integer ( unsigned char *  out,
uint32_t *  out_len,
uint32_t  integer 
)

Encodes an integer.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
integerA integer
Returns
NULL if error or the next entry in the buffer

Definition at line 66 of file snmp-ber.c.

◆ snmp_ber_encode_length()

unsigned char* snmp_ber_encode_length ( unsigned char *  out,
uint32_t *  out_len,
uint8_t  length 
)

Encodes the length.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
lengthA length
Returns
NULL if error or the next entry in the buffer

Definition at line 58 of file snmp-ber.c.

◆ snmp_ber_encode_null()

unsigned char* snmp_ber_encode_null ( unsigned char *  out,
uint32_t *  out_len,
uint8_t  type 
)

Encodes a null.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
typeA type
Returns
NULL if error or the next entry in the buffer

Definition at line 119 of file snmp-ber.c.

◆ snmp_ber_encode_string_len()

unsigned char* snmp_ber_encode_string_len ( unsigned char *  out,
uint32_t *  out_len,
const char *  str,
uint32_t  length 
)

Encodes a string.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
strA string
lengthThe string length
Returns
NULL if error or the next entry in the buffer

Definition at line 102 of file snmp-ber.c.

◆ snmp_ber_encode_type()

unsigned char* snmp_ber_encode_type ( unsigned char *  out,
uint32_t *  out_len,
uint8_t  type 
)

Encodes a type.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
typeA type
Returns
NULL if error or the next entry in the buffer

Definition at line 50 of file snmp-ber.c.

◆ snmp_ber_encode_unsigned_integer()

unsigned char* snmp_ber_encode_unsigned_integer ( unsigned char *  out,
uint32_t *  out_len,
uint8_t  type,
uint32_t  number 
)

Encodes an unsigned integer.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
typeA type that represents an unsigned integer
numberA number
Returns
NULL if error or the next entry in the buffer

Definition at line 84 of file snmp-ber.c.

◆ snmp_engine()

unsigned char* snmp_engine ( unsigned char *  buff,
uint32_t  buff_len,
unsigned char *  out,
uint32_t *  out_len 
)

Process the SNMP packet and prepares the response.

Parameters
buffA pointer to the beginning of the packet buffer
buff_lenThe packet length
outA pointer to the end of the response buffer
out_lenA pointer to the length of the response buffer
Returns
NULL in case of fail or the first element in the response buffer

Definition at line 205 of file snmp-engine.c.

◆ snmp_message_decode()

uint8_t* snmp_message_decode ( uint8_t *  buf,
uint32_t  buf_len,
snmp_header_t header,
snmp_varbind_t varbinds,
uint32_t *  varbinds_length 
)
Parameters
bufA pointer to the beginning of the buffer
buf_lenA pointer to the buffer length
headerThe SNMP header struct
varbindsThe varbinds array
varbinds_lengthA pointer to the number of varbinds
Returns

Definition at line 114 of file snmp-message.c.

◆ snmp_message_encode()

unsigned char* snmp_message_encode ( unsigned char *  out,
uint32_t *  out_len,
snmp_header_t header,
snmp_varbind_t varbinds,
uint32_t  varbinds_length 
)

Encodes a SNMP message.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
headerThe SNMP header struct
varbindsThe varbinds array
varbinds_lengthThe number of varbinds
Returns

Definition at line 50 of file snmp-message.c.

◆ snmp_mib_add()

void snmp_mib_add ( snmp_mib_resource_t resource)

Adds a resource into the linked list.

Parameters
resourceThe resource

Definition at line 84 of file snmp-mib.c.

References list_head(), snmp_mib_resource_s::next, snmp_mib_resource_s::oid, and snmp_oid_cmp_oid().

Referenced by snmp_api_add_resource().

◆ snmp_mib_find()

snmp_mib_resource_t* snmp_mib_find ( uint32_t *  oid)

Finds the MIB Resource for this OID.

Parameters
oidThe OID
Returns
In case of success a pointer to the resouce or NULL in case of fail

Definition at line 52 of file snmp-mib.c.

◆ snmp_mib_find_next()

snmp_mib_resource_t* snmp_mib_find_next ( uint32_t *  oid)

Finds the next MIB Resource after this OID.

Parameters
oidThe OID
Returns
In case of success a pointer to the resouce or NULL in case of fail

Definition at line 68 of file snmp-mib.c.

◆ snmp_oid_cmp_oid()

int snmp_oid_cmp_oid ( uint32_t *  oid1,
uint32_t *  oid2 
)

Compares to oids.

Parameters
oid1First Oid
oid2Second Oid
Returns
< 0 if oid1 < oid2, > 0 if oid1 > oid2 and 0 if they are equal

Definition at line 50 of file snmp-oid.c.

Referenced by snmp_mib_add().

◆ snmp_oid_copy()

void snmp_oid_copy ( uint32_t *  dst,
uint32_t *  src 
)

Copies a Oid.

Parameters
dstA pointer to the destination array
srcA pointer to the source array

Definition at line 185 of file snmp-oid.c.

◆ snmp_oid_decode_oid()

unsigned char* snmp_oid_decode_oid ( unsigned char *  buf,
uint32_t *  buf_len,
uint32_t *  oid,
uint32_t *  oid_len 
)

Decodes a Oid.

Parameters
bufA pointer to the beginning of the buffer
buf_lenA pointer to the buffer length
oidA pointer to the oid array
oid_lenA pointer to the oid length
Returns
NULL if error or the first entry after the oid in the buffer

Definition at line 126 of file snmp-oid.c.

◆ snmp_oid_encode_oid()

unsigned char* snmp_oid_encode_oid ( unsigned char *  out,
uint32_t *  out_len,
uint32_t *  oid 
)

Encodes a Oid.

Parameters
outA pointer to the end of the buffer
out_lenA pointer to the buffer length
oidThe Oid
Returns
NULL if error or the next entry in the buffer

Definition at line 80 of file snmp-oid.c.

◆ snmp_oid_print()

void snmp_oid_print ( uint32_t *  oid)

Prints a oid.

Parameters
oidA oid

Definition at line 202 of file snmp-oid.c.