From b3218d45f364314e7a85371ea933709ac0add24d Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 7 Mar 2015 23:15:00 +0100 Subject: [PATCH] PPP, make DNS a little more optional if LWIP_DNS is unset --- src/include/netif/ppp/ppp.h | 6 ++++++ src/include/netif/ppp/ppp_impl.h | 2 ++ src/netif/ppp/ipcp.c | 9 +++++++-- src/netif/ppp/ppp.c | 4 ++++ src/netif/ppp/pppos.c | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index 7232bedd..4af716ad 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -212,7 +212,11 @@ typedef struct ppp_settings_s { #else unsigned int :1; /* 1 bit of padding */ #endif /* EAP_SUPPORT */ +#if LWIP_DNS unsigned int usepeerdns :1; /* Ask peer for DNS adds */ +#else + unsigned int :1; /* 1 bit of padding */ +#endif /* LWIP_DNS */ unsigned int persist :1; /* Persist mode, always try to open the connection */ #if PRINTPKT_SUPPORT unsigned int hide_password :1; /* Hide password in dumped packets */ @@ -288,7 +292,9 @@ typedef struct ppp_settings_s { struct ppp_addrs { #if PPP_IPV4_SUPPORT ip_addr_t our_ipaddr, his_ipaddr, netmask; +#if LWIP_DNS ip_addr_t dns1, dns2; +#endif /* LWIP_DNS */ #endif /* PPP_IPV4_SUPPORT */ #if PPP_IPV6_SUPPORT ip6_addr_t our6_ipaddr, his6_ipaddr; diff --git a/src/include/netif/ppp/ppp_impl.h b/src/include/netif/ppp/ppp_impl.h index a887d5c1..782ee628 100644 --- a/src/include/netif/ppp/ppp_impl.h +++ b/src/include/netif/ppp/ppp_impl.h @@ -447,8 +447,10 @@ int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t net_mask); int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr); int sifproxyarp(ppp_pcb *pcb, u32_t his_adr); int cifproxyarp(ppp_pcb *pcb, u32_t his_adr); +#if LWIP_DNS int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2); int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2); +#endif /* LWIP_DNS */ #if VJ_SUPPORT int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid); #endif /* VJ_SUPPORT */ diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index 355483f5..bdafec61 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -718,8 +718,9 @@ static void ipcp_resetci(fsm *f) { wo->accept_local = 1; if (wo->hisaddr == 0) wo->accept_remote = 1; - wo->req_dns1 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */ - wo->req_dns2 = pcb->settings.usepeerdns; +#if LWIP_DNS + wo->req_dns1 = wo->req_dns2 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */ +#endif /* LWIP_DNS */ *go = *wo; #if 0 /* UNUSED */ /* We don't need ask_for_local, this is only useful for setup which @@ -1837,6 +1838,7 @@ static void ipcp_up(fsm *f) { if (go->dnsaddr[1]) script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); #endif /* UNUSED */ +#if LWIP_DNS if (pcb->settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { sdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); #if 0 /* UNUSED */ @@ -1844,6 +1846,7 @@ static void ipcp_up(fsm *f) { create_resolv(go->dnsaddr[0], go->dnsaddr[1]); #endif /* UNUSED */ } +#endif /* LWIP_DNS */ /* FIXME: check why it fails, just to know */ #if 0 /* Unused */ @@ -2043,7 +2046,9 @@ static void ipcp_down(fsm *f) { sifdown(pcb); ipcp_clear_addrs(pcb, go->ouraddr, ho->hisaddr, 0); +#if LWIP_DNS cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); +#endif /* LWIP_DNS */ } } diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 8b58f352..7e7617fe 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -512,7 +512,9 @@ ppp_pcb *ppp_new(struct netif *pppif, ppp_link_status_cb_fn link_status_cb, void memset(pcb, 0, sizeof(ppp_pcb)); /* default configuration */ +#if LWIP_DNS pcb->settings.usepeerdns = 1; +#endif /* LWIP_DNS */ #if PAP_SUPPORT pcb->settings.pap_timeout_time = UPAP_DEFTIMEOUT; @@ -910,6 +912,7 @@ int cifproxyarp(ppp_pcb *pcb, u32_t his_adr) { return 0; } +#if LWIP_DNS /* * sdns - Config the DNS servers */ @@ -933,6 +936,7 @@ int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) { ip_addr_set_zero(&pcb->addrs.dns2); return 1; } +#endif /* LWIP_DNS */ #if VJ_SUPPORT /******************************************************************** diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 23dd75b9..179b52da 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -458,8 +458,10 @@ pppos_listen(ppp_pcb *ppp, void *ctx, struct ppp_addrs *addrs) ipcp_wo = &ppp->ipcp_wantoptions; ipcp_wo->ouraddr = ip4_addr_get_u32(&addrs->our_ipaddr); ipcp_wo->hisaddr = ip4_addr_get_u32(&addrs->his_ipaddr); +#if LWIP_DNS ipcp_wo->dnsaddr[0] = ip4_addr_get_u32(&addrs->dns1); ipcp_wo->dnsaddr[1] = ip4_addr_get_u32(&addrs->dns2); +#endif /* LWIP_DNS */ #if VJ_SUPPORT vj_compress_init(&pppos->vj_comp);