From e5cea13e51f5226987048275499314c6f15d526f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 22 Mar 2008 00:24:50 +0000 Subject: [Settings] Implement simple_settings backed with extensible DHCP options --- src/include/gpxe/netdevice.h | 4 ++-- src/include/gpxe/settings.h | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src/include') diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h index 4abada7aa..d8cb84d08 100644 --- a/src/include/gpxe/netdevice.h +++ b/src/include/gpxe/netdevice.h @@ -245,7 +245,7 @@ struct net_device { struct net_device_stats stats; /** Configuration settings applicable to this device */ - struct settings settings; + struct simple_settings settings; /** Driver private data */ void *priv; @@ -349,7 +349,7 @@ netdev_priv ( struct net_device *netdev ) { */ static inline __attribute__ (( always_inline )) struct settings * netdev_settings ( struct net_device *netdev ) { - return &netdev->settings; + return &netdev->settings.settings; } extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ); diff --git a/src/include/gpxe/settings.h b/src/include/gpxe/settings.h index f20c412be..643bd05b0 100644 --- a/src/include/gpxe/settings.h +++ b/src/include/gpxe/settings.h @@ -11,6 +11,7 @@ #include #include #include +#include struct settings; struct in_addr; @@ -138,12 +139,23 @@ struct settings_applicator { #define __settings_applicator \ __table ( struct settings_applicator, settings_applicators, 01 ) +/** + * A simple settings block + * + */ +struct simple_settings { + /** Settings block */ + struct settings settings; + /** DHCP options */ + struct dhcp_options dhcpopts; +}; + +extern struct settings_operations simple_settings_operations; + extern int simple_settings_store ( struct settings *settings, unsigned int tag, const void *data, size_t len ); extern int simple_settings_fetch ( struct settings *settings, unsigned int tag, void *data, size_t len ); -extern struct settings_operations simple_settings_operations; - extern int register_settings ( struct settings *settings, struct settings *parent ); extern void unregister_settings ( struct settings *settings ); @@ -205,6 +217,20 @@ static inline void settings_init ( struct settings *settings, settings->name = name; } +/** + * Initialise a settings block + * + * @v simple Simple settings block + * @v refcnt Containing object reference counter, or NULL + * @v name Settings block name + */ +static inline void simple_settings_init ( struct simple_settings *simple, + struct refcnt *refcnt, + const char *name ) { + settings_init ( &simple->settings, &simple_settings_operations, + refcnt, name ); +} + /** * Delete setting * -- cgit v1.2.3-55-g7522