mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-01 17:35:33 +01:00
DHCPv4: added AllowedDevices Parameter
AllowedDevices if set to All then dhcp will be handles for any device AllowedDevices if set to Known then dhcp will be handled for devices with mac list in StaticAddress AllowedDevices if set to UnKnown then dhcp will not be handled for devices with mac list in StaticAddress and handled for all other devices
This commit is contained in:
parent
2ab34bd42d
commit
f104fd65c9
1 changed files with 44 additions and 1 deletions
|
|
@ -59,6 +59,8 @@ struct dhcp_client_option_args {
|
|||
char *value;
|
||||
};
|
||||
|
||||
static char *allowed_devices[] = {"All", "Known", "UnKnown", NULL};
|
||||
|
||||
/**************************************************************************
|
||||
* LINKER
|
||||
***************************************************************************/
|
||||
|
|
@ -1445,6 +1447,47 @@ static int set_DHCPv4ServerPool_Interface(char *refparam, struct dmctx *ctx, voi
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.DHCPv4.Server.Pool.{i}.alloweddevices!UCI:dhcp/interface,@i-1/allowed_devices*/
|
||||
static int get_DHCPv4ServerPool_AllowedDevices(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *allowed_dev = NULL;
|
||||
|
||||
*value = "All";
|
||||
|
||||
dmuci_get_value_by_section_string((((struct dhcp_args *)data)->sections)->config_section, "allowed_devices", &allowed_dev);
|
||||
if (DM_STRLEN(allowed_dev)) {
|
||||
if (strcasecmp(allowed_dev, "known") == 0)
|
||||
*value = "Known";
|
||||
else if(strcasecmp(allowed_dev, "unknown") == 0)
|
||||
*value = "UnKnown";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_DHCPv4ServerPool_AllowedDevices(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *allowed_dev = "";
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, -1, allowed_devices, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
if (strcasecmp(value, "Known") == 0)
|
||||
allowed_dev = "known";
|
||||
else if(strcasecmp(value, "UnKnown") == 0)
|
||||
allowed_dev = "unknown";
|
||||
else
|
||||
allowed_dev = "all";
|
||||
|
||||
dmuci_set_value_by_section((((struct dhcp_args *)data)->sections)->config_section, "allowed_devices", allowed_dev);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.DHCPv4.Server.Pool.{i}.MinAddress!UCI:dhcp/interface,@i-1/start*/
|
||||
static int get_DHCPv4ServerPool_MinAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
|
|
@ -3429,7 +3472,7 @@ DMLEAF tDHCPv4ServerPoolParams[] = {
|
|||
//{"Chaddr", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_Chaddr, set_DHCPv4ServerPool_Chaddr, BBFDM_BOTH, "2.0"},
|
||||
//{"ChaddrMask", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_ChaddrMask, set_DHCPv4ServerPool_ChaddrMask, BBFDM_BOTH, "2.0"},
|
||||
//{"ChaddrExclude", &DMWRITE, DMT_BOOL, get_DHCPv4ServerPool_ChaddrExclude, set_DHCPv4ServerPool_ChaddrExclude, BBFDM_BOTH, "2.0"},
|
||||
//{"AllowedDevices", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_AllowedDevices, set_DHCPv4ServerPool_AllowedDevices, BBFDM_BOTH, "2.13"},
|
||||
{"AllowedDevices", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_AllowedDevices, set_DHCPv4ServerPool_AllowedDevices, BBFDM_BOTH, "2.13"},
|
||||
{"MinAddress", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_MinAddress, set_DHCPv4ServerPool_MinAddress, BBFDM_BOTH, "2.0"},
|
||||
{"MaxAddress", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_MaxAddress, set_DHCPv4ServerPool_MaxAddress, BBFDM_BOTH, "2.0"},
|
||||
{"ReservedAddresses", &DMWRITE, DMT_STRING, get_DHCPv4ServerPool_ReservedAddresses, set_DHCPv4ServerPool_ReservedAddresses, BBFDM_BOTH, "2.0"},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue