Enhance bbf libs separation: upnp_in_user_mask, list_execute_end_session, apply_end_session, cwmp_set_end_session

This commit is contained in:
Omar Kallel 2020-06-23 10:27:04 +01:00
parent b6be5bdaa0
commit ca758fd9f3
4 changed files with 66 additions and 87 deletions

View file

@ -6,12 +6,71 @@
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*/
#include "dmbbfcommon.h"
int end_session_flag = 0;
unsigned int upnp_in_user_mask = DM_SUPERADMIN_MASK;
LIST_HEAD(list_execute_end_session);
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data)
{
struct execute_end_session *execute_end_session;
execute_end_session = calloc (1,sizeof(struct execute_end_session));
if (execute_end_session == NULL)
{
return -1;
}
execute_end_session->action = action;
execute_end_session->data = data;
execute_end_session->function = function;
execute_end_session->amd_version = ctx->amd_version;
execute_end_session->instance_mode = ctx->instance_mode;
execute_end_session->dm_type = ctx->dm_type;
list_add_tail (&(execute_end_session->list), &(list_execute_end_session));
return 0;
}
int cwmp_free_dm_end_session(struct execute_end_session *execute_end_session)
{
if(execute_end_session != NULL)
{
FREE(execute_end_session);
}
return 0;
}
void apply_end_session()
{
struct execute_end_session *p, *q;
list_for_each_entry_safe(p, q, &(list_execute_end_session), list) {
p->function(p);
list_del(&(p->list));
cwmp_free_dm_end_session(p);
}
return 0;
}
void cwmp_set_end_session (unsigned int flag)
{
if (end_session_flag_ptr != NULL)
end_session_flag = *end_session_flag_ptr;
end_session_flag_ptr = &end_session_flag;
end_session_flag |= flag;
}
int set_bbfdatamodel_type(int bbf_type)
{
bbfdatamodel_type = bbf_type;
return 0;
}
int bbfdmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value)
{
return dmuci_lookup_ptr(ctx, ptr, package, section, option, value);
@ -22,17 +81,6 @@ void bbf_apply_end_session(void)
apply_end_session();
}
int set_bbfdatamodel_type(int bbf_type)
{
bbfdatamodel_type = bbf_type;
return 0;
}
int set_upnp_in_user_mask(unsigned int upnp_user_mask)
{
upnp_in_user_mask = upnp_user_mask;
return 0;
}
int bbf_set_ip_version(int ipversion)
{
@ -40,27 +88,11 @@ int bbf_set_ip_version(int ipversion)
return 0;
}
int set_bbf_end_session_flag(int flag)
{
return (end_session_flag & flag);
}
int reset_bbf_end_session_flag(void)
{
end_session_flag = 0;
return 0;
}
void bbf_del_list_parameter(struct dm_parameter *dm_parameter)
{
del_list_parameter(dm_parameter);
}
void bbf_cwmp_set_end_session (unsigned int flag)
{
cwmp_set_end_session (flag);
}
int bbfdm_update_file_enabled_notify(char *param, char *new_value)
{
return dm_update_file_enabled_notify(param, new_value);
@ -105,12 +137,3 @@ struct list_head get_bbf_list_enabled_lw_notify(void)
{
return list_enabled_lw_notify;
}
void cwmp_set_end_session (unsigned int flag)
{
if (end_session_flag_ptr != NULL) {
end_session_flag = *end_session_flag_ptr;
end_session_flag_ptr = &end_session_flag;
}
end_session_flag |= flag;
}

View file

@ -6,22 +6,20 @@
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*/
#include <libbbf_api/dmcommon.h>
extern int end_session_flag;
extern unsigned int upnp_in_user_mask;
extern struct list_head list_execute_end_session;
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);
int set_bbfdatamodel_type(int bbf_type);
int set_upnp_in_user_mask(unsigned int upnp_user_mask);
int bbf_set_ip_version(int ipversion);
int set_bbf_end_session_flag(int flag);
int reset_bbf_end_session_flag(void);
void bbf_del_list_parameter(struct dm_parameter *dm_parameter);
void bbf_cwmp_set_end_session (unsigned int flag);
int bbfdm_update_file_enabled_notify(char *param, char *new_value);
void bbfdmjson_parse_init(char *msg);
void bbfdmjson_parse_fini(void);
@ -32,4 +30,7 @@ void bbfdmjson_get_var(char *jkey, char **jval);
void bbfdm_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);

View file

@ -94,14 +94,12 @@ LIST_HEAD(list_upnp_changed_version);
LIST_HEAD(list_enabled_notify);
LIST_HEAD(list_enabled_lw_notify);
LIST_HEAD(list_execute_end_session);
int* end_session_flag_ptr = NULL;
int ip_version = 4;
char dm_delim = DMDELIM_CWMP;
char dmroot[64] = "Device";
int bbfdatamodel_type = BBFDM_BOTH;
unsigned int upnp_in_user_mask = DM_SUPERADMIN_MASK;
void (*api_add_list_value_change)(char *param_name, char *param_data, char *param_type) = NULL;
void (*api_send_active_value_change)(void) = NULL;
@ -3167,46 +3165,6 @@ static int enabled_tracked_param_check_param(DMPARAM_ARGS)
/********************/
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data)
{
struct execute_end_session *execute_end_session;
execute_end_session = calloc (1,sizeof(struct execute_end_session));
if (execute_end_session == NULL)
{
return -1;
}
execute_end_session->action = action;
execute_end_session->data = data;
execute_end_session->function = function;
execute_end_session->amd_version = ctx->amd_version;
execute_end_session->instance_mode = ctx->instance_mode;
execute_end_session->dm_type = ctx->dm_type;
list_add_tail (&(execute_end_session->list), &(list_execute_end_session));
return 0;
}
int cwmp_free_dm_end_session(struct execute_end_session *execute_end_session)
{
if(execute_end_session != NULL)
{
FREE(execute_end_session);
}
return 0;
}
int apply_end_session()
{
struct execute_end_session *p, *q;
list_for_each_entry_safe(p, q, &(list_execute_end_session), list) {
p->function(p);
list_del(&(p->list));
cwmp_free_dm_end_session(p);
}
return 0;
}
void bbf_api_cwmp_set_end_session (unsigned int flag)
{
if(end_session_flag_ptr == NULL)

View file

@ -517,7 +517,6 @@ enum {
extern struct list_head list_enabled_notify;
extern struct list_head list_enabled_lw_notify;
extern struct list_head list_execute_end_session;
#ifdef BBF_TR064
extern struct list_head list_upnp_enabled_onevent;
@ -533,7 +532,6 @@ extern int ip_version;
extern char dm_delim;
extern char dmroot[64];
extern int bbfdatamodel_type;
extern unsigned int upnp_in_user_mask;
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);
@ -588,7 +586,6 @@ char *get_last_instance_lev2_bbfdm_dmmap_opt(char* dmmap_package, char *section,
char *get_last_instance_lev2_bbfdm(char *package, char *section, char* dmmap_package, char *opt_inst, char *opt_check, char *value_check);
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_inst, char * (*up_instance)(int action, char **last_inst, void *argv[]), int argc, ...);
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data);
int apply_end_session();
void bbf_api_cwmp_set_end_session (unsigned int flag);
char *dm_print_path(char *fpath, ...);
void free_all_list_enabled_lwnotify();