]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ntp] Define NTP server setting
authorMichael Brown <mcb30@ipxe.org>
Wed, 19 Jul 2023 10:10:15 +0000 (11:10 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 19 Jul 2023 10:10:15 +0000 (11:10 +0100)
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>
src/include/ipxe/dhcp.h
src/net/udp/ntp.c

index a1f9ee250e557aad03dbec2d06ac816448d9d0a7..51349efd9155f0c8563d62ba2010563dec541c18 100644 (file)
@@ -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
 
index 11f8ccc0093f806a25cbbd3c419b18e84f42f43c..5592335755a94f88fc4c436a0027a840005962d1 100644 (file)
@@ -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,
+};