Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Thu Apr 17 08:04:14 2014 +0000
Revision:
47:199042980678
Parent:
31:5f039cbddee8
publishing for sharing with Ken Iwasaki

Who changed what in which revision?

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