From 7d7513c71c9255f717585ee695962d9d818e4935 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Mon, 4 Jun 2012 23:19:23 +0200 Subject: [PATCH] re-enabled DNS support --- src/netif/ppp/ipcp.c | 9 ++++---- src/netif/ppp/ppp.c | 47 +++++++++++++++++++++++++++++++++++----- src/netif/ppp/ppp_impl.h | 3 +++ 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index e7e8f03b..66171bb3 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -95,7 +95,6 @@ struct notifier *ip_down_notifier = NULL; /* local vars */ 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 */ @@ -732,8 +731,8 @@ ipcp_resetci(f) wo->accept_local = 1; if (wo->hisaddr == 0) wo->accept_remote = 1; - wo->req_dns1 = usepeerdns; /* Request DNS addresses from the peer */ - wo->req_dns2 = usepeerdns; + wo->req_dns1 = ppp_settings.usepeerdns; /* Request DNS addresses from the peer */ + wo->req_dns2 = ppp_settings.usepeerdns; *go = *wo; if (!ask_for_local) go->ouraddr = 0; @@ -1845,7 +1844,8 @@ ipcp_up(f) if (go->dnsaddr[1]) script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); #endif /* UNUSED */ - if (usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { + if (ppp_settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { + sdns(f->unit, go->dnsaddr[0], go->dnsaddr[1]); /* FIXME: set here the DNS servers ? */ #if 0 /* UNUSED */ script_setenv("USEPEERDNS", "1", 0); @@ -2040,6 +2040,7 @@ ipcp_down(f) sifdown(f->unit); ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr, ipcp_hisoptions[f->unit].hisaddr, 0); + cdns(f->unit, ipcp_gotoptions[f->unit].dnsaddr[0], ipcp_gotoptions[f->unit].dnsaddr[1]); } } diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 892871ea..be6d61c3 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -2052,20 +2052,17 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr, SMEMCPY(&pc->addrs.our_ipaddr, &our_adr, sizeof(our_adr)); SMEMCPY(&pc->addrs.his_ipaddr, &his_adr, sizeof(his_adr)); SMEMCPY(&pc->addrs.netmask, &net_mask, sizeof(net_mask)); -/* FIXME: re-enable DNS - * SMEMCPY(&pc->addrs.dns1, &ns1, sizeof(ns1)); - * SMEMCPY(&pc->addrs.dns2, &ns2, sizeof(ns2)); - */ } return st; } + /******************************************************************** * * cifaddr - Clear the interface IP addresses, and delete routes * through the interface if possible. */ -int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr) { +int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) { ppp_control *pc = &ppp_control_list[unit]; int st = 1; @@ -2077,13 +2074,51 @@ int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr) { } else { IP4_ADDR(&pc->addrs.our_ipaddr, 0,0,0,0); IP4_ADDR(&pc->addrs.his_ipaddr, 0,0,0,0); - IP4_ADDR(&pc->addrs.netmask, 255,255,255,0); + IP4_ADDR(&pc->addrs.netmask, 255,255,255,255); + } + return st; +} + + +/* + * sdns - Config the DNS servers + */ +int sdns (int unit, u_int32_t ns1, u_int32_t ns2) { + ppp_control *pc = &ppp_control_list[unit]; + int st = 1; + + if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("sdns[%d]: bad parms\n", unit)); + } else { + SMEMCPY(&pc->addrs.dns1, &ns1, sizeof(ns1)); + SMEMCPY(&pc->addrs.dns2, &ns2, sizeof(ns2)); + } + return st; +} + + +/******************************************************************** + * + * cdns - Clear the DNS servers + */ +int cdns (int unit, u_int32_t ns1, u_int32_t ns2) { + ppp_control *pc = &ppp_control_list[unit]; + int st = 1; + + LWIP_UNUSED_ARG(ns1); + LWIP_UNUSED_ARG(ns2); + if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) { + st = 0; + PPPDEBUG(LOG_WARNING, ("cifaddr[%d]: bad parms\n", unit)); + } else { IP4_ADDR(&pc->addrs.dns1, 0,0,0,0); IP4_ADDR(&pc->addrs.dns2, 0,0,0,0); } return st; } + /* * sifup - Config the interface up and enable IP packets to pass. */ diff --git a/src/netif/ppp/ppp_impl.h b/src/netif/ppp/ppp_impl.h index 5f3c5a78..a05ce7c2 100644 --- a/src/netif/ppp/ppp_impl.h +++ b/src/netif/ppp/ppp_impl.h @@ -484,6 +484,9 @@ int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp); int sifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr, u_int32_t net_mask); int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr); +int sdns(int unit, u_int32_t ns1, u_int32_t ns2); +int cdns(int unit, u_int32_t ns1, u_int32_t ns2); + int sifup(int u); int sifdown (int u);