diff --git a/dmdynamicjson.c b/dmdynamicjson.c index 156243df..fc04bc1e 100644 --- a/dmdynamicjson.c +++ b/dmdynamicjson.c @@ -1296,6 +1296,19 @@ static void uci_set_value(json_object *mapping_obj, int json_version, char *refp char uci_type[32] = {0}; snprintf(uci_type, sizeof(uci_type), "@%s[%ld]", json_object_get_string(type), instance ? DM_STRTOL(instance)-1 : 0); + + if (strcmp(opt_temp, "@Name") == 0) { + struct uci_section *dmmap_section = NULL; + char buf[64] = {0}; + + 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); + dmuci_set_value_by_section(dmmap_section, "section_name", value); + + dmuci_rename_section(json_object_get_string(file), uci_type, value); + return; + } + if (option) { if (linker_jobj) adm_entry_get_linker_value(ctx, value, &linker); diff --git a/libbbf_api/dmuci.h b/libbbf_api/dmuci.h index 2db3a99d..5c551816 100644 --- a/libbbf_api/dmuci.h +++ b/libbbf_api/dmuci.h @@ -338,6 +338,7 @@ int dmuci_add_list_value(char *package, char *section, char *option, char *value int dmuci_del_list_value(char *package, char *section, char *option, char *value); int dmuci_add_section(char *package, char *stype, struct uci_section **s); int dmuci_delete(char *package, char *section, char *option, char *value); +int dmuci_rename_section(char *package, char *section, char *value); int dmuci_get_value_by_section_string(struct uci_section *s, char *option, char **value); char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, char *option, char *default_value); int dmuci_get_value_by_section_list(struct uci_section *s, char *option, struct uci_list **value); diff --git a/test/files/etc/bbfdm/json/urlfilter.json b/test/files/etc/bbfdm/json/urlfilter.json index f95d96b7..76833b49 100644 --- a/test/files/etc/bbfdm/json/urlfilter.json +++ b/test/files/etc/bbfdm/json/urlfilter.json @@ -128,14 +128,14 @@ "section": { "type": "profile" }, - "dmmapfile": "dmmap_urlfilter_profile" + "dmmapfile": "dmmap_urlfilter" } } ], "Name": { "type": "string", "read": true, - "write": false, + "write": true, "version": "2.14", "protocols": [ "cwmp", @@ -155,7 +155,7 @@ "section": { "type": "profile" }, - "list": { + "option": { "name": "@Name" } } @@ -258,7 +258,7 @@ "section": { "type": "filter" }, - "dmmapfile": "dmmap_urlfilter_filter" + "dmmapfile": "dmmap_urlfilter" } } ],