mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-08 10:17:44 +01:00
Align with uspd transaction_id updates
This commit is contained in:
parent
f1560b1305
commit
69baee1750
3 changed files with 42 additions and 19 deletions
|
|
@ -11,26 +11,31 @@
|
|||
#include "datamodel_interface.h"
|
||||
#include "log.h"
|
||||
bool transaction_started = false;
|
||||
int transaction_id = 0;
|
||||
|
||||
/*
|
||||
* Transaction Functions
|
||||
*/
|
||||
int cwmp_transaction_start()
|
||||
int cwmp_transaction_start(char *app)
|
||||
{
|
||||
CWMP_LOG (INFO,"Starting transaction ...");
|
||||
json_object *transaction_ret = NULL, *status_obj = NULL;
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_start", CWMP_UBUS_ARGS{{}}, 0, &transaction_ret);
|
||||
json_object *transaction_ret = NULL, *status_obj = NULL, *transaction_id_obj = NULL;
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_start", CWMP_UBUS_ARGS{{"app", {.str_val=app}, UBUS_String}}, 1, &transaction_ret);
|
||||
if (e!=0) {
|
||||
CWMP_LOG (INFO,"Transaction start failed: Ubus err code: %d", e);
|
||||
return 0;
|
||||
}
|
||||
json_object_object_get_ex(transaction_ret, "status", &status_obj);
|
||||
if (strcmp((char*)json_object_get_string(status_obj), "1") != 0) {
|
||||
if (strcmp((char*)json_object_get_string(status_obj), "true") != 0) {
|
||||
json_object *error = NULL;
|
||||
json_object_object_get_ex(transaction_ret, "error", &error);
|
||||
CWMP_LOG (INFO,"Transaction start failed: %s\n",(char*)json_object_get_string(error));
|
||||
return 0;
|
||||
}
|
||||
json_object_object_get_ex(transaction_ret, "transaction_id", &transaction_id_obj);
|
||||
if (transaction_id_obj == NULL)
|
||||
return 0;
|
||||
transaction_id = atoi((char*)json_object_get_string(transaction_id_obj));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -38,18 +43,20 @@ int cwmp_transaction_commit()
|
|||
{
|
||||
CWMP_LOG (INFO,"Transaction Commit ...");
|
||||
json_object *transaction_ret = NULL, *status_obj = NULL;
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_commit", CWMP_UBUS_ARGS{{}}, 0, &transaction_ret);
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_commit", CWMP_UBUS_ARGS{{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 1, &transaction_ret);
|
||||
if (e!=0) {
|
||||
CWMP_LOG (INFO,"Transaction commit failed: Ubus err code: %d", e);
|
||||
return 0;
|
||||
}
|
||||
json_object_object_get_ex(transaction_ret, "status", &status_obj);
|
||||
if (strcmp((char*)json_object_get_string(status_obj), "1") != 0) {
|
||||
if (strcmp((char*)json_object_get_string(status_obj), "true") != 0) {
|
||||
json_object *error = NULL;
|
||||
json_object_object_get_ex(transaction_ret, "error", &error);
|
||||
CWMP_LOG (INFO,"Transaction commit failed: %s\n",(char*)json_object_get_string(error));
|
||||
transaction_id = 0;
|
||||
return 0;
|
||||
}
|
||||
transaction_id = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -57,22 +64,36 @@ int cwmp_transaction_abort()
|
|||
{
|
||||
CWMP_LOG (INFO,"Transaction Abort ...");
|
||||
json_object *transaction_ret = NULL, *status_obj = NULL;
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_abort", CWMP_UBUS_ARGS{{}}, 0, &transaction_ret);
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_abort", CWMP_UBUS_ARGS{{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 1, &transaction_ret);
|
||||
if (e!=0) {
|
||||
CWMP_LOG (INFO,"Transaction abort failed: Ubus err code: %d", e);
|
||||
return 0;
|
||||
}
|
||||
json_object_object_get_ex(transaction_ret, "status", &status_obj);
|
||||
if (strcmp((char*)json_object_get_string(status_obj), "1") != 0) {
|
||||
if (strcmp((char*)json_object_get_string(status_obj), "true") != 0) {
|
||||
json_object *error = NULL;
|
||||
json_object_object_get_ex(transaction_ret, "error", &error);
|
||||
CWMP_LOG (INFO,"Transaction abort failed: %s\n",(char*)json_object_get_string(error));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return e;
|
||||
}
|
||||
|
||||
int cwmp_transaction_status()
|
||||
{
|
||||
json_object *status_obj = NULL, *transaction_ret = NULL;
|
||||
int e = cwmp_ubus_call("usp.raw", "transaction_status", CWMP_UBUS_ARGS{{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 1, &transaction_ret);
|
||||
if (e!=0) {
|
||||
CWMP_LOG (INFO,"Transaction status failed: Ubus err code: %d", e);
|
||||
return 0;
|
||||
}
|
||||
json_object_object_get_ex(transaction_ret, "status", &status_obj);
|
||||
if (!status_obj || strcmp((char*)json_object_get_string(status_obj), "on-going") != 0) {
|
||||
CWMP_LOG (INFO,"Transaction with id: %d is not available anymore\n",transaction_id);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* RPC Methods Functions
|
||||
*/
|
||||
|
|
@ -97,7 +118,7 @@ char* cwmp_get_parameter_values(char *parameter_name, json_object **parameters)
|
|||
char* cwmp_set_parameter_value(char* parameter_name, char* value, char* parameter_key, int* flag)
|
||||
{
|
||||
json_object *set_res;
|
||||
int e = cwmp_ubus_call("usp.raw", "set", CWMP_UBUS_ARGS{{"path", {.str_val=parameter_name}, UBUS_String},{"value", {.str_val=value}, UBUS_String}, {"key", {.str_val=parameter_key}, UBUS_String}}, 3, &set_res);
|
||||
int e = cwmp_ubus_call("usp.raw", "set", CWMP_UBUS_ARGS{{"path", {.str_val=parameter_name}, UBUS_String},{"value", {.str_val=value}, UBUS_String}, {"key", {.str_val=parameter_key}, UBUS_String},{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 3, &set_res);
|
||||
|
||||
if (e < 0 || set_res == NULL)
|
||||
return "9002";
|
||||
|
|
@ -144,7 +165,7 @@ char* cwmp_set_parameter_value(char* parameter_name, char* value, char* paramete
|
|||
char* cwmp_set_multiple_parameters_values(struct list_head parameters_values_list, char* parameter_key, int* flag, json_object **faults_array)
|
||||
{
|
||||
json_object *set_res;
|
||||
int e = cwmp_ubus_call("usp.raw", "setm_values", CWMP_UBUS_ARGS{{"pv_tuple", {.param_value_list=¶meters_values_list}, UBUS_List_Param}, {"key", {.str_val=parameter_key}, UBUS_String}}, 2, &set_res);
|
||||
int e = cwmp_ubus_call("usp.raw", "setm_values", CWMP_UBUS_ARGS{{"pv_tuple", {.param_value_list=¶meters_values_list}, UBUS_List_Param}, {"key", {.str_val=parameter_key}, UBUS_String},{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 3, &set_res);
|
||||
if (e < 0 || set_res == NULL)
|
||||
return "9002";
|
||||
|
||||
|
|
@ -173,7 +194,7 @@ char* cwmp_set_multiple_parameters_values(struct list_head parameters_values_lis
|
|||
char* cwmp_add_object(char* object_name, char* key, char **instance)
|
||||
{
|
||||
json_object *add_res;
|
||||
int e = cwmp_ubus_call("usp.raw", "add_object", CWMP_UBUS_ARGS{{"path", {.str_val=object_name}, UBUS_String},{"key", {.str_val=key}, UBUS_String}}, 2, &add_res);
|
||||
int e = cwmp_ubus_call("usp.raw", "add_object", CWMP_UBUS_ARGS{{"path", {.str_val=object_name}, UBUS_String},{"key", {.str_val=key}, UBUS_String},{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 3, &add_res);
|
||||
if (e < 0 || add_res == NULL)
|
||||
return "9002";
|
||||
json_object *fault_code = NULL;
|
||||
|
|
@ -199,7 +220,7 @@ char* cwmp_add_object(char* object_name, char* key, char **instance)
|
|||
char* cwmp_delete_object(char* object_name, char* key)
|
||||
{
|
||||
json_object *del_res;
|
||||
int e = cwmp_ubus_call("usp.raw", "del_object", CWMP_UBUS_ARGS{{"path", {.str_val=object_name}, UBUS_String},{"key", {.str_val=key}, UBUS_String}}, 2, &del_res);
|
||||
int e = cwmp_ubus_call("usp.raw", "del_object", CWMP_UBUS_ARGS{{"path", {.str_val=object_name}, UBUS_String},{"key", {.str_val=key}, UBUS_String},{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 3, &del_res);
|
||||
if (e < 0 || del_res == NULL)
|
||||
return "9002";
|
||||
json_object *fault_code = NULL;
|
||||
|
|
@ -262,7 +283,7 @@ char* cwmp_get_parameter_attributes(char* parameter_name, json_object **paramete
|
|||
char* cwmp_set_parameter_attributes(char* parameter_name, char* notification)
|
||||
{
|
||||
json_object *set_attribute_res;
|
||||
int e = cwmp_ubus_call("usp.raw", "setm_attributes", CWMP_UBUS_ARGS{{"paths", {.array_value={{.param_value={"path",parameter_name}},{.param_value={"notify-type",notification}},{.param_value={"notify","1"}}}}, UBUS_Array_Obj}}, 1, &set_attribute_res);
|
||||
int e = cwmp_ubus_call("usp.raw", "setm_attributes", CWMP_UBUS_ARGS{{"paths", {.array_value={{.param_value={"path",parameter_name}},{.param_value={"notify-type",notification}},{.param_value={"notify","1"}}}}, UBUS_Array_Obj},{"transaction_id", {.int_val=transaction_id}, UBUS_Integer}}, 2, &set_attribute_res);
|
||||
if (e < 0 || set_attribute_res == NULL)
|
||||
return "9002";
|
||||
json_object *parameters = NULL;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@
|
|||
|
||||
#define DM_ROOT_OBJ "Device."
|
||||
extern bool transaction_started;
|
||||
extern int transaction_id;
|
||||
|
||||
int cwmp_transaction_start();
|
||||
int cwmp_transaction_start(char *app);
|
||||
int cwmp_transaction_commit();
|
||||
int cwmp_transaction_abort();
|
||||
int cwmp_transaction_status();
|
||||
char* cwmp_get_parameter_values(char *parameter_name, json_object **parameters);
|
||||
char* cwmp_set_parameter_value(char* parameter_name, char* value, char* parameter_key, int* flag);
|
||||
char* cwmp_set_multiple_parameters_values(struct list_head parameters_values_list, char* parameter_key, int* flag, json_object **faults_array);
|
||||
|
|
|
|||
8
xml.c
8
xml.c
|
|
@ -1651,7 +1651,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
json_object *faults_array = NULL;
|
||||
int flag = 0;
|
||||
if(!transaction_started) {
|
||||
if (!cwmp_transaction_start())
|
||||
if (!cwmp_transaction_start("cwmp"))
|
||||
goto fault;
|
||||
transaction_started = true;
|
||||
}
|
||||
|
|
@ -1728,7 +1728,7 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
|
|||
b = n;
|
||||
|
||||
if (!transaction_started) {
|
||||
if (!cwmp_transaction_start())
|
||||
if (!cwmp_transaction_start("cwmp"))
|
||||
goto fault;
|
||||
transaction_started = true;
|
||||
}
|
||||
|
|
@ -1841,7 +1841,7 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
|
|||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
}
|
||||
if (!transaction_started) {
|
||||
if (!cwmp_transaction_start())
|
||||
if (!cwmp_transaction_start("cwmp"))
|
||||
goto fault;
|
||||
transaction_started = true;
|
||||
}
|
||||
|
|
@ -1929,7 +1929,7 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
|
|||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
}
|
||||
if (!transaction_started) {
|
||||
if (!cwmp_transaction_start())
|
||||
if (!cwmp_transaction_start("cwmp"))
|
||||
goto fault;
|
||||
transaction_started = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue