mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Ticket refs #14599: SDX810-AP: Unable to manage SDX810-AP from ACS server when it is connected via NAT Gateway(SDX-810RG)
(Fix a crash in icmp with EX400)
This commit is contained in:
parent
d2688b624c
commit
9d206e4e1d
7 changed files with 110 additions and 18 deletions
2
config.c
2
config.c
|
|
@ -1181,7 +1181,7 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
{
|
||||
char *piderr = "PID file creation failed: Quit the daemon!";
|
||||
fprintf(stderr, "%s\n", piderr);
|
||||
CWMP_LOG(ERROR, piderr);
|
||||
CWMP_LOG(ERROR, "%s",piderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else exit(EXIT_SUCCESS);
|
||||
|
|
|
|||
6
cwmp.c
6
cwmp.c
|
|
@ -190,9 +190,9 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
|||
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 && (!list_empty(&(session->head_event_container)) || (list_empty(&(session->head_event_container)) && cwmp->cwmp_cr_event == 0)) )
|
||||
{
|
||||
run_session_end_func(session);
|
||||
error = cwmp_move_session_to_session_queue (cwmp, session);
|
||||
CWMP_LOG(INFO,"Retry session, retry count = %d, retry in %ds",cwmp->retry_count_session,cwmp_get_retry_interval(cwmp));
|
||||
retry = true;
|
||||
|
|
@ -203,6 +203,8 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
|||
pthread_mutex_unlock (&(cwmp->mutex_session_send));
|
||||
continue;
|
||||
}
|
||||
event_remove_all_event_container(session,RPC_SEND);
|
||||
run_session_end_func(session);
|
||||
cwmp_session_destructor (cwmp, session);
|
||||
cwmp->session_send = NULL;
|
||||
cwmp->retry_count_session = 0;
|
||||
|
|
@ -622,7 +624,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
return error;
|
||||
}
|
||||
CWMP_LOG(INFO,"STARTING ICWMP");
|
||||
CWMP_LOG(INFO,"STARTING ICWMP with PID :%d", getpid());
|
||||
cwmp->start_time = time(NULL);
|
||||
|
||||
if (error = cwmp_init_backup_session(cwmp, NULL, ALL))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,13 @@ enum log_severity_enum {
|
|||
DEBUG
|
||||
};
|
||||
|
||||
enum log_xmlmsg_enum {
|
||||
XML_MSG_IN,
|
||||
XML_MSG_OUT
|
||||
};
|
||||
|
||||
void puts_log(int severity, const char *fmt, ...);
|
||||
void puts_log_xmlmsg(int severity, char *msg, int msgtype);
|
||||
int log_set_log_file_name (char *value);
|
||||
int log_set_file_max_size(char *value);
|
||||
int log_set_on_console(char *value);
|
||||
|
|
@ -37,9 +43,11 @@ int log_set_severity_idx (char *value);
|
|||
#ifdef WITH_CWMP_DEBUG
|
||||
# ifndef CWMP_LOG
|
||||
# define CWMP_LOG(SEV,MESSAGE,args...) puts_log(SEV,MESSAGE,##args);
|
||||
# define CWMP_LOG_XML_MSG puts_log_xmlmsg
|
||||
# endif
|
||||
#else
|
||||
# define CWMP_LOG(SEV,MESSAGE,args...)
|
||||
# define CWMP_LOG_XML_MSG(X, Y, Z)
|
||||
#endif
|
||||
|
||||
#ifdef WITH_DEV_DEBUG
|
||||
|
|
|
|||
102
log.c
102
log.c
|
|
@ -89,7 +89,6 @@ int log_set_on_file(char *value)
|
|||
void puts_log(int severity, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int buflen = 1024;
|
||||
int i;
|
||||
time_t t;
|
||||
struct tm *Tm;
|
||||
|
|
@ -98,17 +97,15 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
struct stat st;
|
||||
long int size = 0;
|
||||
char log_file_name_bak[256];
|
||||
char buf[1024];
|
||||
char buf_file[1024];
|
||||
|
||||
if (severity>log_severity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (severity == DEBUG)
|
||||
{
|
||||
buflen = 512000;
|
||||
}
|
||||
char buf[buflen];
|
||||
char buf_file[buflen];
|
||||
|
||||
pthread_mutex_lock (&mutex_log);
|
||||
|
||||
gettimeofday(&tv, 0);
|
||||
t = time((time_t*)NULL);
|
||||
|
|
@ -127,7 +124,6 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
}
|
||||
if(enable_log_file)
|
||||
{
|
||||
pthread_mutex_lock (&mutex_log);
|
||||
if (stat(log_file_name, &st) == 0)
|
||||
{
|
||||
size = st.st_size;
|
||||
|
|
@ -147,17 +143,103 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
i += vsprintf(buf+i, fmt, args);
|
||||
if(enable_log_file)
|
||||
{
|
||||
sprintf(buf_file,"%s\n",buf);
|
||||
strcpy(buf_file,buf);
|
||||
strcat(buf_file,"\n");
|
||||
fputs (buf_file, pLog);
|
||||
}
|
||||
va_end(args);
|
||||
if(enable_log_file)
|
||||
{
|
||||
fclose(pLog);
|
||||
pthread_mutex_unlock (&mutex_log);
|
||||
}
|
||||
if(enable_log_stdout)
|
||||
{
|
||||
puts(buf);
|
||||
}
|
||||
pthread_mutex_unlock (&mutex_log);
|
||||
}
|
||||
|
||||
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;
|
||||
struct stat st;
|
||||
long int size = 0;
|
||||
char log_file_name_bak[256];
|
||||
char buf[1024];
|
||||
char buf_file[1024];
|
||||
char *description, *separator;
|
||||
|
||||
if (severity>log_severity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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->tm_mday,
|
||||
Tm->tm_mon+1,
|
||||
Tm->tm_year+1900,
|
||||
Tm->tm_hour,
|
||||
Tm->tm_min,
|
||||
Tm->tm_sec,
|
||||
SEVERITY_NAMES[severity]);
|
||||
if(strlen(log_file_name) == 0)
|
||||
{
|
||||
strcpy(log_file_name,DEFAULT_LOG_FILE_NAME);
|
||||
}
|
||||
|
||||
if (msgtype == XML_MSG_IN) {
|
||||
description = "MESSAGE IN\n";
|
||||
separator = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
|
||||
|
||||
}
|
||||
else {
|
||||
description = "MESSAGE OUT\n";
|
||||
separator = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n";
|
||||
}
|
||||
if(enable_log_file)
|
||||
{
|
||||
|
||||
if (stat(log_file_name, &st) == 0)
|
||||
{
|
||||
size = st.st_size;
|
||||
}
|
||||
if(size >= log_max_size)
|
||||
{
|
||||
sprintf(log_file_name_bak,"%s.1",log_file_name);
|
||||
rename(log_file_name,log_file_name_bak);
|
||||
pLog = fopen(log_file_name,"w");
|
||||
}
|
||||
else
|
||||
{
|
||||
pLog = fopen(log_file_name,"a+");
|
||||
}
|
||||
fputs (buf, pLog);
|
||||
fputs(description, pLog);
|
||||
fputs(separator, pLog);
|
||||
fputs (msg, pLog);
|
||||
fputs ("\n", pLog);
|
||||
fputs(separator, pLog);
|
||||
fclose(pLog);
|
||||
|
||||
}
|
||||
if(enable_log_stdout)
|
||||
{
|
||||
puts (buf);
|
||||
puts(description);
|
||||
puts(separator);
|
||||
puts (msg);
|
||||
puts ("\n");
|
||||
puts(separator);
|
||||
}
|
||||
pthread_mutex_unlock (&mutex_log);
|
||||
}
|
||||
|
|
|
|||
2
time.c
2
time.c
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
char local_time[26] = {0};
|
||||
char local_time[32] = {0};
|
||||
|
||||
char * mix_get_time_of(time_t t_time)
|
||||
{
|
||||
|
|
|
|||
2
ubus.c
2
ubus.c
|
|
@ -128,7 +128,7 @@ cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
if(rc) {
|
||||
char *piderr = "PID file unlock failed!";
|
||||
fprintf(stderr, "%s\n", piderr);
|
||||
CWMP_LOG(ERROR, piderr);
|
||||
CWMP_LOG(ERROR, "%s", piderr);
|
||||
}
|
||||
blobmsg_add_u32(&b, "status", 0);
|
||||
if (asprintf(&info, "cwmpd daemon stopped") == -1)
|
||||
|
|
|
|||
6
xml.c
6
xml.c
|
|
@ -209,7 +209,7 @@ int xml_send_message(struct cwmp *cwmp, struct session *session, struct rpc *rpc
|
|||
|
||||
unsigned char *zmsg_out;
|
||||
msg_out = mxmlSaveAllocString(session->tree_out, whitespace_cb);
|
||||
CWMP_LOG(DEBUG,"Message OUT \n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n%s\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",msg_out);
|
||||
CWMP_LOG_XML_MSG(DEBUG,msg_out,XML_MSG_OUT);
|
||||
if (cwmp->conf.compression != COMP_NONE) {
|
||||
if (zlib_compress(msg_out, &zmsg_out, &msg_out_len, cwmp->conf.compression)) {
|
||||
return -1;
|
||||
|
|
@ -226,7 +226,7 @@ int xml_send_message(struct cwmp *cwmp, struct session *session, struct rpc *rpc
|
|||
goto error;
|
||||
}
|
||||
if (msg_in) {
|
||||
CWMP_LOG(DEBUG,"Message IN \n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n%s\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",msg_in);
|
||||
CWMP_LOG_XML_MSG(DEBUG,msg_in,XML_MSG_IN);
|
||||
if (s = strstr(msg_in, "<FaultCode>"))
|
||||
sscanf(s, "<FaultCode>%d</FaultCode>",&f);
|
||||
if (f) {
|
||||
|
|
@ -878,7 +878,7 @@ error:
|
|||
|
||||
int cwmp_rpc_acs_destroy_data_inform(struct session *session, struct rpc *rpc)
|
||||
{
|
||||
event_remove_all_event_container(session,RPC_SEND);
|
||||
//event_remove_all_event_container(session,RPC_SEND);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue