diff --git a/src/netif/ppp/ccp.c b/src/netif/ppp/ccp.c index 8428dfb7..f8519ebe 100644 --- a/src/netif/ppp/ccp.c +++ b/src/netif/ppp/ccp.c @@ -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)); diff --git a/src/netif/ppp/chap-new.c b/src/netif/ppp/chap-new.c index 9e7e66c5..485122d2 100644 --- a/src/netif/ppp/chap-new.c +++ b/src/netif/ppp/chap-new.c @@ -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)); diff --git a/src/netif/ppp/ecp.c b/src/netif/ppp/ecp.c index 68e5bcb9..4d84f609 100644 --- a/src/netif/ppp/ecp.c +++ b/src/netif/ppp/ecp.c @@ -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)); diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index c42fdf76..06e1eac3 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -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 */ diff --git a/src/netif/ppp/ipv6cp.c b/src/netif/ppp/ipv6cp.c index f02558e0..db24305c 100644 --- a/src/netif/ppp/ipv6cp.c +++ b/src/netif/ppp/ipv6cp.c @@ -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 */ diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 16aba02f..95cc22b0 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -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 */