Copy of NetServicesMin with the HTTP Client library. Includes modification for HTTP servers which send the HTTP status line in its own packet.

Committer:
andrewbonney
Date:
Thu May 26 10:02:40 2011 +0000
Revision:
0:18dd877d2c77

        

Who changed what in which revision?

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