mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-06 02:27:15 +00:00
added PPPoE persist support (don't timeout sending PADI packets)
This commit is contained in:
parent
7ef99ee6f3
commit
a9ac45c5f0
@ -67,12 +67,13 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#ifndef PPP_OE_H
|
#ifndef PPP_OE_H
|
||||||
#define PPP_OE_H
|
#define PPP_OE_H
|
||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#if PPPOE_SUPPORT > 0
|
|
||||||
|
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
|
|
||||||
@ -163,6 +164,8 @@ struct pppoe_softc {
|
|||||||
#endif
|
#endif
|
||||||
int sc_padi_retried; /* number of PADI retries already done */
|
int sc_padi_retried; /* number of PADI retries already done */
|
||||||
int sc_padr_retried; /* number of PADR retries already done */
|
int sc_padr_retried; /* number of PADR retries already done */
|
||||||
|
|
||||||
|
u_int persist : 1; /* Persist mode, don't timeout sending PADI packets */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +174,7 @@ struct pppoe_softc {
|
|||||||
err_t pppoe_create(struct netif *ethif, int pd, void (*link_status_cb)(int pd, int up), struct pppoe_softc **scptr);
|
err_t pppoe_create(struct netif *ethif, int pd, void (*link_status_cb)(int pd, int up), struct pppoe_softc **scptr);
|
||||||
err_t pppoe_destroy(struct netif *ifp);
|
err_t pppoe_destroy(struct netif *ifp);
|
||||||
|
|
||||||
int pppoe_connect(struct pppoe_softc *sc);
|
int pppoe_connect(struct pppoe_softc *sc, bool persist);
|
||||||
void pppoe_disconnect(struct pppoe_softc *sc);
|
void pppoe_disconnect(struct pppoe_softc *sc);
|
||||||
|
|
||||||
void pppoe_disc_input(struct netif *netif, struct pbuf *p);
|
void pppoe_disc_input(struct netif *netif, struct pbuf *p);
|
||||||
@ -182,6 +185,6 @@ err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
|
|||||||
/** used in ppp.c */
|
/** used in ppp.c */
|
||||||
#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
|
#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
|
||||||
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
|
|
||||||
#endif /* PPP_OE_H */
|
#endif /* PPP_OE_H */
|
||||||
|
|
||||||
|
#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
|
||||||
|
@ -625,7 +625,7 @@ int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const
|
|||||||
return PPPERR_OPEN;
|
return PPPERR_OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
pppoe_connect(pc->pppoe_sc);
|
pppoe_connect(pc->pppoe_sc, ppp_settings.persist);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pd;
|
return pd;
|
||||||
@ -1866,7 +1866,7 @@ static void ppp_over_ethernet_link_status_cb(int pd, int state) {
|
|||||||
if(ppp_settings.persist) {
|
if(ppp_settings.persist) {
|
||||||
if(pc->link_status_cb)
|
if(pc->link_status_cb)
|
||||||
pc->link_status_cb(pc->link_status_ctx, pc->err_code ? pc->err_code : pppoe_err_code, NULL);
|
pc->link_status_cb(pc->link_status_ctx, pc->err_code ? pc->err_code : pppoe_err_code, NULL);
|
||||||
pppoe_connect(pc->pppoe_sc);
|
pppoe_connect(pc->pppoe_sc, ppp_settings.persist);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,10 +748,14 @@ pppoe_timeout(void *arg)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* initialize for quick retry mode */
|
/* initialize for quick retry mode */
|
||||||
retry_wait = PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried);
|
retry_wait = LWIP_MIN(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried), PPPOE_SLOW_RETRY);
|
||||||
|
|
||||||
|
/* prevent sc_padi_retried integer overflow << ~2^31/PPPOE_DISC_TIMEOUT
|
||||||
|
* FIXME: can be improved
|
||||||
|
*/
|
||||||
|
if(sc->sc_padi_retried < 100000)
|
||||||
sc->sc_padi_retried++;
|
sc->sc_padi_retried++;
|
||||||
if (sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) {
|
if (!sc->persist && sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) {
|
||||||
#if 0
|
#if 0
|
||||||
if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) {
|
if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) {
|
||||||
/* slow retry mode */
|
/* slow retry mode */
|
||||||
@ -798,7 +802,7 @@ pppoe_timeout(void *arg)
|
|||||||
|
|
||||||
/* Start a connection (i.e. initiate discovery phase) */
|
/* Start a connection (i.e. initiate discovery phase) */
|
||||||
int
|
int
|
||||||
pppoe_connect(struct pppoe_softc *sc)
|
pppoe_connect(struct pppoe_softc *sc, bool persist)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -811,7 +815,7 @@ pppoe_connect(struct pppoe_softc *sc)
|
|||||||
sc->sc_session = 0;
|
sc->sc_session = 0;
|
||||||
sc->sc_padi_retried = 0;
|
sc->sc_padi_retried = 0;
|
||||||
sc->sc_padr_retried = 0;
|
sc->sc_padr_retried = 0;
|
||||||
|
sc->persist = persist;
|
||||||
#ifdef PPPOE_SERVER
|
#ifdef PPPOE_SERVER
|
||||||
/* wait PADI if IFF_PASSIVE */
|
/* wait PADI if IFF_PASSIVE */
|
||||||
if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
|
if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user