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