mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-21 18:40:12 +00:00
no more PPP unit number in PPPoE, now using ppp_pcb
This commit is contained in:
parent
f7ef9887d7
commit
5abdc99f3e
@ -145,8 +145,8 @@ PACK_STRUCT_END
|
||||
struct pppoe_softc {
|
||||
struct pppoe_softc *next;
|
||||
struct netif *sc_ethif; /* ethernet interface we are using */
|
||||
int sc_pd; /* ppp unit number */
|
||||
void (*sc_link_status_cb)(int pd, int up);
|
||||
ppp_pcb *pcb; /* PPP PCB */
|
||||
void (*sc_link_status_cb)(ppp_pcb *pcb, int up);
|
||||
|
||||
int sc_state; /* discovery phase or session connected */
|
||||
struct eth_addr sc_dest; /* hardware address of concentrator */
|
||||
@ -171,7 +171,7 @@ struct pppoe_softc {
|
||||
|
||||
#define pppoe_init() /* compatibility define, no initialization needed */
|
||||
|
||||
err_t pppoe_create(struct netif *ethif, int pd, void (*link_status_cb)(int pd, int up), struct pppoe_softc **scptr);
|
||||
err_t pppoe_create(struct netif *ethif, ppp_pcb *pcb, void (*link_status_cb)(ppp_pcb *pcb, int up), struct pppoe_softc **scptr);
|
||||
err_t pppoe_destroy(struct netif *ifp);
|
||||
|
||||
int pppoe_connect(struct pppoe_softc *sc, bool persist);
|
||||
|
@ -439,7 +439,7 @@ void ppp_set_xaccm(int unit, ext_accm *accm) {
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
static void ppp_over_ethernet_link_status_cb(int pd, int state);
|
||||
static void ppp_over_ethernet_link_status_cb(ppp_pcb *pcb, int state);
|
||||
|
||||
int ppp_over_ethernet_open(ppp_pcb *pcb, struct netif *ethif, const char *service_name, const char *concentrator_name,
|
||||
ppp_link_status_cb_fn link_status_cb, void *link_status_ctx) {
|
||||
@ -467,7 +467,7 @@ int ppp_over_ethernet_open(ppp_pcb *pcb, struct netif *ethif, const char *servic
|
||||
lcp_allowoptions[pcb->unit].neg_pcompression = 0;
|
||||
lcp_allowoptions[pcb->unit].neg_accompression = 0;
|
||||
|
||||
if(pppoe_create(ethif, pcb->unit, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) {
|
||||
if(pppoe_create(ethif, pcb, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) {
|
||||
pcb->open_flag = 0;
|
||||
return PPPERR_OPEN;
|
||||
}
|
||||
@ -891,7 +891,7 @@ ppp_receive_wakeup(int pd)
|
||||
* this is totally stupid to make room for it and then modify the packet directly
|
||||
* or it is used in output ? have to find out...
|
||||
*/
|
||||
void ppp_input_over_ethernet(int pd, struct pbuf *pb) {
|
||||
void ppp_input_over_ethernet(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
struct ppp_input_header *pih;
|
||||
u16_t in_protocol;
|
||||
|
||||
@ -914,16 +914,16 @@ void ppp_input_over_ethernet(int pd, struct pbuf *pb) {
|
||||
|
||||
pih = pb->payload;
|
||||
|
||||
pih->unit = pd;
|
||||
pih->unit = pcb->unit;
|
||||
pih->proto = in_protocol; /* pih->proto is now in host byte order */
|
||||
|
||||
/* Dispatch the packet thereby consuming it. */
|
||||
ppp_input(pd, pb);
|
||||
ppp_input(pcb->unit, pb);
|
||||
return;
|
||||
|
||||
drop:
|
||||
LINK_STATS_INC(link.drop);
|
||||
snmp_inc_ifindiscards(&ppp_pcb_list[pd].netif);
|
||||
snmp_inc_ifindiscards(&pcb->netif);
|
||||
pbuf_free(pb);
|
||||
return;
|
||||
}
|
||||
@ -1685,47 +1685,44 @@ struct pbuf * ppp_singlebuf(struct pbuf *p) {
|
||||
}
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
static void ppp_over_ethernet_link_status_cb(int pd, int state) {
|
||||
static void ppp_over_ethernet_link_status_cb(ppp_pcb *pcb, int state) {
|
||||
int pppoe_err_code = PPPERR_NONE;
|
||||
ppp_pcb *pc;
|
||||
|
||||
switch(state) {
|
||||
|
||||
/* PPPoE link is established, starting PPP negotiation */
|
||||
case PPPOE_CB_STATE_UP:
|
||||
PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: UP, connecting\n", pd));
|
||||
ppp_start(pd);
|
||||
PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: UP, connecting\n", pcb->unit));
|
||||
ppp_start(pcb->unit);
|
||||
return;
|
||||
|
||||
/* PPPoE link normally down (i.e. asked to do so) */
|
||||
case PPPOE_CB_STATE_DOWN:
|
||||
PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: DOWN, disconnected\n", pd));
|
||||
PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: DOWN, disconnected\n", pcb->unit));
|
||||
pppoe_err_code = PPPERR_CONNECT;
|
||||
break;
|
||||
|
||||
/* PPPoE link failed to setup (i.e. PADI/PADO timeout */
|
||||
case PPPOE_CB_STATE_FAILED:
|
||||
PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: FAILED, aborting\n", pd));
|
||||
PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: FAILED, aborting\n", pcb->unit));
|
||||
pppoe_err_code = PPPERR_OPEN;
|
||||
break;
|
||||
}
|
||||
|
||||
pc = &ppp_pcb_list[pd];
|
||||
|
||||
/* Reconnect if persist mode is enabled */
|
||||
if(pc->settings.persist) {
|
||||
if(pc->link_status_cb)
|
||||
pc->link_status_cb(pc->link_status_ctx, pc->err_code ? pc->err_code : pppoe_err_code, NULL);
|
||||
pppoe_connect(pc->pppoe_sc, pc->settings.persist);
|
||||
if(pcb->settings.persist) {
|
||||
if(pcb->link_status_cb)
|
||||
pcb->link_status_cb(pcb->link_status_ctx, pcb->err_code ? pcb->err_code : pppoe_err_code, NULL);
|
||||
pppoe_connect(pcb->pppoe_sc, pcb->settings.persist);
|
||||
return;
|
||||
}
|
||||
|
||||
ppp_hup(pd);
|
||||
ppp_stop(pd);
|
||||
pppoe_destroy(&pc->netif);
|
||||
pc->open_flag = 0;
|
||||
if(pc->link_status_cb)
|
||||
pc->link_status_cb(pc->link_status_ctx, pc->err_code ? pc->err_code : pppoe_err_code, NULL);
|
||||
ppp_hup(pcb->unit);
|
||||
ppp_stop(pcb->unit);
|
||||
pppoe_destroy(&pcb->netif);
|
||||
pcb->open_flag = 0;
|
||||
if(pcb->link_status_cb)
|
||||
pcb->link_status_cb(pcb->link_status_ctx, pcb->err_code ? pcb->err_code : pppoe_err_code, NULL);
|
||||
}
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
|
@ -398,7 +398,7 @@ ppp_pcb ppp_pcb_list[NUM_PPP]; /* The PPP interface control blocks. */
|
||||
#if PPPOE_SUPPORT
|
||||
void ppp_over_ethernet_init_failed(int pd);
|
||||
/* function called by pppoe.c */
|
||||
void ppp_input_over_ethernet(int pd, struct pbuf *pb);
|
||||
void ppp_input_over_ethernet(ppp_pcb *pcb, struct pbuf *pb);
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
/* function called by all PPP subsystems to send packets */
|
||||
|
@ -141,7 +141,7 @@ static struct pppoe_softc * pppoe_find_softc_by_hunique(u8_t *, size_t, struct n
|
||||
static struct pppoe_softc *pppoe_softc_list;
|
||||
|
||||
err_t
|
||||
pppoe_create(struct netif *ethif, int pd, void (*link_status_cb)(int pd, int up), struct pppoe_softc **scptr)
|
||||
pppoe_create(struct netif *ethif, ppp_pcb *pcb, void (*link_status_cb)(ppp_pcb *pcb, int up), struct pppoe_softc **scptr)
|
||||
{
|
||||
struct pppoe_softc *sc;
|
||||
|
||||
@ -155,7 +155,7 @@ pppoe_create(struct netif *ethif, int pd, void (*link_status_cb)(int pd, int up)
|
||||
/* changed to real address later */
|
||||
MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest));
|
||||
|
||||
sc->sc_pd = pd;
|
||||
sc->pcb = pcb;
|
||||
sc->sc_link_status_cb = link_status_cb;
|
||||
sc->sc_ethif = ethif;
|
||||
|
||||
@ -277,7 +277,7 @@ pppoe_find_softc_by_hunique(u8_t *token, size_t len, struct netif *rcvif)
|
||||
static void
|
||||
pppoe_linkstatus_up(struct pppoe_softc *sc)
|
||||
{
|
||||
sc->sc_link_status_cb(sc->sc_pd, PPPOE_CB_STATE_UP);
|
||||
sc->sc_link_status_cb(sc->pcb, PPPOE_CB_STATE_UP);
|
||||
}
|
||||
|
||||
/* analyze and handle a single received packet while not in session state */
|
||||
@ -622,7 +622,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
||||
goto drop;
|
||||
}
|
||||
|
||||
ppp_input_over_ethernet(sc->sc_pd, pb);
|
||||
ppp_input_over_ethernet(sc->pcb, pb);
|
||||
|
||||
return;
|
||||
|
||||
@ -874,7 +874,7 @@ pppoe_do_disconnect(struct pppoe_softc *sc)
|
||||
sc->sc_padi_retried = 0;
|
||||
sc->sc_padr_retried = 0;
|
||||
|
||||
sc->sc_link_status_cb(sc->sc_pd, PPPOE_CB_STATE_DOWN); /* notify upper layers */
|
||||
sc->sc_link_status_cb(sc->pcb, PPPOE_CB_STATE_DOWN); /* notify upper layers */
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -892,7 +892,7 @@ pppoe_abort_connect(struct pppoe_softc *sc)
|
||||
sc->sc_padi_retried = 0;
|
||||
sc->sc_padr_retried = 0;
|
||||
|
||||
sc->sc_link_status_cb(sc->sc_pd, PPPOE_CB_STATE_FAILED); /* notify upper layers */
|
||||
sc->sc_link_status_cb(sc->pcb, PPPOE_CB_STATE_FAILED); /* notify upper layers */
|
||||
}
|
||||
|
||||
/* Send a PADR packet */
|
||||
@ -1130,7 +1130,7 @@ pppoe_clear_softc(struct pppoe_softc *sc, const char *message)
|
||||
sc->sc_state = PPPOE_STATE_INITIAL;
|
||||
|
||||
/* notify upper layers */
|
||||
sc->sc_link_status_cb(sc->sc_pd, PPPOE_CB_STATE_DOWN);
|
||||
sc->sc_link_status_cb(sc->pcb, PPPOE_CB_STATE_DOWN);
|
||||
|
||||
/* clean up softc */
|
||||
MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest));
|
||||
|
Loading…
x
Reference in New Issue
Block a user