diff --git a/config/cwmp b/config/cwmp index e43b16d..b710f49 100644 --- a/config/cwmp +++ b/config/cwmp @@ -38,6 +38,7 @@ config cpe 'cpe' option notification '1' option datamodel 'tr181' option exec_download '0' + option polling_period '5' config lwn 'lwn' option enable '1' diff --git a/config/icwmp_notifd b/config/icwmp_notifd deleted file mode 100644 index 84a402c..0000000 --- a/config/icwmp_notifd +++ /dev/null @@ -1,2 +0,0 @@ -config icwmp_notifd 'icwmp_notif' - option polling_period '5' \ No newline at end of file diff --git a/icwmp-notifd/icwmp-notifd.c b/icwmp-notifd/icwmp-notifd.c index 5f1b85c..ea049a1 100644 --- a/icwmp-notifd/icwmp-notifd.c +++ b/icwmp-notifd/icwmp-notifd.c @@ -28,6 +28,8 @@ static void polling_parse_icwmp_active_notifications() { struct uci_element *e, *tmp; struct uci_list *list_notif; + LIST_HEAD(listnotif); + list_notif = &listnotif; struct uci_ptr ptr = {0}; char *parameter = NULL, *notification = NULL, *value = NULL, *jval; struct dmctx dmctx = {0}; @@ -51,16 +53,12 @@ static void polling_parse_icwmp_active_notifications() if (fp == NULL) return; - while (fgets(buf, 512, fp) != NULL) { - dm_ctx_init(&dmctx, DM_CWMP, 5, INSTANCE_MODE_NUMBER); int len = strlen(buf); - if (len) buf[len-1] = '\0'; - dmjson_parse_init(buf); dmjson_get_var("parameter", &jval); parameter = strdup(jval); @@ -70,49 +68,34 @@ static void polling_parse_icwmp_active_notifications() notification = strdup(jval); dmjson_parse_fini(); - if (list_notif) { - + if (list_notif && !uci_list_empty(list_notif)) { uci_foreach_element(list_notif, e) { - if (e->name && strcmp(e->name, parameter) == 0) { fault = dm_entry_param_method(&dmctx, CMD_GET_VALUE, parameter, NULL, NULL); - if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) { - dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list); - if (strcmp(dm_parameter->data, value) != 0) { if (pubus_call("tr069", "notify", 0, UBUS_ARGS{}) < 0){ continue; } } - } - } - } } - if(parameter) { - free(parameter); parameter = NULL; } - if(notification) { free(notification); notification = NULL; } - if(value) { free(value); value = NULL; } - - } - end: uloop_timeout_set(&active_notif_timer, polling_period && atoi(polling_period)?atoi(polling_period)*1000:5000); } diff --git a/icwmp-notifd/uci.c b/icwmp-notifd/uci.c index fc7a3b5..f2ebe85 100644 --- a/icwmp-notifd/uci.c +++ b/icwmp-notifd/uci.c @@ -57,11 +57,13 @@ lookup: return 0; } -void load_uci_config(char **polling_period) { +void load_uci_config(char **polling_period) +{ struct uci_context *c = uci_alloc_context(); struct uci_ptr ptr; char *s; - s= strdup(UCI_OPTION_POLLING_PERIOD); + + s= strdup(UCI_OPTION_CPE_NOTIF_POLLING_PERIOD); if (uci_lookup_ptr(c, &ptr, s, true) != UCI_OK) { diff --git a/icwmp-notifd/uci.h b/icwmp-notifd/uci.h index 1cd5c44..d046ec1 100644 --- a/icwmp-notifd/uci.h +++ b/icwmp-notifd/uci.h @@ -15,5 +15,5 @@ #include bool check_section_name(const char *str, bool name); int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value); -#define UCI_OPTION_POLLING_PERIOD "icwmp_notifd.icwmp_notif.polling_period" +#define UCI_OPTION_CPE_NOTIF_POLLING_PERIOD "cwmp.cpe.polling_period" #endif diff --git a/init/icwmp_notifd b/init/icwmp_notifd deleted file mode 100644 index e636cf2..0000000 --- a/init/icwmp_notifd +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=95 -STOP=01 - -USE_PROCD=1 -NAME=icwmp_notifd - -start_service() { - procd_open_instance - procd_set_param command "/usr/sbin/icwmp_notifd" - procd_close_instance -} - -stop() { - service_stop /usr/sbin/icwmp_notifd -} - -service_triggers() -{ - procd_add_reload_trigger icwmp_notifd -} - -reload_service() { - stop - start -} \ No newline at end of file diff --git a/init/icwmpd.init b/init/icwmpd.init index a529acb..915af32 100644 --- a/init/icwmpd.init +++ b/init/icwmpd.init @@ -208,6 +208,11 @@ start_service() { fi procd_set_param respawn "3" "7" "0" procd_close_instance + procd_open_instance + if [ "$(uci -q get cwmp.cpe.notification)" == "1" ]; then + procd_append_param command "/usr/sbin/icwmp_notifd" + fi + procd_close_instance fi }