diff --git a/README.md b/README.md index 9e2e6db..567424c 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ In addition to the above defined forced inform parameters as specified in datamo Additional inform parameters can be configured in a JSON file as below: ```bash -root@iopsys:~# cat /etc/icwmpd/forced_inform.json +root@iopsys:~# cat /etc/icwmpd/inform.json { "forced_inform":[ "Device.DeviceInfo.X_IOPSYS_EU_BaseMACAddress", @@ -294,7 +294,7 @@ root@iopsys:~# And then the path of the JSON file can be set in the UCI option: `cwmp.cpe.forced_inform_json` like below: ```bash -root@iopsys:~# uci set cwmp.cpe.forced_inform_json=/etc/icwmpd/forced_inform.json +root@iopsys:~# uci set cwmp.cpe.forced_inform_json=/etc/icwmpd/inform.json root@iopsys:~# uci commit cwmp root@iopsys:~# /etc/init.d/icwmpd restart ``` @@ -311,9 +311,9 @@ Boot inform parameters will appear in inform messages that includes '0 BOOTSTRAP inform parameters can be configured in a JSON file as below: ```bash -root@iopsys:~# cat /etc/icwmpd/boot_inform.json +root@iopsys:~# cat /etc/icwmpd/inform.json { - "boot_inform_params":[ + "boot_inform":[ "Device.DeviceInfo.UpTime" ] } @@ -322,7 +322,7 @@ root@iopsys:~# And then the path of the JSON file can be set in the UCI option: `cwmp.cpe.boot_inform_json` like below: ```bash -root@iopsys:~# uci set cwmp.cpe.boot_inform_json=/etc/icwmpd/boot_inform.json +root@iopsys:~# uci set cwmp.cpe.boot_inform_json=/etc/icwmpd/inform.json root@iopsys:~# uci commit cwmp root@iopsys:~# /etc/init.d/icwmpd restart ``` @@ -345,6 +345,7 @@ In addition to thos parameters, icwmp gives the possibility to set default notif The json file must respect following form: ```bash +root@iopsys:~# cat /etc/icwmpd/inform.json { "custom_notification": [ { @@ -358,7 +359,13 @@ The json file must respect following form: ] } ``` -the location of this file should be specified in the uci config option: cwmp.cpe.json_custom_notify_file + +The location of this file should be specified in the uci config option: cwmp.cpe.custom_notify_json +```bash +root@iopsys:~# uci set cwmp.cpe.custom_notify_json=/etc/icwmpd/inform.json +root@iopsys:~# uci commit cwmp +root@iopsys:~# /etc/init.d/icwmpd restart +``` Contrary to forced parameters notifications, the ACS has privileges to set new notification type of those custom parameters. diff --git a/config.c b/config.c index ce440f8..1d3b716 100755 --- a/config.c +++ b/config.c @@ -595,15 +595,15 @@ int get_global_config(struct config *conf) CWMP_LOG(DEBUG, "CWMP CONFIG - cpe boot inform json file: %s", conf->forced_inform_json_file); } if (uci_get_value(UCI_CPE_JSON_CUSTOM_NOTIFY_FILE, &value) == CWMP_OK) { - FREE(conf->json_custom_notify_file); + FREE(conf->custom_notify_json); if (value != NULL) { - conf->json_custom_notify_file = strdup(value); + conf->custom_notify_json = strdup(value); FREE(value); } else { - conf->json_custom_notify_file = NULL; + conf->custom_notify_json = NULL; } - if (conf->json_custom_notify_file) - CWMP_LOG(DEBUG, "CWMP CONFIG - cpe json custom notify file: %s", conf->json_custom_notify_file); + if (conf->custom_notify_json) + CWMP_LOG(DEBUG, "CWMP CONFIG - cpe json custom notify file: %s", conf->custom_notify_json); } return CWMP_OK; } diff --git a/cwmp.c b/cwmp.c index 1c35240..b961ad6 100644 --- a/cwmp.c +++ b/cwmp.c @@ -414,7 +414,7 @@ void load_forced_inform_json_file(struct cwmp *cwmp) return; custom_forced_inform_list = tb[0]; if (custom_forced_inform_list == NULL) { - CWMP_LOG(WARNING, "The JSON file %s doesn't contain a forced inform parameters list", cwmp->conf.json_custom_notify_file); + CWMP_LOG(WARNING, "The JSON file %s doesn't contain a forced inform parameters list", cwmp->conf.custom_notify_json); blob_buf_free(&bbuf); return; } @@ -457,7 +457,7 @@ void load_boot_inform_json_file(struct cwmp *cwmp) blob_buf_free(&bbuf); return; } - const struct blobmsg_policy p[1] = { { "boot_inform_params", BLOBMSG_TYPE_ARRAY } }; + const struct blobmsg_policy p[1] = { { "boot_inform", BLOBMSG_TYPE_ARRAY } }; struct blob_attr *tb[1] = { NULL }; blobmsg_parse(p, 1, tb, blobmsg_data(bbuf.head), blobmsg_len(bbuf.head)); if (!tb[0]) @@ -465,7 +465,7 @@ void load_boot_inform_json_file(struct cwmp *cwmp) custom_boot_inform_list = tb[0]; if (custom_boot_inform_list == NULL) { - CWMP_LOG(WARNING, "The JSON file %s doesn't contain a boot inform parameters list", cwmp->conf.json_custom_notify_file); + CWMP_LOG(WARNING, "The JSON file %s doesn't contain a boot inform parameters list", cwmp->conf.custom_notify_json); blob_buf_free(&bbuf); return; } @@ -542,7 +542,7 @@ static int cwmp_init(int argc, char **argv, struct cwmp *cwmp) cwmp_get_deviceid(cwmp); load_forced_inform_json_file(cwmp); load_boot_inform_json_file(cwmp); - load_json_custom_notify_file(cwmp); + load_custom_notify_json(cwmp); return CWMP_OK; } @@ -566,7 +566,7 @@ static void cwmp_free(struct cwmp *cwmp) FREE(cwmp->conf.connection_request_path); FREE(cwmp->conf.default_wan_iface); FREE(cwmp->conf.forced_inform_json_file); - FREE(cwmp->conf.json_custom_notify_file); + FREE(cwmp->conf.custom_notify_json); FREE(cwmp->conf.boot_inform_json_file); clean_list_param_notify(); bkp_tree_clean(); diff --git a/docs/api/uci.cwmp.md b/docs/api/uci.cwmp.md index e8e7a86..ecb7aff 100644 --- a/docs/api/uci.cwmp.md +++ b/docs/api/uci.cwmp.md @@ -357,7 +357,21 @@
string
no
-
Define additional parameters as forced inform parameter. See readme for examples.
+
Define absolute path for the JSON containing additional parameters as forced inform parameter. See readme for examples.
+ + +
boot_inform_json
+
string
+
no
+
+
Define absolute path for the JSON containing additional parameters as boot inform parameter. These parameters only gets added if the notify event is '0 Bootstrap' or '1 Boot'. To enable value change notification, please use custom_notify_json, See readme for examples.
+ + +
custom_notify_json
+
string
+
no
+
+
Define absolute path of the JSON containing parameters on which notification get enabled as per the definition. See readme for examples.
diff --git a/inc/common.h b/inc/common.h index 5abacfc..2e4e437 100644 --- a/inc/common.h +++ b/inc/common.h @@ -72,7 +72,7 @@ typedef struct config { char *cpe_passwd; char *forced_inform_json_file; char *boot_inform_json_file; - char *json_custom_notify_file; + char *custom_notify_json; char *ip; char *ipv6; char *interface; diff --git a/inc/cwmp_uci.h b/inc/cwmp_uci.h index 836f6e1..446dd38 100644 --- a/inc/cwmp_uci.h +++ b/inc/cwmp_uci.h @@ -57,7 +57,7 @@ #define UCI_CPE_DELAY_REBOOT "cwmp.cpe.delay_reboot" #define UCI_CPE_FORCED_INFORM_JSON "cwmp.cpe.forced_inform_json" #define UCI_CPE_BOOT_INFORM_JSON "cwmp.cpe.boot_inform_json" -#define UCI_CPE_JSON_CUSTOM_NOTIFY_FILE "cwmp.cpe.json_custom_notify_file" +#define UCI_CPE_JSON_CUSTOM_NOTIFY_FILE "cwmp.cpe.custom_notify_json" #define LW_NOTIFICATION_ENABLE "cwmp.lwn.enable" #define LW_NOTIFICATION_HOSTNAME "cwmp.lwn.hostname" #define LW_NOTIFICATION_PORT "cwmp.lwn.port" diff --git a/inc/notifications.h b/inc/notifications.h index 16754cb..28ffe63 100644 --- a/inc/notifications.h +++ b/inc/notifications.h @@ -62,7 +62,7 @@ void add_list_value_change(char *param_name, char *param_data, char *param_type) void clean_list_value_change(); char *cwmp_set_parameter_attributes(char *parameter_name, int notification); char *cwmp_get_parameter_attributes(char *parameter_name, struct list_head *parameters_list); -void load_json_custom_notify_file(struct cwmp *cwmp); +void load_custom_notify_json(struct cwmp *cwmp); void add_lw_list_value_change(char *param_name, char *param_data, char *param_type); char *calculate_lwnotification_cnonce(); void cwmp_lwnotification(); diff --git a/notifications.c b/notifications.c index e95d75f..d47dc1c 100644 --- a/notifications.c +++ b/notifications.c @@ -381,14 +381,14 @@ void cwmp_update_enabled_notify_file(void) /* * Load custom notify json file */ -void load_json_custom_notify_file(struct cwmp *cwmp) +void load_custom_notify_json(struct cwmp *cwmp) { struct blob_buf bbuf; struct blob_attr *cur; struct blob_attr *custom_notify_list = NULL; int rem, fd; - if (cwmp->conf.json_custom_notify_file == NULL || !file_exists(cwmp->conf.json_custom_notify_file)) + if (cwmp->conf.custom_notify_json == NULL || !file_exists(cwmp->conf.custom_notify_json)) return; if (file_exists("/etc/icwmpd/.icwmpd_notify")) @@ -397,8 +397,8 @@ void load_json_custom_notify_file(struct cwmp *cwmp) memset(&bbuf, 0, sizeof(struct blob_buf)); blob_buf_init(&bbuf, 0); - if (blobmsg_add_json_from_file(&bbuf, cwmp->conf.json_custom_notify_file) == false) { - CWMP_LOG(WARNING, "The file %s is not a valid JSON file", cwmp->conf.json_custom_notify_file); + if (blobmsg_add_json_from_file(&bbuf, cwmp->conf.custom_notify_json) == false) { + CWMP_LOG(WARNING, "The file %s is not a valid JSON file", cwmp->conf.custom_notify_json); blob_buf_free(&bbuf); creat("/etc/icwmpd/.icwmpd_notify", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); return; @@ -414,7 +414,7 @@ void load_json_custom_notify_file(struct cwmp *cwmp) custom_notify_list = tb_notif[0]; if (custom_notify_list == NULL) { - CWMP_LOG(WARNING, "The JSON file %s doesn't contain a notify parameters list", cwmp->conf.json_custom_notify_file); + CWMP_LOG(WARNING, "The JSON file %s doesn't contain a notify parameters list", cwmp->conf.custom_notify_json); blob_buf_free(&bbuf); creat("/etc/icwmpd/.icwmpd_notify", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); return; diff --git a/schemas/uci/cwmp.json b/schemas/uci/cwmp.json index 4772804..2ecf916 100644 --- a/schemas/uci/cwmp.json +++ b/schemas/uci/cwmp.json @@ -276,7 +276,21 @@ "type": "string", "required": "no", "default": "", - "description": "Define additional parameters as forced inform parameter. See readme for examples." + "description": "Define absolute path for the JSON containing additional parameters as forced inform parameter. See readme for examples." + }, + { + "name": "boot_inform_json", + "type": "string", + "required": "no", + "default": "", + "description": "Define absolute path for the JSON containing additional parameters as boot inform parameter. These parameters only gets added if the notify event is '0 Bootstrap' or '1 Boot'. To enable value change notification, please use custom_notify_json, See readme for examples." + }, + { + "name": "custom_notify_json", + "type": "string", + "required": "no", + "default": "", + "description": "Define absolute path of the JSON containing parameters on which notification get enabled as per the definition. See readme for examples." } ] }, diff --git a/test/script/verify_custom_notifications.sh b/test/script/verify_custom_notifications.sh index f625c3e..0f6824e 100755 --- a/test/script/verify_custom_notifications.sh +++ b/test/script/verify_custom_notifications.sh @@ -18,7 +18,7 @@ rm /var/log/icwmpd.log uci delete cwmp.@notifications[0] uci commit cwmp -exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_valid.json" +exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_valid.json" uci commit cwmp supervisorctl start icwmpd @@ -47,7 +47,7 @@ rm /var/log/icwmpd.log uci delete cwmp.@notifications[0] uci commit cwmp -exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_invalid_json.json" +exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_invalid_json.json" uci commit cwmp supervisorctl start icwmpd @@ -81,7 +81,7 @@ rm /var/log/icwmpd.log uci delete cwmp.@notifications[0] uci commit cwmp -exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_forced.json" +exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_forced.json" uci commit cwmp supervisorctl start icwmpd @@ -115,7 +115,7 @@ rm /var/log/icwmpd.log uci delete cwmp.@notifications[0] uci commit cwmp -exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_invalid_parameter.json" +exec_cmd uci set cwmp.cpe.custom_notify_json="/etc/icwmpd/custom_notification_invalid_parameter.json" uci commit cwmp supervisorctl start icwmpd