mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
PPP, PPPoS: wait for next packet when we drop a packet before it is complete
If we fail to receive a full packet, for exemple if a memory allocation fail for some reason, we currently do not wait for next packet flag character and we start filling a new packet at next received byte. Then we expect the checksum check to discard the packet. The behavior seem to have been broken one or two decades ago when adding support for PFC (Protocol-Field-Compression) and ACFC (Address-and-Control-Field-Compression). Rework to drop any character until we receive a flag character at init and when we drop a packet before it is complete.
This commit is contained in:
parent
88ac7460f0
commit
3779cf7856
@ -50,7 +50,6 @@ extern "C" {
|
||||
* completed. */
|
||||
enum {
|
||||
PDIDLE = 0, /* Idle state - waiting. */
|
||||
PDSTART, /* Process start flag. */
|
||||
PDADDRESS, /* Process address field. */
|
||||
PDCONTROL, /* Process control field. */
|
||||
PDPROTOCOL1, /* Process protocol field 1. */
|
||||
|
@ -593,17 +593,8 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l)
|
||||
|
||||
/* Process character relative to current state. */
|
||||
switch (pppos->in_state) {
|
||||
case PDIDLE: /* Idle state - waiting. */
|
||||
/* Drop the character if it's not 0xff
|
||||
* we would have processed a flag character above. */
|
||||
if (cur_char != PPP_ALLSTATIONS) {
|
||||
break;
|
||||
}
|
||||
/* Fall through */
|
||||
case PDSTART: /* Process start flag. */
|
||||
/* Prepare for a new packet. */
|
||||
pppos->in_fcs = PPP_INITFCS;
|
||||
/* Fall through */
|
||||
case PDIDLE: /* Idle state - wait for flag character. */
|
||||
break;
|
||||
case PDADDRESS: /* Process address field. */
|
||||
if (cur_char == PPP_ALLSTATIONS) {
|
||||
pppos->in_state = PDCONTROL;
|
||||
@ -664,7 +655,7 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l)
|
||||
PPPDEBUG(LOG_ERR, ("pppos_input[%d]: NO FREE PBUFS!\n", ppp->netif->num));
|
||||
LINK_STATS_INC(link.memerr);
|
||||
pppos_input_drop(pppos);
|
||||
pppos->in_state = PDSTART; /* Wait for flag sequence. */
|
||||
pppos->in_state = PDIDLE; /* Wait for flag character. */
|
||||
break;
|
||||
}
|
||||
if (pppos->in_head == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user