mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
T#13729: Use generic structure dm_data for multi-instance objects
This commit is contained in:
parent
3d83590251
commit
8acd70acf1
27 changed files with 1580 additions and 1659 deletions
|
|
@ -422,6 +422,14 @@ struct dmmap_dup {
|
|||
struct uci_section *dmmap_section;
|
||||
};
|
||||
|
||||
struct dm_data {
|
||||
struct list_head list;
|
||||
struct uci_section *config_section;
|
||||
struct uci_section *dmmap_section;
|
||||
struct json_object *json_object;
|
||||
void *additional_data;
|
||||
};
|
||||
|
||||
struct dm_fault {
|
||||
int code;
|
||||
char *description;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,12 @@ static inline int DM_LINK_INST_OBJ(struct dmctx *dmctx, DMNODE *parent_node, voi
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
#define BBF_WARNING(MESSAGE, ...) do { \
|
||||
if (gLogLevel >= 2) { \
|
||||
syslog(LOG_WARNING, "[%s:%d] " MESSAGE, __FUNCTION__, __LINE__, ##__VA_ARGS__); /* Flawfinder: ignore */ \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define BBF_INFO(MESSAGE, ...) do { \
|
||||
if (gLogLevel >= 3) { \
|
||||
syslog(LOG_INFO, "[%s:%d] " MESSAGE, __FUNCTION__, __LINE__, ##__VA_ARGS__); /* Flawfinder: ignore */ \
|
||||
|
|
|
|||
|
|
@ -410,25 +410,21 @@ void hex_to_ip(char *address, char *ret, size_t size)
|
|||
*/
|
||||
void add_dmmap_config_dup_list(struct list_head *dup_list, struct uci_section *config_section, struct uci_section *dmmap_section)
|
||||
{
|
||||
struct dmmap_dup *dmmap_config;
|
||||
struct dm_data *dm_data = NULL;
|
||||
|
||||
dmmap_config = dmcalloc(1, sizeof(struct dmmap_dup));
|
||||
list_add_tail(&dmmap_config->list, dup_list);
|
||||
dmmap_config->config_section = config_section;
|
||||
dmmap_config->dmmap_section = dmmap_section;
|
||||
}
|
||||
|
||||
static void dmmap_config_dup_delete(struct dmmap_dup *dmmap_config)
|
||||
{
|
||||
list_del(&dmmap_config->list);
|
||||
dm_data = dmcalloc(1, sizeof(struct dm_data));
|
||||
list_add_tail(&dm_data->list, dup_list);
|
||||
dm_data->config_section = config_section;
|
||||
dm_data->dmmap_section = dmmap_section;
|
||||
}
|
||||
|
||||
void free_dmmap_config_dup_list(struct list_head *dup_list)
|
||||
{
|
||||
struct dmmap_dup *dmmap_config = NULL;
|
||||
while (dup_list->next != dup_list) {
|
||||
dmmap_config = list_entry(dup_list->next, struct dmmap_dup, list);
|
||||
dmmap_config_dup_delete(dmmap_config);
|
||||
struct dm_data *dm_data = NULL, *tmp = NULL;
|
||||
|
||||
list_for_each_entry_safe(dm_data, tmp, dup_list, list) {
|
||||
list_del(&dm_data->list);
|
||||
dmfree(dm_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ int get_json_plugin_version(json_object *json_obj)
|
|||
return JSON_VERSION_0; // Return JSON_VERSION_0 for invalid input
|
||||
|
||||
int version = json_object_get_int(json_obj);
|
||||
int json_plugin_version = JSON_VERSION_0; // Initialize to JSON_VERSION_0
|
||||
int json_plugin_version = 0; // Initialize to 0
|
||||
|
||||
switch (version) {
|
||||
case 1:
|
||||
|
|
@ -123,6 +123,7 @@ int get_json_plugin_version(json_object *json_obj)
|
|||
json_plugin_version |= JSON_VERSION_1; // Set JSON_VERSION_1 for version 2
|
||||
break;
|
||||
default:
|
||||
json_plugin_version |= JSON_VERSION_0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +334,7 @@ static void resolve_all_symbols(struct dmctx *ctx, void *data, char *instance, c
|
|||
if (strcmp(pch, "@Name") == 0) {
|
||||
char *sec_name = NULL;
|
||||
|
||||
dmuci_get_section_name(section_name((struct uci_section *)data), &sec_name);
|
||||
dmuci_get_section_name(section_name(((struct dm_data *)data)->config_section), &sec_name);
|
||||
pos += snprintf(&new_key[pos], key_len - pos, "%s.", sec_name ? sec_name : "");
|
||||
} else if (strcmp(pch, "@Value") == 0)
|
||||
pos += snprintf(&new_key[pos], key_len - pos, "%s.", value);
|
||||
|
|
@ -431,7 +432,7 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
|
|||
struct json_object *section_type = NULL;
|
||||
struct json_object *dmmap_file = NULL;
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
json_object_object_get_ex((mapping_0 && (json_version & JSON_VERSION_1)) ? mapping_0 : mapping_obj, "uci", &uci_obj);
|
||||
|
|
@ -442,18 +443,18 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
|
|||
|
||||
if (file && section_type && dmmap_file) {
|
||||
synchronize_specific_config_sections_with_dmmap(json_object_get_string(file), json_object_get_string(section_type), json_object_get_string(dmmap_file), &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
char *dm_parent = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "dm_parent", &dm_parent);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "dm_parent", &dm_parent);
|
||||
if (prev_data && DM_STRLEN(dm_parent)) {
|
||||
if (strcmp(section_name((struct uci_section *)prev_data), dm_parent) != 0)
|
||||
if (strcmp(section_name(((struct dm_data *)prev_data)->config_section), dm_parent) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "instance", "alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "instance", "alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -468,6 +469,7 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
|
|||
struct json_object *method = NULL;
|
||||
struct json_object *args_obj = NULL;
|
||||
struct json_object *key = NULL;
|
||||
struct dm_data curr_data = {0};
|
||||
struct ubus_arg u_args[16] = {0};
|
||||
char buf_object[256] = {0};
|
||||
char buf_method[256] = {0};
|
||||
|
|
@ -501,8 +503,12 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
|
|||
json_object *arr_obj = get_requested_json_obj(res, prev_instance, json_object_get_string(key), arr_name, sizeof(arr_name));
|
||||
|
||||
dmjson_foreach_obj_in_array(arr_obj, arrobj, dyn_obj, i, 1, arr_name) {
|
||||
|
||||
curr_data.json_object = dyn_obj;
|
||||
|
||||
char *inst = handle_instance_without_section(dmctx, parent_node, ++id);
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)dyn_obj, inst) == DM_STOP)
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -555,7 +561,7 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
|
|||
|
||||
char *uci_sec_name = json_object_get_string(section_type);
|
||||
|
||||
snprintf(sec_name, sizeof(sec_name), "%s%s%s_%s", data ? section_name((struct uci_section *)data) : "", data ? "_" : "", uci_sec_name, *instance);
|
||||
snprintf(sec_name, sizeof(sec_name), "%s%s%s_%s", data ? section_name(((struct dm_data *)data)->config_section) : "", data ? "_" : "", uci_sec_name, *instance);
|
||||
|
||||
replace_special_char(sec_name, '_');
|
||||
|
||||
|
|
@ -565,7 +571,7 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
|
|||
if (dmuci_rename_section_by_section(s, sec_name))
|
||||
return -1;
|
||||
|
||||
if (dmuci_set_value_by_section(s, "dm_parent", section_name((struct uci_section *)data)))
|
||||
if (dmuci_set_value_by_section(s, "dm_parent", data ? section_name(((struct dm_data *)data)->config_section) : ""))
|
||||
return -1;
|
||||
|
||||
if (dmuci_add_section_bbfdm(json_object_get_string(dmmap_file), uci_sec_name, &dmmap_s))
|
||||
|
|
@ -574,7 +580,7 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
|
|||
if (dmuci_set_value_by_section(dmmap_s, "section_name", section_name(s)))
|
||||
return -1;
|
||||
|
||||
if (dmuci_set_value_by_section(dmmap_s, "dm_parent", section_name((struct uci_section *)data)))
|
||||
if (dmuci_set_value_by_section(dmmap_s, "dm_parent", data ? section_name(((struct dm_data *)data)->config_section) : ""))
|
||||
return -1;
|
||||
|
||||
if (dmuci_set_value_by_section(dmmap_s, "instance", *instance))
|
||||
|
|
@ -632,17 +638,17 @@ static int delete_obj(char *refparam, struct dmctx *ctx, void *data, char *insta
|
|||
char *dm_parent = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "dm_parent", &dm_parent);
|
||||
if (DM_STRLEN(dm_parent) && strcmp(section_name((struct uci_section *)data), dm_parent) == 0) {
|
||||
if (DM_STRLEN(dm_parent) && strcmp(section_name(((struct dm_data *)data)->config_section), dm_parent) == 0) {
|
||||
if (dmuci_delete_by_section(s, NULL, NULL))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
get_dmmap_section_of_config_section(json_object_get_string(dmmap_file), json_object_get_string(section_type), section_name((struct uci_section *)data), &dmmap_section);
|
||||
get_dmmap_section_of_config_section(json_object_get_string(dmmap_file), json_object_get_string(section_type), section_name(((struct dm_data *)data)->config_section), &dmmap_section);
|
||||
if (dmuci_delete_by_section(dmmap_section, NULL, NULL))
|
||||
return -1;
|
||||
|
||||
if (dmuci_delete_by_section((struct uci_section *)data, NULL, NULL))
|
||||
if (dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL))
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
|
@ -726,7 +732,7 @@ static char *uci_get_value(json_object *mapping_obj, int json_version, char *ref
|
|||
|
||||
dmuci_get_value_by_section_string(s, "dm_parent", &dm_parent);
|
||||
if (data && DM_STRLEN(dm_parent)) {
|
||||
if (strcmp(section_name((struct uci_section *)data), dm_parent) != 0)
|
||||
if (strcmp(section_name(((struct dm_data *)data)->config_section), dm_parent) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -736,9 +742,14 @@ static char *uci_get_value(json_object *mapping_obj, int json_version, char *ref
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (opt_temp && strstr(refparam, ".Alias")) {
|
||||
bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, opt_temp, instance, &value);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (data && file && type && opt_temp) {
|
||||
if (strcmp(opt_temp, "@Name") == 0) {
|
||||
dmuci_get_section_name(section_name((struct uci_section *)data), &value);
|
||||
dmuci_get_section_name(section_name(((struct dm_data *)data)->config_section), &value);
|
||||
} else {
|
||||
char uci_type[32] = {0};
|
||||
|
||||
|
|
@ -747,7 +758,7 @@ static char *uci_get_value(json_object *mapping_obj, int json_version, char *ref
|
|||
if (option) {
|
||||
char *res = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, opt_temp, &res);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, opt_temp, &res);
|
||||
if (DM_STRLEN(res) == 0)
|
||||
dmuci_get_option_value_string(json_object_get_string(file), uci_type, opt_temp, &res);
|
||||
|
||||
|
|
@ -758,7 +769,7 @@ static char *uci_get_value(json_object *mapping_obj, int json_version, char *ref
|
|||
} else {
|
||||
struct uci_list *list_val;
|
||||
|
||||
dmuci_get_value_by_section_list((struct uci_section *)data, opt_temp, &list_val);
|
||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, opt_temp, &list_val);
|
||||
if (list_val == NULL)
|
||||
dmuci_get_option_value_list(json_object_get_string(file), uci_type, opt_temp, &list_val);
|
||||
value = dmuci_list_to_string(list_val, ",");
|
||||
|
|
@ -781,9 +792,6 @@ static char *uci_get_value(json_object *mapping_obj, int json_version, char *ref
|
|||
}
|
||||
}
|
||||
|
||||
if (strstr(refparam, "Alias") && value[0] == '\0')
|
||||
dmasprintf(&value, "cpe-%s", instance);
|
||||
|
||||
end:
|
||||
FREE(linker);
|
||||
return value;
|
||||
|
|
@ -842,11 +850,11 @@ static char *ubus_get_value(json_object *mapping_obj, int json_version, char *re
|
|||
char *is_array = strstr(key_buf, ((json_version & JSON_VERSION_1)) ? "[@index]" : "[@i-1]");
|
||||
if (data && is_array) {
|
||||
char *arguments = ((json_version & JSON_VERSION_1)) ? is_array + sizeof("[@index]") : is_array + sizeof("[@i-1]");
|
||||
json_obj = get_requested_json_obj((json_object *)data, instance, arguments, key_name, sizeof(key_name));
|
||||
/* If the json object is already extracted from array object then use that object
|
||||
to extract the value */
|
||||
json_obj = get_requested_json_obj(((struct dm_data *)data)->json_object, instance, arguments, key_name, sizeof(key_name));
|
||||
|
||||
/* If the json object is already extracted from array object then use that object to extract the value */
|
||||
if (!json_obj && data)
|
||||
json_obj = (json_object*)data;
|
||||
json_obj = ((struct dm_data *)data)->json_object;
|
||||
} else {
|
||||
json_obj = get_requested_json_obj(res, instance, key_buf, key_name, sizeof(key_name));
|
||||
}
|
||||
|
|
@ -879,9 +887,11 @@ static char *uci_v1_get_value(json_object *mapping_obj, char *refparam, struct d
|
|||
|
||||
if (key) {
|
||||
if (strcmp(json_object_get_string(key), "@Name") == 0) {
|
||||
dmuci_get_section_name(section_name((struct uci_section *)data), &value);
|
||||
dmuci_get_section_name(section_name(((struct dm_data *)data)->config_section), &value);
|
||||
} else if (strstr(refparam, ".Alias")) {
|
||||
bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, json_object_get_string(key), instance, &value);
|
||||
} else {
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, json_object_get_string(key), &value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, json_object_get_string(key), &value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -904,7 +914,7 @@ static char *ubus_v1_get_value(json_object *mapping_obj, char *refparam, struct
|
|||
if (key) {
|
||||
char key_name[128] = {32};
|
||||
|
||||
json_object *json_obj = get_requested_json_obj((json_object *)data, instance, json_object_get_string(key), key_name, sizeof(key_name));
|
||||
json_object *json_obj = get_requested_json_obj(((struct dm_data *)data)->json_object, instance, json_object_get_string(key), key_name, sizeof(key_name));
|
||||
value = dmjson_get_value(json_obj, 1, key_name);
|
||||
}
|
||||
|
||||
|
|
@ -1361,6 +1371,10 @@ static int uci_set_value(json_object *mapping_obj, int json_version, char *refpa
|
|||
opt_temp = json_object_get_string(option_name);
|
||||
}
|
||||
|
||||
if (opt_temp && strstr(refparam, ".Alias")) {
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, opt_temp, instance, value);
|
||||
}
|
||||
|
||||
if (data && file && type && opt_temp) {
|
||||
|
||||
char uci_type[32] = {0};
|
||||
|
|
@ -1376,32 +1390,32 @@ static int uci_set_value(json_object *mapping_obj, int json_version, char *refpa
|
|||
return -1;
|
||||
|
||||
snprintf(buf, sizeof(buf), "dmmap_%s", json_object_get_string(file));
|
||||
get_dmmap_section_of_config_section(buf, json_object_get_string(type), section_name((struct uci_section *)data), &dmmap_section);
|
||||
get_dmmap_section_of_config_section(buf, json_object_get_string(type), section_name(((struct dm_data *)data)->config_section), &dmmap_section);
|
||||
if (!dmmap_section)
|
||||
return -1;
|
||||
|
||||
if (dmuci_set_value_by_section(dmmap_section, "section_name", sec_name))
|
||||
return -1;
|
||||
|
||||
if ((res = dmuci_rename_section_by_section((struct uci_section *)data, sec_name)))
|
||||
if ((res = dmuci_rename_section_by_section(((struct dm_data *)data)->config_section, sec_name)))
|
||||
res = dmuci_rename_section(json_object_get_string(file), uci_type, sec_name);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (option) {
|
||||
if ((res = dmuci_set_value_by_section((struct uci_section *)data, opt_temp, value)))
|
||||
if ((res = dmuci_set_value_by_section(((struct dm_data *)data)->config_section, opt_temp, value)))
|
||||
res = dmuci_set_value(json_object_get_string(file), uci_type, opt_temp, value);
|
||||
} else {
|
||||
if (value != NULL) {
|
||||
if (dmuci_delete_by_section((struct uci_section *)data, opt_temp, NULL))
|
||||
if (dmuci_delete_by_section(((struct dm_data *)data)->config_section, opt_temp, NULL))
|
||||
dmuci_delete(json_object_get_string(file), uci_type, opt_temp, NULL);
|
||||
|
||||
char *p = strtok(value, ",");
|
||||
while (p) {
|
||||
strip_lead_trail_whitespace(p);
|
||||
|
||||
if ((res = dmuci_add_list_value_by_section((struct uci_section *)data, opt_temp, p)))
|
||||
if ((res = dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, opt_temp, p)))
|
||||
res = dmuci_add_list_value(json_object_get_string(file), uci_type, opt_temp, p);
|
||||
|
||||
if (res)
|
||||
|
|
@ -1482,8 +1496,11 @@ static int uci_v1_set_value(json_object *mapping_obj, int json_version, char *re
|
|||
if (data == NULL || key == NULL || data_s == NULL || strcmp(json_object_get_string(data_s), "@Parent") != 0)
|
||||
return -1;
|
||||
|
||||
return dmuci_set_value_by_section((struct uci_section *)data, json_object_get_string(key), value);
|
||||
|
||||
if (strstr(refparam, ".Alias")) {
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, json_object_get_string(key), instance, value);
|
||||
} else {
|
||||
return dmuci_set_value_by_section(((struct dm_data *)data)->config_section, json_object_get_string(key), value);
|
||||
}
|
||||
}
|
||||
|
||||
static int set_value_from_mapping(json_object *param_obj, int json_version, char *refparam, struct dmctx *ctx, void *data, char *instance, char *value)
|
||||
|
|
@ -1876,7 +1893,7 @@ void parse_obj(char *object, json_object *jobj, DMOBJ *pobj, int index, int json
|
|||
}
|
||||
|
||||
if (strcmp(key, "mapping") == 0 &&
|
||||
((json_object_get_type(json_obj) == json_type_object && json_version == JSON_VERSION_0) ||
|
||||
((json_object_get_type(json_obj) == json_type_object && (json_version & JSON_VERSION_0)) ||
|
||||
(json_object_get_type(json_obj) == json_type_array && (json_version & JSON_VERSION_1)))) {
|
||||
parse_mapping_obj(full_obj, json_obj, (const char **)keys_p, json_version, list);
|
||||
}
|
||||
|
|
@ -1966,6 +1983,10 @@ int load_json_plugins(DMOBJ *entryobj, const char *plugin_path)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (json_plugin_version & JSON_VERSION_0) {
|
||||
BBF_WARNING("Currently, JSON plugin only supports version 2, So please upgrade (%s) to version 2", plugin_path);
|
||||
}
|
||||
|
||||
replace_str(key, "{BBF_VENDOR_PREFIX}", BBF_VENDOR_PREFIX, obj_path, sizeof(obj_path));
|
||||
if (strlen(obj_path) == 0) {
|
||||
BBF_DEBUG("ERROR: Can't get the node object");
|
||||
|
|
|
|||
|
|
@ -1066,16 +1066,16 @@ static void Update_BridgeVLANPort_VLAN_Layer(char *path, struct uci_section *bri
|
|||
static int browseBridgingBridgeInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct bridge_args curr_bridging_args = {0};
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
char *inst = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_bridge_config_sections_with_dmmap_bridge_eq("network", "device", "dmmap_bridge", "type", "bridge", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "bridge_instance", "bridge_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "bridge_instance", "bridge_alias");
|
||||
|
||||
init_bridging_args(&curr_bridging_args, p->config_section ? p->config_section : p->dmmap_section, p->dmmap_section, inst);
|
||||
init_bridging_args(&curr_bridging_args, curr_data->config_section ? curr_data->config_section : curr_data->dmmap_section, curr_data->dmmap_section, inst);
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_bridging_args, inst) == DM_STOP)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -828,16 +828,16 @@ static int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_da
|
|||
|
||||
static int browseVlfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *inst = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("system", "system", "dmmap", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "vlf_instance", "vlf_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "vlf_instance", "vlf_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -1247,17 +1247,17 @@ static int set_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *in
|
|||
|
||||
static int get_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "vlf_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "vlf_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "vlf_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "vlf_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_vlf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "log_file", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "log_file", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1265,7 +1265,7 @@ static int get_vlf_max_size (char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
int size = 0;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "log_size", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "log_size", value);
|
||||
|
||||
// Value defined in system is in KiB in datamodel this is in bytes, convert the value in bytes
|
||||
size = (*value && **value) ? DM_STRTOL(*value) * 1000 : 0;
|
||||
|
|
@ -1612,7 +1612,7 @@ static int operate_DeviceInfoVendorLogFile_Upload(char *refparam, struct dmctx *
|
|||
if (url[0] == '\0')
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "log_file", &vlf_file_path);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "log_file", &vlf_file_path);
|
||||
|
||||
if (DM_STRLEN(vlf_file_path) == 0) {
|
||||
vlf_file_path = DEF_VENDOR_LOG_FILE;
|
||||
|
|
|
|||
|
|
@ -205,8 +205,8 @@ static int delService(char *refparam, struct dmctx *ctx, void *data, char *insta
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("firewall", "service", stmp, s) {
|
||||
|
|
@ -377,16 +377,16 @@ static int browseRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_d
|
|||
/*#Device.Firewall.DMZ.{i}.!UCI:firewall/dmz/dmmap_dmz*/
|
||||
static int browseFirewallDMZInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *inst = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("firewall", "dmz", "dmmap_dmz", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "dmz_instance", "dmz_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "dmz_instance", "dmz_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -395,15 +395,15 @@ static int browseFirewallDMZInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
|
||||
static int browseServiceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("firewall", "service", "dmmap_firewall", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "service_instance", "service_alias");
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "service_instance", "service_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -513,8 +513,8 @@ static int delObjFirewallDMZ(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("firewall", "dmz", stmp, s) {
|
||||
|
|
@ -1981,18 +1981,18 @@ static int get_firewall_dmz_number_of_entries(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.Firewall.DMZ.{i}.Alias!UCI:dmmap_dmz/DMZ,@i-1/alias*/
|
||||
static int get_FirewallDMZ_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "dmz_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "dmz_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_FirewallDMZ_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "dmz_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "dmz_alias", instance, value);
|
||||
}
|
||||
|
||||
/*#Device.Firewall.DMZ.{i}.Enable!UCI:firewall/dmz,@i-1/enabled*/
|
||||
static int get_FirewallDMZ_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enabled", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2007,7 +2007,7 @@ static int set_FirewallDMZ_Enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2016,7 +2016,7 @@ static int set_FirewallDMZ_Enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.Firewall.DMZ.{i}.Status!UCI:firewall/dmz,@i-1/status*/
|
||||
static int get_FirewallDMZ_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct dmmap_dup *dmz_args = (struct dmmap_dup *)data;
|
||||
struct dm_data *dmz_args = (struct dm_data *)data;
|
||||
char *v, *destip, *interface;
|
||||
|
||||
dmuci_get_value_by_section_string(dmz_args->config_section, "interface", &interface);
|
||||
|
|
@ -2034,7 +2034,7 @@ static int get_FirewallDMZ_Status(char *refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.Firewall.DMZ.{i}.Origin!UCI:firewall/dmz,@i-1/origin*/
|
||||
static int get_FirewallDMZ_Origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "origin", "Controller");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "origin", "Controller");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2048,7 +2048,7 @@ static int set_FirewallDMZ_Origin(char *refparam, struct dmctx *ctx, void *data,
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "origin", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "origin", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2057,7 +2057,7 @@ static int set_FirewallDMZ_Origin(char *refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.Firewall.DMZ.{i}.Description!UCI:firewall/dmz,@i-1/description*/
|
||||
static int get_FirewallDMZ_Description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "description", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "description", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2069,7 +2069,7 @@ static int set_FirewallDMZ_Description(char *refparam, struct dmctx *ctx, void *
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "description", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "description", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2080,7 +2080,7 @@ static int get_FirewallDMZ_Interface(char *refparam, struct dmctx *ctx, void *da
|
|||
{
|
||||
char *interf = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &interf);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &interf);
|
||||
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", interf, value);
|
||||
return 0;
|
||||
|
|
@ -2103,7 +2103,7 @@ static int set_FirewallDMZ_Interface(char *refparam, struct dmctx *ctx, void *da
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", reference.value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", reference.value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2112,7 +2112,7 @@ static int set_FirewallDMZ_Interface(char *refparam, struct dmctx *ctx, void *da
|
|||
/*#Device.Firewall.DMZ.{i}.DestIP!UCI:firewall/dmz,@i-1/dest_ip*/
|
||||
static int get_FirewallDMZ_DestIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_ip", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "dest_ip", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2124,7 +2124,7 @@ static int set_FirewallDMZ_DestIP(char *refparam, struct dmctx *ctx, void *data,
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_ip", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_ip", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2133,7 +2133,7 @@ static int set_FirewallDMZ_DestIP(char *refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.Firewall.DMZ.{i}.SourcePrefix!UCI:firewall/dmz,@i-1/source_prefix*/
|
||||
static int get_FirewallDMZ_SourcePrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "source_prefix", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "source_prefix", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2145,7 +2145,7 @@ static int set_FirewallDMZ_SourcePrefix(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "source_prefix", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "source_prefix", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2153,17 +2153,17 @@ static int set_FirewallDMZ_SourcePrefix(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int get_service_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "service_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "service_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_service_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "service_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "service_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_service_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enable", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enable", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2178,7 +2178,7 @@ static int set_service_enable(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enable", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enable", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2189,7 +2189,7 @@ static int get_service_intf(char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
char *intf = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &intf);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &intf);
|
||||
|
||||
if (intf == NULL || *intf == '\0')
|
||||
return 0;
|
||||
|
|
@ -2221,7 +2221,7 @@ static int set_service_intf(char *refparam, struct dmctx *ctx, void *data, char
|
|||
if (!firewall_zone_exists(reference.value))
|
||||
firewall__create_zone_section(reference.value);
|
||||
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", reference.value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", reference.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -2232,7 +2232,7 @@ static int set_service_intf(char *refparam, struct dmctx *ctx, void *data, char
|
|||
static int get_service_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_list *val = NULL;
|
||||
dmuci_get_value_by_section_list(((struct dmmap_dup *)data)->config_section, "dest_port", &val);
|
||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dest_port", &val);
|
||||
*value = dmuci_list_to_string(val, ",");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2250,9 +2250,9 @@ static int set_service_port(char *refparam, struct dmctx *ctx, void *data, char
|
|||
break;
|
||||
case VALUESET:
|
||||
arr = strsplit(value, ",", &length);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_port", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_port", "");
|
||||
for (i = 0; i < length; i++)
|
||||
dmuci_add_list_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_port", arr[i]);
|
||||
dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "dest_port", arr[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2263,7 +2263,7 @@ static int get_service_ipver(char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
char *ipversion;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "family", &ipversion);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "family", &ipversion);
|
||||
if (strcasecmp(ipversion, "ipv4") == 0) {
|
||||
*value = "4";
|
||||
} else if (strcasecmp(ipversion, "ipv6") == 0) {
|
||||
|
|
@ -2284,11 +2284,11 @@ static int set_service_ipver(char *refparam, struct dmctx *ctx, void *data, char
|
|||
break;
|
||||
case VALUESET:
|
||||
if (DM_LSTRCMP(value, "4") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "ipv4");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "family", "ipv4");
|
||||
else if (DM_LSTRCMP(value, "6") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "ipv6");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "family", "ipv6");
|
||||
else if (DM_LSTRCMP(value, "-1") == 0)
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "family", "");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2297,7 +2297,7 @@ static int set_service_ipver(char *refparam, struct dmctx *ctx, void *data, char
|
|||
static int get_service_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_list *val = NULL;
|
||||
dmuci_get_value_by_section_list(((struct dmmap_dup *)data)->config_section, "proto", &val);
|
||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "proto", &val);
|
||||
*value = dmuci_list_to_string(val, ",");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2315,9 +2315,9 @@ static int set_service_protocol(char *refparam, struct dmctx *ctx, void *data, c
|
|||
break;
|
||||
case VALUESET:
|
||||
arr = strsplit(value, ",", &length);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "");
|
||||
for (i = 0; i < length; i++)
|
||||
dmuci_add_list_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", arr[i]);
|
||||
dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "proto", arr[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2326,7 +2326,7 @@ static int set_service_protocol(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
static int get_service_icmp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "icmp_type", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "icmp_type", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2338,7 +2338,7 @@ static int set_service_icmp(char *refparam, struct dmctx *ctx, void *data, char
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "icmp_type", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "icmp_type", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2347,7 +2347,7 @@ static int set_service_icmp(char *refparam, struct dmctx *ctx, void *data, char
|
|||
static int get_service_src_prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_list *val = NULL;
|
||||
dmuci_get_value_by_section_list(((struct dmmap_dup *)data)->config_section, "src_prefix", &val);
|
||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "src_prefix", &val);
|
||||
*value = dmuci_list_to_string(val, ",");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2364,9 +2364,9 @@ static int set_service_src_prefix(char *refparam, struct dmctx *ctx, void *data,
|
|||
break;
|
||||
case VALUESET:
|
||||
arr = strsplit(value, ",", &length);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_prefix", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src_prefix", "");
|
||||
for (i = 0; i < length; i++)
|
||||
dmuci_add_list_value_by_section(((struct dmmap_dup *)data)->config_section, "src_prefix", arr[i]);
|
||||
dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "src_prefix", arr[i]);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2374,7 +2374,7 @@ static int set_service_src_prefix(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_service_action(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "target", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "target", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2388,7 +2388,7 @@ static int set_service_action(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "target", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "target", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -2412,7 +2412,7 @@ static int get_service_status(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
return 0;
|
||||
}
|
||||
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "status", "Enabled");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "status", "Enabled");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@
|
|||
*************************************************************/
|
||||
static int browseGRETunnelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "proto", "gre", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "gretunnel_instance", "gretunnel_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "gretunnel_instance", "gretunnel_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -44,20 +44,21 @@ static struct uci_section *has_tunnel_interface_route(char *interface)
|
|||
static int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, device[128] = {0};
|
||||
struct dmmap_dup *p = NULL, *dm = (struct dmmap_dup *)prev_data;
|
||||
struct uci_section *s = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
snprintf(device, sizeof(device), "@%s", section_name(dm->config_section));
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "device", device, &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
snprintf(device, sizeof(device), "@%s", section_name(((struct dm_data *)prev_data)->config_section));
|
||||
|
||||
if ((s = has_tunnel_interface_route(section_name(p->config_section))) == NULL)
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "device", device, &dup_list);
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
if ((s = has_tunnel_interface_route(section_name(curr_data->config_section))) == NULL)
|
||||
continue;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "greiface_instance", "greiface_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "greiface_instance", "greiface_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -86,9 +87,9 @@ static int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "gretunnel_instance", "");
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "gretunnel_alias", "");
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "gretunnel_instance", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "gretunnel_alias", "");
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_option_eq_safe("network", "interface", "proto", "gre", stmp, s) {
|
||||
|
|
@ -111,7 +112,7 @@ static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
char device_buf[32];
|
||||
|
||||
dmuci_add_section("network", "interface", &greiface_sec);
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dm_data *)data)->config_section));
|
||||
dmuci_set_value_by_section(greiface_sec, "device", device_buf);
|
||||
|
||||
dmuci_add_section("network", "route", &route_sec);
|
||||
|
|
@ -119,7 +120,7 @@ static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_sec);
|
||||
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(greiface_sec));
|
||||
dmuci_set_value_by_section(dmmap_sec, "gre_tunnel_sect", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
dmuci_set_value_by_section(dmmap_sec, "gre_tunnel_sect", section_name(((struct dm_data *)data)->config_section));
|
||||
dmuci_set_value_by_section(dmmap_sec, "greiface_instance", *instance);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -130,13 +131,13 @@ static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "greiface_instance", "");
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "greiface_alias", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "greiface_instance", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "greiface_alias", "");
|
||||
|
||||
if ((s = has_tunnel_interface_route(section_name(((struct dmmap_dup *)data)->config_section))) != NULL)
|
||||
if ((s = has_tunnel_interface_route(section_name(((struct dm_data *)data)->config_section))) != NULL)
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("network", "interface", stmp, s) {
|
||||
|
|
@ -145,7 +146,7 @@ static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
char *device = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dm_data *)data)->config_section));
|
||||
|
||||
if (!device || DM_STRCMP(device, device_buf) != 0)
|
||||
continue;
|
||||
|
|
@ -193,17 +194,17 @@ static int get_GRE_TunnelNumberOfEntries(char *refparam, struct dmctx *ctx, void
|
|||
/*#Device.GRE.Tunnel.{i}.Alias!UCI:dmmap_network/interface,@i-1/gretunnel_alias*/
|
||||
static int get_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "gretunnel_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "gretunnel_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "gretunnel_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "gretunnel_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_GRETunnel_KeepAliveThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "keepalive", "3");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "keepalive", "3");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +216,7 @@ static int set_GRETunnel_KeepAliveThreshold(char *refparam, struct dmctx *ctx, v
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "keepalive", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "keepalive", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -223,7 +224,7 @@ static int set_GRETunnel_KeepAliveThreshold(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
static int get_GRETunnel_ConnectedRemoteEndpoint(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "peeraddr", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "peeraddr", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -236,90 +237,90 @@ static int get_GRETunnel_InterfaceNumberOfEntries(char *refparam, struct dmctx *
|
|||
|
||||
static int get_GRETunnelStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_bytes");
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "tx_bytes");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_bytes");
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "rx_bytes");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_packets");
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "tx_packets");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_packets");
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "rx_packets");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_errors");
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "tx_errors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_errors");
|
||||
*value= get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "rx_errors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.GRE.Tunnel.{i}.Interface.{i}.Alias!UCI:dmmap_network/interface,@i-1/greiface_alias*/
|
||||
static int get_GRETunnelInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "greiface_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "greiface_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_GRETunnelInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "greiface_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "greiface_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterface_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmstrdup(section_name(((struct dmmap_dup *)data)->config_section));
|
||||
*value = dmstrdup(section_name(((struct dm_data *)data)->config_section));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterfaceStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_bytes");
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "tx_bytes");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterfaceStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_bytes");
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "rx_bytes");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterfaceStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_packets");
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "tx_packets");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterfaceStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_packets");
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "rx_packets");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_errors");
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "tx_errors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_GRETunnelInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_errors");
|
||||
*value = get_gre_tunnel_interface_statistics(section_name(((struct dm_data *)data)->config_section), "rx_errors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,16 +84,16 @@ static int browseIEEE1905ALInterfaceLinkInst(struct dmctx *dmctx, DMNODE *parent
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.!UCI:ieee1905/forwarding_rule/dmmap_forwarding_rule*/
|
||||
static int browseIEEE1905ALForwardingTableForwardingRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("ieee1905", "forwarding_rule", "dmmap_forwarding_rule", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "forwardingruleinstance", "forwardingrulealias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "forwardingruleinstance", "forwardingrulealias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -386,8 +386,8 @@ static int delObjIEEE1905ALForwardingTableForwardingRule(char *refparam, struct
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("ieee1905", "forwarding_rule", stmp, s) {
|
||||
|
|
@ -828,7 +828,7 @@ static int get_IEEE1905ALForwardingTable_ForwardingRuleNumberOfEntries(char *ref
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.InterfaceList!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/interface_list*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_InterfaceList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface_list", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface_list", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -840,7 +840,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_InterfaceList(char *refpa
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface_list", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface_list", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -849,7 +849,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_InterfaceList(char *refpa
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.MACDestinationAddress!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/mac_destination_addr*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "mac_destination_addr", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "mac_destination_addr", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -861,7 +861,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress(cha
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "mac_destination_addr", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "mac_destination_addr", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -870,7 +870,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress(cha
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.MACDestinationAddressFlag!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/mac_destination_addr_flag*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "mac_destination_addr_flag", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "mac_destination_addr_flag", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "mac_destination_addr_flag", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "mac_destination_addr_flag", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -894,7 +894,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.MACSourceAddress!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/mac_source_addr*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "mac_source_addr", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "mac_source_addr", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -906,7 +906,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress(char *re
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "mac_source_addr", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "mac_source_addr", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -915,7 +915,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress(char *re
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.MACSourceAddressFlag!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/mac_source_addr_flag*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "mac_source_addr_flag", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "mac_source_addr_flag", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -930,7 +930,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag(char
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "mac_source_addr_flag", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "mac_source_addr_flag", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -939,7 +939,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag(char
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.EtherType!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/ether_type*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_EtherType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ether_type", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ether_type", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -951,7 +951,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_EtherType(char *refparam,
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ether_type", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ether_type", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -960,7 +960,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_EtherType(char *refparam,
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.EtherTypeFlag!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/ether_type_flag*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ether_type_flag", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ether_type_flag", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -975,7 +975,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag(char *refpa
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ether_type_flag", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ether_type_flag", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -984,7 +984,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag(char *refpa
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.Vid!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/vid*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_Vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "vid", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "vid", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -996,7 +996,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_Vid(char *refparam, struc
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "vid", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "vid", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1005,7 +1005,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_Vid(char *refparam, struc
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.VidFlag!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/vid_flag*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_VidFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid_flag", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "vid_flag", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1020,7 +1020,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_VidFlag(char *refparam, s
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "vid_flag", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "vid_flag", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1029,7 +1029,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_VidFlag(char *refparam, s
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.PCP!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/pcp*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_PCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "pcp", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "pcp", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1041,7 +1041,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_PCP(char *refparam, struc
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "pcp", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "pcp", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1050,7 +1050,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_PCP(char *refparam, struc
|
|||
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.PCPFlag!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/pcp_flag*/
|
||||
static int get_IEEE1905ALForwardingTableForwardingRule_PCPFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "pcp_flag", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "pcp_flag", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1065,7 +1065,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_PCPFlag(char *refparam, s
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "pcp_flag", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "pcp_flag", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -542,26 +542,25 @@ static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmm
|
|||
/*#Device.IP.Interface.{i}.!UCI:network/interface/dmmap_network*/
|
||||
static int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL;
|
||||
char *proto, *device;
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *proto = NULL, *device = NULL, *inst = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("network", "interface", "dmmap_network", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &device);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "device", &device);
|
||||
|
||||
if (strcmp(section_name(p->config_section), "loopback") == 0 ||
|
||||
if (strcmp(section_name(curr_data->config_section), "loopback") == 0 ||
|
||||
*proto == '\0' ||
|
||||
DM_STRCHR(device, '@') ||
|
||||
ip___is_ip_interface_instance_exists(section_name(p->config_section), device))
|
||||
ip___is_ip_interface_instance_exists(section_name(curr_data->config_section), device))
|
||||
continue;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "ip_int_instance", "ip_int_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "ip_int_instance", "ip_int_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data->config_section, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
|
|||
|
|
@ -54,15 +54,17 @@ static int delMQTTBroker(char *refparam, struct dmctx *ctx, void *data, char *in
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("mosquitto", "listener", stmp, s) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_mqtt", "listener", section_name(s), &dmmap_section);
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -74,16 +76,16 @@ static int delMQTTBroker(char *refparam, struct dmctx *ctx, void *data, char *in
|
|||
*************************************************************/
|
||||
static int browseMQTTBrokerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *inst = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("mosquitto", "listener", "dmmap_mqtt", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "listener_instance", "listener_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "listener_instance", "listener_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -102,17 +104,17 @@ static int get_MQTT_BrokerNumberOfEntries(char *refparam, struct dmctx *ctx, voi
|
|||
|
||||
static int get_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "listener_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "listener_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "listener_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "listener_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enabled", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +128,7 @@ static int set_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -134,7 +136,7 @@ static int set_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "section_name", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +156,7 @@ static int set_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
}
|
||||
|
||||
// Check if new name is same as current name
|
||||
curr_name = section_name(((struct dmmap_dup *)data)->config_section);
|
||||
curr_name = section_name(((struct dm_data *)data)->config_section);
|
||||
if (DM_STRCMP(curr_name, value) == 0)
|
||||
break;
|
||||
|
||||
|
|
@ -167,18 +169,18 @@ static int set_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
break;
|
||||
case VALUESET:
|
||||
// If new name is same as current name then nothing to do
|
||||
curr_name = section_name(((struct dmmap_dup *)data)->config_section);
|
||||
curr_name = section_name(((struct dm_data *)data)->config_section);
|
||||
if (DM_STRCMP(curr_name, value) == 0)
|
||||
break;
|
||||
|
||||
// Update mosquitto config
|
||||
if (0 != dmuci_rename_section_by_section(((struct dmmap_dup *)data)->config_section, value)) {
|
||||
if (0 != dmuci_rename_section_by_section(((struct dm_data *)data)->config_section, value)) {
|
||||
bbfdm_set_fault_message(ctx, "Rename the entry name with '%s' value was failed.", value);
|
||||
return FAULT_9001;
|
||||
}
|
||||
|
||||
// Update dmmap_mqtt file
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "section_name", value);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -187,7 +189,7 @@ static int set_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
|
||||
static int get_MQTTBroker_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "port", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "port", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +201,7 @@ static int set_MQTTBroker_Port(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "port", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "port", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -209,7 +211,7 @@ static int get_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat
|
|||
{
|
||||
char *intf = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &intf);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &intf);
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", intf, value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -231,7 +233,7 @@ static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", reference.value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", reference.value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -239,7 +241,7 @@ static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
static int get_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "username", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "username", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +260,7 @@ static int set_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "username", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "username", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -266,7 +268,7 @@ static int set_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
static int get_MQTTBroker_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "password", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "password", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +280,7 @@ static int set_MQTTBroker_Password(char *refparam, struct dmctx *ctx, void *data
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "password", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "password", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ static int get_nat_port_mapping_external_port_end_range(char *refparam, struct d
|
|||
static int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("firewall", "zone", "dmmap_firewall", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "interface_setting_instance", "interface_setting_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "interface_setting_instance", "interface_setting_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -39,14 +39,14 @@ static int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
/*#Device.NAT.PortMapping.{i}.!UCI:firewall/redirect/dmmap_firewall*/
|
||||
static int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, *target;
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *inst = NULL, *target = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("firewall", "redirect", "dmmap_firewall", &dup_list);
|
||||
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
dmuci_get_value_by_section_string(p->config_section, "target", &target);
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "target", &target);
|
||||
if (*target != '\0' && DM_LSTRCMP(target, "DNAT") != 0)
|
||||
continue;
|
||||
|
||||
|
|
@ -54,16 +54,16 @@ static int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
* Add port range end in dmmap section if needed
|
||||
*/
|
||||
char *src_dport = NULL;
|
||||
dmuci_get_value_by_section_string(p->config_section, "src_dport", &src_dport);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "src_dport", &src_dport);
|
||||
if (DM_STRLEN(src_dport) != 0) {
|
||||
char *tmp = DM_STRCHR(src_dport, '-');
|
||||
if (tmp)
|
||||
dmuci_set_value_by_section(p->dmmap_section, "src_dport_end", tmp + 1);
|
||||
dmuci_set_value_by_section(curr_data->dmmap_section, "src_dport_end", tmp + 1);
|
||||
}
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "port_mapping_instance", "port_mapping_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "port_mapping_instance", "port_mapping_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -101,8 +101,8 @@ static int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("firewall", "zone", stmp, s) {
|
||||
|
|
@ -144,8 +144,8 @@ static int delete_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("firewall", "redirect", stmp, s) {
|
||||
|
|
@ -184,7 +184,7 @@ static int get_nat_port_mapping_number_of_entries(char *refparam, struct dmctx *
|
|||
static int get_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *val;
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "masq", &val);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "masq", &val);
|
||||
*value = (*val == '1') ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ static int set_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, v
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "masq", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "masq", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -209,7 +209,7 @@ static int set_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, v
|
|||
static int get_nat_interface_setting_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *val;
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "masq", &val);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "masq", &val);
|
||||
*value = (*val == '1') ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -217,12 +217,12 @@ static int get_nat_interface_setting_status(char *refparam, struct dmctx *ctx, v
|
|||
/*#Device.NAT.InterfaceSetting.{i}.Alias!UCI:dmmap_firewall/zone,@i-1/interface_setting_alias*/
|
||||
static int get_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "interface_setting_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "interface_setting_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "interface_setting_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "interface_setting_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
|
|
@ -232,7 +232,7 @@ static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
|
|||
unsigned pos = 0;
|
||||
|
||||
buf[0] = 0;
|
||||
dmuci_get_value_by_section_list(((struct dmmap_dup *)data)->config_section, "network", &v);
|
||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "network", &v);
|
||||
if (v) {
|
||||
struct uci_element *e = NULL;
|
||||
char *ifaceobj = NULL;
|
||||
|
|
@ -269,8 +269,8 @@ static int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
|
|||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "network", "");
|
||||
dmuci_add_list_value_by_section(((struct dmmap_dup *)data)->config_section, "network", reference.value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "network", "");
|
||||
dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "network", reference.value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -279,7 +279,7 @@ static int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
|
|||
/*#Device.NAT.PortMapping.{i}.Enable!UCI:firewall/redirect,@i-1/enabled*/
|
||||
static int get_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->dmmap_section, "enabled", "1");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->dmmap_section, "enabled", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -294,8 +294,8 @@ static int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "enabled", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "enabled", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enabled", b ? "1" : "0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -311,12 +311,12 @@ static int get_nat_port_mapping_status(char *refparam, struct dmctx *ctx, void *
|
|||
/*#Device.NAT.PortMapping.{i}.Alias!UCI:dmmap_firewall/redirect,@i-1/port_mapping_alias*/
|
||||
static int get_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "port_mapping_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "port_mapping_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "port_mapping_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "port_mapping_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
|
|
@ -326,12 +326,12 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
|
|||
char *zone_name = NULL, *name = NULL, *src_dip = NULL, buf[256];
|
||||
unsigned pos = 0;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dip", &src_dip);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src_dip", &src_dip);
|
||||
if (src_dip && DM_LSTRCMP(src_dip, "*") == 0)
|
||||
return 0;
|
||||
|
||||
buf[0] = 0;
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src", &zone_name);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src", &zone_name);
|
||||
uci_foreach_sections("firewall", "zone", s) {
|
||||
dmuci_get_value_by_section_string(s, "name", &name);
|
||||
if (zone_name && name && DM_STRCMP(zone_name, name) == 0) {
|
||||
|
|
@ -391,20 +391,20 @@ static int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
|
|||
|
||||
dmuci_get_value_by_section_string(s, "name", &zone_name);
|
||||
dmuci_get_value_by_section_string(s, "masq", &zone_masq);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src", zone_name);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src", zone_name);
|
||||
|
||||
// set this section enable parameter based on the configured zone masq value
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "enabled", &val);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "enabled", &val);
|
||||
sect_enable = (*val == '1') ? true : false;
|
||||
zone_enable = (*zone_masq == '1') ? true : false;
|
||||
|
||||
sect_enable = sect_enable && zone_enable;
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", sect_enable ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enabled", sect_enable ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src", "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -415,7 +415,7 @@ static int get_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx,
|
|||
{
|
||||
char *src_dip = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dip", &src_dip);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src_dip", &src_dip);
|
||||
*value = (src_dip && *src_dip == '*') ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -432,11 +432,11 @@ static int set_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx,
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_dip", b ? "*" : "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src_dip", b ? "*" : "");
|
||||
if (b) {
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src", &src);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src", &src);
|
||||
if (src == NULL || *src == '\0')
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src", "wan");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src", "wan");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -448,7 +448,7 @@ static int get_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx
|
|||
{
|
||||
char *expiry_date = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "expiry", &expiry_date);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "expiry", &expiry_date);
|
||||
if (expiry_date && *expiry_date != '\0' && DM_STRTOL(expiry_date) > 0) {
|
||||
dmasprintf(value, "%lld", (long long)(DM_STRTOL(expiry_date) - time(NULL)));
|
||||
} else {
|
||||
|
|
@ -471,7 +471,7 @@ static int set_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx
|
|||
break;
|
||||
|
||||
snprintf(expiry_date, sizeof(expiry_date), "%lld", (long long)(DM_STRTOL(value) + time(NULL)));
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "expiry", expiry_date);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "expiry", expiry_date);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -480,7 +480,7 @@ static int set_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx
|
|||
/*#Device.NAT.PortMapping.{i}.RemoteHost!UCI:firewall/redirect,@i-1/src_dip*/
|
||||
static int get_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_ip", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src_ip", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -492,7 +492,7 @@ static int set_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, v
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_ip", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src_ip", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -502,7 +502,7 @@ static int set_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, v
|
|||
static int get_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *src_dport = NULL;
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dport", &src_dport);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src_dport", &src_dport);
|
||||
if (src_dport && *src_dport == '\0') {
|
||||
*value = "0";
|
||||
return 0;
|
||||
|
|
@ -537,7 +537,7 @@ static int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx,
|
|||
return 0;
|
||||
case VALUESET:
|
||||
if (strcmp(value, "0") == 0) { /* 0 means no external port */
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_dport", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src_dport", "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -547,7 +547,7 @@ static int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx,
|
|||
else
|
||||
snprintf(buffer, sizeof(buffer), "%d-%d", start_port, end_port);
|
||||
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_dport", buffer);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src_dport", buffer);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -556,7 +556,7 @@ static int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.NAT.PortMapping.{i}.ExternalPortEndRange!UCI:firewall/redirect,@i-1/src_dport*/
|
||||
static int get_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->dmmap_section, "src_dport_end", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->dmmap_section, "src_dport_end", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +583,7 @@ static int set_nat_port_mapping_external_port_end_range(char *refparam, struct d
|
|||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "src_dport_end", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "src_dport_end", value);
|
||||
|
||||
dport = DM_STRTOL(value);
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ static int set_nat_port_mapping_external_port_end_range(char *refparam, struct d
|
|||
else
|
||||
snprintf(buffer, sizeof(buffer), "%d", sport);
|
||||
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_dport", buffer);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "src_dport", buffer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -604,7 +604,7 @@ static int set_nat_port_mapping_external_port_end_range(char *refparam, struct d
|
|||
/*#Device.NAT.PortMapping.{i}.InternalPort!UCI:firewall/redirect,@i-1/dest_port*/
|
||||
static int get_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "dest_port", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "dest_port", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ static int set_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_port", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_port", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -626,7 +626,7 @@ static int set_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx,
|
|||
static int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *proto = NULL;
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
|
||||
*value = (proto && DM_LSTRCMP(proto, "udp") == 0) ? "UDP" : "TCP";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -641,7 +641,7 @@ static int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (DM_LSTRCMP(value, "UDP") == 0) ? "udp" : "tcp");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", (DM_LSTRCMP(value, "UDP") == 0) ? "udp" : "tcp");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -650,7 +650,7 @@ static int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
|
|||
/*#Device.NAT.PortMapping.{i}.InternalClient!UCI:firewall/redirect,@i-1/dest_ip*/
|
||||
static int get_nat_port_mapping_internal_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_ip", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "dest_ip", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -662,7 +662,7 @@ static int set_nat_port_mapping_internal_client(char *refparam, struct dmctx *ct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_ip", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dest_ip", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -671,7 +671,7 @@ static int set_nat_port_mapping_internal_client(char *refparam, struct dmctx *ct
|
|||
/*#Device.NAT.PortMapping.{i}.Description!UCI:firewall/redirect,@i-1/name*/
|
||||
static int get_nat_port_mapping_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -683,7 +683,7 @@ static int set_nat_port_mapping_description(char *refparam, struct dmctx *ctx, v
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "name", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,12 +12,6 @@
|
|||
#include "dns.h"
|
||||
#include "routeradvertisement.h"
|
||||
|
||||
struct radv_option_args {
|
||||
struct uci_section *config_sect;
|
||||
struct uci_section *dmmap_sect;
|
||||
char *option_value;
|
||||
};
|
||||
|
||||
/*************************************************************
|
||||
* COMMON FUNCTIONS
|
||||
**************************************************************/
|
||||
|
|
@ -52,20 +46,20 @@ static int radv_set_option_value(struct uci_section *s, char *option_list, const
|
|||
static int browseRouterAdvertisementInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, *ignore = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("dhcp", "dhcp", "dmmap_radv", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
// skip the section if option ignore = '1'
|
||||
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "ignore", &ignore);
|
||||
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
|
||||
continue;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "radv_intf_instance", "radv_intf_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "radv_intf_instance", "radv_intf_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
|
|
@ -74,9 +68,9 @@ static int browseRouterAdvertisementInterfaceSettingInst(struct dmctx *dmctx, DM
|
|||
|
||||
static int browseRouterAdvertisementInterfaceSettingOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *dhcp_s = ((struct dmmap_dup *)prev_data)->config_section;
|
||||
struct uci_section *dhcp_s = ((struct dm_data *)prev_data)->config_section;
|
||||
struct uci_section *dhcp_dmmap_s = NULL;
|
||||
struct radv_option_args radv_option_args = {0};
|
||||
struct dm_data curr_data = {0};
|
||||
struct uci_list *dns_list = NULL;
|
||||
char *inst = NULL, *option_value = NULL;
|
||||
|
||||
|
|
@ -97,13 +91,13 @@ static int browseRouterAdvertisementInterfaceSettingOptionInst(struct dmctx *dmc
|
|||
uci_path_foreach_option_eq(bbfdm, "dmmap_radv", "radv_option", "section_name", section_name(dhcp_s), dhcp_dmmap_s) {
|
||||
dmuci_get_value_by_section_string(dhcp_dmmap_s, "option_value", &option_value);
|
||||
|
||||
radv_option_args.config_sect = dhcp_s;
|
||||
radv_option_args.dmmap_sect = dhcp_dmmap_s;
|
||||
radv_option_args.option_value = option_value;
|
||||
curr_data.config_section = dhcp_s;
|
||||
curr_data.dmmap_section = dhcp_dmmap_s;
|
||||
curr_data.additional_data = (void *)option_value;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, dhcp_dmmap_s, "radv_option_instance", "radv_option_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&radv_option_args, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -137,8 +131,8 @@ static int delObjRouterAdvertisementInterfaceSetting(char *refparam, struct dmct
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("dhcp", "dhcp", stmp, s) {
|
||||
|
|
@ -159,7 +153,7 @@ static int addObjRouterAdvertisementInterfaceSettingOption(char *refparam, struc
|
|||
struct uci_section *dmmap_sect = NULL;
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_radv", "radv_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(((struct dm_data *)data)->config_section));
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", "23");
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "radv_option_instance", *instance);
|
||||
return 0;
|
||||
|
|
@ -172,14 +166,14 @@ static int delObjRouterAdvertisementInterfaceSettingOption(char *refparam, struc
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_get_value_by_section_list(((struct radv_option_args *)data)->config_sect, "dns", &dns_list);
|
||||
if (value_exists_in_uci_list(dns_list, ((struct radv_option_args *)data)->option_value))
|
||||
dmuci_del_list_value_by_section(((struct radv_option_args *)data)->config_sect, "dns", ((struct radv_option_args *)data)->option_value);
|
||||
dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dns", &dns_list);
|
||||
if (value_exists_in_uci_list(dns_list, ((struct dm_data *)data)->additional_data))
|
||||
dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dns", ((struct dm_data *)data)->additional_data);
|
||||
|
||||
dmuci_delete_by_section(((struct radv_option_args *)data)->dmmap_sect, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dns", "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dns", "");
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_radv", "radv_option", stmp, s) {
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
|
|
@ -235,7 +229,7 @@ static int get_RouterAdvertisement_InterfaceSettingNumberOfEntries(char *refpara
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.Enable!UCI:dhcp/dhcp,@i-1/ra*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ra", value);
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -251,7 +245,7 @@ static int set_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra", b ? "server" : "disabled");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra", b ? "server" : "disabled");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -260,19 +254,19 @@ static int set_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.Status!UCI:dhcp/dhcp,@i-1/ra*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ra", value);
|
||||
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_RouterAdvertisementInterfaceSetting_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "radv_intf_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_intf_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_RouterAdvertisementInterfaceSetting_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_dup *)data)->dmmap_section, "radv_intf_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_intf_alias", instance, value);
|
||||
}
|
||||
|
||||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.Interface!UCI:dhcp/dhcp,@i-1/interface*/
|
||||
|
|
@ -280,7 +274,7 @@ static int get_RouterAdvertisementInterfaceSetting_Interface(char *refparam, str
|
|||
{
|
||||
char *linker = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &linker);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &linker);
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -302,7 +296,7 @@ static int set_RouterAdvertisementInterfaceSetting_Interface(char *refparam, str
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", reference.value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", reference.value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -315,8 +309,8 @@ static int get_RouterAdvertisementInterfaceSetting_Prefixes(char *refparam, stru
|
|||
struct uci_section *dmmap_s = NULL;
|
||||
int i = 0, pos = 0;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &interface);
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "ip_int_instance", &ip_inst);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &interface);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "ip_int_instance", &ip_inst);
|
||||
|
||||
list_val[0] = 0;
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
|
||||
|
|
@ -350,7 +344,7 @@ static int get_RouterAdvertisementInterfaceSetting_Prefixes(char *refparam, stru
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.MaxRtrAdvInterval!UCI:dhcp/dhcp,@i-1/ra_maxinterval*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_maxinterval", "600");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_maxinterval", "600");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -362,7 +356,7 @@ static int set_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval(char *refpa
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_maxinterval", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_maxinterval", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -371,7 +365,7 @@ static int set_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval(char *refpa
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.MinRtrAdvInterval!UCI:dhcp/dhcp,@i-1/ra_mininterval*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_mininterval", "200");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_mininterval", "200");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -383,7 +377,7 @@ static int set_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval(char *refpa
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_mininterval", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_mininterval", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -392,7 +386,7 @@ static int set_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval(char *refpa
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvDefaultLifetime!UCI:dhcp/dhcp,@i-1/ra_lifetime*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_lifetime", "1800");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_lifetime", "1800");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -404,7 +398,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime(char *refp
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_lifetime", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_lifetime", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -413,7 +407,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime(char *refp
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvManagedFlag!UCI:dhcp/dhcp,@i-1/ra_flags*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvManagedFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return radv_get_option_value(((struct dmmap_dup *)data)->config_section, "ra_flags", "managed-config", value);
|
||||
return radv_get_option_value(((struct dm_data *)data)->config_section, "ra_flags", "managed-config", value);
|
||||
}
|
||||
|
||||
static int set_RouterAdvertisementInterfaceSetting_AdvManagedFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
|
|
@ -427,7 +421,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvManagedFlag(char *refparam
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
return radv_set_option_value(((struct dmmap_dup *)data)->config_section, "ra_flags", "managed-config", b);
|
||||
return radv_set_option_value(((struct dm_data *)data)->config_section, "ra_flags", "managed-config", b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -435,7 +429,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvManagedFlag(char *refparam
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvOtherConfigFlag!UCI:dhcp/dhcp,@i-1/ra_flags*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return radv_get_option_value(((struct dmmap_dup *)data)->config_section, "ra_flags", "other-config", value);
|
||||
return radv_get_option_value(((struct dm_data *)data)->config_section, "ra_flags", "other-config", value);
|
||||
}
|
||||
|
||||
static int set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
|
|
@ -449,7 +443,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag(char *refp
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
return radv_set_option_value(((struct dmmap_dup *)data)->config_section, "ra_flags", "other-config", b);
|
||||
return radv_set_option_value(((struct dm_data *)data)->config_section, "ra_flags", "other-config", b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -457,7 +451,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag(char *refp
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvMobileAgentFlag!UCI:dhcp/dhcp,@i-1/ra_flags*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return radv_get_option_value(((struct dmmap_dup *)data)->config_section, "ra_flags", "home-agent", value);
|
||||
return radv_get_option_value(((struct dm_data *)data)->config_section, "ra_flags", "home-agent", value);
|
||||
}
|
||||
|
||||
static int set_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
|
|
@ -471,7 +465,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag(char *refp
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
return radv_set_option_value(((struct dmmap_dup *)data)->config_section, "ra_flags", "home-agent", b);
|
||||
return radv_set_option_value(((struct dm_data *)data)->config_section, "ra_flags", "home-agent", b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -481,7 +475,7 @@ static int get_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *
|
|||
{
|
||||
char *preferenece = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra_preference", &preferenece);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "ra_preference", &preferenece);
|
||||
*value = (preferenece && *preferenece == 'h') ? "High" : (preferenece && *preferenece == 'l') ? "Low" : "Medium";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -496,7 +490,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_preference", (*value == 'H') ? "high" : (*value == 'L') ? "low" : "medium");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_preference", (*value == 'H') ? "high" : (*value == 'L') ? "low" : "medium");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -505,7 +499,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvLinkMTU!UCI:dhcp/dhcp,@i-1/ra_mtu*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvLinkMTU(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_mtu", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_mtu", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -517,7 +511,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvLinkMTU(char *refparam, st
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_mtu", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_mtu", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -526,7 +520,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvLinkMTU(char *refparam, st
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvReachableTime!UCI:dhcp/dhcp,@i-1/ra_reachabletime*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvReachableTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_reachabletime", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_reachabletime", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -538,7 +532,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvReachableTime(char *refpar
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_reachabletime", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_reachabletime", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -547,7 +541,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvReachableTime(char *refpar
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvRetransTimer!UCI:dhcp/dhcp,@i-1/ra_retranstime*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvRetransTimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_retranstime", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_retranstime", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -559,7 +553,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvRetransTimer(char *refpara
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_retranstime", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_retranstime", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -568,7 +562,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvRetransTimer(char *refpara
|
|||
/*#Device.RouterAdvertisement.InterfaceSetting.{i}.AdvCurHopLimit!UCI:dhcp/dhcp,@i-1/ra_hoplimit*/
|
||||
static int get_RouterAdvertisementInterfaceSetting_AdvCurHopLimit(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "ra_hoplimit", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "ra_hoplimit", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +574,7 @@ static int set_RouterAdvertisementInterfaceSetting_AdvCurHopLimit(char *refparam
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ra_hoplimit", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ra_hoplimit", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -595,13 +589,13 @@ static int get_RouterAdvertisementInterfaceSetting_OptionNumberOfEntries(char *r
|
|||
|
||||
static int get_RouterAdvertisementInterfaceSettingOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct radv_option_args *radv_option_s = (struct radv_option_args *)data;
|
||||
return radv_get_option_value(radv_option_s->config_sect, "dns", radv_option_s->option_value, value);
|
||||
struct dm_data *radv_option_s = (struct dm_data *)data;
|
||||
return radv_get_option_value(radv_option_s->config_section, "dns", radv_option_s->additional_data, value);
|
||||
}
|
||||
|
||||
static int set_RouterAdvertisementInterfaceSettingOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct radv_option_args *radv_option_s = (struct radv_option_args *)data;
|
||||
struct dm_data *radv_option_s = (struct dm_data *)data;
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -611,19 +605,19 @@ static int set_RouterAdvertisementInterfaceSettingOption_Enable(char *refparam,
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
return radv_set_option_value(radv_option_s->config_sect, "dns", radv_option_s->option_value, b);
|
||||
return radv_set_option_value(radv_option_s->config_section, "dns", radv_option_s->additional_data, b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_RouterAdvertisementInterfaceSettingOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct radv_option_args *)data)->dmmap_sect, "radv_option_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_option_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_RouterAdvertisementInterfaceSettingOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct radv_option_args *)data)->dmmap_sect, "radv_option_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "radv_option_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_RouterAdvertisementInterfaceSettingOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
|
|
@ -647,7 +641,7 @@ static int set_RouterAdvertisementInterfaceSettingOption_Tag(char *refparam, str
|
|||
|
||||
static int get_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
const char *option_value = ((struct radv_option_args *)data)->option_value;
|
||||
const char *option_value = ((struct dm_data *)data)->additional_data;
|
||||
char hex[65535] = {0};
|
||||
|
||||
if (option_value && *option_value)
|
||||
|
|
@ -659,7 +653,7 @@ static int get_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, s
|
|||
|
||||
static int set_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct radv_option_args *radv_option_s = (struct radv_option_args *)data;
|
||||
struct dm_data *radv_option_s = (struct dm_data *)data;
|
||||
struct uci_list *dns_list = NULL;
|
||||
char res[256] = {0};
|
||||
|
||||
|
|
@ -671,13 +665,13 @@ static int set_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, s
|
|||
case VALUESET:
|
||||
convert_hex_to_string(value, res, sizeof(res));
|
||||
|
||||
dmuci_get_value_by_section_list(radv_option_s->config_sect, "dns", &dns_list);
|
||||
if (value_exists_in_uci_list(dns_list, radv_option_s->option_value)) {
|
||||
dmuci_del_list_value_by_section(radv_option_s->config_sect, "dns", radv_option_s->option_value);
|
||||
dmuci_add_list_value_by_section(radv_option_s->config_sect, "dns", res);
|
||||
dmuci_get_value_by_section_list(radv_option_s->config_section, "dns", &dns_list);
|
||||
if (value_exists_in_uci_list(dns_list, radv_option_s->additional_data)) {
|
||||
dmuci_del_list_value_by_section(radv_option_s->config_section, "dns", radv_option_s->additional_data);
|
||||
dmuci_add_list_value_by_section(radv_option_s->config_section, "dns", res);
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section_bbfdm(radv_option_s->dmmap_sect, "option_value", res);
|
||||
dmuci_set_value_by_section_bbfdm(radv_option_s->dmmap_section, "option_value", res);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -392,8 +392,8 @@ static int browseIPv4ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, vo
|
|||
{
|
||||
struct uci_section *router_s = (struct uci_section *)prev_data;
|
||||
struct routingfwdargs curr_routefwdargs = {0};
|
||||
struct dm_data *curr_data = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *rt_table = NULL;
|
||||
char *inst = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
|
@ -402,16 +402,16 @@ static int browseIPv4ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, vo
|
|||
|
||||
// Enable Routes
|
||||
synchronize_specific_config_sections_with_dmmap("network", "route", "dmmap_routing", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
char *table = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "table", &table);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "table", &table);
|
||||
if (DM_STRCMP(rt_table, table) != 0 || (DM_STRLEN(table) == 0 && DM_STRCMP(rt_table, "254") != 0))
|
||||
continue;
|
||||
|
||||
init_args_route_forwarding(&curr_routefwdargs, p->config_section, ROUTE_STATIC);
|
||||
init_args_route_forwarding(&curr_routefwdargs, curr_data->config_section, ROUTE_STATIC);
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "route_instance", "route_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "route_instance", "route_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, inst) == DM_STOP)
|
||||
goto end;
|
||||
|
|
@ -439,8 +439,8 @@ static int browseIPv6ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, vo
|
|||
{
|
||||
struct uci_section *router_s = (struct uci_section *)prev_data;
|
||||
struct routingfwdargs curr_route6fwdargs = {0};
|
||||
struct dm_data *curr_data = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
char *rt_table = NULL;
|
||||
char *inst = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
|
@ -449,16 +449,16 @@ static int browseIPv6ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, vo
|
|||
|
||||
// Enable Routes
|
||||
synchronize_specific_config_sections_with_dmmap("network", "route6", "dmmap_routing", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
char *table = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "table", &table);
|
||||
dmuci_get_value_by_section_string(curr_data->config_section, "table", &table);
|
||||
if (DM_STRCMP(rt_table, table) != 0 || (DM_STRLEN(table) == 0 && DM_STRCMP(rt_table, "254") != 0))
|
||||
continue;
|
||||
|
||||
init_args_route_forwarding(&curr_route6fwdargs, p->config_section, ROUTE_STATIC);
|
||||
init_args_route_forwarding(&curr_route6fwdargs, curr_data->config_section, ROUTE_STATIC);
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "route6_instance", "route6_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "route6_instance", "route6_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_route6fwdargs, inst) == DM_STOP)
|
||||
goto end;
|
||||
|
|
|
|||
|
|
@ -20,14 +20,6 @@ struct ssh_session_args {
|
|||
char pid[15];
|
||||
};
|
||||
|
||||
struct dmmap_ssh
|
||||
{
|
||||
struct list_head list;
|
||||
struct uci_section *config_section;
|
||||
struct uci_section *dmmap_section;
|
||||
struct list_head *sessions;
|
||||
};
|
||||
|
||||
static void add_pubkey(const char *cur, const char *new)
|
||||
{
|
||||
if (DM_STRLEN(cur) == 0) {
|
||||
|
|
@ -128,56 +120,6 @@ static bool key_exists(const char *key)
|
|||
return exists;
|
||||
}
|
||||
|
||||
static void add_ssh_config_dup_list(struct list_head *dup_list, struct uci_section *config_section, struct uci_section *dmmap_section)
|
||||
{
|
||||
struct dmmap_ssh *dmmap_config;
|
||||
|
||||
dmmap_config = dmcalloc(1, sizeof(struct dmmap_ssh));
|
||||
list_add_tail(&dmmap_config->list, dup_list);
|
||||
dmmap_config->config_section = config_section;
|
||||
dmmap_config->dmmap_section = dmmap_section;
|
||||
}
|
||||
|
||||
static void free_ssh_config_dup_list(struct list_head *dup_list)
|
||||
{
|
||||
struct dmmap_ssh *dmmap_config = NULL, *tmp = NULL;
|
||||
|
||||
list_for_each_entry_safe(dmmap_config, tmp, dup_list, list) {
|
||||
list_del(&dmmap_config->list);
|
||||
dmfree(dmmap_config);
|
||||
}
|
||||
}
|
||||
|
||||
static void synchronize_ssh_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list)
|
||||
{
|
||||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
char *v;
|
||||
|
||||
uci_foreach_sections(package, section_type, s) {
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add system and dmmap sections to the list
|
||||
*/
|
||||
add_ssh_config_dup_list(dup_list, s, dmmap_sect);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete unused dmmap sections
|
||||
*/
|
||||
uci_path_foreach_sections_safe(bbfdm, dmmap_package, section_type, stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &v);
|
||||
if (get_origin_section_from_config(package, section_type, v) == NULL)
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void ssh_server_session_init(struct list_head *sess_list)
|
||||
{
|
||||
char cmd[512] = {0};
|
||||
|
|
@ -324,17 +266,19 @@ static int delObjSSHServer(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
close_active_sessions(((struct dmmap_ssh *)data)->config_section);
|
||||
dmuci_delete_by_section(((struct dmmap_ssh *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_ssh *)data)->dmmap_section, NULL, NULL);
|
||||
close_active_sessions(((struct dm_data *)data)->config_section);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("dropbear", "dropbear", stmp, s) {
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name(s), &dmmap_section);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
||||
close_active_sessions(s);
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -376,34 +320,34 @@ static int delObjSSHKey(char *refparam, struct dmctx *ctx, void *data, char *ins
|
|||
*************************************************************/
|
||||
static int browseSSHServerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct dmmap_ssh *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
LIST_HEAD(session_list);
|
||||
char *inst = NULL;
|
||||
|
||||
ssh_server_session_init(&session_list);
|
||||
synchronize_ssh_config_sections_with_dmmap("dropbear", "dropbear", "dmmap_dropbear", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
synchronize_specific_config_sections_with_dmmap("dropbear", "dropbear", "dmmap_dropbear", &dup_list);
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
bool b;
|
||||
char *enable = dmuci_get_value_by_section_fallback_def(p->config_section, "enable", "1");
|
||||
char *act_date = dmuci_get_value_by_section_fallback_def(p->dmmap_section, "activationdate", "");
|
||||
char *enable = dmuci_get_value_by_section_fallback_def(curr_data->config_section, "enable", "1");
|
||||
char *act_date = dmuci_get_value_by_section_fallback_def(curr_data->dmmap_section, "activationdate", "");
|
||||
|
||||
string_to_bool(enable, &b);
|
||||
if (b && DM_STRLEN(act_date) == 0) {
|
||||
char *tm = NULL;
|
||||
dm_time_format(time(NULL), &tm);
|
||||
dmuci_set_value_by_section(p->dmmap_section, "activationdate", tm);
|
||||
dmuci_set_value_by_section(curr_data->dmmap_section, "activationdate", tm);
|
||||
}
|
||||
|
||||
p->sessions = &session_list;
|
||||
curr_data->additional_data = (void *)&session_list;
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "server_instance", "server_alias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "server_instance", "server_alias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
free_ssh_session_list(&session_list);
|
||||
free_ssh_config_dup_list(&dup_list);
|
||||
free_dmmap_config_dup_list(&dup_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -469,7 +413,7 @@ static int browseSSHServerSessionInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
char *inst = NULL;
|
||||
int id = 0;
|
||||
|
||||
struct uci_section *s = ((struct dmmap_ssh *)prev_data)->config_section;
|
||||
struct uci_section *s = ((struct dm_data *)prev_data)->config_section;
|
||||
char *value = dmuci_get_value_by_section_fallback_def(s, "enable", "1");
|
||||
string_to_bool(value, &b);
|
||||
if (!b)
|
||||
|
|
@ -513,7 +457,7 @@ static int browseSSHServerSessionInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
}
|
||||
|
||||
struct ssh_session_args *session = NULL;
|
||||
struct list_head *sess_list = ((struct dmmap_ssh *)prev_data)->sessions;
|
||||
struct list_head *sess_list = (struct list_head *)((struct dm_data *)prev_data)->additional_data;
|
||||
bool found = false;
|
||||
list_for_each_entry(session, sess_list, list) {
|
||||
if (DM_STRCMP(session->pid, line) == 0) {
|
||||
|
|
@ -565,7 +509,7 @@ static int get_ssh_server_session_num(char *refparam, struct dmctx *ctx, void *d
|
|||
|
||||
static int get_ssh_server_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "enable", "1");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enable", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +524,7 @@ static int set_ssh_server_enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
char *cur = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "enable", "1");
|
||||
char *cur = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enable", "1");
|
||||
bool cur_val;
|
||||
string_to_bool(cur, &cur_val);
|
||||
|
||||
|
|
@ -588,14 +532,14 @@ static int set_ssh_server_enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
break;
|
||||
|
||||
if (b) {
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "enable", "1");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enable", "1");
|
||||
char *tm = NULL;
|
||||
dm_time_format(time(NULL), &tm);
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->dmmap_section, "activationdate", tm);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "activationdate", tm);
|
||||
} else {
|
||||
close_active_sessions(((struct dmmap_ssh *)data)->config_section);
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "enable", "0");
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->dmmap_section, "activationdate", "");
|
||||
close_active_sessions(((struct dm_data *)data)->config_section);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enable", "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "activationdate", "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -604,19 +548,19 @@ static int set_ssh_server_enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_ssh_server_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return bbf_get_alias(ctx, ((struct dmmap_ssh *)data)->dmmap_section, "server_alias", instance, value);
|
||||
return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "server_alias", instance, value);
|
||||
}
|
||||
|
||||
static int set_ssh_server_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
return bbf_set_alias(ctx, ((struct dmmap_ssh *)data)->dmmap_section, "server_alias", instance, value);
|
||||
return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "server_alias", instance, value);
|
||||
}
|
||||
|
||||
static int get_ssh_server_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct dmmap_ssh *)data)->config_section, "Interface", &linker);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "Interface", &linker);
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -638,7 +582,7 @@ static int set_ssh_server_interface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "Interface", reference.value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "Interface", reference.value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -646,7 +590,7 @@ static int set_ssh_server_interface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
static int get_ssh_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "Port", "22");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "Port", "22");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -658,7 +602,7 @@ static int set_ssh_server_port(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "Port", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "Port", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -666,7 +610,7 @@ static int set_ssh_server_port(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
|
||||
static int get_ssh_server_idle(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "IdleTimeout", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "IdleTimeout", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -678,7 +622,7 @@ static int set_ssh_server_idle(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "IdleTimeout", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "IdleTimeout", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -686,7 +630,7 @@ static int set_ssh_server_idle(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
|
||||
static int get_ssh_server_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "SSHKeepAlive", "300");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "SSHKeepAlive", "300");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -698,7 +642,7 @@ static int set_ssh_server_keepalive(char *refparam, struct dmctx *ctx, void *dat
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "SSHKeepAlive", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "SSHKeepAlive", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -706,7 +650,7 @@ static int set_ssh_server_keepalive(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
static int get_ssh_server_rootlogin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "RootLogin", "1");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "RootLogin", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -721,7 +665,7 @@ static int set_ssh_server_rootlogin(char *refparam, struct dmctx *ctx, void *dat
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "RootLogin", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "RootLogin", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -729,7 +673,7 @@ static int set_ssh_server_rootlogin(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
static int get_ssh_server_passwordlogin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "PasswordAuth", "1");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "PasswordAuth", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -744,7 +688,7 @@ static int set_ssh_server_passwordlogin(char *refparam, struct dmctx *ctx, void
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "PasswordAuth", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "PasswordAuth", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -752,7 +696,7 @@ static int set_ssh_server_passwordlogin(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int get_ssh_server_rootpasswordlogin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "RootPasswordAuth", "1");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "RootPasswordAuth", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -767,7 +711,7 @@ static int set_ssh_server_rootpasswordlogin(char *refparam, struct dmctx *ctx, v
|
|||
break;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "RootPasswordAuth", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "RootPasswordAuth", b ? "1" : "0");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -775,7 +719,7 @@ static int set_ssh_server_rootpasswordlogin(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
static int get_ssh_server_maxauthtries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_ssh *)data)->config_section, "MaxAuthTries", "3");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "MaxAuthTries", "3");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -787,7 +731,7 @@ static int set_ssh_server_maxauthtries(char *refparam, struct dmctx *ctx, void *
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_ssh *)data)->config_section, "MaxAuthTries", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "MaxAuthTries", value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -795,14 +739,14 @@ static int set_ssh_server_maxauthtries(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
static int get_ssh_server_activationdate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_ssh *)data)->dmmap_section, "activationdate", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "activationdate", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_ssh_server_pid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
bool b;
|
||||
struct uci_section *s = ((struct dmmap_ssh *)data)->config_section;
|
||||
struct uci_section *s = ((struct dm_data *)data)->config_section;
|
||||
char *en = dmuci_get_value_by_section_fallback_def(s, "enable", "1");
|
||||
|
||||
*value = "0";
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2
libbbfdm/dmtree/vendor/iopsys/wifi.c
vendored
2
libbbfdm/dmtree/vendor/iopsys/wifi.c
vendored
|
|
@ -15,7 +15,7 @@ static int get_multi_ap_mode(char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
char *multi_ap = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "multi_ap", &multi_ap);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "multi_ap", &multi_ap);
|
||||
|
||||
if (DM_STRCMP(multi_ap, "1") == 0)
|
||||
*value = "Backhaul";
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ static void test_bbf_api_json(void **state)
|
|||
char *json_value = NULL;
|
||||
int idx = 0;
|
||||
|
||||
dmubus_call("wifi.ap.test2", "status", UBUS_ARGS{0}, 0, &wifi_status);
|
||||
dmubus_call("wifi.ap.test2_0", "status", UBUS_ARGS{0}, 0, &wifi_status);
|
||||
assert_non_null(wifi_status);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"Device.X_IOPSYS_EU_Dropbear.{i}.": {
|
||||
"json_plugin_version": 2,
|
||||
"Device.{BBF_VENDOR_PREFIX}Dropbear.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
|
|
@ -7,7 +8,8 @@
|
|||
],
|
||||
"access": true,
|
||||
"array": true,
|
||||
"mapping": {
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
|
|
@ -16,7 +18,8 @@
|
|||
},
|
||||
"dmmapfile": "dmmap_dropbear"
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
"Alias": {
|
||||
"type": "string",
|
||||
"protocols": [
|
||||
|
|
@ -27,18 +30,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dmmap_dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "dropbearalias"
|
||||
},
|
||||
"path":"/etc/bbfdm"
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "alias"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -52,17 +46,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "PasswordAuth"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "PasswordAuth"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -76,17 +62,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "RootPasswordAuth"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "RootPasswordAuth"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -100,17 +78,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "Port"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "Port"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -124,17 +94,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "RootLogin"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "RootLogin"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -148,17 +110,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "GatewayPorts"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "GatewayPorts"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -172,17 +126,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "Interface"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "Interface"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -196,17 +142,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "rsakeyfile"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "rsakeyfile"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -220,17 +158,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "dsskeyfile"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "dsskeyfile"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -244,17 +174,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "SSHKeepAlive"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "SSHKeepAlive"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -268,17 +190,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "IdleTimeout"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "IdleTimeout"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -292,17 +206,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "verbose"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "verbose"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -316,17 +222,9 @@
|
|||
"write": true,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "dropbear",
|
||||
"section": {
|
||||
"type": "dropbear",
|
||||
"index": "@i-1"
|
||||
},
|
||||
"option": {
|
||||
"name": "BannerFile"
|
||||
}
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "uci_sec",
|
||||
"key": "BannerFile"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"Device.X_IOPSYS_EU_TEST.": {
|
||||
"json_plugin_version": 2,
|
||||
"Device.{BBF_VENDOR_PREFIX}TEST.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
|
|
@ -7,7 +8,8 @@
|
|||
],
|
||||
"access": true,
|
||||
"array": true,
|
||||
"mapping": {
|
||||
"mapping": [
|
||||
{
|
||||
"type": "uci",
|
||||
"uci": {
|
||||
"file": "cwmp",
|
||||
|
|
@ -16,7 +18,8 @@
|
|||
},
|
||||
"dmmapfile": "dmmap_cwmp"
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
"Enable": {
|
||||
"type": "boolean",
|
||||
"read": true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,34 @@
|
|||
{
|
||||
"Device.WiFi.X_IOPSYS_EU_Radio.{i}.": {
|
||||
"json_plugin_version": 2,
|
||||
"Device.WiFi.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"access": false,
|
||||
"array": false,
|
||||
"{BBF_VENDOR_PREFIX}RadioNumberOfEntries": {
|
||||
"type": "unsignedInt",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
"usp"
|
||||
],
|
||||
"read": true,
|
||||
"write": false,
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "wifi",
|
||||
"method": "status",
|
||||
"args": {},
|
||||
"key": "radios.@Count"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.WiFi.{BBF_VENDOR_PREFIX}Radio.{i}.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
|
|
@ -7,7 +36,8 @@
|
|||
],
|
||||
"access": false,
|
||||
"array": true,
|
||||
"mapping": {
|
||||
"mapping": [
|
||||
{
|
||||
"type": "ubus",
|
||||
"ubus": {
|
||||
"object": "wifi",
|
||||
|
|
@ -15,7 +45,8 @@
|
|||
"args": {},
|
||||
"key": "radios"
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
"Noise": {
|
||||
"type": "int",
|
||||
"read": true,
|
||||
|
|
@ -26,13 +57,9 @@
|
|||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type" : "ubus",
|
||||
"ubus" : {
|
||||
"object" : "wifi",
|
||||
"method" : "status",
|
||||
"args" : {},
|
||||
"key" : "radios[@i-1].noise"
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "noise"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -46,17 +73,13 @@
|
|||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type" : "ubus",
|
||||
"ubus" : {
|
||||
"object" : "wifi",
|
||||
"method" : "status",
|
||||
"args" : {},
|
||||
"key" : "radios[@i-1].band"
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "band"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Device.WiFi.X_IOPSYS_EU_Radio.{i}.Stats.": {
|
||||
"Device.WiFi.{BBF_VENDOR_PREFIX}Radio.{i}.Stats.": {
|
||||
"type": "object",
|
||||
"protocols": [
|
||||
"cwmp",
|
||||
|
|
@ -74,13 +97,9 @@
|
|||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type" : "ubus",
|
||||
"ubus" : {
|
||||
"object" : "wifi",
|
||||
"method" : "status",
|
||||
"args" : {},
|
||||
"key" : "radios[@i-1].stats.tx_bytes"
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "stats.tx_bytes"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -94,16 +113,13 @@
|
|||
],
|
||||
"mapping": [
|
||||
{
|
||||
"type" : "ubus",
|
||||
"ubus" : {
|
||||
"object" : "wifi",
|
||||
"method" : "status",
|
||||
"args" : {},
|
||||
"key" : "radios[@i-1].stats.rx_packets"
|
||||
}
|
||||
"data": "@Parent",
|
||||
"type": "json",
|
||||
"key": "stats.rx_packets"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
config controller 'controller'
|
||||
option enabled '1'
|
||||
option registrar '5 2'
|
||||
option registrar '2 5'
|
||||
option debug '0'
|
||||
option enable_sta_steer '0'
|
||||
option enable_bsta_steer '0'
|
||||
|
|
@ -9,16 +9,29 @@ config controller 'controller'
|
|||
option primary_vid '1'
|
||||
option primary_pcp '0'
|
||||
|
||||
config interface 'lan'
|
||||
|
||||
config ap
|
||||
option band '2'
|
||||
option ssid 'iopsysWrt-44D43771B810'
|
||||
option encryption 'MPUEO3L7WHJ45P'
|
||||
option encryption 'sae-mixed'
|
||||
option key 'PCTQ44TNVKK5NU'
|
||||
option vid '1'
|
||||
option type 'fronthaul'
|
||||
option network 'lan'
|
||||
|
||||
config ap
|
||||
option band '5'
|
||||
option ssid 'iopsysWrt-44D43771B810'
|
||||
option encryption 'sae-mixed'
|
||||
option key 'PCTQ44TNVKK5NU'
|
||||
option vid '1'
|
||||
option type 'fronthaul'
|
||||
|
||||
config ap
|
||||
option band '2'
|
||||
option ssid 'MAP-44D43771B810-BH-5GHz'
|
||||
option encryption 'sae'
|
||||
option type 'backhaul'
|
||||
option vid '1'
|
||||
option key '029be741b7ff7b4caf9b1b3c48c56030fed877c22f5031bc9cf0132d1672c2c'
|
||||
|
||||
config ap
|
||||
option band '5'
|
||||
|
|
@ -26,7 +39,6 @@ config ap
|
|||
option encryption 'sae'
|
||||
option type 'backhaul'
|
||||
option vid '1'
|
||||
option network 'lan'
|
||||
option key '029be741b7ff7b4caf9b1b3c48c56030fed877c22f5031bc9cf0132d1672c2c'
|
||||
|
||||
config node
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@
|
|||
**************************************************************/
|
||||
int browse_dropbear_instance(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL;
|
||||
struct dmmap_dup *p = NULL;
|
||||
struct dm_data *curr_data = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
char *inst = NULL;
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("dropbear", "dropbear", "dmmap_dropbear", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
list_for_each_entry(curr_data, &dup_list, list) {
|
||||
|
||||
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "dropbearinstance", "dropbearalias");
|
||||
inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "dropbearinstance", "dropbearalias");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -58,8 +58,8 @@ int delete_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("dropbear", "dropbear", stmp, s) {
|
||||
|
|
@ -80,7 +80,7 @@ int delete_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char
|
|||
**************************************************************/
|
||||
static int get_x_test_com_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *res = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "PasswordAuth", "1");
|
||||
char *res = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "PasswordAuth", "1");
|
||||
*value = ((DM_STRCMP(res, "on") == 0) || *res == '1') ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ static int set_x_test_com_dropbear_password_auth(char *refparam, struct dmctx *c
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "PasswordAuth", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "PasswordAuth", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -104,7 +104,7 @@ static int set_x_test_com_dropbear_password_auth(char *refparam, struct dmctx *c
|
|||
|
||||
static int get_x_test_com_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *res = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "RootPasswordAuth", "1");
|
||||
char *res = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "RootPasswordAuth", "1");
|
||||
*value = ((DM_STRCMP(res, "on") == 0) || *res == '1') ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ static int set_x_test_com_dropbear_root_password_auth(char *refparam, struct dmc
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "RootPasswordAuth", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "RootPasswordAuth", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -128,7 +128,7 @@ static int set_x_test_com_dropbear_root_password_auth(char *refparam, struct dmc
|
|||
|
||||
static int get_x_test_com_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "Port", "22");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "Port", "22");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ static int set_x_test_com_dropbear_port(char *refparam, struct dmctx *ctx, void
|
|||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "Port", value);
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "Port", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -147,7 +147,7 @@ static int set_x_test_com_dropbear_port(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int get_x_test_com_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "RootLogin", value);
|
||||
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "RootLogin", value);
|
||||
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1' )
|
||||
*value = "1";
|
||||
else
|
||||
|
|
@ -166,7 +166,7 @@ static int set_x_test_com_dropbear_root_login(char *refparam, struct dmctx *ctx,
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "RootLogin", b ? "1" : "0");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "RootLogin", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -174,7 +174,7 @@ static int set_x_test_com_dropbear_root_login(char *refparam, struct dmctx *ctx,
|
|||
|
||||
static int get_x_test_com_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "GatewayPorts", "0");
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "GatewayPorts", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ static int set_x_test_com_dropbear_gateway_ports(char *refparam, struct dmctx *c
|
|||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "GatewayPorts", b ? "1" : "");
|
||||
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "GatewayPorts", b ? "1" : "");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue