Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

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