From 96296947fcc217877f7baa664fc7374033e4fc14 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 26 Jun 2016 22:31:02 +0200 Subject: [PATCH] PPP: introduce ppp_set_auth_required macro PPP auth required flag is currently hardcoded to true if PPP is acting as a server and set to false if PPP is acting as a client. This is probably the most wanted behavior, but since we now have the ability to change that at runtime, allow users to do it. It means we can now have a server which asks the client to authenticate or vice versa. This is pretty unusual thought. What we don't support yet is mutual authentication with a different set of user and password per direction which is even less usual. --- doc/ppp.txt | 3 +++ src/include/netif/ppp/ppp.h | 7 +++++++ src/netif/ppp/pppos.c | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/ppp.txt b/doc/ppp.txt index 3dc8ad73..bf4673ef 100644 --- a/doc/ppp.txt +++ b/doc/ppp.txt @@ -323,6 +323,9 @@ ppp_set_ipcp_dnsaddr(ppp, 1, &addr); /* Auth configuration, this is pretty self-explanatory */ ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "login", "password"); +/* Require peer to authenticate */ +ppp_set_auth_required(ppp, 1); + /* * Initiate PPP listener (i.e. wait for an incoming connection), can only * be called if PPP session is in the dead state (i.e. disconnected). diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index 20f41dbb..1ed10298 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -453,6 +453,13 @@ struct ppp_pcb_s { #define PPPAUTHTYPE_ANY 0xff void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd); +#if PPP_AUTH_SUPPORT +/* + * Whether peer is required to authenticate. This is mostly necessary for PPP server support. + */ +#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval) +#endif /* PPP_AUTH_SUPPORT */ + #if PPP_IPV4_SUPPORT /* * Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 3478a76b..0ecbec7a 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -351,12 +351,6 @@ pppos_listen(ppp_pcb *ppp, void *ctx) lcp_wo = &ppp->lcp_wantoptions; lcp_wo->silent = 1; -#if PPP_AUTH_SUPPORT - if (ppp->settings.user && ppp->settings.passwd) { - ppp->settings.auth_required = 1; - } -#endif /* PPP_AUTH_SUPPORT */ - /* * Default the in and out accm so that escape and flag characters * are always escaped.