From 10be59cc15a57ff4d6d0050f9fa816f469d64237 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Mon, 14 Mar 2016 14:47:38 +0100 Subject: [PATCH] Update nameserver using DHCP info --- core/net/ip64/ip64-ipv4-dhcp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/net/ip64/ip64-ipv4-dhcp.c b/core/net/ip64/ip64-ipv4-dhcp.c index a8de88b6f..a22c9f903 100644 --- a/core/net/ip64/ip64-ipv4-dhcp.c +++ b/core/net/ip64/ip64-ipv4-dhcp.c @@ -88,8 +88,15 @@ ip64_dhcpc_configured(const struct ip64_dhcpc_state *s) ip64_set_hostaddr((uip_ip4addr_t *)&s->ipaddr); ip64_set_netmask((uip_ip4addr_t *)&s->netmask); ip64_set_draddr((uip_ip4addr_t *)&s->default_router); - ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr); - // mdns_conf(&ip6dnsaddr); + if(!uip_ip4addr_cmp((uip_ip4addr_t *)&s->dnsaddr, &uip_all_zeroes_addr)) { + /* Note: Currently we assume only one DNS server */ + uip_ipaddr_t * dns = uip_nameserver_get(0); + /* Only update DNS entry if it is empty or already IPv4 */ + if(uip_is_addr_unspecified(dns) || ip64_addr_is_ip64(dns)) { + ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr); + uip_nameserver_update(&ip6dnsaddr, uip_ntohs(s->lease_time[0])*65536ul + uip_ntohs(s->lease_time[1])); + } + } } /*---------------------------------------------------------------------------*/ void