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
nxpfan 0:075157567b0c 33 #ifndef __LWIP_PBUF_H__
nxpfan 0:075157567b0c 34 #define __LWIP_PBUF_H__
nxpfan 0:075157567b0c 35
nxpfan 0:075157567b0c 36 #include "lwip/opt.h"
nxpfan 0:075157567b0c 37 #include "lwip/err.h"
nxpfan 0:075157567b0c 38
nxpfan 0:075157567b0c 39 #ifdef __cplusplus
nxpfan 0:075157567b0c 40 extern "C" {
nxpfan 0:075157567b0c 41 #endif
nxpfan 0:075157567b0c 42
nxpfan 0:075157567b0c 43 /* Currently, the pbuf_custom code is only needed for one specific configuration
nxpfan 0:075157567b0c 44 * of IP_FRAG */
nxpfan 0:075157567b0c 45 #define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
nxpfan 0:075157567b0c 46
nxpfan 0:075157567b0c 47 #define PBUF_TRANSPORT_HLEN 20
nxpfan 0:075157567b0c 48 #define PBUF_IP_HLEN 20
nxpfan 0:075157567b0c 49
nxpfan 0:075157567b0c 50 typedef enum {
nxpfan 0:075157567b0c 51 PBUF_TRANSPORT,
nxpfan 0:075157567b0c 52 PBUF_IP,
nxpfan 0:075157567b0c 53 PBUF_LINK,
nxpfan 0:075157567b0c 54 PBUF_RAW
nxpfan 0:075157567b0c 55 } pbuf_layer;
nxpfan 0:075157567b0c 56
nxpfan 0:075157567b0c 57 typedef enum {
nxpfan 0:075157567b0c 58 PBUF_RAM, /* pbuf data is stored in RAM */
nxpfan 0:075157567b0c 59 PBUF_ROM, /* pbuf data is stored in ROM */
nxpfan 0:075157567b0c 60 PBUF_REF, /* pbuf comes from the pbuf pool */
nxpfan 0:075157567b0c 61 PBUF_POOL /* pbuf payload refers to RAM */
nxpfan 0:075157567b0c 62 } pbuf_type;
nxpfan 0:075157567b0c 63
nxpfan 0:075157567b0c 64
nxpfan 0:075157567b0c 65 /* indicates this packet's data should be immediately passed to the application */
nxpfan 0:075157567b0c 66 #define PBUF_FLAG_PUSH 0x01U
nxpfan 0:075157567b0c 67 /* indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a
nxpfan 0:075157567b0c 68 a pbuf differently */
nxpfan 0:075157567b0c 69 #define PBUF_FLAG_IS_CUSTOM 0x02U
nxpfan 0:075157567b0c 70 /* indicates this pbuf is UDP multicast to be looped back */
nxpfan 0:075157567b0c 71 #define PBUF_FLAG_MCASTLOOP 0x04U
nxpfan 0:075157567b0c 72
nxpfan 0:075157567b0c 73 struct pbuf {
nxpfan 0:075157567b0c 74 /* next pbuf in singly linked pbuf chain */
nxpfan 0:075157567b0c 75 struct pbuf *next;
nxpfan 0:075157567b0c 76
nxpfan 0:075157567b0c 77 /* pointer to the actual data in the buffer */
nxpfan 0:075157567b0c 78 void *payload;
nxpfan 0:075157567b0c 79
nxpfan 0:075157567b0c 80 /**
nxpfan 0:075157567b0c 81 * total length of this buffer and all next buffers in chain
nxpfan 0:075157567b0c 82 * belonging to the same packet.
nxpfan 0:075157567b0c 83 *
nxpfan 0:075157567b0c 84 * For non-queue packet chains this is the invariant:
nxpfan 0:075157567b0c 85 * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
nxpfan 0:075157567b0c 86 */
nxpfan 0:075157567b0c 87 u16_t tot_len;
nxpfan 0:075157567b0c 88
nxpfan 0:075157567b0c 89 /* length of this buffer */
nxpfan 0:075157567b0c 90 u16_t len;
nxpfan 0:075157567b0c 91
nxpfan 0:075157567b0c 92 /* pbuf_type as u8_t instead of enum to save space */
nxpfan 0:075157567b0c 93 u8_t /*pbuf_type*/ type;
nxpfan 0:075157567b0c 94
nxpfan 0:075157567b0c 95 /* misc flags */
nxpfan 0:075157567b0c 96 u8_t flags;
nxpfan 0:075157567b0c 97
nxpfan 0:075157567b0c 98 /**
nxpfan 0:075157567b0c 99 * the reference count always equals the number of pointers
nxpfan 0:075157567b0c 100 * that refer to this pbuf. This can be pointers from an application,
nxpfan 0:075157567b0c 101 * the stack itself, or pbuf->next pointers from a chain.
nxpfan 0:075157567b0c 102 */
nxpfan 0:075157567b0c 103 u16_t ref;
nxpfan 0:075157567b0c 104 };
nxpfan 0:075157567b0c 105
nxpfan 0:075157567b0c 106 #if LWIP_SUPPORT_CUSTOM_PBUF
nxpfan 0:075157567b0c 107 /* Prototype for a function to free a custom pbuf */
nxpfan 0:075157567b0c 108 typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
nxpfan 0:075157567b0c 109
nxpfan 0:075157567b0c 110 /* A custom pbuf: like a pbuf, but following a function pointer to free it. */
nxpfan 0:075157567b0c 111 struct pbuf_custom {
nxpfan 0:075157567b0c 112 /* The actual pbuf */
nxpfan 0:075157567b0c 113 struct pbuf pbuf;
nxpfan 0:075157567b0c 114 /* This function is called when pbuf_free deallocates this pbuf(_custom) */
nxpfan 0:075157567b0c 115 pbuf_free_custom_fn custom_free_function;
nxpfan 0:075157567b0c 116 };
nxpfan 0:075157567b0c 117 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
nxpfan 0:075157567b0c 118
nxpfan 0:075157567b0c 119 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
nxpfan 0:075157567b0c 120 #define pbuf_init()
nxpfan 0:075157567b0c 121
nxpfan 0:075157567b0c 122 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
nxpfan 0:075157567b0c 123 #if LWIP_SUPPORT_CUSTOM_PBUF
nxpfan 0:075157567b0c 124 struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
nxpfan 0:075157567b0c 125 struct pbuf_custom *p, void *payload_mem,
nxpfan 0:075157567b0c 126 u16_t payload_mem_len);
nxpfan 0:075157567b0c 127 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
nxpfan 0:075157567b0c 128 void pbuf_realloc(struct pbuf *p, u16_t size);
nxpfan 0:075157567b0c 129 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
nxpfan 0:075157567b0c 130 void pbuf_ref(struct pbuf *p);
nxpfan 0:075157567b0c 131 u8_t pbuf_free(struct pbuf *p);
nxpfan 0:075157567b0c 132 u8_t pbuf_clen(struct pbuf *p);
nxpfan 0:075157567b0c 133 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
nxpfan 0:075157567b0c 134 void pbuf_chain(struct pbuf *head, struct pbuf *tail);
nxpfan 0:075157567b0c 135 struct pbuf *pbuf_dechain(struct pbuf *p);
nxpfan 0:075157567b0c 136 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
nxpfan 0:075157567b0c 137 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
nxpfan 0:075157567b0c 138 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
nxpfan 0:075157567b0c 139 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
nxpfan 0:075157567b0c 140 #if LWIP_CHECKSUM_ON_COPY
nxpfan 0:075157567b0c 141 err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
nxpfan 0:075157567b0c 142 u16_t len, u16_t *chksum);
nxpfan 0:075157567b0c 143 #endif /* LWIP_CHECKSUM_ON_COPY */
nxpfan 0:075157567b0c 144
nxpfan 0:075157567b0c 145 u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
nxpfan 0:075157567b0c 146 u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
nxpfan 0:075157567b0c 147 u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
nxpfan 0:075157567b0c 148 u16_t pbuf_strstr(struct pbuf* p, const char* substr);
nxpfan 0:075157567b0c 149
nxpfan 0:075157567b0c 150 #ifdef __cplusplus
nxpfan 0:075157567b0c 151 }
nxpfan 0:075157567b0c 152 #endif
nxpfan 0:075157567b0c 153
nxpfan 0:075157567b0c 154 #endif /* __LWIP_PBUF_H__ */