From: Arran Cudbard-Bell Date: Wed, 25 Jun 2014 11:52:33 +0000 (+0100) Subject: Populate DHCP-Paramter-Request-List values dynamically X-Git-Tag: release_3_0_4_rc2~196 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=freeradius.git;a=commitdiff_plain;h=56ed92736acb22f7477850b790c03834d56f0941 Populate DHCP-Paramter-Request-List values dynamically --- diff --git a/src/modules/proto_dhcp/rlm_dhcp.c b/src/modules/proto_dhcp/rlm_dhcp.c index 08fc3f7..d00fedc 100644 --- a/src/modules/proto_dhcp/rlm_dhcp.c +++ b/src/modules/proto_dhcp/rlm_dhcp.c @@ -30,6 +30,8 @@ RCSID("$Id$") #include +#define PW_DHCP_PARAMETER_REQUEST_LIST 55 + /* * Define a structure for our module configuration. * @@ -133,10 +135,35 @@ static int mod_detach(void *instance) static int mod_instantiate(UNUSED CONF_SECTION *conf, void *instance) { rlm_dhcp_t *inst = instance; + DICT_ATTR const *da; xlat_register("dhcp_options", dhcp_options_xlat, NULL, inst); xlat_register("dhcp", dhcp_xlat, NULL, inst); + /* + * Fixup dictionary entry for DHCP-Paramter-Request-List adding all the options + */ + da = dict_attrbyvalue(PW_DHCP_PARAMETER_REQUEST_LIST, DHCP_MAGIC_VENDOR); + if (da) { + DICT_ATTR const *value; + int i; + + /* No padding or termination options */ + DEBUG3("Adding values for %s", da->name); + for (i = 1; i < 255; i++) { + value = dict_attrbyvalue(i, DHCP_MAGIC_VENDOR); + if (!value) { + DEBUG3("No DHCP RFC space attribute at %i", i); + continue; + } + + DEBUG3("Adding %s value %i %s", da->name, i, value->name); + if (dict_addvalue(value->name, da->name, i) < 0) { + DEBUG3("Failed adding value: %s", fr_strerror()); + } + } + } + return 0; }