lwIP 2.1.2 Lightweight IP stack

Data Structures | Macros | Enumerations | Functions
snmp_core.h File Reference
`#include "lwip/apps/snmp_opts.h"`
`#include "lwip/ip_addr.h"`
`#include "lwip/err.h"`

## Data Structures
struct | snmp_obj_id
union | snmp_variant_value
struct | snmp_node
struct | snmp_node_instance
struct | snmp_tree_node
struct | snmp_leaf_node
struct | snmp_mib
struct | snmp_oid_range
struct | snmp_next_oid_state

## Macros
#define | SNMP_NODE_TREE 0x00

## Enumerations
enum | snmp_err_t
enum | snmp_access_t

## 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)
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)
u8_t | snmp_next_oid_precheck (struct snmp_next_oid_state *state, const u32_t *oid, u8_t oid_len)
u8_t | snmp_next_oid_check (struct snmp_next_oid_state *state, const u32_t *oid, u8_t oid_len, void *reference)
void | snmp_oid_assign (struct snmp_obj_id *target, const u32_t *oid, u8_t oid_len)
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)
void | snmp_oid_prefix (struct snmp_obj_id *target, const u32_t *oid, u8_t oid_len)
void | snmp_oid_append (struct snmp_obj_id *target, const u32_t *oid, u8_t oid_len)
u8_t | snmp_oid_equal (const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
s8_t | snmp_oid_compare (const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
u8_t | snmp_oid_to_ip4 (const u32_t *oid, ip4_addr_t *ip)
void | snmp_ip4_to_oid (const ip4_addr_t *ip, u32_t *oid)
u8_t | snmp_oid_to_ip6 (const u32_t *oid, ip6_addr_t *ip)
void | snmp_ip6_to_oid (const ip6_addr_t *ip, u32_t *oid)
u8_t | snmp_ip_to_oid (const ip_addr_t *ip, u32_t *oid)
u8_t | snmp_ip_port_to_oid (const ip_addr_t *ip, u16_t port, u32_t *oid)
u8_t | snmp_oid_to_ip (const u32_t *oid, u8_t oid_len, ip_addr_t *ip)
u8_t | snmp_oid_to_ip_port (const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port)
u8_t | netif_to_num (const struct netif *netif)
err_t | snmp_decode_bits (const u8_t *buf, u32_t buf_len, u32_t *bit_value)
u8_t | snmp_encode_bits (u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count)

## Detailed Description

SNMP core API for implementing MIBs

## Macro Definition Documentation

## ◆ SNMP_NODE_TREE

#define SNMP_NODE_TREE 0x00

SNMP MIB node types tree node is the only node the stack can process in order to walk the tree, all other nodes are assumed to be leaf nodes. This cannot be an enum because users may want to define their own node types.

## Enumeration Type Documentation

## ◆ snmp_access_t

enum snmp_access_t

SNMP node instance access types

## ◆ snmp_err_t

enum snmp_err_t

error codes predefined by SNMP prot.

## Function Documentation

## ◆ netif_to_num()

u8_t netif_to_num | ( | const struct netif * | netif | ) |

Convert netif to interface index

Parameters

  netif | netif

Returns
  index

## ◆ snmp_decode_bits()

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

  buf | points to a buffer holding the ASN1 octet string
  buf_len | length of octet string
  bit_value | decoded Bit value with Bit0 == LSB

Returns
  ERR_OK if successful, ERR_ARG if bit value contains more than 32 bit

## ◆ snmp_encode_bits()

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

  buf | points to a buffer where the resulting ASN1 octet string is stored to
  buf_len | max length of the bufffer
  bit_value | Bit value to encode with Bit0 == LSB
  bit_count | Number 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

## ◆ snmp_ip4_to_oid()

void snmp_ip4_to_oid | ( | const ip4_addr_t * | ip,
|  | u32_t * | oid
| ) |  |

Convert ip4_addr to InetAddressIPv4 (no InetAddressType)

Parameters

  ip | points to input struct
  oid | points to u32_t ident[4] output

## ◆ snmp_ip6_to_oid()

void snmp_ip6_to_oid | ( | const ip6_addr_t * | ip,
|  | u32_t * | oid
| ) |  |

Convert ip6_addr to InetAddressIPv6 (no InetAddressType)

Parameters

  ip | points to input struct
  oid | points to u32_t ident[16] output

## ◆ snmp_ip_port_to_oid()

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

Convert to InetAddressType+InetAddress+InetPortNumber

Parameters

  ip | IP address
  port | Port
  oid | OID

Returns
  OID length

## ◆ snmp_ip_to_oid()

u8_t snmp_ip_to_oid | ( | const ip_addr_t * | ip,
|  | u32_t * | oid
| ) |  |

Convert to InetAddressType+InetAddress

Parameters

  ip | IP address
  oid | OID

Returns
  OID length

## ◆ snmp_next_oid_check()

u8_t snmp_next_oid_check | ( | struct snmp_next_oid_state * | state,
|  | const u32_t * | oid,
|  | 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

## ◆ snmp_next_oid_init()

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

## ◆ snmp_next_oid_precheck()

u8_t snmp_next_oid_precheck | ( | struct snmp_next_oid_state * | state,
|  | const u32_t * | oid,
|  | 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()

## ◆ snmp_oid_append()

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

  target | Assignment target to append to
  oid | OID
  oid_len | OID length

## ◆ snmp_oid_assign()

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

  target | Assignment target
  oid | OID
  oid_len | OID length

## ◆ snmp_oid_combine()

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

  target | Assignmet target
  oid1 | OID 1
  oid1_len | OID 1 length
  oid2 | OID 2
  oid2_len | OID 2 length

## ◆ snmp_oid_compare()

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

  oid1 | OID 1
  oid1_len | OID 1 length
  oid2 | OID 2
  oid2_len | OID 2 length

Returns
  -1: OID1<OID2 1: OID1 >OID2 0: equal

## ◆ snmp_oid_equal()

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

  oid1 | OID 1
  oid1_len | OID 1 length
  oid2 | OID 2
  oid2_len | OID 2 length

Returns
  1: equal 0: non-equal

## ◆ snmp_oid_in_range()

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

## ◆ snmp_oid_prefix()

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

  target | Assignment target to prefix
  oid | OID
  oid_len | OID length

## ◆ snmp_oid_to_ip()

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

  oid | OID
  oid_len | OID length
  ip | IP address

Returns
  Parsed OID length

## ◆ snmp_oid_to_ip4()

u8_t snmp_oid_to_ip4 | ( | const u32_t * | oid,
|  | ip4_addr_t * | ip
| ) |  |

Conversion from InetAddressIPv4 oid to lwIP ip4_addr

Parameters

  oid | points to u32_t ident[4] input
  ip | points to output struct

## ◆ snmp_oid_to_ip6()

u8_t snmp_oid_to_ip6 | ( | const u32_t * | oid,
|  | ip6_addr_t * | ip
| ) |  |

Conversion from InetAddressIPv6 oid to lwIP ip6_addr

Parameters

  oid | points to u32_t oid[16] input
  ip | points to output struct

## ◆ snmp_oid_to_ip_port()

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

  oid | OID
  oid_len | OID length
  ip | IP address
  port | Port

Returns
  Parsed OID length