mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-01-27 17:17:17 +01:00
Align option names for notification configuration
This commit is contained in:
parent
393e67dec2
commit
411edf136f
10 changed files with 65 additions and 30 deletions
19
README.md
19
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.
|
||||
|
||||
|
|
|
|||
10
config.c
10
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;
|
||||
}
|
||||
|
|
|
|||
10
cwmp.c
10
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();
|
||||
|
|
|
|||
|
|
@ -357,7 +357,21 @@
|
|||
<td class="td_row_even"><div class="td_row_even">string</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">no</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even"></div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">Define additional parameters as forced inform parameter. See readme for examples.</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">Define absolute path for the JSON containing additional parameters as forced inform parameter. See readme for examples.</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_row_even"><div class="td_row_even">boot_inform_json</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">string</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">no</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even"></div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">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.</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td_row_even"><div class="td_row_even">custom_notify_json</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">string</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">no</div></td>
|
||||
<td class="td_row_even"><div class="td_row_even"></div></td>
|
||||
<td class="td_row_even"><div class="td_row_even">Define absolute path of the JSON containing parameters on which notification get enabled as per the definition. See readme for examples.</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue