summaryrefslogtreecommitdiffstats
path: root/src/net/netdevice.c
diff options
context:
space:
mode:
authorMichael Brown2008-03-20 22:06:03 +0100
committerMichael Brown2008-03-20 22:06:53 +0100
commitacfa14423ef2c974e9d8ff3d0aa48fe0ea2fb8c7 (patch)
tree1541c01facb5ed9d291aa773f12b7a8664077206 /src/net/netdevice.c
parent[Settings] Add settings hierarchy (diff)
downloadipxe-acfa14423ef2c974e9d8ff3d0aa48fe0ea2fb8c7.tar.gz
ipxe-acfa14423ef2c974e9d8ff3d0aa48fe0ea2fb8c7.tar.xz
ipxe-acfa14423ef2c974e9d8ff3d0aa48fe0ea2fb8c7.zip
[Settings] Add per-netdevice settings block
Add a configuration settings block for each net device. This will provide the parent scope for settings applicable only to that network device (e.g. non-volatile options stored on the NIC, options obtained via DHCP, etc.). Expose the MAC address as a setting.
Diffstat (limited to 'src/net/netdevice.c')
-rw-r--r--src/net/netdevice.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index f2778e88..323e9105 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -266,6 +266,9 @@ struct net_device * alloc_netdev ( size_t priv_size ) {
netdev->refcnt.free = free_netdev;
INIT_LIST_HEAD ( &netdev->tx_queue );
INIT_LIST_HEAD ( &netdev->rx_queue );
+ settings_init ( &netdev->settings,
+ &netdev_settings_operations, &netdev->refcnt,
+ netdev->name );
netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) );
}
return netdev;
@@ -282,11 +285,19 @@ struct net_device * alloc_netdev ( size_t priv_size ) {
*/
int register_netdev ( struct net_device *netdev ) {
static unsigned int ifindex = 0;
+ int rc;
/* Create device name */
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
ifindex++ );
+ /* Register per-netdev configuration settings */
+ if ( ( rc = register_settings ( &netdev->settings, NULL ) ) != 0 ) {
+ DBGC ( netdev, "NETDEV %p could not register settings: %s\n",
+ netdev, strerror ( rc ) );
+ return rc;
+ }
+
/* Add to device list */
netdev_get ( netdev );
list_add_tail ( &netdev->list, &net_devices );
@@ -357,6 +368,9 @@ void unregister_netdev ( struct net_device *netdev ) {
/* Ensure device is closed */
netdev_close ( netdev );
+ /* Unregister per-netdev configuration settings */
+ unregister_settings ( &netdev->settings );
+
/* Remove from device list */
list_del ( &netdev->list );
netdev_put ( netdev );