Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:41:36 2011 +0000
Revision:
0:8f5825f330b0
setDataLen hacked to 180bytes

Who changed what in which revision?

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