[settings] Eliminate settings "tag magic"

Create an explicit concept of "settings scope" and eliminate the magic
values used for numerical setting tags.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2013-05-01 17:20:39 +01:00
parent b4ec6a6a68
commit 15d2f947f5
11 changed files with 82 additions and 170 deletions

View File

@@ -230,7 +230,8 @@ static int dhcppkt_settings_applies ( struct settings *settings,
struct dhcp_packet *dhcppkt =
container_of ( settings, struct dhcp_packet, settings );
return dhcppkt_applies ( dhcppkt, setting->tag );
return ( ( setting->scope == NULL ) &&
dhcppkt_applies ( dhcppkt, setting->tag ) );
}
/**
@@ -299,6 +300,6 @@ void dhcppkt_init ( struct dhcp_packet *dhcppkt, struct dhcphdr *data,
dhcpopt_init ( &dhcppkt->options, &dhcppkt->dhcphdr->options,
( len - offsetof ( struct dhcphdr, options ) ),
dhcpopt_no_realloc );
settings_init ( &dhcppkt->settings,
&dhcppkt_settings_operations, &dhcppkt->refcnt, 0 );
settings_init ( &dhcppkt->settings, &dhcppkt_settings_operations,
&dhcppkt->refcnt, NULL );
}