dded support to get IPv4 details from connmand 54/145454/1
authorsaerome kim <saerome.kim@samsung.com>
Tue, 22 Aug 2017 10:01:19 +0000 (19:01 +0900)
committersaerome kim <saerome.kim@samsung.com>
Tue, 22 Aug 2017 10:01:19 +0000 (19:01 +0900)
Change-Id: I5468e0a00981ecb88ad180d11082a486fa3addad
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wmesh.h
introspection/wmesh.xml
src/wmesh-gdbus.c
src/wmesh-service-interface.c

index f92a7b0..a9a33d4 100644 (file)
@@ -49,6 +49,13 @@ typedef enum {
        WMESHD_SECURITY_SAE, /**< SAE */
 } wmeshd_security_type_e;
 
+/**< Internal enum for IP Config Type */
+typedef enum {
+       WMESHD_IP_CONFIG_TYPE_UNKNOWN = 0, /**< Unknown */
+       WMESHD_IP_CONFIG_TYPE_DYNAMIC, /**< DHCP */
+       WMESHD_IP_CONFIG_TYPE_STATIC, /**< Static */
+} wmeshd_ip_config_type_e;
+
 /**< mesh interface information structure */
 typedef struct {
        gchar *bridge_interface; /**< Bridge name between mesh and others */
@@ -73,6 +80,9 @@ typedef struct _wmesh_network_info {
        int channel; /**< Channel */
        wmeshd_security_type_e security; /**< Security type */
        wmeshd_connection_state_e state; /**< Connection state */
+       wmeshd_ip_config_type_e ipv4_type; /**< IPv4 Config Type */
+       char *ipv4_address; /**< IPv4 Address */
+       char *ipv4_netmask; /**< IPv4 Netmask */
 } wmesh_network_info_s;
 
 /**< Mesh network scan result structure */
index d698e6d..d2c94ec 100644 (file)
@@ -45,6 +45,9 @@
                        <arg type="i" name="channel" direction="out"/>\r
                        <arg type="i" name="security" direction="out"/>\r
                        <arg type="i" name="state" direction="out"/>\r
+                       <arg type="i" name="ipv4_type" direction="out"/>\r
+                       <arg type="s" name="ipv4_address" direction="out"/>\r
+                       <arg type="s" name="ipv4_netmask" direction="out"/>\r
                        <arg type="i" name="result" direction="out"/>\r
                </method>\r
                <method name="set_gate">\r
index 27cd58b..f1b8321 100644 (file)
@@ -207,7 +207,7 @@ static void _wmeshd_signal_handler(GDBusConnection *connection,
                const gchar *signal_name, GVariant *parameters, gpointer user_data)
 {
        wmesh_service *service = (wmesh_service*)user_data;
-       wmesh_network_info_s network_info = { 0, 0, 0, 0, 0 };
+       wmesh_network_info_s network_info = { 0, 0, 0, 0, 0, 0, 0, 0};
        int ret = WMESHD_ERROR_NONE;
 
        wmeshd_check_null_ret("user_data", user_data);
@@ -599,8 +599,11 @@ static void _get_joined_network(wmesh_service *service, GVariant *variant)
 {
        GVariantIter *peer = NULL;
        GVariantIter *property = NULL;
+       GVariantIter  *iter = NULL;
        gchar *key = NULL;
+       gchar *sub_key = NULL;
        GVariant *val = NULL;
+       GVariant *sub_val = NULL;
        gsize len = 0;
        GVariant *child;
        const gchar* obj_path = NULL;
@@ -657,6 +660,34 @@ static void _get_joined_network(wmesh_service *service, GVariant *variant)
                                        joined_info->security = WMESHD_SECURITY_NONE;
                        } else if (strcasecmp(key, "Frequency") == 0) {
                                joined_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
+                       } else if (strcasecmp(key, "IPv4") == 0) {
+                               g_variant_get(val, "a{sv}", &iter);
+                               while (g_variant_iter_loop(iter, "{sv}", &sub_key, &sub_val)) {
+
+                                       if (strcasecmp(sub_key, "Method") == 0) {
+                                               buf = g_variant_get_string(sub_val, &len);
+                                               WMESH_LOGD("Method %s", buf);
+
+                                               if (strcasecmp(buf, "dhcp") == 0)
+                                                       joined_info->ipv4_type =
+                                                               WMESHD_IP_CONFIG_TYPE_DYNAMIC;
+                                               else if (strcasecmp(buf, "manual") == 0)
+                                                       joined_info->ipv4_type =
+                                                               WMESHD_IP_CONFIG_TYPE_STATIC;
+                                               else
+                                                       joined_info->ipv4_type =
+                                                               WMESHD_IP_CONFIG_TYPE_UNKNOWN;
+                                       } else if (strcasecmp(sub_key, "Address") == 0) {
+                                               buf = g_variant_get_string(sub_val, &len);
+                                               WMESH_LOGD("Address %s", buf);
+                                               joined_info->ipv4_address = g_strdup(buf);
+                                       } else if (strcasecmp(sub_key, "Netmask") == 0) {
+                                               buf = g_variant_get_string(sub_val, &len);
+                                               WMESH_LOGD("Netmask %s", buf);
+                                               joined_info->ipv4_netmask = g_strdup(buf);
+                                       }
+                               }
+                               g_variant_iter_free(iter);
                        }
                }
 
@@ -664,6 +695,8 @@ static void _get_joined_network(wmesh_service *service, GVariant *variant)
                if (FALSE == valid_state) {
                        g_free(joined_info->mesh_id);
                        g_free(joined_info->bssid);
+                       g_free(joined_info->ipv4_address);
+                       g_free(joined_info->ipv4_netmask);
                        continue;
                }
 
@@ -858,6 +891,8 @@ int wmesh_gdbus_get_joined_mesh_network(wmesh_service *service)
                if (service->joined_network) {
                        g_free(service->joined_network->mesh_id);
                        g_free(service->joined_network->bssid);
+                       g_free(service->joined_network->ipv4_address);
+                       g_free(service->joined_network->ipv4_netmask);
                        g_free(service->joined_network);
                        service->joined_network = NULL;
                }
index f24e394..ab84d8a 100644 (file)
@@ -509,14 +509,15 @@ static gboolean _wmeshd_dbus_handle_get_joined_mesh_network(NetWmesh *object,
                        net_wmesh_complete_get_joined_mesh_network(object, invocation,
                                joined->mesh_id, joined->bssid,
                                joined->channel, (int)joined->security,
-                               joined->state, ret);
+                               joined->state, joined->ipv4_type, joined->ipv4_address,
+                               joined->ipv4_netmask, ret);
                } else {
                        net_wmesh_complete_get_joined_mesh_network(object, invocation,
-                               "", "", 0, 0, 0, WMESHD_ERROR_NO_DATA);
+                               "", "", 0, 0, 0, 0, "", "", WMESHD_ERROR_NO_DATA);
                }
        } else {
                net_wmesh_complete_get_joined_mesh_network(object, invocation,
-                       "", "", 0, 0, 0, ret);
+                       "", "", 0, 0, 0, 0, "", "", ret);
        }
 
        return TRUE;