2 * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gpxe/dhcp.h>
22 #include <gpxe/settings.h>
23 #include <gpxe/netdevice.h>
27 * Network device configuration settings
32 * Store value of network device setting
34 * @v settings Settings block
35 * @v tag Setting tag number
36 * @v data Setting data, or NULL to clear setting
37 * @v len Length of setting data
38 * @ret rc Return status code
40 static int netdev_store ( struct settings *settings, unsigned int tag,
41 const void *data, size_t len ) {
42 struct net_device *netdev =
43 container_of ( settings, struct net_device, settings );
47 if ( len != netdev->ll_protocol->ll_addr_len )
49 memcpy ( netdev->ll_addr, data, len );
52 return simple_settings_store ( settings, tag, data, len );
57 * Fetch value of network device setting
59 * @v settings Settings block
60 * @v tag Setting tag number
61 * @v data Setting data, or NULL to clear setting
62 * @v len Length of setting data
63 * @ret rc Return status code
65 static int netdev_fetch ( struct settings *settings, unsigned int tag,
66 void *data, size_t len ) {
67 struct net_device *netdev =
68 container_of ( settings, struct net_device, settings );
72 if ( len > netdev->ll_protocol->ll_addr_len )
73 len = netdev->ll_protocol->ll_addr_len;
74 memcpy ( data, netdev->ll_addr, len );
75 return netdev->ll_protocol->ll_addr_len;
77 return simple_settings_fetch ( settings, tag, data, len );
81 /** Network device configuration settings operations */
82 struct settings_operations netdev_settings_operations = {
83 .store = netdev_store,
84 .fetch = netdev_fetch,
87 /** Network device named settings */
88 struct named_setting netdev_named_settings[] __named_setting = {
91 .description = "MAC address",
93 .type = &setting_type_hex,