From 50b5b4c4dd6691a1eeefb6cde3636049162839d8 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 2 Jul 2016 19:09:50 +0200 Subject: [PATCH] PPP, PPPAPI: remove useless pppapi_set_auth function Setting PPP authentication most only be done when the PPP PCB is in the dead phase (i.e. disconnected). This is safe to access the PPP PCB members while the session is down, therefore providing a thread-safe function of it is meaningless and it might even be misleading. All our new ppp_set_* functions do not have their equivalent pppapi_set_* functions and they are not going to have them. At least we make ppp_set_auth consistent with all others ppp_set_*, so that it doesn't look like special. --- src/include/netif/ppp/ppp.h | 7 ++++++- src/include/netif/ppp/pppapi.h | 6 ------ src/netif/ppp/pppapi.c | 34 ---------------------------------- 3 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index d819a9f3..de740ec7 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -423,7 +423,12 @@ struct ppp_pcb_s { ************************/ /* - * Set auth helper, optional, you can either fill ppp_pcb->settings. + * WARNING: For multi-threads environment, all ppp_set_* functions most + * only be called while the PPP is in the dead phase (i.e. disconnected). + */ + +/* + * Set PPP authentication. * * Warning: Using PPPAUTHTYPE_ANY might have security consequences. * RFC 1994 says: diff --git a/src/include/netif/ppp/pppapi.h b/src/include/netif/ppp/pppapi.h index c5974e1e..913d93f7 100644 --- a/src/include/netif/ppp/pppapi.h +++ b/src/include/netif/ppp/pppapi.h @@ -47,11 +47,6 @@ extern "C" { struct pppapi_msg_msg { ppp_pcb *ppp; union { - struct { - u8_t authtype; - const char *user; - const char *passwd; - } setauth; #if PPP_NOTIFY_PHASE struct { ppp_notify_phase_cb_fn notify_phase_cb; @@ -109,7 +104,6 @@ struct pppapi_msg { /* API for application */ err_t pppapi_set_default(ppp_pcb *pcb); -err_t pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd); #if PPP_NOTIFY_PHASE err_t pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb); #endif /* PPP_NOTIFY_PHASE */ diff --git a/src/netif/ppp/pppapi.c b/src/netif/ppp/pppapi.c index 8dc54f80..32b479df 100644 --- a/src/netif/ppp/pppapi.c +++ b/src/netif/ppp/pppapi.c @@ -81,40 +81,6 @@ pppapi_set_default(ppp_pcb *pcb) } -/** - * Call ppp_set_auth() inside the tcpip_thread context. - */ -static err_t -pppapi_do_ppp_set_auth(struct tcpip_api_call_data *m) -{ - struct pppapi_msg *msg = (struct pppapi_msg *)m; - - ppp_set_auth(msg->msg.ppp, msg->msg.msg.setauth.authtype, - msg->msg.msg.setauth.user, msg->msg.msg.setauth.passwd); - return ERR_OK; -} - -/** - * Call ppp_set_auth() in a thread-safe way by running that function inside the - * tcpip_thread context. - */ -err_t -pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) -{ - err_t err; - PPPAPI_VAR_DECLARE(msg); - PPPAPI_VAR_ALLOC(msg); - - PPPAPI_VAR_REF(msg).msg.ppp = pcb; - PPPAPI_VAR_REF(msg).msg.msg.setauth.authtype = authtype; - PPPAPI_VAR_REF(msg).msg.msg.setauth.user = user; - PPPAPI_VAR_REF(msg).msg.msg.setauth.passwd = passwd; - err = tcpip_api_call(pppapi_do_ppp_set_auth, &PPPAPI_VAR_REF(msg).call); - PPPAPI_VAR_FREE(msg); - return err; -} - - #if PPP_NOTIFY_PHASE /** * Call ppp_set_notify_phase_callback() inside the tcpip_thread context.