TwitterExample with newer library (2012Aug)

Dependencies:   EthernetNetIf HTTPClient mbed

Committer:
nxpfan
Date:
Wed Aug 29 03:50:19 2012 +0000
Revision:
0:075157567b0c
simple twitter example with newer library

Who changed what in which revision?

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