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
134 struct snmp_obj_id_const_ref
140 extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero;
143 union 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
187 struct snmp_node_instance;
189 typedef s16_t (*node_instance_get_value_method)(
struct snmp_node_instance*,
void*);
190 typedef snmp_err_t (*node_instance_set_test_method)(
struct snmp_node_instance*, u16_t,
void*);
191 typedef snmp_err_t (*node_instance_set_value_method)(
struct snmp_node_instance*, u16_t,
void*);
192 typedef void (*node_instance_release_method)(
struct snmp_node_instance*);
194 #define SNMP_GET_VALUE_RAW_DATA 0x4000 197 struct snmp_node_instance
200 const struct snmp_node*
node;
202 struct snmp_obj_id instance_oid;
207 snmp_access_t access;
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;
219 union snmp_variant_value reference;
226 struct snmp_tree_node
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) }, \ 243 struct snmp_leaf_node
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 } 262 struct snmp_oid_range
269 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);
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;
278 struct snmp_next_oid_state
280 const u32_t* start_oid;
285 u8_t next_oid_max_len;
287 snmp_next_oid_status_t status;
291 void 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);
294 u8_t snmp_next_oid_precheck(
struct snmp_next_oid_state *state,
const u32_t *oid, u8_t oid_len);
295 u8_t snmp_next_oid_check(
struct snmp_next_oid_state *state,
const u32_t *oid, u8_t oid_len,
void* reference);
297 void snmp_oid_assign(
struct snmp_obj_id* target,
const u32_t *oid, u8_t oid_len);
298 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);
299 void snmp_oid_prefix(
struct snmp_obj_id* target,
const u32_t *oid, u8_t oid_len);
300 void snmp_oid_append(
struct snmp_obj_id* target,
const u32_t *oid, u8_t oid_len);
301 u8_t snmp_oid_equal(
const u32_t *oid1, u8_t oid1_len,
const u32_t *oid2, u8_t oid2_len);
302 s8_t snmp_oid_compare(
const u32_t *oid1, u8_t oid1_len,
const u32_t *oid2, u8_t oid2_len);
305 u8_t snmp_oid_to_ip4(
const u32_t *oid,
ip4_addr_t *ip);
306 void snmp_ip4_to_oid(
const ip4_addr_t *ip, u32_t *oid);
309 u8_t snmp_oid_to_ip6(
const u32_t *oid,
ip6_addr_t *ip);
310 void snmp_ip6_to_oid(
const ip6_addr_t *ip, u32_t *oid);
312 #if LWIP_IPV4 || LWIP_IPV6 313 u8_t snmp_ip_to_oid(
const ip_addr_t *ip, u32_t *oid);
314 u8_t snmp_ip_port_to_oid(
const ip_addr_t *ip, u16_t port, u32_t *oid);
316 u8_t snmp_oid_to_ip(
const u32_t *oid, u8_t oid_len,
ip_addr_t *ip);
317 u8_t snmp_oid_to_ip_port(
const u32_t *oid, u8_t oid_len,
ip_addr_t *ip, u16_t *port);
323 snmp_err_t snmp_set_test_ok(
struct snmp_node_instance* instance, u16_t value_len,
void* value);
325 err_t snmp_decode_bits(
const u8_t *buf, u32_t buf_len, u32_t *bit_value);
326 err_t snmp_decode_truthvalue(
const s32_t *asn1_value, u8_t *bool_value);
327 u8_t snmp_encode_bits(u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count);
328 u8_t snmp_encode_truthvalue(s32_t *asn1_value, u32_t bool_value);
330 struct 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;
369 extern struct snmp_statistics snmp_stats;
Connected isochronous stream node.
Generic data structure used for all lwIP network interfaces.
SNMP server options list.
IP address structure for passing IP addresses by value.
#define SNMP_MAX_OBJ_ID_LEN
The maximum number of Sub ID's inside an object identifier.
IP address API (common IPv4 and IPv6)