mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
T#10115: Some enhancements in the RPC calls
This commit is contained in:
parent
1cf1c0a30b
commit
08604a791d
5 changed files with 27 additions and 46 deletions
|
|
@ -63,8 +63,8 @@ class cwmp {
|
|||
```mermaid
|
||||
classDiagram
|
||||
class session {
|
||||
head_rpc_cpe: list
|
||||
head_rpc_acs: list
|
||||
rpc_cpe: struct rpc
|
||||
events: list
|
||||
session_status: struct session_status
|
||||
tree_in: mxml_node_t
|
||||
|
|
@ -76,7 +76,7 @@ class session {
|
|||
|
||||
session attributes are:
|
||||
|
||||
- head_rpc_cpe: its type is struct list_head. It contains RPC methods list that needs to be executed by the CPE in the actual session.
|
||||
- rpc_cpe: its type is struct rpc. It contains RPC method that is just requested by the ACS to be executed in the CPE.
|
||||
- head_rpc_acs: its type is struct list_head. It contains RPC methods list that the CPE requests to be executed in the ACS side in the actual session.
|
||||
- events: its type is struct list_head. It contains list of events that the CPE notifies the ACS in the Inform message of the actual session.
|
||||
- session_status: its type is struct session_status. it contains informations about the running session like start time, end time, if it's successful or failed session, hearbeat session validation ...
|
||||
|
|
|
|||
12
src/rpc.c
12
src/rpc.c
|
|
@ -76,7 +76,6 @@ char *forced_inform_parameters[] = {
|
|||
|
||||
int xml_handle_message()
|
||||
{
|
||||
struct rpc *rpc_cpe;
|
||||
char *c = NULL;
|
||||
int i;
|
||||
mxml_node_t *b;
|
||||
|
|
@ -141,25 +140,24 @@ int xml_handle_message()
|
|||
goto fault;
|
||||
}
|
||||
CWMP_LOG(INFO, "SOAP RPC message: %s", c);
|
||||
rpc_cpe = NULL;
|
||||
for (i = 1; i < __RPC_CPE_MAX; i++) {
|
||||
if (i != RPC_CPE_FAULT && c && strcmp(c, rpc_cpe_methods[i].name) == 0 && rpc_cpe_methods[i].amd <= conf->supported_amd_version) {
|
||||
CWMP_LOG(INFO, "%s RPC is supported", c);
|
||||
rpc_cpe = cwmp_add_session_rpc_cpe(i);
|
||||
if (rpc_cpe == NULL)
|
||||
cwmp_main->session->rpc_cpe = build_sessin_rcp_cpe(i);
|
||||
if (cwmp_main->session->rpc_cpe == NULL)
|
||||
goto error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!rpc_cpe) {
|
||||
if (!cwmp_main->session->rpc_cpe) {
|
||||
CWMP_LOG(INFO, "%s RPC is not supported", c);
|
||||
cwmp_main->session->fault_code = FAULT_CPE_METHOD_NOT_SUPPORTED;
|
||||
goto fault;
|
||||
}
|
||||
return 0;
|
||||
fault:
|
||||
rpc_cpe = cwmp_add_session_rpc_cpe(RPC_CPE_FAULT);
|
||||
if (rpc_cpe == NULL)
|
||||
cwmp_main->session->rpc_cpe = build_sessin_rcp_cpe(RPC_CPE_FAULT);
|
||||
if (cwmp_main->session->rpc_cpe == NULL)
|
||||
goto error;
|
||||
return 0;
|
||||
error:
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ int create_cwmp_session_structure()
|
|||
return CWMP_GEN_ERR;
|
||||
INIT_LIST_HEAD(&(cwmp_main->session->events));
|
||||
INIT_LIST_HEAD(&(cwmp_main->session->head_rpc_acs));
|
||||
INIT_LIST_HEAD(&(cwmp_main->session->head_rpc_cpe));
|
||||
cwmp_main->session->session_status.is_heartbeat = false;
|
||||
cwmp_main->session->session_status.next_heartbeat = false;
|
||||
return CWMP_OK;
|
||||
|
|
@ -77,6 +76,8 @@ int cwmp_session_init()
|
|||
if (rpc_acs == NULL)
|
||||
return CWMP_GEN_ERR;
|
||||
|
||||
cwmp_main->session->rpc_cpe = NULL;
|
||||
|
||||
set_cwmp_session_status(SESSION_RUNNING, 0);
|
||||
if (file_exists(fc_cookies))
|
||||
remove(fc_cookies);
|
||||
|
|
@ -121,7 +122,7 @@ static int cwmp_rpc_cpe_handle_message(struct rpc *rpc_cpe)
|
|||
int cwmp_schedule_rpc()
|
||||
{
|
||||
struct list_head *ilist;
|
||||
struct rpc *rpc_acs, *rpc_cpe;
|
||||
struct rpc *rpc_acs;
|
||||
|
||||
if (icwmp_http_client_init() || cwmp_stop) {
|
||||
CWMP_LOG(INFO, "Initializing http client failed");
|
||||
|
|
@ -179,23 +180,18 @@ int cwmp_schedule_rpc()
|
|||
if (xml_handle_message() || cwmp_stop)
|
||||
goto retry;
|
||||
|
||||
while (cwmp_main->session->head_rpc_cpe.next != &(cwmp_main->session->head_rpc_cpe)) {
|
||||
|
||||
rpc_cpe = list_entry(cwmp_main->session->head_rpc_cpe.next, struct rpc, list);
|
||||
if (!rpc_cpe->type || cwmp_stop)
|
||||
goto retry;
|
||||
|
||||
CWMP_LOG(INFO, "Preparing the %s%s message", rpc_cpe_methods[rpc_cpe->type].name, (rpc_cpe->type != RPC_CPE_FAULT) ? "Response" : "");
|
||||
if (cwmp_rpc_cpe_handle_message(rpc_cpe) || cwmp_stop)
|
||||
while (cwmp_main->session->rpc_cpe) {
|
||||
CWMP_LOG(INFO, "Preparing the %s%s message", rpc_cpe_methods[cwmp_main->session->rpc_cpe->type].name, (cwmp_main->session->rpc_cpe->type != RPC_CPE_FAULT) ? "Response" : "");
|
||||
if (cwmp_rpc_cpe_handle_message(cwmp_main->session->rpc_cpe) || cwmp_stop)
|
||||
goto retry;
|
||||
MXML_DELETE(cwmp_main->session->tree_in);
|
||||
|
||||
CWMP_LOG(INFO, "Send the %s%s message to the ACS", rpc_cpe_methods[rpc_cpe->type].name, (rpc_cpe->type != RPC_CPE_FAULT) ? "Response" : "");
|
||||
if (xml_send_message(rpc_cpe) || cwmp_stop)
|
||||
CWMP_LOG(INFO, "Send the %s%s message to the ACS", rpc_cpe_methods[cwmp_main->session->rpc_cpe->type].name, (cwmp_main->session->rpc_cpe->type != RPC_CPE_FAULT) ? "Response" : "");
|
||||
if (xml_send_message(cwmp_main->session->rpc_cpe) || cwmp_stop)
|
||||
goto retry;
|
||||
MXML_DELETE(cwmp_main->session->tree_out);
|
||||
FREE(cwmp_main->session->rpc_cpe);
|
||||
|
||||
cwmp_session_rpc_destructor(rpc_cpe);
|
||||
if (!cwmp_main->session->tree_in || cwmp_stop)
|
||||
break;
|
||||
|
||||
|
|
@ -305,22 +301,15 @@ void set_cwmp_session_status(int status, int retry_time)
|
|||
|
||||
void rpc_exit()
|
||||
{
|
||||
struct rpc *rpc;
|
||||
while (cwmp_main->session->head_rpc_acs.next != &(cwmp_main->session->head_rpc_acs)) {
|
||||
rpc = list_entry(cwmp_main->session->head_rpc_acs.next, struct rpc, list);
|
||||
struct rpc *rpc = list_entry(cwmp_main->session->head_rpc_acs.next, struct rpc, list);
|
||||
if (!rpc)
|
||||
break;
|
||||
if (rpc_acs_methods[rpc->type].extra_clean != NULL)
|
||||
rpc_acs_methods[rpc->type].extra_clean(rpc);
|
||||
cwmp_session_rpc_destructor(rpc);
|
||||
}
|
||||
|
||||
while (cwmp_main->session->head_rpc_cpe.next != &(cwmp_main->session->head_rpc_cpe)) {
|
||||
rpc = list_entry(cwmp_main->session->head_rpc_cpe.next, struct rpc, list);
|
||||
if (!rpc)
|
||||
break;
|
||||
cwmp_session_rpc_destructor(rpc);
|
||||
}
|
||||
FREE(cwmp_main->session->rpc_cpe);
|
||||
}
|
||||
|
||||
void start_cwmp_session()
|
||||
|
|
@ -370,6 +359,7 @@ void start_cwmp_session()
|
|||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
}
|
||||
FREE(exec_download);
|
||||
|
||||
error = cwmp_schedule_rpc();
|
||||
if (error != CWMP_OK) {
|
||||
CWMP_LOG(ERROR, "CWMP session error: %d", error);
|
||||
|
|
@ -576,7 +566,7 @@ void reinit_cwmp_periodic_session_feature()
|
|||
cwmp_main->prev_periodic_time = cwmp_main->conf.time;
|
||||
}
|
||||
|
||||
struct rpc *cwmp_add_session_rpc_cpe(int type)
|
||||
struct rpc *build_sessin_rcp_cpe(int type)
|
||||
{
|
||||
struct rpc *rpc_cpe;
|
||||
|
||||
|
|
@ -585,7 +575,6 @@ struct rpc *cwmp_add_session_rpc_cpe(int type)
|
|||
return NULL;
|
||||
}
|
||||
rpc_cpe->type = type;
|
||||
list_add_tail(&(rpc_cpe->list), &(cwmp_main->session->head_rpc_cpe));
|
||||
return rpc_cpe;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ typedef struct session_status {
|
|||
} session_status;
|
||||
|
||||
typedef struct session {
|
||||
struct list_head head_rpc_cpe;
|
||||
struct list_head head_rpc_acs;
|
||||
struct rpc *rpc_cpe;
|
||||
struct list_head events;
|
||||
struct session_status session_status;
|
||||
mxml_node_t *tree_in;
|
||||
|
|
@ -89,7 +89,7 @@ enum enum_session_status
|
|||
extern unsigned int end_session_flag;
|
||||
|
||||
void cwmp_set_end_session(unsigned int flag);
|
||||
struct rpc *cwmp_add_session_rpc_cpe(int type);
|
||||
struct rpc *build_sessin_rcp_cpe(int type);
|
||||
struct rpc *cwmp_add_session_rpc_acs(int type);
|
||||
struct rpc *cwmp_add_session_rpc_acs_head(int type);
|
||||
int cwmp_session_rpc_destructor(struct rpc *rpc);
|
||||
|
|
|
|||
|
|
@ -205,9 +205,8 @@ static void prepare_gpv_soap_request(char *parameters[], int len)
|
|||
static void soap_get_param_value_message_test(void **state)
|
||||
{
|
||||
mxml_node_t *env = NULL, *n = NULL, *name = NULL, *value = NULL;
|
||||
struct rpc *rpc_cpe;
|
||||
|
||||
rpc_cpe = list_entry(&(cwmp_main->session->head_rpc_cpe), struct rpc, list);
|
||||
struct rpc *rpc_cpe = build_sessin_rcp_cpe(RPC_CPE_GET_PARAMETER_VALUES);
|
||||
|
||||
/*
|
||||
* Valid parameter path
|
||||
|
|
@ -305,10 +304,8 @@ static void prepare_addobj_soap_request(char *object, char *parameter_key)
|
|||
static void soap_add_object_message_test(void **state)
|
||||
{
|
||||
mxml_node_t *env = NULL, *n = NULL, *add_resp = NULL;
|
||||
struct rpc *rpc_cpe;
|
||||
|
||||
rpc_cpe = list_entry(&(cwmp_main->session->head_rpc_cpe), struct rpc, list);
|
||||
|
||||
struct rpc *rpc_cpe = build_sessin_rcp_cpe(RPC_CPE_ADD_OBJECT);
|
||||
/*
|
||||
* Valid path & writable object
|
||||
*/
|
||||
|
|
@ -454,9 +451,8 @@ static void prepare_delobj_soap_request(char *object, char *parameter_key)
|
|||
static void soap_delete_object_message_test(void **state)
|
||||
{
|
||||
mxml_node_t *env = NULL, *n = NULL, *add_resp = NULL;
|
||||
struct rpc *rpc_cpe;
|
||||
|
||||
rpc_cpe = list_entry(&(cwmp_main->session->head_rpc_cpe), struct rpc, list);
|
||||
struct rpc *rpc_cpe = build_sessin_rcp_cpe(RPC_CPE_DELETE_OBJECT);
|
||||
|
||||
/*
|
||||
* Valid path & writable object
|
||||
|
|
@ -601,9 +597,8 @@ static void prepare_gpa_soap_request(char *parameter)
|
|||
static void soap_get_parameter_attributes_message_test(void **state)
|
||||
{
|
||||
mxml_node_t *env = NULL, *n = NULL, *param_attr = NULL;
|
||||
struct rpc *rpc_cpe;
|
||||
|
||||
rpc_cpe = list_entry(&(cwmp_main->session->head_rpc_cpe), struct rpc, list);
|
||||
struct rpc *rpc_cpe = build_sessin_rcp_cpe(RPC_CPE_GET_PARAMETER_ATTRIBUTES);
|
||||
|
||||
/*
|
||||
* Valid path
|
||||
|
|
@ -701,9 +696,8 @@ static void prepare_spa_soap_request(char *parameter, char *notification, char *
|
|||
static void soap_set_parameter_attributes_message_test(void **state)
|
||||
{
|
||||
mxml_node_t *env = NULL, *n = NULL;
|
||||
struct rpc *rpc_cpe;
|
||||
|
||||
rpc_cpe = list_entry(&(cwmp_main->session->head_rpc_cpe), struct rpc, list);
|
||||
struct rpc *rpc_cpe = build_sessin_rcp_cpe(RPC_CPE_SET_PARAMETER_ATTRIBUTES);
|
||||
|
||||
/*
|
||||
* Valid path
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue