From 3d4ac802c2805b81aac0ac71a304f951777246ab Mon Sep 17 00:00:00 2001 From: Omar Kallel Date: Tue, 15 Dec 2020 14:23:41 +0100 Subject: [PATCH] Delete some unused functions && get ip_version from cwmp uci config --- dmbbfcommon.c | 6 ---- dmbbfcommon.h | 1 - dmtree/tr157/softwaremodules.c | 66 ---------------------------------- dmtree/tr157/softwaremodules.h | 2 -- dmtree/tr181/deviceinfo.c | 9 ----- dmtree/tr181/deviceinfo.h | 1 - libbbf_api/dmbbf.c | 1 - libbbf_api/dmbbf.h | 1 - libbbf_api/dmcommon.c | 5 +-- 9 files changed, 3 insertions(+), 89 deletions(-) diff --git a/dmbbfcommon.c b/dmbbfcommon.c index 38376a18..ca110805 100644 --- a/dmbbfcommon.c +++ b/dmbbfcommon.c @@ -46,12 +46,6 @@ void bbf_uci_revert_bbfdm(void) dmuci_exit_bbfdm(); } -int bbf_set_ip_version(int ipversion) -{ - ip_version = ipversion; - return 0; -} - void del_list_parameter(struct dm_parameter *dm_parameter) { api_del_list_parameter(dm_parameter); diff --git a/dmbbfcommon.h b/dmbbfcommon.h index ff331099..8416a3e8 100644 --- a/dmbbfcommon.h +++ b/dmbbfcommon.h @@ -21,7 +21,6 @@ void bbf_uci_commit_bbfdm(void); void bbf_uci_revert_bbfdm(void); int set_bbfdatamodel_type(int bbf_type); int get_bbfdatamodel_type(void); -int bbf_set_ip_version(int ipversion); void del_list_parameter(struct dm_parameter *dm_parameter); void dmjson_parse_init(char *msg); void dmjson_parse_fini(void); diff --git a/dmtree/tr157/softwaremodules.c b/dmtree/tr157/softwaremodules.c index 53545f07..241a918d 100644 --- a/dmtree/tr157/softwaremodules.c +++ b/dmtree/tr157/softwaremodules.c @@ -725,72 +725,6 @@ static int get_SoftwareModulesExecutionUnit_ExecutionEnvRef(char *refparam, stru return 0; } -char *get_deployment_unit_reference(struct dmctx *ctx, char *package_name, char *package_env) -{ - char *linker, *value; - dmasprintf(&linker, "%s-%s", package_name, package_env); - adm_entry_get_linker_param(ctx, dm_print_path("%s%cSoftwareModules%cDeploymentUnit%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &value); - return value; -} - -void get_deployment_unit_name_version(char *uuid, char **name, char **version, char **env) -{ - json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; - int j = 0; - char *cur_uuid; - - dmubus_call("swmodules", "du_list", UBUS_ARGS{}, 0, &res); - if (res) { - dmjson_foreach_obj_in_array(res, arrobj, du_obj, j, 1, "deployment_unit") { - cur_uuid = dmjson_get_value(du_obj, 1, "uuid"); - if (strcmp(cur_uuid, uuid) == 0) { - *name = dmjson_get_value(du_obj, 1, "name"); - *version = dmjson_get_value(du_obj, 1, "version"); - *env = dmjson_get_value(du_obj, 1, "environment"); - return; - } - } - } -} - -char *get_softwaremodules_uuid(char *url) -{ - json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; - char *cur_url, *uuid = ""; - int j = 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") { - cur_url = dmjson_get_value(du_obj, 1, "url"); - if (strcmp(cur_url, url) == 0) { - uuid = dmjson_get_value(du_obj, 1, "uuid"); - break; - } - } - } - return uuid; -} - -char *get_softwaremodules_url(char *uuid) -{ - json_object *res = NULL, *du_obj = NULL, *arrobj = NULL; - char *cur_uuid, *url = ""; - int j = 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") { - cur_uuid = dmjson_get_value(du_obj, 1, "uuid"); - if (strcmp(cur_uuid, uuid) == 0) { - url = dmjson_get_value(du_obj, 1, "url"); - break; - } - } - } - return url; -} - /* *** Device.SoftwareModules. *** */ DMOBJ tSoftwareModulesObj[] = { /* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/ diff --git a/dmtree/tr157/softwaremodules.h b/dmtree/tr157/softwaremodules.h index d2a0b00f..99723501 100644 --- a/dmtree/tr157/softwaremodules.h +++ b/dmtree/tr157/softwaremodules.h @@ -20,8 +20,6 @@ extern DMLEAF tSoftwareModulesDeploymentUnitParams[]; extern DMOBJ tSoftwareModulesExecutionUnitObj[]; extern DMLEAF tSoftwareModulesExecutionUnitParams[]; -char *get_deployment_unit_reference(struct dmctx *ctx, char *package_name, char *package_env); -void get_deployment_unit_name_version(char *uuid, char **name, char **version, char **env); char *get_softwaremodules_uuid(char *url); char *get_softwaremodules_url(char *uuid); diff --git a/dmtree/tr181/deviceinfo.c b/dmtree/tr181/deviceinfo.c index deb92758..e587e673 100644 --- a/dmtree/tr181/deviceinfo.c +++ b/dmtree/tr181/deviceinfo.c @@ -86,15 +86,6 @@ char *get_softwareversion() return os__get_softwareversion(); } -int lookup_vcf_name(char *instance, char **value) -{ - struct uci_section *s = NULL; - uci_path_foreach_option_eq(bbfdm, DMMAP, "vcf", "vcf_instance", instance, s) { - dmuci_get_value_by_section_string(s, "name", value); - } - return 0; -} - static int get_device_manufacturer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = get_deviceid_manufacturer(); diff --git a/dmtree/tr181/deviceinfo.h b/dmtree/tr181/deviceinfo.h index 8651383d..6c7de5aa 100644 --- a/dmtree/tr181/deviceinfo.h +++ b/dmtree/tr181/deviceinfo.h @@ -32,6 +32,5 @@ char *get_deviceid_manufactureroui(); char *get_deviceid_productclass(); char *get_deviceid_serialnumber(); char *get_softwareversion(); -int lookup_vcf_name(char *instance, char **value); #endif diff --git a/libbbf_api/dmbbf.c b/libbbf_api/dmbbf.c index c8804022..4f52b4d4 100644 --- a/libbbf_api/dmbbf.c +++ b/libbbf_api/dmbbf.c @@ -95,7 +95,6 @@ LIST_HEAD(list_upnp_changed_version); LIST_HEAD(list_enabled_notify); -int ip_version = 4; char dm_delim = DMDELIM_CWMP; char dmroot[64] = "Device"; int bbfdatamodel_type = BBFDM_BOTH; diff --git a/libbbf_api/dmbbf.h b/libbbf_api/dmbbf.h index 8106cad9..50a0df66 100644 --- a/libbbf_api/dmbbf.h +++ b/libbbf_api/dmbbf.h @@ -559,7 +559,6 @@ extern struct list_head list_upnp_changed_onalarm; extern struct list_head list_upnp_changed_version; #endif -extern int ip_version; extern char dm_delim; extern char dmroot[64]; extern char *DMT_TYPE[]; diff --git a/libbbf_api/dmcommon.c b/libbbf_api/dmcommon.c index ffd94ec6..f4acd742 100644 --- a/libbbf_api/dmcommon.c +++ b/libbbf_api/dmcommon.c @@ -326,7 +326,7 @@ int network_get_ipaddr(char **value, char *iface) { json_object *res, *jobj; char *ipv6_value = ""; - + char *ip_version = NULL; dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", iface, String}}, 1, &res); DM_ASSERT(res, *value = ""); jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address"); @@ -334,10 +334,11 @@ int network_get_ipaddr(char **value, char *iface) jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address"); ipv6_value = dmjson_get_value(jobj, 1, "address"); + dmuci_get_option_value_string("cwmp", "acs", "ip_version", &ip_version); if((*value)[0] == '\0' || ipv6_value[0] == '\0') { if ((*value)[0] == '\0') *value = ipv6_value; - } else if (ip_version == 6) { + } else if (ip_version && ip_version[0] == '6') { *value = ipv6_value; return 0; }