diff --git a/dmbbfcommon.c b/dmbbfcommon.c index df207e9b..4df297a3 100644 --- a/dmbbfcommon.c +++ b/dmbbfcommon.c @@ -53,7 +53,6 @@ void apply_end_session() list_del(&(p->list)); cwmp_free_dm_end_session(p); } - return 0; } void cwmp_set_end_session (unsigned int flag) @@ -88,9 +87,9 @@ int bbf_set_ip_version(int ipversion) return 0; } -void bbf_del_list_parameter(struct dm_parameter *dm_parameter) +void del_list_parameter(struct dm_parameter *dm_parameter) { - del_list_parameter(dm_parameter); + api_del_list_parameter(dm_parameter); } int dm_update_file_enabled_notify(char *param, char *new_value) @@ -133,8 +132,3 @@ void dm_update_enabled_notify(struct dm_enabled_notify *p, char *new_value) free(p->value); // Should be free and not dmfree p->value = strdup(new_value); } - -struct list_head get_bbf_list_enabled_lw_notify(void) -{ - return list_enabled_lw_notify; -} diff --git a/dmbbfcommon.h b/dmbbfcommon.h index c0a5c065..3203e587 100644 --- a/dmbbfcommon.h +++ b/dmbbfcommon.h @@ -19,7 +19,7 @@ int bbfdmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *pack void bbf_apply_end_session(void); int set_bbfdatamodel_type(int bbf_type); int bbf_set_ip_version(int ipversion); -void bbf_del_list_parameter(struct dm_parameter *dm_parameter); +void del_list_parameter(struct dm_parameter *dm_parameter); int dm_update_file_enabled_notify(char *param, char *new_value); void dmjson_parse_init(char *msg); void dmjson_parse_fini(void); @@ -28,9 +28,9 @@ void del_list_fault_param(struct param_fault *param_fault); int copy_temporary_file_to_original_file(char *f1, char *f2); void dmjson_get_var(char *jkey, char **jval); void dm_update_enabled_notify(struct dm_enabled_notify *p, char *new_value); -struct list_head get_bbf_list_enabled_lw_notify(void); - void apply_end_session(void); int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data); void cwmp_set_end_session (unsigned int flag); +int bbfdmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value); +void bbf_apply_end_session(void); diff --git a/dmentry.c b/dmentry.c index 0fe3e928..882e0926 100644 --- a/dmentry.c +++ b/dmentry.c @@ -18,12 +18,14 @@ #include "dmoperate.h" #include "device.h" #include "wepkey.h" +#include "dmbbfcommon.h" #ifdef BBF_TR064 #include "upnp_device.h" #endif LIST_HEAD(head_package_change); +LIST_HEAD(list_enabled_lw_notify); unsigned char dmcli_timetrack = 0; unsigned char dmcli_evaluatetest = 0; @@ -429,6 +431,35 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2) return usp_fault_map(fault); } +void add_list_enabled_lwnotify(char *param, char *notification, char *value) +{ + struct dm_enabled_notify *dm_enabled_notify; + + dm_enabled_notify = calloc(1, sizeof(struct dm_enabled_notify)); // Should be calloc and not dmcalloc + list_add_tail(&dm_enabled_notify->list, &list_enabled_lw_notify); + dm_enabled_notify->name = strdup(param); // Should be strdup and not dmstrdup + dm_enabled_notify->value = value ? strdup(value) : strdup(""); // Should be strdup and not dmstrdup + dm_enabled_notify->notification = strdup(notification); // Should be strdup and not dmstrdup +} + +void del_list_enabled_notify(struct dm_enabled_notify *dm_enabled_notify) +{ + list_del(&dm_enabled_notify->list); // Should be free and not dmfree + free(dm_enabled_notify->name); + free(dm_enabled_notify->value); + free(dm_enabled_notify->notification); + free(dm_enabled_notify); +} + +void free_all_list_enabled_lwnotify() +{ + struct dm_enabled_notify *dm_enabled_notify; + while (list_enabled_lw_notify.next != &list_enabled_lw_notify) { + dm_enabled_notify = list_entry(list_enabled_lw_notify.next, struct dm_enabled_notify, list); + del_list_enabled_notify(dm_enabled_notify); + } +} + int dm_entry_load_enabled_notify(unsigned int dm_type, unsigned int amd_version, int instance_mode, void (*add_list_value_change)(char *param_name, char *param_data, char *param_type), void (*send_active_value_change)(void)) { struct dmctx dmctx = {0}; @@ -438,7 +469,7 @@ int dm_entry_load_enabled_notify(unsigned int dm_type, unsigned int amd_version, free_all_list_enabled_lwnotify(); dm_entry_enabled_notify_check_value_change(&dmctx, add_list_value_change, send_active_value_change); - dm_entry_enabled_notify(&dmctx); + dm_entry_enabled_notify(&dmctx, add_list_enabled_lwnotify); dm_ctx_clean(&dmctx); return 0; @@ -452,7 +483,7 @@ int dm_entry_reload_enabled_notify(unsigned int dm_type, unsigned int amd_versio dmctx.in_param = ""; free_all_list_enabled_lwnotify(); - dm_entry_enabled_notify(&dmctx); + dm_entry_enabled_notify(&dmctx, add_list_enabled_lwnotify); dm_ctx_clean(&dmctx); return 0; diff --git a/dmentry.h b/dmentry.h index 2acff840..06c4afed 100644 --- a/dmentry.h +++ b/dmentry.h @@ -20,6 +20,7 @@ extern struct list_head head_package_change; extern unsigned char dmcli_timetrack; extern unsigned char dmcli_evaluatetest; +extern struct list_head list_enabled_lw_notify; enum ctx_init_enum { CTX_INIT_ALL, diff --git a/dmtree/tr143/diagnostics.c b/dmtree/tr143/diagnostics.c index 2b8c3083..d3a79c78 100644 --- a/dmtree/tr143/diagnostics.c +++ b/dmtree/tr143/diagnostics.c @@ -11,6 +11,7 @@ #include "dmentry.h" #include "diagnostics.h" +#include "dmbbfcommon.h" static int get_diag_enable_true(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { diff --git a/dmtree/tr181/dns.c b/dmtree/tr181/dns.c index b3101335..c1fee619 100644 --- a/dmtree/tr181/dns.c +++ b/dmtree/tr181/dns.c @@ -10,6 +10,7 @@ #include "dmentry.h" #include "dns.h" +#include "dmbbfcommon.h" static inline char *nslookup_get(char *option, char *def) { diff --git a/dmtree/tr181/firewall.c b/dmtree/tr181/firewall.c index 77dc029a..bd73171d 100644 --- a/dmtree/tr181/firewall.c +++ b/dmtree/tr181/firewall.c @@ -791,8 +791,6 @@ static int set_rule_order(char *refparam, struct dmctx *ctx, void *data, char *i static int set_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { - struct uci_section *dms = NULL; - switch (action) { case VALUECHECK: if (dm_validate_string(value, -1, 256, NULL, 0, NULL, 0)) diff --git a/dmtree/tr181/managementserver.c b/dmtree/tr181/managementserver.c index 0edaab08..1972547b 100644 --- a/dmtree/tr181/managementserver.c +++ b/dmtree/tr181/managementserver.c @@ -11,6 +11,7 @@ */ #include "managementserver.h" +#include "dmbbfcommon.h" /*#Device.ManagementServer.URL!UCI:cwmp/acs,acs/url*/ static int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) diff --git a/libbbf_api/dmbbf.c b/libbbf_api/dmbbf.c index d9e5ca84..1ec6e743 100644 --- a/libbbf_api/dmbbf.c +++ b/libbbf_api/dmbbf.c @@ -93,7 +93,6 @@ LIST_HEAD(list_upnp_changed_version); #endif LIST_HEAD(list_enabled_notify); -LIST_HEAD(list_enabled_lw_notify); int* end_session_flag_ptr = NULL; int ip_version = 4; @@ -104,6 +103,7 @@ int bbfdatamodel_type = BBFDM_BOTH; void (*api_add_list_value_change)(char *param_name, char *param_data, char *param_type) = NULL; void (*api_send_active_value_change)(void) = NULL; +void (*api_add_list_enabled_lwnotify)(char *param, char *notification, char *value) = NULL; struct notification notifications[] = { [0] = {"0", "disabled"}, @@ -773,7 +773,7 @@ void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, dm_parameter->flags = flags; } -void del_list_parameter(struct dm_parameter *dm_parameter) +void api_del_list_parameter(struct dm_parameter *dm_parameter) { list_del(&dm_parameter->list); dmfree(dm_parameter->name); @@ -785,7 +785,7 @@ void free_all_list_parameter(struct dmctx *ctx) struct dm_parameter *dm_parameter; while (ctx->list_parameter.next != &ctx->list_parameter) { dm_parameter = list_entry(ctx->list_parameter.next, struct dm_parameter, list); - del_list_parameter(dm_parameter); + api_del_list_parameter(dm_parameter); } } @@ -843,35 +843,6 @@ void free_all_list_fault_param(struct dmctx *ctx) } } -void add_list_enabled_lwnotify(struct dmctx *dmctx, char *param, char *notification, char *value) -{ - struct dm_enabled_notify *dm_enabled_notify; - - dm_enabled_notify = calloc(1, sizeof(struct dm_enabled_notify)); // Should be calloc and not dmcalloc - list_add_tail(&dm_enabled_notify->list, &list_enabled_lw_notify); - dm_enabled_notify->name = strdup(param); // Should be strdup and not dmstrdup - dm_enabled_notify->value = value ? strdup(value) : strdup(""); // Should be strdup and not dmstrdup - dm_enabled_notify->notification = strdup(notification); // Should be strdup and not dmstrdup -} - -void del_list_enabled_notify(struct dm_enabled_notify *dm_enabled_notify) -{ - list_del(&dm_enabled_notify->list); // Should be free and not dmfree - free(dm_enabled_notify->name); - free(dm_enabled_notify->value); - free(dm_enabled_notify->notification); - free(dm_enabled_notify); -} - -void free_all_list_enabled_lwnotify() -{ - struct dm_enabled_notify *dm_enabled_notify; - while (list_enabled_lw_notify.next != &list_enabled_lw_notify) { - dm_enabled_notify = list_entry(list_enabled_lw_notify.next, struct dm_enabled_notify, list); - del_list_enabled_notify(dm_enabled_notify); - } -} - int bbf_api_dm_update_file_enabled_notify(char *param, char *new_value) { FILE *fp, *ftmp; @@ -1762,12 +1733,13 @@ static int mobj_set_notification_in_param(DMOBJECT_ARGS) /********************* * load enabled notify ********************/ -int dm_entry_enabled_notify(struct dmctx *dmctx) +int dm_entry_enabled_notify(struct dmctx *dmctx, void (*add_list_enabled_lwnotify_arg)(char *param, char *notification, char *value)) { int err; DMOBJ *root = dmctx->dm_entryobj; DMNODE node = { .current_object = "" }; + api_add_list_enabled_lwnotify = add_list_enabled_lwnotify_arg; dmctx->method_obj = enabled_notify_check_obj; dmctx->method_param = enabled_notify_check_param; dmctx->checkobj = NULL ; @@ -1813,8 +1785,8 @@ static int enabled_notify_check_param(DMPARAM_ARGS) } fclose(fp); - if (notif[0] >= '3') { - add_list_enabled_lwnotify(dmctx, refparam, notif, value); + if (api_add_list_enabled_lwnotify != NULL && notif[0] >= '3') { + api_add_list_enabled_lwnotify(refparam, notif, value); } dmfree(refparam); return 0; diff --git a/libbbf_api/dmbbf.h b/libbbf_api/dmbbf.h index daeeaec2..ea1e69a0 100644 --- a/libbbf_api/dmbbf.h +++ b/libbbf_api/dmbbf.h @@ -67,6 +67,7 @@ extern struct dm_notif_s DMPASSIVE; extern void (*api_add_list_value_change)(char *param_name, char *param_data, char *param_type); extern void (*api_send_active_value_change)(void); +extern void (*api_add_list_enabled_lwnotify)(char *param, char *notification, char *value); #define DMPARAM_ARGS \ struct dmctx *dmctx, \ struct dmnode *node, \ @@ -516,7 +517,6 @@ enum { }; extern struct list_head list_enabled_notify; -extern struct list_head list_enabled_lw_notify; #ifdef BBF_TR064 extern struct list_head list_upnp_enabled_onevent; @@ -533,6 +533,7 @@ extern char dm_delim; extern char dmroot[64]; extern int bbfdatamodel_type; + char *update_instance(struct uci_section *s, char *last_inst, char *inst_opt); char *update_instance_bbfdm(struct uci_section *s, char *last_inst, char *inst_opt); char *update_instance_alias_bbfdm(int action, char **last_inst , void *argv[]); @@ -540,7 +541,7 @@ char *update_instance_alias(int action, char **last_inst , void *argv[]); char *update_instance_without_section(int action, char **last_inst, void *argv[]); int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags); -void del_list_parameter(struct dm_parameter *dm_parameter); +void api_del_list_parameter(struct dm_parameter *dm_parameter); void free_all_list_parameter(struct dmctx *ctx); void add_set_list_tmp(struct dmctx *ctx, char *param, char *value, unsigned int flags); void del_set_list_tmp(struct set_tmp *set_tmp); @@ -558,7 +559,7 @@ int dm_entry_add_object(struct dmctx *ctx); int dm_entry_delete_object(struct dmctx *ctx); int dm_entry_set_value(struct dmctx *ctx); int dm_entry_set_notification(struct dmctx *ctx); -int dm_entry_enabled_notify(struct dmctx *ctx); +int dm_entry_enabled_notify(struct dmctx *dmctx, void (*add_list_enabled_lwnotify_arg)(char *param, char *notification, char *value)); int dm_entry_enabled_notify_check_value_change(struct dmctx *dmctx, void (*add_list_value_change_arg)(char *param_name, char *param_data, char *param_type), void (*send_active_value_change_arg)(void)); int dm_entry_get_linker(struct dmctx *ctx); int dm_entry_get_linker_value(struct dmctx *ctx); @@ -587,7 +588,6 @@ char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_ int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data); void bbf_api_cwmp_set_end_session (unsigned int flag); char *dm_print_path(char *fpath, ...); -void free_all_list_enabled_lwnotify(); int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance); void dm_check_dynamic_obj(struct dmctx *dmctx, DMNODE *parent_node, DMOBJ *entryobj, char *full_obj, char *obj, DMOBJ **root_entry, int *obj_found); int free_dm_browse_node_dynamic_object_tree(DMNODE *parent_node, DMOBJ *entryobj);