support linker in the param value get (when value is another param path)

This commit is contained in:
Anis Ellouze 2015-08-31 11:41:43 +01:00 committed by MOHAMED Kallel
parent 6c7671cd70
commit ff529fe94e
5 changed files with 134 additions and 3 deletions

View file

@ -731,13 +731,11 @@ int save_acs_bkp_config(struct cwmp *cwmp)
}
int cwmp_get_deviceid(struct cwmp *cwmp) {
dm_global_init();
cwmp->deviceid.manufacturer = strdup(get_deviceid_manufacturer()); //TODO free
cwmp->deviceid.serialnumber = strdup(get_deviceid_serialnumber());
cwmp->deviceid.productclass = strdup(get_deviceid_productclass());
cwmp->deviceid.oui = strdup(get_deviceid_manufactureroui());
cwmp->deviceid.softwareversion = strdup(get_softwareversion());
dm_global_clean();
return CWMP_OK;
}
@ -774,7 +772,10 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
{
return error;
}
dm_global_init();
cwmp_get_deviceid(cwmp);
dm_entry_load_enabled_notify();
dm_global_clean();
return CWMP_OK;
}
@ -787,5 +788,6 @@ int cwmp_config_reload(struct cwmp *cwmp)
{
return error;
}
dm_entry_load_enabled_notify();
return CWMP_OK;
}

View file

@ -60,6 +60,10 @@ static int set_notification_check_obj(DMOBJECT_API_ARGS);
static int set_notification_check_param(DMPARAM_API_ARGS);
static int enabled_notify_check_obj(DMOBJECT_API_ARGS);
static int enabled_notify_check_param(DMPARAM_API_ARGS);
static int get_linker_check_obj(DMOBJECT_API_ARGS);
static int get_linker_check_param(DMOBJECT_API_ARGS);
static int get_linker_value_check_obj(DMOBJECT_API_ARGS);
static int get_linker_value_check_param(DMOBJECT_API_ARGS);
LIST_HEAD(list_enabled_notify);
@ -997,7 +1001,7 @@ int dm_entry_enabled_notify(struct dmctx *ctx)
ctx->method_param = &enabled_notify_check_param;
for (i = 0; i < ARRAY_SIZE(prefix_methods); i++) {
if (!prefix_methods[i].enable) continue;
prefix_methods[i].method(ctx);
prefix_methods[i].method(ctx);
}
return 0;
}
@ -1031,3 +1035,80 @@ static int enabled_notify_check_param(DMPARAM_API_ARGS)
dmfree(full_param);
return 0;
}
/******************
* get linker param
*****************/
int dm_entry_get_linker(struct dmctx *ctx)
{
int i;
ctx->method_obj = &get_linker_check_obj;
ctx->method_param = &get_linker_check_param;
for (i = 0; i < ARRAY_SIZE(prefix_methods); i++) {
if (!prefix_methods[i].enable) continue;
int ret = prefix_methods[i].method(ctx);
if (ctx->stop)
return ret;
}
return 0;
}
static int get_linker_check_obj(DMOBJECT_API_ARGS)
{
if (linker && strcmp(linker, ctx->linker) == 0) {
ctx->linker_param = dmstrdup(ctx->current_obj);
ctx->stop = true;
return 0;
}
return FAULT_9005;
}
static int get_linker_check_param(DMPARAM_API_ARGS)
{
if (linker && strcmp(linker, ctx->linker) == 0) {
dmastrcat(&(ctx->linker_param), ctx->current_obj, lastname);
ctx->stop = true;
return 0;
}
return FAULT_9005;
}
/******************
* get linker value
*****************/
int dm_entry_get_linker_value(struct dmctx *ctx)
{
int i;
ctx->method_obj = &get_linker_value_check_obj;
ctx->method_param = &get_linker_value_check_param;
for (i = 0; i < ARRAY_SIZE(prefix_methods); i++) {
if (!prefix_methods[i].enable) continue;
int ret = prefix_methods[i].method(ctx);
if (ctx->stop)
return ret;
}
return 0;
}
static int get_linker_value_check_obj(DMOBJECT_API_ARGS)
{
if (linker && strcmp(ctx->current_obj, ctx->in_param) == 0) {
ctx->linker = dmstrdup(linker);
ctx->stop = true;
return 0;
}
return FAULT_9005;
}
static int get_linker_value_check_param(DMPARAM_API_ARGS)
{
char *refparam;
dmastrcat(&refparam, ctx->current_obj, lastname);
if (linker && strcmp(refparam, ctx->in_param) == 0) {
ctx->linker = dmstrdup(linker);
ctx->stop = true;
return 0;
}
return FAULT_9005;
}

View file

@ -123,6 +123,8 @@ struct dmctx
char *in_notification;
char *in_value;
char *addobj_instance;
char *linker;
char *linker_param;
char current_obj[512];
};
@ -204,6 +206,8 @@ int dm_entry_set_value(struct dmctx *ctx);
int dm_entry_set_notification(struct dmctx *ctx);
int dm_entry_set_prefix_methods_enable(void);
int dm_entry_enabled_notify(struct dmctx *ctx);
int dm_entry_get_linker(struct dmctx *ctx);
int dm_entry_get_linker_value(struct dmctx *ctx);
void free_all_list_enabled_notify();
void dm_update_enabled_notify(struct dm_enabled_notify *p, char *new_value);
void dm_update_enabled_notify_byname(char *name, char *new_value);

View file

@ -186,6 +186,48 @@ int dm_entry_load_enabled_notify()
return 0;
}
int adm_entry_get_linker_param(char *param, char *linker, char **value)
{
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
dmctx.in_param = param ? param : "";
dmctx.linker = linker;
if (dmctx.in_param[0] == '\0') {
dmctx.tree = true;
} else {
dmctx.tree = false;
}
dm_entry_get_linker(&dmctx);
*value = dmctx.linker_param;
dm_ctx_clean(&dmctx);
return 0;
}
int adm_entry_get_linker_value(char *param, char **value)
{
struct dmctx dmctx = {0};
*value = NULL;
if (!param || param[0] == '\0') {
return 0;
}
dm_ctx_init(&dmctx);
dmctx.in_param = param;
dmctx.tree = false;
dm_entry_get_linker_value(&dmctx);
*value = dmctx.linker;
dm_ctx_clean(&dmctx);
return 0;
}
int cli_output_dm_result(struct dmctx *dmctx, int fault, int cmd, int out)
{
if (!out) return 0;

View file

@ -8,6 +8,8 @@ int dm_ctx_init(struct dmctx *ctx);
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2);
int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2);
int dm_entry_load_enabled_notify();
int adm_entry_get_linker_param(char *param, char *linker, char **value);
int adm_entry_get_linker_value(char *param, char **value);
int dm_ctx_clean(struct dmctx *ctx);
int dm_global_clean(void);
void dm_entry_cli(int argc, char** argv);