summaryrefslogtreecommitdiff
path: root/net/lwip/dhcp.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-09-30 08:57:25 -0600
committerTom Rini <trini@konsulko.com>2025-09-30 08:57:25 -0600
commit662672dede1ddc77c99dcea03c490603abf05786 (patch)
tree20a5cf6382b26ab2b5a5e64cb716f02f975468f8 /net/lwip/dhcp.c
parenta239b0b0b6dbe6a168969b8cd6e600cf85db278d (diff)
parentb2217c935e3f30d15821b1c5183ab4dd4c9d9dd2 (diff)
Merge tag 'net-20250930' of https://source.denx.de/u-boot/custodians/u-boot-net
Pull request net-20250930 net-common: - DesignWare: avoid regulator enable failure - Fix RMII help text net-lwip: - Ensure alignment of packet buffers - Use NTP server(s) obtained from DHCP
Diffstat (limited to 'net/lwip/dhcp.c')
-rw-r--r--net/lwip/dhcp.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/lwip/dhcp.c b/net/lwip/dhcp.c
index 4c9cb0ecaa0..531bf2c6705 100644
--- a/net/lwip/dhcp.c
+++ b/net/lwip/dhcp.c
@@ -8,6 +8,7 @@
#include <dm/device.h>
#include <linux/delay.h>
#include <linux/errno.h>
+#include <lwip/apps/sntp.h>
#include <lwip/dhcp.h>
#include <lwip/dns.h>
#include <lwip/timeouts.h>
@@ -32,6 +33,7 @@ static int dhcp_loop(struct udevice *udev)
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;
@@ -48,6 +50,13 @@ static int dhcp_loop(struct udevice *udev)
if (!netif)
return CMD_RET_FAILURE;
+ /*
+ * Request the DHCP stack to parse and store the NTP servers for
+ * eventual use by the SNTP command
+ */
+ if (CONFIG_IS_ENABLED(CMD_SNTP))
+ sntp_servermode_dhcp(1);
+
start = get_timer(0);
if (dhcp_start(netif))
@@ -102,6 +111,11 @@ static int dhcp_loop(struct udevice *udev)
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));