36#ifndef LWIP_HDR_APPS_SNMP_CORE_H
37#define LWIP_HDR_APPS_SNMP_CORE_H
51#define SNMP_ASN1_CLASS_UNIVERSAL 0x00
52#define SNMP_ASN1_CLASS_APPLICATION 0x40
53#define SNMP_ASN1_CLASS_CONTEXT 0x80
54#define SNMP_ASN1_CLASS_PRIVATE 0xC0
56#define SNMP_ASN1_CONTENTTYPE_PRIMITIVE 0x00
57#define SNMP_ASN1_CONTENTTYPE_CONSTRUCTED 0x20
60#define SNMP_ASN1_UNIVERSAL_END_OF_CONTENT 0
61#define SNMP_ASN1_UNIVERSAL_INTEGER 2
62#define SNMP_ASN1_UNIVERSAL_OCTET_STRING 4
63#define SNMP_ASN1_UNIVERSAL_NULL 5
64#define SNMP_ASN1_UNIVERSAL_OBJECT_ID 6
65#define SNMP_ASN1_UNIVERSAL_SEQUENCE_OF 16
68#define SNMP_ASN1_APPLICATION_IPADDR 0
69#define SNMP_ASN1_APPLICATION_COUNTER 1
70#define SNMP_ASN1_APPLICATION_GAUGE 2
71#define SNMP_ASN1_APPLICATION_TIMETICKS 3
72#define SNMP_ASN1_APPLICATION_OPAQUE 4
73#define SNMP_ASN1_APPLICATION_COUNTER64 6
76#define SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE 1
79#define SNMP_ASN1_TYPE_END_OF_CONTENT (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_END_OF_CONTENT)
80#define SNMP_ASN1_TYPE_INTEGER (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_INTEGER)
81#define SNMP_ASN1_TYPE_OCTET_STRING (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OCTET_STRING)
82#define SNMP_ASN1_TYPE_NULL (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_NULL)
83#define SNMP_ASN1_TYPE_OBJECT_ID (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OBJECT_ID)
84#define SNMP_ASN1_TYPE_SEQUENCE (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_CONSTRUCTED | SNMP_ASN1_UNIVERSAL_SEQUENCE_OF)
85#define SNMP_ASN1_TYPE_IPADDR (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_IPADDR)
86#define SNMP_ASN1_TYPE_IPADDRESS SNMP_ASN1_TYPE_IPADDR
87#define SNMP_ASN1_TYPE_COUNTER (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER)
88#define SNMP_ASN1_TYPE_COUNTER32 SNMP_ASN1_TYPE_COUNTER
89#define SNMP_ASN1_TYPE_GAUGE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_GAUGE)
90#define SNMP_ASN1_TYPE_GAUGE32 SNMP_ASN1_TYPE_GAUGE
91#define SNMP_ASN1_TYPE_UNSIGNED32 SNMP_ASN1_TYPE_GAUGE
92#define SNMP_ASN1_TYPE_TIMETICKS (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_TIMETICKS)
93#define SNMP_ASN1_TYPE_OPAQUE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_OPAQUE)
95#define SNMP_ASN1_TYPE_COUNTER64 (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER64)
98#define SNMP_VARBIND_EXCEPTION_OFFSET 0xF0
99#define SNMP_VARBIND_EXCEPTION_MASK 0x0F
103 SNMP_ERR_NOERROR = 0,
110 SNMP_ERR_GENERROR = 5,
111 SNMP_ERR_NOACCESS = 6,
112 SNMP_ERR_WRONGTYPE = 7,
113 SNMP_ERR_WRONGLENGTH = 8,
114 SNMP_ERR_WRONGENCODING = 9,
115 SNMP_ERR_WRONGVALUE = 10,
116 SNMP_ERR_NOCREATION = 11,
117 SNMP_ERR_INCONSISTENTVALUE = 12,
118 SNMP_ERR_RESOURCEUNAVAILABLE = 13,
119 SNMP_ERR_COMMITFAILED = 14,
120 SNMP_ERR_UNDOFAILED = 15,
121 SNMP_ERR_NOTWRITABLE = 17,
122 SNMP_ERR_INCONSISTENTNAME = 18,
124 SNMP_ERR_NOSUCHINSTANCE = SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE
134struct snmp_obj_id_const_ref
140extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero;
143union snmp_variant_value
146 const void* const_ptr;
161#define SNMP_NODE_TREE 0x00
163#define SNMP_NODE_SCALAR 0x01
164#define SNMP_NODE_SCALAR_ARRAY 0x02
165#define SNMP_NODE_TABLE 0x03
166#define SNMP_NODE_THREADSYNC 0x04
179 SNMP_NODE_INSTANCE_ACCESS_READ = 1,
180 SNMP_NODE_INSTANCE_ACCESS_WRITE = 2,
181 SNMP_NODE_INSTANCE_READ_ONLY = SNMP_NODE_INSTANCE_ACCESS_READ,
182 SNMP_NODE_INSTANCE_READ_WRITE = (SNMP_NODE_INSTANCE_ACCESS_READ | SNMP_NODE_INSTANCE_ACCESS_WRITE),
183 SNMP_NODE_INSTANCE_WRITE_ONLY = SNMP_NODE_INSTANCE_ACCESS_WRITE,
184 SNMP_NODE_INSTANCE_NOT_ACCESSIBLE = 0
187struct snmp_node_instance;
189typedef s16_t (*node_instance_get_value_method)(
struct snmp_node_instance*,
void*);
190typedef snmp_err_t (*node_instance_set_test_method)(
struct snmp_node_instance*,
u16_t,
void*);
191typedef snmp_err_t (*node_instance_set_value_method)(
struct snmp_node_instance*,
u16_t,
void*);
192typedef void (*node_instance_release_method)(
struct snmp_node_instance*);
194#define SNMP_GET_VALUE_RAW_DATA 0x4000
197struct snmp_node_instance
200 const struct snmp_node*
node;
202 struct snmp_obj_id instance_oid;
210 node_instance_get_value_method
get_value;
212 node_instance_set_test_method set_test;
214 node_instance_set_value_method
set_value;
216 node_instance_release_method release_instance;
229 struct snmp_node
node;
231 const struct snmp_node*
const *subnodes;
234#define SNMP_CREATE_TREE_NODE(oid, subnodes) \
235 {{ SNMP_NODE_TREE, (oid) }, \
236 (u16_t)LWIP_ARRAYSIZE(subnodes), (subnodes) }
238#define SNMP_CREATE_EMPTY_TREE_NODE(oid) \
239 {{ SNMP_NODE_TREE, (oid) }, \
246 struct snmp_node
node;
247 snmp_err_t (*get_instance)(
const u32_t *root_oid,
u8_t root_oid_len,
struct snmp_node_instance*
instance);
248 snmp_err_t (*get_next_instance)(
const u32_t *root_oid,
u8_t root_oid_len,
struct snmp_node_instance*
instance);
254 const u32_t *base_oid;
256 const struct snmp_node *root_node;
259#define SNMP_MIB_CREATE(oid_list, root_node) { (oid_list), (u8_t)LWIP_ARRAYSIZE(oid_list), root_node }
269u8_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);
272 SNMP_NEXT_OID_STATUS_SUCCESS,
273 SNMP_NEXT_OID_STATUS_NO_MATCH,
274 SNMP_NEXT_OID_STATUS_BUF_TO_SMALL
275} snmp_next_oid_status_t;
278struct snmp_next_oid_state
280 const u32_t* start_oid;
285 u8_t next_oid_max_len;
287 snmp_next_oid_status_t
status;
291void snmp_next_oid_init(
struct snmp_next_oid_state *
state,
292 const u32_t *start_oid,
u8_t start_oid_len,
293 u32_t *next_oid_buf,
u8_t next_oid_max_len);
294u8_t snmp_next_oid_precheck(
struct snmp_next_oid_state *
state,
const u32_t *oid,
u8_t oid_len);
297void snmp_oid_assign(
struct snmp_obj_id*
target,
const u32_t *oid,
u8_t oid_len);
299void snmp_oid_prefix(
struct snmp_obj_id*
target,
const u32_t *oid,
u8_t oid_len);
300void snmp_oid_append(
struct snmp_obj_id*
target,
const u32_t *oid,
u8_t oid_len);
305u8_t snmp_oid_to_ip4(
const u32_t *oid, ip4_addr_t *
ip);
306void snmp_ip4_to_oid(
const ip4_addr_t *
ip,
u32_t *oid);
309u8_t snmp_oid_to_ip6(
const u32_t *oid, ip6_addr_t *
ip);
310void snmp_ip6_to_oid(
const ip6_addr_t *
ip,
u32_t *oid);
312#if LWIP_IPV4 || LWIP_IPV6
323snmp_err_t snmp_set_test_ok(
struct snmp_node_instance*
instance,
u16_t value_len,
void*
value);
326err_t snmp_decode_truthvalue(
const s32_t *asn1_value,
u8_t *bool_value);
330struct snmp_statistics
335 u32_t inbadcommunitynames;
336 u32_t inbadcommunityuses;
337 u32_t inasnparseerrs;
343 u32_t intotalreqvars;
344 u32_t intotalsetvars;
348 u32_t ingetresponses;
351 u32_t outnosuchnames;
354 u32_t outgetrequests;
356 u32_t outsetrequests;
357 u32_t outgetresponses;
360 u32_t unsupportedseclevels;
361 u32_t notintimewindows;
362 u32_t unknownusernames;
363 u32_t unknownengineids;
365 u32_t decryptionerrors;
369extern struct snmp_statistics snmp_stats;
static HINSTANCE instance
static HRESULT set_value(struct d3dx_parameter *param, const void *data, unsigned int bytes, void *dst_data)
HRESULT get_value(const struct table *table, UINT row, UINT column, LONGLONG *val)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLint GLboolean GLint GLenum access
#define SNMP_MAX_OBJ_ID_LEN