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 * ppp_oe.h - PPP Over Ethernet implementation for lwIP.
nxpfan 0:075157567b0c 3 *
nxpfan 0:075157567b0c 4 * Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
nxpfan 0:075157567b0c 5 *
nxpfan 0:075157567b0c 6 * The authors hereby grant permission to use, copy, modify, distribute,
nxpfan 0:075157567b0c 7 * and license this software and its documentation for any purpose, provided
nxpfan 0:075157567b0c 8 * that existing copyright notices are retained in all copies and that this
nxpfan 0:075157567b0c 9 * notice and the following disclaimer are included verbatim in any
nxpfan 0:075157567b0c 10 * distributions. No written agreement, license, or royalty fee is required
nxpfan 0:075157567b0c 11 * for any of the authorized uses.
nxpfan 0:075157567b0c 12 *
nxpfan 0:075157567b0c 13 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
nxpfan 0:075157567b0c 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
nxpfan 0:075157567b0c 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
nxpfan 0:075157567b0c 16 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
nxpfan 0:075157567b0c 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
nxpfan 0:075157567b0c 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nxpfan 0:075157567b0c 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nxpfan 0:075157567b0c 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nxpfan 0:075157567b0c 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
nxpfan 0:075157567b0c 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nxpfan 0:075157567b0c 23 *
nxpfan 0:075157567b0c 24 ******************************************************************************
nxpfan 0:075157567b0c 25 * REVISION HISTORY
nxpfan 0:075157567b0c 26 *
nxpfan 0:075157567b0c 27 * 06-01-01 Marc Boucher <marc@mbsi.ca>
nxpfan 0:075157567b0c 28 * Ported to lwIP.
nxpfan 0:075157567b0c 29 *****************************************************************************/
nxpfan 0:075157567b0c 30
nxpfan 0:075157567b0c 31
nxpfan 0:075157567b0c 32
nxpfan 0:075157567b0c 33 /* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
nxpfan 0:075157567b0c 34
nxpfan 0:075157567b0c 35 /*-
nxpfan 0:075157567b0c 36 * Copyright (c) 2002 The NetBSD Foundation, Inc.
nxpfan 0:075157567b0c 37 * All rights reserved.
nxpfan 0:075157567b0c 38 *
nxpfan 0:075157567b0c 39 * This code is derived from software contributed to The NetBSD Foundation
nxpfan 0:075157567b0c 40 * by Martin Husemann <martin@NetBSD.org>.
nxpfan 0:075157567b0c 41 *
nxpfan 0:075157567b0c 42 * Redistribution and use in source and binary forms, with or without
nxpfan 0:075157567b0c 43 * modification, are permitted provided that the following conditions
nxpfan 0:075157567b0c 44 * are met:
nxpfan 0:075157567b0c 45 * 1. Redistributions of source code must retain the above copyright
nxpfan 0:075157567b0c 46 * notice, this list of conditions and the following disclaimer.
nxpfan 0:075157567b0c 47 * 2. Redistributions in binary form must reproduce the above copyright
nxpfan 0:075157567b0c 48 * notice, this list of conditions and the following disclaimer in the
nxpfan 0:075157567b0c 49 * documentation and/or other materials provided with the distribution.
nxpfan 0:075157567b0c 50 * 3. All advertising materials mentioning features or use of this software
nxpfan 0:075157567b0c 51 * must display the following acknowledgement:
nxpfan 0:075157567b0c 52 * This product includes software developed by the NetBSD
nxpfan 0:075157567b0c 53 * Foundation, Inc. and its contributors.
nxpfan 0:075157567b0c 54 * 4. Neither the name of The NetBSD Foundation nor the names of its
nxpfan 0:075157567b0c 55 * contributors may be used to endorse or promote products derived
nxpfan 0:075157567b0c 56 * from this software without specific prior written permission.
nxpfan 0:075157567b0c 57 *
nxpfan 0:075157567b0c 58 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
nxpfan 0:075157567b0c 59 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
nxpfan 0:075157567b0c 60 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
nxpfan 0:075157567b0c 61 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
nxpfan 0:075157567b0c 62 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
nxpfan 0:075157567b0c 63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
nxpfan 0:075157567b0c 64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
nxpfan 0:075157567b0c 65 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
nxpfan 0:075157567b0c 66 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
nxpfan 0:075157567b0c 67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
nxpfan 0:075157567b0c 68 * POSSIBILITY OF SUCH DAMAGE.
nxpfan 0:075157567b0c 69 */
nxpfan 0:075157567b0c 70 #ifndef PPP_OE_H
nxpfan 0:075157567b0c 71 #define PPP_OE_H
nxpfan 0:075157567b0c 72
nxpfan 0:075157567b0c 73 #include "lwip/opt.h"
nxpfan 0:075157567b0c 74
nxpfan 0:075157567b0c 75 #if PPPOE_SUPPORT > 0
nxpfan 0:075157567b0c 76
nxpfan 0:075157567b0c 77 #include "netif/etharp.h"
nxpfan 0:075157567b0c 78
nxpfan 0:075157567b0c 79 #ifdef PACK_STRUCT_USE_INCLUDES
nxpfan 0:075157567b0c 80 # include "arch/bpstruct.h"
nxpfan 0:075157567b0c 81 #endif
nxpfan 0:075157567b0c 82 PACK_STRUCT_BEGIN
nxpfan 0:075157567b0c 83 struct pppoehdr {
nxpfan 0:075157567b0c 84 PACK_STRUCT_FIELD(u8_t vertype);
nxpfan 0:075157567b0c 85 PACK_STRUCT_FIELD(u8_t code);
nxpfan 0:075157567b0c 86 PACK_STRUCT_FIELD(u16_t session);
nxpfan 0:075157567b0c 87 PACK_STRUCT_FIELD(u16_t plen);
nxpfan 0:075157567b0c 88 } PACK_STRUCT_STRUCT;
nxpfan 0:075157567b0c 89 PACK_STRUCT_END
nxpfan 0:075157567b0c 90 #ifdef PACK_STRUCT_USE_INCLUDES
nxpfan 0:075157567b0c 91 # include "arch/epstruct.h"
nxpfan 0:075157567b0c 92 #endif
nxpfan 0:075157567b0c 93
nxpfan 0:075157567b0c 94 #ifdef PACK_STRUCT_USE_INCLUDES
nxpfan 0:075157567b0c 95 # include "arch/bpstruct.h"
nxpfan 0:075157567b0c 96 #endif
nxpfan 0:075157567b0c 97 PACK_STRUCT_BEGIN
nxpfan 0:075157567b0c 98 struct pppoetag {
nxpfan 0:075157567b0c 99 PACK_STRUCT_FIELD(u16_t tag);
nxpfan 0:075157567b0c 100 PACK_STRUCT_FIELD(u16_t len);
nxpfan 0:075157567b0c 101 } PACK_STRUCT_STRUCT;
nxpfan 0:075157567b0c 102 PACK_STRUCT_END
nxpfan 0:075157567b0c 103 #ifdef PACK_STRUCT_USE_INCLUDES
nxpfan 0:075157567b0c 104 # include "arch/epstruct.h"
nxpfan 0:075157567b0c 105 #endif
nxpfan 0:075157567b0c 106
nxpfan 0:075157567b0c 107
nxpfan 0:075157567b0c 108 #define PPPOE_STATE_INITIAL 0
nxpfan 0:075157567b0c 109 #define PPPOE_STATE_PADI_SENT 1
nxpfan 0:075157567b0c 110 #define PPPOE_STATE_PADR_SENT 2
nxpfan 0:075157567b0c 111 #define PPPOE_STATE_SESSION 3
nxpfan 0:075157567b0c 112 #define PPPOE_STATE_CLOSING 4
nxpfan 0:075157567b0c 113 /* passive */
nxpfan 0:075157567b0c 114 #define PPPOE_STATE_PADO_SENT 1
nxpfan 0:075157567b0c 115
nxpfan 0:075157567b0c 116 #define PPPOE_HEADERLEN sizeof(struct pppoehdr)
nxpfan 0:075157567b0c 117 #define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */
nxpfan 0:075157567b0c 118
nxpfan 0:075157567b0c 119 #define PPPOE_TAG_EOL 0x0000 /* end of list */
nxpfan 0:075157567b0c 120 #define PPPOE_TAG_SNAME 0x0101 /* service name */
nxpfan 0:075157567b0c 121 #define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */
nxpfan 0:075157567b0c 122 #define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */
nxpfan 0:075157567b0c 123 #define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */
nxpfan 0:075157567b0c 124 #define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */
nxpfan 0:075157567b0c 125 #define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */
nxpfan 0:075157567b0c 126 #define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */
nxpfan 0:075157567b0c 127 #define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */
nxpfan 0:075157567b0c 128 #define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */
nxpfan 0:075157567b0c 129
nxpfan 0:075157567b0c 130 #define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */
nxpfan 0:075157567b0c 131 #define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */
nxpfan 0:075157567b0c 132 #define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */
nxpfan 0:075157567b0c 133 #define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */
nxpfan 0:075157567b0c 134 #define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */
nxpfan 0:075157567b0c 135
nxpfan 0:075157567b0c 136 #ifndef ETHERMTU
nxpfan 0:075157567b0c 137 #define ETHERMTU 1500
nxpfan 0:075157567b0c 138 #endif
nxpfan 0:075157567b0c 139
nxpfan 0:075157567b0c 140 /* two byte PPP protocol discriminator, then IP data */
nxpfan 0:075157567b0c 141 #define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
nxpfan 0:075157567b0c 142
nxpfan 0:075157567b0c 143 #ifndef PPPOE_MAX_AC_COOKIE_LEN
nxpfan 0:075157567b0c 144 #define PPPOE_MAX_AC_COOKIE_LEN 64
nxpfan 0:075157567b0c 145 #endif
nxpfan 0:075157567b0c 146
nxpfan 0:075157567b0c 147 struct pppoe_softc {
nxpfan 0:075157567b0c 148 struct pppoe_softc *next;
nxpfan 0:075157567b0c 149 struct netif *sc_ethif; /* ethernet interface we are using */
nxpfan 0:075157567b0c 150 int sc_pd; /* ppp unit number */
nxpfan 0:075157567b0c 151 void (*sc_linkStatusCB)(int pd, int up);
nxpfan 0:075157567b0c 152
nxpfan 0:075157567b0c 153 int sc_state; /* discovery phase or session connected */
nxpfan 0:075157567b0c 154 struct eth_addr sc_dest; /* hardware address of concentrator */
nxpfan 0:075157567b0c 155 u16_t sc_session; /* PPPoE session id */
nxpfan 0:075157567b0c 156
nxpfan 0:075157567b0c 157 #ifdef PPPOE_TODO
nxpfan 0:075157567b0c 158 char *sc_service_name; /* if != NULL: requested name of service */
nxpfan 0:075157567b0c 159 char *sc_concentrator_name; /* if != NULL: requested concentrator id */
nxpfan 0:075157567b0c 160 #endif /* PPPOE_TODO */
nxpfan 0:075157567b0c 161 u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
nxpfan 0:075157567b0c 162 size_t sc_ac_cookie_len; /* length of cookie data */
nxpfan 0:075157567b0c 163 #ifdef PPPOE_SERVER
nxpfan 0:075157567b0c 164 u8_t *sc_hunique; /* content of host unique we must echo back */
nxpfan 0:075157567b0c 165 size_t sc_hunique_len; /* length of host unique */
nxpfan 0:075157567b0c 166 #endif
nxpfan 0:075157567b0c 167 int sc_padi_retried; /* number of PADI retries already done */
nxpfan 0:075157567b0c 168 int sc_padr_retried; /* number of PADR retries already done */
nxpfan 0:075157567b0c 169 };
nxpfan 0:075157567b0c 170
nxpfan 0:075157567b0c 171
nxpfan 0:075157567b0c 172 #define pppoe_init() /* compatibility define, no initialization needed */
nxpfan 0:075157567b0c 173
nxpfan 0:075157567b0c 174 err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
nxpfan 0:075157567b0c 175 err_t pppoe_destroy(struct netif *ifp);
nxpfan 0:075157567b0c 176
nxpfan 0:075157567b0c 177 int pppoe_connect(struct pppoe_softc *sc);
nxpfan 0:075157567b0c 178 void pppoe_disconnect(struct pppoe_softc *sc);
nxpfan 0:075157567b0c 179
nxpfan 0:075157567b0c 180 void pppoe_disc_input(struct netif *netif, struct pbuf *p);
nxpfan 0:075157567b0c 181 void pppoe_data_input(struct netif *netif, struct pbuf *p);
nxpfan 0:075157567b0c 182
nxpfan 0:075157567b0c 183 err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
nxpfan 0:075157567b0c 184
nxpfan 0:075157567b0c 185 /** used in ppp.c */
nxpfan 0:075157567b0c 186 #define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
nxpfan 0:075157567b0c 187
nxpfan 0:075157567b0c 188 #endif /* PPPOE_SUPPORT */
nxpfan 0:075157567b0c 189
nxpfan 0:075157567b0c 190 #endif /* PPP_OE_H */