diff --git a/doc/ppp.txt b/doc/ppp.txt index bf4673ef..f380df02 100644 --- a/doc/ppp.txt +++ b/doc/ppp.txt @@ -326,6 +326,17 @@ ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "login", "password"); /* Require peer to authenticate */ ppp_set_auth_required(ppp, 1); +/* + * Only for PPPoS, the PPP session should be up and waiting for input. + * + * Note: for PPPoS, ppp_connect() and ppp_listen() are actually the same thing. + * The listen call is meant for future support of PPPoE and PPPoL2TP server + * mode, where we will need to negotiate the incoming PPPoE session or L2TP + * session before initiating PPP itself. We need this call because there is + * two passive modes for PPPoS, ppp_set_passive and ppp_set_silent. + */ +ppp_set_silent(pppos, 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 862b8269..ac7bee42 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -509,6 +509,20 @@ void ppp_set_mppe(ppp_pcb *pcb, u8_t flags); */ #define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval) +/* + * Enables the "passive" option in the LCP. With this option, we will attempt + * to initiate a connection; if no reply is received from the peer, we will + * then just wait passively for a valid LCP packet from the peer. + */ +#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval) + +/* + * With this option, we will not transmit LCP packets to initiate a connection + * until a valid LCP packet is received from the peer. This is what we usually + * call the server mode. + */ +#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval) + /* * Set a PPP interface as the default network interface * (used to output all packets for which no specific route is found). diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index c0d2004b..fe7d544b 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -288,18 +288,12 @@ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff) { * established before calling this. */ err_t ppp_listen(ppp_pcb *pcb) { - lcp_options *lcp_wo; - if (pcb->phase != PPP_PHASE_DEAD) { return ERR_ALREADY; } PPPDEBUG(LOG_DEBUG, ("ppp_listen[%d]\n", pcb->netif->num)); - /* Wait passively */ - lcp_wo = &pcb->lcp_wantoptions; - lcp_wo->silent = 1; - if (pcb->link_cb->listen) { return pcb->link_cb->listen(pcb, pcb->link_ctx_cb); }