X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fipcp.c;h=4957ac59c2f106a35f746af249afa2b84d399be4;hb=6e6bb3246106e680463c106d1ee6b773fc4f9c5a;hp=1ed4c07796706e3a9e9ce63817e75f2b9600fdb2;hpb=731ef5f88822fdccf7894a28c906bf6bf8fa134c;p=ppp.git diff --git a/pppd/ipcp.c b/pppd/ipcp.c index 1ed4c07..4957ac5 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.63 2003/06/29 10:06:14 paulus Exp $" +#define RCSID "$Id: ipcp.c,v 1.66 2004/10/28 00:32:32 paulus Exp $" /* * TODO: @@ -1098,10 +1098,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; @@ -1687,12 +1687,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]); } @@ -1805,6 +1805,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; @@ -1836,6 +1838,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) @@ -1846,6 +1850,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).