Add feature check for route 72/277572/2
authorchaehee-hong <chaehee.hong@samsung.com>
Fri, 8 Jul 2022 08:55:26 +0000 (17:55 +0900)
committercheoleun moon <chleun.moon@samsung.com>
Mon, 11 Jul 2022 05:10:33 +0000 (14:10 +0900)
- tizen.org/feature/network.route

Change-Id: I0bcc4cd0db945b631b8d815114ca35a75b1b01e2

include/net_connection_private.h
src/connection.c
src/libnetwork.c
unittest/utc-connection-common.h
unittest/utc-network-connection.c

index 94c53a8..1b2c74f 100755 (executable)
@@ -42,6 +42,7 @@ extern "C" {
 #define WIFI_FEATURE                           "http://tizen.org/feature/network.wifi"
 #define TETHERING_BLUETOOTH_FEATURE    "http://tizen.org/feature/network.tethering.bluetooth"
 #define ETHERNET_FEATURE                       "http://tizen.org/feature/network.ethernet"
+#define ROUTE_FEATURE                          "http://tizen.org/feature/network.route"
 
 typedef enum {
        CONNECTION_CELLULAR_SUBSCRIBER_1 = 0x00,
@@ -53,6 +54,7 @@ typedef enum {
        CONNECTION_SUPPORTED_FEATURE_WIFI,
        CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH,
        CONNECTION_SUPPORTED_FEATURE_ETHERNET,
+       CONNECTION_SUPPORTED_FEATURE_ROUTE,
        CONNECTION_SUPPORTED_FEATURE_MAX,
 } connection_supported_feature_e;
 
index de8372e..50e29e2 100755 (executable)
@@ -1368,6 +1368,7 @@ EXPORT_API int connection_add_route(connection_h connection, const char* interfa
        CONN_LOCK;
 
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+       CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
@@ -1392,6 +1393,7 @@ EXPORT_API int connection_remove_route(connection_h connection, const char* inte
        CONN_LOCK;
 
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+       CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
@@ -1416,6 +1418,7 @@ EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *in
        CONN_LOCK;
 
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+       CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
@@ -1440,6 +1443,7 @@ EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char
        CONN_LOCK;
 
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+       CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
            interface_name == NULL || host_address == NULL) {
@@ -1466,6 +1470,7 @@ EXPORT_API int connection_add_route_entry(connection_h connection,
        CONN_LOCK;
 
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+       CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
                (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
@@ -1496,6 +1501,7 @@ EXPORT_API int connection_remove_route_entry(connection_h connection,
        CONN_LOCK;
 
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
+       CHECK_FEATURE_SUPPORTED(ROUTE_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) ||
                (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
index 3a1f310..5ed4ddb 100755 (executable)
@@ -1753,6 +1753,8 @@ int _connection_check_feature_supported(const char *feature_name, ...)
                        value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH);
                if (strcmp(key, ETHERNET_FEATURE) == 0)
                        value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_ETHERNET);
+               if (strcmp(key, ROUTE_FEATURE) == 0)
+                       value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_ROUTE);
 
                feature_supported |= value;
                key = va_arg(list, const char *);
index 7f2ce11..4361a2c 100755 (executable)
@@ -40,6 +40,7 @@
 #define FEATURE_ETHERNET                       "http://tizen.org/feature/network.ethernet"
 #define FEATURE_TELEPHONY                      "http://tizen.org/feature/network.telephony"
 #define FEATURE_BT_TETHERING                   "http://tizen.org/feature/network.tethering.bluetooth"
+#define FEATURE_ROUTE                          "http://tizen.org/feature/network.route"
 #define CALLBACK_RETURN                                "callback return"
 
 GMainLoop *g_pMainLoop;
@@ -50,6 +51,7 @@ bool wifi_supported;
 bool telephony_supported;
 bool bt_tethering_supported;
 bool ethernet_supported;
+bool route_supported;
 bool all_features_not_supported;
 
 connection_profile_h profile_cellular;
index 6c9bd5d..fd1ae89 100755 (executable)
@@ -84,6 +84,7 @@ void utc_network_connection_startup(void)
        telephony_supported = connection_check_feature_supported(FEATURE_TELEPHONY);
        bt_tethering_supported = connection_check_feature_supported(FEATURE_BT_TETHERING);
        ethernet_supported = connection_check_feature_supported(FEATURE_ETHERNET);
+       route_supported = connection_check_feature_supported(FEATURE_ROUTE);
 
        if (telephony_supported == false && wifi_supported == false
                        && bt_tethering_supported == false && ethernet_supported == false) {
@@ -1468,7 +1469,7 @@ int utc_connection_add_route_n(void)
 {
        int ret;
 
-       if (all_features_not_supported) {
+       if (!route_supported || all_features_not_supported) {
                ret = connection_add_route(connection, NULL, NULL);
                CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1501,7 +1502,7 @@ int utc_connection_add_route_p(void)
        int ret;
        char* interface_name = NULL;
 
-       if (all_features_not_supported) {
+       if (!route_supported || all_features_not_supported) {
                ret = connection_add_route(connection, interface_name, "192.168.129.3");
                CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1531,7 +1532,7 @@ int utc_connection_remove_route_n(void)
 {
        int ret;
 
-       if (all_features_not_supported) {
+       if (!route_supported || all_features_not_supported) {
                ret = connection_remove_route(NULL, NULL, NULL);
                CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1564,7 +1565,7 @@ int utc_connection_remove_route_p(void)
        int ret;
        char* interface_name = NULL;
 
-       if (all_features_not_supported) {
+       if (!route_supported || all_features_not_supported) {
                ret = connection_remove_route(connection, interface_name, "192.168.129.3");
                CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1594,7 +1595,7 @@ int utc_connection_add_route_ipv6_n(void)
 {
        int ret;
 
-       if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) {
+       if (!route_supported || (telephony_supported == false && wifi_supported == false && ethernet_supported == false)) {
                ret = connection_add_route_ipv6(NULL, NULL, NULL, NULL);
                CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1624,7 +1625,7 @@ int utc_connection_add_route_ipv6_p(void)
        int ret;
        char* interface_name = NULL;
 
-       if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) {
+       if (!route_supported || (telephony_supported == false && wifi_supported == false && ethernet_supported == false)) {
                ret = connection_add_route_ipv6(connection, interface_name, "2001:db8:1:0::1", "fe80::");
                CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1653,7 +1654,7 @@ int utc_connection_remove_route_ipv6_n(void)
 {
        int ret;
 
-       if (all_features_not_supported) {
+       if (!route_supported || (telephony_supported == false && wifi_supported == false && ethernet_supported == false)) {
                ret = connection_remove_route_ipv6(NULL, NULL, NULL, NULL);
                CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED);
                return 0;
@@ -1683,7 +1684,7 @@ int utc_connection_remove_route_ipv6_p(void)
        int ret;
        char* interface_name = NULL;
 
-       if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) {
+       if (!route_supported || (telephony_supported == false && wifi_supported == false && ethernet_supported == false)) {
                ret = connection_remove_route_ipv6(connection, interface_name, "2001:db8:1:0::1", "fe80::");
                FREE_RESOURCE(interface_name);
                CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED);