From 6b4db944dd2ee81983cd31f9344ab98a44286322 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Fri, 20 Feb 2015 21:24:58 +0100 Subject: [PATCH] PPP, using err_t return code instead of PPPERR_ Standardised PPP API to follow lwIP already used return codes. PPPERR_ are now used only on link status callback. --- src/api/pppapi.c | 6 +++--- src/include/lwip/pppapi.h | 8 ++++---- src/include/netif/ppp/ppp.h | 6 +++--- src/netif/ppp/ppp.c | 18 +++++++++--------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/api/pppapi.c b/src/api/pppapi.c index daf3a483..759b3f1d 100644 --- a/src/api/pppapi.c +++ b/src/api/pppapi.c @@ -249,7 +249,7 @@ pppapi_do_ppp_open(struct pppapi_msg_msg *msg) * Call ppp_open() in a thread-safe way by running that function inside the * tcpip_thread context. */ -int +err_t pppapi_open(ppp_pcb *pcb, u16_t holdoff) { struct pppapi_msg msg; @@ -275,7 +275,7 @@ pppapi_do_ppp_close(struct pppapi_msg_msg *msg) * Call ppp_close() in a thread-safe way by running that function inside the * tcpip_thread context. */ -int +err_t pppapi_close(ppp_pcb *pcb) { struct pppapi_msg msg; @@ -324,7 +324,7 @@ pppapi_do_ppp_free(struct pppapi_msg_msg *msg) * Call ppp_free() in a thread-safe way by running that function inside the * tcpip_thread context. */ -int +err_t pppapi_free(ppp_pcb *pcb) { struct pppapi_msg msg; diff --git a/src/include/lwip/pppapi.h b/src/include/lwip/pppapi.h index 2adfa4ac..dadbc689 100644 --- a/src/include/lwip/pppapi.h +++ b/src/include/lwip/pppapi.h @@ -44,7 +44,7 @@ struct pppapi_msg_msg { #if !LWIP_TCPIP_CORE_LOCKING sys_sem_t sem; #endif /* !LWIP_TCPIP_CORE_LOCKING */ - int err; + err_t err; ppp_pcb *ppp; union { struct { @@ -133,10 +133,10 @@ ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_add u8_t *secret, u8_t secret_len, ppp_link_status_cb_fn link_status_cb, void *ctx_cb); #endif /* PPPOL2TP_SUPPORT */ -int pppapi_open(ppp_pcb *pcb, u16_t holdoff); -int pppapi_close(ppp_pcb *pcb); +err_t pppapi_open(ppp_pcb *pcb, u16_t holdoff); +err_t pppapi_close(ppp_pcb *pcb); void pppapi_sighup(ppp_pcb *pcb); -int pppapi_free(ppp_pcb *pcb); +err_t pppapi_free(ppp_pcb *pcb); err_t 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 e08455ff..bbf9073f 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -464,14 +464,14 @@ void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_p * Holdoff is the time to wait (in seconds) before initiating * the connection. */ -int ppp_open(ppp_pcb *pcb, u16_t holdoff); +err_t ppp_open(ppp_pcb *pcb, u16_t holdoff); /* * Initiate the end of a PPP connection. * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ -int ppp_close(ppp_pcb *pcb); +err_t ppp_close(ppp_pcb *pcb); /* * Indicate to the PPP stack that the line has disconnected. @@ -488,7 +488,7 @@ void ppp_sighup(ppp_pcb *pcb); * * Return 0 on success, an error code on failure. */ -int ppp_free(ppp_pcb *pcb); +err_t 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 190732fc..992680c2 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -250,9 +250,9 @@ void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_p * Holdoff is the time to wait (in seconds) before initiating * the connection. */ -int ppp_open(ppp_pcb *pcb, u16_t holdoff) { +err_t ppp_open(ppp_pcb *pcb, u16_t holdoff) { if (pcb->phase != PPP_PHASE_DEAD) { - return PPPERR_PARAM; + return ERR_ALREADY; } PPPDEBUG(LOG_DEBUG, ("ppp_open() called, holdoff=%d\n", holdoff)); @@ -263,7 +263,7 @@ int ppp_open(ppp_pcb *pcb, u16_t holdoff) { new_phase(pcb, PPP_PHASE_HOLDOFF); sys_timeout((u32_t)(holdoff*1000), ppp_do_open, pcb); - return PPPERR_NONE; + return ERR_OK; } /* @@ -271,7 +271,7 @@ int ppp_open(ppp_pcb *pcb, u16_t holdoff) { * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ -int +err_t ppp_close(ppp_pcb *pcb) { pcb->err_code = PPPERR_USER; @@ -279,14 +279,14 @@ ppp_close(ppp_pcb *pcb) /* dead phase, nothing to do, call the status callback to be consistent */ if (pcb->phase == PPP_PHASE_DEAD) { pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb); - return PPPERR_NONE; + return ERR_OK; } /* holdoff phase, cancel the reconnection and call the status callback */ if (pcb->phase == PPP_PHASE_HOLDOFF) { sys_untimeout(ppp_do_open, pcb); pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb); - return PPPERR_NONE; + return ERR_OK; } PPPDEBUG(LOG_DEBUG, ("ppp_close() called\n")); @@ -296,7 +296,7 @@ ppp_close(ppp_pcb *pcb) /* LCP close request, this will leave us at PPP_PHASE_DEAD. */ lcp_close(pcb, "User request"); - return PPPERR_NONE; + return ERR_OK; } /* This function is called when carrier is lost on the PPP channel. */ @@ -319,10 +319,10 @@ ppp_sighup(ppp_pcb *pcb) * * Return 0 on success, an error code on failure. */ -int ppp_free(ppp_pcb *pcb) { +err_t ppp_free(ppp_pcb *pcb) { int err; if (pcb->phase != PPP_PHASE_DEAD) { - return PPPERR_PARAM; + return ERR_CONN; } PPPDEBUG(LOG_DEBUG, ("ppp_free: unit %d\n", pcb->num));