Parameter: InternetGatewayDevice.ManagementServer.PeriodicInformTime added

This commit is contained in:
Mohamed Kallel 2013-08-16 20:00:22 +01:00 committed by Benjamin Larsson
parent ebfc7378be
commit d809ee41c7
5 changed files with 150 additions and 4 deletions

View file

@ -590,6 +590,22 @@ int get_global_config(struct config *conf)
}
}
else
{
return error;
}
if((error = uci_get_value(UCI_PERIODIC_INFORM_TIME_PATH,&value)) == CWMP_OK)
{
int a = 0;
if(value != NULL)
{
a = atol(value);
free(value);
value = NULL;
}
conf->time = a;
}
else
{
return error;
}

View file

@ -4,6 +4,7 @@ config 'cwmp' 'acs'
option 'passwd' 'inteno'
option 'periodic_inform_enable' 'true'
option 'periodic_inform_interval' '1800'
option 'periodic_inform_time' '0'
option 'ParameterKey' ''
option 'dhcp_discovery' 'disable'
option 'dhcp_url_path' 'provisioning.iup.tr069url'

56
event.c
View file

@ -317,15 +317,45 @@ void *thread_event_periodic (void *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 = 0;
long int delta_time;
periodic_interval = cwmp->conf.period;
periodic_enable = cwmp->conf.periodic_enable;
periodic_time = cwmp->conf.time;
for(;;)
{
pthread_mutex_lock (&(cwmp->mutex_periodic));
periodic_timeout.tv_sec = time(NULL) + periodic_interval;
if(periodic_time != 0)
{
if (periodic_time != cwmp->conf.time)
periodic_time = cwmp->conf.time;
if(periodic_time == 0)
{
pthread_mutex_unlock (&(cwmp->mutex_periodic));
continue;
}
if ((periodic_timeout.tv_sec == current_time) && (current_time == time(NULL)))
{
pthread_mutex_unlock (&(cwmp->mutex_periodic));
continue;
}
current_time = time(NULL);
delta_time = current_time - periodic_time;
if (delta_time % periodic_interval != 0)
{
pthread_mutex_unlock (&(cwmp->mutex_periodic));
continue;
}
periodic_timeout.tv_sec = current_time;
}
else
{
periodic_timeout.tv_sec = time(NULL) + periodic_interval;
}
if (cwmp->conf.periodic_enable)
{
pthread_cond_timedwait(&(cwmp->threshold_periodic), &(cwmp->mutex_periodic), &periodic_timeout);
@ -335,10 +365,11 @@ void *thread_event_periodic (void *v)
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)
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");
@ -360,14 +391,33 @@ int cwmp_root_cause_event_periodic (struct cwmp *cwmp)
{
static int period = 0;
static bool periodic_enable = false;
if (period==cwmp->conf.period && periodic_enable==cwmp->conf.periodic_enable)
static time_t periodic_time = 0;
char local_time[26] = {0};
struct tm *t_tm;
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;
periodic_enable = cwmp->conf.periodic_enable;
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)
return CWMP_GEN_ERR;
local_time[25] = local_time[24];
local_time[24] = local_time[23];
local_time[22] = ':';
local_time[26] = '\0';
CWMP_LOG(INFO,periodic_time?"Periodic time is %s":"Periodic time is Unknown", local_time);
pthread_mutex_unlock (&(cwmp->mutex_periodic));
pthread_cond_signal(&(cwmp->threshold_periodic));
return CWMP_OK;

View file

@ -34,6 +34,7 @@
#define UCI_DHCP_DISCOVERY_PATH "cwmp.acs.dhcp_discovery"
#define UCI_DHCP_ACS_URL_PATH "cwmp.acs.dhcp_url_path"
#define UCI_ACS_URL_PATH "cwmp.acs.url"
#define UCI_PERIODIC_INFORM_TIME_PATH "cwmp.acs.periodic_inform_time"
#define UCI_PERIODIC_INFORM_INTERVAL_PATH "cwmp.acs.periodic_inform_interval"
#define UCI_PERIODIC_INFORM_ENABLE_PATH "cwmp.acs.periodic_inform_enable"
#define UCI_ACS_USERID_PATH "cwmp.acs.userid"
@ -136,6 +137,7 @@ typedef struct config {
char *ubus_socket;
int connection_request_port;
int period;
time_t time;
bool periodic_enable;
} config;

View file

@ -306,6 +306,52 @@ esac
# TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
get_management_server_periodic_inform_time() {
local val=""
local type="xsd:dateTime"
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformTime"
local permissions=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get cwmp.acs.periodic_inform_time`
if [ "$val" != "0" -a "$val" != "" ];then
val=`date -d @$val +"%Y-%m-%dT%H:%M:%S.000Z"`
else
val="0001-01-01T00:00:00Z"
fi
;;
get_name)
permissions="1"
;;
get_notification)
freecwmp_get_parameter_notification "val" "$parm"
;;
esac
freecwmp_output "$parm" "$val" "$permissions" "$type"
}
set_management_server_periodic_inform_time() {
local val=$1
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformTime"
case "$action" in
set_value)
if [ "$val" != "0001-01-01T00:00:00Z" ];then
val=`echo $val|sed 's/Z//g'`
val=`echo $val|sed 's/T/ /g'`
val=${val%%.*}
val=`date -d "$val" "+%s"`
else
val=0
fi
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q set cwmp.acs.periodic_inform_time="$val"
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 command '{ "command": "reload_end_session" }' &> /dev/null &
;;
set_notification)
freecwmp_set_parameter_notification "$parm" "$val"
;;
esac
}
get_management_server_x_freecwmp_org__acs_scheme() {
local val=""
local permissions=""
@ -473,6 +519,7 @@ case "$1" in
get_management_server_password
get_management_server_periodic_inform_enable
get_management_server_periodic_inform_interval
get_management_server_periodic_inform_time
get_management_server_connection_request_url
get_management_server_connection_request_username
get_management_server_connection_request_password
@ -485,6 +532,7 @@ case "$1" in
get_management_server_password
get_management_server_periodic_inform_enable
get_management_server_periodic_inform_interval
get_management_server_periodic_inform_time
get_management_server_connection_request_url
get_management_server_connection_request_username
get_management_server_connection_request_password
@ -511,6 +559,10 @@ case "$1" in
get_management_server_periodic_inform_interval
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformTime)
get_management_server_periodic_inform_time
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
get_management_server_connection_request_url
return $FAULT_CPE_NO_FAULT
@ -541,6 +593,7 @@ case "$1" in
get_management_server_password
get_management_server_periodic_inform_enable
get_management_server_periodic_inform_interval
get_management_server_periodic_inform_time
get_management_server_connection_request_url
get_management_server_connection_request_username
get_management_server_connection_request_password
@ -555,6 +608,7 @@ case "$1" in
get_management_server_password
get_management_server_periodic_inform_enable
get_management_server_periodic_inform_interval
get_management_server_periodic_inform_time
get_management_server_connection_request_url
get_management_server_connection_request_username
get_management_server_connection_request_password
@ -596,6 +650,13 @@ case "$1" in
get_management_server_periodic_inform_interval
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformTime)
if [ "$2" = "1" ]; then
return $FAULT_CPE_INVALID_ARGUMENTS
fi
get_management_server_periodic_inform_time
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
if [ "$2" = "1" ]; then
return $FAULT_CPE_INVALID_ARGUMENTS
@ -636,6 +697,7 @@ case "$1" in
get_management_server_password
get_management_server_periodic_inform_enable
get_management_server_periodic_inform_interval
get_management_server_periodic_inform_time
get_management_server_connection_request_url
get_management_server_connection_request_username
get_management_server_connection_request_password
@ -648,6 +710,7 @@ case "$1" in
get_management_server_password
get_management_server_periodic_inform_enable
get_management_server_periodic_inform_interval
get_management_server_periodic_inform_time
get_management_server_connection_request_url
get_management_server_connection_request_username
get_management_server_connection_request_password
@ -674,6 +737,10 @@ case "$1" in
get_management_server_periodic_inform_interval
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformTime)
get_management_server_periodic_inform_time
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
get_management_server_connection_request_url
return $FAULT_CPE_NO_FAULT
@ -716,6 +783,10 @@ case "$1" in
set_management_server_periodic_inform_interval "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformTime)
set_management_server_periodic_inform_time "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
set_management_server_connection_request_url "$2"
return $FAULT_CPE_NO_FAULT
@ -744,6 +815,7 @@ case "$1" in
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.Password" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.PeriodicInformEnable" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.PeriodicInformInterval" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.PeriodicInformTime" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "0"
@ -756,6 +828,7 @@ case "$1" in
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.Password" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.PeriodicInformEnable" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.PeriodicInformInterval" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.PeriodicInformTime" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "0"
freecwmp_set_parameter_notification "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "0"
@ -783,6 +856,10 @@ case "$1" in
set_management_server_periodic_inform_interval "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformTime)
set_management_server_periodic_inform_time "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
set_management_server_connection_request_url "$2"
return $FAULT_CPE_NO_FAULT
@ -857,4 +934,4 @@ delete_management_server() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
add_management_server_generic() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
delete_management_server_generic() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
delete_management_server_generic() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }