diff --git a/libbbfdm-api/dmapi.c b/libbbfdm-api/dmapi.c index 63067178..378c268f 100644 --- a/libbbfdm-api/dmapi.c +++ b/libbbfdm-api/dmapi.c @@ -222,8 +222,10 @@ int bbf_set_alias(struct dmctx *ctx, struct uci_section *s, char *option_name, c return 0; } -int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value) +int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value) // To be removed later!!!!!!!!!!!! { + BBF_ERR("Use bbfdm_get_references API in place of %s API, this API will be removed later!!!", __func__); + if (DM_STRLEN(path) == 0 || DM_STRLEN(key_name) == 0 || DM_STRLEN(key_value) == 0 || !value) return -1; @@ -231,8 +233,10 @@ int bbf_get_reference_param(char *path, char *key_name, char *key_value, char ** return 0; } -int bbf_get_reference_args(char *value, struct dm_reference *reference_args) +int bbf_get_reference_args(char *value, struct dm_reference *reference_args) // To be removed later!!!!!!!!!!!! { + BBF_ERR("Use bbfdm_get_reference_linker API in place of %s API, this API will be removed later!!!", __func__); + if (DM_STRLEN(value) == 0) return -1; @@ -249,6 +253,95 @@ int bbf_get_reference_args(char *value, struct dm_reference *reference_args) return 0; } +int bbfdm_get_references(struct dmctx *ctx, int match_action, const char *base_path, char *key_name, char *key_value, char *out, size_t out_len) +{ + char param_path[1024] = {0}; + char *value = NULL; + + if (DM_STRLEN(base_path) == 0) { + BBF_ERR("Reference base path should not be empty!!!"); + return -1; + } + + if (DM_STRLEN(key_name) == 0) { + BBF_ERR("Reference key name should not be empty!!!"); + return -1; + } + + if (DM_STRLEN(key_value) == 0) { + BBF_ERR("Reference key value should not be empty!!!"); + return -1; + } + + if (!out || !out_len) { + BBF_ERR("Output buffer is NULL or has zero length. A valid buffer with sufficient size is required"); + return -1; + } + + snprintf(param_path, sizeof(param_path), "%s*.%s", base_path, key_name); + + adm_entry_get_reference_param(ctx, param_path, key_value, &value); + + size_t len = strlen(out); + + if (DM_STRLEN(value) != 0) { + + if (out_len - len < strlen(value)) { + BBF_ERR("Buffer overflow detected. The output buffer is not large enough to hold the additional data!!!"); + return -1; + } + + snprintf(&out[len], out_len - len, "%s%s", len ? (match_action == MATCH_FIRST ? "," : ";") : "", value); + goto end; + } + + if (is_micro_service == true) { // It's a micro-service instance + + if (out_len - len < strlen(base_path) + strlen(key_name) + strlen(key_value) + 9) { // 9 = 'path[key_name==\"key_value\"].' + BBF_ERR("Buffer overflow detected. The output buffer is not large enough to hold the additional data!!!"); + return -1; + } + + snprintf(&out[len], out_len - len, "%s%s[%s==\"%s\"].", len ? (match_action == MATCH_FIRST ? "," : ";") : "", base_path, key_name, key_value); + } + +end: + return 0; +} + +int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_name, char *key_value, char **value) +{ + char buf[1024] = {0}; + + int res = bbfdm_get_references(ctx, MATCH_FIRST, base_path, key_name, key_value, buf, sizeof(buf)); + + *value = (!res) ? dmstrdup(buf): ""; + + return 0; +} + +int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct dm_reference *reference_args) +{ + if (DM_STRLEN(reference_path) == 0) { + bbfdm_set_fault_message(ctx, "%s: reference path should not be empty", __func__); + return -1; + } + + reference_args->path = reference_path; + + char *separator = strstr(reference_path, "=>"); + if (!separator) { + bbfdm_set_fault_message(ctx, "%s: reference path must contain '=>' symbol to separate the path and value", __func__); + return -1; + } + + *separator = 0; + + reference_args->value = separator + 2; + + return 0; +} + __attribute__ ((deprecated)) int bbf_validate_string(char *value, int min_length, int max_length, char *enumeration[], char *pattern[]) { struct dmctx ctx = {0}; diff --git a/libbbfdm-api/dmapi.h b/libbbfdm-api/dmapi.h index b47b7f75..2c0bd488 100644 --- a/libbbfdm-api/dmapi.h +++ b/libbbfdm-api/dmapi.h @@ -271,6 +271,11 @@ enum { BBF_EVENT, }; +enum { + MATCH_FIRST, + MATCH_ALL +}; + enum usp_fault_code_enum { USP_FAULT_GENERAL_FAILURE = 7000, // general failure USP_FAULT_MESSAGE_NOT_UNDERSTOOD = 7001, // message was not understood diff --git a/libbbfdm-api/dmbbf.c b/libbbfdm-api/dmbbf.c index ed45ea8a..9b182c80 100644 --- a/libbbfdm-api/dmbbf.c +++ b/libbbfdm-api/dmbbf.c @@ -873,52 +873,60 @@ static int is64digit(char c) char *get_value_by_reference(struct dmctx *ctx, char *value) { - char *pch = NULL, *spch = NULL, *val = NULL; + if (is_micro_service == true) // It's a micro-service instance + return value; + + char *pch = NULL, *spch = NULL; char buf[MAX_DM_PATH * 4] = {0}; char buf_val[MAX_DM_PATH * 4] = {0}; bool is_list = false; int pos = 0; - if (DM_STRLEN(value) == 0 || !DM_LSTRSTR(value, "==")) + if (DM_STRLEN(value) == 0) return value; DM_STRNCPY(buf, value, sizeof(buf)); - if (DM_STRCHR(buf, '&')) + if (DM_STRCHR(buf, ';')) is_list = true; buf_val[0] = 0; - for (pch = strtok_r(buf, is_list ? "&" : ",", &spch); pch; pch = strtok_r(NULL, is_list ? "&" : ",", &spch)) { - char path[MAX_DM_PATH] = {0}; - char key_name[256], key_value[256]; - regmatch_t pmatch[2]; + for (pch = strtok_r(buf, is_list ? ";" : ",", &spch); pch; pch = strtok_r(NULL, is_list ? ";" : ",", &spch)) { + char *val = NULL; - bool res = match(pch, "\\[(.*?)\\]", 2, pmatch); - if (!res) - goto end; + if (DM_LSTRSTR(pch, "==")) { + char path[MAX_DM_PATH] = {0}; + char key_name[256], key_value[256]; + regmatch_t pmatch[2]; - snprintf(path, pmatch[0].rm_so + 1, "%s", pch); - int len = DM_STRLEN(path); - if (!len) - goto end; + bool res = match(pch, "\\[(.*?)\\]", 2, pmatch); + if (!res) + continue; - char *match_str = pch + pmatch[1].rm_so; - if (DM_STRLEN(match_str) == 0) - goto end; + snprintf(path, pmatch[0].rm_so + 1, "%s", pch); + int len = DM_STRLEN(path); + if (!len) + continue; - int n = sscanf(match_str, "%255[^=]==\"%255[^\"]\"", key_name, key_value); - if (n != 2) { - n = sscanf(match_str, "%255[^=]==%255[^]]", key_name, key_value); + char *match_str = pch + pmatch[1].rm_so; + if (DM_STRLEN(match_str) == 0) + continue; + + int n = sscanf(match_str, "%255[^=]==\"%255[^\"]\"", key_name, key_value); if (n != 2) { - goto end; + n = sscanf(match_str, "%255[^=]==%255[^]]", key_name, key_value); + if (n != 2) + continue; } + + snprintf(path + len, sizeof(path) - len, "*.%s", key_name); + + adm_entry_get_reference_param(ctx, path, key_value, &val); + } else { + val = pch; } - snprintf(path + len, sizeof(path) - len, "*.%s", key_name); - - adm_entry_get_reference_param(ctx, path, key_value, &val); - if (DM_STRLEN(val)) { pos += snprintf(&buf_val[pos], sizeof(buf_val) - pos, "%s,", val); @@ -932,11 +940,10 @@ char *get_value_by_reference(struct dmctx *ctx, char *value) return dmstrdup(buf_val); } -end: - return is_micro_service ? value : ""; + return ""; } -static bool has_same_reference(char *curr_value, char *new_value) +static bool has_same_reference(struct dmctx *ctx, char *curr_value, char *new_value) { struct dm_reference reference = {0}; char buf[MAX_DM_PATH * 4] = {0}; @@ -944,7 +951,7 @@ static bool has_same_reference(char *curr_value, char *new_value) char *pch = NULL, *spch = NULL; snprintf(param_value, sizeof(param_value), "%s", new_value); - bbf_get_reference_args(param_value, &reference); + bbfdm_get_reference_linker(ctx, param_value, &reference); DM_STRNCPY(buf, curr_value, sizeof(buf)); @@ -2366,7 +2373,7 @@ static int mparam_set_value(DMPARAM_ARGS) if (DM_LSTRSTR(dmctx->in_value, "=>") == NULL) get_reference_paramater_value(dmctx, dmctx->in_value, param_value, sizeof(param_value)); - if (has_same_reference(value, param_value)) { + if (has_same_reference(dmctx, value, param_value)) { BBF_DEBUG("Requested value (%s) is same as current value (%s)", dmctx->in_value, value); return 0; } diff --git a/libbbfdm-api/dmcommon.h b/libbbfdm-api/dmcommon.h index 05c4ea66..78eb2aef 100644 --- a/libbbfdm-api/dmcommon.h +++ b/libbbfdm-api/dmcommon.h @@ -239,10 +239,10 @@ void get_dmmap_section_of_config_section_cont(char* dmmap_package, char* section void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section); int adm_entry_get_reference_param(struct dmctx *ctx, char *param, char *linker, char **value); int adm_entry_get_reference_value(struct dmctx *ctx, char *param, char **value); -int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value); -int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value); -int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); -int dm_entry_validate_external_linker_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); +int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value); // To be removed later!!!!!!!!!!!! +int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value); // To be removed later!!!!!!!!!!!! +int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); // To be removed later!!!!!!!!!!!! +int dm_entry_validate_external_linker_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); // To be removed later!!!!!!!!!!!! int dm_validate_allowed_objects(struct dmctx *ctx, struct dm_reference *reference, char *objects[]); char *check_create_dmmap_package(const char *dmmap_package); unsigned int count_occurrences(const char *str, char c); @@ -301,8 +301,11 @@ int bbfdm_validate_string_list(struct dmctx *ctx, char *value, int min_item, int int bbfdm_validate_hexBinary_list(struct dmctx *ctx, char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size); int bbf_get_alias(struct dmctx *ctx, struct uci_section *s, char *option_name, char *instance, char **value); int bbf_set_alias(struct dmctx *ctx, struct uci_section *s, char *option_name, char *instance, char *value); -int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value); -int bbf_get_reference_args(char *value, struct dm_reference *reference_args); +int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value); // To be removed later!!!!!!!!!!!! +int bbf_get_reference_args(char *value, struct dm_reference *reference_args); // To be removed later!!!!!!!!!!!! +int bbfdm_get_references(struct dmctx *ctx, int match_action, const char *base_path, char *key_name, char *key_value, char *out, size_t out_len); +int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_name, char *key_value, char **value); +int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct dm_reference *reference_args); char *base64_decode(const char *src); void string_to_mac(const char *str, size_t str_len, char *out, size_t out_len); bool folder_exists(const char *path); diff --git a/libbbfdm-api/dmentry.c b/libbbfdm-api/dmentry.c index b839b93d..951401a0 100644 --- a/libbbfdm-api/dmentry.c +++ b/libbbfdm-api/dmentry.c @@ -257,6 +257,8 @@ void bbf_global_clean(DMOBJ *dm_entryobj) int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[]) // To be removed later!!!!!!!!!!!! { + BBF_ERR("%s API will be removed later, don't use it!!!!!!", __func__); + if (!value || !objects) return -1; @@ -280,6 +282,8 @@ int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *obje int dm_entry_validate_external_linker_allowed_objects(struct dmctx *ctx, char *value, char *objects[]) // To be removed later!!!!!!!!!!!! { + BBF_ERR("%s API will be removed later, don't use it!!!!!!", __func__); + if (!value || !objects) return -1; @@ -370,6 +374,8 @@ int adm_entry_get_reference_value(struct dmctx *ctx, char *param, char **value) int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value) // To be removed later!!!!!!!!!!!! { + BBF_ERR("%s API will be removed later, don't use it!!!!!!", __func__); + struct dmctx dmctx = {0}; *value = ""; @@ -390,6 +396,8 @@ int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, cha int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value) // To be removed later!!!!!!!!!!!! { + BBF_ERR("%s API will be removed later, don't use it!!!!!!", __func__); + struct dmctx dmctx = {0}; char linker[256] = {0}; *value = NULL; @@ -410,7 +418,7 @@ int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value) // return 0; } -bool adm_entry_object_exists(struct dmctx *ctx, char *param) +bool adm_entry_object_exists(struct dmctx *ctx, char *param) // To be removed later!!!!!!!!!!!! (After moving all Objects outside bbfdm core) { struct dmctx dmctx = {0}; char linker[256] = {0}; diff --git a/libbbfdm-api/dmentry.h b/libbbfdm-api/dmentry.h index 568ef68b..83002e92 100644 --- a/libbbfdm-api/dmentry.h +++ b/libbbfdm-api/dmentry.h @@ -28,14 +28,14 @@ int bbf_entry_method(struct dmctx *ctx, int cmd); void bbf_global_init(DMOBJ *dm_entryobj, const char *plugin_path); void bbf_global_clean(DMOBJ *dm_entryobj); -int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); -int dm_entry_validate_external_linker_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); +int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); // To be removed later!!!!!!!!!!!! +int dm_entry_validate_external_linker_allowed_objects(struct dmctx *ctx, char *value, char *objects[]); // To be removed later!!!!!!!!!!!! int dm_validate_allowed_objects(struct dmctx *ctx, struct dm_reference *reference, char *objects[]); -bool adm_entry_object_exists(struct dmctx *ctx, char *param); +bool adm_entry_object_exists(struct dmctx *ctx, char *param); // To be removed later!!!!!!!!!!!! (After moving all Objects outside bbfdm core) -int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value); -int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value); +int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value); // To be removed later!!!!!!!!!!!! +int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value); // To be removed later!!!!!!!!!!!! void bbf_entry_restart_services(struct blob_buf *bb, bool restart_services); void bbf_entry_revert_changes(struct blob_buf *bb); diff --git a/libbbfdm-api/include/libbbfdm_api.h b/libbbfdm-api/include/libbbfdm_api.h index 0b486907..6b0322d9 100644 --- a/libbbfdm-api/include/libbbfdm_api.h +++ b/libbbfdm-api/include/libbbfdm_api.h @@ -598,7 +598,7 @@ int bbf_set_alias(struct dmctx *ctx, struct uci_section *s, char *option_name, c ** \return 0 if operation is successful, -1 otherwise ** **************************************************************************/ -int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value); +int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value); // To be removed later!!!!!!!!!!!! /*********************************************************************//** ** @@ -612,7 +612,58 @@ int bbf_get_reference_param(char *path, char *key_name, char *key_value, char ** ** \return 0 if operation is successful, -1 otherwise ** **************************************************************************/ -int bbf_get_reference_args(char *value, struct dm_reference *reference_args); +int bbf_get_reference_args(char *value, struct dm_reference *reference_args); // To be removed later!!!!!!!!!!!! + +/*********************************************************************//** +** +** bbfdm_get_references +** +** This API is used to get the reference parameter value +** +** \param ctx - bbf context +** \param match_action - match all or first reference resolved based on MATCH_FIRST(,), MATCH_ALL(;) +** \param base_path - parent path object +** \param key_name - parameter name used to identify the object +** \param key_value - value of parameter name used to identify the object +** \param out - buffer where the value will be stored +** \param out - buffer size where the value will be stored +** +** \return 0 if operation is successful, -1 otherwise +** +**************************************************************************/ +int bbfdm_get_references(struct dmctx *ctx, int match_action, const char *base_path, char *key_name, char *key_value, char *out, size_t out_len); + +/*********************************************************************//** +** +** _bbfdm_get_references +** +** This API is similar to bbfdm_get_references but it is used to get only one reference +** +** \param ctx - bbf context +** \param base_path - parent path object +** \param key_name - parameter name used to identify the object +** \param key_value - value of parameter name used to identify the object +** \param value - pointer to where the value will be stored +** +** \return 0 if operation is successful, -1 otherwise +** +**************************************************************************/ +int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_name, char *key_value, char **value); + +/*********************************************************************//** +** +** bbf_get_linker_from_reference +** +** This API is used to get the reference arguments in order to set external linker +** +** \param ctx - bbf context +** \param reference_path - reference path +** \param reference - linker of the given reference path +** +** \return 0 if operation is successful, -1 otherwise +** +**************************************************************************/ +int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct dm_reference *reference_args); /*********************************************************************//** ** @@ -855,7 +906,10 @@ int bbfdm_validate_hexBinary_list(struct dmctx *ctx, char *value, int min_item, **************************************************************************/ void bbfdm_set_fault_message(struct dmctx *ctx, const char *format, ...); +int bbf_get_reference_param(char *path, char *key_name, char *key_value, char **value); +int bbf_get_reference_args(char *value, struct dm_reference *reference_args); +//TODO /********************** * * BBF DEPRECATED APIs diff --git a/libbbfdm-api/plugin/json_plugin.c b/libbbfdm-api/plugin/json_plugin.c index 7eb78f7f..02d8d3d0 100644 --- a/libbbfdm-api/plugin/json_plugin.c +++ b/libbbfdm-api/plugin/json_plugin.c @@ -1656,7 +1656,7 @@ static int setvalue_param(char *refparam, struct dmctx *ctx, void *data, char *i } } - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr143/diagnostics.c b/libbbfdm/dmtree/tr143/diagnostics.c index 7ff0f826..673ec809 100644 --- a/libbbfdm/dmtree/tr143/diagnostics.c +++ b/libbbfdm/dmtree/tr143/diagnostics.c @@ -78,7 +78,7 @@ static int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void static int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("ipping", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -87,7 +87,7 @@ static int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -332,7 +332,7 @@ static int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct d static int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("traceroute", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -341,7 +341,7 @@ static int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *c char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -587,7 +587,7 @@ static int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, static int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("download", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -596,7 +596,7 @@ static int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -917,7 +917,7 @@ static int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, s static int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("upload", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -926,7 +926,7 @@ static int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct d char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -1273,7 +1273,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, static int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("udpechodiag", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -1282,7 +1282,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -1553,7 +1553,7 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *re static int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("serverselection", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -1562,7 +1562,7 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/deviceinfo.c b/libbbfdm/dmtree/tr181/deviceinfo.c index 837cefa5..5af68561 100644 --- a/libbbfdm/dmtree/tr181/deviceinfo.c +++ b/libbbfdm/dmtree/tr181/deviceinfo.c @@ -975,7 +975,7 @@ static int get_device_active_fwimage(char *refparam, struct dmctx *ctx, void *da } snprintf(linker, sizeof(linker), "cpe-%s", id); - adm_entry_get_reference_param(ctx, "Device.DeviceInfo.FirmwareImage.*.Alias", linker, value); + _bbfdm_get_references(ctx, "Device.DeviceInfo.FirmwareImage.", "Alias", linker, value); return 0; } @@ -1000,7 +1000,7 @@ static int get_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data } snprintf(linker, sizeof(linker), "cpe-%s", id); - adm_entry_get_reference_param(ctx, "Device.DeviceInfo.FirmwareImage.*.Alias", linker, value); + _bbfdm_get_references(ctx, "Device.DeviceInfo.FirmwareImage.", "Alias", linker, value); return 0; } @@ -1009,7 +1009,7 @@ static int set_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data char *allowed_objects[] = {"Device.DeviceInfo.FirmwareImage.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/gre.c b/libbbfdm/dmtree/tr181/gre.c index 0121f20d..12a9f86a 100644 --- a/libbbfdm/dmtree/tr181/gre.c +++ b/libbbfdm/dmtree/tr181/gre.c @@ -627,7 +627,7 @@ static int get_GRETunnelInterface_LowerLayers(char *refparam, struct dmctx *ctx, dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "tunlink", &tunlink); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", tunlink, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", tunlink, value); // Store LowerLayers value dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "LowerLayers", *value); @@ -644,7 +644,7 @@ static int set_GRETunnelInterface_LowerLayers(char *refparam, struct dmctx *ctx, char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/ieee1905.c b/libbbfdm/dmtree/tr181/ieee1905.c index fcb50671..0702c205 100644 --- a/libbbfdm/dmtree/tr181/ieee1905.c +++ b/libbbfdm/dmtree/tr181/ieee1905.c @@ -540,16 +540,18 @@ static int get_IEEE1905ALInterface_Status(char *refparam, struct dmctx *ctx, voi /*#Device.IEEE1905.AL.Interface.{i}.LowerLayers!UBUS:ieee1905/info//interface[@i-1].ifname*/ static int get_IEEE1905ALInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { + char buf[256] = {0}; char *linker = dmjson_get_value((json_object *)data, 1, "ifname"); - adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", linker, value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Interface.", "Name", linker, buf, sizeof(buf)); - if (!DM_STRLEN(*value)) { + if (!DM_STRLEN(buf)) { struct uci_section *s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", linker); dmuci_get_value_by_section_string(s, "device", &linker); - adm_entry_get_reference_param(ctx, "Device.WiFi.Radio.*.Name", linker, value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.WiFi.Radio.", "Name", linker, buf, sizeof(buf)); } + *value = dmstrdup(buf); return 0; } @@ -1509,7 +1511,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex2( /*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.LocalInterface!UBUS:ieee1905/info//topology.device[@i-1].non1905_neighbors[@i-1].interface_macaddress*/ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_LocalInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.*.InterfaceId", ((struct ieee1905_device_nonieee1905neighbor_args *)data)->mac_addr, value); + _bbfdm_get_references(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.", "InterfaceId", ((struct ieee1905_device_nonieee1905neighbor_args *)data)->mac_addr, value); return 0; } @@ -1544,7 +1546,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_BehindInterface static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = ((struct ieee1905_device_ieee1905neighbor_args *)data)->mac_addr; - adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.*.InterfaceId", linker, value); + _bbfdm_get_references(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.", "InterfaceId", linker, value); return 0; } @@ -1638,22 +1640,13 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceLis json_object *json_obj = NULL; char *mac_addr = NULL; char buf[4096] = {0}; - unsigned pos = 0; int idx = 0; - buf[0] = 0; dmjson_foreach_value_in_array((json_object *)data, json_obj, mac_addr, idx, 1, "tuple") { - char *linker = NULL; - - adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.*.InterfaceId", mac_addr, &linker); - if (DM_STRLEN(linker) && (sizeof(buf) - pos) > 0) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", linker); + bbfdm_get_references(ctx, MATCH_ALL, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.", "InterfaceId", mac_addr, buf, sizeof(buf)); } - if (pos) - buf[pos - 1] = 0; - - *value = (buf[0] != '\0') ? dmstrdup(buf) : ""; + *value = dmstrdup(buf); return 0; } diff --git a/libbbfdm/dmtree/tr181/ip.c b/libbbfdm/dmtree/tr181/ip.c index 8137c4ce..767d47b5 100644 --- a/libbbfdm/dmtree/tr181/ip.c +++ b/libbbfdm/dmtree/tr181/ip.c @@ -1235,6 +1235,8 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * dmuci_get_value_by_section_string(dmmap_section, "LowerLayers", value); if ((*value)[0] == '\0') { + char buf[256] = {0}; + char *device = get_device(section_name((struct uci_section *)data)); if (DM_STRLEN(device) == 0) { dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device); @@ -1242,30 +1244,32 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * return 0; } - adm_entry_get_reference_param(ctx, "Device.PPP.Interface.*.Name", device, value); - if (DM_STRLEN(*value)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.PPP.Interface.", "Name", device, buf, sizeof(buf)); + if (DM_STRLEN(buf)) goto end; - adm_entry_get_reference_param(ctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.*.Name", device, value); - if (DM_STRLEN(*value)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "Name", device, buf, sizeof(buf)); + if (DM_STRLEN(buf)) goto end; - adm_entry_get_reference_param(ctx, "Device.Ethernet.VLANTermination.*.Name", device, value); - if (DM_STRLEN(*value)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.VLANTermination.", "Name", device, buf, sizeof(buf)); + if (DM_STRLEN(buf)) goto end; - adm_entry_get_reference_param(ctx, "Device.Ethernet.Link.*.Name", device, value); - if (DM_STRLEN(*value)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Link.", "Name", device, buf, sizeof(buf)); + if (DM_STRLEN(buf)) goto end; if ((DM_STRLEN(device) > 5) && DM_LSTRNCMP(device, "gre", 3) == 0) { // gre device name is of the form gre4- or gre6- - adm_entry_get_reference_param(ctx, "Device.GRE.Tunnel.*.Interface.*.Name", device + 5, value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.GRE.Tunnel.*.Interface.", "Name", device + 5, buf, sizeof(buf)); } end: // Store LowerLayers value - dmuci_set_value_by_section(dmmap_section, "LowerLayers", *value); + dmuci_set_value_by_section(dmmap_section, "LowerLayers", buf); + + *value = dmstrdup(buf); } else { if (!adm_entry_object_exists(ctx, *value)) *value = ""; @@ -1288,7 +1292,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * char *curr_device = NULL; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -1370,7 +1374,7 @@ static int get_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, dmuci_get_value_by_section_string((struct uci_section *)data, "ip4table", &ip4table); snprintf(linker, sizeof(linker), "route_table-%s", DM_STRLEN(ip4table) ? ip4table : "254"); - adm_entry_get_reference_param(ctx, "Device.Routing.Router.*.Alias", linker, value); + _bbfdm_get_references(ctx, "Device.Routing.Router.", "Alias", linker, value); // Store LowerLayers value dmuci_set_value_by_section(dmmap_section, "Router", *value); @@ -1386,7 +1390,7 @@ static int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, struct uci_section *s = NULL; char *device = NULL; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -2037,7 +2041,7 @@ static int get_IPInterfaceIPv6Prefix_ParentPrefix(char *refparam, struct dmctx * char *linker = NULL; dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "address", &linker); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.IPv6Prefix.*.ChildPrefixBits", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.*.IPv6Prefix.", "ChildPrefixBits", linker, value); } return 0; } diff --git a/libbbfdm/dmtree/tr181/mqtt.c b/libbbfdm/dmtree/tr181/mqtt.c index e753a5b1..2037bdb2 100644 --- a/libbbfdm/dmtree/tr181/mqtt.c +++ b/libbbfdm/dmtree/tr181/mqtt.c @@ -212,7 +212,7 @@ static int get_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat char *intf = NULL; dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &intf); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", intf, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", intf, value); return 0; } @@ -221,7 +221,7 @@ static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/packetcapture.c b/libbbfdm/dmtree/tr181/packetcapture.c index ffa42245..348c2e4f 100644 --- a/libbbfdm/dmtree/tr181/packetcapture.c +++ b/libbbfdm/dmtree/tr181/packetcapture.c @@ -194,7 +194,7 @@ static int set_PacketCapture_DiagnosticsState(char *refparam, struct dmctx *ctx, static int get_PacketCapture_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("packetcapture", "Interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -203,7 +203,7 @@ static int set_PacketCapture_Interface(char *refparam, struct dmctx *ctx, void * char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/ppp.c b/libbbfdm/dmtree/tr181/ppp.c index 06d306d4..c0442962 100644 --- a/libbbfdm/dmtree/tr181/ppp.c +++ b/libbbfdm/dmtree/tr181/ppp.c @@ -952,6 +952,7 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch if ((*value)[0] == '\0') { char *device = NULL; + char buf[256] = {0}; if (ppp->iface_s) { device = get_device(section_name(ppp->iface_s)); @@ -964,19 +965,21 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch if (DM_STRLEN(device) == 0) return 0; - adm_entry_get_reference_param(ctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.*.Name", device, value); - if (DM_STRLEN(*value)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "Name", device, buf, sizeof(buf)); + if (DM_STRLEN(buf)) goto end; - adm_entry_get_reference_param(ctx, "Device.Ethernet.VLANTermination.*.Name", device, value); - if (DM_STRLEN(*value)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.VLANTermination.", "Name", device, buf, sizeof(buf)); + if (DM_STRLEN(buf)) goto end; - adm_entry_get_reference_param(ctx, "Device.Ethernet.Link.*.Name", device, value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Link.", "Name", device, buf, sizeof(buf)); end: // Store LowerLayers value - dmuci_set_value_by_section(ppp->dmmap_s, "LowerLayers", *value); + dmuci_set_value_by_section(ppp->dmmap_s, "LowerLayers", buf); + + *value = dmstrdup(buf); } else { if (!adm_entry_object_exists(ctx, *value)) *value = ""; @@ -997,7 +1000,7 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch struct dm_reference reference = {0}; char proto[8] = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/routeradvertisement.c b/libbbfdm/dmtree/tr181/routeradvertisement.c index 9ba38c80..d054e677 100644 --- a/libbbfdm/dmtree/tr181/routeradvertisement.c +++ b/libbbfdm/dmtree/tr181/routeradvertisement.c @@ -287,7 +287,7 @@ static int get_RouterAdvertisementInterfaceSetting_Interface(char *refparam, str char *linker = NULL; dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &linker); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -296,7 +296,7 @@ static int set_RouterAdvertisementInterfaceSetting_Interface(char *refparam, str char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/routing.c b/libbbfdm/dmtree/tr181/routing.c index 5c7c9ee5..24998720 100644 --- a/libbbfdm/dmtree/tr181/routing.c +++ b/libbbfdm/dmtree/tr181/routing.c @@ -736,7 +736,7 @@ static int get_RoutingRouterForwarding_Interface(char *refparam, struct dmctx *c char *linker = NULL; dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "interface", &linker); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -745,7 +745,7 @@ static int set_RoutingRouterForwarding_Interface(char *refparam, struct dmctx *c char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -1054,7 +1054,7 @@ static int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam, } } - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", iface, value); return 0; } diff --git a/libbbfdm/dmtree/tr181/selftest.c b/libbbfdm/dmtree/tr181/selftest.c index c77ce032..88f395d5 100644 --- a/libbbfdm/dmtree/tr181/selftest.c +++ b/libbbfdm/dmtree/tr181/selftest.c @@ -28,10 +28,10 @@ static char *get_selftest_log_instance(struct dmctx *ctx) if (DM_STRLEN(file_name) == 0) goto err; - adm_entry_get_reference_param(ctx, "Device.DeviceInfo.VendorLogFile.*.Name", file_name, &path); + _bbfdm_get_references(ctx, "Device.DeviceInfo.VendorLogFile.", "Name", file_name, &path); err: - return dmstrdup(path ? path : ""); + return path ? path : dmstrdup(""); } /************************************************************* diff --git a/libbbfdm/dmtree/tr181/upnp.c b/libbbfdm/dmtree/tr181/upnp.c index 1ceb0ddf..7f5ac4c8 100644 --- a/libbbfdm/dmtree/tr181/upnp.c +++ b/libbbfdm/dmtree/tr181/upnp.c @@ -475,11 +475,14 @@ static int get_UPnPDiscoveryService_Location(char *refparam, struct dmctx *ctx, static int get_UPnPDiscoveryService_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.Device.*.UUID", ((struct upnpdiscovery *)data)->uuid, value); + char buf[256] = {0}; - if (!DM_STRLEN(*value)) - adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.RootDevice.*.UUID", ((struct upnpdiscovery *)data)->uuid, value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.UPnP.Discovery.Device.", "UUID", ((struct upnpdiscovery *)data)->uuid, buf, sizeof(buf)); + if (!DM_STRLEN(buf)) + bbfdm_get_references(ctx, MATCH_FIRST, "Device.UPnP.Discovery.RootDevice.", "UUID", ((struct upnpdiscovery *)data)->uuid, buf, sizeof(buf)); + + *value = dmstrdup(buf); return 0; } @@ -520,7 +523,7 @@ static int get_UPnPDescriptionDeviceInstance_UDN(char *refparam, struct dmctx *c static int get_UPnPDescriptionDeviceInstance_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - adm_entry_get_reference_param(ctx, "Device.UPnP.Description.DeviceInstance.*.UDN", ((struct upnp_device_inst *)data)->parentudn, value); + _bbfdm_get_references(ctx, "Device.UPnP.Description.DeviceInstance.", "UDN", ((struct upnp_device_inst *)data)->parentudn, value); return 0; } @@ -529,6 +532,7 @@ static int get_UPnPDescriptionDeviceInstance_DiscoveryDevice(char *refparam, str struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data; if (upnpdevinst->udn && upnpdevinst->udn[0]) { + char buf[256] = {0}; size_t length = 0; char **udnarray = strsplit(upnpdevinst->udn, ":", &length); @@ -536,10 +540,12 @@ static int get_UPnPDescriptionDeviceInstance_DiscoveryDevice(char *refparam, str if (length != 2) return 0; - adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.Device.*.UUID", udnarray[1], value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.UPnP.Discovery.Device.", "UUID", udnarray[1], buf, sizeof(buf)); if (!DM_STRLEN(*value)) - adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.RootDevice.*.UUID", udnarray[1], value); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.UPnP.Discovery.RootDevice.", "UUID", udnarray[1], buf, sizeof(buf)); + + *value = dmstrdup(buf); } return 0; @@ -624,7 +630,7 @@ static int get_UPnPDescriptionDeviceInstance_PresentationURL(char *refparam, str static int get_UPnPDescriptionServiceInstance_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - adm_entry_get_reference_param(ctx, "Device.UPnP.Description.DeviceInstance.*.UDN", ((struct upnp_service_inst *)data)->parentudn, value); + _bbfdm_get_references(ctx, "Device.UPnP.Description.DeviceInstance.", "UDN", ((struct upnp_service_inst *)data)->parentudn, value); return 0; } @@ -641,7 +647,7 @@ static int get_UPnPDescriptionServiceInstance_ServiceDiscovery(char *refparam, s snprintf(usn, sizeof(usn), "%s::%s", ((struct upnp_service_inst *)data)->parentudn, ((struct upnp_service_inst *)data)->servicetype); - adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.Service.*.USN", usn, value); + _bbfdm_get_references(ctx, "Device.UPnP.Discovery.Service.", "USN", usn, value); return 0; } diff --git a/libbbfdm/dmtree/tr181/wifi.c b/libbbfdm/dmtree/tr181/wifi.c index ee132247..dab28b5a 100644 --- a/libbbfdm/dmtree/tr181/wifi.c +++ b/libbbfdm/dmtree/tr181/wifi.c @@ -2428,7 +2428,7 @@ static int get_WiFiEndPoint_SSIDReference(char *refparam, struct dmctx *ctx, voi { struct uci_section *iface_s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", (char *)((struct dm_data *)data)->additional_data); - adm_entry_get_reference_param(ctx, "Device.WiFi.SSID.*.Name", section_name(iface_s), value); + _bbfdm_get_references(ctx, "Device.WiFi.SSID.", "Name", section_name(iface_s), value); return 0; } @@ -2879,7 +2879,8 @@ static int get_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, c char *device = NULL; dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "device", &device); - adm_entry_get_reference_param(ctx, "Device.WiFi.Radio.*.Name", device, value); + + _bbfdm_get_references(ctx, "Device.WiFi.Radio.", "Name", device, value); // Store LowerLayers value dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "LowerLayers", *value); @@ -2896,7 +2897,7 @@ static int set_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, c char *allowed_objects[] = {"Device.WiFi.Radio.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: @@ -2926,7 +2927,7 @@ static int get_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char * dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "LowerLayers", value); if ((*value)[0] == '\0') { - adm_entry_get_reference_param(ctx, "Device.WiFi.SSID.*.Name", section_name(((struct dm_data *)data)->config_section), value); + _bbfdm_get_references(ctx, "Device.WiFi.SSID.", "Name", section_name(((struct dm_data *)data)->config_section), value); // Store LowerLayers value dmuci_set_value_by_section(((struct dm_data *)data)->dmmap_section, "LowerLayers", *value); @@ -2944,7 +2945,7 @@ static int set_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char * struct uci_section *ss = NULL; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: diff --git a/libbbfdm/dmtree/tr181/wifi.dataelements.c b/libbbfdm/dmtree/tr181/wifi.dataelements.c index 0a91fdea..775f19ab 100644 --- a/libbbfdm/dmtree/tr181/wifi.dataelements.c +++ b/libbbfdm/dmtree/tr181/wifi.dataelements.c @@ -2797,7 +2797,7 @@ static int get_WiFiDataElementsNetworkDeviceMultiAPDevice_LastContactTime(char * static int get_WiFiDataElementsNetworkDeviceMultiAPDevice_AssocIEEE1905DeviceRef(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *device_id = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "ID"); - adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.IEEE1905Id", device_id, value); + _bbfdm_get_references(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", "IEEE1905Id", device_id, value); return 0; } diff --git a/libbbfdm/dmtree/tr471/iplayercap.c b/libbbfdm/dmtree/tr471/iplayercap.c index aa871215..724204d0 100644 --- a/libbbfdm/dmtree/tr471/iplayercap.c +++ b/libbbfdm/dmtree/tr471/iplayercap.c @@ -120,7 +120,7 @@ int get_IPDiagnosticsIPLayerCapacity_SupportedMetrics(char *refparam, struct dmc static int get_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = diagnostics_get_option("iplayercapacity", "interface"); - adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); return 0; } @@ -129,7 +129,7 @@ static int set_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmc char *allowed_objects[] = {"Device.IP.Interface.", NULL}; struct dm_reference reference = {0}; - bbf_get_reference_args(value, &reference); + bbfdm_get_reference_linker(ctx, value, &reference); switch (action) { case VALUECHECK: