JSON Plugin: Added support for extending/overwriting/excluding in version 2

This commit is contained in:
Amin Ben Romdhane 2024-02-21 14:13:05 +01:00
parent 84c01a5698
commit c26fa5d295
9 changed files with 438 additions and 333 deletions

View file

@ -53,8 +53,8 @@ In the [test/vendor_test/](../../test/vendor_test) directory, you'll find an exa
- Add support for [Device.Firewall.Chain.{i}.Rule.{i}.X_TEST_COM_ICMPType](../../test/vendor_test/firewall.c#L178) parameter
- using JSON Plugin:
- Add support for [Device.PD2.{i}.](../../test/vendor_test/test_extend.json#L59) object
- Add support for [Device.WiFi.X_IOPSYS_EU_TEST1](../../test/vendor_test/test_extend.json#L10) parameter
- Add support for [Device.PD2.{i}.](../../test/vendor_test/test_extend.json#L60) object
- Add support for [Device.WiFi.X_IOPSYS_EU_TEST1](../../test/vendor_test/test_extend.json#L11) parameter
### 2. Overwrite Data Model
@ -63,8 +63,8 @@ In the [test/vendor_test/](../../test/vendor_test) directory, you'll find an exa
- Overwrite [Device.DeviceInfo.Manufacturer](../../test/vendor_test/deviceinfo.c#L29) parameter in the core tree
- using JSON Plugin:
- Overwrite [Device.DeviceInfo.Processor.](../../test/vendor_test/test_overwrite.json#L10) object in the core tree
- Overwrite [Device.DeviceInfo.ProcessorNumberOfEntries](../../test/vendor_test/test_overwrite.json#L29) parameter in the core tree
- Overwrite [Device.DeviceInfo.Processor.](../../test/vendor_test/test_overwrite.json#L11) object in the core tree
- Overwrite [Device.DeviceInfo.ProcessorNumberOfEntries](../../test/vendor_test/test_overwrite.json#L30) parameter in the core tree
### 3. Exclude Data Model
@ -73,8 +73,8 @@ In the [test/vendor_test/](../../test/vendor_test) directory, you'll find an exa
- Exclude [Device.Ethernet.RMONStats.{i}.Packets1024to1518Bytes](../../test/vendor_test/extension.c#L37) parameter from the core tree
- using JSON Plugin:
- Exclude [Device.X_IOPSYS_EU_IGMP.](../../test/vendor_test/test_exclude.json#L27) object from the core tree
- Exclude [Device.InterfaceStackNumberOfEntries](../../test/vendor_test/test_exclude.json#L51) parameter from the core tree
- Exclude [Device.X_IOPSYS_EU_IGMP.](../../test/vendor_test/test_exclude.json#L28) object from the core tree
- Exclude [Device.InterfaceStackNumberOfEntries](../../test/vendor_test/test_exclude.json#L52) parameter from the core tree
> Note1: The `libbbfdm` vendor list can support multiple vendors, separated by commas.

View file

@ -34,6 +34,22 @@ echo "Validate X_IOPSYS_EU_WiFi JSON Plugin"
./tools/validate_json_plugin.py test/files/etc/bbfdm/plugins/X_IOPSYS_EU_WiFi.json
check_ret $?
echo "Validate UCI_TEST_V1 JSON Plugin"
./tools/validate_json_plugin.py test/files/etc/bbfdm/plugins/X_IOPSYS_EU_JSON_TEST_V1.json
check_ret $?
echo "Validate test extend Plugin"
./tools/validate_json_plugin.py test/vendor_test/test_extend.json
check_ret $?
echo "Validate test exclude Plugin"
./tools/validate_json_plugin.py test/vendor_test/test_exclude.json
check_ret $?
echo "Validate test overwrite Plugin"
./tools/validate_json_plugin.py test/vendor_test/test_overwrite.json
check_ret $?
echo "Validate TR-181 JSON Plugin after generating from XML"
json_path=$(./tools/convert_dm_xml_to_json.py test/tools/tr-181-2-*-cwmp-full.xml test/tools/tr-181-2-*-usp-full.xml Device.)
./tools/validate_json_plugin.py $json_path

View file

@ -45,8 +45,9 @@ struct dm_json_obj {
};
enum json_plugin_version {
JSON_VERSION_0,
JSON_VERSION_1
JSON_VERSION_0 = 1,
JSON_VERSION_1 = 1 << 1,
JSON_VERSION_2 = 1 << 2
};
static void save_json_data(struct list_head *json_list, char *name, json_object *data, int json_version,
@ -111,6 +112,29 @@ static void free_loaded_json_files(struct list_head *json_list)
}
}
static int get_json_plugin_version(json_object *json_obj)
{
if (json_obj == NULL || json_object_get_type(json_obj) != json_type_int)
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
switch (version) {
case 1:
json_plugin_version |= JSON_VERSION_1;
break;
case 2:
json_plugin_version |= JSON_VERSION_2;
json_plugin_version |= JSON_VERSION_1; // Set JSON_VERSION_1 for version 2
break;
default:
break;
}
return json_plugin_version;
}
void json_plugin_find_prefix_obj(const char *full_obj, char *prefix_obj, size_t len)
{
int last_occurent = 0, occur = 0;
@ -319,7 +343,7 @@ static void resolve_all_symbols(struct dmctx *ctx, void *data, char *instance, c
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);
else if (strcmp(pch, (json_version == JSON_VERSION_1) ? "@index" : "@i-1") == 0)
else if (strcmp(pch, ((json_version & JSON_VERSION_1)) ? "@index" : "@i-1") == 0)
pos += snprintf(&new_key[pos], key_len - pos, "%ld.", instance ? DM_STRTOL(instance)-1 : 1);
else if (strstr(pch, "@index-")) {
char *p = strchr(pch, '-');
@ -399,7 +423,7 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
}
}
if (json_version == JSON_VERSION_1 && mapping_obj && json_object_get_type(mapping_obj) == json_type_array) {
if ((json_version & JSON_VERSION_1) && mapping_obj && json_object_get_type(mapping_obj) == json_type_array) {
mapping_0 = json_object_array_get_idx(mapping_obj, 0);
json_object_object_get_ex(mapping_0, "type", &type);
} else {
@ -416,7 +440,7 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list);
json_object_object_get_ex((mapping_0 && json_version == JSON_VERSION_1) ? mapping_0 : mapping_obj, "uci", &uci_obj);
json_object_object_get_ex((mapping_0 && (json_version & JSON_VERSION_1)) ? mapping_0 : mapping_obj, "uci", &uci_obj);
json_object_object_get_ex(uci_obj, "file", &file);
json_object_object_get_ex(uci_obj, "section", &section);
json_object_object_get_ex(section, "type", &section_type);
@ -457,7 +481,7 @@ static int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
int nbr_instances = get_number_of_instances(parent_node->current_object);
json_object_object_get_ex((mapping_0 && json_version == JSON_VERSION_1) ? mapping_0 : mapping_obj, "ubus", &ubus_obj);
json_object_object_get_ex((mapping_0 && (json_version & JSON_VERSION_1)) ? mapping_0 : mapping_obj, "ubus", &ubus_obj);
json_object_object_get_ex(ubus_obj, "object", &object);
json_object_object_get_ex(ubus_obj, "method", &method);
json_object_object_get_ex(ubus_obj, "args", &args_obj);
@ -511,7 +535,7 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
}
}
if (json_version == JSON_VERSION_1 && mapping_obj && json_object_get_type(mapping_obj) == json_type_array) {
if ((json_version & JSON_VERSION_1) && mapping_obj && json_object_get_type(mapping_obj) == json_type_array) {
mapping_0 = json_object_array_get_idx(mapping_obj, 0);
json_object_object_get_ex(mapping_0, "type", &obj_type);
} else {
@ -525,7 +549,7 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
struct json_object *section_type = NULL;
struct json_object *dmmap_file = NULL;
json_object_object_get_ex((mapping_0 && json_version == JSON_VERSION_1) ? mapping_0 : mapping_obj, "uci", &uci_obj);
json_object_object_get_ex((mapping_0 && (json_version & JSON_VERSION_1)) ? mapping_0 : mapping_obj, "uci", &uci_obj);
json_object_object_get_ex(uci_obj, "file", &file);
json_object_object_get_ex(uci_obj, "section", &section);
json_object_object_get_ex(section, "type", &section_type);
@ -585,7 +609,7 @@ static int delete_obj(char *refparam, struct dmctx *ctx, void *data, char *insta
}
}
if (json_version == JSON_VERSION_1 && mapping_obj && json_object_get_type(mapping_obj) == json_type_array) {
if ((json_version & JSON_VERSION_1) && mapping_obj && json_object_get_type(mapping_obj) == json_type_array) {
mapping_0 = json_object_array_get_idx(mapping_obj, 0);
json_object_object_get_ex(mapping_0, "type", &type_obj);
} else {
@ -599,7 +623,7 @@ static int delete_obj(char *refparam, struct dmctx *ctx, void *data, char *insta
struct json_object *section_type = NULL;
struct json_object *dmmap_file = NULL;
json_object_object_get_ex((mapping_0 && json_version == JSON_VERSION_1) ? mapping_0 : mapping_obj, "uci", &uci_obj);
json_object_object_get_ex((mapping_0 && (json_version & JSON_VERSION_1)) ? mapping_0 : mapping_obj, "uci", &uci_obj);
json_object_object_get_ex(uci_obj, "file", &file);
json_object_object_get_ex(uci_obj, "section", &section);
json_object_object_get_ex(section, "type", &section_type);
@ -697,7 +721,7 @@ static char *uci_get_value(json_object *mapping_obj, int json_version, char *ref
if (file && type && opt_temp && strstr(refparam, "NumberOfEntries")) {
if (strcmp(opt_temp, "@Count") != 0 && json_version == JSON_VERSION_1)
if (strcmp(opt_temp, "@Count") != 0 && (json_version & JSON_VERSION_1))
goto end;
struct uci_section *s = NULL;
@ -814,16 +838,16 @@ static char *ubus_get_value(json_object *mapping_obj, int json_version, char *re
DM_STRNCPY(key_buf, json_object_get_string(key), sizeof(key_buf));
if (json_version == JSON_VERSION_1) {
if ((json_version & JSON_VERSION_1)) {
char *str = NULL;
if ((str = strstr(key_buf, ".@Count")) != NULL)
*str = 0;
}
char *is_array = strstr(key_buf, (json_version == JSON_VERSION_1) ? "[@index]" : "[@i-1]");
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]");
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 */
@ -919,7 +943,7 @@ static char *get_value_from_mapping(json_object *param_obj, int json_version, ch
json_object_object_get_ex(mapping, "rpc", &rpc);
json_object_object_get_ex(mapping, "type", &type);
if (rpc && json_version == JSON_VERSION_1 && strcmp(json_object_get_string(rpc), "get") != 0)
if (rpc && (json_version & JSON_VERSION_1) && strcmp(json_object_get_string(rpc), "get") != 0)
continue;
if (type && strcmp(json_object_get_string(type), "uci") == 0) {
@ -928,10 +952,10 @@ static char *get_value_from_mapping(json_object *param_obj, int json_version, ch
} else if (type && strcmp(json_object_get_string(type), "ubus") == 0) {
val = ubus_get_value(mapping, json_version, refparam, ctx, data, instance);
break;
} else if (type && strcmp(json_object_get_string(type), "uci_sec") == 0 && json_version == JSON_VERSION_1) {
} else if (type && strcmp(json_object_get_string(type), "uci_sec") == 0 && (json_version & JSON_VERSION_1)) {
val = uci_v1_get_value(mapping, refparam, ctx, data, instance);
break;
} else if (type && strcmp(json_object_get_string(type), "json") == 0 && json_version == JSON_VERSION_1) {
} else if (type && strcmp(json_object_get_string(type), "json") == 0 && (json_version & JSON_VERSION_1)) {
val = ubus_v1_get_value(mapping, refparam, ctx, data, instance);
break;
} else
@ -1498,14 +1522,14 @@ static int set_value_from_mapping(json_object *param_obj, int json_version, char
json_object_object_get_ex(mapping, "rpc", &rpc);
json_object_object_get_ex(mapping, "type", &type);
if (rpc && json_version == JSON_VERSION_1 && strcmp(json_object_get_string(rpc), "set") != 0)
if (rpc && (json_version & JSON_VERSION_1) && strcmp(json_object_get_string(rpc), "set") != 0)
continue;
if (type && strcmp(json_object_get_string(type), "uci") == 0)
res = uci_set_value(mapping, json_version, refparam, ctx, data, instance, value);
else if (type && strcmp(json_object_get_string(type), "ubus") == 0)
res = ubus_set_value(mapping, json_version, refparam, ctx, data, instance, value);
else if (type && strcmp(json_object_get_string(type), "uci_sec") == 0 && json_version == JSON_VERSION_1)
else if (type && strcmp(json_object_get_string(type), "uci_sec") == 0 && (json_version & JSON_VERSION_1))
res = uci_v1_set_value(mapping, json_version, refparam, ctx, data, instance, value);
else
res = -1;
@ -1859,7 +1883,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_array && json_version == JSON_VERSION_1))) {
(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);
}
@ -1901,6 +1925,12 @@ static void create_parse_obj(DMOBJ *dm_entryobj, char *obj_path, json_object *jo
static void create_parse_param(DMOBJ *dm_entryobj, char *obj_path, char *param, json_object *jobj, int json_plugin_version)
{
char full_obj[MAX_DM_LENGTH] = {0};
replace_str(obj_path, ".{i}.", ".", full_obj, sizeof(full_obj));
if (strlen(full_obj) == 0)
return;
if (dm_entryobj->dynamicleaf == NULL) {
dm_entryobj->dynamicleaf = calloc(__INDX_DYNAMIC_MAX, sizeof(struct dm_dynamic_obj));
dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].idx_type = INDX_JSON_MOUNT;
@ -1914,12 +1944,12 @@ static void create_parse_param(DMOBJ *dm_entryobj, char *obj_path, char *param,
if (dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0] == NULL) {
dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0] = dm_dynamic_calloc(&json_memhead, 2, sizeof(struct dm_leaf_s));
parse_param(obj_path, param, jobj, dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0], 0, json_plugin_version, &json_list);
parse_param(full_obj, param, jobj, dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0], 0, json_plugin_version, &json_list);
} else {
int idx = get_entry_leaf_idx(dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0]);
dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0] = dm_dynamic_realloc(&json_memhead, dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0], (idx + 2) * sizeof(struct dm_leaf_s));
memset(dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0] + (idx + 1), 0, sizeof(struct dm_leaf_s));
parse_param(obj_path, param, jobj, dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0], idx, json_plugin_version, &json_list);
parse_param(full_obj, param, jobj, dm_entryobj->dynamicleaf[INDX_JSON_MOUNT].nextleaf[0], idx, json_plugin_version, &json_list);
}
}
@ -1935,9 +1965,10 @@ int load_json_plugins(DMOBJ *entryobj, const char *plugin_path)
json_object_object_foreach(json, key, jobj) {
char obj_path[MAX_DM_LENGTH] = {0};
DMOBJ *dm_entryobj = NULL;
if (strcmp(key, "json_plugin_version") == 0) {
json_plugin_version = json_object_get_int(jobj);
json_plugin_version = get_json_plugin_version(jobj);
continue;
}
@ -1952,41 +1983,46 @@ int load_json_plugins(DMOBJ *entryobj, const char *plugin_path)
continue;
}
DMOBJ *dm_entryobj = find_entry_obj(entryobj, obj_path);
if (dm_entryobj) { // The object is already in the core tree, should check the next level
if (json_plugin_version & JSON_VERSION_2) {
dm_entryobj = find_entry_obj(entryobj, obj_path);
if (dm_entryobj) { // The object is already in the core tree, should check the next level
json_object_object_foreach(jobj, opt, json_obj) {
json_object_object_foreach(jobj, opt, json_obj) {
if (json_object_get_type(json_obj) == json_type_object && is_obj(opt, json_obj)) {
char curr_obj[128] = {0};
if (json_object_get_type(json_obj) == json_type_object && is_obj(opt, json_obj)) {
char curr_obj[128] = {0};
json_plugin_find_current_obj(opt, curr_obj, sizeof(curr_obj));
json_plugin_find_current_obj(opt, curr_obj, sizeof(curr_obj));
disable_entry_obj(dm_entryobj, curr_obj, obj_path, plugin_path);
create_parse_obj(dm_entryobj, opt, json_obj, json_plugin_version);
disable_entry_obj(dm_entryobj, curr_obj, obj_path, plugin_path);
create_parse_obj(dm_entryobj, opt, json_obj, json_plugin_version);
}
if (json_object_get_type(json_obj) == json_type_object && !is_obj(opt, json_obj) && strcmp(opt, "mapping") != 0) {
disable_entry_leaf(dm_entryobj, opt, obj_path, plugin_path);
create_parse_param(dm_entryobj, obj_path, opt, json_obj, json_plugin_version);
}
}
if (json_object_get_type(json_obj) == json_type_object && !is_obj(opt, json_obj) && strcmp(opt, "mapping") != 0) {
disable_entry_leaf(dm_entryobj, opt, obj_path, plugin_path);
create_parse_param(dm_entryobj, obj_path, opt, json_obj, json_plugin_version);
}
}
} else { // It's a new object
char obj_prefix[MAX_DM_LENGTH] = {0};
json_plugin_find_prefix_obj(obj_path, obj_prefix, MAX_DM_LENGTH);
if (strlen(obj_prefix) == 0) {
BBF_DEBUG("ERROR: Obj prefix is empty for (%s) Object", obj_path);
continue;
}
dm_entryobj = find_entry_obj(entryobj, obj_prefix);
if (!dm_entryobj) {
BBF_DEBUG("ERROR: entry obj doesn't exist for (%s) Object", obj_prefix);
continue;
}
create_parse_obj(dm_entryobj, obj_path, jobj, json_plugin_version);
}
char obj_prefix[MAX_DM_LENGTH] = {0};
json_plugin_find_prefix_obj(obj_path, obj_prefix, MAX_DM_LENGTH);
if (strlen(obj_prefix) == 0) {
BBF_DEBUG("ERROR: Obj prefix is empty for (%s) Object", obj_path);
continue;
}
dm_entryobj = find_entry_obj(entryobj, obj_prefix);
if (!dm_entryobj) {
BBF_DEBUG("ERROR: entry obj doesn't exist for (%s) Object", obj_prefix);
continue;
}
create_parse_obj(dm_entryobj, obj_path, jobj, json_plugin_version);
}
save_loaded_json_files(&loaded_json_files, json);

View file

@ -0,0 +1,44 @@
{
"json_plugin_version": 2,
"Device.WiFi.AccessPoint.{i}.Security.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"{BBF_VENDOR_PREFIX}KeyPassphrase": {
"type": "string",
"read": true,
"write": false,
"protocols": [
"usp"
],
"datatype": "string",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "key"
}
]
},
"{BBF_VENDOR_PREFIX}SAEPassphrase": {
"type": "string",
"read": true,
"write": false,
"protocols": [
"usp"
],
"datatype": "string",
"mapping": [
{
"data": "@Parent",
"type": "uci_sec",
"key": "key"
}
]
}
}
}

View file

@ -1,3 +1,8 @@
config globals globals
option test1_enable '1'
option test2_enable '1'
config wifi-device 'test1'
option type 'mac80211'
option channel '36'
@ -13,6 +18,7 @@ config wifi-iface 'no_mp_test1'
option mode 'ap'
option ifname 'test1_0'
option encryption 'psk2'
option key '533b31744130c8'
option wps_pushbutton '1'
option ieee80211k '1'
option ieee80211v '1'
@ -26,6 +32,7 @@ config wifi-iface 'default_test1'
option ifname 'test1_1'
option ssid 'MAP-44D43771B810-BH-5GHz'
option encryption 'psk2'
option key '4fhQeJxA3ywRqYaT'
option wps_pushbutton '1'
option ieee80211k '1'
option ieee80211v '1'

View file

@ -1,60 +1,61 @@
{
"Device.DeviceInfo.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Device.DeviceInfo.ProcessStatus.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
"json_plugin_version": 2,
"Device.DeviceInfo.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Device.DeviceInfo.ProcessStatus.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
}
},
"Device.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Device.{BBF_VENDOR_PREFIX}IGMP.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
},
"Device.{BBF_VENDOR_PREFIX}MLD.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
},
"Device.InterfaceStack.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
},
"InterfaceStackNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"none"
],
"read": true,
"write": false
}
}
},
"Device.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Device.{BBF_VENDOR_PREFIX}IGMP.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
},
"Device.{BBF_VENDOR_PREFIX}MLD.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
},
"Device.InterfaceStack.": {
"type": "object",
"protocols": [
"none"
],
"access": false,
"array": false
},
"InterfaceStackNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"none"
],
"read": true,
"write": false
}
}
}
}

View file

@ -1,195 +1,193 @@
{
"Device.WiFi.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"{BBF_VENDOR_PREFIX}TEST1": {
"type": "boolean",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": true,
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "wireless",
"section": {
"name": "config"
},
"option": {
"name": "test1_enable"
}
}
}
]
},
"{BBF_VENDOR_PREFIX}TEST2": {
"type": "boolean",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": true,
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "wireless",
"section": {
"name": "config"
},
"option": {
"name": "test1_enable"
}
}
}
]
}
},
"Device.PD2.{i}.": {
"type": "object",
"version": "2.14",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": true,
"mapping": {
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
},
"MiniHubNumberOfEntries": {
"type": "unsignedInt",
"version": "2.14",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
}
]
},
"MHubNumberOfEntries": {
"type": "unsignedInt",
"version": "2.14",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "numofdevices"
}
}
]
},
"Device.PD2.{i}.MiniHub.{i}.": {
"type": "object",
"version": "2.14",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": true,
"mapping": {
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
},
"Device.PD2.{i}.MiniHub.{i}.DeviceInfo.": {
"json_plugin_version": 2,
"Device.WiFi.": {
"type": "object",
"version": "2.14",
"protocols": [
"cwmp",
"usp"
"cwmp",
"usp"
],
"access": false,
"array": false,
"Description": {
"type": "string",
"version": "2.14",
"read": true,
"write": false,
"protocols": [
"{BBF_VENDOR_PREFIX}TEST1": {
"type": "boolean",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": true,
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "wireless",
"section": {
"name": "globals"
},
"option": {
"name": "test1_enable"
}
}
}
]
},
"{BBF_VENDOR_PREFIX}TEST2": {
"type": "boolean",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": true,
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "wireless",
"section": {
"name": "globals"
},
"option": {
"name": "test2_enable"
}
}
}
]
}
},
"Device.PD2.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"mapping": [
],
"access": false,
"array": true,
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "get",
"args": {
"path": "Device.ProxiedDevice.{i}.MiniHub.{i}.DeviceInfo.Description"
},
"key": "Description"
}
}
]
},
"Reboot()": {
"type": "command",
"async": true,
"version" : "2.12",
"protocols": [
"usp"
],
"input": {},
"output": {},
"mapping": [
{
"type" : "ubus",
"ubus" : {
"object" : "proxd",
"method" : "get",
"args":{
"path": "Device.ProxiedDevice.{i}.MiniHub.{i}.DeviceInfo.",
"action": "Reboot()"
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
}
],
"MiniHubNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
}
]
},
"MHubNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "numofdevices"
}
}
]
},
"Device.PD2.{i}.MiniHub.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": true,
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
}
],
"Device.PD2.{i}.MiniHub.{i}.DeviceInfo.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Description": {
"type": "string",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "get",
"args": {
"path": "Device.ProxiedDevice.{i}.MiniHub.{i}.DeviceInfo.Description"
},
"key": "Description"
}
}
]
},
"Reboot()": {
"type": "command",
"async": true,
"protocols": [
"usp"
],
"input": {},
"output": {},
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "get",
"args": {
"path": "Device.ProxiedDevice.{i}.MiniHub.{i}.DeviceInfo.",
"action": "Reboot()"
}
}
}
]
}
}
}
]
}
}
}
}
}
}

View file

@ -1,40 +1,41 @@
{
"Device.DeviceInfo.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Device.DeviceInfo.Processor.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Architecture": {
"type": "string",
"json_plugin_version": 2,
"Device.DeviceInfo.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
"cwmp",
"usp"
],
"read": true,
"write": false,
"default": "x86_64"
}
},
"ProcessorNumberOfEntries": {
"type": "unsignedInt",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"default": "1"
"access": false,
"array": false,
"Device.DeviceInfo.Processor.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Architecture": {
"type": "string",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"default": "x86_64"
}
},
"ProcessorNumberOfEntries": {
"type": "unsignedInt",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"default": "1"
}
}
}
}

View file

@ -88,7 +88,8 @@ obj_schema_v1 = {
"type": "string",
"enum": [
"cwmp",
"usp"
"usp",
"none"
]
}
},
@ -163,7 +164,8 @@ param_schema = {
"type": "string",
"enum": [
"cwmp",
"usp"
"usp",
"none"
]
}
},
@ -285,7 +287,7 @@ def parse_value( key , value ):
print(key + " is not a valid path")
exit(1)
if key.endswith('.') and JSON_PLUGIN_VERSION == 1:
if key.endswith('.') and (JSON_PLUGIN_VERSION == 1 or JSON_PLUGIN_VERSION == 2):
__schema = obj_schema_v1
elif key.endswith('.'):
__schema = obj_schema