From 88ac7460f09a67f8564b3109cebc63878f59bca3 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 17 Oct 2020 16:01:00 +0200 Subject: [PATCH] PPP: cleanup Code cleaning only (misleading indents or comments, etc.), no behavior change. --- src/netif/ppp/ppp.c | 15 ++++++++------- src/netif/ppp/pppos.c | 22 +++------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index b8a33a3a..dcefd3a6 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -874,7 +874,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { } #endif /* CCP_SUPPORT */ - switch(protocol) { + switch (protocol) { #if PPP_IPV4_SUPPORT case PPP_IP: /* Internet Protocol */ @@ -963,13 +963,14 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { #endif /* PPP_PROTOCOLNAME */ ppp_warn(("Unsupported protocol 0x%x received", protocol)); #endif /* PPP_DEBUG */ - if (pbuf_add_header(pb, sizeof(protocol))) { - PPPDEBUG(LOG_WARNING, ("ppp_input[%d]: Dropping (pbuf_add_header failed)\n", pcb->netif->num)); - goto drop; - } - lcp_sprotrej(pcb, (u8_t*)pb->payload, pb->len); + + if (pbuf_add_header(pb, sizeof(protocol))) { + PPPDEBUG(LOG_WARNING, ("ppp_input[%d]: Dropping (pbuf_add_header failed)\n", pcb->netif->num)); + goto drop; } - break; + lcp_sprotrej(pcb, (u8_t*)pb->payload, pb->len); + } + break; } drop: diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 7992388e..afa65bae 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -502,6 +502,7 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l) } escaped = ESCAPE_P(pppos->in_accm, cur_char); PPPOS_UNPROTECT(lev); + /* Handle special characters. */ if (escaped) { /* Check for escape sequences. */ @@ -591,50 +592,33 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l) } /* Process character relative to current state. */ - switch(pppos->in_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; } - /* no break */ /* Fall through */ - case PDSTART: /* Process start flag. */ /* Prepare for a new packet. */ pppos->in_fcs = PPP_INITFCS; - /* no break */ /* Fall through */ - case PDADDRESS: /* Process address field. */ if (cur_char == PPP_ALLSTATIONS) { pppos->in_state = PDCONTROL; break; } - /* no break */ - /* Else assume compressed address and control fields so * fall through to get the protocol... */ /* Fall through */ case PDCONTROL: /* Process control field. */ - /* If we don't get a valid control code, restart. */ if (cur_char == PPP_UI) { pppos->in_state = PDPROTOCOL1; break; } - /* no break */ - -#if 0 - else { - PPPDEBUG(LOG_WARNING, - ("pppos_input[%d]: Invalid control <%d>\n", ppp->netif->num, cur_char)); - pppos->in_state = PDSTART; - } -#endif /* Fall through */ - - case PDPROTOCOL1: /* Process protocol field 1. */ + case PDPROTOCOL1: /* Process protocol field 1. */ /* If the lower bit is set, this is the end of the protocol * field. */ if (cur_char & 1) {