wmesh-manager: Add support to get softAP station info
[platform/core/connectivity/wifi-mesh-manager.git] / src / wmesh-service-interface.c
index c56070b..3f640b3 100644 (file)
@@ -831,7 +831,7 @@ static gboolean _wmeshd_dbus_handle_set_interfaces(NetWmesh *object,
 }
 
 static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object,
-               GDBusMethodInvocation *invocation,
+               GDBusMethodInvocation *invocation, gint station_type,
                gpointer user_data)
 {
        int ret = WMESHD_ERROR_NONE;
@@ -843,12 +843,31 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object,
        wmesh_service *service = (wmesh_service *)user_data;
        wmesh_interface_s *info = service->interface_info;
 
-       /* Clear mesh station list */
-       g_list_free_full(service->station_list, _on_station_list_destroy);
-       service->station_list = NULL;
+       if (station_type == WMESHD_STATION_TYPE_MESH_POINT) {
+               /* Clear mesh station list */
+               g_list_free_full(service->station_list, _on_station_list_destroy);
+               service->station_list = NULL;
+
+               ret = wmesh_request_get_station_info(
+                                                               info->mesh_interface, &service->station_list);
+       } else if (station_type == WMESHD_STATION_TYPE_SOFTAP) {
+               /* Clear softAP station list */
+               g_list_free_full(service->softap_station_list,
+                                                _on_station_list_destroy);
+               service->softap_station_list = NULL;
+
+               ret = wmesh_request_get_station_info(
+                                                               info->softap_interface,
+                                                               &service->softap_station_list);
+       } else {
+               WMESH_LOGE("Invalid station type");
+
+               g_dbus_method_invocation_return_error(invocation,
+                               G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Invalid station type");
+
+               return FALSE;
+       }
 
-       ret = wmesh_request_get_station_info(
-                               info->mesh_interface, &service->station_list);
        if (WMESHD_ERROR_NONE != ret) {
                WMESH_LOGE("Failed to wmesh_request_get_station_info");
 
@@ -891,7 +910,11 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object,
                /* Get station information and make variant data */
                g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
 
-               iter = service->station_list;
+               if (station_type == WMESHD_STATION_TYPE_MESH_POINT)
+                       iter = service->station_list;
+               else
+                       iter = service->softap_station_list;
+
                while (iter != NULL) {
                        wmesh_station_info_s *item = (wmesh_station_info_s*)iter->data;
 
@@ -926,18 +949,20 @@ static gboolean _wmeshd_dbus_handle_get_station_info(NetWmesh *object,
                                                g_variant_new_uint32(item->tx_bitrate)); /* 10 times */
                        g_variant_builder_add(&builder, "{sv}", "rx_bitrate",
                                                g_variant_new_uint32(item->rx_bitrate)); /* 10 times */
-                       g_variant_builder_add(&builder, "{sv}", "mesh_llid",
-                                               g_variant_new_uint16(item->llid));
-                       g_variant_builder_add(&builder, "{sv}", "mesh_plid",
-                                               g_variant_new_uint16(item->plid));
-                       g_variant_builder_add(&builder, "{sv}", "mesh_plink",
-                                               g_variant_new_byte(item->mesh_plink)); /* 0 : DISCON, 1 : ESTAB */
-                       g_variant_builder_add(&builder, "{sv}", "local_ps_mode",
-                                               g_variant_new_uint32(item->local_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */
-                       g_variant_builder_add(&builder, "{sv}", "peer_ps_mode",
-                                               g_variant_new_uint32(item->peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */
-                       g_variant_builder_add(&builder, "{sv}", "non_peer_ps_mode",
-                                               g_variant_new_uint32(item->non_peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */
+                       if (station_type == WMESHD_STATION_TYPE_MESH_POINT) {
+                               g_variant_builder_add(&builder, "{sv}", "mesh_llid",
+                                                               g_variant_new_uint16(item->llid));
+                               g_variant_builder_add(&builder, "{sv}", "mesh_plid",
+                                                               g_variant_new_uint16(item->plid));
+                               g_variant_builder_add(&builder, "{sv}", "mesh_plink",
+                                                               g_variant_new_byte(item->mesh_plink)); /* 0 : DISCON, 1 : ESTAB */
+                               g_variant_builder_add(&builder, "{sv}", "local_ps_mode",
+                                                               g_variant_new_uint32(item->local_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */
+                               g_variant_builder_add(&builder, "{sv}", "peer_ps_mode",
+                                                               g_variant_new_uint32(item->peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */
+                               g_variant_builder_add(&builder, "{sv}", "non_peer_ps_mode",
+                                                               g_variant_new_uint32(item->non_peer_ps_mode)); /* 0 : INACTIVE, 1 : ACTIVE */
+                       }
                        g_variant_builder_add(&builder, "{sv}", "authorized",
                                                g_variant_new_boolean(item->authorized));
                        g_variant_builder_add(&builder, "{sv}", "associated",
@@ -1324,6 +1349,12 @@ static void _wmeshd_dbus_deinit(wmesh_service *service)
                g_list_free_full(service->station_list, _on_station_list_destroy);
        service->station_list = NULL;
 
+       /* Clear mesh station list */
+       if (service->softap_station_list)
+               g_list_free_full(service->softap_station_list,
+                                                _on_station_list_destroy);
+       service->softap_station_list = NULL;
+
        g_free(service->interface_info);
        service->interface_info = NULL;
 }