aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-07-19 11:10:15 +0100
committerMichael Brown <mcb30@ipxe.org>2023-07-19 11:10:15 +0100
commitd5c08f78bdf45668a955c1f3d3a96f35d8c0e91b (patch)
treee3b1f7cc62d38f6a564ba10fec10d7da14826c52
parentc30b71ee9cc2dc2a1d2f225d99f2d70dd73de247 (diff)
downloadipxe-d5c08f78bdf45668a955c1f3d3a96f35d8c0e91b.zip
ipxe-d5c08f78bdf45668a955c1f3d3a96f35d8c0e91b.tar.gz
ipxe-d5c08f78bdf45668a955c1f3d3a96f35d8c0e91b.tar.bz2
[ntp] Define NTP server setting
Define the IPv4 NTP server setting to simplify the use of a DHCP-provided NTP server in scripts, using e.g. #!ipxe dhcp ntp ${ntp} Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/ipxe/dhcp.h3
-rw-r--r--src/net/udp/ntp.c10
2 files changed, 13 insertions, 0 deletions
diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h
index a1f9ee2..51349ef 100644
--- a/src/include/ipxe/dhcp.h
+++ b/src/include/ipxe/dhcp.h
@@ -86,6 +86,9 @@ struct dhcp_packet;
/** Maximum transmission unit */
#define DHCP_MTU 26
+/** NTP servers */
+#define DHCP_NTP_SERVERS 42
+
/** Vendor encapsulated options */
#define DHCP_VENDOR_ENCAP 43
diff --git a/src/net/udp/ntp.c b/src/net/udp/ntp.c
index 11f8ccc..5592335 100644
--- a/src/net/udp/ntp.c
+++ b/src/net/udp/ntp.c
@@ -36,6 +36,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/timer.h>
#include <ipxe/time.h>
#include <ipxe/tcpip.h>
+#include <ipxe/dhcp.h>
+#include <ipxe/settings.h>
#include <ipxe/ntp.h>
/** @file
@@ -273,3 +275,11 @@ int start_ntp ( struct interface *job, const char *hostname ) {
err_alloc:
return rc;
}
+
+/** IPv4 NTP server setting */
+const struct setting ntp_setting __setting ( SETTING_IP4_EXTRA, ntp ) = {
+ .name = "ntp",
+ .description = "NTP server",
+ .tag = DHCP_NTP_SERVERS,
+ .type = &setting_type_ipv4,
+};