ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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