#include <byteswap.h>
#include <errno.h>
#include <assert.h>
+#include <time.h>
#include <ipxe/in.h>
#include <ipxe/ip.h>
#include <ipxe/ipv6.h>
.fetch = version_fetch,
};
+/**
+ * Fetch current time setting
+ *
+ * @v data Buffer to fill with setting data
+ * @v len Length of buffer
+ * @ret len Length of setting data, or negative error
+ */
+static int unixtime_fetch ( void *data, size_t len ) {
+ uint32_t content;
+
+ /* Return current time */
+ content = htonl ( time(NULL) );
+ if ( len > sizeof ( content ) )
+ len = sizeof ( content );
+ memcpy ( data, &content, len );
+ return sizeof ( content );
+}
+
+/** Current time setting */
+const struct setting unixtime_setting __setting ( SETTING_MISC, unixtime ) = {
+ .name = "unixtime",
+ .description = "Seconds since the Epoch",
+ .type = &setting_type_uint32,
+ .scope = &builtin_scope,
+};
+
+/** Current time built-in setting */
+struct builtin_setting unixtime_builtin_setting __builtin_setting = {
+ .setting = &unixtime_setting,
+ .fetch = unixtime_fetch,
+};
+
/**
* Fetch built-in setting
*