return WIFI_AWARE_ERROR_INVALID_OPERATION;
}
+static void __unpack_byte_array(unsigned char *array, GVariant *var, uint16_t len)
+{
+ GVariantIter *iter = NULL;
+ int length = 0;
+
+ if (array == NULL || var == NULL || len == 0) {
+ WIFI_AWARE_LOGI("Invalid parameter");
+ return;
+ }
+
+ g_variant_get(var, "ay", &iter);
+ if (iter == NULL) {
+ WIFI_AWARE_LOGE("Fail to get iterator");
+ return;
+ }
+
+ while (g_variant_iter_loop(iter, "y", &array[length])) {
+ ++length;
+ if (length >= len)
+ break;
+ }
+ g_variant_iter_free(iter);
+}
+
static void __parsing_service_discovered_event(GVariant *parameters,
- uint16_t *sub_id, unsigned int *peer_id,
+ uint16_t *sub_id, unsigned int *peer_id, unsigned char *peer_mac,
unsigned char *specific_info, size_t *specific_info_len)
{
- gchar *info_value = NULL;
+ GVariant *mac_var = NULL;
+ GVariant *info_var = NULL;
- g_variant_get(parameters, "(qusq)", sub_id, peer_id,
- &info_value, specific_info_len);
+ g_variant_get(parameters, "(quvqv)", sub_id, peer_id, &mac_var,
+ specific_info_len, &info_var);
- memcpy(specific_info, info_value, *specific_info_len);
- g_free(info_value);
+ __unpack_byte_array(peer_mac, mac_var, WIFI_AWARE_MAC_ADDRESS_LEN);
+ __unpack_byte_array(specific_info, info_var, *specific_info_len);
+ g_variant_unref(mac_var);
+ g_variant_unref(info_var);
}
static void __parsing_message_received_event(GVariant *parameters, unsigned int *peer_id,
+ unsigned char *peer_mac,
unsigned char *message, size_t *message_len)
{
- gchar *value = NULL;
+ GVariant *mac_var = NULL;
+ GVariant *msg_var = NULL;
- g_variant_get(parameters, "(usq)", peer_id,
- &value, message_len);
+ g_variant_get(parameters, "(uvqv)", peer_id, &mac_var,
+ message_len, &msg_var);
- memcpy(message, value, *message_len);
- g_free(value);
+ __unpack_byte_array(peer_mac, mac_var, WIFI_AWARE_MAC_ADDRESS_LEN);
+ __unpack_byte_array(message, msg_var, *message_len);
+ g_variant_unref(mac_var);
+ g_variant_unref(msg_var);
}
static int __get_peer_handle(unsigned int peer_id, wifi_aware_peer_h *peer)
uint16_t sub_id = 0;
unsigned int peer_id = 0;
+ unsigned char peer_mac[WIFI_AWARE_MAC_ADDRESS_LEN];
unsigned char specific_info[WIFI_AWARE_MAX_SERVICE_SPECIFIC_INFO_LEN];
size_t specific_info_len = 0;
RET_IF(!_wifi_aware_session_is_subscribe_type(session), "This session is not for Subscribe");
__parsing_service_discovered_event(parameters,
- &sub_id, &peer_id,
+ &sub_id, &peer_id, peer_mac,
specific_info, &specific_info_len);
uint16_t session_pub_sub_id = _wifi_aware_session_get_pub_sub_id(session);
return;
}
+ _wifi_aware_peer_set_mac(peer, peer_mac);
__wifi_aware_discovered_cb(session, peer, specific_info, specific_info_len);
}
WIFI_AWARE_LOGD("NAN Service is discovered");
unsigned int peer_id = 0;
+ unsigned char peer_mac[WIFI_AWARE_MAC_ADDRESS_LEN];
unsigned char message[WIFI_AWARE_MAX_SERVICE_SPECIFIC_INFO_LEN];
size_t message_len = 0;
wifi_aware_session_h session = (wifi_aware_session_h)user_data;
wifi_aware_peer_h peer = NULL;
- __parsing_message_received_event(parameters, &peer_id,
+ __parsing_message_received_event(parameters, &peer_id, peer_mac,
message, &message_len);
WIFI_AWARE_LOGD("Peer ID: %u", peer_id);
return;
}
+ _wifi_aware_peer_set_mac(peer, peer_mac);
__wifi_aware_received_cb(session, peer, message, message_len);
}
#include "wifi-aware-data-path.h"
#include "wifi-aware-gdbus.h"
#include "wifi-aware-log.h"
+#include "wifi-aware-peer.h"
#include "wifi-aware-private.h"
#include "wifi-aware-utils.h"
return WIFI_AWARE_ERROR_NONE;
}
+API int wifi_aware_peer_get_mac(wifi_aware_peer_h peer, unsigned char **mac)
+{
+ __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(peer == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "Peer is NULL");
+ RET_VAL_IF(mac == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "mac is NULL");
+
+ return _wifi_aware_peer_get_mac(peer, mac);
+}
+
API int wifi_aware_data_path_create(wifi_aware_session_h session, wifi_aware_peer_h peer,
wifi_aware_data_path_h *data_path)
{