mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-28 00:15:16 +00:00
PPP, rework initial/reconnect cleanup
Our previous way of doing it was to clear everything except a small part of the ppp_pcb structure and then populate the structure with default values using protocols init functions. But it means the user is currently not allowed to change the default configuration except the few flags and values that are currently available in the ppp_settings structure. Instead of adding more and more fields to the ppp_settings structure, actually making them duplicate of already existing structure members of ppp_pcb, but unfortunately cleaned, we carefully checked that everything is properly cleaned during protocol lowerdown/close and replaced our giant memset to selective memset of the few ppp_pcb members that are not properly cleaned.
This commit is contained in:
parent
c751802fad
commit
7df5496e7b
@ -310,7 +310,6 @@ struct ppp_addrs {
|
||||
* PPP interface control block.
|
||||
*/
|
||||
struct ppp_pcb_s {
|
||||
/* -- below are data that will NOT be cleared between two sessions */
|
||||
ppp_settings settings;
|
||||
const struct link_callbacks *link_cb;
|
||||
void *link_ctx_cb;
|
||||
@ -320,13 +319,6 @@ struct ppp_pcb_s {
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
void *ctx_cb; /* Callbacks optional pointer */
|
||||
struct netif *netif; /* PPP interface */
|
||||
|
||||
/* -- below are data that will be cleared between two sessions */
|
||||
|
||||
/*
|
||||
* phase must be the first member of cleared members, because it is used to know
|
||||
* which part must not be cleared.
|
||||
*/
|
||||
u8_t phase; /* where the link is at */
|
||||
u8_t err_code; /* Code indicating why interface is down. */
|
||||
|
||||
|
@ -697,11 +697,15 @@ void ppp_clear(ppp_pcb *pcb) {
|
||||
|
||||
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. */
|
||||
#if PPP_STATS_SUPPORT
|
||||
link_stats_valid = 0;
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
memset(&pcb->phase, 0, sizeof(ppp_pcb) - ( (char*)&((ppp_pcb*)0)->phase - (char*)0 ) );
|
||||
#if MPPE_SUPPORT
|
||||
pcb->mppe_keys_set = 0;
|
||||
memset(&pcb->mppe_comp, 0, sizeof(pcb->mppe_comp));
|
||||
memset(&pcb->mppe_decomp, 0, sizeof(pcb->mppe_decomp));
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
/*
|
||||
* Initialize each protocol.
|
||||
|
Loading…
Reference in New Issue
Block a user