mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Add/Delete object return status 0 as result instead of 1
This commit is contained in:
parent
dd14199d01
commit
6cee3b2fde
7 changed files with 41 additions and 32 deletions
|
|
@ -102,7 +102,7 @@ char *cmd_set_exec_func(struct cmd_input in, union cmd_result *res __attribute__
|
|||
}
|
||||
set_rpc_parameter_key(in.third_input);
|
||||
if (transaction_id) {
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
icwmp_restart_services();
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ char *cmd_add_exec_func(struct cmd_input in, union cmd_result *res)
|
|||
}
|
||||
set_rpc_parameter_key(in.second_input);
|
||||
if (transaction_id) {
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(false);
|
||||
icwmp_restart_services();
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -180,7 +180,7 @@ char *cmd_del_exec_func(struct cmd_input in, union cmd_result *res __attribute__
|
|||
}
|
||||
set_rpc_parameter_key(in.second_input);
|
||||
if (transaction_id) {
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
icwmp_restart_services();
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -244,7 +244,7 @@ char *cmd_set_notif_exec_func(struct cmd_input in, union cmd_result *res __attri
|
|||
return fault;
|
||||
}
|
||||
if (transaction_id)
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ struct setm_values_res {
|
|||
bool status;
|
||||
struct list_head *faults_list;
|
||||
};
|
||||
|
||||
struct transaction_commit_info {
|
||||
bool status;
|
||||
bool restart_services;
|
||||
};
|
||||
/*
|
||||
* Common functions
|
||||
*/
|
||||
|
|
@ -159,22 +164,26 @@ void ubus_transaction_commit_callback(struct ubus_request *req __attribute__((un
|
|||
CWMP_LOG(ERROR, "dm_iface %s: msg is null", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
bool *status = (bool *)req->priv;
|
||||
struct transaction_commit_info *trans_commit = (struct transaction_commit_info*)req->priv;
|
||||
const struct blobmsg_policy p[1] = { { "status", BLOBMSG_TYPE_BOOL } };
|
||||
struct blob_attr *updated_services = NULL;
|
||||
struct blob_attr *cur;
|
||||
int rem;
|
||||
|
||||
struct blob_attr *tb[1] = { NULL };
|
||||
blobmsg_parse(p, 1, tb, blobmsg_data(msg), blobmsg_len(msg));
|
||||
if (!tb[0]) {
|
||||
*status = false;
|
||||
trans_commit->status = false;
|
||||
return;
|
||||
}
|
||||
*status = blobmsg_get_u8(tb[0]);
|
||||
if (*status == false)
|
||||
trans_commit->status = blobmsg_get_u8(tb[0]);
|
||||
if (trans_commit->status == false)
|
||||
return;
|
||||
|
||||
if (trans_commit->restart_services == false)
|
||||
return;
|
||||
|
||||
struct blob_attr *updated_services = NULL;
|
||||
|
||||
blobmsg_for_each_attr(cur, msg, rem)
|
||||
{
|
||||
if (blobmsg_type(cur) == BLOBMSG_TYPE_ARRAY) {
|
||||
|
|
@ -257,10 +266,10 @@ bool cwmp_transaction_start(char *app)
|
|||
return status;
|
||||
}
|
||||
|
||||
bool cwmp_transaction_commit()
|
||||
bool cwmp_transaction_commit(bool rest_serv)
|
||||
{
|
||||
CWMP_LOG(INFO, "Transaction Commit ...");
|
||||
bool status = false;
|
||||
struct transaction_commit_info trans_commit = {.status = false, .restart_services = rest_serv};
|
||||
struct blob_buf b = { 0 };
|
||||
|
||||
memset(&b, 0, sizeof(struct blob_buf));
|
||||
|
|
@ -268,18 +277,18 @@ bool cwmp_transaction_commit()
|
|||
blobmsg_add_u32(&b, "transaction_id", transaction_id);
|
||||
blobmsg_add_u8(&b, "restart_services", false);
|
||||
|
||||
int e = icwmp_ubus_invoke(USP_OBJECT_NAME, "transaction_commit", b.head, ubus_transaction_commit_callback, &status);
|
||||
int e = icwmp_ubus_invoke(USP_OBJECT_NAME, "transaction_commit", b.head, ubus_transaction_commit_callback, &trans_commit);
|
||||
if (e != 0) {
|
||||
CWMP_LOG(INFO, "Transaction commit failed: Ubus err code: %d", e);
|
||||
status = false;
|
||||
trans_commit.status = false;
|
||||
}
|
||||
if (!status) {
|
||||
if (!trans_commit.status) {
|
||||
CWMP_LOG(INFO, "Transaction Commit with id: %d doesn't success\n", transaction_id);
|
||||
}
|
||||
|
||||
blob_buf_free(&b);
|
||||
transaction_id = 0;
|
||||
return status;
|
||||
return trans_commit.status;
|
||||
}
|
||||
|
||||
bool cwmp_transaction_abort()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ extern int transaction_id;
|
|||
struct blob_attr *get_parameters_array(struct blob_attr *msg);
|
||||
int get_fault(struct blob_attr *msg);
|
||||
bool cwmp_transaction_start(char *app);
|
||||
bool cwmp_transaction_commit();
|
||||
bool cwmp_transaction_commit(bool rest_serv);
|
||||
bool cwmp_transaction_abort();
|
||||
bool cwmp_transaction_status();
|
||||
char *cwmp_get_parameter_values(char *parameter_name, struct list_head *parameters_list);
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct rpc *rpc)
|
|||
if (fault_code)
|
||||
goto fault;
|
||||
|
||||
if (!cwmp_transaction_commit()) {
|
||||
if (!cwmp_transaction_commit(true)) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -1167,7 +1167,7 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
|
|||
goto fault;
|
||||
|
||||
int instance_int = atoi(instance);
|
||||
int status = 1;
|
||||
int status = 0;
|
||||
struct xml_data_struct add_resp_xml_attrs = {0};
|
||||
add_resp_xml_attrs.instance = &instance_int;
|
||||
add_resp_xml_attrs.status = &status;
|
||||
|
|
@ -1176,7 +1176,7 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
|
|||
if (fault_code != CWMP_OK)
|
||||
goto fault;
|
||||
|
||||
if (!cwmp_transaction_commit())
|
||||
if (!cwmp_transaction_commit(false))
|
||||
goto fault;
|
||||
|
||||
char *object_path = NULL;
|
||||
|
|
@ -1253,7 +1253,7 @@ int cwmp_handle_rpc_cpe_delete_object(struct rpc *rpc)
|
|||
if (fault_code != CWMP_OK)
|
||||
goto fault;
|
||||
|
||||
if (!cwmp_transaction_commit()) {
|
||||
if (!cwmp_transaction_commit(true)) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
goto fault;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,14 +130,14 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
cwmp_transaction_start("cwmp");
|
||||
fault = cwmp_set_multiple_parameters_values(&list_set_param_value, &faults_array);
|
||||
assert_int_equal(fault, 0);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.ManagementServer.Username", "iopsys_user", NULL, 0, false);
|
||||
cwmp_transaction_start("cwmp");
|
||||
fault = cwmp_set_multiple_parameters_values(&list_set_param_value, &faults_array);
|
||||
assert_int_equal(fault, 0);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
fault = 0;
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
cwmp_transaction_start("cwmp");
|
||||
fault = cwmp_set_multiple_parameters_values(&list_set_param_value, &faults_array);
|
||||
assert_int_equal(fault, 0);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
cwmp_free_all_list_param_fault(&faults_array);
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
list_for_each_entry (param_fault, &faults_array, list) {
|
||||
assert_in_set(param_fault->fault, faults_values, 3);
|
||||
}
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ static void dm_add_object_test(void **state)
|
|||
fault = cwmp_add_object("Device.WiFi.SSID.", &instance);
|
||||
assert_non_null(instance);
|
||||
assert_null(fault);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(false);
|
||||
FREE(instance);
|
||||
|
||||
/*
|
||||
|
|
@ -263,7 +263,7 @@ static void dm_add_object_test(void **state)
|
|||
assert_non_null(fault);
|
||||
assert_string_equal(fault, "9005");
|
||||
assert_null(instance);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(false);
|
||||
FREE(instance);
|
||||
|
||||
/*
|
||||
|
|
@ -274,7 +274,7 @@ static void dm_add_object_test(void **state)
|
|||
assert_non_null(fault);
|
||||
assert_string_equal(fault, "9005");
|
||||
assert_null(instance);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(false);
|
||||
FREE(instance);
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ static void dm_delete_object_test(void **state)
|
|||
cwmp_transaction_start("cwmp");
|
||||
fault = cwmp_delete_object("Device.WiFi.SSID.2.");
|
||||
assert_null(fault);
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
|
||||
/*
|
||||
* Delete not valid path object
|
||||
|
|
@ -297,7 +297,7 @@ static void dm_delete_object_test(void **state)
|
|||
fault = cwmp_delete_object("Device.WiFi.SIDl.3.");
|
||||
assert_non_null(fault);
|
||||
assert_string_equal(fault, "9005");
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
|
||||
/*
|
||||
* Delte valid path not writable object
|
||||
|
|
@ -306,7 +306,7 @@ static void dm_delete_object_test(void **state)
|
|||
fault = cwmp_delete_object("Device.DeviceInfo.Processor.2.");
|
||||
assert_non_null(fault);
|
||||
assert_string_equal(fault, "9005");
|
||||
cwmp_transaction_commit();
|
||||
cwmp_transaction_commit(true);
|
||||
}
|
||||
|
||||
static void dm_get_parameter_names_test(void **state)
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ static void soap_add_object_message_test(void **state)
|
|||
instance = (mxmlGetFirstChild(n) && mxmlGetOpaque(mxmlGetFirstChild(n))) ? atoi(mxmlGetOpaque(mxmlGetFirstChild(n))) : 1;
|
||||
n = mxmlFindElement(add_resp, add_resp, "Status", NULL, NULL, MXML_DESCEND);
|
||||
assert_non_null(n);
|
||||
assert_string_equal(mxmlGetOpaque(mxmlGetFirstChild(n)), "1");
|
||||
assert_string_equal(mxmlGetOpaque(mxmlGetFirstChild(n)), "0");
|
||||
MXML_DELETE(cwmp_main->session->tree_in);
|
||||
MXML_DELETE(cwmp_main->session->tree_out);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ sleep 2
|
|||
check_session "AddObject"
|
||||
obj_instance=$(print_tag_value "cwmp:AddObjectResponse" "InstanceNumber")
|
||||
status=$(print_tag_value "cwmp:AddObjectResponse" "Status")
|
||||
if [ "$obj_instance" != "2" -o $status != "1" ]; then
|
||||
if [ "$obj_instance" != "2" -o $status != "0" ]; then
|
||||
echo "Error: Add Object Method doesn't work correctly, current_value($obj_instance) expected_value(2)" >> ./funl-test-debug.log
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue