Add new APIs to get data path information
authorCheoleun Moon <chleun.moon@samsung.com>
Mon, 9 Mar 2020 06:41:35 +0000 (15:41 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Mon, 9 Mar 2020 06:41:35 +0000 (15:41 +0900)
include/wifi-aware.h
src/include/wifi-aware-data-path.h
src/include/wifi-aware-gdbus.h
src/include/wifi-aware-private.h
src/wifi-aware-data-path.c
src/wifi-aware-gdbus.c
src/wifi-aware-private.c
src/wifi-aware.c

index 326bcb1..220a91a 100644 (file)
@@ -640,17 +640,17 @@ int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const unsigne
 
 // only for responder
 /**
- * @brief Set a service specific information which is contained in Data Path Response Frame.
+ * @brief
+ * @remarks This is only for Data Path Responder
  * @since_tizen 6.0
  * @param[in] data_path
- * @param[in] service_specific_info
- * @param[in] service_specific_info_len
+ * @param[in] port
+ * @return     0 on success, otherwise a negative error value
+ * @retval     #WIFI_AWARE_ERROR_NONE
  */
-int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, const unsigned char *service_specific_info, size_t service_specific_info_len);
-// TODO:
-// We are considering
-// removing wifi_aware_data_path_set_service_specific_info() and
-// adding wifi_aware_data_path_set_port() and wifi_aware_data_path_set_ip_address().
+int wifi_aware_data_path_set_port(wifi_aware_data_path_h data_path, int port);
+
+// We are considering to add wifi_aware_data_path_set_ip_address().
 
 /**
  * @brief Destroy a handle for Wi-Fi Aware Data Path
@@ -665,25 +665,22 @@ int wifi_aware_data_path_destroy(wifi_aware_data_path_h data_path);
  * @since_tizen 6.0
  * @param[in] data_path
  * @param[in] error
- * @param[in] mac
- * @param[in] service_specific_info
- * @param[in] service_specific_info_len
+ * @param[in] mac peer's NDI (NAN Data Interface)
  * @param[in] user_data
  */
 typedef void(*wifi_aware_data_path_open_cb)(wifi_aware_data_path_h data_path, wifi_aware_error_e error,
-               const unsigned char *mac, const unsigned char *service_specific_info, size_t service_specific_info_len, void *user_data);
+               void *user_data);
 
 /**
  * @brief Start to open a Wi-Fi Aware Data Path.
- * @remarks If role is WIFI_AWARE_DATA_PATH_INITIATOR, the device will send a DataRequest Frame.
- *          If role is WIFI_AWARE_DATA_PATH_RESPONDER, the device will wait for a DataRequest and send DataResponse on receiving DataRequest from its peer
  * @remarks The @a callback will be always invoked whether the open request succeeds or fails.
  * @since_tizen 6.0
  * @param[in] data_path
  * @param[in] callback
  * @param[in] user_data
  */
-int wifi_aware_data_path_open(wifi_aware_data_path_h data_path, wifi_aware_data_path_open_cb callback, void *user_data);
+int wifi_aware_data_path_open(wifi_aware_data_path_h data_path,
+               wifi_aware_data_path_open_cb callback, void *user_data);
 
 /**
  * @brief Close a Wi-Fi Aware Data Path.
@@ -692,6 +689,41 @@ int wifi_aware_data_path_open(wifi_aware_data_path_h data_path, wifi_aware_data_
  */
 int wifi_aware_data_path_close(wifi_aware_data_path_h data_path);
 
+/**
+ * @brief
+ * @remarks This is only for Data Path Initiator
+ * @since_tizen 6.0
+ * @param[in]
+ * @param[out]
+ * @return
+ * @retval     #WIFI_AWARE_ERROR_NONE
+ */
+int wifi_aware_data_path_get_peer_port(wifi_aware_data_path_h data_path, int* port);
+
+/**
+ * @brief
+ * @remarks This is only for Data Path Initiator
+ * @remarks @a ipv6_address should be freed by using free().
+ * @since_tizen 6.0
+ * @param[in]
+ * @param[out]
+ * @return
+ * @retval     #WIFI_AWARE_ERROR_NONE
+ */
+int wifi_aware_data_path_get_ipv6_address(wifi_aware_data_path_h data_path, char **ipv6_address);
+
+/**
+ * @brief
+ * @remarks @a interface should be freed by using free().
+ * @since_tizen 6.0
+ * @param[in]
+ * @param[out]
+ * @return
+ * @retval     #WIFI_AWARE_ERROR_NONE
+ */
+int wifi_aware_data_path_get_interface(wifi_aware_data_path_h data_path, char **interface);
+
+// get peer NDI?
 
 /**
  * @brief Callback to notify that the Wi-Fi Aware Data Path has been lost.
index eebc783..774b73a 100644 (file)
@@ -30,6 +30,7 @@ extern "C" {
 #define WIFI_AWARE_MIN_PSK_LEN 8
 #define WIFI_AWARE_MAX_PSK_LEN 63
 #define WIFI_AWARE_PMK_LEN 32
+#define WIFI_AWARE_STR_IPV6_ADDRESS_LEN 39
 
 typedef enum {
        WIFI_AWARE_DATA_PATH_INITIATOR,
@@ -38,6 +39,7 @@ typedef enum {
 
 int _wifi_aware_data_path_handle_create(wifi_aware_session_h session, wifi_aware_peer_h peer,
                wifi_aware_data_path_h *data_path);
+int _wifi_aware_data_path_handle_destroy(wifi_aware_data_path_h data_path);
 int _wifi_aware_data_path_set_security(wifi_aware_data_path_h data_path,
                wifi_aware_security_type_e security_type);
 int _wifi_aware_data_path_set_psk(wifi_aware_data_path_h data_path, const char *key);
@@ -45,10 +47,13 @@ int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path,
                const unsigned char *key);
 int _wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path,
                const unsigned char *service_specific_info, size_t service_specific_info_len);
-int _wifi_aware_data_path_destroy(wifi_aware_data_path_h data_path);
+int _wifi_aware_data_path_set_port(wifi_aware_data_path_h data_path, int port);
 int _wifi_aware_data_path_open(wifi_aware_data_path_h data_path,
                wifi_aware_data_path_open_cb callback, void *user_data);
 int _wifi_aware_data_path_close(wifi_aware_data_path_h data_path);
+int _wifi_aware_data_path_get_peer_port(wifi_aware_data_path_h data_path, int* port);
+int _wifi_aware_data_path_get_peer_ipv6_address(wifi_aware_data_path_h data_path, char **ipv6_address);
+int _wifi_aware_data_path_get_interface(wifi_aware_data_path_h data_path, char **interface);
 int _wifi_aware_data_path_set_terminated_cb(wifi_aware_data_path_h data_path,
                wifi_aware_data_path_terminated_cb callback, void *user_data);
 
index c9fa22a..b08a946 100644 (file)
@@ -76,21 +76,21 @@ int wifi_aware_gdbus_followup(wifi_aware_session_h session,
                const unsigned char *message, size_t len,
                GAsyncReadyCallback cb, void *user_data);
 
-int wifi_aware_gdbus_ndp_open(wifi_aware_data_path_h data_path,
-               uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role,
-               const unsigned char *specific_info, size_t specific_info_len,
+int wifi_aware_gdbus_open_ndp(wifi_aware_data_path_h data_path,
+               uint16_t pub_sub_id, unsigned int peer_id,
+               wifi_aware_data_path_role_e role, int port,
                GAsyncReadyCallback cb);
-int wifi_aware_gdbus_ndp_close(wifi_aware_data_path_h data_path,
-               unsigned int ndp_id, uint16_t pub_sub_id, unsigned int peer_id);
-int wifi_aware_gdbus_ndp_psk(wifi_aware_data_path_h data_path,
-               uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role,
-               const unsigned char *specific_info, size_t specific_info_len,
+int wifi_aware_gdbus_open_ndp_psk(wifi_aware_data_path_h data_path,
+               uint16_t pub_sub_id, unsigned int peer_id,
+               wifi_aware_data_path_role_e role, int port,
                const char *psk, GAsyncReadyCallback cb);
-int wifi_aware_gdbus_ndp_pmk(wifi_aware_data_path_h data_path,
-               uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role,
-               const unsigned char *specific_info, size_t specific_info_len,
-               const unsigned char *pmk, size_t pmk_len,
+int wifi_aware_gdbus_open_ndp_pmk(wifi_aware_data_path_h data_path,
+               uint16_t pub_sub_id, unsigned int peer_id,
+               wifi_aware_data_path_role_e role, int port,
+               const unsigned char *pmk,
                GAsyncReadyCallback cb);
+int wifi_aware_gdbus_ndp_close(wifi_aware_data_path_h data_path,
+               unsigned int ndp_id, uint16_t pub_sub_id, unsigned int peer_id);
 #ifdef __cplusplus
 }
 #endif
index 79bcffb..a183774 100644 (file)
@@ -29,6 +29,7 @@ extern "C" {
 
 const char *_wifi_aware_convert_error_type_to_string(wifi_aware_error_e err);
 wifi_aware_error_e _wifi_aware_convert_error_string_to_enum(const char *error);
+wifi_aware_error_e _wifi_aware_convert_nan_manager_error(int error);
 
 bool _wifi_aware_is_initialized();
 int _wifi_aware_init();
index a6cd345..795f9a7 100644 (file)
@@ -45,12 +45,13 @@ typedef struct {
        char psk[WIFI_AWARE_MAX_PSK_LEN + 1];
        unsigned char pmk[WIFI_AWARE_PMK_LEN];
        size_t pmk_len;
-
-       unsigned char specific_info[WIFI_AWARE_MAX_SERVICE_SPECIFIC_INFO_LEN];
-       size_t specific_info_len;
+       int port;
 
        char iface_name[IFNAMSIZ + 1];
 
+       int peer_port;
+       char peer_ip[WIFI_AWARE_STR_IPV6_ADDRESS_LEN + 1];
+
        wifi_aware_data_path_open_cb open_cb;
        void *open_cb_user_data;
        wifi_aware_data_path_terminated_cb terminated_cb;
@@ -81,12 +82,26 @@ static void __data_path_open(wifi_aware_data_path_h data_path)
 {
        wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
        ndp->is_open = true;
+       WIFI_AWARE_LOGD("Opened Data path %p. Session: %p, Peer: %p", data_path, ndp->session, ndp->peer);
 }
 
 static void __data_path_close(wifi_aware_data_path_h data_path)
 {
        wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
        ndp->is_open = false;
+       WIFI_AWARE_LOGD("Closed Data path %p. Session: %p, Peer: %p", data_path, ndp->session, ndp->peer);
+}
+
+static bool __data_path_is_initiator(wifi_aware_data_path_h data_path)
+{
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
+       return ndp->role == WIFI_AWARE_DATA_PATH_INITIATOR;
+}
+
+static bool __data_path_is_responder(wifi_aware_data_path_h data_path)
+{
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
+       return ndp->role == WIFI_AWARE_DATA_PATH_RESPONDER;
 }
 
 int _wifi_aware_data_path_handle_create(wifi_aware_session_h session, wifi_aware_peer_h peer,
@@ -111,6 +126,12 @@ int _wifi_aware_data_path_handle_create(wifi_aware_session_h session, wifi_aware
        return WIFI_AWARE_ERROR_NONE;
 }
 
+int _wifi_aware_data_path_handle_destroy(wifi_aware_data_path_h data_path)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+       return WIFI_AWARE_ERROR_NONE;
+}
+
 int _wifi_aware_data_path_set_security(wifi_aware_data_path_h data_path,
                wifi_aware_security_type_e security_type)
 {
@@ -157,7 +178,7 @@ int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const unsign
 {
        __WIFI_AWARE_FUNC_ENTER__;
 
-       RET_VAL_IF(data_path== NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
        wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
        RET_VAL_IF(ndp->security_type != WIFI_AWARE_SECURITY_TYPE_PMK,
                WIFI_AWARE_ERROR_INVALID_OPERATION, "security type is not WIFI_AWARE_SECURITY_TYPE_PMK");
@@ -166,30 +187,21 @@ int _wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const unsign
        return WIFI_AWARE_ERROR_NONE;
 }
 
-int _wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path,
-               const unsigned char *service_specific_info, size_t service_specific_info_len)
+static bool __is_valid_port(int port)
 {
-       __WIFI_AWARE_FUNC_ENTER__;
-
-       RET_VAL_IF(data_path== NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
-       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
-
-       if (service_specific_info_len > WIFI_AWARE_MAX_SERVICE_SPECIFIC_INFO_LEN) {
-               WIFI_AWARE_LOGE("service_specific_info is too long");
-               return WIFI_AWARE_ERROR_INVALID_PARAMETER;
-       }
-
-       if (service_specific_info_len  == 0)
-               return WIFI_AWARE_ERROR_NONE;
-
-       memcpy(ndp->specific_info, service_specific_info, service_specific_info_len);
-       ndp->specific_info_len = service_specific_info_len;
-       return WIFI_AWARE_ERROR_NONE;
+       return port >= 0 && port <= 65535;      // 0 to 1023 are reserved for privileged services (well-know ports)
 }
 
-int _wifi_aware_data_path_destroy(wifi_aware_data_path_h data_path)
+int _wifi_aware_data_path_set_port(wifi_aware_data_path_h data_path, int port)
 {
        __WIFI_AWARE_FUNC_ENTER__;
+
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(!__data_path_is_responder(data_path),
+                       WIFI_AWARE_ERROR_INVALID_OPERATION, "Only for Data Path Responder");
+       RET_VAL_IF(__is_valid_port(port), WIFI_AWARE_ERROR_INVALID_PARAMETER, "Port numbers range from 0 to 65535");
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
+       ndp->port = port;
        return WIFI_AWARE_ERROR_NONE;
 }
 
@@ -208,32 +220,50 @@ static void __data_path_invoke_callback(wifi_aware_data_path_h data_path, wifi_a
        wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
 
        if (ndp->open_cb)
-               ndp->open_cb(data_path, error, mac, specific_info, specific_info_len, ndp->open_cb_user_data);
+               ndp->open_cb(data_path, error, ndp->open_cb_user_data);
 }
 
-static void __data_path_open_reply(GObject *src, GAsyncResult *res, gpointer user_data)
+static wifi_aware_error_e __get_data_path_open_result(GObject *src,
+               GAsyncResult *res, wifi_aware_data_path_h data_path)
 {
-       //GDBusConnection *conn = NULL;
+       GDBusConnection *conn = G_DBUS_CONNECTION(src);
        GError *dbus_error = NULL;
-       //GVariant *reply = NULL;
+       GVariant *reply = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       int nan_error = 0;
        wifi_aware_error_e error = WIFI_AWARE_ERROR_NONE;
-       //int nan_error = 0;
-       wifi_aware_data_path_h data_path = (wifi_aware_data_path_h)user_data;
-       // unsigned int ndp_id;
+       gchar *iface = NULL;
+       gchar *ip = NULL;
 
-       WIFI_AWARE_LOGI("Reply for Data Path Open request");
-
-       //conn = G_DBUS_CONNECTION(src);
-       //reply = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       RET_VAL_IF(reply == NULL, WIFI_AWARE_ERROR_INVALID_OPERATION, "reply is NULL");
 
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
        if (dbus_error != NULL) {
-               WIFI_AWARE_LOGE("Open Request failure: %s", dbus_error->message);
+               WIFI_AWARE_LOGE("Fail to open Data Path: %s", dbus_error->message);
                error = _wifi_aware_convert_error_string_to_enum(dbus_error->message);
                g_error_free(dbus_error);
-       } else {
-               // TODO: Parameter parsing
        }
-       
+       else {
+               g_variant_get(reply, "ussii", &ndp->ndp_id, &iface, &ip, &ndp->peer_port, nan_error);
+               error = _wifi_aware_convert_nan_manager_error(nan_error);
+               if (error == WIFI_AWARE_ERROR_NONE) {
+                       strncpy(ndp->iface_name, iface, IFNAMSIZ);
+                       strncpy(ndp->peer_ip, ip, WIFI_AWARE_STR_IPV6_ADDRESS_LEN);
+                       WIFI_AWARE_LOGD("New Data Path. ndp_id: %u", ndp->ndp_id);
+               }
+       }
+       return error;
+}
+
+static void __data_path_open_reply(GObject *src, GAsyncResult *res, gpointer user_data)
+{
+       wifi_aware_error_e error = WIFI_AWARE_ERROR_NONE;
+       wifi_aware_data_path_h data_path = (wifi_aware_data_path_h)user_data;
+
+       WIFI_AWARE_LOGI("Reply for Data Path Open request");
+       RET_IF(data_path == NULL, "Data path is NULL");
+
+       error = __get_data_path_open_result(src, res, data_path);
+
        if (error == WIFI_AWARE_ERROR_NONE)
                __data_path_open(data_path);
        __data_path_invoke_callback(data_path, error, NULL, NULL, 0);
@@ -244,37 +274,33 @@ int _wifi_aware_data_path_open(wifi_aware_data_path_h data_path,
 {
        __WIFI_AWARE_FUNC_ENTER__;
 
-       RET_VAL_IF(data_path== NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
        wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
 
        __data_path_set_open_cb(data_path, callback, user_data);
        switch (ndp->security_type) {
        case WIFI_AWARE_SECURITY_TYPE_OPEN:
-               return wifi_aware_gdbus_ndp_open(data_path,
+               return wifi_aware_gdbus_open_ndp(data_path,
                                _wifi_aware_session_get_pub_sub_id(ndp->session),
                                _wifi_aware_peer_get_id(ndp->peer),
                                ndp->role,
-                               ndp->specific_info,
-                               ndp->specific_info_len,
+                               ndp->port,
                                __data_path_open_reply);
        case WIFI_AWARE_SECURITY_TYPE_PSK:
-               return wifi_aware_gdbus_ndp_psk(data_path,
+               return wifi_aware_gdbus_open_ndp_psk(data_path,
                                _wifi_aware_session_get_pub_sub_id(ndp->session),
                                _wifi_aware_peer_get_id(ndp->peer),
                                ndp->role,
-                               ndp->specific_info,
-                               ndp->specific_info_len,
+                               ndp->port,
                                ndp->psk,
                                __data_path_open_reply);
        case WIFI_AWARE_SECURITY_TYPE_PMK:
-               return wifi_aware_gdbus_ndp_pmk(data_path,
+               return wifi_aware_gdbus_open_ndp_pmk(data_path,
                                _wifi_aware_session_get_pub_sub_id(ndp->session),
                                _wifi_aware_peer_get_id(ndp->peer),
                                ndp->role,
-                               ndp->specific_info,
-                               ndp->specific_info_len,
+                               ndp->port,
                                ndp->pmk,
-                               WIFI_AWARE_PMK_LEN,
                                __data_path_open_reply);
        }
 
@@ -288,7 +314,7 @@ int _wifi_aware_data_path_close(wifi_aware_data_path_h data_path)
        int ret = WIFI_AWARE_ERROR_NONE;
        __WIFI_AWARE_FUNC_ENTER__;
 
-       RET_VAL_IF(data_path== NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
        RET_VAL_IF(!__data_path_is_open(data_path), WIFI_AWARE_ERROR_INVALID_OPERATION, "No Data Path");
 
        wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
@@ -300,7 +326,53 @@ int _wifi_aware_data_path_close(wifi_aware_data_path_h data_path)
        return ret;
 }
 
-int _wifi_aware_data_path_set_terminated_cb(wifi_aware_data_path_h data_path, wifi_aware_data_path_terminated_cb callback, void *user_data)
+int _wifi_aware_data_path_get_peer_port(wifi_aware_data_path_h data_path, int* port)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(!__data_path_is_open(data_path), WIFI_AWARE_ERROR_INVALID_OPERATION, "No Data Path");
+       RET_VAL_IF(!__data_path_is_initiator(data_path),
+                       WIFI_AWARE_ERROR_INVALID_OPERATION, "Only for Data Path Initiator");
+
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
+       *port = ndp->port;
+
+       return WIFI_AWARE_ERROR_NONE;
+}
+
+int _wifi_aware_data_path_get_peer_ipv6_address(wifi_aware_data_path_h data_path, char **ipv6_address)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(!__data_path_is_open(data_path), WIFI_AWARE_ERROR_INVALID_OPERATION, "No Data Path");
+       RET_VAL_IF(!__data_path_is_initiator(data_path),
+                       WIFI_AWARE_ERROR_INVALID_OPERATION, "Only for Data Path Initiator");
+
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
+       *ipv6_address = g_strdup(ndp->peer_ip);
+       RET_VAL_IF(ipv6_address == NULL, WIFI_AWARE_ERROR_OUT_OF_MEMORY, "Out of memory");
+
+       return WIFI_AWARE_ERROR_NONE;
+}
+
+int _wifi_aware_data_path_get_interface(wifi_aware_data_path_h data_path, char **interface)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "data_path is NULL");
+       RET_VAL_IF(!__data_path_is_open(data_path), WIFI_AWARE_ERROR_INVALID_OPERATION, "No Data Path");
+
+       wifi_aware_data_path_s *ndp = (wifi_aware_data_path_s *)data_path;
+       *interface = g_strdup(ndp->iface_name);
+       RET_VAL_IF(interface == NULL, WIFI_AWARE_ERROR_OUT_OF_MEMORY, "Out of memory");
+
+       return WIFI_AWARE_ERROR_NONE;
+}
+
+int _wifi_aware_data_path_set_terminated_cb(wifi_aware_data_path_h data_path,
+               wifi_aware_data_path_terminated_cb callback, void *user_data)
 {
        int ret = WIFI_AWARE_ERROR_NONE;
        __WIFI_AWARE_FUNC_ENTER__;
index dcb20db..0a02b15 100644 (file)
@@ -627,34 +627,33 @@ int wifi_aware_gdbus_followup(wifi_aware_session_h session,
        return ret;
 }
 
-int wifi_aware_gdbus_ndp_open(wifi_aware_data_path_h data_path,
-               uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role,
-               const unsigned char *specific_info, size_t specific_info_len,
+int wifi_aware_gdbus_open_ndp(wifi_aware_data_path_h data_path,
+               uint16_t pub_sub_id, unsigned int peer_id,
+               wifi_aware_data_path_role_e role, int port,
                GAsyncReadyCallback cb)
 {
        return WIFI_AWARE_ERROR_NONE;
 }
 
-int wifi_aware_gdbus_ndp_close(wifi_aware_data_path_h data_path,
-               unsigned int ndp_id, uint16_t pub_sub_id, unsigned int peer_id)
+int wifi_aware_gdbus_open_ndp_psk(wifi_aware_data_path_h data_path,
+               uint16_t pub_sub_id, unsigned int peer_id,
+               wifi_aware_data_path_role_e role, int port, const char *psk,
+               GAsyncReadyCallback cb)
 {
        return WIFI_AWARE_ERROR_NONE;
 }
 
-int wifi_aware_gdbus_ndp_psk(wifi_aware_data_path_h data_path,
-               uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role,
-               const unsigned char *specific_info, size_t specific_info_len,
-               const char *psk,
+int wifi_aware_gdbus_open_ndp_pmk(wifi_aware_data_path_h data_path,
+               uint16_t pub_sub_id, unsigned int peer_id,
+               wifi_aware_data_path_role_e role, int port, const unsigned char *pmk,
                GAsyncReadyCallback cb)
 {
        return WIFI_AWARE_ERROR_NONE;
 }
 
-int wifi_aware_gdbus_ndp_pmk(wifi_aware_data_path_h data_path,
-               uint16_t pub_sub_id, unsigned int peer_id, wifi_aware_data_path_role_e role,
-               const unsigned char *specific_info, size_t specific_info_len,
-               const unsigned char *pmk, size_t pmk_len,
-               GAsyncReadyCallback cb)
+int wifi_aware_gdbus_ndp_close(wifi_aware_data_path_h data_path,
+               unsigned int ndp_id, uint16_t pub_sub_id, unsigned int peer_id)
 {
        return WIFI_AWARE_ERROR_NONE;
 }
+
index e6ccd5f..2be8729 100644 (file)
@@ -291,7 +291,7 @@ static wifi_aware_error_e __get_dbus_result(GObject *src, GAsyncResult *res, uin
        RET_VAL_IF(reply == NULL, WIFI_AWARE_ERROR_INVALID_OPERATION, "reply is NULL");
 
        if (dbus_error != NULL) {
-               WIFI_AWARE_LOGE("Publish Request failure: %s", dbus_error->message);
+               WIFI_AWARE_LOGE("Publish/Subsribe Request failure: %s", dbus_error->message);
                error = _wifi_aware_convert_error_string_to_enum(dbus_error->message);
                g_error_free(dbus_error);
        }
index 10cc57d..66f4e4b 100644 (file)
@@ -639,7 +639,7 @@ API int wifi_aware_data_path_set_pmk(wifi_aware_data_path_h data_path, const uns
        return ret;
 }
 
-API int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h data_path, const unsigned char *service_specific_info, size_t service_specific_info_len)
+API int wifi_aware_data_path_set_port(wifi_aware_data_path_h data_path, int port)
 {
        int ret = WIFI_AWARE_ERROR_NONE;
 
@@ -648,8 +648,7 @@ API int wifi_aware_data_path_set_service_specific_info(wifi_aware_data_path_h da
        RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
        RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
 
-       ret = _wifi_aware_data_path_set_service_specific_info(data_path,
-                       service_specific_info, service_specific_info_len);
+       ret = _wifi_aware_data_path_set_port(data_path, port);
 
        __WIFI_AWARE_FUNC_EXIT__;
        return ret;
@@ -664,7 +663,7 @@ API int wifi_aware_data_path_destroy(wifi_aware_data_path_h data_path)
        RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
        RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
 
-       ret = _wifi_aware_data_path_destroy(data_path);
+       ret = _wifi_aware_data_path_handle_destroy(data_path);
 
        __WIFI_AWARE_FUNC_EXIT__;
        return ret;
@@ -700,6 +699,37 @@ API int wifi_aware_data_path_close(wifi_aware_data_path_h data_path)
        return ret;
 }
 
+int wifi_aware_data_path_get_peer_port(wifi_aware_data_path_h data_path, int* port)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
+       RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
+
+       return _wifi_aware_data_path_get_peer_port(data_path, port);
+}
+
+int wifi_aware_data_path_get_peer_ipv6_address(wifi_aware_data_path_h data_path, char **ipv6_address)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
+       RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
+       RET_VAL_IF(ipv6_address == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "ipv6_address is NULL");
+
+       return _wifi_aware_data_path_get_peer_ipv6_address(data_path, ipv6_address);
+}
+
+int wifi_aware_data_path_get_interface(wifi_aware_data_path_h data_path, char **interface)
+{
+       __WIFI_AWARE_FUNC_ENTER__;
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
+       RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
+       RET_VAL_IF(data_path == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Data path is NULL");
+       RET_VAL_IF(interface == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "interface is NULL");
+
+       return _wifi_aware_data_path_get_interface(data_path, interface);
+}
 
 API int wifi_aware_data_path_set_terminated_cb(wifi_aware_data_path_h data_path, wifi_aware_data_path_terminated_cb callback, void *user_data)
 {