mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
icwmp: cleanup
Fixed memory leak and warning of unused variable
This commit is contained in:
parent
2c84f1764d
commit
0d3861337a
20 changed files with 369 additions and 624 deletions
|
|
@ -358,7 +358,6 @@ void bkp_session_insert_apply_schedule_download(struct apply_schedule_download *
|
|||
struct search_keywords keys[9];
|
||||
char delay[4][128];
|
||||
int i;
|
||||
char file_size[128];
|
||||
char maxretrie[2][128];
|
||||
mxml_node_t *b;
|
||||
|
||||
|
|
@ -411,8 +410,6 @@ void bkp_session_delete_apply_schedule_download(struct apply_schedule_download *
|
|||
{
|
||||
struct search_keywords keys[9];
|
||||
char delay[4][128];
|
||||
char schedule_time[128];
|
||||
char file_size[128];
|
||||
char maxretrie[2][128];
|
||||
int i;
|
||||
mxml_node_t *b;
|
||||
|
|
@ -572,7 +569,6 @@ void bkp_session_delete_schedule_download(struct schedule_download *pschedule_do
|
|||
{
|
||||
struct search_keywords keys[16];
|
||||
char delay[4][128];
|
||||
char schedule_time[128];
|
||||
char file_size[128];
|
||||
char maxretrie[2][128];
|
||||
int i;
|
||||
|
|
@ -1224,8 +1220,6 @@ void load_apply_schedule_download(mxml_node_t *tree,struct cwmp *cwmp)
|
|||
{
|
||||
mxml_node_t *b = tree, *c;
|
||||
struct apply_schedule_download *download_request = NULL;
|
||||
struct list_head *ilist = NULL;
|
||||
struct apply_schedule_download *idownload_request = NULL;
|
||||
|
||||
download_request = calloc(1,sizeof(struct apply_schedule_download));
|
||||
|
||||
|
|
@ -1445,8 +1439,6 @@ void load_change_du_state(mxml_node_t *tree,struct cwmp *cwmp)
|
|||
{
|
||||
mxml_node_t *b = tree, *c, *d;
|
||||
struct change_du_state *change_du_state_request = NULL;
|
||||
struct list_head *ilist = NULL;
|
||||
struct change_du_state *ichange_du_state_request = NULL;
|
||||
struct operations *elem;
|
||||
|
||||
change_du_state_request = calloc(1,sizeof(struct change_du_state));
|
||||
|
|
@ -1687,8 +1679,6 @@ void load_du_state_change_complete (mxml_node_t *tree,struct cwmp *cwmp)
|
|||
{
|
||||
mxml_node_t *b = tree, *c, *d;
|
||||
struct du_state_change_complete *du_state_change_complete_request = NULL;
|
||||
struct list_head *ilist = NULL;
|
||||
struct change_du_state *idu_state_change_complete_request = NULL;
|
||||
struct opresult *elem;
|
||||
|
||||
du_state_change_complete_request = calloc(1,sizeof(struct du_state_change_complete));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ icwmpd_CFLAGS = \
|
|||
$(LIBUBOX_CFLAGS) \
|
||||
$(LIBUBUS_CFLAGS) \
|
||||
$(MICROXML_CFLAGS) \
|
||||
$(LIBCURL_CFLAGS)
|
||||
$(LIBCURL_CFLAGS) \
|
||||
-Wall
|
||||
|
||||
icwmpd_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
|
|
@ -83,7 +84,8 @@ icwmp_tr098d_CFLAGS = \
|
|||
$(LIBUBOX_CFLAGS) \
|
||||
$(LIBUBUS_CFLAGS) \
|
||||
$(MICROXML_CFLAGS) \
|
||||
$(LIBCURL_CFLAGS)
|
||||
$(LIBCURL_CFLAGS) \
|
||||
-Wall
|
||||
|
||||
icwmp_tr098d_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
|
|
@ -113,29 +115,41 @@ icwmp_tr098d_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
|
|||
icwmp_tr098d_CFLAGS+=-DTR098
|
||||
icwmp_tr098d_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
|
||||
|
||||
CWMP_BKP_FILE=/etc/icwmpd/.icwmpd_backup_session.xml
|
||||
icwmp_tr098d_CFLAGS+=-DCWMP_BKP_FILE=\"$(CWMP_BKP_FILE)\"
|
||||
icwmp_tr098d_CFLAGS+=-I../inc
|
||||
endif
|
||||
|
||||
if ICWMP_ACTIVE_NOTIF
|
||||
bin_PROGRAMS += icwmp_notifd
|
||||
|
||||
icwmp_notifd_SOURCES = \
|
||||
../icwmp-notifd/icwmp-notifd.c \
|
||||
../icwmp-notifd/ubus.c \
|
||||
../icwmp-notifd/icwmp-notifd.c \
|
||||
../icwmp-notifd/ubus.c \
|
||||
../icwmp-notifd/uci.c
|
||||
|
||||
icwmp_notifd_LDADD = \
|
||||
$(AM_LIBS) \
|
||||
$(LIBUCI_LIBS) \
|
||||
$(LIBUBOX_LIBS) \
|
||||
-lbbfdm \
|
||||
-lubus \
|
||||
-ljson-c \
|
||||
-lblobmsg_json
|
||||
|
||||
icwmp_notifd_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
$(LIBUCI_CFLAGS) \
|
||||
$(LIBUBOX_CFLAGS) \
|
||||
$(LIBUBUS_CFLAGS) \
|
||||
$(LIBJSON_LIBS) \
|
||||
$(LBLOBMSG_LIBS) \
|
||||
-Wall
|
||||
|
||||
icwmp_notifd_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
$(LIBUCI_LDFLAGS) \
|
||||
$(LIBUBOX_LDFLAGS)
|
||||
$(LIBUBOX_LDFLAGS) \
|
||||
$(LIBUBUS_LIBS) \
|
||||
$(LIBJSON_LIBS) \
|
||||
$(LBLOBMSG_LIBS)
|
||||
|
||||
icwmp_notifd_LDADD = \
|
||||
$(AM_LIBS) \
|
||||
$(LIBUCI_LIBS) \
|
||||
$(LIBUBOX_LIBS) \
|
||||
$(LIBUBUS_LIBS) \
|
||||
$(LIBJSON_LIBS) \
|
||||
$(LBLOBMSG_LIBS) \
|
||||
-lbbfdm
|
||||
endif
|
||||
|
|
|
|||
35
config.c
35
config.c
|
|
@ -298,15 +298,12 @@ int uci_add_list_value(char *cmd)
|
|||
|
||||
static int cwmp_package_commit(struct uci_context *c,char *tuple)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
struct uci_ptr ptr;
|
||||
|
||||
if (uci_lookup_ptr(c, &ptr, tuple, true) != UCI_OK) {
|
||||
return CWMP_GEN_ERR;
|
||||
}
|
||||
|
||||
e = ptr.last;
|
||||
|
||||
if (uci_commit(c, &ptr.p, false) != UCI_OK)
|
||||
{
|
||||
return CWMP_GEN_ERR;
|
||||
|
|
@ -996,7 +993,6 @@ int global_env_init (int argc, char** argv, struct env *env)
|
|||
unsigned int dminstancemode =INSTANCE_MODE_NUMBER;
|
||||
unsigned int dmamendment = AMD_2;
|
||||
unsigned int dmtype = DM_CWMP;
|
||||
struct dmctx dmctx = {0};
|
||||
|
||||
char *file = NULL;
|
||||
char *upnpuser;
|
||||
|
|
@ -1139,12 +1135,12 @@ int global_conf_init (struct config *conf)
|
|||
int error;
|
||||
|
||||
pthread_mutex_lock (&mutex_config_load);
|
||||
if (error = get_global_config(conf))
|
||||
if ((error = get_global_config(conf)))
|
||||
{
|
||||
pthread_mutex_unlock (&mutex_config_load);
|
||||
return error;
|
||||
}
|
||||
if (error = check_global_config(conf))
|
||||
if ((error = check_global_config(conf)))
|
||||
{
|
||||
pthread_mutex_unlock (&mutex_config_load);
|
||||
return error;
|
||||
|
|
@ -1180,13 +1176,11 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
{
|
||||
int error;
|
||||
struct env env;
|
||||
struct config *conf;
|
||||
conf = &(cwmp->conf);
|
||||
|
||||
memset(&env,0,sizeof(struct env));
|
||||
if(error = global_env_init (argc, argv, &env))
|
||||
{
|
||||
if ((error = global_env_init (argc, argv, &env)))
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Only One instance should run*/
|
||||
cwmp->pid_file = open("/var/run/icwmpd.pid", O_CREAT | O_RDWR, 0666);
|
||||
fcntl(cwmp->pid_file, F_SETFD, fcntl(cwmp->pid_file, F_GETFD) | FD_CLOEXEC);
|
||||
|
|
@ -1208,10 +1202,10 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
pthread_mutex_init(&cwmp->mutex_handle_notify, NULL);
|
||||
memcpy(&(cwmp->env),&env,sizeof(struct env));
|
||||
INIT_LIST_HEAD(&(cwmp->head_session_queue));
|
||||
if(error = global_conf_init(&(cwmp->conf)))
|
||||
{
|
||||
|
||||
if ((error = global_conf_init(&(cwmp->conf))))
|
||||
return error;
|
||||
}
|
||||
|
||||
cwmp_get_deviceid(cwmp);
|
||||
dm_entry_load_enabled_notify(DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode, add_list_value_change, send_active_value_change);
|
||||
return CWMP_OK;
|
||||
|
|
@ -1220,14 +1214,13 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
int cwmp_config_reload(struct cwmp *cwmp)
|
||||
{
|
||||
int error;
|
||||
struct config *conf;
|
||||
conf = &(cwmp->conf);
|
||||
memset(&cwmp->env,0,sizeof(struct env));
|
||||
memset(&cwmp->conf,0,sizeof(struct config));
|
||||
if(error = global_conf_init(&(cwmp->conf)))
|
||||
{
|
||||
|
||||
memset(&cwmp->env, 0, sizeof(struct env));
|
||||
memset(&cwmp->conf, 0, sizeof(struct config));
|
||||
|
||||
if ((error = global_conf_init(&(cwmp->conf))))
|
||||
return error;
|
||||
}
|
||||
|
||||
dm_entry_reload_enabled_notify(DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
|
|
|||
15
configure.ac
15
configure.ac
|
|
@ -23,21 +23,6 @@ AC_ARG_ENABLE(dummy_mode, [AS_HELP_STRING([--enable-dummy-mode], [enable dummy m
|
|||
AC_ARG_ENABLE(icwmp_tr098, [AS_HELP_STRING([--enable-icwmp_tr098], [enable icwmp tr098])], AC_DEFINE(ICWMP_TR098),)
|
||||
AM_CONDITIONAL([ICWMP_TR098],[test "x$enable_icwmp_tr098" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(icwmp_xmpp, [AS_HELP_STRING([--enable-icwmp_xmpp], [enable icwmp xmpp])], AC_DEFINE(ICWMP_XMPP),)
|
||||
AM_CONDITIONAL([ICWMP_XMPP],[test "x$enable_icwmp_xmpp" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(icwmp_stun, [AS_HELP_STRING([--enable-icwmp_stun], [enable icwmp stun])], AC_DEFINE(ICWMP_STUN),)
|
||||
AM_CONDITIONAL([ICWMP_STUN],[test "x$enable_icwmp_stun" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(icwmp_udpechoserver, [AS_HELP_STRING([--enable-icwmp_udpechoserver], [enable icwmp udpechoserver])], AC_DEFINE(ICWMP_UDPECHOSERVER),)
|
||||
AM_CONDITIONAL([ICWMP_UDPECHOSERVER],[test "x$enable_icwmp_udpechoserver" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(icwmp_twamp, [AS_HELP_STRING([--enable-icwmp_twamp], [enable icwmp twamp])], AC_DEFINE(ICWMP_TWAMP),)
|
||||
AM_CONDITIONAL([ICWMP_TWAMP],[test "x$enable_icwmp_twamp" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(icwmp_bulkdata, [AS_HELP_STRING([--enable-icwmp_bulkdata], [enable icwmp bulkdata])], AC_DEFINE(ICWMP_BULKDATA),)
|
||||
AM_CONDITIONAL([ICWMP_BULKDATA],[test "x$enable_icwmp_bulkdata" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(icwmp_notifd, [AS_HELP_STRING([--enable-icwmp_notifd], [enable icwmp icwmp_notifd])], AC_DEFINE(ICWMP_ACTIVE_NOTIF),)
|
||||
AM_CONDITIONAL([ICWMP_ACTIVE_NOTIF],[test "x$enable_icwmp_notifd" = "xyes"])
|
||||
|
||||
|
|
|
|||
221
cwmp.c
221
cwmp.c
|
|
@ -26,7 +26,7 @@
|
|||
#include "diagnostic.h"
|
||||
#include "config.h"
|
||||
|
||||
struct cwmp cwmp_main = {0};
|
||||
struct cwmp cwmp_main = {0};
|
||||
char *commandKey = NULL;
|
||||
|
||||
int cwmp_dm_ctx_init(struct cwmp *cwmp, struct dmctx *ctx)
|
||||
|
|
@ -63,6 +63,7 @@ int cwmp_get_int_event_code(char *code)
|
|||
|
||||
else if (code && code[0] == '8')
|
||||
return EVENT_IDX_8DIAGNOSTICS_COMPLETE;
|
||||
|
||||
else
|
||||
return EVENT_IDX_6CONNECTION_REQUEST;
|
||||
}
|
||||
|
|
@ -178,11 +179,11 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
|||
|
||||
cwmp_prepare_value_change(cwmp, session);
|
||||
|
||||
if (error = cwmp_move_session_to_session_send (cwmp, session))
|
||||
{
|
||||
if ((error = cwmp_move_session_to_session_send (cwmp, session))) {
|
||||
CWMP_LOG(EMERG,"FATAL error in the mutex process in the session scheduler!");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cwmp->session_status.last_end_time = 0;
|
||||
cwmp->session_status.last_start_time = time(NULL);
|
||||
cwmp->session_status.last_status = SESSION_RUNNING;
|
||||
|
|
@ -192,11 +193,13 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
|||
if (access(fc_cookies, F_OK) != -1)
|
||||
remove(fc_cookies);
|
||||
CWMP_LOG (INFO,"Start session");
|
||||
|
||||
uci_get_value(UCI_CPE_EXEC_DOWNLOAD, &exec_download);
|
||||
if(strcmp(exec_download, "1") == 0){
|
||||
if (strcmp(exec_download, "1") == 0) {
|
||||
CWMP_LOG(INFO, "Firmware downloaded and applied successfully");
|
||||
uci_set_value("cwmp.cpe.exec_download=0");
|
||||
}
|
||||
|
||||
error = cwmp_schedule_rpc (cwmp,session);
|
||||
CWMP_LOG (INFO,"End session");
|
||||
if (session->error == CWMP_RETRY_SESSION && (!list_empty(&(session->head_event_container)) || (list_empty(&(session->head_event_container)) && cwmp->cwmp_cr_event == 0)) )
|
||||
|
|
@ -229,28 +232,28 @@ int cwmp_rpc_cpe_handle_message (struct session *session, struct rpc *rpc_cpe)
|
|||
{
|
||||
if (xml_prepare_msg_out(session))
|
||||
return -1;
|
||||
|
||||
if (rpc_cpe_methods[rpc_cpe->type].handler(session, rpc_cpe))
|
||||
return -1;
|
||||
|
||||
if (xml_set_cwmp_id_rpc_cpe(session))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session)
|
||||
{
|
||||
struct list_head *ilist;
|
||||
struct rpc *rpc_acs, *rpc_cpe;
|
||||
int error=0,e;
|
||||
struct list_head *ilist;
|
||||
struct rpc *rpc_acs, *rpc_cpe;
|
||||
|
||||
if (http_client_init(cwmp)) {
|
||||
CWMP_LOG(INFO, "Initializing http client failed");
|
||||
goto retry;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
list_for_each(ilist, &(session->head_rpc_acs))
|
||||
{
|
||||
while (1) {
|
||||
list_for_each(ilist, &(session->head_rpc_acs)) {
|
||||
rpc_acs = list_entry (ilist, struct rpc, list);
|
||||
if (!rpc_acs->type)
|
||||
goto retry;
|
||||
|
|
@ -293,8 +296,7 @@ int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session)
|
|||
if (xml_handle_message(session))
|
||||
goto retry;
|
||||
|
||||
while (session->head_rpc_cpe.next != &(session->head_rpc_cpe))
|
||||
{
|
||||
while (session->head_rpc_cpe.next != &(session->head_rpc_cpe)) {
|
||||
rpc_cpe = list_entry (session->head_rpc_cpe.next, struct rpc, list);
|
||||
if (!rpc_cpe->type)
|
||||
goto retry;
|
||||
|
|
@ -329,7 +331,6 @@ next:
|
|||
MXML_DELETE(session->tree_out);
|
||||
}
|
||||
|
||||
success:
|
||||
session->error = CWMP_OK;
|
||||
goto end;
|
||||
|
||||
|
|
@ -349,8 +350,7 @@ end:
|
|||
int cwmp_move_session_to_session_send (struct cwmp *cwmp, struct session *session)
|
||||
{
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
if (cwmp->session_send != NULL)
|
||||
{
|
||||
if (cwmp->session_send != NULL) {
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
return CWMP_MUTEX_ERR;
|
||||
}
|
||||
|
|
@ -454,49 +454,43 @@ int cwmp_move_session_to_session_queue (struct cwmp *cwmp, struct session *sessi
|
|||
|
||||
int cwmp_session_destructor (struct cwmp *cwmp, struct session *session)
|
||||
{
|
||||
struct rpc *rpc;
|
||||
struct session_end_func *session_end_func;
|
||||
struct rpc *rpc;
|
||||
|
||||
while (session->head_rpc_acs.next != &(session->head_rpc_acs))
|
||||
{
|
||||
while (session->head_rpc_acs.next != &(session->head_rpc_acs)) {
|
||||
rpc = list_entry(session->head_rpc_acs.next, struct rpc, list);
|
||||
if (rpc_acs_methods[rpc->type].extra_clean != NULL)
|
||||
rpc_acs_methods[rpc->type].extra_clean(session,rpc);
|
||||
cwmp_session_rpc_destructor(rpc);
|
||||
}
|
||||
while (session->head_rpc_cpe.next != &(session->head_rpc_cpe))
|
||||
{
|
||||
|
||||
while (session->head_rpc_cpe.next != &(session->head_rpc_cpe)) {
|
||||
rpc = list_entry(session->head_rpc_cpe.next, struct rpc, list);
|
||||
cwmp_session_rpc_destructor(rpc);
|
||||
}
|
||||
|
||||
if (session->list.next != NULL && session->list.prev != NULL)
|
||||
{
|
||||
list_del (&(session->list));
|
||||
}
|
||||
|
||||
free (session);
|
||||
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct session *cwmp_add_queue_session (struct cwmp *cwmp)
|
||||
{
|
||||
struct session *session;
|
||||
struct rpc *rpc_acs;
|
||||
struct session *session = NULL;
|
||||
struct rpc *rpc_acs;
|
||||
|
||||
session = calloc (1,sizeof(struct session));
|
||||
if (session==NULL)
|
||||
{
|
||||
session = calloc(1, sizeof(struct session));
|
||||
if (session == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list_add_tail (&(session->list), &(cwmp->head_session_queue));
|
||||
INIT_LIST_HEAD (&(session->head_event_container));
|
||||
INIT_LIST_HEAD (&(session->head_rpc_acs));
|
||||
INIT_LIST_HEAD (&(session->head_rpc_cpe));
|
||||
if ((rpc_acs = cwmp_add_session_rpc_acs_head(session, RPC_ACS_INFORM)) == NULL)
|
||||
{
|
||||
free (session);
|
||||
if ((rpc_acs = cwmp_add_session_rpc_acs_head(session, RPC_ACS_INFORM)) == NULL) {
|
||||
FREE(session);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -507,16 +501,14 @@ int run_session_end_func (struct session *session)
|
|||
{
|
||||
apply_end_session();
|
||||
|
||||
if (end_session_flag & END_SESSION_EXTERNAL_ACTION)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_EXTERNAL_ACTION) {
|
||||
CWMP_LOG (INFO,"Executing external commands: end session request");
|
||||
external_init();
|
||||
external_simple("end_session", NULL, 0);
|
||||
external_exit();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_FACTORY_RESET)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_FACTORY_RESET) {
|
||||
CWMP_LOG (INFO,"Executing factory reset: end session request");
|
||||
external_init();
|
||||
external_simple("factory_reset", NULL, 0);
|
||||
|
|
@ -524,47 +516,38 @@ int run_session_end_func (struct session *session)
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
if (end_session_flag & END_SESSION_IPPING_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_IPPING_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing ippingdiagnostic: end session request");
|
||||
cwmp_ip_ping_diagnostic();
|
||||
}
|
||||
|
||||
#ifndef TR098
|
||||
if (end_session_flag & END_SESSION_DOWNLOAD_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_DOWNLOAD_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing download diagnostic: end session request");
|
||||
cwmp_start_diagnostic(DOWNLOAD_DIAGNOSTIC);
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_UPLOAD_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_UPLOAD_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing upload diagnostic: end session request");
|
||||
cwmp_start_diagnostic(UPLOAD_DIAGNOSTIC);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (end_session_flag & END_SESSION_REBOOT)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_REBOOT) {
|
||||
CWMP_LOG (INFO,"Executing Reboot: end session request");
|
||||
external_init();
|
||||
external_simple("reboot", commandKey, 0);
|
||||
if(commandKey)
|
||||
free(commandKey);
|
||||
FREE(commandKey);
|
||||
external_exit();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
if (end_session_flag & END_SESSION_RELOAD)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_RELOAD) {
|
||||
CWMP_LOG (INFO,"Config reload: end session request");
|
||||
cwmp_apply_acs_changes();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_X_FACTORY_RESET_SOFT)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_X_FACTORY_RESET_SOFT) {
|
||||
CWMP_LOG (INFO,"Executing factory reset soft: end session request");
|
||||
external_init();
|
||||
external_simple("factory_reset_soft", NULL, 0);
|
||||
|
|
@ -572,35 +555,28 @@ int run_session_end_func (struct session *session)
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_NSLOOKUP_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_NSLOOKUP_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing nslookupdiagnostic: end session request");
|
||||
cwmp_nslookup_diagnostic();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_TRACEROUTE_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_TRACEROUTE_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing traceroutediagnostic: end session request");
|
||||
cwmp_traceroute_diagnostic();
|
||||
}
|
||||
|
||||
|
||||
if (end_session_flag & END_SESSION_UDPECHO_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_UDPECHO_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing udpechodiagnostic: end session request");
|
||||
cwmp_udp_echo_diagnostic();
|
||||
}
|
||||
|
||||
|
||||
if (end_session_flag & END_SESSION_SERVERSELECTION_DIAGNOSTIC)
|
||||
{
|
||||
if (end_session_flag & END_SESSION_SERVERSELECTION_DIAGNOSTIC) {
|
||||
CWMP_LOG (INFO,"Executing serverselectiondiagnostic: end session request");
|
||||
cwmp_serverselection_diagnostic();
|
||||
}
|
||||
|
||||
dm_entry_restart_services();
|
||||
|
||||
|
||||
end_session_flag = 0;
|
||||
|
||||
return CWMP_OK;
|
||||
|
|
@ -615,32 +591,32 @@ void add_list_value_change(char *param_name, char *param_data, char *param_type)
|
|||
|
||||
void send_active_value_change(void)
|
||||
{
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct event_container *event_container;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct event_container *event_container;
|
||||
|
||||
pthread_mutex_lock(&(cwmp->mutex_session_queue));
|
||||
event_container = cwmp_add_event_container(cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_queue));
|
||||
return;
|
||||
}
|
||||
|
||||
cwmp_save_event_container(cwmp,event_container);
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_queue));
|
||||
pthread_cond_signal(&(cwmp->threshold_session_send));
|
||||
return;
|
||||
}
|
||||
|
||||
int cwmp_apply_acs_changes ()
|
||||
int cwmp_apply_acs_changes(void)
|
||||
{
|
||||
int error;
|
||||
if (error = cwmp_config_reload(&cwmp_main))
|
||||
{
|
||||
|
||||
if ((error = cwmp_config_reload(&cwmp_main)))
|
||||
return error;
|
||||
}
|
||||
if (error = cwmp_root_cause_events(&cwmp_main))
|
||||
{
|
||||
|
||||
if ((error = cwmp_root_cause_events(&cwmp_main)))
|
||||
return error;
|
||||
}
|
||||
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
|
|
@ -697,40 +673,35 @@ int cwmp_exit(void)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
int error;
|
||||
pthread_t periodic_event_thread;
|
||||
pthread_t handle_notify_thread;
|
||||
pthread_t scheduleInform_thread;
|
||||
pthread_t change_du_state_thread;
|
||||
pthread_t download_thread;
|
||||
pthread_t schedule_download_thread;
|
||||
pthread_t apply_schedule_download_thread;
|
||||
pthread_t upload_thread;
|
||||
pthread_t ubus_thread;
|
||||
pthread_t http_cr_server_thread;
|
||||
struct sigaction act = {0};
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
int error;
|
||||
pthread_t periodic_event_thread;
|
||||
pthread_t handle_notify_thread;
|
||||
pthread_t scheduleInform_thread;
|
||||
pthread_t change_du_state_thread;
|
||||
pthread_t download_thread;
|
||||
pthread_t schedule_download_thread;
|
||||
pthread_t apply_schedule_download_thread;
|
||||
pthread_t upload_thread;
|
||||
pthread_t ubus_thread;
|
||||
pthread_t http_cr_server_thread;
|
||||
struct sigaction act = {0};
|
||||
|
||||
#ifndef TR098
|
||||
set_bbfdatamodel_type(BBFDM_CWMP); // To show only CWMP parameters
|
||||
#endif
|
||||
|
||||
if (error = cwmp_init(argc, argv, cwmp))
|
||||
{
|
||||
if ((error = cwmp_init(argc, argv, cwmp)))
|
||||
return error;
|
||||
}
|
||||
|
||||
CWMP_LOG(INFO,"STARTING ICWMP with PID :%d", getpid());
|
||||
cwmp->start_time = time(NULL);
|
||||
|
||||
if (error = cwmp_init_backup_session(cwmp, NULL, ALL))
|
||||
{
|
||||
if ((error = cwmp_init_backup_session(cwmp, NULL, ALL)))
|
||||
return error;
|
||||
}
|
||||
|
||||
if (error = cwmp_root_cause_events(cwmp))
|
||||
{
|
||||
if ((error = cwmp_root_cause_events(cwmp)))
|
||||
return error;
|
||||
}
|
||||
|
||||
http_server_init();
|
||||
|
||||
|
|
@ -739,55 +710,45 @@ int main(int argc, char **argv)
|
|||
sigaction(SIGTERM, &act, 0);
|
||||
|
||||
error = pthread_create(&http_cr_server_thread, NULL, &thread_http_cr_server_listen, NULL);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the http connection request server thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the ubus thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&periodic_event_thread, NULL, &thread_event_periodic, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the periodic event thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&handle_notify_thread, NULL, &thread_handle_notify, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the handle notify thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&scheduleInform_thread, NULL, &thread_cwmp_rpc_cpe_scheduleInform, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the scheduled inform thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&download_thread, NULL, &thread_cwmp_rpc_cpe_download, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the download thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&change_du_state_thread, NULL, &thread_cwmp_rpc_cpe_change_du_state, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the state change thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&schedule_download_thread, NULL, &thread_cwmp_rpc_cpe_schedule_download, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the schedule download thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&apply_schedule_download_thread, NULL, &thread_cwmp_rpc_cpe_apply_schedule_download, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the schedule download thread!");
|
||||
}
|
||||
|
||||
error = pthread_create(&upload_thread, NULL, &thread_cwmp_rpc_cpe_upload, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the download thread!");
|
||||
}
|
||||
|
||||
cwmp_schedule_session(cwmp);
|
||||
|
||||
pthread_join(ubus_thread, NULL);
|
||||
|
|
|
|||
14
diagnostic.c
14
diagnostic.c
|
|
@ -87,13 +87,13 @@ static int icwmpd_cmd_no_wait(char *cmd, int n, ...)
|
|||
{
|
||||
va_list arg;
|
||||
int i, pid;
|
||||
static int dmcmd_pfds[2];
|
||||
char *argv[n+2];
|
||||
static char sargv[4][128];
|
||||
|
||||
argv[0] = cmd;
|
||||
va_start(arg,n);
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
|
||||
va_start(arg, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
strcpy(sargv[i], va_arg(arg, char*));
|
||||
argv[i+1] = sargv[i];
|
||||
}
|
||||
|
|
@ -109,6 +109,7 @@ static int icwmpd_cmd_no_wait(char *cmd, int n, ...)
|
|||
exit(ESRCH);
|
||||
} else if (pid < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -124,13 +125,12 @@ int cwmp_start_diagnostic(int diagnostic_type)
|
|||
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC) {
|
||||
uci_get_state_value("cwmp.@downloaddiagnostic[0].url", &url);
|
||||
uci_get_state_value("cwmp.@downloaddiagnostic[0].device", &interface);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
uci_get_state_value("cwmp.@uploaddiagnostic[0].url", &url);
|
||||
uci_get_state_value("cwmp.@uploaddiagnostic[0].TestFileLength", &size);
|
||||
uci_get_state_value("cwmp.@uploaddiagnostic[0].device", &interface);
|
||||
}
|
||||
|
||||
if( url == NULL || ((url != NULL) && (strcmp(url,"")==0))
|
||||
|| ((strncmp(url,DOWNLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_PROTOCOL_FTP))!=0) &&
|
||||
(strstr(url,"@") != NULL && strncmp(url,DOWNLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_PROTOCOL_HTTP)) == 0))
|
||||
|
|
|
|||
220
event.c
220
event.c
|
|
@ -62,24 +62,19 @@ const struct EVENT_CONST_STRUCT EVENT_CONST [] = {
|
|||
|
||||
void cwmp_save_event_container (struct cwmp *cwmp,struct event_container *event_container)
|
||||
{
|
||||
struct list_head *ilist;
|
||||
struct dm_parameter *dm_parameter;
|
||||
char section[256];
|
||||
mxml_node_t *b;
|
||||
struct list_head *ilist;
|
||||
struct dm_parameter *dm_parameter;
|
||||
mxml_node_t *b;
|
||||
|
||||
if (EVENT_CONST[event_container->code].RETRY & EVENT_RETRY_AFTER_REBOOT)
|
||||
{
|
||||
if (EVENT_CONST[event_container->code].RETRY & EVENT_RETRY_AFTER_REBOOT) {
|
||||
b = bkp_session_insert_event(event_container->code, event_container->command_key, event_container->id, "queue");
|
||||
|
||||
list_for_each(ilist,&(event_container->head_dm_parameter))
|
||||
{
|
||||
list_for_each(ilist,&(event_container->head_dm_parameter)) {
|
||||
dm_parameter = list_entry(ilist, struct dm_parameter, list);
|
||||
bkp_session_insert_parameter(b, dm_parameter->name);
|
||||
}
|
||||
bkp_session_save();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_code, char *command_key)
|
||||
|
|
@ -278,15 +273,15 @@ void cwmp_lwnotification()
|
|||
FREE(msg_out);
|
||||
}
|
||||
|
||||
void cwmp_add_notification_min(void) {
|
||||
void cwmp_add_notification_min(void)
|
||||
{
|
||||
int fault, iscopy;
|
||||
FILE *fp;
|
||||
char buf[512];
|
||||
char *parameter, *notification = NULL, *value = NULL, *jval;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct dm_parameter *dm_parameter;
|
||||
struct dmctx dmctx = {0};
|
||||
bool initiate = false;
|
||||
|
||||
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
|
||||
|
||||
|
|
@ -296,7 +291,6 @@ void cwmp_add_notification_min(void) {
|
|||
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
|
||||
initiate = true;
|
||||
int len = strlen(buf);
|
||||
if (len)
|
||||
buf[len-1] = '\0';
|
||||
|
|
@ -337,13 +331,11 @@ void cwmp_add_notification(void)
|
|||
FILE *fp;
|
||||
char buf[512];
|
||||
char *parameter, *notification = NULL, *value = NULL, *jval;
|
||||
struct event_container *event_container;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct dm_enabled_notify *p;
|
||||
struct dm_parameter *dm_parameter;
|
||||
struct dmctx dmctx = {0};
|
||||
struct config *conf;
|
||||
conf = &(cwmp->conf);
|
||||
struct config *conf = &(cwmp->conf);
|
||||
bool isactive = false;
|
||||
bool initiate = false;
|
||||
bool lw_isactive = false;
|
||||
|
|
@ -457,11 +449,9 @@ int cwmp_root_cause_event_boot (struct cwmp *cwmp)
|
|||
}
|
||||
int event_remove_all_event_container(struct session *session, int rem_from)
|
||||
{
|
||||
struct event_container *event_container;
|
||||
struct dm_parameter *dm_parameter;
|
||||
struct event_container *event_container;
|
||||
|
||||
while (session->head_event_container.next!=&(session->head_event_container))
|
||||
{
|
||||
while (session->head_event_container.next!=&(session->head_event_container)) {
|
||||
event_container = list_entry(session->head_event_container.next, struct event_container, list);
|
||||
bkp_session_delete_event(event_container->id, rem_from?"send":"queue");
|
||||
if (event_container->code == EVENT_IDX_1BOOT && rem_from == RPC_SEND) {
|
||||
|
|
@ -478,12 +468,10 @@ int event_remove_all_event_container(struct session *session, int rem_from)
|
|||
|
||||
int event_remove_noretry_event_container(struct session *session, struct cwmp *cwmp)
|
||||
{
|
||||
struct event_container *event_container;
|
||||
struct dm_parameter *dm_parameter;
|
||||
|
||||
struct event_container *event_container;
|
||||
struct list_head *ilist, *q;
|
||||
list_for_each_safe(ilist,q,&(session->head_event_container))
|
||||
{
|
||||
|
||||
list_for_each_safe(ilist,q,&(session->head_event_container)) {
|
||||
event_container = list_entry(ilist, struct event_container, list);
|
||||
if (EVENT_CONST[event_container->code].RETRY == 0) {
|
||||
free (event_container->command_key);
|
||||
|
|
@ -491,40 +479,34 @@ int event_remove_noretry_event_container(struct session *session, struct cwmp *c
|
|||
list_del(&(event_container->list));
|
||||
free (event_container);
|
||||
}
|
||||
|
||||
if (EVENT_CONST[event_container->code].CODE[0] == '6')
|
||||
{
|
||||
cwmp->cwmp_cr_event = 1;
|
||||
}
|
||||
}
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
|
||||
{
|
||||
char *acsurl = NULL;
|
||||
int error,cmp=0;
|
||||
struct event_container *event_container;
|
||||
struct session *session;
|
||||
char *acsurl = NULL;
|
||||
int cmp = 0;
|
||||
struct event_container *event_container;
|
||||
struct session *session;
|
||||
|
||||
error = cwmp_load_saved_session(cwmp, &acsurl, ACS);
|
||||
cwmp_load_saved_session(cwmp, &acsurl, ACS);
|
||||
|
||||
if(acsurl == NULL)
|
||||
{
|
||||
if (acsurl == NULL)
|
||||
save_acs_bkp_config (cwmp);
|
||||
}
|
||||
|
||||
if (acsurl == NULL || ((acsurl != NULL)&&(cmp = strcmp(cwmp->conf.acsurl,acsurl))))
|
||||
{
|
||||
if (acsurl == NULL || ((acsurl != NULL)&&(cmp = strcmp(cwmp->conf.acsurl,acsurl)))) {
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
if (cwmp->head_event_container!=NULL && cwmp->head_session_queue.next!=&(cwmp->head_session_queue))
|
||||
{
|
||||
if (cwmp->head_event_container!=NULL && cwmp->head_session_queue.next!=&(cwmp->head_session_queue)) {
|
||||
session = list_entry(cwmp->head_event_container,struct session, head_event_container);
|
||||
event_remove_all_event_container (session,RPC_QUEUE);
|
||||
}
|
||||
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_0BOOTSTRAP, "");
|
||||
FREE(acsurl);
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
return CWMP_MEM_ERR;
|
||||
}
|
||||
|
|
@ -539,12 +521,10 @@ int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
|
|||
FREE(acsurl);
|
||||
}
|
||||
|
||||
if (cmp)
|
||||
{
|
||||
if (cmp) {
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
return CWMP_MEM_ERR;
|
||||
}
|
||||
|
|
@ -650,25 +630,20 @@ int cwmp_root_cause_dustatechangeComplete (struct cwmp *cwmp, struct du_state_ch
|
|||
|
||||
int cwmp_root_cause_getRPCMethod (struct cwmp *cwmp)
|
||||
{
|
||||
char acsurl[256];
|
||||
int error,cmp=0;
|
||||
struct event_container *event_container;
|
||||
struct session *session;
|
||||
struct event_container *event_container;
|
||||
struct session *session;
|
||||
|
||||
if (cwmp->env.periodic == CWMP_START_PERIODIC)
|
||||
{
|
||||
if (cwmp->env.periodic == CWMP_START_PERIODIC) {
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
cwmp->env.periodic = 0;
|
||||
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_2PERIODIC, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
return CWMP_MEM_ERR;
|
||||
}
|
||||
cwmp_save_event_container (cwmp,event_container);
|
||||
session = list_entry (cwmp->head_event_container, struct session,head_event_container);
|
||||
if(cwmp_add_session_rpc_acs(session, RPC_ACS_GET_RPC_METHODS) == NULL)
|
||||
{
|
||||
if (cwmp_add_session_rpc_acs(session, RPC_ACS_GET_RPC_METHODS) == NULL) {
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
return CWMP_MEM_ERR;
|
||||
}
|
||||
|
|
@ -682,8 +657,7 @@ void *thread_handle_notify(void *v)
|
|||
{
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
for(;;) {
|
||||
pthread_mutex_lock(&(cwmp->mutex_handle_notify));
|
||||
pthread_cond_wait(&(cwmp->threshold_handle_notify), &(cwmp->mutex_handle_notify));
|
||||
pthread_mutex_unlock(&(cwmp->mutex_handle_notify));
|
||||
|
|
@ -697,58 +671,51 @@ void *thread_handle_notify(void *v)
|
|||
|
||||
void *thread_event_periodic (void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
struct event_container *event_container;
|
||||
static int periodic_interval;
|
||||
static bool periodic_enable;
|
||||
static time_t periodic_time;
|
||||
static struct timespec periodic_timeout = {0, 0};
|
||||
time_t current_time;
|
||||
long int delta_time;
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
struct event_container *event_container;
|
||||
static int periodic_interval;
|
||||
static bool periodic_enable;
|
||||
static time_t periodic_time;
|
||||
static struct timespec periodic_timeout = {0, 0};
|
||||
time_t current_time;
|
||||
long int delta_time;
|
||||
|
||||
periodic_interval = cwmp->conf.period;
|
||||
periodic_enable = cwmp->conf.periodic_enable;
|
||||
periodic_time = cwmp->conf.time;
|
||||
periodic_interval = cwmp->conf.period;
|
||||
periodic_enable = cwmp->conf.periodic_enable;
|
||||
periodic_time = cwmp->conf.time;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
for(;;) {
|
||||
pthread_mutex_lock (&(cwmp->mutex_periodic));
|
||||
if (cwmp->conf.periodic_enable)
|
||||
{
|
||||
if (cwmp->conf.periodic_enable) {
|
||||
current_time = time(NULL);
|
||||
if(periodic_time != 0)
|
||||
{
|
||||
if (periodic_time != 0) {
|
||||
delta_time = (current_time - periodic_time) % periodic_interval;
|
||||
if (delta_time >= 0)
|
||||
periodic_timeout.tv_sec = current_time + periodic_interval - delta_time;
|
||||
else
|
||||
periodic_timeout.tv_sec = current_time - delta_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
periodic_timeout.tv_sec = current_time + periodic_interval;
|
||||
}
|
||||
cwmp->session_status.next_periodic = periodic_timeout.tv_sec;
|
||||
pthread_cond_timedwait(&(cwmp->threshold_periodic), &(cwmp->mutex_periodic), &periodic_timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cwmp->session_status.next_periodic = 0;
|
||||
pthread_cond_wait(&(cwmp->threshold_periodic), &(cwmp->mutex_periodic));
|
||||
}
|
||||
pthread_mutex_unlock (&(cwmp->mutex_periodic));
|
||||
if (periodic_interval != cwmp->conf.period || periodic_enable != cwmp->conf.periodic_enable || periodic_time != cwmp->conf.time)
|
||||
{
|
||||
periodic_enable = cwmp->conf.periodic_enable;
|
||||
periodic_interval = cwmp->conf.period;
|
||||
periodic_time = cwmp->conf.time;
|
||||
if (periodic_interval != cwmp->conf.period ||
|
||||
periodic_enable != cwmp->conf.periodic_enable ||
|
||||
periodic_time != cwmp->conf.time) {
|
||||
periodic_enable = cwmp->conf.periodic_enable;
|
||||
periodic_interval = cwmp->conf.period;
|
||||
periodic_time = cwmp->conf.time;
|
||||
continue;
|
||||
}
|
||||
CWMP_LOG(INFO,"Periodic thread: add periodic event in the queue");
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_2PERIODIC, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
continue;
|
||||
}
|
||||
|
|
@ -759,29 +726,30 @@ void *thread_event_periodic (void *v)
|
|||
return CWMP_OK;
|
||||
}
|
||||
|
||||
int cwmp_root_cause_event_periodic (struct cwmp *cwmp)
|
||||
int cwmp_root_cause_event_periodic(struct cwmp *cwmp)
|
||||
{
|
||||
static int period = 0;
|
||||
static bool periodic_enable = false;
|
||||
static time_t periodic_time = 0;
|
||||
char local_time[26] = {0};
|
||||
struct tm *t_tm;
|
||||
static int period = 0;
|
||||
static bool periodic_enable = false;
|
||||
static time_t periodic_time = 0;
|
||||
char local_time[27] = {0};
|
||||
struct tm *t_tm;
|
||||
|
||||
if (period==cwmp->conf.period && periodic_enable==cwmp->conf.periodic_enable && periodic_time==cwmp->conf.time)
|
||||
{
|
||||
if (period == cwmp->conf.period &&
|
||||
periodic_enable == cwmp->conf.periodic_enable &&
|
||||
periodic_time == cwmp->conf.time)
|
||||
return CWMP_OK;
|
||||
}
|
||||
pthread_mutex_lock (&(cwmp->mutex_periodic));
|
||||
period = cwmp->conf.period;
|
||||
|
||||
pthread_mutex_lock(&(cwmp->mutex_periodic));
|
||||
period = cwmp->conf.period;
|
||||
periodic_enable = cwmp->conf.periodic_enable;
|
||||
periodic_time = cwmp->conf.time;
|
||||
periodic_time = cwmp->conf.time;
|
||||
CWMP_LOG(INFO,periodic_enable?"Periodic event is enabled. Interval period = %ds":"Periodic event is disabled", period);
|
||||
|
||||
t_tm = localtime(&periodic_time);
|
||||
if (t_tm == NULL)
|
||||
return CWMP_GEN_ERR;
|
||||
|
||||
if(strftime(local_time, sizeof(local_time), "%FT%T%z", t_tm) == 0)
|
||||
if (strftime(local_time, sizeof(local_time), "%FT%T%z", t_tm) == 0)
|
||||
return CWMP_GEN_ERR;
|
||||
|
||||
local_time[25] = local_time[24];
|
||||
|
|
@ -815,26 +783,25 @@ void connection_request_ip_value_change(struct cwmp *cwmp, int version)
|
|||
{
|
||||
char *bip = NULL;
|
||||
struct event_container *event_container;
|
||||
int error;
|
||||
char *ip_version = (version == IPv6) ? strdup("ipv6") : strdup("ip");
|
||||
char *ip_value = (version == IPv6) ? strdup(cwmp->conf.ipv6) : strdup(cwmp->conf.ip);
|
||||
|
||||
error = (version == IPv6) ? cwmp_load_saved_session(cwmp, &bip, CR_IPv6): cwmp_load_saved_session(cwmp, &bip, CR_IP);
|
||||
if (version == IPv6)
|
||||
cwmp_load_saved_session(cwmp, &bip, CR_IPv6);
|
||||
else
|
||||
cwmp_load_saved_session(cwmp, &bip, CR_IP);
|
||||
|
||||
if(bip == NULL)
|
||||
{
|
||||
if (bip == NULL) {
|
||||
bkp_session_simple_insert_in_parent("connection_request", ip_version, ip_value);
|
||||
bkp_session_save();
|
||||
FREE(ip_version);
|
||||
FREE(ip_value);
|
||||
return;
|
||||
}
|
||||
if (strcmp(bip, ip_value)!=0)
|
||||
{
|
||||
if (strcmp(bip, ip_value) != 0) {
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
FREE(bip);
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
FREE(ip_version);
|
||||
|
|
@ -856,24 +823,20 @@ void connection_request_port_value_change(struct cwmp *cwmp, int port)
|
|||
{
|
||||
char *bport = NULL;
|
||||
struct event_container *event_container;
|
||||
int error;
|
||||
char bufport[32];
|
||||
char bufport[16];
|
||||
|
||||
sprintf(bufport, "%d", port);
|
||||
snprintf(bufport, sizeof(bufport), "%d", port);
|
||||
|
||||
error = cwmp_load_saved_session(cwmp, &bport, CR_PORT);
|
||||
cwmp_load_saved_session(cwmp, &bport, CR_PORT);
|
||||
|
||||
if(bport == NULL)
|
||||
{
|
||||
if (bport == NULL) {
|
||||
bkp_session_simple_insert_in_parent("connection_request", "port", bufport);
|
||||
bkp_session_save();
|
||||
return;
|
||||
}
|
||||
if (strcmp(bport, bufport)!=0)
|
||||
{
|
||||
if (strcmp(bport, bufport) != 0) {
|
||||
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
if (event_container == NULL) {
|
||||
FREE(bport);
|
||||
return;
|
||||
}
|
||||
|
|
@ -888,25 +851,18 @@ int cwmp_root_cause_events (struct cwmp *cwmp)
|
|||
{
|
||||
int error;
|
||||
|
||||
if (error = cwmp_root_cause_event_bootstrap(cwmp))
|
||||
{
|
||||
if ((error = cwmp_root_cause_event_bootstrap(cwmp)))
|
||||
return error;
|
||||
}
|
||||
|
||||
if (error = cwmp_root_cause_event_boot(cwmp))
|
||||
{
|
||||
if ((error = cwmp_root_cause_event_boot(cwmp)))
|
||||
return error;
|
||||
}
|
||||
|
||||
if (error = cwmp_root_cause_getRPCMethod(cwmp))
|
||||
{
|
||||
if ((error = cwmp_root_cause_getRPCMethod(cwmp)))
|
||||
return error;
|
||||
}
|
||||
|
||||
if (error = cwmp_root_cause_event_periodic(cwmp))
|
||||
{
|
||||
if ((error = cwmp_root_cause_event_periodic(cwmp)))
|
||||
return error;
|
||||
}
|
||||
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
10
external.c
10
external.c
|
|
@ -32,15 +32,19 @@
|
|||
#include "log.h"
|
||||
|
||||
static int pid;
|
||||
static json_object *json_obj_in;
|
||||
static int pfds_in[2], pfds_out[2];
|
||||
static FILE *fpipe;
|
||||
char *external_MethodFault = NULL;
|
||||
char *external_MethodName = NULL;
|
||||
char *external_MethodVersion = NULL;
|
||||
char *external_MethodUUID = NULL;
|
||||
char *external_MethodENV = NULL;
|
||||
|
||||
#ifdef DUMMY_MODE
|
||||
static char *fc_script = "./ext/openwrt/scripts/icwmp.sh";
|
||||
#else
|
||||
static char *fc_script = "/usr/sbin/icwmp";
|
||||
#endif
|
||||
|
||||
#define ICWMP_PROMPT "icwmp>"
|
||||
|
||||
void external_downloadFaultResp (char *fault_code)
|
||||
|
|
@ -109,7 +113,6 @@ void external_fetch_du_change_stateFaultResp(char **fault, char **version, char
|
|||
static void external_read_pipe_input(int (*external_handler)(char *msg))
|
||||
{
|
||||
char buf[1], *value = NULL, *c = NULL;
|
||||
int i=0, len;
|
||||
struct pollfd fd = {
|
||||
.fd = pfds_in[0],
|
||||
.events = POLLIN
|
||||
|
|
@ -141,7 +144,6 @@ static void external_read_pipe_input(int (*external_handler)(char *msg))
|
|||
static void external_write_pipe_output(const char *msg)
|
||||
{
|
||||
char *value = NULL;
|
||||
int i=0, len;
|
||||
|
||||
asprintf(&value, "%s\n", msg);
|
||||
if (write(pfds_out[1], value, strlen(value)) == -1) {
|
||||
|
|
|
|||
3
http.c
3
http.c
|
|
@ -274,10 +274,9 @@ error:
|
|||
|
||||
void http_success_cr()
|
||||
{
|
||||
struct event_container *event_container;
|
||||
CWMP_LOG(INFO,"Connection Request thread: add connection request event in the queue");
|
||||
pthread_mutex_lock (&(cwmp_main.mutex_session_queue));
|
||||
event_container = cwmp_add_event_container (&cwmp_main, EVENT_IDX_6CONNECTION_REQUEST, "");
|
||||
cwmp_add_event_container(&cwmp_main, EVENT_IDX_6CONNECTION_REQUEST, "");
|
||||
pthread_mutex_unlock (&(cwmp_main.mutex_session_queue));
|
||||
pthread_cond_signal(&(cwmp_main.threshold_session_send));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ char *polling_period = NULL;
|
|||
|
||||
static void polling_parse_icwmp_active_notifications()
|
||||
{
|
||||
struct uci_element *e, *tmp;
|
||||
struct uci_element *e;
|
||||
struct uci_list *list_notif;
|
||||
LIST_HEAD(listnotif);
|
||||
list_notif = &listnotif;
|
||||
|
|
@ -75,7 +75,7 @@ static void polling_parse_icwmp_active_notifications()
|
|||
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
|
||||
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
|
||||
if (strcmp(dm_parameter->data, value) != 0) {
|
||||
if (pubus_call("tr069", "notify", 0, UBUS_ARGS{}) < 0){
|
||||
if (pubus_call("tr069", "notify", 0, PUBUS_ARGS{}) < 0){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -96,8 +96,8 @@ static void polling_parse_icwmp_active_notifications()
|
|||
value = NULL;
|
||||
}
|
||||
}
|
||||
end:
|
||||
uloop_timeout_set(&active_notif_timer, polling_period && atoi(polling_period)?atoi(polling_period)*1000:5000);
|
||||
end:
|
||||
uloop_timeout_set(&active_notif_timer, polling_period && atoi(polling_period)?atoi(polling_period)*1000:5000);
|
||||
}
|
||||
|
||||
static void parse_icwmp_active_notifications(struct uloop_timeout *timeout) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct parg {
|
|||
char *val;
|
||||
};
|
||||
|
||||
#define UBUS_ARGS (struct parg[])
|
||||
#define PUBUS_ARGS (struct parg[])
|
||||
|
||||
int pubus_call(char *path, char *method, int argc, struct parg sarg[]);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@
|
|||
#include "uci.h"
|
||||
#include <stdio.h>
|
||||
|
||||
bool check_section_name(const char *str, bool name)
|
||||
#define UCI_OPTION_CPE_NOTIF_POLLING_PERIOD "cwmp.cpe.polling_period"
|
||||
|
||||
static bool check_section_name(const char *str, bool name)
|
||||
{
|
||||
if (!*str)
|
||||
return false;
|
||||
|
|
@ -59,33 +61,29 @@ lookup:
|
|||
|
||||
void load_uci_config(char **polling_period)
|
||||
{
|
||||
struct uci_context *c = uci_alloc_context();
|
||||
struct uci_ptr ptr;
|
||||
struct uci_context *c = uci_alloc_context();
|
||||
struct uci_ptr ptr;
|
||||
char *s;
|
||||
|
||||
s= strdup(UCI_OPTION_CPE_NOTIF_POLLING_PERIOD);
|
||||
s = strdup(UCI_OPTION_CPE_NOTIF_POLLING_PERIOD);
|
||||
|
||||
if (uci_lookup_ptr(c, &ptr, s, true) != UCI_OK)
|
||||
{
|
||||
if (uci_lookup_ptr(c, &ptr, s, true) != UCI_OK) {
|
||||
fprintf(stderr, "Error occurred in uci\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(ptr.flags & UCI_LOOKUP_COMPLETE)
|
||||
{
|
||||
if(ptr.flags & UCI_LOOKUP_COMPLETE) {
|
||||
|
||||
if (ptr.o==NULL || ptr.o->v.string==NULL)
|
||||
{
|
||||
fprintf(stderr, "icwmp_notifd.icwmp_notif.polling_period not found or empty value\n");
|
||||
uci_free_context(c);
|
||||
if (ptr.o == NULL || ptr.o->v.string == NULL) {
|
||||
fprintf(stderr, "cwmp.cpe.icwmp_notif.polling_period not found or empty value\n");
|
||||
*polling_period = NULL;
|
||||
goto end;
|
||||
}
|
||||
|
||||
*polling_period = strdup(ptr.o->v.string);
|
||||
|
||||
}
|
||||
|
||||
end:
|
||||
uci_free_context(c);
|
||||
end:
|
||||
uci_free_context(c);
|
||||
free(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#ifndef __PUCI_H
|
||||
#define __PUCI_H
|
||||
|
||||
#include <uci.h>
|
||||
#include <libbbfdm/dmentry.h>
|
||||
#include <libbbfdm/dmbbfcommon.h>
|
||||
bool check_section_name(const char *str, bool name);
|
||||
|
||||
int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value);
|
||||
#define UCI_OPTION_CPE_NOTIF_POLLING_PERIOD "cwmp.cpe.polling_period"
|
||||
void load_uci_config(char **polling_period);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -278,9 +278,9 @@ typedef struct rpc {
|
|||
|
||||
extern int ip_version;
|
||||
extern char *commandKey;
|
||||
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#ifndef FREE
|
||||
#define FREE(x) do { free(x); x = NULL; } while (0)
|
||||
#define FREE(x) do { if (x) {free(x); x = NULL;} } while (0)
|
||||
#endif
|
||||
|
||||
extern struct cwmp cwmp_main;
|
||||
|
|
|
|||
|
|
@ -15,12 +15,6 @@
|
|||
#define _FREECWMP_EXTERNAL_H__
|
||||
#include <libubox/list.h>
|
||||
|
||||
#ifdef DUMMY_MODE
|
||||
static char *fc_script = "./ext/openwrt/scripts/icwmp.sh";
|
||||
#else
|
||||
static char *fc_script = "/usr/sbin/icwmp";
|
||||
#endif
|
||||
|
||||
void external_du_change_stateFaultResp (char *fault_code, char *version, char *name, char *uuid, char *env);
|
||||
void external_downloadFaultResp (char *fault_code);
|
||||
void external_fetch_downloadFaultResp (char **fault_code);
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@ struct http_client
|
|||
char *url;
|
||||
};
|
||||
|
||||
#ifdef HTTP_CURL
|
||||
static size_t http_get_response(void *buffer, size_t size, size_t rxed, char **msg_in);
|
||||
#endif /* HTTP_CURL */
|
||||
|
||||
int http_client_init(struct cwmp *cwmp);
|
||||
void http_client_exit(void);
|
||||
int http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len,char **msg_in);
|
||||
|
|
|
|||
4
jshn.c
4
jshn.c
|
|
@ -60,7 +60,6 @@ char *download_fault_policy[] = {
|
|||
int
|
||||
cwmp_handle_downloadFault(char *msg)
|
||||
{
|
||||
int tmp;
|
||||
char *tb[__DOWNLOAD_MAX] = {0};
|
||||
|
||||
jshn_message_parse(download_fault_policy, ARRAYSIZEOF(download_fault_policy), tb, msg);
|
||||
|
|
@ -91,7 +90,6 @@ char *upload_fault_policy[] = {
|
|||
int
|
||||
cwmp_handle_uploadFault(char *msg)
|
||||
{
|
||||
int tmp;
|
||||
char *tb[__UPLOAD_MAX] = {0};
|
||||
|
||||
jshn_message_parse(upload_fault_policy, ARRAYSIZEOF(upload_fault_policy), tb, msg);
|
||||
|
|
@ -131,7 +129,6 @@ char *dustatechange_fault_policy[] = {
|
|||
int
|
||||
cwmp_handle_dustate_changeFault(char *msg)
|
||||
{
|
||||
int tmp;
|
||||
char *tb[__DUSTATE_MAX] = {0};
|
||||
|
||||
jshn_message_parse(dustatechange_fault_policy, ARRAYSIZEOF(dustatechange_fault_policy), tb, msg);
|
||||
|
|
@ -163,7 +160,6 @@ char *uninstall_fault_policy[] = {
|
|||
int
|
||||
cwmp_handle_uninstallFault(char *msg)
|
||||
{
|
||||
int tmp;
|
||||
char *tb[__UNINSTALL_MAX] = {0};
|
||||
|
||||
jshn_message_parse(uninstall_fault_policy, ARRAYSIZEOF(uninstall_fault_policy), tb, msg);
|
||||
|
|
|
|||
28
log.c
28
log.c
|
|
@ -30,10 +30,8 @@ static pthread_mutex_t mutex_log = PTHREAD_MUTEX_INITIALIZER;
|
|||
int log_set_severity_idx (char *value)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<8;i++)
|
||||
{
|
||||
if (strstr(SEVERITY_NAMES[i],value)!=NULL)
|
||||
{
|
||||
for (i = 0;i < 8; i++) {
|
||||
if (strstr(SEVERITY_NAMES[i],value) != NULL) {
|
||||
log_severity = i;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -43,12 +41,9 @@ int log_set_severity_idx (char *value)
|
|||
|
||||
int log_set_log_file_name (char *value)
|
||||
{
|
||||
if(value != NULL)
|
||||
{
|
||||
if(value != NULL) {
|
||||
strcpy(log_file_name,value);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
strcpy(log_file_name,DEFAULT_LOG_FILE_NAME);
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -90,7 +85,6 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
{
|
||||
va_list args;
|
||||
int i;
|
||||
time_t t;
|
||||
struct tm *Tm;
|
||||
struct timeval tv;
|
||||
FILE *pLog = NULL;
|
||||
|
|
@ -108,9 +102,8 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
pthread_mutex_lock (&mutex_log);
|
||||
|
||||
gettimeofday(&tv, 0);
|
||||
t = time((time_t*)NULL);
|
||||
Tm= localtime(&tv.tv_sec);
|
||||
i = sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d %s ",
|
||||
Tm = localtime(&tv.tv_sec);
|
||||
i = sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d %s ",
|
||||
Tm->tm_mday,
|
||||
Tm->tm_mon+1,
|
||||
Tm->tm_year+1900,
|
||||
|
|
@ -161,9 +154,6 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
|
||||
void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
time_t t;
|
||||
struct tm *Tm;
|
||||
struct timeval tv;
|
||||
FILE *pLog = NULL;
|
||||
|
|
@ -171,7 +161,6 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
long int size = 0;
|
||||
char log_file_name_bak[256];
|
||||
char buf[1024];
|
||||
char buf_file[1024];
|
||||
char *description, *separator;
|
||||
|
||||
if (severity>log_severity)
|
||||
|
|
@ -182,9 +171,8 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
pthread_mutex_lock(&mutex_log);
|
||||
|
||||
gettimeofday(&tv, 0);
|
||||
t = time((time_t*)NULL);
|
||||
Tm= localtime(&tv.tv_sec);
|
||||
i = sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d %s ",
|
||||
Tm = localtime(&tv.tv_sec);
|
||||
sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d %s ",
|
||||
Tm->tm_mday,
|
||||
Tm->tm_mon+1,
|
||||
Tm->tm_year+1900,
|
||||
|
|
|
|||
41
netlink.c
41
netlink.c
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
static int itfcmp(char *itf1, char *itf2);
|
||||
static void netlink_new_msg(struct uloop_fd *ufd, unsigned events);
|
||||
static void netlink_new_msg_v6(struct uloop_fd *ufd, unsigned events);
|
||||
static struct uloop_fd netlink_event = { .cb = netlink_new_msg };
|
||||
static struct uloop_fd netlink_event_v6 = { .cb = netlink_new_msg };
|
||||
|
||||
|
|
@ -47,6 +46,7 @@ static int itfcmp(char *itf1, char *itf2)
|
|||
char *str = NULL;
|
||||
char *buf1 = NULL;
|
||||
char *buf2 = NULL;
|
||||
|
||||
if(itf1[0] == '\0')
|
||||
goto end;
|
||||
str = strchr(itf1, '.');
|
||||
|
|
@ -189,42 +189,6 @@ static void netlink_new_msg(struct uloop_fd *ufd, unsigned events)
|
|||
}
|
||||
}
|
||||
|
||||
static void netlink_new_msg_v6(struct uloop_fd *ufd, unsigned events)
|
||||
{
|
||||
struct nlmsghdr *nlh;
|
||||
char buffer[BUFSIZ];
|
||||
int msg_size;
|
||||
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
|
||||
nlh = (struct nlmsghdr *)buffer;
|
||||
if ((msg_size = recv(ufd->fd, nlh, BUFSIZ, 0)) == -1) {
|
||||
CWMP_LOG(ERROR,"error receiving netlink message");
|
||||
return;
|
||||
}
|
||||
|
||||
while (msg_size > sizeof(*nlh)) {
|
||||
int len = nlh->nlmsg_len;
|
||||
int req_len = len - sizeof(*nlh);
|
||||
|
||||
if (req_len < 0 || len > msg_size) {
|
||||
CWMP_LOG(ERROR,"error reading netlink message");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NLMSG_OK(nlh, msg_size)) {
|
||||
CWMP_LOG(ERROR,"netlink message is not NLMSG_OK");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nlh->nlmsg_type == RTM_NEWADDR) {
|
||||
freecwmp_netlink_interface(nlh);
|
||||
}
|
||||
msg_size -= NLMSG_ALIGN(len);
|
||||
nlh = (struct nlmsghdr*)((char*)nlh + NLMSG_ALIGN(len));
|
||||
}
|
||||
}
|
||||
|
||||
int netlink_init_v6(void)
|
||||
{
|
||||
struct {
|
||||
|
|
@ -244,7 +208,7 @@ int netlink_init_v6(void)
|
|||
|
||||
addr.nl_family = AF_NETLINK;
|
||||
addr.nl_groups = RTMGRP_IPV6_IFADDR;
|
||||
if ((bind(sock[0], (struct sockaddr_in6 *)&addr, sizeof(addr))) == -1) {
|
||||
if ((bind(sock[0], (struct sockaddr *)&addr, sizeof(addr))) == -1) {
|
||||
CWMP_LOG(ERROR,"couldn't bind netlink socket");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -272,6 +236,7 @@ int netlink_init_v6(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int netlink_init(void)
|
||||
{
|
||||
struct {
|
||||
|
|
|
|||
290
xml.c
290
xml.c
|
|
@ -221,7 +221,7 @@ static int xml_recreate_namespace(mxml_node_t *tree)
|
|||
if (!ns.cwmp) continue;
|
||||
|
||||
return 0;
|
||||
} while(b = mxmlWalkNext(b, tree, MXML_DESCEND));
|
||||
} while ((b = mxmlWalkNext(b, tree, MXML_DESCEND)));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ int xml_send_message(struct cwmp *cwmp, struct session *session, struct rpc *rpc
|
|||
}
|
||||
if (msg_in) {
|
||||
CWMP_LOG_XML_MSG(DEBUG,msg_in,XML_MSG_IN);
|
||||
if (s = strstr(msg_in, "<FaultCode>"))
|
||||
if ((s = strstr(msg_in, "<FaultCode>")))
|
||||
sscanf(s, "<FaultCode>%d</FaultCode>",&f);
|
||||
if (f) {
|
||||
if (f == 8005) {
|
||||
|
|
@ -495,7 +495,7 @@ const char *whitespace_cb(mxml_node_t *node, int where)
|
|||
return NULL;
|
||||
case MXML_WS_BEFORE_OPEN:
|
||||
tab_space[0] = '\0';
|
||||
while (node = node->parent)
|
||||
while ((node = node->parent))
|
||||
strcat(tab_space, CWMP_MXML_TAB_SPACE);
|
||||
return tab_space;
|
||||
case MXML_WS_AFTER_OPEN:
|
||||
|
|
@ -557,11 +557,9 @@ error:
|
|||
static int xml_prepare_parameters_inform(struct dmctx *dmctx, struct dm_parameter *dm_parameter, mxml_node_t *parameter_list, int *size)
|
||||
{
|
||||
mxml_node_t *node, *b;
|
||||
int found;
|
||||
|
||||
b = mxmlFindElementOpaque(parameter_list, parameter_list, dm_parameter->name, MXML_DESCEND);
|
||||
if(b && dm_parameter->data != NULL)
|
||||
{
|
||||
if (b && dm_parameter->data != NULL) {
|
||||
node = b->parent->parent;
|
||||
b = mxmlFindElement(node, node, "Value", NULL, NULL, MXML_DESCEND_FIRST);
|
||||
if(!b) return 0;
|
||||
|
|
@ -638,13 +636,11 @@ error:
|
|||
|
||||
int xml_prepare_lwnotification_message(char **msg_out)
|
||||
{
|
||||
mxml_node_t *tree, *b, *n, *parameter_list;
|
||||
struct external_parameter *external_parameter;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct config *conf;
|
||||
mxml_node_t *tree, *b, *parameter_list;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct config *conf;
|
||||
conf = &(cwmp->conf);
|
||||
char *c = NULL;
|
||||
int counter = 0;
|
||||
|
||||
tree = mxmlLoadString(NULL, CWMP_LWNOTIFICATION_MESSAGE, MXML_OPAQUE_CALLBACK);
|
||||
if (!tree) goto error;
|
||||
|
|
@ -727,16 +723,14 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
|
|||
struct event_container *event_container;
|
||||
mxml_node_t *tree, *b, *node, *parameter_list;
|
||||
char *c = NULL;
|
||||
int size = 0, i, error;
|
||||
int size = 0;
|
||||
struct list_head *ilist,*jlist;
|
||||
struct dmctx dmctx = {0};
|
||||
|
||||
cwmp_dm_ctx_init(cwmp, &dmctx);
|
||||
|
||||
if (session==NULL || this==NULL)
|
||||
{
|
||||
if (session == NULL || this == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DUMMY_MODE
|
||||
FILE *fp;
|
||||
|
|
@ -1175,7 +1169,6 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
|
|||
mxml_node_t *n, *parameter_list, *b;
|
||||
struct dm_parameter *dm_parameter;
|
||||
char *parameter_name = NULL;
|
||||
char *parameter_value = NULL;
|
||||
char *c = NULL;
|
||||
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
struct dmctx dmctx = {0};
|
||||
|
|
@ -1496,7 +1489,7 @@ error:
|
|||
static int is_duplicated_parameter(mxml_node_t *param_node, struct session *session)
|
||||
{
|
||||
mxml_node_t *b = param_node;
|
||||
while(b = mxmlWalkNext(b, session->body_in, MXML_DESCEND)) {
|
||||
while ((b = mxmlWalkNext(b, session->body_in, MXML_DESCEND))) {
|
||||
if (b && b->type == MXML_OPAQUE &&
|
||||
b->value.opaque &&
|
||||
b->parent->type == MXML_ELEMENT &&
|
||||
|
|
@ -1514,9 +1507,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
char *parameter_name = NULL;
|
||||
char *parameter_value = NULL;
|
||||
char *parameter_key = NULL;
|
||||
char *status = NULL;
|
||||
char *v, *c = NULL;
|
||||
char buf[128];
|
||||
int fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
struct dmctx dmctx = {0};
|
||||
|
||||
|
|
@ -1551,10 +1542,10 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
b->value.opaque &&
|
||||
b->parent->type == MXML_ELEMENT &&
|
||||
!strcmp(b->parent->value.element.name, "Value")) {
|
||||
int whitespace;
|
||||
int whitespace = 0;
|
||||
parameter_value = strdup((char *)mxmlGetOpaque(b));
|
||||
n = b->parent;
|
||||
while (b = mxmlWalkNext(b, n, MXML_DESCEND)) {
|
||||
while ((b = mxmlWalkNext(b, n, MXML_DESCEND))) {
|
||||
v = (char *)mxmlGetOpaque(b);
|
||||
if (!whitespace) break;
|
||||
asprintf(&c, "%s %s", parameter_value, v);
|
||||
|
|
@ -1613,7 +1604,6 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
b = mxmlNewOpaque(b, "1");
|
||||
if (!b) goto fault;
|
||||
|
||||
success:
|
||||
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
|
||||
return 0;
|
||||
|
||||
|
|
@ -1717,7 +1707,6 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
|
|||
b = mxmlNewElement(b, "cwmp:SetParameterAttributesResponse");
|
||||
if (!b) goto fault;
|
||||
|
||||
end_success:
|
||||
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
|
||||
return 0;
|
||||
|
||||
|
|
@ -1739,8 +1728,6 @@ error:
|
|||
int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *b;
|
||||
struct paramameter_container *paramameter_container;
|
||||
char buf[128];
|
||||
char *object_name = NULL;
|
||||
char *parameter_key = NULL;
|
||||
int fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
|
|
@ -1796,7 +1783,6 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
|
|||
b = mxmlNewOpaque(b, "1");
|
||||
if (!b) goto fault;
|
||||
|
||||
success:
|
||||
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
|
||||
return 0;
|
||||
|
||||
|
|
@ -1818,7 +1804,6 @@ error:
|
|||
int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *b;
|
||||
char buf[128];
|
||||
char *object_name = NULL;
|
||||
char *parameter_key = NULL;
|
||||
int fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
|
|
@ -1868,7 +1853,6 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
|
|||
b = mxmlNewOpaque(b, "1");
|
||||
if (!b) goto fault;
|
||||
|
||||
success:
|
||||
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
|
||||
return 0;
|
||||
|
||||
|
|
@ -2231,17 +2215,13 @@ int cwmp_scheduleInform_remove_all()
|
|||
|
||||
int cwmp_handle_rpc_cpe_schedule_inform(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *n, *method_list, *b = session->body_in;
|
||||
char *c = NULL, *command_key = NULL;
|
||||
int i,counter = 0;
|
||||
struct event_container *event_container;
|
||||
struct schedule_inform *schedule_inform;
|
||||
time_t scheduled_time;
|
||||
struct list_head *ilist;
|
||||
bool cond_signal=false;
|
||||
pthread_t scheduleInform_thread;
|
||||
int error,fault = FAULT_CPE_NO_FAULT;
|
||||
unsigned int delay_seconds = 0;
|
||||
mxml_node_t *n, *b = session->body_in;
|
||||
char *command_key = NULL;
|
||||
struct schedule_inform *schedule_inform;
|
||||
time_t scheduled_time;
|
||||
struct list_head *ilist;
|
||||
int fault = FAULT_CPE_NO_FAULT;
|
||||
unsigned int delay_seconds = 0;
|
||||
|
||||
pthread_mutex_lock (&mutex_schedule_inform);
|
||||
|
||||
|
|
@ -2307,7 +2287,7 @@ int cwmp_handle_rpc_cpe_schedule_inform(struct session *session, struct rpc *rpc
|
|||
bkp_session_insert_schedule_inform(schedule_inform->scheduled_time,schedule_inform->commandKey);
|
||||
bkp_session_save();
|
||||
pthread_mutex_unlock (&mutex_schedule_inform);
|
||||
pthread_cond_signal(&threshold_schedule_inform);
|
||||
pthread_cond_signal(&threshold_schedule_inform);
|
||||
|
||||
success:
|
||||
return 0;
|
||||
|
|
@ -2622,19 +2602,17 @@ void *thread_cwmp_rpc_cpe_download (void *v)
|
|||
|
||||
void *thread_cwmp_rpc_cpe_schedule_download (void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct schedule_download *pschedule_download;
|
||||
struct timespec download_timeout = {0, 0};
|
||||
time_t current_time, stime;
|
||||
int i,error = FAULT_CPE_NO_FAULT;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
long int timeout;
|
||||
char *fault_code;
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct timespec download_timeout = {0, 0};
|
||||
time_t current_time;
|
||||
int i,error = FAULT_CPE_NO_FAULT;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
char *fault_code;
|
||||
int min_time = 0;
|
||||
struct schedule_download *current_download = NULL;
|
||||
struct schedule_download *p, *_p;
|
||||
for(;;)
|
||||
{
|
||||
|
||||
for (;;) {
|
||||
current_time = time(NULL);
|
||||
if(list_schedule_download.next != &(list_schedule_download))
|
||||
{
|
||||
|
|
@ -2894,17 +2872,16 @@ void *thread_cwmp_rpc_cpe_schedule_download (void *v)
|
|||
|
||||
void *thread_cwmp_rpc_cpe_apply_schedule_download (void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct schedule_download *pschedule_download;
|
||||
struct timespec apply_timeout = {0, 0};
|
||||
time_t current_time, stime;
|
||||
int i,error = FAULT_CPE_NO_FAULT;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
long int timeout;
|
||||
char *fault_code;
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct timespec apply_timeout = {0, 0};
|
||||
time_t current_time;
|
||||
int i, error = FAULT_CPE_NO_FAULT;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
char *fault_code;
|
||||
int min_time = 0;
|
||||
struct apply_schedule_download *apply_download = NULL;
|
||||
struct apply_schedule_download *p, *_p;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
current_time = time(NULL);
|
||||
|
|
@ -3083,41 +3060,32 @@ void *thread_cwmp_rpc_cpe_apply_schedule_download (void *v)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *thread_cwmp_rpc_cpe_change_du_state (void *v)
|
||||
void *thread_cwmp_rpc_cpe_change_du_state(void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct change_du_state *pchange_du_state;
|
||||
struct timespec download_timeout = {50, 0};
|
||||
time_t current_time, stime;
|
||||
int i, error = FAULT_CPE_NO_FAULT;
|
||||
struct du_state_change_complete *pdu_state_change_complete;
|
||||
long int time_of_grace = 216000, timeout;
|
||||
char *fault_code;
|
||||
char *package_version;
|
||||
char *package_name;
|
||||
char *package_uuid;
|
||||
char *package_env;
|
||||
struct operations *p, *q;
|
||||
struct opresult *res;
|
||||
char *operation_endTime;
|
||||
char *du_instance;
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct change_du_state *pchange_du_state;
|
||||
struct timespec download_timeout = {50, 0};
|
||||
time_t current_time;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct du_state_change_complete *pdu_state_change_complete;
|
||||
long int time_of_grace = 216000, timeout;
|
||||
char *package_version;
|
||||
char *package_name;
|
||||
char *package_uuid;
|
||||
char *package_env;
|
||||
struct operations *p, *q;
|
||||
struct opresult *res;
|
||||
struct dmctx dmctx = {0};
|
||||
char *du_ref = NULL;
|
||||
char *cur_uuid = NULL;
|
||||
char *cur_url = NULL;
|
||||
char *cur_user = NULL;
|
||||
char *cur_pass = NULL;
|
||||
char *cur_instance = NULL;
|
||||
char *cur_name = NULL;
|
||||
char *cur_version = NULL;
|
||||
char *cur_env = NULL;
|
||||
int uuid;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (;;) {
|
||||
if (list_change_du_state.next != &(list_change_du_state)) {
|
||||
pchange_du_state = list_entry(list_change_du_state.next,struct change_du_state, list);
|
||||
stime = pchange_du_state->timeout;
|
||||
current_time = time(NULL);
|
||||
timeout = current_time - pchange_du_state->timeout;
|
||||
if ((timeout >= 0) && (timeout > time_of_grace))
|
||||
|
|
@ -3374,16 +3342,15 @@ int cwmp_launch_du_uninstall(char *package_name, char *package_env, struct opres
|
|||
|
||||
void *thread_cwmp_rpc_cpe_upload (void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct upload *pupload;
|
||||
struct timespec upload_timeout = {0, 0};
|
||||
time_t current_time, stime;
|
||||
int i,error = FAULT_CPE_NO_FAULT;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
long int time_of_grace = 3600,timeout;
|
||||
char *fault_code;
|
||||
for(;;)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *)v;
|
||||
struct upload *pupload;
|
||||
struct timespec upload_timeout = {0, 0};
|
||||
time_t current_time, stime;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
long int time_of_grace = 3600,timeout;
|
||||
|
||||
for (;;) {
|
||||
if (list_upload.next!=&(list_upload)) {
|
||||
pupload = list_entry(list_upload.next,struct upload, list);
|
||||
stime = pupload->scheduled_time;
|
||||
|
|
@ -3463,28 +3430,22 @@ void *thread_cwmp_rpc_cpe_upload (void *v)
|
|||
|
||||
int cwmp_free_download_request(struct download *download)
|
||||
{
|
||||
if(download != NULL)
|
||||
{
|
||||
if (download != NULL) {
|
||||
if(download->command_key != NULL)
|
||||
{
|
||||
free(download->command_key);
|
||||
}
|
||||
|
||||
if(download->file_type != NULL)
|
||||
{
|
||||
free(download->file_type);
|
||||
}
|
||||
|
||||
if(download->url != NULL)
|
||||
{
|
||||
free(download->url);
|
||||
}
|
||||
|
||||
if(download->username != NULL)
|
||||
{
|
||||
free(download->username);
|
||||
}
|
||||
|
||||
if(download->password != NULL)
|
||||
{
|
||||
free(download->password);
|
||||
}
|
||||
|
||||
free(download);
|
||||
}
|
||||
return CWMP_OK;
|
||||
|
|
@ -3492,70 +3453,47 @@ int cwmp_free_download_request(struct download *download)
|
|||
|
||||
int cwmp_free_schedule_download_request(struct schedule_download *schedule_download)
|
||||
{
|
||||
int i;
|
||||
if(schedule_download != NULL)
|
||||
{
|
||||
if (schedule_download != NULL) {
|
||||
if(schedule_download->command_key != NULL)
|
||||
{
|
||||
free(schedule_download->command_key);
|
||||
}
|
||||
|
||||
if(schedule_download->file_type != NULL)
|
||||
{
|
||||
free(schedule_download->file_type);
|
||||
}
|
||||
|
||||
if(schedule_download->url != NULL)
|
||||
{
|
||||
free(schedule_download->url);
|
||||
}
|
||||
|
||||
if(schedule_download->username != NULL)
|
||||
{
|
||||
free(schedule_download->username);
|
||||
}
|
||||
|
||||
if(schedule_download->password != NULL)
|
||||
{
|
||||
free(schedule_download->password);
|
||||
}
|
||||
for (i = 0; i<=1; i++)
|
||||
{
|
||||
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
if(schedule_download->timewindowstruct[i].windowmode != NULL)
|
||||
{
|
||||
free(schedule_download->timewindowstruct[i].windowmode);
|
||||
}
|
||||
|
||||
if(schedule_download->timewindowstruct[i].usermessage != NULL)
|
||||
{
|
||||
|
||||
free(schedule_download->timewindowstruct[i].usermessage);
|
||||
}
|
||||
free(schedule_download->timewindowstruct[i].usermessage);
|
||||
}
|
||||
free(schedule_download);
|
||||
|
||||
}
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
int cwmp_free_apply_schedule_download_request(struct apply_schedule_download *apply_schedule_download)
|
||||
{
|
||||
int i;
|
||||
if(apply_schedule_download != NULL)
|
||||
{
|
||||
if(apply_schedule_download->command_key != NULL)
|
||||
{
|
||||
if (apply_schedule_download != NULL) {
|
||||
if (apply_schedule_download->command_key != NULL)
|
||||
free(apply_schedule_download->command_key);
|
||||
}
|
||||
if(apply_schedule_download->file_type != NULL)
|
||||
{
|
||||
|
||||
if (apply_schedule_download->file_type != NULL)
|
||||
free(apply_schedule_download->file_type);
|
||||
}
|
||||
if(apply_schedule_download->start_time != NULL)
|
||||
{
|
||||
|
||||
if (apply_schedule_download->start_time != NULL)
|
||||
free(apply_schedule_download->start_time);
|
||||
}
|
||||
|
||||
free(apply_schedule_download);
|
||||
|
||||
}
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
|
@ -3587,32 +3525,25 @@ int cwmp_free_change_du_state_request(struct change_du_state *change_du_state)
|
|||
|
||||
int cwmp_free_upload_request(struct upload *upload)
|
||||
{
|
||||
if(upload != NULL)
|
||||
{
|
||||
if(upload->command_key != NULL)
|
||||
{
|
||||
if (upload != NULL) {
|
||||
if (upload->command_key != NULL)
|
||||
FREE(upload->command_key);
|
||||
}
|
||||
if(upload->file_type != NULL)
|
||||
{
|
||||
|
||||
if (upload->file_type != NULL)
|
||||
FREE(upload->file_type);
|
||||
}
|
||||
if(upload->url != NULL)
|
||||
{
|
||||
|
||||
if (upload->url != NULL)
|
||||
FREE(upload->url);
|
||||
}
|
||||
if(upload->username != NULL)
|
||||
{
|
||||
|
||||
if (upload->username != NULL)
|
||||
FREE(upload->username);
|
||||
}
|
||||
if(upload->password != NULL)
|
||||
{
|
||||
|
||||
if (upload->password != NULL)
|
||||
FREE(upload->password);
|
||||
}
|
||||
if(upload->f_instance != NULL)
|
||||
{
|
||||
|
||||
if (upload->f_instance != NULL)
|
||||
FREE(upload->f_instance);
|
||||
}
|
||||
|
||||
FREE(upload);
|
||||
}
|
||||
return CWMP_OK;
|
||||
|
|
@ -3697,16 +3628,11 @@ int cwmp_apply_scheduled_Download_remove_all()
|
|||
int cwmp_add_apply_schedule_download(struct schedule_download *schedule_download, char *start_time)
|
||||
{
|
||||
int i = 0;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct apply_schedule_download *apply_schedule_download,*iapply_schedule_download;
|
||||
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
struct list_head *ilist;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct apply_schedule_download *apply_schedule_download;
|
||||
|
||||
|
||||
apply_schedule_download = calloc (1,sizeof(struct apply_schedule_download));
|
||||
if (apply_schedule_download == NULL)
|
||||
{
|
||||
if (apply_schedule_download == NULL) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -3732,12 +3658,7 @@ int cwmp_add_apply_schedule_download(struct schedule_download *schedule_download
|
|||
return 0;
|
||||
fault:
|
||||
cwmp_free_apply_schedule_download_request(apply_schedule_download);
|
||||
/*if (cwmp_create_fault_message(session, rpc, error))
|
||||
goto error;*/ //TOCK
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int cwmp_handle_rpc_cpe_change_du_state(struct session *session, struct rpc *rpc)
|
||||
|
|
@ -3884,15 +3805,12 @@ error:
|
|||
int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *n, *t, *b = session->body_in;
|
||||
pthread_t download_thread;
|
||||
char *c, *tmp, *file_type = NULL;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct download *download = NULL,*idownload;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
struct list_head *ilist;
|
||||
time_t scheduled_time = 0;
|
||||
time_t download_delay = 0;
|
||||
bool cond_signal = false;
|
||||
|
||||
if (asprintf(&c, "%s:%s", ns.cwmp, "Download") == -1)
|
||||
{
|
||||
|
|
@ -4078,22 +3996,15 @@ error:
|
|||
|
||||
int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *ibc, *n, *t, *b = session->body_in;
|
||||
pthread_t schedule_download_thread;
|
||||
mxml_node_t *n, *t, *b = session->body_in;
|
||||
char *c, *tmp, *file_type = NULL;
|
||||
char *windowmode0 = NULL, *windowmode1 = NULL;
|
||||
int i = 0, j = 0;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct schedule_download *schedule_download = NULL,*ischedule_download;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
struct list_head *ilist;
|
||||
time_t scheduled_time;
|
||||
time_t schedule_download_delay[4] = {0, 0, 0, 0};
|
||||
bool cond_signal = false;
|
||||
|
||||
struct schedule_download *schedule_download = NULL;
|
||||
time_t schedule_download_delay[4] = {0, 0, 0, 0};
|
||||
|
||||
if (asprintf(&c, "%s:%s", ns.cwmp, "ScheduleDownload") == -1)
|
||||
{
|
||||
if (asprintf(&c, "%s:%s", ns.cwmp, "ScheduleDownload") == -1) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -4104,7 +4015,6 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
if (!n) return -1;
|
||||
b = n;
|
||||
|
||||
|
||||
schedule_download = calloc (1,sizeof(struct schedule_download));
|
||||
if (schedule_download == NULL)
|
||||
{
|
||||
|
|
@ -4307,8 +4217,7 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
while (i > 0) {
|
||||
i--;
|
||||
schedule_download->timewindowstruct[i].windowstart = time(NULL) + schedule_download_delay[i*2];
|
||||
schedule_download->timewindowstruct[i].windowend = time(NULL) + schedule_download_delay[i*2+1];
|
||||
|
||||
schedule_download->timewindowstruct[i].windowend = time(NULL) + schedule_download_delay[i*2+1];
|
||||
}
|
||||
bkp_session_insert_schedule_download(schedule_download);
|
||||
bkp_session_save();
|
||||
|
|
@ -4339,15 +4248,12 @@ error:
|
|||
int cwmp_handle_rpc_cpe_upload(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *n, *t, *b = session->body_in;
|
||||
pthread_t upload_thread;
|
||||
char *c, *tmp, *file_type = NULL;
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
struct upload *upload = NULL,*iupload;
|
||||
struct transfer_complete *ptransfer_complete;
|
||||
struct list_head *ilist;
|
||||
time_t scheduled_time = 0;
|
||||
time_t upload_delay = 0;
|
||||
bool cond_signal = false;
|
||||
|
||||
if (asprintf(&c, "%s:%s", ns.cwmp, "Upload") == -1)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue