Program the control the fischertechnik robo interface or intelligent interface via tcp socket or via a java gui.

Dependencies:   mbed ConfigFile

Committer:
networker
Date:
Fri Dec 31 14:01:14 2010 +0000
Revision:
0:7f26f0680202
initial release: comprises ftlib (no usb), ft-over-ip socket server, and the http server (the html page and java jar I still have to publish somewhere)

Who changed what in which revision?

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