PPP, make DNS a little more optional if LWIP_DNS is unset

This commit is contained in:
Sylvain Rochet 2015-03-07 23:15:00 +01:00
parent 3ca5184998
commit b3218d45f3
5 changed files with 21 additions and 2 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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 */
}
}

View File

@ -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
/********************************************************************

View File

@ -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);