update log messages

This commit is contained in:
zribiahmed 2013-02-21 11:01:34 +00:00
parent 25ae7ca5bd
commit b179941d94
5 changed files with 69 additions and 46 deletions

View file

@ -136,7 +136,9 @@ void cwmp_schedule_session (struct cwmp *cwmp)
CWMP_LOG(EMERG,"FATAL error in the mutex process in the session scheduler!");
exit(EXIT_FAILURE);
}
CWMP_LOG (INFO,"Start session");
error = cwmp_schedule_rpc (cwmp,session);
CWMP_LOG (INFO,"End session");
run_session_end_func(session);
if (session->error == CWMP_RETRY_SESSION)
{
@ -182,11 +184,19 @@ int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session)
rpc_acs = list_entry (ilist, struct rpc, list);
if (!rpc_acs->type)
goto retry;
CWMP_LOG (INFO,"Preparing the %s RPC message to send to the ACS",
rpc_acs_methods[rpc_acs->type].name);
if (rpc_acs_methods[rpc_acs->type].prepare_message(cwmp, session, rpc_acs))
goto retry;
CWMP_LOG (INFO,"Send the RPC message to the ACS");
CWMP_LOG (INFO,"Send the %s RPC message to the ACS",
rpc_acs_methods[rpc_acs->type].name);
if (xml_send_message(cwmp, session, rpc_acs))
goto retry;
CWMP_LOG (INFO,"Get the %sResponse message from the ACS",
rpc_acs_methods[rpc_acs->type].name);
if (rpc_acs_methods[rpc_acs->type].parse_response)
if (rpc_acs_methods[rpc_acs->type].parse_response(cwmp, session, rpc_acs))
goto retry;
@ -200,11 +210,13 @@ int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session)
if (session->hold_request)
break;
}
if (xml_send_message(cwmp, session, NULL))
CWMP_LOG (INFO,"Send empty message to the ACS");
if (xml_send_message(cwmp, session, NULL))
goto retry;
if (!session->tree_in)
goto next;
CWMP_LOG (INFO,"Receive request from the ACS");
if (xml_handle_message(session))
goto retry;
@ -213,16 +225,26 @@ int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session)
rpc_cpe = list_entry (session->head_rpc_cpe.next, struct rpc, list);
if (!rpc_cpe->type)
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(session, rpc_cpe))
goto retry;
MXML_DELETE(session->tree_in);
CWMP_LOG (INFO,"Send the RPC response message to the ACS");
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(cwmp, session, rpc_cpe))
goto retry;
MXML_DELETE(session->tree_out);
cwmp_session_rpc_destructor(rpc_cpe);
if (!session->tree_in)
break;
CWMP_LOG (INFO,"Receive request from the ACS");
if (xml_handle_message(session))
goto retry;
}
@ -237,7 +259,9 @@ next:
success:
session->error = CWMP_OK;
goto end;
retry:
CWMP_LOG (INFO,"Failed");
session->error = CWMP_RETRY_SESSION;
end:
@ -414,21 +438,29 @@ struct session *cwmp_add_queue_session (struct cwmp *cwmp)
int run_session_end_func (struct session *session)
{
if (session->end_session & END_SESSION_EXTERNAL_ACTION)
{
CWMP_LOG (INFO,"Executing external commands: end session request");
external_simple("end_session", NULL);
}
if (session->end_session & END_SESSION_FACTORY_RESET)
{
CWMP_LOG (INFO,"Executing factory reset: end session request");
external_simple("factory_reset", NULL);
exit(EXIT_SUCCESS);
}
if (session->end_session & END_SESSION_REBOOT)
{
CWMP_LOG (INFO,"Executing Reboot: end session request");
external_simple("reboot", NULL);
exit(EXIT_SUCCESS);
}
if (session->end_session & END_SESSION_RELOAD)
cwmp_apply_acs_changes();
if (session->end_session & END_SESSION_FACTORY_RESET)
{
external_simple("factory_reset", NULL);
exit(EXIT_SUCCESS);
CWMP_LOG (INFO,"Config reload: end session request");
cwmp_apply_acs_changes();
}
session->end_session = 0;

View file

@ -162,7 +162,7 @@ int external_get_action(char *action, char *name, char *arg, int external_handle
if (pipe(pfds) < 0)
return -1;
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"executing get %s '%s'", action, name);
DD(INFO,"executing get %s '%s'", action, name);
if ((uproc.pid = fork()) == -1)
goto error;
@ -215,7 +215,7 @@ error:
int external_get_action_write(char *action, char *name, char *arg)
{
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"adding to get %s script '%s'", action, name);
DD(INFO,"adding to get %s script '%s'", action, name);
FILE *fp;
@ -261,7 +261,7 @@ int external_get_action_execute(int external_handler(char *msg))
if (access(fc_script_actions, F_OK) == -1)
goto success;
CWMP_LOG(INFO,"executing get script");
DD(INFO,"executing get script");
if ((uproc.pid = fork()) == -1) {
goto error;
@ -312,7 +312,7 @@ error:
int external_set_action_write(char *action, char *name, char *value, char *change)
{
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"adding to set %s script '%s'", action, name);
DD(INFO,"adding to set %s script '%s'", action, name);
FILE *fp;
@ -354,7 +354,7 @@ int external_set_action_execute(char *action, int external_handler(char *msg))
return -1;
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"executing set script");
DD(INFO,"executing set script");
FILE *fp;
@ -426,7 +426,7 @@ int external_object_action(char *action, char *name, int external_handler(char *
return -1;
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"executing object %s '%s'", action, name);
DD(INFO,"executing object %s '%s'", action, name);
if ((uproc.pid = fork()) == -1)
goto error;
@ -482,7 +482,7 @@ int external_simple(char *arg, int external_handler(char *msg))
return -1;
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"executing %s request", arg);
DD(INFO,"executing %s request", arg);
if ((uproc.pid = fork()) == -1)
goto error;
@ -536,7 +536,7 @@ int external_download(char *url, char *size, char *type, char *user, char *pass,
return -1;
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"executing download url '%s'", url);
DD(INFO,"executing download url '%s'", url);
if ((uproc.pid = fork()) == -1)
goto error;
@ -605,7 +605,7 @@ int external_apply_download(char *type, int external_handler(char *msg))
return -1;
pthread_mutex_lock(&external_mutex_exec);
CWMP_LOG(INFO,"applying downloaded file");
DD(INFO,"applying downloaded file");
if ((uproc.pid = fork()) == -1)
goto error;

View file

@ -92,6 +92,7 @@ struct rpc_cpe_method {
};
struct rpc_acs_method {
const char *name;
int (*prepare_message)(struct cwmp *cwmp, struct session *session, struct rpc *rpc);
int (*parse_response)(struct cwmp *cwmp, struct session *session, struct rpc *rpc);
int (*extra_clean)(struct session *session, struct rpc *rpc);

View file

@ -70,7 +70,7 @@ cwmp_handle_downloadFault(char *msg)
if (!tb[DOWNLOAD_FAULT])
goto error;
CWMP_LOG(INFO,"triggered handle download fault %s", tb[DOWNLOAD_FAULT]);
DD(INFO,"triggered handle download fault %s", tb[DOWNLOAD_FAULT]);
external_downloadFaultResp (tb[DOWNLOAD_FAULT]);
@ -108,7 +108,7 @@ cwmp_handle_getParamValues(char *msg)
goto error;
CWMP_LOG(INFO, "triggered handle get parameter value of: %s",
DD(INFO, "triggered handle get parameter value of: %s",
tb[GETPARAMVALUES_PARAM]);
@ -149,7 +149,7 @@ cwmp_handle_getParamNames(char *msg)
goto error;
CWMP_LOG(INFO, "triggered handle get parameter name of: %s",
DD(INFO, "triggered handle get parameter name of: %s",
tb[GETPARAMNAMES_PARAM]);
@ -189,7 +189,7 @@ cwmp_handle_getParamAttributes(char *msg)
if (!tb[GETPARAMATTRIBUTES_PARAM])
goto error;
CWMP_LOG(INFO, "triggered handle get parameter attribute of: %s",
DD(INFO, "triggered handle get parameter attribute of: %s",
tb[GETPARAMATTRIBUTES_PARAM]);
external_add_list_parameter(tb[GETPARAMATTRIBUTES_PARAM],
@ -223,7 +223,7 @@ cwmp_handle_setParamAttributes(char *msg)
jshn_message_parse(setParamAttributes_policy, ARRAYSIZEOF(setParamAttributes_policy), tb, msg);
CWMP_LOG(INFO, "triggered handle set parameter attribute");
DD(INFO, "triggered handle set parameter attribute");
external_setParamAttrResp(tb[SETPARAMATTRIBUTES_SUCCESS],
tb[SETPARAMATTRIBUTES_FAULT]);
@ -257,7 +257,7 @@ cwmp_handle_setParamValuesFault(char *msg)
goto error;
CWMP_LOG(INFO, "triggered handle set parameter value fault (%s) of: %s",
DD(INFO, "triggered handle set parameter value fault (%s) of: %s",
tb[SETPARAMVALUESFAULT_FAULT],
tb[SETPARAMVALUESFAULT_PARAM]);
@ -295,7 +295,7 @@ cwmp_handle_setParamValuesStatus(char *msg)
goto error;
CWMP_LOG(INFO, "triggered handle set parameter value status");
DD(INFO, "triggered handle set parameter value status");
external_setParamValRespStatus(tb[SETPARAMVALUESSTATUS_STATUS]);
@ -337,7 +337,7 @@ cwmp_handle_addObject(char *msg)
{
char *tb[__ADDOBJECT_MAX] = {0};
CWMP_LOG(INFO, "triggered handle add object");
DD(INFO, "triggered handle add object");
jshn_message_parse(addObject_policy, ARRAYSIZEOF(addObject_policy), tb, msg);
@ -364,7 +364,7 @@ cwmp_handle_delObject(char *msg)
{
char *tb[__DELOBJECT_MAX] = {0};
CWMP_LOG(INFO, "triggered handle delete object");
DD(INFO, "triggered handle delete object");
jshn_message_parse(delObject_policy, ARRAYSIZEOF(delObject_policy), tb, msg);

View file

@ -90,9 +90,9 @@ const struct rpc_cpe_method rpc_cpe_methods[] = {
};
const struct rpc_acs_method rpc_acs_methods[] = {
[RPC_ACS_INFORM] = {cwmp_rpc_acs_prepare_message_inform, cwmp_rpc_acs_parse_response_inform, cwmp_rpc_acs_destroy_data_inform},
[RPC_ACS_GET_RPC_METHODS] = {cwmp_rpc_acs_prepare_get_rpc_methods, NULL, NULL},
[RPC_ACS_TRANSFER_COMPLETE] = {cwmp_rpc_acs_prepare_transfer_complete, NULL, cwmp_rpc_acs_destroy_data_transfer_complete}
[RPC_ACS_INFORM] = {"Inform", cwmp_rpc_acs_prepare_message_inform, cwmp_rpc_acs_parse_response_inform, cwmp_rpc_acs_destroy_data_inform},
[RPC_ACS_GET_RPC_METHODS] = {"GetRPCMethods", cwmp_rpc_acs_prepare_get_rpc_methods, NULL, NULL},
[RPC_ACS_TRANSFER_COMPLETE] = {"TransferComplete", cwmp_rpc_acs_prepare_transfer_complete, NULL, cwmp_rpc_acs_destroy_data_transfer_complete}
};
const struct DEVICE_ID_STRUCT DEVICE_ID_CONST [] = {
@ -329,10 +329,10 @@ int xml_handle_message(struct session *session)
} else {
goto error;
}
CWMP_LOG (INFO,"Receive SOAP RPC from ACS: %s", c);
CWMP_LOG (INFO,"SOAP RPC message: %s", c);
rpc_cpe = NULL;
for (i = 1; i < RPC_CPE_FAULT; i++) {
if (!strcmp(c, rpc_cpe_methods[i].name)) {
for (i = 1; i < __RPC_CPE_MAX; i++) {
if (i!= RPC_CPE_FAULT && strcmp(c, rpc_cpe_methods[i].name) == 0) {
CWMP_LOG (INFO,"%s RPC is supported",c);
rpc_cpe = cwmp_add_session_rpc_cpe(session, i);
if (rpc_cpe == NULL) goto error;
@ -340,6 +340,7 @@ int xml_handle_message(struct session *session)
}
}
if (!rpc_cpe) {
CWMP_LOG (INFO,"%s RPC is not supported",c);
session->fault_code = FAULT_CPE_METHOD_NOT_SUPPORTED;
rpc_cpe = cwmp_add_session_rpc_cpe(session, RPC_CPE_FAULT);
if (rpc_cpe == NULL) goto error;
@ -488,7 +489,6 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
return -1;
}
CWMP_LOG (INFO,"Prepare the RPC message: Inform");
#ifdef DUMMY_MODE
FILE *fp;
fp = fopen("./ext/soap_msg_templates/cwmp_inform_message.xml", "r");
@ -605,7 +605,6 @@ int cwmp_rpc_acs_prepare_get_rpc_methods(struct cwmp *cwmp, struct session *sess
{
mxml_node_t *tree, *n;
CWMP_LOG (INFO,"Prepare the RPC message: GetRPCMethods");
tree = mxmlLoadString(NULL, CWMP_RESPONSE_MESSAGE, MXML_NO_CALLBACK);
n = mxmlFindElement(tree, tree, "soap_env:Body",
@ -646,7 +645,6 @@ int cwmp_rpc_acs_prepare_transfer_complete(struct cwmp *cwmp, struct session *se
mxml_node_t *tree, *n;
struct transfer_complete *p;
CWMP_LOG (INFO,"Prepare the RPC message: TransferComplete");
p = (struct transfer_complete *)rpc->extra_data;
tree = mxmlLoadString(NULL, CWMP_RESPONSE_MESSAGE, MXML_NO_CALLBACK);
@ -734,7 +732,6 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
char *c = NULL;
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
CWMP_LOG (INFO,"Prepare the RPC response message: GetParameterValuesResponse");
b = session->body_in;
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
NULL, NULL, MXML_DESCEND);
@ -842,7 +839,6 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
char *c;
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
CWMP_LOG (INFO,"Prepare the RPC response message: GetParameterNamesResponse");
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
NULL, NULL, MXML_DESCEND);
if (!n) goto fault;
@ -950,7 +946,6 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct session *session, struct
char *c=NULL;
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
CWMP_LOG (INFO,"Prepare the RPC response message: GetParameterAttributesResponse");
b = session->body_in;
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
NULL, NULL, MXML_DESCEND);
@ -1079,7 +1074,6 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
char buf[128];
int fault_code = FAULT_CPE_INTERNAL_ERROR;
CWMP_LOG (INFO,"Prepare the RPC response message: SetParameterValuesResponse");
b = mxmlFindElement(session->body_in, session->body_in, "ParameterList", NULL, NULL, MXML_DESCEND);
if(!b) {
@ -1286,7 +1280,6 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
char *status = NULL, *instance = NULL, *fault = NULL;
int fault_code = FAULT_CPE_INTERNAL_ERROR;
CWMP_LOG (INFO,"Prepare the RPC response message: AddObjectResponse");
b = session->body_in;
while (b) {
if (b && b->type == MXML_TEXT &&
@ -1380,7 +1373,6 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
char *status = NULL, *fault = NULL;
int fault_code = FAULT_CPE_INTERNAL_ERROR;
CWMP_LOG (INFO,"Prepare the RPC response message: DeleteObjectResponse");
b = session->body_in;
while (b) {
if (b && b->type == MXML_TEXT &&
@ -1463,7 +1455,6 @@ int cwmp_handle_rpc_cpe_get_rpc_methods(struct session *session, struct rpc *rpc
char *c = NULL;
int i,counter = 0;
CWMP_LOG (INFO,"Prepare the RPC response message: GetRPCMethodsResponse");
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
NULL, NULL, MXML_DESCEND);
if (!n) goto fault;
@ -1476,7 +1467,7 @@ int cwmp_handle_rpc_cpe_get_rpc_methods(struct session *session, struct rpc *rpc
for (i=1; i<__RPC_CPE_MAX; i++)
{
if ((rpc_cpe_methods[i].handler != NULL) && (rpc_cpe_methods[i].name != NULL))
if (i!= RPC_CPE_FAULT)
{
n = mxmlNewElement(method_list, "string");
if (!n) goto fault;
@ -1547,7 +1538,6 @@ int cwmp_handle_rpc_cpe_reboot(struct session *session, struct rpc *rpc)
struct event_container *event_container;
char *command_key = NULL;
CWMP_LOG (INFO,"Prepare the RPC response message: RebootResponse");
b = session->body_in;
while (b) {
@ -1696,7 +1686,6 @@ int cwmp_handle_rpc_cpe_schedule_inform(struct session *session, struct rpc *rpc
int error;
unsigned int delay_seconds = 0;
CWMP_LOG (INFO,"Prepare the RPC response message: ScheduleInformResponse");
pthread_mutex_lock (&mutex_schedule_inform);
while (b) {
@ -2006,7 +1995,6 @@ int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
time_t download_delay;
bool cond_signal = false;
CWMP_LOG (INFO,"Prepare the RPC response message: DownloadResponse");
if (asprintf(&c, "%s:%s", ns.cwmp, "Download") == -1)
{
error = FAULT_CPE_INTERNAL_ERROR;
@ -2300,6 +2288,7 @@ int cwmp_get_fault_code (char *fault_code)
int cwmp_create_fault_message(struct session *session, struct rpc *rpc_cpe, int fault_code)
{
CWMP_LOG (INFO,"Fault in the received RPC");
session->fault_code = fault_code;
MXML_DELETE(session->tree_out);
@ -2307,6 +2296,7 @@ int cwmp_create_fault_message(struct session *session, struct rpc *rpc_cpe, int
if (xml_prepare_msg_out(session))
return -1;
CWMP_LOG (INFO,"Preparing the Fault message");
if (rpc_cpe_methods[RPC_CPE_FAULT].handler(session, rpc_cpe))
return -1;