PPP, move protocols initialization from ppp_clear to ppp_new

What protocols init functions are meant to is to be called once to set
the default configuration before user specific configuration is set.

Until now, we reset to the default configuration just before
reconnecting, thus without allowing any time frame to let users change
it. That was fine until one user asked to be able to do that.

This change move protocols init functions calls from ppp_clear to
ppp_new, meaning user configuration is not overwritten anymore.
This commit is contained in:
Sylvain Rochet 2016-06-19 23:48:08 +02:00
parent 7df5496e7b
commit 42d50eba4e
6 changed files with 15 additions and 16 deletions

View File

@ -373,7 +373,7 @@ static void ccp_init(ppp_pcb *pcb) {
f->callbacks = &ccp_callbacks;
fsm_init(f);
#if 0 /* Not necessary, everything is cleared in ppp_clear() */
#if 0 /* Not necessary, everything is cleared in ppp_new() */
memset(wo, 0, sizeof(*wo));
memset(go, 0, sizeof(*go));
memset(ao, 0, sizeof(*ao));

View File

@ -124,7 +124,7 @@ static const struct chap_digest_type* const chap_digests[] = {
static void chap_init(ppp_pcb *pcb) {
LWIP_UNUSED_ARG(pcb);
#if 0 /* Not necessary, everything is cleared in ppp_clear() */
#if 0 /* Not necessary, everything is cleared in ppp_new() */
memset(&pcb->chap_client, 0, sizeof(chap_client_state));
#if PPP_SERVER
memset(&pcb->chap_server, 0, sizeof(chap_server_state));

View File

@ -166,7 +166,7 @@ ecp_init(unit)
f->callbacks = &ecp_callbacks;
fsm_init(f);
#if 0 /* Not necessary, everything is cleared in ppp_clear() */
#if 0 /* Not necessary, everything is cleared in ppp_new() */
memset(&ecp_wantoptions[unit], 0, sizeof(ecp_options));
memset(&ecp_gotoptions[unit], 0, sizeof(ecp_options));
memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options));

View File

@ -611,7 +611,7 @@ static void ipcp_init(ppp_pcb *pcb) {
*/
f->maxnakloops = 100;
#if 0 /* Not necessary, everything is cleared in ppp_clear() */
#if 0 /* Not necessary, everything is cleared in ppp_new() */
memset(wo, 0, sizeof(*wo));
memset(ao, 0, sizeof(*ao));
#endif /* 0 */

View File

@ -435,7 +435,7 @@ static void ipv6cp_init(ppp_pcb *pcb) {
f->callbacks = &ipv6cp_callbacks;
fsm_init(f);
#if 0 /* Not necessary, everything is cleared in ppp_clear() */
#if 0 /* Not necessary, everything is cleared in ppp_new() */
memset(wo, 0, sizeof(*wo));
memset(ao, 0, sizeof(*ao));
#endif /* 0 */

View File

@ -613,6 +613,8 @@ int ppp_init(void)
*/
ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, void *link_ctx_cb, ppp_link_status_cb_fn link_status_cb, void *ctx_cb) {
ppp_pcb *pcb;
const struct protent *protp;
int i;
/* PPP is single-threaded: without a callback,
* there is no way to know when the link is up. */
@ -686,15 +688,20 @@ ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, vo
pcb->link_ctx_cb = link_ctx_cb;
pcb->link_status_cb = link_status_cb;
pcb->ctx_cb = ctx_cb;
/*
* Initialize each protocol.
*/
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
(*protp->init)(pcb);
}
new_phase(pcb, PPP_PHASE_DEAD);
return pcb;
}
/* Set a PPP PCB to its initial state */
void ppp_clear(ppp_pcb *pcb) {
const struct protent *protp;
int i;
LWIP_ASSERT("pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF", pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF);
/* Clean data not taken care by anything else, mostly shared data. */
@ -706,14 +713,6 @@ void ppp_clear(ppp_pcb *pcb) {
memset(&pcb->mppe_comp, 0, sizeof(pcb->mppe_comp));
memset(&pcb->mppe_decomp, 0, sizeof(pcb->mppe_decomp));
#endif /* MPPE_SUPPORT */
/*
* Initialize each protocol.
*/
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
(*protp->init)(pcb);
}
#if VJ_SUPPORT && LWIP_TCP
vj_compress_init(&pcb->vj_comp);
#endif /* VJ_SUPPORT && LWIP_TCP */