mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-02-12 19:10:07 +01:00
remove the use of new config and init files && enahancement of the code
This commit is contained in:
parent
3499487844
commit
bbb2a21e8f
7 changed files with 14 additions and 52 deletions
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
config icwmp_notifd 'icwmp_notif'
|
||||
option polling_period '5'
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@
|
|||
#include <libbbfdm/dmbbfcommon.h>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue