mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-06 22:44:38 +08:00
PPP, MPPE, sanity error path rework
We are going to need sanity error path a little further, rework to be able to use the sanity error path anywhere in decompressor.
This commit is contained in:
parent
e20a071977
commit
d0f91c00cb
@ -267,7 +267,6 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb)
|
|||||||
u8_t *pl;
|
u8_t *pl;
|
||||||
u16_t ccount;
|
u16_t ccount;
|
||||||
u8_t flushed;
|
u8_t flushed;
|
||||||
u8_t sanity = 0;
|
|
||||||
|
|
||||||
/* MPPE Header */
|
/* MPPE Header */
|
||||||
if (n0->len < MPPE_OVHD) {
|
if (n0->len < MPPE_OVHD) {
|
||||||
@ -289,32 +288,19 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb)
|
|||||||
("mppe_decompress[%d]: ENCRYPTED bit not set!\n",
|
("mppe_decompress[%d]: ENCRYPTED bit not set!\n",
|
||||||
pcb->netif->num));
|
pcb->netif->num));
|
||||||
state->sanity_errors += 100;
|
state->sanity_errors += 100;
|
||||||
sanity = 1;
|
goto sanity_error;
|
||||||
}
|
}
|
||||||
if (!state->stateful && !flushed) {
|
if (!state->stateful && !flushed) {
|
||||||
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in "
|
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in "
|
||||||
"stateless mode!\n", pcb->netif->num));
|
"stateless mode!\n", pcb->netif->num));
|
||||||
state->sanity_errors += 100;
|
state->sanity_errors += 100;
|
||||||
sanity = 1;
|
goto sanity_error;
|
||||||
}
|
}
|
||||||
if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) {
|
if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) {
|
||||||
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on "
|
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on "
|
||||||
"flag packet!\n", pcb->netif->num));
|
"flag packet!\n", pcb->netif->num));
|
||||||
state->sanity_errors += 100;
|
state->sanity_errors += 100;
|
||||||
sanity = 1;
|
goto sanity_error;
|
||||||
}
|
|
||||||
|
|
||||||
if (sanity) {
|
|
||||||
if (state->sanity_errors < SANITY_MAX)
|
|
||||||
return ERR_BUF;
|
|
||||||
else
|
|
||||||
/*
|
|
||||||
* Take LCP down if the peer is sending too many bogons.
|
|
||||||
* We don't want to do this for a single or just a few
|
|
||||||
* instances since it could just be due to packet corruption.
|
|
||||||
*/
|
|
||||||
lcp_close(pcb, "Too many MPPE errors");
|
|
||||||
return ERR_BUF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -387,6 +373,18 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb)
|
|||||||
state->sanity_errors >>= 1;
|
state->sanity_errors >>= 1;
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
|
||||||
|
sanity_error:
|
||||||
|
if (state->sanity_errors < SANITY_MAX)
|
||||||
|
return ERR_BUF;
|
||||||
|
else
|
||||||
|
/*
|
||||||
|
* Take LCP down if the peer is sending too many bogons.
|
||||||
|
* We don't want to do this for a single or just a few
|
||||||
|
* instances since it could just be due to packet corruption.
|
||||||
|
*/
|
||||||
|
lcp_close(pcb, "Too many MPPE errors");
|
||||||
|
return ERR_BUF;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PPP_SUPPORT && MPPE_SUPPORT */
|
#endif /* PPP_SUPPORT && MPPE_SUPPORT */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user