Once the DHCP exchange is complete, if we have an IP address for an NTP
server, set the ntpserverip environment variable accordingly. Although
not necessary to make the sntp command use that server (since it is
known internally to the lwIP stack), this makes the behavior in line
with the legacy NET stack. This is also consistent with exporting the
DNS servers etc.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Michal Simek <michal.simek@amd.com>
char ipstr[] = "ipaddr\0\0";
char maskstr[] = "netmask\0\0";
char gwstr[] = "gatewayip\0\0";
+ const ip_addr_t *ntpserverip;
unsigned long start;
struct netif *netif;
struct dhcp *dhcp;
strncpy(boot_file_name, dhcp->boot_file_name,
sizeof(boot_file_name));
#endif
+ if (CONFIG_IS_ENABLED(CMD_SNTP)) {
+ ntpserverip = sntp_getserver(1);
+ if (ntpserverip != IP_ADDR_ANY)
+ env_set("ntpserverip", ip4addr_ntoa(ntpserverip));
+ }
printf("DHCP client bound to address %pI4 (%lu ms)\n",
&dhcp->offered_ip_addr, get_timer(start));