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

Committer:
RodColeman
Date:
Thu Sep 08 10:48:09 2011 +0000
Revision:
0:850eacf3e945
revised fixed length to 178 bytes

Who changed what in which revision?

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