code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.

Dependencies:   mbed

Committer:
eqon
Date:
Thu Jun 07 05:44:29 2012 +0000
Revision:
0:0ce833f21e63

        

Who changed what in which revision?

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