Ethernet for Nucleo and Disco board STM32F746 works with gcc and arm. IAC is untested

Fork of F7_Ethernet by Dieter Graef

Committer:
TudaPellini
Date:
Sun Aug 20 22:09:22 2017 +0000
Revision:
4:c63cab7b2bda
Parent:
0:d26c1b55cfca
Minor adjustments;

Who changed what in which revision?

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