From 17c6be6a9b14ab9d0aff8edbf5b1bbdf19a0e3a5 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 14 Feb 2015 22:22:08 +0100 Subject: [PATCH] PPP: removed ppp_delete(), merged with ppp_free() The only benefit of ppp_delete() call was about having a persistent netif interface. netif was moved out of PPP pcb so we don't need ppp_delete() anymore, second step in simplifying the weird new/open/free/delete PPP API. --- src/api/pppapi.c | 12 ++++++------ src/include/lwip/pppapi.h | 2 +- src/include/netif/ppp/ppp.h | 17 +---------------- src/netif/ppp/ppp.c | 38 +++++-------------------------------- 4 files changed, 13 insertions(+), 56 deletions(-) diff --git a/src/api/pppapi.c b/src/api/pppapi.c index 3a417931..13b5488d 100644 --- a/src/api/pppapi.c +++ b/src/api/pppapi.c @@ -308,24 +308,24 @@ pppapi_sighup(ppp_pcb *pcb) /** - * Call ppp_delete() inside the tcpip_thread context. + * Call ppp_free() inside the tcpip_thread context. */ static void -pppapi_do_ppp_delete(struct pppapi_msg_msg *msg) +pppapi_do_ppp_free(struct pppapi_msg_msg *msg) { - msg->err = ppp_delete(msg->ppp); + msg->err = ppp_free(msg->ppp); TCPIP_PPPAPI_ACK(msg); } /** - * Call ppp_delete() in a thread-safe way by running that function inside the + * Call ppp_free() in a thread-safe way by running that function inside the * tcpip_thread context. */ int -pppapi_delete(ppp_pcb *pcb) +pppapi_free(ppp_pcb *pcb) { struct pppapi_msg msg; - msg.function = pppapi_do_ppp_delete; + msg.function = pppapi_do_ppp_free; msg.msg.ppp = pcb; TCPIP_PPPAPI(&msg); return msg.msg.err; diff --git a/src/include/lwip/pppapi.h b/src/include/lwip/pppapi.h index 5a27eede..98a44bd9 100644 --- a/src/include/lwip/pppapi.h +++ b/src/include/lwip/pppapi.h @@ -136,7 +136,7 @@ ppp_pcb *pppapi_over_l2tp_create(struct netif *pppif, struct netif *netif, ip_ad int pppapi_open(ppp_pcb *pcb, u16_t holdoff); int pppapi_close(ppp_pcb *pcb); void pppapi_sighup(ppp_pcb *pcb); -int pppapi_delete(ppp_pcb *pcb); +int pppapi_free(ppp_pcb *pcb); int pppapi_ioctl(ppp_pcb *pcb, int cmd, void *arg); #if LWIP_NETIF_STATUS_CALLBACK void pppapi_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback); diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index 7e270e5b..8ad4bc22 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -573,21 +573,6 @@ int ppp_close(ppp_pcb *pcb); */ void ppp_sighup(ppp_pcb *pcb); -/* - * Free the control block, clean everything except the PPP PCB itself - * and the netif, it allows you to change the underlying PPP protocol - * (eg. from PPPoE to PPPoS to switch from DSL to GPRS) without losing - * your PPP and netif handlers. - * - * This can only be called if PPP is in the dead phase. - * - * You must use ppp_close() before if you wish to terminate - * an established PPP session. - * - * Return 0 on success, an error code on failure. - */ -int ppp_free(ppp_pcb *pcb); - /* * Release the control block. * @@ -598,7 +583,7 @@ int ppp_free(ppp_pcb *pcb); * * Return 0 on success, an error code on failure. */ -int ppp_delete(ppp_pcb *pcb); +int ppp_free(ppp_pcb *pcb); /* * Get and set parameters for the given connection. diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index ff69a4bf..8c9d8a38 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -352,7 +352,7 @@ ppp_pcb *ppp_over_ethernet_create(struct netif *pppif, struct netif *ethif, cons pcb->ctx_cb = ctx_cb; if (pppoe_create(ethif, pcb, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) { - ppp_delete(pcb); + ppp_free(pcb); return NULL; } @@ -383,7 +383,7 @@ ppp_pcb *ppp_over_l2tp_create(struct netif *pppif, struct netif *netif, ip_addr_ pcb->ctx_cb = ctx_cb; if (pppol2tp_create(pcb, ppp_over_l2tp_link_status_cb, &pcb->l2tp_pcb, netif, ipaddr, port, secret, secret_len) != ERR_OK) { - ppp_delete(pcb); + ppp_free(pcb); return NULL; } @@ -478,10 +478,7 @@ ppp_sighup(ppp_pcb *pcb) } /* - * Free the control block, clean everything except the PPP PCB itself - * and the netif, it allows you to change the underlying PPP protocol - * (eg. from PPPoE to PPPoS to switch from DSL to GPRS) without losing - * your PPP and netif handlers. + * Release the control block. * * This can only be called if PPP is in the dead phase. * @@ -497,6 +494,8 @@ int ppp_free(ppp_pcb *pcb) { PPPDEBUG(LOG_DEBUG, ("ppp_free: unit %d\n", pcb->num)); + netif_remove(pcb->netif); + #if PPPOE_SUPPORT if (pcb->pppoe_sc) { pppoe_destroy(pcb->pppoe_sc); @@ -516,33 +515,6 @@ int ppp_free(ppp_pcb *pcb) { ppp_free_current_input_packet(&pcb->rx); #endif /* PPPOS_SUPPORT */ - return 0; -} - -/* - * Release the control block. - * - * This can only be called if PPP is in the dead phase. - * - * You must use ppp_close() before if you wish to terminate - * an established PPP session. - * - * Return 0 on success, an error code on failure. - */ -int ppp_delete(ppp_pcb *pcb) { - int err; - - if (pcb->phase != PPP_PHASE_DEAD) { - return PPPERR_PARAM; - } - - PPPDEBUG(LOG_DEBUG, ("ppp_delete: unit %d\n", pcb->num)); - - netif_remove(pcb->netif); - if( (err = ppp_free(pcb)) != PPPERR_NONE) { - return err; - } - memp_free(MEMP_PPP_PCB, pcb); return 0; }