OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [lwip_tcpip/] [current/] [include/] [lwip/] [snmp_structs.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/**
2
 * @file
3
 * 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
 
42
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
43
 
44
#include "lwip/snmp.h"
45
 
46
#if SNMP_PRIVATE_MIB
47
#include "private_mib.h"
48
#endif
49
 
50
#ifdef __cplusplus
51
extern "C" {
52
#endif
53
 
54
/* MIB object instance */
55
#define MIB_OBJECT_NONE 0 
56
#define MIB_OBJECT_SCALAR 1
57
#define MIB_OBJECT_TAB 2
58
 
59
/* MIB object access */
60
#define MIB_OBJECT_READ_ONLY 0
61
#define MIB_OBJECT_READ_WRITE 1
62
#define MIB_OBJECT_WRITE_ONLY 2
63
#define MIB_OBJECT_NOT_ACCESSIBLE 3
64
 
65
/** object definition returned by (get_object_def)() */
66
struct obj_def
67
{
68
  /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */
69
  u8_t instance;
70
  /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */
71
  u8_t access;
72
  /* ASN type for this object */
73
  u8_t asn_type;
74
  /* value length (host length) */
75
  u16_t v_len;
76
  /* length of instance part of supplied object identifier */
77
  u8_t  id_inst_len;
78
  /* instance part of supplied object identifier */
79
  s32_t *id_inst_ptr;
80
};
81
 
82
struct snmp_name_ptr
83
{
84
  u8_t ident_len;
85
  s32_t *ident;
86
};
87
 
88
/** MIB const scalar (.0) node */
89
#define MIB_NODE_SC 0x01
90
/** MIB const array node */
91
#define MIB_NODE_AR 0x02
92
/** MIB array node (mem_malloced from RAM) */
93
#define MIB_NODE_RA 0x03
94
/** MIB list root node (mem_malloced from RAM) */
95
#define MIB_NODE_LR 0x04
96
/** MIB node for external objects */
97
#define MIB_NODE_EX 0x05
98
 
99
/** node "base class" layout, the mandatory fields for a node  */
100
struct mib_node
101
{
102
  /** returns struct obj_def for the given object identifier */
103
  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
104
  /** returns object value for the given object identifier,
105
     @note the caller must allocate at least len bytes for the value */
106
  void (*get_value)(struct obj_def *od, u16_t len, void *value);
107
  /** tests length and/or range BEFORE setting */
108
  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
109
  /** sets object value, only to be called when set_test()  */
110
  void (*set_value)(struct obj_def *od, u16_t len, void *value);
111
  /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */
112
  const u8_t node_type;
113
  /* array or max list length */
114
  const u16_t maxlength;
115
};
116
 
117
/** derived node for scalars .0 index */
118
typedef struct mib_node mib_scalar_node;
119
 
120
/** derived node, points to a fixed size const array
121
    of sub-identifiers plus a 'child' pointer */
122
struct mib_array_node
123
{
124
  /* inherited "base class" members */
125
  void (* const get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
126
  void (* const get_value)(struct obj_def *od, u16_t len, void *value);
127
  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
128
  void (*set_value)(struct obj_def *od, u16_t len, void *value);
129
 
130
  const u8_t node_type;
131
  const u16_t maxlength;
132
 
133
  /* aditional struct members */
134
  const s32_t *objid;
135
  struct mib_node* const *nptr;
136
};
137
 
138
/** derived node, points to a fixed size mem_malloced array
139
    of sub-identifiers plus a 'child' pointer */
140
struct mib_ram_array_node
141
{
142
  /* inherited "base class" members */
143
  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
144
  void (*get_value)(struct obj_def *od, u16_t len, void *value);
145
  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
146
  void (*set_value)(struct obj_def *od, u16_t len, void *value);
147
 
148
  u8_t node_type;
149
  u16_t maxlength;
150
 
151
  /* aditional struct members */
152
  s32_t *objid;
153
  struct mib_node **nptr;
154
};
155
 
156
struct mib_list_node
157
{
158
  struct mib_list_node *prev;
159
  struct mib_list_node *next;
160
  s32_t objid;
161
  struct mib_node *nptr;
162
};
163
 
164
/** derived node, points to a doubly linked list
165
    of sub-identifiers plus a 'child' pointer */
166
struct mib_list_rootnode
167
{
168
  /* inherited "base class" members */
169
  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
170
  void (*get_value)(struct obj_def *od, u16_t len, void *value);
171
  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
172
  void (*set_value)(struct obj_def *od, u16_t len, void *value);
173
 
174
  u8_t node_type;
175
  u16_t maxlength;
176
 
177
  /* aditional struct members */
178
  struct mib_list_node *head;
179
  struct mib_list_node *tail;
180
  /* counts list nodes in list  */
181
  u16_t count;
182
};
183
 
184
/** derived node, has access functions for mib object in external memory or device
185
    using 'tree_level' and 'idx', with a range 0 .. (level_length() - 1) */
186
struct mib_external_node
187
{
188
  /* inherited "base class" members */
189
  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
190
  void (*get_value)(struct obj_def *od, u16_t len, void *value);
191
  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
192
  void (*set_value)(struct obj_def *od, u16_t len, void *value);
193
 
194
  u8_t node_type;
195
  u16_t maxlength;
196
 
197
  /* aditional struct members */
198
  /** points to an extenal (in memory) record of some sort of addressing
199
      information, passed to and interpreted by the funtions below */
200
  void* addr_inf;
201
  /** tree levels under this node */
202
  u8_t tree_levels;
203
  /** number of objects at this level */
204
  u16_t (*level_length)(void* addr_inf, u8_t level);
205
  /** compares object sub identifier with external id
206
      return zero when equal, nonzero when unequal */
207
  s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id);
208
  void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id);
209
 
210
  /** async Questions */
211
  void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident);
212
  void (*get_value_q)(u8_t rid, struct obj_def *od);
213
  void (*set_test_q)(u8_t rid, struct obj_def *od);
214
  void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value);
215
  /** async Answers */
216
  void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od);
217
  void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
218
  u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
219
  void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
220
  /** async Panic Close (agent returns error reply,
221
      e.g. used for external transaction cleanup) */
222
  void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident);
223
  void (*get_value_pc)(u8_t rid, struct obj_def *od);
224
  void (*set_test_pc)(u8_t rid, struct obj_def *od);
225
  void (*set_value_pc)(u8_t rid, struct obj_def *od);
226
};
227
 
228
/** export MIB tree from mib2.c */
229
extern const struct mib_array_node internet;
230
 
231
/** dummy function pointers for non-leaf MIB nodes from mib2.c */
232
void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
233
void noleafs_get_value(struct obj_def *od, u16_t len, void *value);
234
u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value);
235
void noleafs_set_value(struct obj_def *od, u16_t len, void *value);
236
 
237
void snmp_oidtoip(s32_t *ident, struct ip_addr *ip);
238
void snmp_iptooid(struct ip_addr *ip, s32_t *ident);
239
void snmp_ifindextonetif(s32_t ifindex, struct netif **netif);
240
void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx);
241
 
242
struct mib_list_node* snmp_mib_ln_alloc(s32_t id);
243
void snmp_mib_ln_free(struct mib_list_node *ln);
244
struct mib_list_rootnode* snmp_mib_lrn_alloc(void);
245
void snmp_mib_lrn_free(struct mib_list_rootnode *lrn);
246
 
247
s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn);
248
s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn);
249
struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n);
250
 
251
struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np);
252
struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
253
u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
254
u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
255
 
256
#ifdef __cplusplus
257
}
258
#endif
259
 
260
#endif /* LWIP_SNMP */
261
 
262
#endif /* __LWIP_SNMP_STRUCTS_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.