From ae196c54590dc343db14a70879f21ef88203c426 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Sun, 20 Dec 2020 11:30:20 +0100 Subject: [PATCH] SoftwareModules: move it from TR157 to TR181 folder --- bin/Makefile.am | 11 +- configure.ac | 3 - dmoperate.c | 36 ++-- dmtree/tr181/device.c | 6 +- dmtree/{tr157 => tr181}/softwaremodules.c | 247 +++++++++------------- dmtree/{tr157 => tr181}/softwaremodules.h | 2 +- openwrt/bbf/Config_bbfdm.in | 8 - openwrt/bbf/Makefile | 11 - tools/generate_json.py | 3 - tools/generate_xml.sh | 4 +- tools/generate_xml_bbf.sh | 4 +- 11 files changed, 124 insertions(+), 211 deletions(-) rename dmtree/{tr157 => tr181}/softwaremodules.c (84%) rename dmtree/{tr157 => tr181}/softwaremodules.h (92%) diff --git a/bin/Makefile.am b/bin/Makefile.am index bfd37191..aa028de8 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -78,8 +78,9 @@ libbbfdm_la_SOURCES += \ ../dmtree/tr181/dynamicdns.c \ ../dmtree/tr181/security.c \ ../dmtree/tr181/lanconfigsecurity.c \ - ../dmtree/tr181/ieee1905.c \ - ../dmtree/tr181/qos.c + ../dmtree/tr181/ieee1905.c \ + ../dmtree/tr181/qos.c \ + ../dmtree/tr181/softwaremodules.c endif @@ -116,11 +117,6 @@ libbbfdm_la_SOURCES += \ ../dmtree/tr143/diagnostics.c endif -if BBF_TR157 -libbbfdm_la_SOURCES += \ - ../dmtree/tr157/softwaremodules.c -endif - libbbfdm_la_CFLAGS = \ $(AM_CFLAGS) \ $(LIBUCI_CFLAGS) \ @@ -151,4 +147,3 @@ libbbfdm_la_CFLAGS+=-I../ libbbfdm_la_CFLAGS+=-I../dmtree/tr181 libbbfdm_la_CFLAGS+=-I../dmtree/tr104 libbbfdm_la_CFLAGS+=-I../dmtree/tr143 -libbbfdm_la_CFLAGS+=-I../dmtree/tr157 diff --git a/configure.ac b/configure.ac index 669b79d4..5b9cc4a5 100644 --- a/configure.ac +++ b/configure.ac @@ -12,9 +12,6 @@ AM_CONDITIONAL([BBF_TR104],[test "x$enable_tr104" = "xyes"]) AC_ARG_ENABLE(tr143, [AS_HELP_STRING([--enable-tr143], [enable tr143 diagnostics feature])], AC_DEFINE(BBF_TR143),) AM_CONDITIONAL([BBF_TR143],[test "x$enable_tr143" = "xyes"]) -AC_ARG_ENABLE(tr157, [AS_HELP_STRING([--enable-tr157], [enable tr157 bulkdata collector feature])], AC_DEFINE(BBF_TR157),) -AM_CONDITIONAL([BBF_TR157],[test "x$enable_tr157" = "xyes"]) - AC_ARG_ENABLE(libopenssl, [AS_HELP_STRING([--enable-libopenssl], [enable libopenssl feature])], AC_DEFINE(LOPENSSL),) AM_CONDITIONAL([LOPENSSL],[test "x$enable_libopenssl" = "xyes"]) diff --git a/dmoperate.c b/dmoperate.c index 53bcc830..cfecf0d6 100644 --- a/dmoperate.c +++ b/dmoperate.c @@ -744,19 +744,17 @@ static opr_ret_t swmodules_install_du(struct dmctx *dmctx, char *path, json_obje du_install.username = dmjson_get_value(input, 1, "Username"); du_install.password = dmjson_get_value(input, 1, "Password"); du_install.environment = dmjson_get_value(input, 1, "ExecutionEnvRef"); - if (du_install.environment[0] == '\0') - return UBUS_INVALID_ARGUMENTS; - char *exec_env = get_param_val_from_op_cmd(du_install.environment, "Name"); + char *exec_env = get_param_val_from_op_cmd(du_install.environment ? du_install.environment : "Device.SoftwareModules.ExecEnv.1.", "Name"); if (!exec_env) return FAIL; - dmubus_call("swmodules", "du_install", - UBUS_ARGS{{"url", du_install.url}, - {"uuid", du_install.uuid}, - {"username", du_install.username}, - {"password", du_install.password}, - {"environment", exec_env}}, + dmubus_call("swmodules", "du_install", UBUS_ARGS{ + {"url", du_install.url}, + {"uuid", du_install.uuid}, + {"username", du_install.username}, + {"password", du_install.password}, + {"environment", exec_env}}, 5, &res); @@ -783,11 +781,11 @@ static opr_ret_t swmodules_update_du(struct dmctx *dmctx, char *path, json_objec if (!du_uuid) return FAIL; - dmubus_call("swmodules", "du_update", - UBUS_ARGS{{"uuid", du_uuid}, - {"url", du_update.url}, - {"username", du_update.username}, - {"password", du_update.password}}, + dmubus_call("swmodules", "du_update", UBUS_ARGS{ + {"uuid", du_uuid}, + {"url", du_update.url}, + {"username", du_update.username}, + {"password", du_update.password}}, 4, &res); @@ -802,6 +800,7 @@ static opr_ret_t swmodules_update_du(struct dmctx *dmctx, char *path, json_objec static opr_ret_t swmodules_uninstall_du(struct dmctx *dmctx, char *path, json_object *input) { json_object *res = NULL; + char exec_env_path[64] = {0}; char *du_name = get_param_val_from_op_cmd(path, "Name"); if (!du_name) @@ -811,13 +810,14 @@ static opr_ret_t swmodules_uninstall_du(struct dmctx *dmctx, char *path, json_ob if (!exec_env) return FAIL; - char *env = get_param_val_from_op_cmd(exec_env, "Name"); + snprintf(exec_env_path, sizeof(exec_env_path), "%s.", exec_env); + char *env = get_param_val_from_op_cmd(exec_env_path, "Name"); if (!env) return FAIL; - dmubus_call("swmodules", "du_uninstall", - UBUS_ARGS{{"name", du_name}, - {"environment", env}}, + dmubus_call("swmodules", "du_uninstall", UBUS_ARGS{ + {"name", du_name}, + {"environment", env}}, 2, &res); diff --git a/dmtree/tr181/device.c b/dmtree/tr181/device.c index 8ab44f4a..f7a86109 100644 --- a/dmtree/tr181/device.c +++ b/dmtree/tr181/device.c @@ -48,12 +48,10 @@ #include "lanconfigsecurity.h" #include "security.h" #include "ieee1905.h" +#include "softwaremodules.h" #ifdef BBF_TR104 #include "servicesvoiceservice.h" #endif -#ifdef BBF_TR157 -#include "softwaremodules.h" -#endif /* *** BBFDM *** */ DMOBJ tEntry181Obj[] = { @@ -113,9 +111,7 @@ DMOBJ tDeviceObj[] = { {"DynamicDNS", &DMREAD, NULL, NULL, "file:/etc/config/ddns", NULL, NULL, tDynamicDNSObj, tDynamicDNSParams, NULL, BBFDM_BOTH}, {"QoS", &DMREAD, NULL, NULL, "file:/etc/config/qos", NULL, NULL, tQoSObj, tQoSParams, NULL, BBFDM_BOTH}, {"LANConfigSecurity", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, tLANConfigSecurityParams, NULL, BBFDM_BOTH}, -#ifdef BBF_TR157 {"SoftwareModules", &DMREAD, NULL, NULL, "ubus:swmodules", NULL, NULL, tSoftwareModulesObj, tSoftwareModulesParams, NULL, BBFDM_BOTH}, -#endif {"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, tSecurityObj, tSecurityParams, NULL, BBFDM_BOTH}, {0} }; diff --git a/dmtree/tr157/softwaremodules.c b/dmtree/tr181/softwaremodules.c similarity index 84% rename from dmtree/tr157/softwaremodules.c rename to dmtree/tr181/softwaremodules.c index f132fa22..7eeaba1c 100644 --- a/dmtree/tr157/softwaremodules.c +++ b/dmtree/tr181/softwaremodules.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 iopsys Software Solutions AB + * Copyright (C) 2020 iopsys Software Solutions AB * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1 @@ -16,24 +16,16 @@ ***************************************************************************/ static int get_exe_cenv_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data) { - char *name = dmjson_get_value((json_object *)data, 1, "name"); - *linker = dmstrdup(name); - return 0; - } - *linker = ""; + char *name = dmjson_get_value((json_object *)data, 1, "name"); + *linker = (name && *name) ? dmstrdup(name) : ""; return 0; } static int get_du_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data) { - char *name = dmjson_get_value((json_object *)data, 1, "name"); - char *environment = dmjson_get_value((json_object *)data, 1, "environment"); - dmasprintf(linker, "%s-%s", name, environment); - return 0; - } - *linker = ""; + char *name = dmjson_get_value((json_object *)data, 1, "name"); + char *environment = dmjson_get_value((json_object *)data, 1, "environment"); + dmasprintf(linker, "%s-%s", name, environment); return 0; } @@ -44,15 +36,13 @@ static int browseSoftwareModulesExecEnvInst(struct dmctx *dmctx, DMNODE *parent_ { json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; char *inst, *max_inst = NULL; - int id = 0, j = 0; + int id = 0, env = 0; dmubus_call("swmodules", "environment", UBUS_ARGS{}, 0, &res); - if (res) { - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "environment") { - inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, ++id); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)du_obj, inst) == DM_STOP) - break; - } + dmjson_foreach_obj_in_array(res, arrobj, du_obj, env, 1, "environment") { + inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, ++id); + if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)du_obj, inst) == DM_STOP) + break; } return 0; } @@ -61,15 +51,13 @@ static int browseSoftwareModulesDeploymentUnitInst(struct dmctx *dmctx, DMNODE * { json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; char *inst, *max_inst = NULL; - int id = 0, j = 0; + int id = 0, du = 0; dmubus_call("swmodules", "du_list", UBUS_ARGS{}, 0, &res); - if (res) { - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "deployment_unit") { - inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, ++id); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)du_obj, inst) == DM_STOP) - break; - } + dmjson_foreach_obj_in_array(res, arrobj, du_obj, du, 1, "deployment_unit") { + inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, ++id); + if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)du_obj, inst) == DM_STOP) + break; } return 0; } @@ -78,15 +66,13 @@ static int browseSoftwareModulesExecutionUnitInst(struct dmctx *dmctx, DMNODE *p { json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; char *inst, *max_inst = NULL; - int id = 0, j = 0; + int id = 0, eu = 0; dmubus_call("swmodules", "eu_list", UBUS_ARGS{}, 0, &res); - if (res) { - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "execution_unit") { - inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, ++id); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)du_obj, inst) == DM_STOP) - break; - } + dmjson_foreach_obj_in_array(res, arrobj, du_obj, eu, 1, "execution_unit") { + inst = handle_update_instance(1, dmctx, &max_inst, update_instance_without_section, 1, ++id); + if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)du_obj, inst) == DM_STOP) + break; } return 0; } @@ -110,7 +96,7 @@ static int get_SoftwareModules_VendorConfigList(char *refparam, struct dmctx *ct if (name && strcmp(name, config) == 0) { char *vcf_instance; dmuci_get_value_by_section_string(s, "vcf_instance", &vcf_instance); - dmasprintf(value, "Device.DeviceInfo.VendorConfigFile.%s.", vcf_instance); + dmasprintf(value, "Device.DeviceInfo.VendorConfigFile.%s", vcf_instance); break; } } @@ -128,7 +114,7 @@ static int get_SoftwareModules_ExecEnvNumberOfEntries(char *refparam, struct dmc dmubus_call("swmodules", "environment", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = "0"); json_object_object_get_ex(res, "environment", &environment); - nbre_env = json_object_array_length(environment); + nbre_env = (environment) ? json_object_array_length(environment) : 0; dmasprintf(value, "%d", nbre_env); return 0; } @@ -141,7 +127,7 @@ static int get_SoftwareModules_DeploymentUnitNumberOfEntries(char *refparam, str dmubus_call("swmodules", "du_list", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = "0"); json_object_object_get_ex(res, "deployment_unit", &deployment_unit); - nbre_du = json_object_array_length(deployment_unit); + nbre_du = (deployment_unit) ? json_object_array_length(deployment_unit) : 0; dmasprintf(value, "%d", nbre_du); return 0; } @@ -154,7 +140,7 @@ static int get_SoftwareModules_ExecutionUnitNumberOfEntries(char *refparam, stru dmubus_call("swmodules", "eu_list", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = "0"); json_object_object_get_ex(res, "execution_unit", &execution_unit); - nbre_env = json_object_array_length(execution_unit); + nbre_env = (execution_unit) ? json_object_array_length(execution_unit) : 0; dmasprintf(value, "%d", nbre_env); return 0; } @@ -162,18 +148,15 @@ static int get_SoftwareModules_ExecutionUnitNumberOfEntries(char *refparam, stru /*#Device.SoftwareModules.ExecEnv.{i}.Enable!UBUS:swmodules/environment//environment[i-1].status*/ static int get_SoftwareModulesExecEnv_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = dmjson_get_value((json_object *)data, 1, "status"); - if (strcmp(*value, "Up") == 0) - *value = "1"; - else - *value = "0"; + char *status = dmjson_get_value((json_object *)data, 1, "status"); + *value = (status && strcmp(status, "Up") == 0) ? "1" : "0"; return 0; } static int set_SoftwareModulesExecEnv_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + char *env_name = NULL; bool b; - char *env_name; switch (action) { case VALUECHECK: @@ -183,12 +166,8 @@ static int set_SoftwareModulesExecEnv_Enable(char *refparam, struct dmctx *ctx, case VALUESET: string_to_bool(value, &b); env_name = dmjson_get_value((json_object *)data, 1, "name"); - if (strcmp(env_name, "OpenWRT_Linux")) { - if (b) - dmcmd_no_wait("/usr/bin/lxc-start", 2, "-n", env_name); - else - dmcmd_no_wait("/usr/bin/lxc-stop", 2, "-n", env_name); - } + if (env_name && strcmp(env_name, "OpenWRT_Linux") != 0) + dmcmd_no_wait(b ? "/usr/bin/lxc-start" : "/usr/bin/lxc-stop", 2, "-n", env_name); break; } return 0; @@ -209,8 +188,8 @@ static int get_SoftwareModulesExecEnv_Reset(char *refparam, struct dmctx *ctx, v static int set_SoftwareModulesExecEnv_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + char *env_name = NULL; bool b; - char *env_name; switch (action) { case VALUECHECK: @@ -220,7 +199,7 @@ static int set_SoftwareModulesExecEnv_Reset(char *refparam, struct dmctx *ctx, v case VALUESET: string_to_bool(value, &b); env_name = dmjson_get_value((json_object *)data, 1, "name"); - if (strcmp(env_name, "OpenWRT_Linux") == 0) { + if (env_name && strcmp(env_name, "OpenWRT_Linux") == 0) { if (b) dmcmd_no_wait("/sbin/defaultreset", 0); } break; @@ -231,18 +210,18 @@ static int set_SoftwareModulesExecEnv_Reset(char *refparam, struct dmctx *ctx, v static int get_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct uci_section *s = NULL; - char *env_name, *name; + char *env_name, *name = NULL; name = dmjson_get_value((json_object *)data, 1, "name"); - uci_path_foreach_sections(bbfdm, "dmmap", "environment", s) { + uci_path_foreach_sections(bbfdm, "dmmap_sw_modules", "environment", s) { dmuci_get_value_by_section_string(s, "name", &env_name); - if (strcmp(env_name, name) == 0) { + if (name && strcmp(env_name, name) == 0) { dmuci_get_value_by_section_string(s, "alias", value); - if ((*value)[0] == '\0') - dmasprintf(value, "cpe-%s", instance); - return 0; + break; } } + if ((*value)[0] == '\0') + dmasprintf(value, "cpe-%s", instance); return 0; } @@ -250,7 +229,7 @@ static int set_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, v { struct uci_section *s = NULL, *dmmap = NULL; char *name; - int found = 0; + bool found = false; switch (action) { case VALUECHECK: @@ -259,12 +238,12 @@ static int set_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, v break; case VALUESET: name = dmjson_get_value((json_object *)data, 1, "name"); - uci_path_foreach_option_eq(bbfdm, "dmmap", "environment", "name", name, s) { + uci_path_foreach_option_eq(bbfdm, "dmmap_sw_modules", "environment", "name", name, s) { dmuci_set_value_by_section_bbfdm(s, "alias", value); - found = 1; + found = true; } if (!found) { - dmuci_add_section_bbfdm("dmmap", "environment", &dmmap); + dmuci_add_section_bbfdm("dmmap_sw_modules", "environment", &dmmap); dmuci_set_value_by_section(dmmap, "name", name); dmuci_set_value_by_section(dmmap, "alias", value); } @@ -304,15 +283,10 @@ static int get_SoftwareModulesExecEnv_Version(char *refparam, struct dmctx *ctx, static int get_SoftwareModulesExecEnv_ParentExecEnv(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *env_name = dmjson_get_value((json_object *)data, 1, "name"); - *value = ""; - if (strcmp(env_name, "OpenWRT_Linux")) { - char *linker = dmstrdup(env_name); - adm_entry_get_linker_param(ctx, "Device.SoftwareModules.ExecEnv.", linker, value); - if (*value == NULL) { - *value = ""; - return 0; - } - } + if (env_name && strcmp(env_name, "OpenWRT_Linux")) + adm_entry_get_linker_param(ctx, "Device.SoftwareModules.ExecEnv.", env_name, value); + if (*value == NULL) + *value = ""; return 0; } @@ -347,28 +321,24 @@ static int get_SoftwareModulesExecEnv_AvailableMemory(char *refparam, struct dmc static int get_SoftwareModulesExecEnv_ActiveExecutionUnits(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; - int j = 0, env = 0; - char *environment, *eu_list = NULL, *eu_list_tmp = NULL; + unsigned pos = 0, eu = 0; + char eu_list[1024]; + eu_list[0] = 0; char *curr_env = dmjson_get_value((json_object *)data, 1, "name"); dmubus_call("swmodules", "eu_list", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = ""); - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "execution_unit") { - env++; - environment = dmjson_get_value(du_obj, 1, "environment"); - if (strcmp(environment, curr_env) == 0) { - if(!eu_list) { - dmasprintf(&eu_list, "Device.SoftwareModules.ExecutionUnit.%d.", env); - } else { - eu_list_tmp = dmstrdup(eu_list); - dmfree(eu_list); - dmasprintf(&eu_list, "%s,Device.SoftwareModules.ExecutionUnit.%d.", eu_list_tmp, env); - dmfree(eu_list_tmp); - } - } + dmjson_foreach_obj_in_array(res, arrobj, du_obj, eu, 1, "execution_unit") { + char *environment = dmjson_get_value(du_obj, 1, "environment"); + + if (strcmp(environment, curr_env) == 0) + pos += snprintf(&eu_list[pos], sizeof(eu_list) - pos, "Device.SoftwareModules.ExecutionUnit.%d,", eu+1); } - if(eu_list) - *value = eu_list; + + if (pos) + eu_list[pos - 1] = 0; + + *value = dmstrdup(eu_list); return 0; } @@ -389,28 +359,28 @@ static int get_SoftwareModulesDeploymentUnit_DUID(char *refparam, struct dmctx * static int get_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct uci_section *s = NULL; - char *du_name, *du_env, *environment, *name; + char *du_name, *du_env, *environment = NULL, *name = NULL; name = dmjson_get_value((json_object *)data, 1, "name"); environment = dmjson_get_value((json_object *)data, 1, "environment"); - uci_path_foreach_sections(bbfdm, "dmmap", "deployment_unit", s) { + uci_path_foreach_sections(bbfdm, "dmmap_sw_modules", "deployment_unit", s) { dmuci_get_value_by_section_string(s, "name", &du_name); dmuci_get_value_by_section_string(s, "environment", &du_env); - if ((strcmp(du_name, name) == 0) && (strcmp(du_env, environment) == 0)) { + if (name && (strcmp(du_name, name) == 0) && (environment && strcmp(du_env, environment) == 0)) { dmuci_get_value_by_section_string(s, "alias", value); - if ((*value)[0] == '\0') - dmasprintf(value, "cpe-%s", instance); - return 0; + break; } } + if ((*value)[0] == '\0') + dmasprintf(value, "cpe-%s", instance); return 0; } static int set_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { struct uci_section *s = NULL, *dmmap = NULL; - char *du_name, *du_env, *environment, *name; - int found = 0; + char *du_name, *du_env, *environment = NULL, *name = NULL; + bool found = false; switch (action) { case VALUECHECK: @@ -420,17 +390,17 @@ static int set_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx case VALUESET: name = dmjson_get_value((json_object *)data, 1, "name"); environment = dmjson_get_value((json_object *)data, 1, "environment"); - uci_path_foreach_sections(bbfdm, "dmmap", "deployment_unit", s) { + uci_path_foreach_sections(bbfdm, "dmmap_sw_modules", "deployment_unit", s) { dmuci_get_value_by_section_string(s, "name", &du_name); dmuci_get_value_by_section_string(s, "environment", &du_env); - if ((strcmp(du_name, name) == 0) && (strcmp(du_env, environment) == 0)) { + if (name && (strcmp(du_name, name) == 0) && (environment && strcmp(du_env, environment) == 0)) { dmuci_set_value_by_section_bbfdm(s, "alias", value); - found = 1; + found = true; break; } } if (!found) { - dmuci_add_section_bbfdm("dmmap", "deployment_unit", &dmmap); + dmuci_add_section_bbfdm("dmmap_sw_modules", "deployment_unit", &dmmap); dmuci_set_value_by_section(dmmap, "name", name); dmuci_set_value_by_section(dmmap, "environment", environment); dmuci_set_value_by_section(dmmap, "alias", value); @@ -487,12 +457,6 @@ static int get_SoftwareModulesDeploymentUnit_Version(char *refparam, struct dmct return 0; } -static int get_SoftwareModulesDeploymentUnit_VendorLogList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = ""; - return 0; -} - /*#Device.SoftwareModules.DeploymentUnit.{i}.VendorConfigList!UBUS:swmodules/du_list//deployment_unit[i-1].config*/ static int get_SoftwareModulesDeploymentUnit_VendorConfigList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -503,19 +467,18 @@ static int get_SoftwareModulesDeploymentUnit_ExecutionUnitList(char *refparam, s { json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; char *environment, *name, *curr_environment, *curr_name; - int j = 0, env = 0; + int eu = 0; curr_name = dmjson_get_value((json_object *)data, 1, "name"); curr_environment = dmjson_get_value((json_object *)data, 1, "environment"); dmubus_call("swmodules", "eu_list", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = ""); - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "execution_unit") { - env++; + dmjson_foreach_obj_in_array(res, arrobj, du_obj, eu, 1, "execution_unit") { name = dmjson_get_value(du_obj, 1, "name"); environment = dmjson_get_value(du_obj, 1, "environment"); if ((strcmp(name, curr_name) == 0) && (strcmp(environment, curr_environment) == 0)) { - dmasprintf(value, "Device.SoftwareModules.ExecutionUnit.%d.", env); + dmasprintf(value, "Device.SoftwareModules.ExecutionUnit.%d", eu+1); break; } } @@ -542,20 +505,20 @@ static int get_SoftwareModulesExecutionUnit_EUID(char *refparam, struct dmctx *c static int get_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct uci_section *s = NULL; - char *eu_euid, *eu_env, *environment, *euid; + char *eu_euid, *eu_env, *environment = NULL, *euid = NULL; euid = dmjson_get_value((json_object *)data, 1, "euid"); environment = dmjson_get_value((json_object *)data, 1, "environment"); - uci_path_foreach_sections(bbfdm, "dmmap", "execution_unit", s) { + uci_path_foreach_sections(bbfdm, "dmmap_sw_modules", "execution_unit", s) { dmuci_get_value_by_section_string(s, "euid", &eu_euid); dmuci_get_value_by_section_string(s, "environment", &eu_env); - if ((strcmp(eu_euid, euid) == 0) && (strcmp(eu_env, environment) == 0)) { + if ((euid && strcmp(eu_euid, euid) == 0) && (environment && strcmp(eu_env, environment) == 0)) { dmuci_get_value_by_section_string(s, "alias", value); - if ((*value)[0] == '\0') - dmasprintf(value, "cpe-%s", instance); - return 0; + break; } } + if ((*value)[0] == '\0') + dmasprintf(value, "cpe-%s", instance); return 0; } @@ -563,7 +526,7 @@ static int set_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx * { struct uci_section *s = NULL, *dmmap = NULL; char *eu_euid, *eu_env, *environment, *euid; - int found = 0; + bool found = false; switch (action) { case VALUECHECK: @@ -573,17 +536,17 @@ static int set_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx * case VALUESET: euid = dmjson_get_value((json_object *)data, 1, "euid"); environment = dmjson_get_value((json_object *)data, 1, "environment"); - uci_path_foreach_sections(bbfdm, "dmmap", "execution_unit", s) { + uci_path_foreach_sections(bbfdm, "dmmap_sw_modules", "execution_unit", s) { dmuci_get_value_by_section_string(s, "euid", &eu_euid); dmuci_get_value_by_section_string(s, "environment", &eu_env); if ((strcmp(eu_euid, euid) == 0) && (strcmp(eu_env, environment) == 0)) { dmuci_set_value_by_section_bbfdm(s, "alias", value); - found = 1; + found = true; break; } } if (!found) { - dmuci_add_section_bbfdm("dmmap", "execution_unit", &dmmap); + dmuci_add_section_bbfdm("dmmap_sw_modules", "execution_unit", &dmmap); dmuci_set_value_by_section(dmmap, "euid", euid); dmuci_set_value_by_section(dmmap, "environment", environment); dmuci_set_value_by_section(dmmap, "alias", value); @@ -652,22 +615,19 @@ static int get_SoftwareModulesExecutionUnit_References(char *refparam, struct dm { json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; char *environment, *name, *curr_environment, *curr_name; - int j = 0, env = 0; + int du = 0; curr_name = dmjson_get_value((json_object *)data, 1, "name"); curr_environment = dmjson_get_value((json_object *)data, 1, "environment"); dmubus_call("swmodules", "du_list", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = ""); - if (res) { - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "deployment_unit") { - env++; - name = dmjson_get_value(du_obj, 1, "name"); - environment = dmjson_get_value(du_obj, 1, "environment"); - if ((strcmp(name, curr_name) == 0) && (strcmp(environment, curr_environment) == 0)) { - dmasprintf(value, "Device.SoftwareModules.DeploymentUnit.%d.", env); - break; - } + dmjson_foreach_obj_in_array(res, arrobj, du_obj, du, 1, "deployment_unit") { + name = dmjson_get_value(du_obj, 1, "name"); + environment = dmjson_get_value(du_obj, 1, "environment"); + if ((strcmp(name, curr_name) == 0) && (strcmp(environment, curr_environment) == 0)) { + dmasprintf(value, "Device.SoftwareModules.DeploymentUnit.%d", du+1); + break; } } return 0; @@ -677,28 +637,21 @@ static int get_SoftwareModulesExecutionUnit_AssociatedProcessList(char *refparam { json_object *res = NULL, *processes_obj = NULL, *arrobj = NULL; char *euid, *pid; - int j = 0, process = 0; + int process = 0; euid = dmjson_get_value((json_object *)data, 1, "euid"); dmubus_call("router.system", "processes", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = ""); - dmjson_foreach_obj_in_array(res, arrobj, processes_obj, j, 1, "processes") { - process++; - pid = dmjson_get_value(processes_obj, 1, "PID"); + dmjson_foreach_obj_in_array(res, arrobj, processes_obj, process, 1, "processes") { + pid = dmjson_get_value(processes_obj, 1, "pid"); if (strcmp(euid, pid) == 0) { - dmasprintf(value, "Device.DeviceInfo.ProcessStatus.Process.%d.", process); + dmasprintf(value, "Device.DeviceInfo.ProcessStatus.Process.%d", process+1); break; } } return 0; } -static int get_SoftwareModulesExecutionUnit_VendorLogList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = ""; - return 0; -} - /*#Device.SoftwareModules.ExecutionUnit.{i}.VendorConfigList!UBUS:swmodules/eu_list//execution_unit[i-1].config*/ static int get_SoftwareModulesExecutionUnit_VendorConfigList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -710,10 +663,8 @@ static int get_SoftwareModulesExecutionUnit_ExecutionEnvRef(char *refparam, stru { char *linker = dmjson_get_value((json_object *)data, 1, "environment"); adm_entry_get_linker_param(ctx, "Device.SoftwareModules.ExecEnv.", linker, value); - if (*value == NULL) { + if (*value == NULL) *value = ""; - return 0; - } return 0; } @@ -772,7 +723,7 @@ DMLEAF tSoftwareModulesDeploymentUnitParams[] = { {"Description", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_Description, NULL, BBFDM_BOTH}, {"Vendor", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_Vendor, NULL, BBFDM_BOTH}, {"Version", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_Version, NULL, BBFDM_BOTH}, -{"VendorLogList", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_VendorLogList, NULL, BBFDM_BOTH}, +//{"VendorLogList", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_VendorLogList, NULL, BBFDM_BOTH}, {"VendorConfigList", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_VendorConfigList, NULL, BBFDM_BOTH}, {"ExecutionUnitList", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_ExecutionUnitList, NULL, BBFDM_BOTH}, {"ExecutionEnvRef", &DMREAD, DMT_STRING, get_SoftwareModulesDeploymentUnit_ExecutionEnvRef, NULL, BBFDM_BOTH}, @@ -793,7 +744,7 @@ DMLEAF tSoftwareModulesExecutionUnitParams[] = { {"Name", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Name, NULL, BBFDM_BOTH}, {"ExecEnvLabel", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecEnvLabel, NULL, BBFDM_BOTH}, {"Status", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Status, NULL, BBFDM_BOTH}, -//{"RequestedState", &DMWRITE, DMT_STRING, get_SoftwareModulesExecutionUnit_RequestedState, set_SoftwareModulesExecutionUnit_RequestedState, NULL, BBFDM_CWMP}, +//{"RequestedState", &DMWRITE, DMT_STRING, get_SoftwareModulesExecutionUnit_RequestedState, set_SoftwareModulesExecutionUnit_RequestedState, BBFDM_CWMP}, //{"ExecutionFaultCode", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionFaultCode, NULL, BBFDM_BOTH}, //{"ExecutionFaultMessage", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionFaultMessage, NULL, BBFDM_BOTH}, //{"AutoStart", &DMWRITE, DMT_BOOL, get_SoftwareModulesExecutionUnit_AutoStart, set_SoftwareModulesExecutionUnit_AutoStart, BBFDM_BOTH}, @@ -805,7 +756,7 @@ DMLEAF tSoftwareModulesExecutionUnitParams[] = { {"MemoryInUse", &DMREAD, DMT_INT, get_SoftwareModulesExecutionUnit_MemoryInUse, NULL, BBFDM_BOTH}, {"References", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_References, NULL, BBFDM_BOTH}, {"AssociatedProcessList", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_AssociatedProcessList, NULL, BBFDM_BOTH}, -{"VendorLogList", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_VendorLogList, NULL, BBFDM_BOTH}, +//{"VendorLogList", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_VendorLogList, NULL, BBFDM_BOTH}, {"VendorConfigList", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_VendorConfigList, NULL, BBFDM_BOTH}, //{"SupportedDataModelList", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_SupportedDataModelList, NULL, BBFDM_CWMP}, {"ExecutionEnvRef", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionEnvRef, NULL, BBFDM_BOTH}, diff --git a/dmtree/tr157/softwaremodules.h b/dmtree/tr181/softwaremodules.h similarity index 92% rename from dmtree/tr157/softwaremodules.h rename to dmtree/tr181/softwaremodules.h index 6d1a3fc7..67f9bc62 100644 --- a/dmtree/tr157/softwaremodules.h +++ b/dmtree/tr181/softwaremodules.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 iopsys Software Solutions AB + * Copyright (C) 2020 iopsys Software Solutions AB * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1 diff --git a/openwrt/bbf/Config_bbfdm.in b/openwrt/bbf/Config_bbfdm.in index bd9a8205..97315926 100644 --- a/openwrt/bbf/Config_bbfdm.in +++ b/openwrt/bbf/Config_bbfdm.in @@ -16,12 +16,4 @@ config BBF_TR143 bool "Compile with tr143 diagnostics features" default y -config BBF_TR157 - bool "Compile with tr157 bulkdata collector features" - default y - -config BBF_TR064 - bool "Compile with tr064 features" - default n - endif diff --git a/openwrt/bbf/Makefile b/openwrt/bbf/Makefile index 8e8f7948..6627f9f5 100644 --- a/openwrt/bbf/Makefile +++ b/openwrt/bbf/Makefile @@ -60,16 +60,6 @@ CONFIGURE_ARGS += \ --enable-tr143 endif -ifeq ($(CONFIG_BBF_TR157),y) -CONFIGURE_ARGS += \ - --enable-tr157 -endif - -ifeq ($(CONFIG_BBF_TR064),y) -CONFIGURE_ARGS += \ - --enable-tr064 -endif - define Package/libbbfdm/install $(INSTALL_DIR) $(1)/lib $(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbfdm.so* $(1)/lib/ @@ -84,7 +74,6 @@ define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include/libbbfdm $(1)/usr/include/libbbf_api $(CP) $(PKG_BUILD_DIR)/*.h $(1)/usr/include/libbbfdm/ $(CP) $(PKG_BUILD_DIR)/libbbf_api/*.h $(1)/usr/include/libbbf_api/ - $(CP) $(PKG_BUILD_DIR)/dmtree/tr181/*.h $(1)/usr/include/libbbfdm/ $(INSTALL_DIR) $(1)/usr/lib $(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbfdm.{a,so*} $(1)/usr/lib/ $(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbf_api.{a,so*} $(1)/usr/lib/ diff --git a/tools/generate_json.py b/tools/generate_json.py index 090432c0..66eb553e 100755 --- a/tools/generate_json.py +++ b/tools/generate_json.py @@ -218,9 +218,6 @@ def generatelistfromfile(dmobject): if "tr-104" in sys.argv[1]: pathfilename = "../dmtree/tr104/" + obj[1].lower() + ".c" pathiopsyswrtfilename = "../dmtree/tr104/" + obj[1].lower() + "-iopsyswrt.c" - elif obj[1] == "SoftwareModules" or obj[1] == "BulkData" : - pathfilename = "../dmtree/tr157/" + obj[1].lower() + ".c" - pathiopsyswrtfilename = "../dmtree/tr157/" + obj[1].lower() + "-iopsyswrt.c" else: pathfilename = "../dmtree/tr181/" + obj[1].lower() + ".c" pathiopsyswrtfilename = "../dmtree/tr181/" + obj[1].lower() + "-iopsyswrt.c" diff --git a/tools/generate_xml.sh b/tools/generate_xml.sh index fd28f819..9cad769e 100755 --- a/tools/generate_xml.sh +++ b/tools/generate_xml.sh @@ -354,12 +354,10 @@ cnt_param=0 DM_TR181="tr181" DM_TR104="tr104" DM_TR143="tr143" -DM_TR157="tr157" SCRIPTS_PATH_TR181=${DM_PATH}/${DM_TR181} SCRIPTS_PATH_TR104=${DM_PATH}/${DM_TR104} SCRIPTS_PATH_TR143=${DM_PATH}/${DM_TR143} -SCRIPTS_PATH_TR157=${DM_PATH}/${DM_TR157} -DIR_LIST="$SCRIPTS_PATH_TR181 $SCRIPTS_PATH_TR104 $SCRIPTS_PATH_TR143 $SCRIPTS_PATH_TR157" +DIR_LIST="$SCRIPTS_PATH_TR181 $SCRIPTS_PATH_TR104 $SCRIPTS_PATH_TR143" XML_OUT_STREAM_BBF="iopsys.xml" ROOT_PATH="Device" CUSTOM_PREFIX="X_IOPSYS_EU_" diff --git a/tools/generate_xml_bbf.sh b/tools/generate_xml_bbf.sh index 231ecdd0..1670b69e 100755 --- a/tools/generate_xml_bbf.sh +++ b/tools/generate_xml_bbf.sh @@ -371,13 +371,11 @@ cnt_param=0 DM_TR181="tr181" DM_TR104="tr104" DM_TR143="tr143" -DM_TR157="tr157" DM_PATH="$(pwd)/../dmtree" SCRIPTS_PATH_TR181=${DM_PATH}/${DM_TR181} SCRIPTS_PATH_TR104=${DM_PATH}/${DM_TR104} SCRIPTS_PATH_TR143=${DM_PATH}/${DM_TR143} -SCRIPTS_PATH_TR157=${DM_PATH}/${DM_TR157} -DIR_LIST="$SCRIPTS_PATH_TR181 $SCRIPTS_PATH_TR104 $SCRIPTS_PATH_TR143 $SCRIPTS_PATH_TR157" +DIR_LIST="$SCRIPTS_PATH_TR181 $SCRIPTS_PATH_TR104 $SCRIPTS_PATH_TR143" ROOT_PATH="Device" DM_HEAD="$ROOT_PATH-2.13" DM_FILE="tr-181-2-13-0-cwmp-full.xml"