[ACR]Add new APIs for TDLS 38/54538/2
authorhyunuktak <hyunuk.tak@samsung.com>
Wed, 16 Dec 2015 04:48:42 +0000 (13:48 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 24 Dec 2015 07:37:29 +0000 (16:37 +0900)
Change-Id: I0171927d83dff8d71ed194e088ba0fb877a37fbd
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/common/network-cm-error.h
include/common/network-cm-intf.h
include/profile/network-pm-wlan.h
include/wifi/network-wifi-intf.h
packaging/libnet-client.spec
src/include/network-dbus-request.h
src/include/network-internal.h
src/include/network-signal-handler.h
src/network-dbus-request.c
src/network-signal-handler.c
src/network-wifi-intf.c

index 275f5f6..c9a1f18 100755 (executable)
@@ -171,5 +171,5 @@ typedef enum {
 #ifdef __cplusplus
 }
 #endif
+
 #endif
index b00f3ca..eb702ff 100755 (executable)
@@ -126,6 +126,12 @@ typedef enum
 
        /** Ethernet Cable Detached Event */
        NET_EVENT_ETHERNET_CABLE_DETACHED,
+
+       /** Wi-Fi TDLS Peer Connected EVENT) */
+       NET_EVENT_TDLS_CONNECTED_IND,
+
+       /** Wi-Fi TDLS Peer Disconnect EVENT) */
+       NET_EVENT_TDLS_DISCONNECTED_IND,
 } net_event_t;
 
 /**
index 32c2141..95dc0a3 100755 (executable)
@@ -51,11 +51,11 @@ extern "C"
 /** Length of bssid */
 #define NET_WLAN_BSSID_LEN      17
 
-/** 
- * Length of WPS PIN code 
+/**
+ * Length of WPS PIN code
  * WPS PIN code should be 4 or 8 digits
  */
-#define NET_WLAN_MAX_WPSPIN_LEN                8       
+#define NET_WLAN_MAX_WPSPIN_LEN                8
 
 /**
  * Passphrase length should be between 8..63,
index e900edf..18709c7 100755 (executable)
@@ -44,7 +44,7 @@ extern "C" {
 
 
 /*****************************************************************************
- *     Global Enums 
+ *     Global Enums
  *****************************************************************************/
 
 /**
@@ -93,7 +93,7 @@ typedef enum
 typedef struct {
        /** PBC / PIN */
        net_wifi_wps_type_t type;
-       
+
        /** Optional. This pin is needed when the user input PIN code */
        char pin[NET_WLAN_MAX_WPSPIN_LEN + 1];
 } net_wifi_wps_info_t;
@@ -129,15 +129,15 @@ struct wps_scan_bss_info_t {
 };
 
 /*****************************************************************************
- *     Typedefs 
+ *     Typedefs
  *****************************************************************************/
 
 
 /*****************************************************************************
- *     Global Functions 
+ *     Global Functions
  *****************************************************************************/
 
-       
+
 /*****************************************************************************
  *     ConnMan Wi-Fi Client Interface Synchronous API Declaration
  *****************************************************************************/
@@ -438,6 +438,10 @@ int net_check_profile_privilege();
 int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_t *wps_info);
 
 #endif
+
+int net_wifi_tdls_disconnect(const char* peer_mac_addr);
+int net_wifi_tdls_connected_peer(char** peer_mac_addr);
+
 /**
  * \}
  */
index 9c24ab4..3dc8b20 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          libnet-client
 Summary:       Network Client library (Shared library)
-Version:       1.1.43
+Version:       1.1.44
 Release:       1
 Group:         System/Network
 License:       Flora-1.1
index d40503f..a4599b6 100755 (executable)
@@ -141,6 +141,8 @@ int _net_dbus_set_agent_wps_pin(const char *wps_pin);
 
 #endif
 
+int _net_dbus_tdls_disconnect(const char* peer_mac_addr);
+int _net_dbus_tdls_connected_peer(char** peer_mac_addr);
 
 #ifdef __cplusplus
 }
index 5163a00..ff265ec 100755 (executable)
@@ -131,6 +131,9 @@ extern "C" {
 #define NETCONFIG_SIGNAL_SPECIFIC_SCAN_DONE    "SpecificScanCompleted"
 #define NETCONFIG_SIGNAL_WPS_SCAN_DONE         "WpsScanCompleted"
 #define NETCONFIG_SIGNAL_ETHERNET_CABLE_STATE  "EthernetCableState"
+#define NETCONFIG_SIGNAL_TDLS_CONNECTED                "TDLSConnect"
+#define NETCONFIG_SIGNAL_TDLS_DISCONNECTED             "TDLSDisconnect"
+#define NETCONFIG_SIGNAL_TDLS_PEER_FOUND               "TDLSPeerFound"
 
 #undef LOG_TAG
 #define        LOG_TAG         "NET_CLIENT"
index f851136..1648fce 100755 (executable)
@@ -33,7 +33,7 @@ extern "C" {
  *****************************************************************************/
 
 /*****************************************************************************
- *     Global Functions 
+ *     Global Functions
  *****************************************************************************/
 int _net_deregister_signal(void);
 int _net_register_signal(void);
index 97712b5..5960add 100755 (executable)
@@ -2440,3 +2440,77 @@ int _net_dbus_set_agent_wps_pin(const char *wps_pin)
        return NET_ERR_NONE;
 }
 #endif
+
+int _net_dbus_tdls_disconnect(const char* peer_mac_addr)
+{
+
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       const char *method = "TdlsDisconnect";
+       gint32 ret = -1;
+
+       params = g_variant_new("(s)", peer_mac_addr);
+
+       message = _net_invoke_dbus_method(
+                       NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+                       NETCONFIG_WIFI_INTERFACE, method, params, &Error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Failed to TDLS Disconnect Request\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       g_variant_get(message, "(i)", &ret);
+
+       NETWORK_LOG(NETWORK_HIGH, "Status [%d]\n", ret);
+
+       if(ret)
+               Error = NET_ERR_NONE;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       g_variant_unref(message);
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+int _net_dbus_tdls_connected_peer(char** peer_mac_addr)
+{
+
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+       const char *method = "TdlsConnectedPeer";
+
+
+       if(NULL == peer_mac_addr) {
+                       NETWORK_LOG(NETWORK_ERROR,"Invalid Parameter\n");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_INVALID_PARAM;
+       }
+
+       message = _net_invoke_dbus_method(
+                       NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+                       NETCONFIG_WIFI_INTERFACE, method, NULL, &Error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Failed to Get Peer Connected Mac address\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       g_variant_get(message, "(s)", peer_mac_addr);
+
+       NETWORK_LOG(NETWORK_HIGH, "TDLS Peer Mac address [%s]\n", *peer_mac_addr);
+
+       g_variant_unref(message);
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
\ No newline at end of file
index bcc4d34..1ba86f7 100755 (executable)
@@ -701,6 +701,89 @@ static void __net_connman_service_signal_filter(GDBusConnection *conn,
                        g_variant_unref(var);
        }
 }
+static int __net_handle_wifi_tdls_connected_event(GVariant *param)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       GVariant *value = NULL;
+       const char *key = NULL;
+       const gchar *sig_value = NULL;
+
+       g_variant_get(param, "(a{sv})", &iter);
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+               if (g_strcmp0(key, "peermac") == 0) {
+                       sig_value = g_variant_get_string(value, NULL);
+
+                       NETWORK_LOG(NETWORK_ERROR, "TDLS Connected Peer Mac Adress: %s",
+                                               sig_value);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       net_event_info_t event_data;
+       memset(&event_data, 0, sizeof(event_data));
+
+       event_data.Error = NET_ERR_NONE;
+       event_data.Event = NET_EVENT_TDLS_CONNECTED_IND;
+       event_data.Data = g_strdup(sig_value);
+
+       if(event_data.Data)
+               event_data.Datalength = strlen(event_data.Data);
+       else
+               event_data.Datalength = 0;
+
+       NETWORK_LOG(NETWORK_ERROR,"Sending NET_EVENT_TDLS_CONNECTED_IND");
+       _net_client_callback(&event_data);
+       g_free(event_data.Data);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_tdls_disconnected_event(GVariant *param)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       GVariant *value = NULL;
+       const char *key = NULL;
+       const gchar *sig_value = NULL;
+
+       g_variant_get(param, "(a{sv})", &iter);
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+               if (g_strcmp0(key, "peermac") == 0) {
+                       sig_value = g_variant_get_string(value, NULL);
+
+                       NETWORK_LOG(NETWORK_ERROR, "TDLS Connected Peer Mac Adress: %s",
+                                               sig_value);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       net_event_info_t event_data;
+       memset(&event_data, 0, sizeof(event_data));
+
+       event_data.Error = NET_ERR_NONE;
+       event_data.Event = NET_EVENT_TDLS_DISCONNECTED_IND;
+       event_data.Data = g_strdup(sig_value);
+
+       if(event_data.Data)
+               event_data.Datalength = strlen(event_data.Data);
+       else
+               event_data.Datalength = 0;
+
+       NETWORK_LOG(NETWORK_ERROR,"Sending NET_EVENT_TDLS_DISCONNECTED_IND");
+       _net_client_callback(&event_data);
+       g_free(event_data.Data);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
 
 static void __net_supplicant_signal_filter(GDBusConnection *conn,
                const gchar *name, const gchar *path, const gchar *interface,
@@ -722,6 +805,10 @@ static void __net_netconfig_signal_filter(GDBusConnection *conn,
                __net_handle_wifi_specific_scan_rsp(param);
        else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WPS_SCAN_DONE) == 0)
                __net_handle_wifi_wps_scan_rsp(param);
+       else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_CONNECTED) == 0)
+               __net_handle_wifi_tdls_connected_event(param);
+       else if (g_strcmp0(sig, NETCONFIG_SIGNAL_TDLS_DISCONNECTED) == 0)
+               __net_handle_wifi_tdls_disconnected_event(param);
 }
 
 static void __net_netconfig_network_signal_filter(GDBusConnection *conn,
index e03e1b3..d6cf7e9 100755 (executable)
@@ -876,3 +876,61 @@ EXPORT_API int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_t *wps_info)
        return Error;
 }
 #endif
+
+EXPORT_API int net_wifi_tdls_disconnect(const char* peer_mac_addr)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (peer_mac_addr == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "invalid parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+               NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       Error = _net_dbus_tdls_disconnect(peer_mac_addr);
+
+       if (Error != NET_ERR_NONE)
+               NETWORK_LOG(NETWORK_ERROR, "_net_dbus_tdls_set_device_type failed\n");
+
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+
+}
+
+EXPORT_API int net_wifi_tdls_connected_peer(char** peer_mac_addr)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (peer_mac_addr == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "invalid parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (g_atomic_int_get(&NetworkInfo.ref_count) == 0) {
+               NETWORK_LOG(NETWORK_ERROR, "Application is not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       Error = _net_dbus_tdls_connected_peer(peer_mac_addr);
+
+       if (Error != NET_ERR_NONE)
+               NETWORK_LOG(NETWORK_ERROR, "net_wifi_tdls_connected_peer failed\n");
+
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+
+}
\ No newline at end of file