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 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
nxpfan 0:075157567b0c 3 * All rights reserved.
nxpfan 0:075157567b0c 4 *
nxpfan 0:075157567b0c 5 * Redistribution and use in source and binary forms, with or without modification,
nxpfan 0:075157567b0c 6 * are permitted provided that the following conditions are met:
nxpfan 0:075157567b0c 7 *
nxpfan 0:075157567b0c 8 * 1. Redistributions of source code must retain the above copyright notice,
nxpfan 0:075157567b0c 9 * this list of conditions and the following disclaimer.
nxpfan 0:075157567b0c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
nxpfan 0:075157567b0c 11 * this list of conditions and the following disclaimer in the documentation
nxpfan 0:075157567b0c 12 * and/or other materials provided with the distribution.
nxpfan 0:075157567b0c 13 * 3. The name of the author may not be used to endorse or promote products
nxpfan 0:075157567b0c 14 * derived from this software without specific prior written permission.
nxpfan 0:075157567b0c 15 *
nxpfan 0:075157567b0c 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
nxpfan 0:075157567b0c 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
nxpfan 0:075157567b0c 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
nxpfan 0:075157567b0c 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
nxpfan 0:075157567b0c 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
nxpfan 0:075157567b0c 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
nxpfan 0:075157567b0c 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
nxpfan 0:075157567b0c 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
nxpfan 0:075157567b0c 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
nxpfan 0:075157567b0c 25 * OF SUCH DAMAGE.
nxpfan 0:075157567b0c 26 *
nxpfan 0:075157567b0c 27 * This file is part of the lwIP TCP/IP stack.
nxpfan 0:075157567b0c 28 *
nxpfan 0:075157567b0c 29 * Author: Adam Dunkels <adam@sics.se>
nxpfan 0:075157567b0c 30 *
nxpfan 0:075157567b0c 31 */
nxpfan 0:075157567b0c 32 #ifndef __LWIP_STATS_H__
nxpfan 0:075157567b0c 33 #define __LWIP_STATS_H__
nxpfan 0:075157567b0c 34
nxpfan 0:075157567b0c 35 #include "lwip/opt.h"
nxpfan 0:075157567b0c 36
nxpfan 0:075157567b0c 37 #include "lwip/mem.h"
nxpfan 0:075157567b0c 38 #include "lwip/memp.h"
nxpfan 0:075157567b0c 39
nxpfan 0:075157567b0c 40 #ifdef __cplusplus
nxpfan 0:075157567b0c 41 extern "C" {
nxpfan 0:075157567b0c 42 #endif
nxpfan 0:075157567b0c 43
nxpfan 0:075157567b0c 44 #if LWIP_STATS
nxpfan 0:075157567b0c 45
nxpfan 0:075157567b0c 46 #ifndef LWIP_STATS_LARGE
nxpfan 0:075157567b0c 47 #define LWIP_STATS_LARGE 0
nxpfan 0:075157567b0c 48 #endif
nxpfan 0:075157567b0c 49
nxpfan 0:075157567b0c 50 #if LWIP_STATS_LARGE
nxpfan 0:075157567b0c 51 #define STAT_COUNTER u32_t
nxpfan 0:075157567b0c 52 #define STAT_COUNTER_F U32_F
nxpfan 0:075157567b0c 53 #else
nxpfan 0:075157567b0c 54 #define STAT_COUNTER u16_t
nxpfan 0:075157567b0c 55 #define STAT_COUNTER_F U16_F
nxpfan 0:075157567b0c 56 #endif
nxpfan 0:075157567b0c 57
nxpfan 0:075157567b0c 58 struct stats_proto {
nxpfan 0:075157567b0c 59 STAT_COUNTER xmit; /* Transmitted packets. */
nxpfan 0:075157567b0c 60 STAT_COUNTER recv; /* Received packets. */
nxpfan 0:075157567b0c 61 STAT_COUNTER fw; /* Forwarded packets. */
nxpfan 0:075157567b0c 62 STAT_COUNTER drop; /* Dropped packets. */
nxpfan 0:075157567b0c 63 STAT_COUNTER chkerr; /* Checksum error. */
nxpfan 0:075157567b0c 64 STAT_COUNTER lenerr; /* Invalid length error. */
nxpfan 0:075157567b0c 65 STAT_COUNTER memerr; /* Out of memory error. */
nxpfan 0:075157567b0c 66 STAT_COUNTER rterr; /* Routing error. */
nxpfan 0:075157567b0c 67 STAT_COUNTER proterr; /* Protocol error. */
nxpfan 0:075157567b0c 68 STAT_COUNTER opterr; /* Error in options. */
nxpfan 0:075157567b0c 69 STAT_COUNTER err; /* Misc error. */
nxpfan 0:075157567b0c 70 STAT_COUNTER cachehit;
nxpfan 0:075157567b0c 71 };
nxpfan 0:075157567b0c 72
nxpfan 0:075157567b0c 73 struct stats_igmp {
nxpfan 0:075157567b0c 74 STAT_COUNTER xmit; /* Transmitted packets. */
nxpfan 0:075157567b0c 75 STAT_COUNTER recv; /* Received packets. */
nxpfan 0:075157567b0c 76 STAT_COUNTER drop; /* Dropped packets. */
nxpfan 0:075157567b0c 77 STAT_COUNTER chkerr; /* Checksum error. */
nxpfan 0:075157567b0c 78 STAT_COUNTER lenerr; /* Invalid length error. */
nxpfan 0:075157567b0c 79 STAT_COUNTER memerr; /* Out of memory error. */
nxpfan 0:075157567b0c 80 STAT_COUNTER proterr; /* Protocol error. */
nxpfan 0:075157567b0c 81 STAT_COUNTER rx_v1; /* Received v1 frames. */
nxpfan 0:075157567b0c 82 STAT_COUNTER rx_group; /* Received group-specific queries. */
nxpfan 0:075157567b0c 83 STAT_COUNTER rx_general; /* Received general queries. */
nxpfan 0:075157567b0c 84 STAT_COUNTER rx_report; /* Received reports. */
nxpfan 0:075157567b0c 85 STAT_COUNTER tx_join; /* Sent joins. */
nxpfan 0:075157567b0c 86 STAT_COUNTER tx_leave; /* Sent leaves. */
nxpfan 0:075157567b0c 87 STAT_COUNTER tx_report; /* Sent reports. */
nxpfan 0:075157567b0c 88 };
nxpfan 0:075157567b0c 89
nxpfan 0:075157567b0c 90 struct stats_mem {
nxpfan 0:075157567b0c 91 #ifdef LWIP_DEBUG
nxpfan 0:075157567b0c 92 const char *name;
nxpfan 0:075157567b0c 93 #endif /* LWIP_DEBUG */
nxpfan 0:075157567b0c 94 mem_size_t avail;
nxpfan 0:075157567b0c 95 mem_size_t used;
nxpfan 0:075157567b0c 96 mem_size_t max;
nxpfan 0:075157567b0c 97 STAT_COUNTER err;
nxpfan 0:075157567b0c 98 STAT_COUNTER illegal;
nxpfan 0:075157567b0c 99 };
nxpfan 0:075157567b0c 100
nxpfan 0:075157567b0c 101 struct stats_syselem {
nxpfan 0:075157567b0c 102 STAT_COUNTER used;
nxpfan 0:075157567b0c 103 STAT_COUNTER max;
nxpfan 0:075157567b0c 104 STAT_COUNTER err;
nxpfan 0:075157567b0c 105 };
nxpfan 0:075157567b0c 106
nxpfan 0:075157567b0c 107 struct stats_sys {
nxpfan 0:075157567b0c 108 struct stats_syselem sem;
nxpfan 0:075157567b0c 109 struct stats_syselem mutex;
nxpfan 0:075157567b0c 110 struct stats_syselem mbox;
nxpfan 0:075157567b0c 111 };
nxpfan 0:075157567b0c 112
nxpfan 0:075157567b0c 113 struct stats_ {
nxpfan 0:075157567b0c 114 #if LINK_STATS
nxpfan 0:075157567b0c 115 struct stats_proto link;
nxpfan 0:075157567b0c 116 #endif
nxpfan 0:075157567b0c 117 #if ETHARP_STATS
nxpfan 0:075157567b0c 118 struct stats_proto etharp;
nxpfan 0:075157567b0c 119 #endif
nxpfan 0:075157567b0c 120 #if IPFRAG_STATS
nxpfan 0:075157567b0c 121 struct stats_proto ip_frag;
nxpfan 0:075157567b0c 122 #endif
nxpfan 0:075157567b0c 123 #if IP_STATS
nxpfan 0:075157567b0c 124 struct stats_proto ip;
nxpfan 0:075157567b0c 125 #endif
nxpfan 0:075157567b0c 126 #if ICMP_STATS
nxpfan 0:075157567b0c 127 struct stats_proto icmp;
nxpfan 0:075157567b0c 128 #endif
nxpfan 0:075157567b0c 129 #if IGMP_STATS
nxpfan 0:075157567b0c 130 struct stats_igmp igmp;
nxpfan 0:075157567b0c 131 #endif
nxpfan 0:075157567b0c 132 #if UDP_STATS
nxpfan 0:075157567b0c 133 struct stats_proto udp;
nxpfan 0:075157567b0c 134 #endif
nxpfan 0:075157567b0c 135 #if TCP_STATS
nxpfan 0:075157567b0c 136 struct stats_proto tcp;
nxpfan 0:075157567b0c 137 #endif
nxpfan 0:075157567b0c 138 #if MEM_STATS
nxpfan 0:075157567b0c 139 struct stats_mem mem;
nxpfan 0:075157567b0c 140 #endif
nxpfan 0:075157567b0c 141 #if MEMP_STATS
nxpfan 0:075157567b0c 142 struct stats_mem memp[MEMP_MAX];
nxpfan 0:075157567b0c 143 #endif
nxpfan 0:075157567b0c 144 #if SYS_STATS
nxpfan 0:075157567b0c 145 struct stats_sys sys;
nxpfan 0:075157567b0c 146 #endif
nxpfan 0:075157567b0c 147 };
nxpfan 0:075157567b0c 148
nxpfan 0:075157567b0c 149 extern struct stats_ lwip_stats;
nxpfan 0:075157567b0c 150
nxpfan 0:075157567b0c 151 void stats_init(void);
nxpfan 0:075157567b0c 152
nxpfan 0:075157567b0c 153 #define STATS_INC(x) ++lwip_stats.x
nxpfan 0:075157567b0c 154 #define STATS_DEC(x) --lwip_stats.x
nxpfan 0:075157567b0c 155 #define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \
nxpfan 0:075157567b0c 156 if (lwip_stats.x.max < lwip_stats.x.used) { \
nxpfan 0:075157567b0c 157 lwip_stats.x.max = lwip_stats.x.used; \
nxpfan 0:075157567b0c 158 } \
nxpfan 0:075157567b0c 159 } while(0)
nxpfan 0:075157567b0c 160 #else /* LWIP_STATS */
nxpfan 0:075157567b0c 161 #define stats_init()
nxpfan 0:075157567b0c 162 #define STATS_INC(x)
nxpfan 0:075157567b0c 163 #define STATS_DEC(x)
nxpfan 0:075157567b0c 164 #define STATS_INC_USED(x)
nxpfan 0:075157567b0c 165 #endif /* LWIP_STATS */
nxpfan 0:075157567b0c 166
nxpfan 0:075157567b0c 167 #if TCP_STATS
nxpfan 0:075157567b0c 168 #define TCP_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 169 #define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
nxpfan 0:075157567b0c 170 #else
nxpfan 0:075157567b0c 171 #define TCP_STATS_INC(x)
nxpfan 0:075157567b0c 172 #define TCP_STATS_DISPLAY()
nxpfan 0:075157567b0c 173 #endif
nxpfan 0:075157567b0c 174
nxpfan 0:075157567b0c 175 #if UDP_STATS
nxpfan 0:075157567b0c 176 #define UDP_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 177 #define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
nxpfan 0:075157567b0c 178 #else
nxpfan 0:075157567b0c 179 #define UDP_STATS_INC(x)
nxpfan 0:075157567b0c 180 #define UDP_STATS_DISPLAY()
nxpfan 0:075157567b0c 181 #endif
nxpfan 0:075157567b0c 182
nxpfan 0:075157567b0c 183 #if ICMP_STATS
nxpfan 0:075157567b0c 184 #define ICMP_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 185 #define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
nxpfan 0:075157567b0c 186 #else
nxpfan 0:075157567b0c 187 #define ICMP_STATS_INC(x)
nxpfan 0:075157567b0c 188 #define ICMP_STATS_DISPLAY()
nxpfan 0:075157567b0c 189 #endif
nxpfan 0:075157567b0c 190
nxpfan 0:075157567b0c 191 #if IGMP_STATS
nxpfan 0:075157567b0c 192 #define IGMP_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 193 #define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp)
nxpfan 0:075157567b0c 194 #else
nxpfan 0:075157567b0c 195 #define IGMP_STATS_INC(x)
nxpfan 0:075157567b0c 196 #define IGMP_STATS_DISPLAY()
nxpfan 0:075157567b0c 197 #endif
nxpfan 0:075157567b0c 198
nxpfan 0:075157567b0c 199 #if IP_STATS
nxpfan 0:075157567b0c 200 #define IP_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 201 #define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
nxpfan 0:075157567b0c 202 #else
nxpfan 0:075157567b0c 203 #define IP_STATS_INC(x)
nxpfan 0:075157567b0c 204 #define IP_STATS_DISPLAY()
nxpfan 0:075157567b0c 205 #endif
nxpfan 0:075157567b0c 206
nxpfan 0:075157567b0c 207 #if IPFRAG_STATS
nxpfan 0:075157567b0c 208 #define IPFRAG_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 209 #define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
nxpfan 0:075157567b0c 210 #else
nxpfan 0:075157567b0c 211 #define IPFRAG_STATS_INC(x)
nxpfan 0:075157567b0c 212 #define IPFRAG_STATS_DISPLAY()
nxpfan 0:075157567b0c 213 #endif
nxpfan 0:075157567b0c 214
nxpfan 0:075157567b0c 215 #if ETHARP_STATS
nxpfan 0:075157567b0c 216 #define ETHARP_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 217 #define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
nxpfan 0:075157567b0c 218 #else
nxpfan 0:075157567b0c 219 #define ETHARP_STATS_INC(x)
nxpfan 0:075157567b0c 220 #define ETHARP_STATS_DISPLAY()
nxpfan 0:075157567b0c 221 #endif
nxpfan 0:075157567b0c 222
nxpfan 0:075157567b0c 223 #if LINK_STATS
nxpfan 0:075157567b0c 224 #define LINK_STATS_INC(x) STATS_INC(x)
nxpfan 0:075157567b0c 225 #define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
nxpfan 0:075157567b0c 226 #else
nxpfan 0:075157567b0c 227 #define LINK_STATS_INC(x)
nxpfan 0:075157567b0c 228 #define LINK_STATS_DISPLAY()
nxpfan 0:075157567b0c 229 #endif
nxpfan 0:075157567b0c 230
nxpfan 0:075157567b0c 231 #if MEM_STATS
nxpfan 0:075157567b0c 232 #define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
nxpfan 0:075157567b0c 233 #define MEM_STATS_INC(x) STATS_INC(mem.x)
nxpfan 0:075157567b0c 234 #define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y)
nxpfan 0:075157567b0c 235 #define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
nxpfan 0:075157567b0c 236 #define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
nxpfan 0:075157567b0c 237 #else
nxpfan 0:075157567b0c 238 #define MEM_STATS_AVAIL(x, y)
nxpfan 0:075157567b0c 239 #define MEM_STATS_INC(x)
nxpfan 0:075157567b0c 240 #define MEM_STATS_INC_USED(x, y)
nxpfan 0:075157567b0c 241 #define MEM_STATS_DEC_USED(x, y)
nxpfan 0:075157567b0c 242 #define MEM_STATS_DISPLAY()
nxpfan 0:075157567b0c 243 #endif
nxpfan 0:075157567b0c 244
nxpfan 0:075157567b0c 245 #if MEMP_STATS
nxpfan 0:075157567b0c 246 #define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
nxpfan 0:075157567b0c 247 #define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
nxpfan 0:075157567b0c 248 #define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
nxpfan 0:075157567b0c 249 #define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1)
nxpfan 0:075157567b0c 250 #define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
nxpfan 0:075157567b0c 251 #else
nxpfan 0:075157567b0c 252 #define MEMP_STATS_AVAIL(x, i, y)
nxpfan 0:075157567b0c 253 #define MEMP_STATS_INC(x, i)
nxpfan 0:075157567b0c 254 #define MEMP_STATS_DEC(x, i)
nxpfan 0:075157567b0c 255 #define MEMP_STATS_INC_USED(x, i)
nxpfan 0:075157567b0c 256 #define MEMP_STATS_DISPLAY(i)
nxpfan 0:075157567b0c 257 #endif
nxpfan 0:075157567b0c 258
nxpfan 0:075157567b0c 259 #if SYS_STATS
nxpfan 0:075157567b0c 260 #define SYS_STATS_INC(x) STATS_INC(sys.x)
nxpfan 0:075157567b0c 261 #define SYS_STATS_DEC(x) STATS_DEC(sys.x)
nxpfan 0:075157567b0c 262 #define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1)
nxpfan 0:075157567b0c 263 #define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
nxpfan 0:075157567b0c 264 #else
nxpfan 0:075157567b0c 265 #define SYS_STATS_INC(x)
nxpfan 0:075157567b0c 266 #define SYS_STATS_DEC(x)
nxpfan 0:075157567b0c 267 #define SYS_STATS_INC_USED(x)
nxpfan 0:075157567b0c 268 #define SYS_STATS_DISPLAY()
nxpfan 0:075157567b0c 269 #endif
nxpfan 0:075157567b0c 270
nxpfan 0:075157567b0c 271 /* Display of statistics */
nxpfan 0:075157567b0c 272 #if LWIP_STATS_DISPLAY
nxpfan 0:075157567b0c 273 void stats_display(void);
nxpfan 0:075157567b0c 274 void stats_display_proto(struct stats_proto *proto, char *name);
nxpfan 0:075157567b0c 275 void stats_display_igmp(struct stats_igmp *igmp);
nxpfan 0:075157567b0c 276 void stats_display_mem(struct stats_mem *mem, char *name);
nxpfan 0:075157567b0c 277 void stats_display_memp(struct stats_mem *mem, int index);
nxpfan 0:075157567b0c 278 void stats_display_sys(struct stats_sys *sys);
nxpfan 0:075157567b0c 279 #else /* LWIP_STATS_DISPLAY */
nxpfan 0:075157567b0c 280 #define stats_display()
nxpfan 0:075157567b0c 281 #define stats_display_proto(proto, name)
nxpfan 0:075157567b0c 282 #define stats_display_igmp(igmp)
nxpfan 0:075157567b0c 283 #define stats_display_mem(mem, name)
nxpfan 0:075157567b0c 284 #define stats_display_memp(mem, index)
nxpfan 0:075157567b0c 285 #define stats_display_sys(sys)
nxpfan 0:075157567b0c 286 #endif /* LWIP_STATS_DISPLAY */
nxpfan 0:075157567b0c 287
nxpfan 0:075157567b0c 288 #ifdef __cplusplus
nxpfan 0:075157567b0c 289 }
nxpfan 0:075157567b0c 290 #endif
nxpfan 0:075157567b0c 291
nxpfan 0:075157567b0c 292 #endif /* __LWIP_STATS_H__ */