From: Michael Brown Date: Wed, 19 Jul 2023 10:10:15 +0000 (+0100) Subject: [ntp] Define NTP server setting X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c08f78bdf45668a955c1f3d3a96f35d8c0e91b;p=thirdparty%2Fipxe.git [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 --- diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h index a1f9ee250..51349efd9 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 11f8ccc00..559233575 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 #include #include +#include +#include #include /** @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, +};