mbed Phone Platform

Dependencies:   ulaw mbed ConfigFile

Committer:
okini3939
Date:
Sun Dec 26 15:49:07 2010 +0000
Revision:
1:0f82c574096f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 1:0f82c574096f 1 /**
okini3939 1:0f82c574096f 2 * @file
okini3939 1:0f82c574096f 3 * Generic MIB tree structures.
okini3939 1:0f82c574096f 4 *
okini3939 1:0f82c574096f 5 * @todo namespace prefixes
okini3939 1:0f82c574096f 6 */
okini3939 1:0f82c574096f 7
okini3939 1:0f82c574096f 8 /*
okini3939 1:0f82c574096f 9 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
okini3939 1:0f82c574096f 10 * All rights reserved.
okini3939 1:0f82c574096f 11 *
okini3939 1:0f82c574096f 12 * Redistribution and use in source and binary forms, with or without modification,
okini3939 1:0f82c574096f 13 * are permitted provided that the following conditions are met:
okini3939 1:0f82c574096f 14 *
okini3939 1:0f82c574096f 15 * 1. Redistributions of source code must retain the above copyright notice,
okini3939 1:0f82c574096f 16 * this list of conditions and the following disclaimer.
okini3939 1:0f82c574096f 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
okini3939 1:0f82c574096f 18 * this list of conditions and the following disclaimer in the documentation
okini3939 1:0f82c574096f 19 * and/or other materials provided with the distribution.
okini3939 1:0f82c574096f 20 * 3. The name of the author may not be used to endorse or promote products
okini3939 1:0f82c574096f 21 * derived from this software without specific prior written permission.
okini3939 1:0f82c574096f 22 *
okini3939 1:0f82c574096f 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
okini3939 1:0f82c574096f 24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
okini3939 1:0f82c574096f 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
okini3939 1:0f82c574096f 26 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
okini3939 1:0f82c574096f 27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
okini3939 1:0f82c574096f 28 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
okini3939 1:0f82c574096f 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
okini3939 1:0f82c574096f 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
okini3939 1:0f82c574096f 31 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
okini3939 1:0f82c574096f 32 * OF SUCH DAMAGE.
okini3939 1:0f82c574096f 33 *
okini3939 1:0f82c574096f 34 * Author: Christiaan Simons <christiaan.simons@axon.tv>
okini3939 1:0f82c574096f 35 */
okini3939 1:0f82c574096f 36
okini3939 1:0f82c574096f 37 #ifndef __LWIP_SNMP_STRUCTS_H__
okini3939 1:0f82c574096f 38 #define __LWIP_SNMP_STRUCTS_H__
okini3939 1:0f82c574096f 39
okini3939 1:0f82c574096f 40 #include "lwip/opt.h"
okini3939 1:0f82c574096f 41
okini3939 1:0f82c574096f 42 #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
okini3939 1:0f82c574096f 43
okini3939 1:0f82c574096f 44 #include "lwip/snmp.h"
okini3939 1:0f82c574096f 45
okini3939 1:0f82c574096f 46 #if SNMP_PRIVATE_MIB
okini3939 1:0f82c574096f 47 /* When using a private MIB, you have to create a file 'private_mib.h' that contains
okini3939 1:0f82c574096f 48 * a 'struct mib_array_node mib_private' which contains your MIB. */
okini3939 1:0f82c574096f 49 #include "private_mib.h"
okini3939 1:0f82c574096f 50 #endif
okini3939 1:0f82c574096f 51
okini3939 1:0f82c574096f 52 #ifdef __cplusplus
okini3939 1:0f82c574096f 53 extern "C" {
okini3939 1:0f82c574096f 54 #endif
okini3939 1:0f82c574096f 55
okini3939 1:0f82c574096f 56 /* MIB object instance */
okini3939 1:0f82c574096f 57 #define MIB_OBJECT_NONE 0
okini3939 1:0f82c574096f 58 #define MIB_OBJECT_SCALAR 1
okini3939 1:0f82c574096f 59 #define MIB_OBJECT_TAB 2
okini3939 1:0f82c574096f 60
okini3939 1:0f82c574096f 61 /* MIB access types */
okini3939 1:0f82c574096f 62 #define MIB_ACCESS_READ 1
okini3939 1:0f82c574096f 63 #define MIB_ACCESS_WRITE 2
okini3939 1:0f82c574096f 64
okini3939 1:0f82c574096f 65 /* MIB object access */
okini3939 1:0f82c574096f 66 #define MIB_OBJECT_READ_ONLY MIB_ACCESS_READ
okini3939 1:0f82c574096f 67 #define MIB_OBJECT_READ_WRITE (MIB_ACCESS_READ | MIB_ACCESS_WRITE)
okini3939 1:0f82c574096f 68 #define MIB_OBJECT_WRITE_ONLY MIB_ACCESS_WRITE
okini3939 1:0f82c574096f 69 #define MIB_OBJECT_NOT_ACCESSIBLE 0
okini3939 1:0f82c574096f 70
okini3939 1:0f82c574096f 71 /** object definition returned by (get_object_def)() */
okini3939 1:0f82c574096f 72 struct obj_def
okini3939 1:0f82c574096f 73 {
okini3939 1:0f82c574096f 74 /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */
okini3939 1:0f82c574096f 75 u8_t instance;
okini3939 1:0f82c574096f 76 /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */
okini3939 1:0f82c574096f 77 u8_t access;
okini3939 1:0f82c574096f 78 /* ASN type for this object */
okini3939 1:0f82c574096f 79 u8_t asn_type;
okini3939 1:0f82c574096f 80 /* value length (host length) */
okini3939 1:0f82c574096f 81 u16_t v_len;
okini3939 1:0f82c574096f 82 /* length of instance part of supplied object identifier */
okini3939 1:0f82c574096f 83 u8_t id_inst_len;
okini3939 1:0f82c574096f 84 /* instance part of supplied object identifier */
okini3939 1:0f82c574096f 85 s32_t *id_inst_ptr;
okini3939 1:0f82c574096f 86 };
okini3939 1:0f82c574096f 87
okini3939 1:0f82c574096f 88 struct snmp_name_ptr
okini3939 1:0f82c574096f 89 {
okini3939 1:0f82c574096f 90 u8_t ident_len;
okini3939 1:0f82c574096f 91 s32_t *ident;
okini3939 1:0f82c574096f 92 };
okini3939 1:0f82c574096f 93
okini3939 1:0f82c574096f 94 /** MIB const scalar (.0) node */
okini3939 1:0f82c574096f 95 #define MIB_NODE_SC 0x01
okini3939 1:0f82c574096f 96 /** MIB const array node */
okini3939 1:0f82c574096f 97 #define MIB_NODE_AR 0x02
okini3939 1:0f82c574096f 98 /** MIB array node (mem_malloced from RAM) */
okini3939 1:0f82c574096f 99 #define MIB_NODE_RA 0x03
okini3939 1:0f82c574096f 100 /** MIB list root node (mem_malloced from RAM) */
okini3939 1:0f82c574096f 101 #define MIB_NODE_LR 0x04
okini3939 1:0f82c574096f 102 /** MIB node for external objects */
okini3939 1:0f82c574096f 103 #define MIB_NODE_EX 0x05
okini3939 1:0f82c574096f 104
okini3939 1:0f82c574096f 105 /** node "base class" layout, the mandatory fields for a node */
okini3939 1:0f82c574096f 106 struct mib_node
okini3939 1:0f82c574096f 107 {
okini3939 1:0f82c574096f 108 /** returns struct obj_def for the given object identifier */
okini3939 1:0f82c574096f 109 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 110 /** returns object value for the given object identifier,
okini3939 1:0f82c574096f 111 @note the caller must allocate at least len bytes for the value */
okini3939 1:0f82c574096f 112 void (*get_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 113 /** tests length and/or range BEFORE setting */
okini3939 1:0f82c574096f 114 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 115 /** sets object value, only to be called when set_test() */
okini3939 1:0f82c574096f 116 void (*set_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 117 /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */
okini3939 1:0f82c574096f 118 u8_t node_type;
okini3939 1:0f82c574096f 119 /* array or max list length */
okini3939 1:0f82c574096f 120 u16_t maxlength;
okini3939 1:0f82c574096f 121 };
okini3939 1:0f82c574096f 122
okini3939 1:0f82c574096f 123 /** derived node for scalars .0 index */
okini3939 1:0f82c574096f 124 typedef struct mib_node mib_scalar_node;
okini3939 1:0f82c574096f 125
okini3939 1:0f82c574096f 126 /** derived node, points to a fixed size const array
okini3939 1:0f82c574096f 127 of sub-identifiers plus a 'child' pointer */
okini3939 1:0f82c574096f 128 struct mib_array_node
okini3939 1:0f82c574096f 129 {
okini3939 1:0f82c574096f 130 /* inherited "base class" members */
okini3939 1:0f82c574096f 131 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 132 void (*get_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 133 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 134 void (*set_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 135
okini3939 1:0f82c574096f 136 u8_t node_type;
okini3939 1:0f82c574096f 137 u16_t maxlength;
okini3939 1:0f82c574096f 138
okini3939 1:0f82c574096f 139 /* additional struct members */
okini3939 1:0f82c574096f 140 const s32_t *objid;
okini3939 1:0f82c574096f 141 struct mib_node* const *nptr;
okini3939 1:0f82c574096f 142 };
okini3939 1:0f82c574096f 143
okini3939 1:0f82c574096f 144 /** derived node, points to a fixed size mem_malloced array
okini3939 1:0f82c574096f 145 of sub-identifiers plus a 'child' pointer */
okini3939 1:0f82c574096f 146 struct mib_ram_array_node
okini3939 1:0f82c574096f 147 {
okini3939 1:0f82c574096f 148 /* inherited "base class" members */
okini3939 1:0f82c574096f 149 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 150 void (*get_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 151 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 152 void (*set_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 153
okini3939 1:0f82c574096f 154 u8_t node_type;
okini3939 1:0f82c574096f 155 u16_t maxlength;
okini3939 1:0f82c574096f 156
okini3939 1:0f82c574096f 157 /* aditional struct members */
okini3939 1:0f82c574096f 158 s32_t *objid;
okini3939 1:0f82c574096f 159 struct mib_node **nptr;
okini3939 1:0f82c574096f 160 };
okini3939 1:0f82c574096f 161
okini3939 1:0f82c574096f 162 struct mib_list_node
okini3939 1:0f82c574096f 163 {
okini3939 1:0f82c574096f 164 struct mib_list_node *prev;
okini3939 1:0f82c574096f 165 struct mib_list_node *next;
okini3939 1:0f82c574096f 166 s32_t objid;
okini3939 1:0f82c574096f 167 struct mib_node *nptr;
okini3939 1:0f82c574096f 168 };
okini3939 1:0f82c574096f 169
okini3939 1:0f82c574096f 170 /** derived node, points to a doubly linked list
okini3939 1:0f82c574096f 171 of sub-identifiers plus a 'child' pointer */
okini3939 1:0f82c574096f 172 struct mib_list_rootnode
okini3939 1:0f82c574096f 173 {
okini3939 1:0f82c574096f 174 /* inherited "base class" members */
okini3939 1:0f82c574096f 175 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 176 void (*get_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 177 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 178 void (*set_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 179
okini3939 1:0f82c574096f 180 u8_t node_type;
okini3939 1:0f82c574096f 181 u16_t maxlength;
okini3939 1:0f82c574096f 182
okini3939 1:0f82c574096f 183 /* additional struct members */
okini3939 1:0f82c574096f 184 struct mib_list_node *head;
okini3939 1:0f82c574096f 185 struct mib_list_node *tail;
okini3939 1:0f82c574096f 186 /* counts list nodes in list */
okini3939 1:0f82c574096f 187 u16_t count;
okini3939 1:0f82c574096f 188 };
okini3939 1:0f82c574096f 189
okini3939 1:0f82c574096f 190 /** derived node, has access functions for mib object in external memory or device
okini3939 1:0f82c574096f 191 using 'tree_level' and 'idx', with a range 0 .. (level_length() - 1) */
okini3939 1:0f82c574096f 192 struct mib_external_node
okini3939 1:0f82c574096f 193 {
okini3939 1:0f82c574096f 194 /* inherited "base class" members */
okini3939 1:0f82c574096f 195 void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 196 void (*get_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 197 u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 198 void (*set_value)(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 199
okini3939 1:0f82c574096f 200 u8_t node_type;
okini3939 1:0f82c574096f 201 u16_t maxlength;
okini3939 1:0f82c574096f 202
okini3939 1:0f82c574096f 203 /* additional struct members */
okini3939 1:0f82c574096f 204 /** points to an external (in memory) record of some sort of addressing
okini3939 1:0f82c574096f 205 information, passed to and interpreted by the funtions below */
okini3939 1:0f82c574096f 206 void* addr_inf;
okini3939 1:0f82c574096f 207 /** tree levels under this node */
okini3939 1:0f82c574096f 208 u8_t tree_levels;
okini3939 1:0f82c574096f 209 /** number of objects at this level */
okini3939 1:0f82c574096f 210 u16_t (*level_length)(void* addr_inf, u8_t level);
okini3939 1:0f82c574096f 211 /** compares object sub identifier with external id
okini3939 1:0f82c574096f 212 return zero when equal, nonzero when unequal */
okini3939 1:0f82c574096f 213 s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id);
okini3939 1:0f82c574096f 214 void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id);
okini3939 1:0f82c574096f 215
okini3939 1:0f82c574096f 216 /** async Questions */
okini3939 1:0f82c574096f 217 void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident);
okini3939 1:0f82c574096f 218 void (*get_value_q)(u8_t rid, struct obj_def *od);
okini3939 1:0f82c574096f 219 void (*set_test_q)(u8_t rid, struct obj_def *od);
okini3939 1:0f82c574096f 220 void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 221 /** async Answers */
okini3939 1:0f82c574096f 222 void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 223 void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 224 u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 225 void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 226 /** async Panic Close (agent returns error reply,
okini3939 1:0f82c574096f 227 e.g. used for external transaction cleanup) */
okini3939 1:0f82c574096f 228 void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident);
okini3939 1:0f82c574096f 229 void (*get_value_pc)(u8_t rid, struct obj_def *od);
okini3939 1:0f82c574096f 230 void (*set_test_pc)(u8_t rid, struct obj_def *od);
okini3939 1:0f82c574096f 231 void (*set_value_pc)(u8_t rid, struct obj_def *od);
okini3939 1:0f82c574096f 232 };
okini3939 1:0f82c574096f 233
okini3939 1:0f82c574096f 234 /** export MIB tree from mib2.c */
okini3939 1:0f82c574096f 235 extern const struct mib_array_node internet;
okini3939 1:0f82c574096f 236
okini3939 1:0f82c574096f 237 /** dummy function pointers for non-leaf MIB nodes from mib2.c */
okini3939 1:0f82c574096f 238 void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
okini3939 1:0f82c574096f 239 void noleafs_get_value(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 240 u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 241 void noleafs_set_value(struct obj_def *od, u16_t len, void *value);
okini3939 1:0f82c574096f 242
okini3939 1:0f82c574096f 243 void snmp_oidtoip(s32_t *ident, ip_addr_t *ip);
okini3939 1:0f82c574096f 244 void snmp_iptooid(ip_addr_t *ip, s32_t *ident);
okini3939 1:0f82c574096f 245 void snmp_ifindextonetif(s32_t ifindex, struct netif **netif);
okini3939 1:0f82c574096f 246 void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx);
okini3939 1:0f82c574096f 247
okini3939 1:0f82c574096f 248 struct mib_list_node* snmp_mib_ln_alloc(s32_t id);
okini3939 1:0f82c574096f 249 void snmp_mib_ln_free(struct mib_list_node *ln);
okini3939 1:0f82c574096f 250 struct mib_list_rootnode* snmp_mib_lrn_alloc(void);
okini3939 1:0f82c574096f 251 void snmp_mib_lrn_free(struct mib_list_rootnode *lrn);
okini3939 1:0f82c574096f 252
okini3939 1:0f82c574096f 253 s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn);
okini3939 1:0f82c574096f 254 s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn);
okini3939 1:0f82c574096f 255 struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n);
okini3939 1:0f82c574096f 256
okini3939 1:0f82c574096f 257 struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np);
okini3939 1:0f82c574096f 258 struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
okini3939 1:0f82c574096f 259 u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
okini3939 1:0f82c574096f 260 u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
okini3939 1:0f82c574096f 261
okini3939 1:0f82c574096f 262 #ifdef __cplusplus
okini3939 1:0f82c574096f 263 }
okini3939 1:0f82c574096f 264 #endif
okini3939 1:0f82c574096f 265
okini3939 1:0f82c574096f 266 #endif /* LWIP_SNMP */
okini3939 1:0f82c574096f 267
okini3939 1:0f82c574096f 268 #endif /* __LWIP_SNMP_STRUCTS_H__ */