Rtos API example

Embed: (wiki syntax)

« Back to documentation index

snmp_core.h File Reference

snmp_core.h File Reference

SNMP core API for implementing MIBs. More...

Go to the source code of this file.

Data Structures

struct  snmp_obj_id
 internal object identifier representation More...
union  snmp_variant_value
 SNMP variant value, used as reference in struct snmp_node_instance and table implementation. More...
struct  snmp_node
 node "base class" layout, the mandatory fields for a node More...
struct  snmp_node_instance
 SNMP node instance. More...
struct  snmp_tree_node
 SNMP tree node. More...
struct  snmp_leaf_node
 SNMP leaf node. More...
struct  snmp_mib
 represents a single mib with its base oid and root node More...
struct  snmp_oid_range
 OID range structure. More...
struct  snmp_next_oid_state
 state for next_oid_init / next_oid_check functions More...

Enumerations

enum  snmp_err_t
 

error codes predefined by SNMP prot.

More...
enum  snmp_access_t
 

SNMP node instance access types.

More...

Functions

u8_t snmp_oid_in_range (const u32_t *oid_in, u8_t oid_len, const struct snmp_oid_range *oid_ranges, u8_t oid_ranges_len)
 checks if incoming OID length and values are in allowed ranges
void snmp_next_oid_init (struct snmp_next_oid_state *state, const u32_t *start_oid, u8_t start_oid_len, u32_t *next_oid_buf, u8_t next_oid_max_len)
 initialize struct next_oid_state using this function before passing it to next_oid_check
u8_t snmp_next_oid_precheck (struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len)
 checks if the passed incomplete OID may be a possible candidate for snmp_next_oid_check(); this methid is intended if the complete OID is not yet known but it is very expensive to build it up, so it is possible to test the starting part before building up the complete oid and pass it to snmp_next_oid_check()
u8_t snmp_next_oid_check (struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void *reference)
 checks the passed OID if it is a candidate to be the next one (get_next); returns !=0 if passed oid is currently closest, otherwise 0
void snmp_oid_assign (struct snmp_obj_id *target, const u32_t *oid, u8_t oid_len)
 Assign an OID to struct snmp_obj_id.
void snmp_oid_combine (struct snmp_obj_id *target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
 Combine two OIDs into struct snmp_obj_id.
void snmp_oid_prefix (struct snmp_obj_id *target, const u32_t *oid, u8_t oid_len)
 Prefix an OID to OID in struct snmp_obj_id.
void snmp_oid_append (struct snmp_obj_id *target, const u32_t *oid, u8_t oid_len)
 Append OIDs to struct snmp_obj_id.
u8_t snmp_oid_equal (const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
 Check of two OIDs are equal.
s8_t snmp_oid_compare (const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
 Compare two OIDs.
u8_t snmp_oid_to_ip4 (const u32_t *oid, ip4_addr_t *ip)
 Conversion from InetAddressIPv4 oid to lwIP ip4_addr.
void snmp_ip4_to_oid (const ip4_addr_t *ip, u32_t *oid)
 Convert ip4_addr to InetAddressIPv4 (no InetAddressType)
u8_t snmp_oid_to_ip6 (const u32_t *oid, ip6_addr_t *ip)
 Conversion from InetAddressIPv6 oid to lwIP ip6_addr.
void snmp_ip6_to_oid (const ip6_addr_t *ip, u32_t *oid)
 Convert ip6_addr to InetAddressIPv6 (no InetAddressType)
u8_t snmp_ip_to_oid (const ip_addr_t *ip, u32_t *oid)
 Convert to InetAddressType+InetAddress.
u8_t snmp_ip_port_to_oid (const ip_addr_t *ip, u16_t port, u32_t *oid)
 Convert to InetAddressType+InetAddress+InetPortNumber.
u8_t snmp_oid_to_ip (const u32_t *oid, u8_t oid_len, ip_addr_t *ip)
 Convert from InetAddressType+InetAddress to ip_addr_t.
u8_t snmp_oid_to_ip_port (const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port)
 Convert from InetAddressType+InetAddress+InetPortNumber to ip_addr_t and u16_t.
u8_t netif_to_num (const struct netif *netif)
 Convert netif to interface index.
err_t snmp_decode_bits (const u8_t *buf, u32_t buf_len, u32_t *bit_value)
 Decodes BITS pseudotype value from ASN.1 OctetString.
u8_t snmp_encode_bits (u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count)
 Encodes BITS pseudotype value into ASN.1 OctetString.

Detailed Description

SNMP core API for implementing MIBs.

Definition in file snmp_core.h.


Enumeration Type Documentation

SNMP node instance access types.

Definition at line 173 of file snmp_core.h.

enum snmp_err_t

error codes predefined by SNMP prot.

Definition at line 100 of file snmp_core.h.


Function Documentation

u8_t netif_to_num ( const struct netif netif )

Convert netif to interface index.

Parameters:
netifnetif
Returns:
index

Definition at line 656 of file lwip_snmp_core.c.

err_t snmp_decode_bits ( const u8_t *  buf,
u32_t  buf_len,
u32_t *  bit_value 
)

Decodes BITS pseudotype value from ASN.1 OctetString.

Note:
Because BITS pseudo type is encoded as OCTET STRING, it cannot directly be encoded/decoded by the agent. Instead call this function as required from get/test/set methods.
Parameters:
bufpoints to a buffer holding the ASN1 octet string
buf_lenlength of octet string
bit_valuedecoded Bit value with Bit0 == LSB
Returns:
ERR_OK if successful, ERR_ARG if bit value contains more than 32 bit

Definition at line 1210 of file lwip_snmp_core.c.

u8_t snmp_encode_bits ( u8_t *  buf,
u32_t  buf_len,
u32_t  bit_value,
u8_t  bit_count 
)

Encodes BITS pseudotype value into ASN.1 OctetString.

Note:
Because BITS pseudo type is encoded as OCTET STRING, it cannot directly be encoded/decoded by the agent. Instead call this function as required from get/test/set methods.
Parameters:
bufpoints to a buffer where the resulting ASN1 octet string is stored to
buf_lenmax length of the bufffer
bit_valueBit value to encode with Bit0 == LSB
bit_countNumber of possible bits for the bit value (according to rfc we have to send all bits independant from their truth value)
Returns:
number of bytes used from buffer to store the resulting OctetString

Definition at line 1284 of file lwip_snmp_core.c.

void snmp_ip4_to_oid ( const ip4_addr_t ip,
u32_t *  oid 
)

Convert ip4_addr to InetAddressIPv4 (no InetAddressType)

Parameters:
ippoints to input struct
oidpoints to u32_t ident[4] output

Definition at line 287 of file lwip_snmp_core.c.

void snmp_ip6_to_oid ( const ip6_addr_t ip,
u32_t *  oid 
)

Convert ip6_addr to InetAddressIPv6 (no InetAddressType)

Parameters:
ippoints to input struct
oidpoints to u32_t ident[16] output

Definition at line 338 of file lwip_snmp_core.c.

u8_t snmp_ip_port_to_oid ( const ip_addr_t ip,
u16_t  port,
u32_t *  oid 
)

Convert to InetAddressType+InetAddress+InetPortNumber.

Parameters:
ipIP address
portPort
oidOID
Returns:
OID length

Definition at line 368 of file lwip_snmp_core.c.

u8_t snmp_ip_to_oid ( const ip_addr_t ip,
u32_t *  oid 
)

Convert to InetAddressType+InetAddress.

Parameters:
ipIP address
oidOID
Returns:
OID length

Definition at line 386 of file lwip_snmp_core.c.

u8_t snmp_next_oid_check ( struct snmp_next_oid_state state,
const u32_t *  oid,
const u8_t  oid_len,
void *  reference 
)

checks the passed OID if it is a candidate to be the next one (get_next); returns !=0 if passed oid is currently closest, otherwise 0

Definition at line 1144 of file lwip_snmp_core.c.

void snmp_next_oid_init ( struct snmp_next_oid_state state,
const u32_t *  start_oid,
u8_t  start_oid_len,
u32_t *  next_oid_buf,
u8_t  next_oid_max_len 
)

initialize struct next_oid_state using this function before passing it to next_oid_check

Definition at line 1108 of file lwip_snmp_core.c.

u8_t snmp_next_oid_precheck ( struct snmp_next_oid_state state,
const u32_t *  oid,
const u8_t  oid_len 
)

checks if the passed incomplete OID may be a possible candidate for snmp_next_oid_check(); this methid is intended if the complete OID is not yet known but it is very expensive to build it up, so it is possible to test the starting part before building up the complete oid and pass it to snmp_next_oid_check()

Definition at line 1124 of file lwip_snmp_core.c.

void snmp_oid_append ( struct snmp_obj_id target,
const u32_t *  oid,
u8_t  oid_len 
)

Append OIDs to struct snmp_obj_id.

Parameters:
targetAssignment target to append to
oidOID
oid_lenOID length

Definition at line 585 of file lwip_snmp_core.c.

void snmp_oid_assign ( struct snmp_obj_id target,
const u32_t *  oid,
u8_t  oid_len 
)

Assign an OID to struct snmp_obj_id.

Parameters:
targetAssignment target
oidOID
oid_lenOID length

Definition at line 529 of file lwip_snmp_core.c.

void snmp_oid_combine ( struct snmp_obj_id target,
const u32_t *  oid1,
u8_t  oid1_len,
const u32_t *  oid2,
u8_t  oid2_len 
)

Combine two OIDs into struct snmp_obj_id.

Parameters:
targetAssignmet target
oid1OID 1
oid1_lenOID 1 length
oid2OID 2
oid2_lenOID 2 length

Definition at line 572 of file lwip_snmp_core.c.

s8_t snmp_oid_compare ( const u32_t *  oid1,
u8_t  oid1_len,
const u32_t *  oid2,
u8_t  oid2_len 
)

Compare two OIDs.

Parameters:
oid1OID 1
oid1_lenOID 1 length
oid2OID 2
oid2_lenOID 2 length
Returns:
-1: OID1<OID2 1: OID1 >OID2 0: equal

Definition at line 604 of file lwip_snmp_core.c.

u8_t snmp_oid_equal ( const u32_t *  oid1,
u8_t  oid1_len,
const u32_t *  oid2,
u8_t  oid2_len 
)

Check of two OIDs are equal.

Parameters:
oid1OID 1
oid1_lenOID 1 length
oid2OID 2
oid2_lenOID 2 length
Returns:
1: equal 0: non-equal

Definition at line 645 of file lwip_snmp_core.c.

u8_t snmp_oid_in_range ( const u32_t *  oid_in,
u8_t  oid_len,
const struct snmp_oid_range oid_ranges,
u8_t  oid_ranges_len 
)

checks if incoming OID length and values are in allowed ranges

Definition at line 1170 of file lwip_snmp_core.c.

void snmp_oid_prefix ( struct snmp_obj_id target,
const u32_t *  oid,
u8_t  oid_len 
)

Prefix an OID to OID in struct snmp_obj_id.

Parameters:
targetAssignment target to prefix
oidOID
oid_lenOID length

Definition at line 547 of file lwip_snmp_core.c.

u8_t snmp_oid_to_ip ( const u32_t *  oid,
u8_t  oid_len,
ip_addr_t ip 
)

Convert from InetAddressType+InetAddress to ip_addr_t.

Parameters:
oidOID
oid_lenOID length
ipIP address
Returns:
Parsed OID length

Definition at line 421 of file lwip_snmp_core.c.

u8_t snmp_oid_to_ip4 ( const u32_t *  oid,
ip4_addr_t ip 
)

Conversion from InetAddressIPv4 oid to lwIP ip4_addr.

Parameters:
oidpoints to u32_t ident[4] input
ippoints to output struct

Definition at line 267 of file lwip_snmp_core.c.

u8_t snmp_oid_to_ip6 ( const u32_t *  oid,
ip6_addr_t ip 
)

Conversion from InetAddressIPv6 oid to lwIP ip6_addr.

Parameters:
oidpoints to u32_t oid[16] input
ippoints to output struct

Definition at line 303 of file lwip_snmp_core.c.

u8_t snmp_oid_to_ip_port ( const u32_t *  oid,
u8_t  oid_len,
ip_addr_t ip,
u16_t *  port 
)

Convert from InetAddressType+InetAddress+InetPortNumber to ip_addr_t and u16_t.

Parameters:
oidOID
oid_lenOID length
ipIP address
portPort
Returns:
Parsed OID length

Definition at line 497 of file lwip_snmp_core.c.