summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/lwip/dhcp.c14
-rw-r--r--net/lwip/net-lwip.c4
2 files changed, 17 insertions, 1 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));
diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c
index 1a70cedfb58..8741f65fe12 100644
--- a/net/lwip/net-lwip.c
+++ b/net/lwip/net-lwip.c
@@ -7,6 +7,7 @@
#include <dm/device.h>
#include <dm/uclass.h>
#include <hexdump.h>
+#include <linux/compiler_attributes.h>
#include <linux/kernel.h>
#include <lwip/ip4_addr.h>
#include <lwip/dns.h>
@@ -30,7 +31,8 @@ void (*push_packet)(void *, int len) = 0;
int net_try_count;
static int net_restarted;
int net_restart_wrap;
-static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN];
+static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN]
+ __aligned(PKTALIGN);
uchar *net_rx_packets[PKTBUFSRX];
uchar *net_rx_packet;
const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };