Added handling to support TDLS feature
[platform/core/connectivity/net-config.git] / src / wifi-tdls.c
index d34dbfa..9c45374 100755 (executable)
@@ -79,6 +79,56 @@ static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const
        return message;
 }
 
+gboolean handle_tdls_connect(Wifi *wifi, GDBusMethodInvocation *context,
+                       gchar *peer_mac_Addr)
+{
+       DBG("[TizenMW-->WPAS]: TDLS Setup Request: [%s]", peer_mac_Addr);
+
+       if (is_connected) {
+               ERR(" Already active TDLS Connection !!!");
+       } else {
+               GVariant *message = NULL;
+               message = __netconfig_wifi_tdls_send_dbus_str("TDLSSetup", (const char*)peer_mac_Addr);
+
+               if (message == NULL) {
+                       ERR(" TDLS : failed to connect !!!");
+                       netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailTdlsConnect");
+                       return FALSE;
+               }
+
+               DBG("[TizenMW<--WPAS] TDLS DBUS Command sent successfully");
+               g_variant_unref(message);
+               is_connected = 1;
+       }
+
+       wifi_complete_tdls_connect(wifi, context, 1);
+       return TRUE;
+}
+
+gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context)
+{
+       DBG("[TizenMW-->WPAS]: TDLS Discover Request ");
+
+       if (is_connected) {
+               ERR(" Already active TDLS Connection !!!");
+       } else {
+               GVariant *message = NULL;
+               message = __netconfig_wifi_tdls_send_dbus_str("TDLSDiscover", "ff:ff:ff:ff:ff:ff");
+
+               if (message == NULL) {
+                       ERR(" TDLS : failed to discover !!!");
+                       netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailTdlsDiscover");
+                       return FALSE;
+               }
+
+               DBG("[TizenMW<--WPAS] TDLS DBUS Command sent successfully");
+               g_variant_unref(message);
+       }
+
+       wifi_complete_tdls_discover(wifi, context);
+       return TRUE;
+}
+
 gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context,
                        gchar *peer_mac_Addr)
 {
@@ -89,6 +139,13 @@ gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context,
        } else {
                GVariant *message = NULL;
                message = __netconfig_wifi_tdls_send_dbus_str("TDLSTeardown", (const char*)peer_mac_Addr);
+
+               if (message == NULL) {
+                       ERR(" TDLS : failed to disconnect !!!");
+                       netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailTdlsDisconnect");
+                       return FALSE;
+               }
+
                DBG("[TizenMW<--WPAS] TDLS DBUS Command sent successfully");
                g_variant_unref(message);
                is_connected = 0;