From dbbaa3c416db7c404bdf167c7984fe0777367438 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 13 Apr 2010 13:34:12 -0500 Subject: [PATCH] ppp: Reset the options whenever the layer is down So we can re-negotiate the options if the layer is opened again. --- gatchat/ppp_ipcp.c | 25 +++++++++++++++++++------ gatchat/ppp_lcp.c | 18 +++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/gatchat/ppp_ipcp.c b/gatchat/ppp_ipcp.c index 26092de..74e7778 100644 --- a/gatchat/ppp_ipcp.c +++ b/gatchat/ppp_ipcp.c @@ -101,6 +101,20 @@ static void ipcp_generate_config_options(struct ipcp_data *ipcp) ipcp->options_len = len; } +static void ipcp_reset_config_options(struct ipcp_data *ipcp) +{ + ipcp->req_options = REQ_OPTION_IPADDR | REQ_OPTION_DNS1 | + REQ_OPTION_DNS2 | REQ_OPTION_NBNS1 | + REQ_OPTION_NBNS2; + ipcp->ipaddr = 0; + ipcp->dns1 = 0; + ipcp->dns2 = 0; + ipcp->nbns1 = 0; + ipcp->nbns2 = 0; + + ipcp_generate_config_options(ipcp); +} + static void ipcp_up(struct pppcp_data *pppcp) { struct ipcp_data *ipcp = pppcp_get_data(pppcp); @@ -129,6 +143,10 @@ static void ipcp_up(struct pppcp_data *pppcp) static void ipcp_down(struct pppcp_data *pppcp) { + struct ipcp_data *ipcp = pppcp_get_data(pppcp); + + ipcp_reset_config_options(ipcp); + pppcp_set_local_options(pppcp, ipcp->options, ipcp->options_len); } /* @@ -307,12 +325,7 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp) } pppcp_set_data(pppcp, ipcp); - - ipcp->req_options = REQ_OPTION_IPADDR | REQ_OPTION_DNS1 | - REQ_OPTION_DNS2 | REQ_OPTION_NBNS1 | - REQ_OPTION_NBNS2; - - ipcp_generate_config_options(ipcp); + ipcp_reset_config_options(ipcp); pppcp_set_local_options(pppcp, ipcp->options, ipcp->options_len); return pppcp; diff --git a/gatchat/ppp_lcp.c b/gatchat/ppp_lcp.c index 304a72c..e945fea 100644 --- a/gatchat/ppp_lcp.c +++ b/gatchat/ppp_lcp.c @@ -90,6 +90,14 @@ static void lcp_generate_config_options(struct lcp_data *lcp) lcp->options_len = len; } +static void lcp_reset_config_options(struct lcp_data *lcp) +{ + lcp->req_options = REQ_OPTION_ACCM; + lcp->accm = 0; + + lcp_generate_config_options(lcp); +} + /* * signal the Up event to the NCP */ @@ -103,7 +111,10 @@ static void lcp_up(struct pppcp_data *pppcp) */ static void lcp_down(struct pppcp_data *pppcp) { - /* XXX should implement a way to signal NCP */ + struct lcp_data *lcp = pppcp_get_data(pppcp); + + lcp_reset_local_options(lcp); + pppcp_set_local_options(pppcp, lcp->options, lcp->options_len); } /* @@ -255,10 +266,7 @@ struct pppcp_data *lcp_new(GAtPPP *ppp) pppcp_set_data(pppcp, lcp); - lcp->req_options = REQ_OPTION_ACCM; - lcp->accm = 0; - - lcp_generate_config_options(lcp); + lcp_reset_local_options(lcp); pppcp_set_local_options(pppcp, lcp->options, lcp->options_len); return pppcp; -- 2.7.4