Embedded WebSockets Experiment

Dependencies:   mbed MD5

Committer:
nandgate
Date:
Tue Jul 26 05:30:53 2011 +0000
Revision:
0:6dee052a3fa4

        

Who changed what in which revision?

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