diff options
author | Michael Brown | 2006-08-11 20:00:22 +0200 |
---|---|---|
committer | Michael Brown | 2006-08-11 20:00:22 +0200 |
commit | db469723493f61c7df16f7933b715ba084f819f0 (patch) | |
tree | fbeee1bdd8861043396013838345772135927e99 /src/include/gpxe/settings.h | |
parent | Removing because of conflict with new HTTP protocol (diff) | |
download | ipxe-db469723493f61c7df16f7933b715ba084f819f0.tar.gz ipxe-db469723493f61c7df16f7933b715ba084f819f0.tar.xz ipxe-db469723493f61c7df16f7933b715ba084f819f0.zip |
Added basic infrastructure for manipulating settings.
Diffstat (limited to 'src/include/gpxe/settings.h')
-rw-r--r-- | src/include/gpxe/settings.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/include/gpxe/settings.h b/src/include/gpxe/settings.h new file mode 100644 index 00000000..f05805f2 --- /dev/null +++ b/src/include/gpxe/settings.h @@ -0,0 +1,103 @@ +#ifndef _GPXE_SETTINGS_H +#define _GPXE_SETTINGS_H + +/** @file + * + * Configuration settings + * + */ + +#include <stdint.h> +#include <gpxe/dhcp.h> +#include <gpxe/tables.h> + +struct config_setting; + +/** + * A configuration context + * + * This identifies the context within which settings are inspected and + * changed. For example, the context might be global, or might be + * restricted to the settings stored in NVS on a particular device. + */ +struct config_context { + /** DHCP options block, or NULL + * + * If NULL, all registered DHCP options blocks will be used. + */ + struct dhcp_option_block *options; +}; + +/** + * A configuration setting type + * + * This represents a type of configuration setting (e.g. string, IPv4 + * address, etc.). + */ +struct config_setting_type { + /** Name + * + * This is the name exposed to the user (e.g. "string"). + */ + const char *name; + /** Show value of setting + * + * @v context Configuration context + * @v setting Configuration setting + * @ret value Setting value (as a string), or NULL + */ + const char * ( * show ) ( struct config_context *context, + struct config_setting *setting ); + /** Set value of setting + * + * @v context Configuration context + * @v setting Configuration setting + * @v value Setting value (as a string) + * @ret rc Return status code + */ + int ( * set ) ( struct config_context *context, + struct config_setting *setting, + const char *value ); +}; + +/** Declare a configuration setting type */ +#define __config_setting_type __table ( config_setting_types, 01 ) + +/** + * A configuration setting + * + * This represents a single configuration setting (e.g. "hostname"). + */ +struct config_setting { + /** Name + * + * This is the human-readable name for the setting. Where + * possible, it should match the name used in dhcpd.conf (see + * dhcp-options(5)). + */ + const char *name; + /** DHCP option tag + * + * This is the DHCP tag used to identify the option in DHCP + * packets and stored option blocks. + */ + unsigned int tag; + /** Configuration setting type + * + * This identifies the type of setting (e.g. string, IPv4 + * address, etc.). + */ + struct config_setting_type *type; +}; + +/** Declare a configuration setting */ +#define __config_setting __table ( config_settings, 01 ) + +/* Function prototypes */ + +extern const char * ( show_setting ) ( struct config_context *context, + const char *name ); +extern int ( set_setting ) ( struct config_context *context, const char *name, + const char *value ); + +#endif /* _GPXE_SETTINGS_H */ |