Add feature check in Mac Policy APIs 63/258163/2
authorNishant Chaprana <n.chaprana@samsung.com>
Tue, 11 May 2021 12:22:26 +0000 (17:52 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 25 May 2021 09:37:09 +0000 (15:07 +0530)
Change-Id: If0a2e8fe1bec1a96e833b29d0d8b9b1504069d6e
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/wifi_internal.h
src/wifi_internal.c
src/wifi_manager.c

index 3666d51..d0de98f 100755 (executable)
@@ -43,6 +43,7 @@ extern "C" {
 
 #define WIFI_FEATURE                    "http://tizen.org/feature/network.wifi"
 #define WIFI_TDLS_FEATURE               "http://tizen.org/feature/network.wifi.tdls"
+#define WIFI_MAC_RANDOMIZATION_FEATURE  "http://tizen.org/feature/network.wifi.mac_randomization"
 
 #define WIFI_CONFIG_NAME                                       "Name"
 #define WIFI_CONFIG_SSID                                       "SSID"
@@ -74,6 +75,7 @@ extern "C" {
 typedef enum {
        WIFI_SUPPORTED_FEATURE_WIFI,
        WIFI_SUPPORTED_FEATURE_WIFI_TDLS,
+       WIFI_SUPPORTED_FEATURE_WIFI_MAC_RANDOMIZATION,
        WIFI_SUPPORTED_FEATURE_MAX,
 } wifi_supported_feature_e;
 
index 30cd2d5..4a3ade2 100755 (executable)
@@ -3404,20 +3404,24 @@ int _wifi_check_feature_supported(const char *feature_name, ...)
        va_start(list, feature_name);
        key = feature_name;
        while (1) {
-               if (strcmp(key, WIFI_FEATURE) == 0)
+               if (g_strcmp0(key, WIFI_FEATURE) == 0)
                        value = __check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI);
-               else if (strcmp(key, WIFI_TDLS_FEATURE) == 0)
+               else if (g_strcmp0(key, WIFI_TDLS_FEATURE) == 0)
                        value = __check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI_TDLS);
+               else if (g_strcmp0(key, WIFI_MAC_RANDOMIZATION_FEATURE) == 0)
+                       value = __check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI_MAC_RANDOMIZATION);
 
                feature_supported |= value;
                key = va_arg(list, const char *);
                if (!key) break;
        }
        if (!feature_supported) {
-               if (strcmp(feature_name, WIFI_FEATURE) == 0)
+               if (g_strcmp0(feature_name, WIFI_FEATURE) == 0)
                        WIFI_LOG(WIFI_ERROR, "http://tizen.org/feature/network.wifi Feature is not supported"); //LCOV_EXCL_LINE
-               else
+               else if (g_strcmp0(feature_name, WIFI_TDLS_FEATURE) == 0)
                        WIFI_LOG(WIFI_ERROR, "http://tizen.org/feature/network.wifi.tdls Feature is not supported"); //LCOV_EXCL_LINE
+               else
+                       WIFI_LOG(WIFI_ERROR, "http://tizen.org/feature/network.wifi.mac_randomization Feature is not supported"); //LCOV_EXCL_LINE
                set_last_result(WIFI_MANAGER_ERROR_NOT_SUPPORTED); //LCOV_EXCL_LINE
                va_end(list);
                return WIFI_MANAGER_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
index af81966..7e7be64 100755 (executable)
@@ -2001,7 +2001,7 @@ EXPORT_API int wifi_manager_set_mac_policy(wifi_manager_h wifi, wifi_manager_mac
 
        int rv = WIFI_MANAGER_ERROR_NONE;
 
-       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, WIFI_MAC_RANDOMIZATION_FEATURE);
 
        if (policy < WIFI_MANAGER_MAC_POLICY_FIXED_MAC || policy > WIFI_MANAGER_MAC_POLICY_FIXED_OUI_RANDOM_MAC) {
                WIFI_LOG(WIFI_ERROR, "Invalid policy parameter, value [%d]", policy);
@@ -2023,7 +2023,7 @@ EXPORT_API int wifi_manager_get_mac_policy(wifi_manager_h wifi, wifi_manager_mac
 
        int rv = WIFI_MANAGER_ERROR_NONE;
 
-       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, WIFI_MAC_RANDOMIZATION_FEATURE);
 
        if (policy == NULL) {
                WIFI_LOG(WIFI_ERROR, "policy parameter is NULL");
@@ -2045,7 +2045,7 @@ EXPORT_API int wifi_manager_set_preassoc_mac_policy(wifi_manager_h wifi, wifi_ma
 
        int rv = WIFI_MANAGER_ERROR_NONE;
 
-       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, WIFI_MAC_RANDOMIZATION_FEATURE);
 
        if (policy < WIFI_MANAGER_MAC_POLICY_FIXED_MAC || policy > WIFI_MANAGER_MAC_POLICY_FIXED_OUI_RANDOM_MAC) {
                WIFI_LOG(WIFI_ERROR, "Invalid policy parameter, value [%d]", policy);
@@ -2067,7 +2067,7 @@ EXPORT_API int wifi_manager_get_preassoc_mac_policy(wifi_manager_h wifi, wifi_ma
 
        int rv = WIFI_MANAGER_ERROR_NONE;
 
-       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, WIFI_MAC_RANDOMIZATION_FEATURE);
 
        if (policy == NULL) {
                WIFI_LOG(WIFI_ERROR, "policy parameter is NULL");
@@ -2089,7 +2089,7 @@ EXPORT_API int wifi_manager_set_random_mac_lifetime(wifi_manager_h wifi, unsigne
 
        int rv = WIFI_MANAGER_ERROR_NONE;
 
-       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, WIFI_MAC_RANDOMIZATION_FEATURE);
 
        if (lifetime == 0) {
                WIFI_LOG(WIFI_ERROR, "Invalid lifetime parameter, value [%u]", lifetime);
@@ -2111,7 +2111,7 @@ EXPORT_API int wifi_manager_get_random_mac_lifetime(wifi_manager_h wifi, unsigne
 
        int rv = WIFI_MANAGER_ERROR_NONE;
 
-       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, WIFI_MAC_RANDOMIZATION_FEATURE);
 
        if (lifetime == NULL) {
                WIFI_LOG(WIFI_ERROR, "lifetime parameter is NULL");