diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-03-25 20:46:16 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-03-25 20:46:16 +0000 |
commit | 92d15eff30410dcb0ec406e06b131fb7d9179ffd (patch) | |
tree | 191d29013372b541d353bbfa55114b8060dd557c /src/net/dhcppkt.c | |
parent | ee5bdb0d758a953a4f044795a3571ecb5cf3c735 (diff) | |
download | ipxe-92d15eff30410dcb0ec406e06b131fb7d9179ffd.tar.gz |
[Settings] Remove assumption that all settings have DHCP tag values
Allow for settings to be described by something other than a DHCP option
tag if desirable. Currently used only for the MAC address setting.
Separate out fake DHCP packet creation code from dhcp.c to fakedhcp.c.
Remove notion of settings from dhcppkt.c.
Rationalise dhcp.c to use settings API only for final registration of the
DHCP options, rather than using {store,fetch}_setting throughout.
Diffstat (limited to 'src/net/dhcppkt.c')
-rw-r--r-- | src/net/dhcppkt.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/net/dhcppkt.c b/src/net/dhcppkt.c index 0a11520f..1cf99d8d 100644 --- a/src/net/dhcppkt.c +++ b/src/net/dhcppkt.c @@ -92,20 +92,18 @@ find_dhcp_packet_field ( unsigned int tag ) { } return NULL; } - + /** * Store value of DHCP packet setting * - * @v settings Settings block + * @v dhcppkt DHCP packet * @v tag Setting tag number * @v data Setting data, or NULL to clear setting * @v len Length of setting data * @ret rc Return status code */ -static int dhcppkt_store ( struct settings *settings, unsigned int tag, - const void *data, size_t len ) { - struct dhcp_packet *dhcppkt = - container_of ( settings, struct dhcp_packet, settings ); +int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag, + const void *data, size_t len ) { struct dhcp_packet_field *field; int rc; @@ -131,16 +129,14 @@ static int dhcppkt_store ( struct settings *settings, unsigned int tag, /** * Fetch value of DHCP packet setting * - * @v settings Settings block + * @v dhcppkt DHCP packet * @v tag Setting tag number * @v data Buffer to fill with setting data * @v len Length of buffer * @ret len Length of setting data, or negative error */ -static int dhcppkt_fetch ( struct settings *settings, unsigned int tag, - void *data, size_t len ) { - struct dhcp_packet *dhcppkt = - container_of ( settings, struct dhcp_packet, settings ); +int dhcppkt_fetch ( struct dhcp_packet *dhcppkt, unsigned int tag, + void *data, size_t len ) { struct dhcp_packet_field *field; /* If this is a special field, return it */ @@ -156,31 +152,21 @@ static int dhcppkt_fetch ( struct settings *settings, unsigned int tag, return dhcpopt_fetch ( &dhcppkt->options, tag, data, len ); } -/** DHCP settings operations */ -static struct settings_operations dhcppkt_settings_operations = { - .store = dhcppkt_store, - .fetch = dhcppkt_fetch, -}; - /** * Initialise prepopulated DHCP packet * * @v dhcppkt Uninitialised DHCP packet - * @v refcnt Reference counter of containing object, or NULL * @v data Memory for DHCP packet data * @v max_len Length of memory for DHCP packet data * * The memory content must already be filled with valid DHCP options. * A zeroed block counts as a block of valid DHCP options. */ -void dhcppkt_init ( struct dhcp_packet *dhcppkt, struct refcnt *refcnt, - void *data, size_t len ) { +void dhcppkt_init ( struct dhcp_packet *dhcppkt, void *data, size_t len ) { dhcppkt->dhcphdr = data; dhcppkt->max_len = len; dhcpopt_init ( &dhcppkt->options, &dhcppkt->dhcphdr->options, ( len - offsetof ( struct dhcphdr, options ) ) ); dhcppkt->len = ( offsetof ( struct dhcphdr, options ) + dhcppkt->options.len ); - settings_init ( &dhcppkt->settings, &dhcppkt_settings_operations, - refcnt, "dhcp" ); } |