diff --git a/src/include/netif/ppp/ccp.h b/src/include/netif/ppp/ccp.h index becfc135..a8eab9c0 100644 --- a/src/include/netif/ppp/ccp.h +++ b/src/include/netif/ppp/ccp.h @@ -150,5 +150,7 @@ typedef struct ccp_options { extern const struct protent ccp_protent; +void ccp_resetrequest(ppp_pcb *pcb); /* Issue a reset-request. */ + #endif /* CCP_H */ #endif /* PPP_SUPPORT && CCP_SUPPORT */ diff --git a/src/netif/ppp/ccp.c b/src/netif/ppp/ccp.c index 506f5d21..d0f924f8 100644 --- a/src/netif/ppp/ccp.c +++ b/src/netif/ppp/ccp.c @@ -411,7 +411,7 @@ static void ccp_init(ppp_pcb *pcb) { (pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40) | (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128); } -#endif +#endif /* MPPE_SUPPORT */ } /* @@ -1701,6 +1701,29 @@ static void ccp_datainput(ppp_pcb *pcb, u_char *pkt, int len) { } #endif /* PPP_DATAINPUT */ +/* + * We have received a packet that the decompressor failed to + * decompress. Issue a reset-request. + */ +void ccp_resetrequest(ppp_pcb *pcb) { + fsm *f = &pcb->ccp_fsm; + + if (f->state != PPP_FSM_OPENED) + return; + + /* + * Send a reset-request to reset the peer's compressor. + * We don't do that if we are still waiting for an + * acknowledgement to a previous reset-request. + */ + if (!(pcb->ccp_localstate & RACK_PENDING)) { + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate |= RACK_PENDING; + } else + pcb->ccp_localstate |= RREQ_REPEAT; +} + /* * Timeout waiting for reset-ack. */ diff --git a/src/netif/ppp/mppe.c b/src/netif/ppp/mppe.c index 31a38d86..39d512ae 100644 --- a/src/netif/ppp/mppe.c +++ b/src/netif/ppp/mppe.c @@ -273,7 +273,8 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb) PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: short pkt (%d)\n", pcb->netif->num, n0->len)); - return ERR_BUF; + state->sanity_errors += 100; + goto sanity_error; } pl = (u8_t*)n0->payload; @@ -381,16 +382,18 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb) return ERR_OK; sanity_error: - if (state->sanity_errors < SANITY_MAX) - return ERR_BUF; - else + if (state->sanity_errors < SANITY_MAX) { + /* Signal the peer to rekey (by sending a CCP Reset-Request). */ + ccp_resetrequest(pcb); + } 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; + } + return ERR_BUF; } #endif /* PPP_SUPPORT && MPPE_SUPPORT */