mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-12-11 17:26:40 +08:00
saved some bytes from PPPoE control block, improved PADI retries
This commit is contained in:
parent
d2b2ae09e6
commit
91af8878e1
@ -148,22 +148,22 @@ struct pppoe_softc {
|
|||||||
ppp_pcb *pcb; /* PPP PCB */
|
ppp_pcb *pcb; /* PPP PCB */
|
||||||
void (*sc_link_status_cb)(ppp_pcb *pcb, int up);
|
void (*sc_link_status_cb)(ppp_pcb *pcb, int up);
|
||||||
|
|
||||||
int sc_state; /* discovery phase or session connected */
|
|
||||||
struct eth_addr sc_dest; /* hardware address of concentrator */
|
struct eth_addr sc_dest; /* hardware address of concentrator */
|
||||||
u16_t sc_session; /* PPPoE session id */
|
u16_t sc_session; /* PPPoE session id */
|
||||||
|
u8_t sc_state; /* discovery phase or session connected */
|
||||||
|
|
||||||
#ifdef PPPOE_TODO
|
#ifdef PPPOE_TODO
|
||||||
char *sc_service_name; /* if != NULL: requested name of service */
|
u8_t *sc_service_name; /* if != NULL: requested name of service */
|
||||||
char *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
u8_t *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
||||||
#endif /* PPPOE_TODO */
|
#endif /* PPPOE_TODO */
|
||||||
u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
|
u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
|
||||||
size_t sc_ac_cookie_len; /* length of cookie data */
|
u8_t sc_ac_cookie_len; /* length of cookie data */
|
||||||
#ifdef PPPOE_SERVER
|
#ifdef PPPOE_SERVER
|
||||||
u8_t *sc_hunique; /* content of host unique we must echo back */
|
u8_t *sc_hunique; /* content of host unique we must echo back */
|
||||||
size_t sc_hunique_len; /* length of host unique */
|
u8_t sc_hunique_len; /* length of host unique */
|
||||||
#endif
|
#endif
|
||||||
int sc_padi_retried; /* number of PADI retries already done */
|
u8_t sc_padi_retried; /* number of PADI retries already done */
|
||||||
int sc_padr_retried; /* number of PADR retries already done */
|
u8_t sc_padr_retried; /* number of PADR retries already done */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -730,7 +730,8 @@ pppoe_send_padi(struct pppoe_softc *sc)
|
|||||||
static void
|
static void
|
||||||
pppoe_timeout(void *arg)
|
pppoe_timeout(void *arg)
|
||||||
{
|
{
|
||||||
int retry_wait, err;
|
u32_t retry_wait;
|
||||||
|
int err;
|
||||||
struct pppoe_softc *sc = (struct pppoe_softc*)arg;
|
struct pppoe_softc *sc = (struct pppoe_softc*)arg;
|
||||||
|
|
||||||
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": timeout\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": timeout\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
||||||
@ -746,15 +747,9 @@ pppoe_timeout(void *arg)
|
|||||||
* We only enter slow retry mode if IFF_LINK1 (aka autodial)
|
* We only enter slow retry mode if IFF_LINK1 (aka autodial)
|
||||||
* is not set.
|
* is not set.
|
||||||
*/
|
*/
|
||||||
|
if (sc->sc_padi_retried < UCHAR_MAX) {
|
||||||
/* initialize for quick retry mode */
|
|
||||||
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->pcb->settings.persist && sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) {
|
if (!sc->pcb->settings.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) {
|
||||||
@ -767,6 +762,8 @@ pppoe_timeout(void *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* initialize for quick retry mode */
|
||||||
|
retry_wait = LWIP_MIN(PPPOE_DISC_TIMEOUT * sc->sc_padi_retried, PPPOE_SLOW_RETRY);
|
||||||
if ((err = pppoe_send_padi(sc)) != 0) {
|
if ((err = pppoe_send_padi(sc)) != 0) {
|
||||||
sc->sc_padi_retried--;
|
sc->sc_padi_retried--;
|
||||||
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to transmit PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
|
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": failed to transmit PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user