mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Ticket refs #9642: CWMP SPAs not persistent
This commit is contained in:
parent
a0da2716b9
commit
d92ef77e28
11 changed files with 59 additions and 36 deletions
|
|
@ -7,6 +7,8 @@ pwd
|
|||
trap cleanup EXIT
|
||||
trap cleanup SIGINT
|
||||
|
||||
if [ ! -f /etc/icwmpd/cwmp_notifications ]; then touch /etc/icwmpd/cwmp_notifications; fi
|
||||
|
||||
echo "Configure download server"
|
||||
configure_download_firmware
|
||||
|
||||
|
|
|
|||
|
|
@ -314,8 +314,8 @@ void check_firewall_restart_state()
|
|||
*/
|
||||
void cwmp_reboot(char *command_key)
|
||||
{
|
||||
cwmp_uci_set_varstate_value("cwmp", "cpe", "ParameterKey", command_key);
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
cwmp_uci_set_value("cwmp", "cpe", "ParameterKey", command_key);
|
||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
|
||||
struct blob_buf b = { 0 };
|
||||
memset(&b, 0, sizeof(struct blob_buf));
|
||||
|
|
@ -324,6 +324,8 @@ void cwmp_reboot(char *command_key)
|
|||
icwmp_ubus_invoke("rpc-sys", "reboot", b.head, NULL, NULL);
|
||||
|
||||
blob_buf_free(&b);
|
||||
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ void set_interface_reset_request(char *param_name, char *value)
|
|||
list_add_tail(&node->list, &intf_reset_list);
|
||||
}
|
||||
|
||||
int create_cwmp_var_state_files()
|
||||
int create_cwmp_temporary_files()
|
||||
{
|
||||
/*
|
||||
* Create Notifications empty uci package
|
||||
|
|
@ -228,7 +228,10 @@ static int cwmp_init()
|
|||
if (cwmp_main->pid_file)
|
||||
fclose(cwmp_main->pid_file);
|
||||
|
||||
if ((error = create_cwmp_var_state_files()))
|
||||
if ((error = create_cwmp_temporary_files()))
|
||||
return error;
|
||||
|
||||
if ((error = create_cwmp_notifications_package()))
|
||||
return error;
|
||||
|
||||
CWMP_LOG(DEBUG, "Loading icwmpd configuration");
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
struct uci_paths uci_save_conf_paths[] = {
|
||||
[UCI_STANDARD_CONFIG] = { "/etc/config", "/tmp/.uci", NULL },
|
||||
[UCI_VARSTATE_CONFIG] = { "/var/state", NULL, NULL }
|
||||
[UCI_VARSTATE_CONFIG] = { "/var/state", NULL, NULL },
|
||||
[UCI_ETCICWMPD_CONFIG] = {"/etc/icwmpd", NULL, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@
|
|||
typedef enum uci_config_paths
|
||||
{
|
||||
UCI_STANDARD_CONFIG,
|
||||
UCI_VARSTATE_CONFIG
|
||||
UCI_VARSTATE_CONFIG,
|
||||
UCI_ETCICWMPD_CONFIG
|
||||
}uci_config_paths;
|
||||
|
||||
enum uci_val_type
|
||||
|
|
@ -130,6 +131,7 @@ int cwmp_uci_init();
|
|||
void cwmp_uci_exit(void);
|
||||
void cwmp_uci_reinit(void);
|
||||
int cwmp_uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value);
|
||||
int cwmp_uci_get_option_value_list(char *package, char *section, char *option, uci_config_paths uci_type, struct uci_list **value);
|
||||
int cwmp_uci_get_cwmp_standard_option_value_list(char *package, char *section, char *option, struct uci_list **value);
|
||||
int cwmp_uci_get_cwmp_varstate_option_value_list(char *package, char *section, char *option, struct uci_list **value);
|
||||
int uci_get_state_value(char *cmd, char **value);
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ static int set_management_server_delay_reboot(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.ManagementServer.ParameterKey!UCI:cwmp/acs,acs/ParameterKey*/
|
||||
static int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string_varstate("cwmp", "cpe", "ParameterKey", value);
|
||||
dmuci_get_option_value_string("cwmp", "cpe", "ParameterKey", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -537,8 +537,8 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
|||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
|
||||
if ((error == FAULT_CPE_NO_FAULT) && (pdownload->file_type[0] == '1' || pdownload->file_type[0] == '3')) {
|
||||
cwmp_uci_set_varstate_value("cwmp", "cpe", "ParameterKey", pdownload->command_key ? pdownload->command_key : "");
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
cwmp_uci_set_value("cwmp", "cpe", "ParameterKey", pdownload->command_key ? pdownload->command_key : "");
|
||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
if (pdownload->file_type[0] == '3') {
|
||||
CWMP_LOG(INFO, "Download and apply new vendor config file is done successfully");
|
||||
//cwmp_root_cause_transfer_complete(ptransfer_complete);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,18 @@ char *forced_notifications_parameters[] = {
|
|||
/*
|
||||
* Common functions
|
||||
*/
|
||||
int create_cwmp_notifications_package()
|
||||
{
|
||||
if (!file_exists(CWMP_NOTIFICATIONS_PACKAGE)) {
|
||||
FILE *fptr = fopen(CWMP_NOTIFICATIONS_PACKAGE, "w+");
|
||||
if (fptr)
|
||||
fclose(fptr);
|
||||
else
|
||||
return CWMP_GEN_ERR;
|
||||
}
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
static bool parameter_is_subobject_of_parameter(char *parent, char *child)
|
||||
{
|
||||
if (child == NULL) {
|
||||
|
|
@ -105,18 +117,18 @@ int add_uci_option_notification(char *parameter_name, int notification)
|
|||
struct uci_section *s = NULL;
|
||||
int ret = 0;
|
||||
|
||||
ret = cwmp_uci_get_section_type("cwmp", "@notifications[0]", UCI_VARSTATE_CONFIG, ¬ification_type);
|
||||
ret = cwmp_uci_get_section_type("cwmp_notifications", "@notifications[0]", UCI_ETCICWMPD_CONFIG, ¬ification_type);
|
||||
if (ret != UCI_OK)
|
||||
return -1;
|
||||
|
||||
if (notification_type == NULL || notification_type[0] == '\0') {
|
||||
cwmp_uci_add_section("cwmp", "notifications", UCI_VARSTATE_CONFIG, &s);
|
||||
cwmp_uci_add_section("cwmp_notifications", "notifications", UCI_ETCICWMPD_CONFIG, &s);
|
||||
}
|
||||
ret = cwmp_uci_add_list_value("cwmp", "@notifications[0]", notifications[notification], parameter_name, UCI_VARSTATE_CONFIG);
|
||||
ret = cwmp_uci_add_list_value("cwmp_notifications", "@notifications[0]", notifications[notification], parameter_name, UCI_ETCICWMPD_CONFIG);
|
||||
if (ret != UCI_OK)
|
||||
return -1;
|
||||
|
||||
ret = cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
ret = cwmp_commit_package("cwmp_notifications", UCI_ETCICWMPD_CONFIG);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +142,7 @@ bool check_parent_with_different_notification(char *parameter_name, int notifica
|
|||
|
||||
if (i == notification)
|
||||
continue;
|
||||
option_type = cwmp_uci_get_cwmp_varstate_option_value_list("cwmp", "@notifications[0]", notifications[i], &list_notif);
|
||||
option_type = cwmp_uci_get_option_value_list("cwmp_notifications", "@notifications[0]", notifications[i], UCI_ETCICWMPD_CONFIG, &list_notif);
|
||||
if (list_notif) {
|
||||
uci_foreach_element(list_notif, e) {
|
||||
if (parameter_is_subobject_of_parameter(e->name, parameter_name))
|
||||
|
|
@ -155,19 +167,19 @@ bool update_notifications_list(char *parameter_name, int notification)
|
|||
parameter_name = "Device.";
|
||||
for (i = 0; i < 7; i++) {
|
||||
int option_type;
|
||||
option_type = cwmp_uci_get_cwmp_varstate_option_value_list("cwmp", "@notifications[0]", notifications[i], &list_notif);
|
||||
option_type = cwmp_uci_get_option_value_list("cwmp_notifications", "@notifications[0]", notifications[i], UCI_ETCICWMPD_CONFIG, &list_notif);
|
||||
if (list_notif) {
|
||||
uci_foreach_element_safe(list_notif, tmp, e) {
|
||||
if (e->name == NULL)
|
||||
continue;
|
||||
ename = strdup(e->name);
|
||||
if ((strcmp(parameter_name, e->name) == 0 && (i != notification)) || parameter_is_subobject_of_parameter(parameter_name, e->name))
|
||||
cwmp_uci_del_list_value("cwmp", "@notifications[0]", notifications[i], e->name, UCI_VARSTATE_CONFIG);
|
||||
cwmp_uci_del_list_value("cwmp_notifications", "@notifications[0]", notifications[i], e->name, UCI_ETCICWMPD_CONFIG);
|
||||
if (ename && (strcmp(parameter_name, ename) == 0 || parameter_is_subobject_of_parameter(ename, parameter_name) ) && (i == notification))
|
||||
update_ret = false;
|
||||
FREE(ename);
|
||||
}
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
cwmp_commit_package("cwmp_notifications", UCI_ETCICWMPD_CONFIG);
|
||||
}
|
||||
if (option_type == UCI_TYPE_STRING)
|
||||
cwmp_free_uci_list(list_notif);
|
||||
|
|
@ -213,7 +225,7 @@ int get_parameter_family_notifications(char *parameter_name, struct list_head *c
|
|||
for (i = 0; i < 7; i++) {
|
||||
int option_type;
|
||||
|
||||
option_type = cwmp_uci_get_cwmp_varstate_option_value_list("cwmp", "@notifications[0]", notifications[i], &list_notif);
|
||||
option_type = cwmp_uci_get_option_value_list("cwmp_notifications", "@notifications[0]", notifications[i], UCI_ETCICWMPD_CONFIG, &list_notif);
|
||||
if (list_notif) {
|
||||
uci_foreach_element(list_notif, e) {
|
||||
if (parameter_is_subobject_of_parameter(parameter_name, e->name)) {
|
||||
|
|
@ -335,7 +347,7 @@ void create_list_param_obj_notify()
|
|||
cwmp_uci_reinit();
|
||||
for (i = 0; i < 7; i++) {
|
||||
int option_type;
|
||||
option_type = cwmp_uci_get_cwmp_varstate_option_value_list("cwmp", "@notifications[0]", notifications[i], &list_notif);
|
||||
option_type = cwmp_uci_get_option_value_list("cwmp_notifications", "@notifications[0]", notifications[i], UCI_ETCICWMPD_CONFIG, &list_notif);
|
||||
if (list_notif) {
|
||||
uci_foreach_element(list_notif, e) {
|
||||
add_dm_parameter_to_list(&list_param_obj_notify, e->name, "", "", i, false);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#define CWMP_NOTIFICATIONS_PACKAGE "/etc/icwmpd/cwmp_notifications"
|
||||
|
||||
enum NOTIFICATION_STATUS
|
||||
{
|
||||
NOTIF_NONE = 0,
|
||||
|
|
@ -48,6 +50,7 @@ extern struct uloop_timeout check_notify_timer;
|
|||
#define DM_ENABLED_NOTIFY "/var/run/icwmpd/dm_enabled_notify"
|
||||
#define NOTIFY_MARKER "/etc/icwmpd/icwmpd_notify_import_marker"
|
||||
#define RUN_NOTIFY_MARKER "/var/run/icwmpd/icwmpd_notify_import_marker"
|
||||
int create_cwmp_notifications_package();
|
||||
void ubus_check_value_change_callback(struct ubus_request *req, int type, struct blob_attr *msg);
|
||||
void cwmp_update_enabled_notify_file(void);
|
||||
int check_value_change(void);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ static int get_parameter_notification_from_notifications_uci_list(char *paramete
|
|||
struct uci_element *e;
|
||||
for (i = 0; i < 7; i++) {
|
||||
int option_type;
|
||||
option_type = cwmp_uci_get_cwmp_varstate_option_value_list("cwmp", "@notifications[0]", notifications_test[i], &list_notif);
|
||||
option_type = cwmp_uci_get_option_value_list("cwmp_notifications", "@notifications[0]", notifications_test[i], UCI_ETCICWMPD_CONFIG, &list_notif);
|
||||
if (list_notif) {
|
||||
uci_foreach_element(list_notif, e) {
|
||||
if (strcmp(e->name, parameter_name) == 0) {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ exec_cmd cp test/files/etc/icwmpd/custom_notification* /etc/icwmpd
|
|||
# Test a valid custom notification json file
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci -c /var/state delete cwmp.@notifications[0]
|
||||
uci -c /var/state commit cwmp
|
||||
|
||||
exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_valid.json"
|
||||
uci commit cwmp
|
||||
|
|
@ -29,12 +27,12 @@ supervisorctl stop icwmpd
|
|||
|
||||
check_valgrind_xml
|
||||
|
||||
notif1=`uci -c /var/state get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
notif1=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 != *"Device.Users."* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci -c /var/state get cwmp.@notifications[0].passive | grep "Device.WiFi.SSID.1.SSID"`
|
||||
notif2=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].passive | grep "Device.WiFi.SSID.1.SSID"`
|
||||
if [[ $notif2 != *"Device.WiFi.SSID.1.SSID"* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.WiFi.SSID.1.SSID parameter"
|
||||
exit 1
|
||||
|
|
@ -48,8 +46,8 @@ echo "PASS test valid custom notification json file"
|
|||
# Test custom notification invalid json file
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci -c /var/state delete cwmp.@notifications[0]
|
||||
uci -c /var/state commit cwmp
|
||||
uci -c /etc/icwmpd delete cwmp_notifications.@notifications[0]
|
||||
uci -c /etc/icwmpd commit cwmp_notifications
|
||||
|
||||
exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_invalid_json.json"
|
||||
uci commit cwmp
|
||||
|
|
@ -62,12 +60,12 @@ supervisorctl stop icwmpd
|
|||
|
||||
check_valgrind_xml
|
||||
|
||||
notif1=`uci -c /var/state get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
notif1=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 == *"Device.Users."* ]]; then
|
||||
echo "FAIL: the json file is invalid, the active notifcation list shouldn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci -c /var/state get cwmp.@notifications[0].passive | grep "Device.WiFi.SSID.1.SSID"`
|
||||
notif2=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].passive | grep "Device.WiFi.SSID.1.SSID"`
|
||||
if [[ $notif2 == *"Device.WiFi.SSID.1.SSID"* ]]; then
|
||||
echo "FAIL: the json file is invalid, the active notifcation list shouldn't contain Device.WiFi.SSID.1.SSID parameter"
|
||||
exit 1
|
||||
|
|
@ -87,8 +85,8 @@ rm /etc/icwmpd/icwmpd_notify
|
|||
# Test custom notification json file containing forced active notification
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci -c /var/state delete cwmp.@notifications[0]
|
||||
uci -c /var/state commit cwmp
|
||||
uci -c /etc/icwmpd delete cwmp_notifications.@notifications[0]
|
||||
uci -c /etc/icwmpd commit cwmp_notifications
|
||||
|
||||
exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_forced.json"
|
||||
uci commit cwmp
|
||||
|
|
@ -100,12 +98,12 @@ supervisorctl stop icwmpd
|
|||
|
||||
check_valgrind_xml
|
||||
|
||||
notif1=`uci -c /var/state get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
notif1=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 != *"Device.Users."* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci -c /var/state get cwmp.@notifications[0].passive | grep "Device.DeviceInfo.ProvisioningCode"`
|
||||
notif2=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].passive | grep "Device.DeviceInfo.ProvisioningCode"`
|
||||
if [[ $notif2 == *"Device.DeviceInfo.ProvisioningCode"* ]]; then
|
||||
echo "FAIL: passive notifications list contains Device.DeviceInfo.ProvisioningCode while it's a forced active notification paramter"
|
||||
exit 1
|
||||
|
|
@ -125,8 +123,8 @@ rm /etc/icwmpd/icwmpd_notify
|
|||
# Test custom notification json file containing invalid parameter path
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci -c /var/state delete cwmp.@notifications[0]
|
||||
uci -c /var/state commit cwmp
|
||||
uci -c /etc/icwmpd delete cwmp_notifications.@notifications[0]
|
||||
uci -c /etc/icwmpd commit cwmp_notifications
|
||||
|
||||
exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_invalid_parameter.json"
|
||||
uci commit cwmp
|
||||
|
|
@ -138,12 +136,12 @@ supervisorctl stop icwmpd
|
|||
|
||||
check_valgrind_xml
|
||||
|
||||
notif1=`uci -c /var/state get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
notif1=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 != *"Device.Users."* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci -c /var/state get cwmp.@notifications[0].passive | grep "Device.WiFi.SSID.1.SD"`
|
||||
notif2=`uci -c /etc/icwmpd get cwmp_notifications.@notifications[0].passive | grep "Device.WiFi.SSID.1.SD"`
|
||||
if [[ $notif2 == *"Device.WiFi.SSID.1.SD"* ]]; then
|
||||
echo "FAIL: passive notifications list contains Device.WiFi.SSID.1.SD while it's a wrong parameter path"
|
||||
exit 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue