[wifi-tdls]: Remove extra structure 83/59983/2
authorManeesh Jain <maneesh.jain@samsung.com>
Mon, 22 Feb 2016 05:07:15 +0000 (10:37 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Mon, 22 Feb 2016 07:09:06 +0000 (12:39 +0530)
Change-Id: Ia969c09f3897e939fad9dd842888a3d0bf7d3685
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
include/wifi-tdls.h
src/wifi-tdls.c

index 9f8ef29..0caea6a 100755 (executable)
@@ -1,50 +1,41 @@
-/*\r
- * Network Configuration Module\r
- *\r
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-#ifndef __TIZEN_NETWORK_WIFI_TDLS_H__\r
-#define __TIZEN_NETWORK_WIFI_TDLS_H__\r
-\r
-#ifdef __cplusplus\r
-        extern "C" {\r
-#endif\r
-\r
-#include <glib.h>\r
-#include "netsupplicant.h"\r
-\r
-typedef struct {\r
-       int is_connected;\r
-       int hdcp;\r
-       int port;\r
-       int availability;\r
-       int tdls_support;\r
-       unsigned char ip_add[4];\r
-}wifi_tdls_wfd_info_s;\r
-\r
-void netconfig_wifi_tlds_connected_event(GVariant *message);\r
-void netconfig_wifi_tlds_disconnected_event(GVariant *message);\r
-void __netconfig_wifi_notify_tdls_connected_event(const char *peer_mac);\r
-gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context, gchar *peer_mac_addr);\r
-gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context);\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* __TIZEN_NETWORK_WIFI_TDLS_H__ */\r
-\r
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __TIZEN_NETWORK_WIFI_TDLS_H__
+#define __TIZEN_NETWORK_WIFI_TDLS_H__
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+#include <glib.h>
+#include "netsupplicant.h"
+
+void netconfig_wifi_tlds_connected_event(GVariant *message);
+void netconfig_wifi_tlds_disconnected_event(GVariant *message);
+void __netconfig_wifi_notify_tdls_connected_event(const char *peer_mac);
+gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context, gchar *peer_mac_addr);
+gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_NETWORK_WIFI_TDLS_H__ */
+
index dc38441..14366c9 100755 (executable)
-/*\r
- * Network Configuration Module\r
- *\r
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <time.h>\r
-#include <stdlib.h>\r
-#include <sys/time.h>\r
-#include <unistd.h>\r
-#include <string.h>\r
-#include "neterror.h"\r
-#include "netdbus.h"\r
-#include "netsupplicant.h"\r
-#include "network-state.h"\r
-#include <vconf.h>\r
-#include <vconf-keys.h>\r
-#include <arpa/inet.h>\r
-#include <log.h>\r
-#include "util.h"\r
-#include "neterror.h"\r
-#include "wifi-tdls.h"\r
-#include <glib.h>\r
-\r
-wifi_tdls_wfd_info_s peer_info;\r
-char *peer_mac = NULL;\r
-\r
-void __netconfig_wifi_notify_tdls_event(const char *sig_name,const char *peer_mac)\r
-{\r
-       GVariantBuilder *builder;\r
-       GVariant *params;\r
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));\r
-       g_variant_builder_add(builder, "{sv}", "peermac", g_variant_new_string(peer_mac));\r
-\r
-       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));\r
-       g_variant_builder_unref(builder);\r
-\r
-       netconfig_dbus_emit_signal(NULL,\r
-                               NETCONFIG_WIFI_PATH,\r
-                               NETCONFIG_WIFI_INTERFACE,\r
-                               sig_name,\r
-                               params);\r
-\r
-       INFO("Sent signal (%s) Peer Mac (%s)", sig_name, peer_mac);\r
-}\r
-\r
-static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const char *str)\r
-{\r
-       GVariant *message = NULL;\r
-       const char *if_path = NULL;\r
-       GVariant *params = NULL;\r
-\r
-       if_path = netconfig_wifi_get_supplicant_interface();\r
-       if (if_path == NULL) {\r
-               ERR("Fail to get wpa_supplicant DBus path");\r
-               return NULL;\r
-       }\r
-\r
-       params = g_variant_new("(s)", str);\r
-       INFO("[TizenMW-->WPAS] Sent Dbus Method :[%s],value[%s]", method,str);\r
-       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,\r
-                       if_path, SUPPLICANT_INTERFACE ".Interface", method, params);\r
-\r
-       INFO("TDLS Returned from Blocking method for Send DBUS Command");\r
-       return message;\r
-}\r
-\r
-gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context,\r
-                       gchar *peer_mac_Addr)\r
-{\r
-       DBG("[TizenMW-->WPAS]: TDLS Teardown Request: [%s]", peer_mac_Addr);\r
-\r
-       if(!peer_info.is_connected) {\r
-               ERR(" No active TDLS Connection !!!");\r
-\r
-       } else {\r
-               GVariant *message = NULL;\r
-               message = __netconfig_wifi_tdls_send_dbus_str("TDLSTeardown", (const char*)peer_mac_Addr);\r
-               DBG("[TizenMW<--WPAS] TDLS DBUS Command sent successfully");\r
-               g_variant_unref(message);\r
-               peer_info.is_connected = 0;\r
-       }\r
-\r
-       wifi_complete_tdls_disconnect(wifi, context, 1);\r
-       return TRUE;\r
-}\r
-\r
-gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context)\r
-{\r
-       DBG("[TizenMW-->WPAS]: TDLS Connected Peer Request: ");\r
-\r
-       GVariant *message = NULL;\r
-       const gchar* reply_str = NULL;\r
-\r
-       if (peer_mac == NULL) {\r
-               INFO("TDLS: No Active Connection");\r
-               wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");\r
-               return TRUE;\r
-       }\r
-       message = __netconfig_wifi_tdls_send_dbus_str("TDLSStatus", (const char*)peer_mac);\r
-       if (message == NULL) {\r
-               ERR(" TDLS : No active TDLS Link Setup !!!");\r
-               wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");\r
-               return TRUE;\r
-       }\r
-\r
-       g_variant_get(message, "(&s)", &reply_str);\r
-       INFO("TDLS reply: [%s]", reply_str);\r
-       INFO("TDLS :peer_mac [%s]", peer_mac);\r
-\r
-       if (g_strcmp0("connected", reply_str) != 0) {\r
-               ERR("[TizenMW<--WPAS] TDLS Connection not available");\r
-               wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");\r
-               g_variant_unref(message);\r
-               return TRUE;\r
-       }\r
-\r
-       INFO("[TizenMW<--WPAS] TDLS Connection available, Peer Mac address %s", peer_mac);\r
-       wifi_complete_tdls_connected_peer(wifi, context, peer_mac);\r
-\r
-       g_variant_unref(message);\r
-       return TRUE;\r
-}\r
-\r
-void netconfig_wifi_tlds_connected_event(GVariant *message)\r
-{\r
-\r
-       DBG("[TizenMW<--WPAS] WiFi TDLS Connected EVENT");\r
-       if (peer_info.is_connected == 1) {\r
-               INFO("TDLS Peer already connected");\r
-               g_free(peer_mac);\r
-       }\r
-\r
-       g_variant_get(message, "(s)", &peer_mac);\r
-       INFO("Peer Mac Address: [%s]", peer_mac);\r
-\r
-       /*update the Peer Mac address in Gloablestructure*/\r
-       peer_info.is_connected = 1;\r
-       __netconfig_wifi_notify_tdls_event("TDLSConnect", peer_mac);\r
-}\r
-\r
-void netconfig_wifi_tlds_disconnected_event(GVariant *message)\r
-{\r
-       DBG("[TizenMW<--WPAS]: WiFi TDLS Disconnected EVENT");\r
-       const gchar *peer_mac_addr = NULL;\r
-\r
-       g_variant_get(message, "(&s)", &peer_mac_addr);\r
-       if (g_strcmp0(peer_mac, peer_mac_addr) == 0) {\r
-               INFO("TDLS Peer Disconnected Mac Address: [%s]", peer_mac);\r
-               peer_info.is_connected = 0;\r
-               __netconfig_wifi_notify_tdls_event("TDLSDisconnect",peer_mac);\r
-       } else\r
-               INFO("TDLS Peer Disconnected peer_mac(%s) != peer_mac_address(%s)", peer_mac, peer_mac_addr);\r
-}\r
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <string.h>
+#include "neterror.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
+#include "network-state.h"
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <arpa/inet.h>
+#include <log.h>
+#include "util.h"
+#include "neterror.h"
+#include "wifi-tdls.h"
+#include <glib.h>
+
+char *peer_mac = NULL;
+int is_connected = 0;
+
+void __netconfig_wifi_notify_tdls_event(const char *sig_name,const char *peer_mac)
+{
+       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));
+
+       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,
+                               sig_name,
+                               params);
+
+       INFO("Sent signal (%s) Peer Mac (%s)", sig_name, peer_mac);
+}
+
+static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const char *str)
+{
+       GVariant *message = NULL;
+       const char *if_path = NULL;
+       GVariant *params = NULL;
+
+       if_path = netconfig_wifi_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus path");
+               return NULL;
+       }
+
+       params = g_variant_new("(s)", 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);
+
+       INFO("TDLS Returned from Blocking method for Send DBUS Command");
+       return message;
+}
+
+gboolean handle_tdls_disconnect(Wifi *wifi, GDBusMethodInvocation *context,
+                       gchar *peer_mac_Addr)
+{
+       DBG("[TizenMW-->WPAS]: TDLS Teardown Request: [%s]", peer_mac_Addr);
+
+       if(!is_connected) {
+               ERR(" No active TDLS Connection !!!");
+
+       } else {
+               GVariant *message = NULL;
+               message = __netconfig_wifi_tdls_send_dbus_str("TDLSTeardown", (const char*)peer_mac_Addr);
+               DBG("[TizenMW<--WPAS] TDLS DBUS Command sent successfully");
+               g_variant_unref(message);
+               is_connected = 0;
+       }
+
+       wifi_complete_tdls_disconnect(wifi, context, 1);
+       return TRUE;
+}
+
+gboolean handle_tdls_connected_peer(Wifi *wifi, GDBusMethodInvocation *context)
+{
+       DBG("[TizenMW-->WPAS]: TDLS Connected Peer Request: ");
+
+       GVariant *message = NULL;
+       const gchar* reply_str = NULL;
+
+       if (peer_mac == NULL) {
+               INFO("TDLS: No Active Connection");
+               wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");
+               return TRUE;
+       }
+       message = __netconfig_wifi_tdls_send_dbus_str("TDLSStatus", (const char*)peer_mac);
+       if (message == NULL) {
+               ERR(" TDLS : No active TDLS Link Setup !!!");
+               wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");
+               return TRUE;
+       }
+
+       g_variant_get(message, "(&s)", &reply_str);
+       INFO("TDLS reply: [%s]", reply_str);
+       INFO("TDLS :peer_mac [%s]", peer_mac);
+
+       if (g_strcmp0("connected", reply_str) != 0) {
+               ERR("[TizenMW<--WPAS] TDLS Connection not available");
+               wifi_complete_tdls_connected_peer(wifi, context, "00.00.00.00.00.00");
+               g_variant_unref(message);
+               return TRUE;
+       }
+
+       INFO("[TizenMW<--WPAS] TDLS Connection available, Peer Mac address %s", peer_mac);
+       wifi_complete_tdls_connected_peer(wifi, context, peer_mac);
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+void netconfig_wifi_tlds_connected_event(GVariant *message)
+{
+
+       DBG("[TizenMW<--WPAS] WiFi TDLS Connected EVENT");
+       if (is_connected == 1) {
+               INFO("TDLS Peer already connected");
+               g_free(peer_mac);
+       }
+
+       g_variant_get(message, "(s)", &peer_mac);
+       INFO("Peer Mac Address: [%s]", peer_mac);
+
+       is_connected = 1;
+       __netconfig_wifi_notify_tdls_event("TDLSConnect", peer_mac);
+}
+
+void netconfig_wifi_tlds_disconnected_event(GVariant *message)
+{
+       DBG("[TizenMW<--WPAS]: WiFi TDLS Disconnected EVENT");
+       const gchar *peer_mac_addr = NULL;
+
+       g_variant_get(message, "(&s)", &peer_mac_addr);
+       if (g_strcmp0(peer_mac, peer_mac_addr) == 0) {
+               INFO("TDLS Peer Disconnected Mac Address: [%s]", peer_mac);
+               is_connected = 0;
+               __netconfig_wifi_notify_tdls_event("TDLSDisconnect",peer_mac);
+       } else
+               INFO("TDLS Peer Disconnected peer_mac(%s) != peer_mac_address(%s)", peer_mac, peer_mac_addr);
+}