PPP: introduce ppp_set_passive and ppp_set_silent

There is two passive modes for PPPoS, passive more, for which we will
try to connect and then listen silently, and silent mode, for which we
will listen silently from the beginning.

Introduce ppp_set_passive and ppp_set_silent so the mode can be chosen
before connecting/listening.
This commit is contained in:
Sylvain Rochet 2016-07-02 20:59:50 +02:00
parent b97c4d96e2
commit e7069d6e82
3 changed files with 25 additions and 6 deletions

View File

@ -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).

View File

@ -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).

View File

@ -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);
}