char *peer_mac = NULL;
int is_connected = 0;
+static gint tdls_timer_id = 0;
+int is_discover_broadcast = 0;
+
+#define TDLS_DISCOVER_TIMOUT 4 /*TDLS Unicast Discovery Timeout*/
+#define TDLS_DISCOVER_BROADCAST_TIMOUT 8 /*TDLS Broadcast Discovery Timeout*/
+static void stop_tdls_timer()
+{
+ if (tdls_timer_id > 0) {
+ g_source_remove(tdls_timer_id);
+ tdls_timer_id = 0;
+ }
+}
void __netconfig_wifi_notify_tdls_event(const char *sig_name, const char *peer_mac)
{
INFO("Sent signal (%s) Peer Mac (%s)", sig_name, peer_mac);
}
+void __netconfig_wifi_notify_tdls_discover_event(const char *peer_mac, int discover_type)
+{
+ GVariantBuilder *builder;
+ GVariant *params;
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_builder_add(builder, "{sv}", "peermac", g_variant_new_string(peer_mac));
+ g_variant_builder_add(builder, "{sv}", "discover_type", g_variant_new_int32(discover_type));
+
+ params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+ g_variant_builder_unref(builder);
+
+ netconfig_dbus_emit_signal(NULL,
+ NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE,
+ "TDLSPeerFound",
+ params);
+
+ INFO("Sent signal (%s) Peer Mac (%s)", "TDLSPeerFound", peer_mac);
+}
+
+static gboolean _tdls_timer_discover_event(gpointer user_data)
+{
+
+ if (tdls_timer_id == 0)
+ return FALSE;
+
+ INFO("[TDLS Discover Timer Expired");
+ __netconfig_wifi_notify_tdls_discover_event("00:00:00:00:00:00", is_discover_broadcast);
+ is_discover_broadcast = 0;
+ stop_tdls_timer();
+ return FALSE;
+}
+
static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const char *str)
{
GVariant *message = NULL;
}
params = g_variant_new("(s)", str);
- INFO("[TizenMW-->WPAS] Sent Dbus Method :[%s],value[%s]", method, str);
+ INFO("[TizenMW-->WPAS]Sent Dbus Method :[%s],value[%s]", method, str);
message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
if_path, SUPPLICANT_INTERFACE ".Interface", method, params);
gboolean handle_tdls_discover(Wifi *wifi, GDBusMethodInvocation *context,
gchar *peer_mac_Addr)
{
- DBG("[TizenMW-->WPAS]: TDLS Discover Request: [%s], peer_mac_Addr");
+ DBG("TDLS Discover Request: [%s]", peer_mac_Addr);
+ int discover_timeout = 0;
- if (is_connected) {
- ERR(" Already TDLS Connection !!!");
- } else {
- GVariant *message = NULL;
- message = __netconfig_wifi_tdls_send_dbus_str("TDLSDiscover", (const char*)peer_mac_Addr);
+ GVariant *message = NULL;
+ message = __netconfig_wifi_tdls_send_dbus_str("TDLSDiscover", (const char*)peer_mac_Addr);
- if (message == NULL) {
- ERR(" TDLS : failed to discover !!!");
- netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailTdlsDiscover");
- return FALSE;
- }
+ if (message == NULL) {
+ ERR(" TDLS : failed to discover !!!");
+ netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailTdlsDiscover");
+ wifi_complete_tdls_discover(wifi, context, NETCONFIG_ERROR_TDLS_FAIL_DISCOVER);
+ return FALSE;
+ }
- DBG("[TizenMW<--WPAS] TDLS DBUS Command sent successfully");
- g_variant_unref(message);
+ DBG(" TDLS DBUS Command sent successfully");
+ g_variant_unref(message);
+
+ if (NULL != strstr(peer_mac_Addr, "ff:ff:ff:ff:ff:ff")) {
+ DBG("TDLS: Broadcast Discovery");
+ is_discover_broadcast = 1;
+ discover_timeout = TDLS_DISCOVER_BROADCAST_TIMOUT;
+ } else {
+ is_discover_broadcast = 0;
+ discover_timeout = TDLS_DISCOVER_TIMOUT;
}
- wifi_complete_tdls_discover(wifi, context, 1);
+ tdls_timer_id = g_timeout_add_seconds(discover_timeout,
+ _tdls_timer_discover_event, NULL);
+
+ wifi_complete_tdls_discover(wifi, context, NETCONFIG_ERROR_TDLS_NO_ERROR);
return TRUE;
}
DBG("[TizenMW-->WPAS]: TDLS Teardown Request: [%s]", peer_mac_Addr);
if (!is_connected) {
- ERR(" Already TDLS discnnection !!!");
+ ERR(" Already TDLS disconnection !!!");
+ wifi_complete_tdls_disconnect(wifi, context, NETCONFIG_ERROR_TDLS_ALREADY_DONE);
} else {
GVariant *message = NULL;
message = __netconfig_wifi_tdls_send_dbus_str("TDLSTeardown", (const char*)peer_mac_Addr);
is_connected = 0;
}
- wifi_complete_tdls_disconnect(wifi, context, 1);
+ wifi_complete_tdls_disconnect(wifi, context, NETCONFIG_ERROR_TDLS_NO_ERROR);
return TRUE;
}
return TRUE;
}
- INFO("[TizenMW<--WPAS] TDLS Connection available, Peer Mac address %s", peer_mac);
+ INFO("TDLS Connection available, Peer Mac address %s", peer_mac);
wifi_complete_tdls_connected_peer(wifi, context, peer_mac);
g_variant_unref(message);
void netconfig_wifi_tdls_connected_event(GVariant *message)
{
- DBG("[TizenMW<--WPAS] WiFi TDLS Connected EVENT");
+ DBG("WiFi TDLS Connected EVENT");
if (is_connected == 1) {
INFO("TDLS Peer already connected");
g_free(peer_mac);
void netconfig_wifi_tdls_disconnected_event(GVariant *message)
{
- DBG("[TizenMW<--WPAS]: WiFi TDLS Disconnected EVENT");
+ DBG("WiFi TDLS Disconnected EVENT");
const gchar *peer_mac_addr = NULL;
g_variant_get(message, "(&s)", &peer_mac_addr);
void netconfig_wifi_tdls_peer_found_event(GVariant *message)
{
- DBG("[TizenMW<--WPAS]: WiFi TDLS Discovery EVENT");
+ DBG("WiFi TDLS Discovery EVENT");
const gchar *peer_mac_addr = NULL;
g_variant_get(message, "(s)", &peer_mac_addr);
INFO("Discover Peer Mac Address: [%s]", peer_mac_addr);
- __netconfig_wifi_notify_tdls_event("TDLSPeerFound", peer_mac_addr);
+
+ if (is_discover_broadcast == 0)
+ stop_tdls_timer();
+
+ __netconfig_wifi_notify_tdls_discover_event(peer_mac_addr, is_discover_broadcast);
}