Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:48:09 2011 +0000
Revision:
0:850eacf3e945
revised fixed length to 178 bytes

Who changed what in which revision?

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