bbf: commit uci changes under bbfdm repo when calling get_value, get_name, etc...

- commit uci changes under '/etc/bbfdm' when calling all methods except set/add/delete
 - align icwmp cli with bbf changes
 - remove unused functions
This commit is contained in:
Amin Ben Ramdhane 2020-12-02 22:37:40 +01:00
parent 423dcafe48
commit 15d02b20fa
7 changed files with 31 additions and 34 deletions

View file

@ -67,9 +67,9 @@ int bbfdmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *pack
return dmuci_lookup_ptr(ctx, ptr, package, section, option, value);
}
void bbf_apply_end_session(void)
int bbf_uci_commit_bbfdm(void)
{
apply_end_session();
return dmuci_commit_bbfdm();
}
int bbf_set_ip_version(int ipversion)

View file

@ -18,7 +18,7 @@
extern unsigned int upnp_in_user_mask;
extern struct list_head list_execute_end_session;
void bbf_apply_end_session(void);
int bbf_uci_commit_bbfdm(void);
int set_bbfdatamodel_type(int bbf_type);
int get_bbfdatamodel_type(void);
int bbf_set_ip_version(int ipversion);
@ -37,7 +37,6 @@ void apply_end_session(void);
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data);
void bbf_set_end_session_flag (struct dmctx *ctx, 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);
void dmbbf_update_enabled_notify_file(unsigned int dm_type, unsigned int amd_version, int instance_mode);
int get_dm_type(char *dm_str);

View file

@ -259,6 +259,7 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
{
int err = 0, fault = 0;
bool setnotif = true;
bool bbfdm_commit = true;
#ifdef BBF_TR064
bool alarm = false, event = false;
int err2 = 0;
@ -305,6 +306,7 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
fault = dm_entry_set_value(ctx);
if (fault)
add_list_fault_param(ctx, ctx->in_param, usp_fault_map(fault));
bbfdm_commit = false;
break;
case CMD_SET_NOTIFICATION:
if (arg2)
@ -331,6 +333,7 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
dmuci_change_packages(&head_package_change);
}
bbfdm_commit = false;
break;
case CMD_DEL_OBJECT:
fault = dm_entry_delete_object(ctx);
@ -338,6 +341,7 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
dmuci_change_packages(&head_package_change);
}
bbfdm_commit = false;
break;
case CMD_USP_OPERATE:
ctx->in_value = arg1 ? arg1 : "";
@ -409,6 +413,10 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
break;
#endif
}
if (bbfdm_commit)
dmuci_commit_bbfdm();
dmuci_save();
return usp_fault_map(fault);
}
@ -885,12 +893,6 @@ int dm_entry_revert_changes(void)
return 0;
}
void dm_apply_config(void)
{
apply_end_session();
dm_entry_restart_services();
}
#ifdef BBF_TR064
int dm_entry_upnp_restart_services(void)
{
@ -904,12 +906,6 @@ int dm_entry_upnp_restart_services(void)
return 0;
}
void dm_upnp_apply_config(void)
{
apply_end_session();
dm_entry_upnp_restart_services();
}
int cli_output_dm_upnp_variable_state(struct dmctx *dmctx, int cmd, char *variable)
{
switch (cmd) {
@ -1499,8 +1495,10 @@ void dm_execute_cli_shell(int argc, char** argv, unsigned int dmtype, unsigned i
}
dm_ctx_clean(&cli_dmctx);
if (apply_services) {
dm_apply_config();
dmuci_commit_bbfdm();
dm_entry_restart_services();
}
if (!fault) {
@ -1817,8 +1815,10 @@ int dmentry_cli(int argc, char *argv[], unsigned int dmtype, unsigned int amd_ve
}
dm_ctx_clean(&cli_dmctx);
if (apply_services) {
dm_apply_config();
dmuci_commit_bbfdm();
dm_entry_restart_services();
}
if (!fault) {

View file

@ -39,7 +39,6 @@ int dm_entry_revert_changes(void);
int usp_fault_map(int fault);
#ifdef BBF_TR064
int dm_entry_upnp_restart_services(void);
void dm_upnp_apply_config(void);
int dm_entry_upnp_check_alarmonchange_param(struct dmctx *dmctx);
int dm_entry_upnp_check_eventonchange_param(struct dmctx *dmctx);
int dm_entry_upnp_check_versiononchange_param(struct dmctx *pctx);

View file

@ -621,7 +621,6 @@ int free_dm_browse_node_dynamic_object_tree(DMNODE *parent_node, DMOBJ *entryobj
int dm_entry_get_full_param_value(struct dmctx *dmctx);
char* check_parameter_forced_notification(char *parameter);
#ifdef BBF_TR064
void dm_upnp_apply_config(void);
void add_list_upnp_param_track(struct dmctx *dmctx, struct list_head *pchead, char *param, char *key, char *value, unsigned int isobj);
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
int dm_entry_upnp_get_supported_parameters(struct dmctx *dmctx);

View file

@ -274,7 +274,7 @@ end:
return o;
}
/**** UCI Commit *****/
/**** UCI COMMIT *****/
int dmuci_commit_package(char *package)
{
struct uci_ptr ptr = {0};
@ -291,7 +291,6 @@ int dmuci_commit_package(char *package)
int dmuci_commit(void)
{
char **configs = NULL;
char **bbfdm_configs = NULL;
char **p;
int rc = 0;
@ -299,26 +298,17 @@ int dmuci_commit(void)
rc = -1;
goto end;
}
for (p = configs; *p; p++)
dmuci_commit_package(*p);
if (uci_ctx_bbfdm) {
if ((uci_list_configs(uci_ctx_bbfdm, &bbfdm_configs) != UCI_OK) || !bbfdm_configs) {
rc = -1;
goto out;
}
for (p = bbfdm_configs; *p; p++)
dmuci_commit_package_bbfdm(*p);
free(bbfdm_configs);
}
out:
free(configs);
end:
return rc;
}
/**** UCI SAVE *****/
int dmuci_save_package(char *package)
{
struct uci_ptr ptr = {0};

View file

@ -280,6 +280,15 @@ int dmuci_commit_package_##UCI_PATH(char *package) \
uci_ctx = save_uci_ctx; \
return res; \
}\
int dmuci_commit_##UCI_PATH(void) \
{\
struct uci_context *save_uci_ctx; \
save_uci_ctx = uci_ctx; \
uci_ctx = uci_ctx_##UCI_PATH; \
int res = dmuci_commit(); \
uci_ctx = save_uci_ctx; \
return res; \
}\
int dmuci_save_package_##UCI_PATH(char *package) \
{\
struct uci_context *save_uci_ctx; \
@ -331,6 +340,7 @@ int dmuci_delete_bbfdm(char *package, char *section, char *option, char *value);
int dmuci_delete_by_section_unnamed_bbfdm(struct uci_section *s, char *option, char *value);
int dmuci_delete_by_section_bbfdm(struct uci_section *s, char *option, char *value);
int dmuci_commit_package_bbfdm(char *package);
int dmuci_commit_bbfdm(void);
struct uci_section *dmuci_walk_section_bbfdm(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk);
void alloc_uci_ctx_bbfdm(void);