3 * [EXPERIMENTAL] Generic MIB tree structures.
5 * @todo namespace prefixes
9 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without modification,
13 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34 * Author: Christiaan Simons <christiaan.simons@axon.tv>
37 #ifndef __LWIP_SNMP_STRUCTS_H__
38 #define __LWIP_SNMP_STRUCTS_H__
44 #include "private_mib.h"
47 /* MIB object instance */
48 #define MIB_OBJECT_NONE 0
49 #define MIB_OBJECT_SCALAR 1
50 #define MIB_OBJECT_TAB 2
52 /* MIB object access */
53 #define MIB_OBJECT_READ_ONLY 0
54 #define MIB_OBJECT_READ_WRITE 1
55 #define MIB_OBJECT_WRITE_ONLY 2
56 #define MIB_OBJECT_NOT_ACCESSIBLE 3
58 /** object definition returned by (get_object_def)() */
61 /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */
63 /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */
65 /* ASN type for this object */
67 /* value length (host length) */
69 /* length of instance part of supplied object identifier */
71 /* instance part of supplied object identifier */
75 /** MIB const array node */
76 #define MIB_NODE_AR 0x01
77 /** MIB array node (mem_malloced from RAM) */
78 #define MIB_NODE_RA 0x02
79 /** MIB list root node (mem_malloced from RAM) */
80 #define MIB_NODE_LR 0x03
81 /** MIB node for external objects */
82 #define MIB_NODE_EX 0x04
84 /** node "base class" layout, the mandatory fields for a node */
87 /** returns struct obj_def for the given object identifier */
88 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
89 /** returns object value for the given object identifier,
90 @note the caller must allocate at least len bytes for the value */
91 void (*get_value)(u8_t ident_len, s32_t *ident, u16_t len, void *value);
92 /** @todo set_value() */
93 /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */
95 /* array or max list length */
96 const u16_t maxlength;
99 /** derived node, points to a fixed size const array
100 of sub-identifiers plus a 'child' pointer */
101 struct mib_array_node
103 /* inherited "base class" */
104 const void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
105 const void (*get_value)(u8_t ident_len, s32_t *ident, u16_t len, void *value);
106 const u8_t node_type;
107 const u16_t maxlength;
109 /* aditional struct members */
111 struct mib_node* const *nptr;
114 /** derived node, points to a fixed size mem_malloced array
115 of sub-identifiers plus a 'child' pointer */
116 struct mib_ram_array_node
118 /* inherited "base class" */
119 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
120 void (*get_value)(u8_t ident_len, s32_t *ident, u16_t len, void *value);
124 /* aditional struct members */
126 struct mib_node **nptr;
131 struct mib_list_node *prev;
132 struct mib_list_node *next;
134 struct mib_node *nptr;
137 /** derived node, points to a doubly linked list
138 of sub-identifiers plus a 'child' pointer */
139 struct mib_list_rootnode
141 /* inherited "base class" */
142 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
143 void (*get_value)(u8_t ident_len, s32_t *ident, u16_t len, void *value);
147 /* aditional struct members */
148 struct mib_list_node *head;
149 struct mib_list_node *tail;
150 /* counts list nodes in list */
154 /** derived node, has access functions for mib object in external memory or device
155 using index ('idx'), with a range 0 .. (count - 1) to address these objects */
156 struct mib_external_node
158 /* inherited "base class" */
159 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
160 void (*get_value)(u8_t ident_len, s32_t *ident, u16_t len, void *value);
164 /* aditional struct members */
165 void (*req_object_def)(u8_t ident_len, s32_t *ident);
166 void (*getreq_value)(u8_t ident_len, s32_t *ident);
168 /** compares object sub identifier with externally available id
169 return zero when equal, nonzero when unequal */
170 u16_t (*ident_cmp)(u16_t idx, s32_t sub_id);
171 /** returns next pointer for given index (NULL for scalar 'leaf') */
172 struct mib_extern_node* (*get_nptr)(u16_t idx);
173 /* counts actual number of external objects */
177 struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct obj_def *object_def);