]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/blob - src/include/lwip/snmp_structs.h
c5de341e6a9fdcc2dae6861b889683dab82b170d
[pes-rpp/rpp-lwip.git] / src / include / lwip / snmp_structs.h
1 /**
2  * @file
3  * [EXPERIMENTAL] Generic MIB tree structures.
4  *
5  * @todo namespace prefixes
6  */
7
8 /*
9  * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without modification,
13  * are permitted provided that the following conditions are met:
14  *
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.
22  *
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
32  * OF SUCH DAMAGE.
33  *
34  * Author: Christiaan Simons <christiaan.simons@axon.tv>
35  */
36
37 #ifndef __LWIP_SNMP_STRUCTS_H__
38 #define __LWIP_SNMP_STRUCTS_H__
39
40 #include "lwip/opt.h"
41 #include "arch/cc.h"
42
43 #if SNMP_PRIVATE_MIB
44 #include "private_mib.h"
45 #endif
46
47 /* MIB object instance */
48 #define MIB_OBJECT_NONE 0 
49 #define MIB_OBJECT_SCALAR 1
50 #define MIB_OBJECT_TAB 2
51
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
57
58 /** object definition returned by (get_object_def)() */
59 struct obj_def
60 {
61   /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */
62   u8_t instance;
63   /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */
64   u8_t access;
65   /* ASN type for this object */
66   u8_t asn_type;
67   /* value length (host length) */
68   u16_t v_len;
69   /* length of instance part of supplied object identifier */
70   u8_t  id_inst_len;
71   /* instance part of supplied object identifier */
72   s32_t *id_inst_ptr; 
73 };
74
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
83
84 /** node "base class" layout, the mandatory fields for a node  */
85 struct mib_node
86 {
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 */
94   const u8_t node_type;
95   /* array or max list length */
96   const u16_t maxlength;
97 };
98
99 /** derived node, points to a fixed size const array
100     of sub-identifiers plus a 'child' pointer */
101 struct mib_array_node
102 {
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;
108
109   /* aditional struct members */
110   const s32_t *objid;
111   struct mib_node* const *nptr;
112 };
113
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
117 {
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);
121   u8_t node_type;
122   u16_t maxlength;
123
124   /* aditional struct members */
125   s32_t *objid;
126   struct mib_node **nptr;
127 };
128
129 struct mib_list_node
130 {
131   struct mib_list_node *prev;  
132   struct mib_list_node *next;
133   s32_t objid;
134   struct mib_node *nptr;
135 };
136
137 /** derived node, points to a doubly linked list
138     of sub-identifiers plus a 'child' pointer */
139 struct mib_list_rootnode
140 {
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);
144   u8_t node_type;
145   u16_t maxlength;
146
147   /* aditional struct members */
148   struct mib_list_node *head;
149   struct mib_list_node *tail;
150   /* counts list nodes in list  */
151   u16_t count;
152 };
153
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
157 {
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);
161   u8_t node_type;
162   u16_t maxlength;
163
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);
167
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  */
174   u16_t count;
175 };
176
177 struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct obj_def *object_def);
178
179 #endif