PPP, PPPoE: remove useless PPPoE state conditions

sc->sc_ethif can't be NULL, it is set definitively in pppoe_create.

PPPoE can't by anything else than PADI sent in pppoe_send_padi, it
is only called when this is true.

PPPoE state can't be anything else than initial state in
pppoe_connect, this function is called from PPP core only when PPP
is in the dead phase, if PPP is in the dead phase it means the link
protocol is dead as well.

PPPoE can't be anything else than data phase in pppoe_disconnect
this function is only called by PPP core only when PPP session is up,
if PPP session is UP it means the link protocol is UP as well.

PPPoE can't by anything else than PADR sent in pppoe_send_padr, it
is only called when this is true.

PPPoE can't by anything else than PADO sent in pppoe_send_pado, it
is only called when this is true.

PPPoE can't by anything else than PADO sent in pppoe_send_pads, it
is only called when this is true.

PPPoE can't be anything else than session phase in pppoe_xmit,
function is only called by pppoe_write and pppoe_netif_output
which are both called by PPP core only when PPP session is up, if
PPP session is UP it means the link protocol is UP as well.
This commit is contained in:
Sylvain Rochet 2016-08-04 23:06:30 +02:00
parent e8d8c5dcc9
commit 9b47b6393b

View File

@ -731,11 +731,6 @@ pppoe_output(struct pppoe_softc *sc, struct pbuf *pb)
u16_t etype;
err_t res;
if (!sc->sc_ethif) {
pbuf_free(pb);
return ERR_IF;
}
/* make room for Ethernet header - should not fail */
if (pbuf_header(pb, (s16_t)(sizeof(struct eth_hdr))) != 0) {
/* bail out */
@ -773,10 +768,6 @@ pppoe_send_padi(struct pppoe_softc *sc)
int l1 = 0, l2 = 0; /* XXX: gcc */
#endif /* PPPOE_TODO */
if (sc->sc_state >PPPOE_STATE_PADI_SENT) {
PPPDEBUG(LOG_ERR, ("ERROR: pppoe_send_padi in state %d", sc->sc_state));
}
/* calculate length of frame (excluding ethernet header + pppoe header) */
len = 2 + 2 + 2 + 2 + sizeof sc; /* service name tag is required, host unique is send too */
#ifdef PPPOE_TODO
@ -909,10 +900,6 @@ pppoe_connect(ppp_pcb *ppp, void *ctx)
ipcp_options *ipcp_ao;
#endif /* PPP_IPV4_SUPPORT && VJ_SUPPORT */
if (sc->sc_state != PPPOE_STATE_INITIAL) {
return EBUSY;
}
/* stop any timer */
sys_untimeout(pppoe_timeout, sc);
sc->sc_session = 0;
@ -966,10 +953,6 @@ pppoe_disconnect(ppp_pcb *ppp, void *ctx)
{
struct pppoe_softc *sc = (struct pppoe_softc *)ctx;
if (sc->sc_state < PPPOE_STATE_SESSION) {
return;
}
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest);
@ -1020,10 +1003,6 @@ pppoe_send_padr(struct pppoe_softc *sc)
size_t l1 = 0; /* XXX: gcc */
#endif /* PPPOE_TODO */
if (sc->sc_state != PPPOE_STATE_PADR_SENT) {
return ERR_CONN;
}
len = 2 + 2 + 2 + 2 + sizeof(sc); /* service name, host unique */
#ifdef PPPOE_TODO
if (sc->sc_service_name != NULL) { /* service name tag maybe empty */
@ -1106,10 +1085,6 @@ pppoe_send_pado(struct pppoe_softc *sc)
u8_t *p;
size_t len;
if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
return ERR_CONN;
}
/* calc length */
len = 0;
/* include ac_cookie */
@ -1140,10 +1115,6 @@ pppoe_send_pads(struct pppoe_softc *sc)
u8_t *p;
size_t len, l1 = 0; /* XXX: gcc */
if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
return ERR_CONN;
}
sc->sc_session = mono_time.tv_sec % 0xff + 1;
/* calc length */
len = 0;
@ -1181,13 +1152,6 @@ pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb)
u8_t *p;
size_t len;
/* are we ready to process data yet? */
if (sc->sc_state < PPPOE_STATE_SESSION) {
/*sppp_flush(&sc->sc_sppp.pp_if);*/
pbuf_free(pb);
return ERR_CONN;
}
len = pb->tot_len;
/* make room for PPPoE header - should not fail */