X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fipcp.c;h=efc1af8d87c87abf98678cddf8658008942a915a;hb=a492cec08cacae8eeb09f5a6f0412ebc0e21bda1;hp=c3b052160f949ad74b679bec3c9cac3b15b97fa8;hpb=f53a48eb9d74db3c71938e114b7f489c339bc003;p=ppp.git diff --git a/pppd/ipcp.c b/pppd/ipcp.c index c3b0521..efc1af8 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -40,7 +40,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: ipcp.c,v 1.62 2002/12/04 23:03:32 paulus Exp $" +#define RCSID "$Id: ipcp.c,v 1.67 2004/11/08 11:45:59 paulus Exp $" /* * TODO: @@ -91,6 +91,7 @@ static int default_route_set[NUM_PPP]; /* Have set up a default route */ static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ static bool usepeerdns; /* Ask peer for DNS addrs */ static int ipcp_is_up; /* have called np_up() */ +static int ipcp_is_open; /* haven't called np_finished() */ static bool ask_for_local; /* request our address from peer */ static char vj_value[8]; /* string form of vj option value */ static char netmask_str[20]; /* string form of netmask value */ @@ -602,6 +603,7 @@ ipcp_open(unit) int unit; { fsm_open(&ipcp_fsm[unit]); + ipcp_is_open = 1; } @@ -694,6 +696,7 @@ ipcp_resetci(f) wo->accept_remote = 0; } } + BZERO(&ipcp_hisoptions[f->unit], sizeof(ipcp_options)); } @@ -718,10 +721,8 @@ ipcp_cilen(f) * First see if we want to change our options to the old * forms because we have received old forms from the peer. */ - if ((wo->neg_addr || wo->old_addrs) && !go->neg_addr && !go->old_addrs) { - /* use the old style of address negotiation */ - go->old_addrs = 1; - } + if (go->neg_addr && go->old_addrs && !ho->neg_addr && ho->old_addrs) + go->neg_addr = 0; if (wo->neg_vj && !go->neg_vj && !go->old_vj) { /* try an older style of VJ negotiation */ /* use the old style only if the peer did */ @@ -1096,10 +1097,10 @@ ipcp_nakci(f, p, len) * If they want to negotiate about IP addresses, we comply. * If they want us to ask for compression, we refuse. */ - while (len > CILEN_VOID) { + while (len >= CILEN_VOID) { GETCHAR(citype, p); GETCHAR(cilen, p); - if( (len -= cilen) < 0 ) + if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) goto bad; next = p + cilen - 2; @@ -1685,12 +1686,12 @@ ipcp_up(f) script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0); script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); + if (go->dnsaddr[0]) + script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); + if (go->dnsaddr[1]) + script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); if (usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { script_setenv("USEPEERDNS", "1", 0); - if (go->dnsaddr[0]) - script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); - if (go->dnsaddr[1]) - script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); create_resolv(go->dnsaddr[0], go->dnsaddr[1]); } @@ -1803,6 +1804,8 @@ ipcp_up(f) notice("secondary DNS address %I", go->dnsaddr[1]); } + reset_link_stats(f->unit); + np_up(f->unit, PPP_IP); ipcp_is_up = 1; @@ -1834,6 +1837,8 @@ ipcp_down(f) IPCPDEBUG(("ipcp: down")); /* XXX a bit IPv4-centric here, we only need to get the stats * before the interface is marked down. */ + /* XXX more correct: we must get the stats before running the notifiers, + * at least for the radius plugin */ update_link_stats(f->unit); notify(ip_down_notifier, 0); if (ip_down_hook) @@ -1844,6 +1849,10 @@ ipcp_down(f) } sifvjcomp(f->unit, 0, 0, 0); + print_link_stats(); /* _after_ running the notifiers and ip_down_hook(), + * because print_link_stats() sets link_stats_valid + * to 0 (zero) */ + /* * If we are doing dial-on-demand, set the interface * to queue up outgoing packets (for now). @@ -1894,7 +1903,10 @@ static void ipcp_finished(f) fsm *f; { - np_finished(f->unit, PPP_IP); + if (ipcp_is_open) { + ipcp_is_open = 0; + np_finished(f->unit, PPP_IP); + } }