mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Remove support for deleting all instances since cwmp and usp protocols do not require it
This commit is contained in:
parent
85318dac63
commit
3a3b00b8e4
6 changed files with 24 additions and 83 deletions
|
|
@ -239,7 +239,7 @@ enum event_action_enum {
|
||||||
EVENT_CHECK
|
EVENT_CHECK
|
||||||
};
|
};
|
||||||
|
|
||||||
enum del_action_enum {
|
enum del_action_enum { // To be removed later!!!!!!!!!!!!
|
||||||
DEL_INST,
|
DEL_INST,
|
||||||
DEL_ALL
|
DEL_ALL
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2289,7 +2289,6 @@ static int delete_object_obj(DMOBJECT_ARGS)
|
||||||
} else {
|
} else {
|
||||||
char *refparam = node->current_object;
|
char *refparam = node->current_object;
|
||||||
char *perm = permission->val;
|
char *perm = permission->val;
|
||||||
unsigned char del_action = DEL_INST;
|
|
||||||
|
|
||||||
if (DM_STRCMP(refparam, dmctx->in_param) != 0)
|
if (DM_STRCMP(refparam, dmctx->in_param) != 0)
|
||||||
return FAULT_9005;
|
return FAULT_9005;
|
||||||
|
|
@ -2303,9 +2302,9 @@ static int delete_object_obj(DMOBJECT_ARGS)
|
||||||
return FAULT_9005;
|
return FAULT_9005;
|
||||||
|
|
||||||
if (!node->is_instanceobj)
|
if (!node->is_instanceobj)
|
||||||
del_action = DEL_ALL;
|
return FAULT_9005;
|
||||||
|
|
||||||
return (delobj)(refparam, dmctx, data, instance, del_action);
|
return (delobj)(refparam, dmctx, data, instance, DEL_INST);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -634,49 +634,22 @@ static int delete_obj(char *refparam, struct dmctx *ctx, void *data, char *insta
|
||||||
if (file && section_type && dmmap_file) {
|
if (file && section_type && dmmap_file) {
|
||||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
|
struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
|
||||||
|
|
||||||
switch (del_action) {
|
uci_package_foreach_sections_safe(json_object_get_string(file), stmp, s) {
|
||||||
case DEL_INST:
|
char *dm_parent = NULL;
|
||||||
uci_package_foreach_sections_safe(json_object_get_string(file), stmp, s) {
|
|
||||||
char *dm_parent = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(s, "dm_parent", &dm_parent);
|
dmuci_get_value_by_section_string(s, "dm_parent", &dm_parent);
|
||||||
if (DM_STRLEN(dm_parent) && strcmp(section_name(((struct dm_data *)data)->config_section), 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))
|
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 dm_data *)data)->config_section), &dmmap_section);
|
|
||||||
if (dmuci_delete_by_section(dmmap_section, NULL, NULL))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
if (dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case DEL_ALL:
|
|
||||||
uci_foreach_sections_safe(json_object_get_string(file), json_object_get_string(section_type), stmp, s) {
|
|
||||||
struct uci_section *ss = NULL, *sstmp = NULL;
|
|
||||||
|
|
||||||
uci_package_foreach_sections_safe(json_object_get_string(file), sstmp, ss) {
|
|
||||||
char *dm_parent = NULL;
|
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(ss, "dm_parent", &dm_parent);
|
|
||||||
if (DM_STRLEN(dm_parent) && strcmp(section_name(s), dm_parent) == 0) {
|
|
||||||
if (dmuci_delete_by_section(ss, NULL, NULL))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get_dmmap_section_of_config_section(json_object_get_string(dmmap_file), json_object_get_string(section_type), section_name(s), &dmmap_section);
|
|
||||||
if (dmuci_delete_by_section(dmmap_section, NULL, NULL))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (dmuci_delete_by_section(s, NULL, NULL))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 dm_data *)data)->config_section, NULL, NULL))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1068,15 +1068,9 @@ static void test_api_bbfdm_add_del_standard_object(void **state)
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
|
|
||||||
// delete all object ==> expected "0" error
|
// delete all object ==> expected "9005" error
|
||||||
ctx->in_param = "Device.Users.User.";
|
ctx->in_param = "Device.Users.User.";
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
|
||||||
|
|
||||||
// Get name object after deleting all instances ==> expected "9005" error
|
|
||||||
ctx->in_param = "Device.Users.User.1.";
|
|
||||||
ctx->nextlevel = true;
|
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1111,15 +1105,9 @@ static void test_api_bbfdm_add_del_json_object(void **state)
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
|
|
||||||
// delete all object ==> expected "0" error
|
// delete all object ==> expected "9005" error
|
||||||
ctx->in_param = "Device.X_IOPSYS_EU_Dropbear.";
|
ctx->in_param = "Device.X_IOPSYS_EU_Dropbear.";
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
|
||||||
|
|
||||||
// Get name object after deleting all instances ==> expected "9005" error
|
|
||||||
ctx->in_param = "Device.X_IOPSYS_EU_Dropbear.1.";
|
|
||||||
ctx->nextlevel = true;
|
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1154,15 +1142,9 @@ static void test_api_bbfdm_add_del_json_v1_object(void **state)
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
|
|
||||||
// delete all object ==> expected "0" error
|
// delete all object ==> expected "9005" error
|
||||||
ctx->in_param = "Device.UCI_TEST_V1.OWSD.";
|
ctx->in_param = "Device.UCI_TEST_V1.OWSD.";
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
|
||||||
|
|
||||||
// Get name object after deleting all instances ==> expected "9005" error
|
|
||||||
ctx->in_param = "Device.UCI_TEST_V1.OWSD.1.";
|
|
||||||
ctx->nextlevel = true;
|
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
|
|
||||||
// add object ==> expected "9005" error
|
// add object ==> expected "9005" error
|
||||||
|
|
@ -1213,15 +1195,9 @@ static void test_api_bbfdm_add_del_library_object(void **state)
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
|
|
||||||
// delete all object ==> expected "0" error
|
// delete all object ==> expected "9005" error
|
||||||
ctx->in_param = "Device.WiFi.SSID.";
|
ctx->in_param = "Device.WiFi.SSID.";
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
|
||||||
|
|
||||||
// Get name object after deleting all instances ==> expected "9005" error
|
|
||||||
ctx->in_param = "Device.WiFi.SSID.1.";
|
|
||||||
ctx->nextlevel = true;
|
|
||||||
fault = bbf_entry_method(ctx, BBF_GET_NAME);
|
|
||||||
assert_int_equal(fault, FAULT_9005);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ static void test_api_bbfdm_delete_object_all_instances(void **state)
|
||||||
ctx->in_param = "Device.Users.User.";
|
ctx->in_param = "Device.Users.User.";
|
||||||
|
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_api_bbfdm_delete_wrong_object(void **state)
|
static void test_api_bbfdm_delete_wrong_object(void **state)
|
||||||
|
|
@ -568,7 +568,7 @@ static void test_api_bbfdm_json_delete_object(void **state)
|
||||||
ctx->in_param = "Device.X_IOPSYS_EU_Dropbear.";
|
ctx->in_param = "Device.X_IOPSYS_EU_Dropbear.";
|
||||||
|
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_api_bbfdm_library_get_value(void **state)
|
static void test_api_bbfdm_library_get_value(void **state)
|
||||||
|
|
@ -624,7 +624,7 @@ static void test_api_bbfdm_library_delete_object(void **state)
|
||||||
ctx->in_param = "Device.WiFi.SSID.";
|
ctx->in_param = "Device.WiFi.SSID.";
|
||||||
|
|
||||||
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
fault = bbf_entry_method(ctx, BBF_DEL_OBJECT);
|
||||||
assert_int_equal(fault, 0);
|
assert_int_equal(fault, FAULT_9005);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
|
||||||
|
|
@ -382,14 +382,7 @@ def cprintAddDelObj(faddobj, fdelobj):
|
||||||
print("", file=fp)
|
print("", file=fp)
|
||||||
print("static int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)" % fdelobj, file=fp)
|
print("static int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)" % fdelobj, file=fp)
|
||||||
print("{", file=fp)
|
print("{", file=fp)
|
||||||
print(" switch (del_action) {", file=fp)
|
print(" //TODO", file=fp)
|
||||||
print(" case DEL_INST:", file=fp)
|
|
||||||
print(" //TODO", file=fp)
|
|
||||||
print(" break;", file=fp)
|
|
||||||
print(" case DEL_ALL:", file=fp)
|
|
||||||
print(" //TODO", file=fp)
|
|
||||||
print(" break;", file=fp)
|
|
||||||
print(" }", file=fp)
|
|
||||||
print(" return 0;", file=fp)
|
print(" return 0;", file=fp)
|
||||||
print("}", file=fp)
|
print("}", file=fp)
|
||||||
print("", file=fp)
|
print("", file=fp)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue