[Settings] Implement simple_settings backed with extensible DHCP options

This commit is contained in:
Michael Brown
2008-03-22 00:24:50 +00:00
parent a462c96ffc
commit e5cea13e51
4 changed files with 72 additions and 26 deletions

View File

@@ -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 );

View File

@@ -11,6 +11,7 @@
#include <gpxe/tables.h>
#include <gpxe/list.h>
#include <gpxe/refcnt.h>
#include <gpxe/dhcpopts.h>
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
*