Added support to set and get prefix length. 64/189264/1
authorNiraj Kumar Goit <niraj.g@samsung.com>
Fri, 14 Sep 2018 15:21:48 +0000 (20:51 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Fri, 14 Sep 2018 15:21:48 +0000 (20:51 +0530)
Added support to set and get prefix length from configuration file.

Change-Id: I17144c9a6a515ad8efcbc5ae2ca5199ef56cbcdb
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/wifi-config.h
src/wifi-config.c

index dd871a1..6dd783b 100755 (executable)
@@ -40,6 +40,7 @@ extern "C" {
 #define WIFI_CONFIG_IPV6_DNS_METHOD                    "Nameservers.IPv6method"
 #define WIFI_CONFIG_IPV4_ADDRESS                       "IPv4.local_address"
 #define WIFI_CONFIG_IPV4_SUBNET_MASK                   "IPv4.netmask_prefixlen"
+#define WIFI_CONFIG_IPV6_PREFIX_LEN                    "IPv6.netmask_prefixlen"
 #define WIFI_CONFIG_IPV4_GATEWAY_ADDRESS               "IPv4.gateway"
 #define WIFI_CONFIG_DNS_ADDRESS                        "Nameservers"
 #define WIFI_CONFIG_FAILURE                    "Failure"
index 3b01143..6901e6c 100755 (executable)
@@ -123,6 +123,7 @@ static void __free_wifi_configuration(struct wifi_config *conf)
                g_free(conf->ip_info->subnet_mask);
                g_free(conf->ip_info->gateway_address);
                g_free(conf->ip_info->dns_type);
+               conf->ip_info->prefix_length = 0;
 
                int i = 0, count = conf->ip_info->dns_count;
                while (i < count) {
@@ -1085,6 +1086,9 @@ gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
        if (conf->ip_info->subnet_mask != NULL)
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_SUBNET_MASK, g_variant_new_string(conf->ip_info->subnet_mask));
 
+       if (conf->ip_info->prefix_length > 0)
+               g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV6_PREFIX_LEN, g_variant_new_int32(conf->ip_info->prefix_length));
+
        if (conf->ip_info->gateway_address != NULL)
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, g_variant_new_string(conf->ip_info->gateway_address));
 
@@ -1207,6 +1211,13 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
                        } else {
                                conf->ip_info->subnet_mask = NULL;
                        }
+               } else if (g_strcmp0(field, WIFI_CONFIG_IPV6_PREFIX_LEN) == 0) {
+                       if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) {
+                               conf->ip_info->prefix_length = g_variant_get_int32(value);
+                               DBG("IPv6 Prefix Length [%d]", conf->ip_info->prefix_length);
+                       } else {
+                               conf->ip_info->prefix_length = 0;
+                       }
                } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->ip_info->gateway_address = g_strdup(g_variant_get_string(value, NULL));
@@ -1300,6 +1311,10 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
                                                 WIFI_CONFIG_IPV4_SUBNET_MASK, prefix_len);
        }
 
+       if (conf->ip_info->prefix_length > 0)
+               g_key_file_set_integer(keyfile, group_name,
+                               WIFI_CONFIG_IPV6_PREFIX_LEN, conf->ip_info->prefix_length);
+
        if (conf->ip_info->gateway_address != NULL)
                g_key_file_set_string(keyfile, group_name,
                        WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, conf->ip_info->gateway_address);