mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
DHCPv6: update implementation
- Don't create a network interface when adding a new 'DHCPv6.Client.' instance, therefore the network interface will only be managed with 'Device.IP.Interface.' object
This commit is contained in:
parent
587d5f14b8
commit
25fee5c7dc
2 changed files with 215 additions and 100 deletions
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
struct dhcpv6_client_args
|
||||
{
|
||||
struct dmmap_dup *dhcp_client_sections;
|
||||
char *ip;
|
||||
struct uci_section *iface_s;
|
||||
struct uci_section *dmmap_s;
|
||||
};
|
||||
|
||||
struct dhcpv6_args
|
||||
|
|
@ -40,6 +40,57 @@ struct dhcpv6_client_option_args {
|
|||
char *value;
|
||||
};
|
||||
|
||||
/*************************************************************
|
||||
* COMMON FUNCTIONS
|
||||
**************************************************************/
|
||||
static bool is_dhcpv6_client_section_exist(char *sec_name)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_dhcpv6", "interface", "iface_name", sec_name, s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void dmmap_synchronizeDHCPv6Client(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s = NULL, *stmp = NULL;
|
||||
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_dhcpv6", "interface", stmp, s) {
|
||||
struct uci_section *iface_s = NULL;
|
||||
char *added_by_controller = NULL;
|
||||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
|
||||
if (strcmp(added_by_controller, "1") == 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
|
||||
if (DM_STRLEN(iface_name))
|
||||
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
|
||||
|
||||
if (!iface_s)
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
struct uci_section *ppp_s = NULL;
|
||||
char *proto = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (strcmp(proto, "dhcpv6") != 0)
|
||||
continue;
|
||||
|
||||
if (is_dhcpv6_client_section_exist(section_name(s)))
|
||||
continue;
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "interface", &ppp_s);
|
||||
dmuci_set_value_by_section(ppp_s, "iface_name", section_name(s));
|
||||
}
|
||||
}
|
||||
|
||||
static struct uci_section *get_dhcpv6_classifier(char *classifier_name, const char *network)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
|
@ -90,35 +141,27 @@ static inline int init_dhcpv6_args(struct dhcpv6_args *args, struct dmmap_dup *s
|
|||
/*#Device.DHCPv6.Client.{i}.!UCI:network/interface/dmmap_dhcpv6*/
|
||||
static int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dhcpv6_client_args dhcpv6_client_arg = {0};
|
||||
struct dhcpv6_client_args curr_dhcpv6_client_args = {0};
|
||||
struct uci_section *dmmap_s = NULL;
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_dhcpv6", "proto", "dhcpv6", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
char *ipv6addr = NULL;
|
||||
dmmap_synchronizeDHCPv6Client(dmctx, parent_node, prev_data, prev_instance);
|
||||
uci_path_foreach_sections(bbfdm, "dmmap_dhcpv6", "interface", dmmap_s) {
|
||||
struct uci_section *iface_s = NULL;
|
||||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "ip6addr", &ipv6addr);
|
||||
if (ipv6addr && ipv6addr[0] == '\0') {
|
||||
json_object *res = NULL;
|
||||
dmuci_get_value_by_section_string(dmmap_s, "iface_name", &iface_name);
|
||||
if (DM_STRLEN(iface_name))
|
||||
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(p->config_section), String}}, 1, &res);
|
||||
if (res) {
|
||||
json_object *jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
|
||||
ipv6addr = dmjson_get_value(jobj, 1, "address");
|
||||
}
|
||||
}
|
||||
curr_dhcpv6_client_args.iface_s = iface_s;
|
||||
curr_dhcpv6_client_args.dmmap_s = dmmap_s;
|
||||
|
||||
dhcpv6_client_arg.dhcp_client_sections = p;
|
||||
dhcpv6_client_arg.ip = dmstrdup(ipv6addr ? ipv6addr : "");
|
||||
inst = handle_instance(dmctx, parent_node, dmmap_s, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias");
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&dhcpv6_client_arg, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcpv6_client_args, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -279,20 +322,13 @@ static int browseDHCPv6ServerPoolClientIPv6PrefixInst(struct dmctx *dmctx, DMNOD
|
|||
**************************************************************/
|
||||
static int addObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap_sect = NULL;
|
||||
char dhcpv6_s[32];
|
||||
|
||||
snprintf(dhcpv6_s, sizeof(dhcpv6_s), "dhcpv6_intf_%s", *instance);
|
||||
|
||||
dmuci_add_section("network", "interface", &s);
|
||||
dmuci_rename_section_by_section(s, dhcpv6_s);
|
||||
dmuci_set_value_by_section(s, "proto", "dhcpv6");
|
||||
dmuci_set_value_by_section(s, "disabled", "1");
|
||||
dmuci_set_value_by_section(s, "reqaddress", "force");
|
||||
dmuci_set_value_by_section(s, "reqprefix", "no");
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "interface", &dmmap_sect);
|
||||
dmuci_set_value_by_section(dmmap_sect, "section_name", dhcpv6_s);
|
||||
dmuci_set_value_by_section(dmmap_sect, "proto", "dhcpv6");
|
||||
dmuci_set_value_by_section(dmmap_sect, "disabled", "1");
|
||||
dmuci_set_value_by_section(dmmap_sect, "reqaddress", "force");
|
||||
dmuci_set_value_by_section(dmmap_sect, "reqprefix", "no");
|
||||
dmuci_set_value_by_section(dmmap_sect, "added_by_controller", "1");
|
||||
dmuci_set_value_by_section(dmmap_sect, "bbf_dhcpv6client_instance", *instance);
|
||||
return 0;
|
||||
|
|
@ -300,34 +336,36 @@ static int addObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *s = NULL, *s_tmp = NULL;
|
||||
char *added_by_controller = NULL;
|
||||
struct uci_section *s = NULL, *stmp = NULL;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "added_by_controller", &added_by_controller);
|
||||
if (added_by_controller && strcmp(added_by_controller, "1") == 0) {
|
||||
dmuci_delete_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, NULL, NULL);
|
||||
} else {
|
||||
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "proto", "none");
|
||||
}
|
||||
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, NULL, NULL);
|
||||
|
||||
dmuci_delete_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, NULL, NULL);
|
||||
if (((struct dhcpv6_client_args *)data)->iface_s) {
|
||||
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none");
|
||||
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", "");
|
||||
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", "");
|
||||
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", "");
|
||||
}
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_option_eq_safe("network", "interface", "proto", "dhcpv6", s_tmp, s) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_dhcpv6", "interface", stmp, s) {
|
||||
struct uci_section *iface_s = NULL;
|
||||
char *iface_name = NULL;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dhcpv6", "interface", section_name(s), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
|
||||
if (DM_STRLEN(iface_name))
|
||||
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
|
||||
|
||||
dmuci_get_value_by_section_string(dmmap_section, "added_by_controller", &added_by_controller);
|
||||
if (added_by_controller && strcmp(added_by_controller, "1") == 0) {
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
} else {
|
||||
dmuci_set_value_by_section(s, "proto", "none");
|
||||
if (iface_s) {
|
||||
dmuci_set_value_by_section(iface_s, "proto", "none");
|
||||
dmuci_set_value_by_section(iface_s, "reqaddress", "");
|
||||
dmuci_set_value_by_section(iface_s, "reqprefix", "");
|
||||
dmuci_set_value_by_section(iface_s, "reqopts", "");
|
||||
}
|
||||
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -433,14 +471,17 @@ static int get_DHCPv6_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, v
|
|||
/*#Device.DHCPv6.Client.{i}.Enable!UCI:network/interface,@i-1/disabled*/
|
||||
static int get_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
char *disabled = NULL;
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "disabled", &disabled);
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "disabled", &disabled);
|
||||
*value = (disabled[0] == '1') ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -450,7 +491,9 @@ static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "disabled", b ? "0" : "1");
|
||||
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "disabled", b ? "0" : "1");
|
||||
if (dhcpv6_client->iface_s)
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "disabled", b ? "0" : "1");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -458,7 +501,7 @@ static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
static int get_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "bbf_dhcpv6client_alias", value);
|
||||
dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->dmmap_s, "bbf_dhcpv6client_alias", value);
|
||||
if ((*value)[0] == '\0')
|
||||
dmasprintf(value, "cpe-%s", instance);
|
||||
return 0;
|
||||
|
|
@ -472,7 +515,7 @@ static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data,
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "bbf_dhcpv6client_alias", value);
|
||||
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, "bbf_dhcpv6client_alias", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -480,61 +523,120 @@ static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
|
||||
char *device = NULL;
|
||||
char *is_empty = NULL;
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
char *iface_name = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "is_empty", &is_empty);
|
||||
if ((is_empty && strcmp(is_empty, "1") == 0)) {
|
||||
*value = "";
|
||||
return 0;
|
||||
if (dhcpv6_client->iface_s) {
|
||||
char *device = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s, "device", &device);
|
||||
iface_name = (device && *device) ? strchr(device, '@') : NULL;
|
||||
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", iface_name ? iface_name + 1 : "", value);
|
||||
} else {
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "iface_name", &iface_name);
|
||||
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", iface_name ? iface_name : "", value);
|
||||
}
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_s, "device", &device);
|
||||
char *parent_s = (device && *device) ? strchr(device, '@') : NULL;
|
||||
|
||||
char *linker = dmstrdup(parent_s ? parent_s + 1 : dhcpv6_s ? section_name(dhcpv6_s) : "");
|
||||
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return set_DHCP_Interface(ctx, value, (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "dmmap_dhcpv6", "dhcpv6", action);
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
|
||||
struct uci_section *interface_s = NULL;
|
||||
char *curr_iface_name = NULL;
|
||||
char *linker = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, 256, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
|
||||
return FAULT_9007;
|
||||
|
||||
break;
|
||||
case VALUESET:
|
||||
// Get linker
|
||||
adm_entry_get_linker_value(ctx, value, &linker);
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "iface_name", &curr_iface_name);
|
||||
|
||||
// Get the corresponding network config
|
||||
if (linker && *linker != 0)
|
||||
get_config_section_of_dmmap_section("network", "interface", linker, &interface_s);
|
||||
|
||||
// break if interface section is not found
|
||||
if (interface_s && (strcmp(section_name(interface_s), curr_iface_name) == 0))
|
||||
break;
|
||||
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none");
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", "");
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", "");
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", "");
|
||||
|
||||
if (!linker || *linker == 0) {
|
||||
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "added_by_controller", "1");
|
||||
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", "");
|
||||
} else {
|
||||
char *reqaddress = NULL;
|
||||
char *reqprefix = NULL;
|
||||
char *reqopts = NULL;
|
||||
|
||||
// Get the current value of requested parameters
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqopts", &reqopts);
|
||||
|
||||
// Update proto option of config section
|
||||
dmuci_set_value_by_section(interface_s, "proto", "dhcpv6");
|
||||
dmuci_set_value_by_section(interface_s, "reqaddress", reqaddress);
|
||||
dmuci_set_value_by_section(interface_s, "reqprefix", reqprefix);
|
||||
dmuci_set_value_by_section(interface_s, "reqopts", reqopts);
|
||||
|
||||
// Update dmmap section
|
||||
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", linker);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.DHCPv6.Client.{i}.Status!UCI:network/interface,@i-1/disabled*/
|
||||
static int get_DHCPv6Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *disabled = NULL;
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "disabled", &disabled);
|
||||
*value = (disabled[0] == '1') ? "Disabled" : "Enabled";
|
||||
get_DHCPv6Client_Enable(refparam, ctx, data, instance, value);
|
||||
*value = (strcmp(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.DHCPv6.Client.{i}.DUID!UBUS:network.interface/status/interface,@Name/data.passthru*/
|
||||
static int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
|
||||
json_object *res = NULL;
|
||||
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
|
||||
if (dhcpv6_s) {
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", dhcpv6_s ? section_name(dhcpv6_s) : "", String}}, 1, &res);
|
||||
*value = res ? dmjson_get_value(res, 2, "data", "passthru") : "";
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1, &res);
|
||||
*value = res ? dmjson_get_value(res, 2, "data", "passthru") : "";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.DHCPv6.Client.{i}.RequestAddresses!UCI:network/interface,@i-1/reqaddress*/
|
||||
static int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
char *reqaddress = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqaddress", &reqaddress);
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
|
||||
*value = (reqaddress && strcmp(reqaddress, "none") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -544,7 +646,9 @@ static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqaddress", b ? "force" : "none");
|
||||
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqaddress", b ? "force" : "none");
|
||||
if (dhcpv6_client->iface_s)
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", b ? "force" : "none");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -553,15 +657,17 @@ static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.DHCPv6.Client.{i}.RequestPrefixes!UCI:network/interface,@i-1/reqprefix*/
|
||||
static int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
char *reqprefix = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqprefix", &reqprefix);
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);
|
||||
*value = (reqprefix && strcmp(reqprefix, "auto") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -571,7 +677,9 @@ static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, v
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqprefix", b ? "auto" : "no");
|
||||
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqprefix", b ? "auto" : "no");
|
||||
if (dhcpv6_client->iface_s)
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", b ? "auto" : "no");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -585,7 +693,7 @@ static int get_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
|
||||
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -596,7 +704,8 @@ static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
|
|||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
if (!b) break;
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", dhcpv6_s ? section_name(dhcpv6_s) : "", String}}, 1);
|
||||
if (dhcpv6_s)
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -605,19 +714,25 @@ static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.DHCPv6.Client.{i}.RequestedOptions!UCI:network/interface,@i-1/reqopts*/
|
||||
static int get_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqopts", value);
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqopts", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_unsignedInt_list(value, -1, -1, -1, RANGE_ARGS{{NULL,NULL}}, 1))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqopts", value);
|
||||
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqopts", value);
|
||||
if (dhcpv6_client->iface_s)
|
||||
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -864,7 +979,7 @@ static int set_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) //TODO: return wrong value
|
||||
static int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *classifier_s = get_dhcpv6_classifier("mac", ((struct dhcpv6_args *)data)->interface);
|
||||
if (classifier_s == NULL) {
|
||||
|
|
@ -1211,9 +1326,10 @@ static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
|
|||
*************************************************************/
|
||||
static int operate_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
|
||||
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
|
||||
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1);
|
||||
if (dhcpv6_s)
|
||||
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -368,6 +368,16 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
|
||||
dmuci_get_value_by_section_string(int_ss, "proto", &proto);
|
||||
|
||||
if (strcmp(proto, "dhcpv6") == 0) {
|
||||
struct uci_section *dhcpv6_client_s = get_dup_section_in_dmmap_opt("dmmap_dhcpv6", "interface", "iface_name", section_name(int_ss));
|
||||
|
||||
if (dhcpv6_client_s) {
|
||||
|
||||
/* Remove "DHCPv6.Client." section related to this "IP.Interface." object */
|
||||
dmuci_delete_by_section(dhcpv6_client_s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp(proto, "ppp", 3) == 0) {
|
||||
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", section_name(int_ss));
|
||||
|
||||
|
|
@ -525,17 +535,6 @@ static int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
continue;
|
||||
}
|
||||
|
||||
// skip dhcpv6 sections added by controller
|
||||
if (strcmp(proto, "dhcpv6") == 0) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
char *dhcpv6_user_s = NULL;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dhcpv6", "interface", section_name(p->config_section), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "added_by_controller", &dhcpv6_user_s);
|
||||
if (dhcpv6_user_s && strcmp(dhcpv6_user_s, "1") == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "ip_int_instance", "ip_int_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue