int raw_ssid_len; /** Raw SSID length */
char vsie[NET_WLAN_MAX_VSIE_LEN+1]; /** Vendor Specific Information Element of AP*/
gsize vsie_len; /** VSIE length */
+ GSList *vsie_list; /** List of Vendor Specific Information Element of AP*/
int assoc_status_code; /** Supplicant WiFi Association Status Code */
} net_profile_info_s;
int wifi_manager_ap_get_vsie(wifi_manager_ap_h ap,
char **vsie, int *length);
+/**
+ * @brief Called with VSIE data and length of VSIE.
+ * @since_tizen 5.0
+ * @remarks If @a vsie is needed outside the callback, a copy should be
+ * made. @a vsie will be freed automatically after the execution
+ * of this callback.
+ * @param[in] vsie The vendor specific data
+ * @param[in] length The length of vendor specific data
+ * @param[in] user_data The user data passed from the foreach function
+ * @return @c true to continue with the next iteration of the loop, \n
+ * @c false to break out of the loop
+ * @pre wifi_manager_ap_foreach_vsie() will invoke this callback.
+ * @see wifi_manager_ap_foreach_vsie().
+ */
+typedef bool(*wifi_manager_ap_vsie_cb)(unsigned char *vsie, int length, void *user_data);
+
+/**
+ * @brief Gets all VSIE of AP.
+ * @since_tizen 5.0
+ * @param[in] ap The access point handle
+ * @param[in] callback The callback to be called for each VSIE of AP
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value.
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ap_foreach_vsie(wifi_manager_ap_h ap,
+ wifi_manager_ap_vsie_cb callback, void *user_data);
/**
* @}
return Error;
}
-static int __net_convert_byte_to_txt(const unsigned char *src, char **dst, int src_len)
-{
- int dst_length = 0;
- int i = 0;
- char *buf = NULL;
-
- if (src_len <= 0) {
- WIFI_LOG(WIFI_ERROR, "Invalid source length");
- return -1;
- }
-
- *dst = (char *) g_try_malloc0((2*src_len)+1);
- if (!(*dst)) {
- WIFI_LOG(WIFI_ERROR, "failed to allocate memory to buffer");
- return -1;
- }
-
- buf = (*dst);
-
- for (i = 0; i < src_len; i++) {
- snprintf(buf, 3, "%02x", src[i]);
- buf += 2;
- dst_length += 2;
- }
-
- return dst_length;
-}
-
static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* ProfInfo)
{
net_err_e Error = NET_ERR_NONE;
} else if (g_strcmp0(key, "Vsie") == 0) {
const unsigned char *vsie_bytes = NULL;
- char *vsie = NULL;
+ unsigned char *vsie = NULL;
gsize size;
- int buf_len = 0;
vsie_bytes = g_variant_get_fixed_array(var, &size, sizeof(guchar));
if (vsie_bytes) {
- ProfInfo->vsie_len = size;
-
- buf_len = __net_convert_byte_to_txt(vsie_bytes, &vsie, size);
- if (buf_len > 0)
- g_strlcpy(ProfInfo->vsie, vsie, buf_len+1);
-
- g_free(vsie);
+ vsie = (unsigned char *)g_try_malloc0(size);
+ if (vsie) {
+ memcpy(vsie, vsie_bytes, size);
+ ProfInfo->vsie_list = g_slist_append(ProfInfo->vsie_list, vsie);
+ } else
+ WIFI_LOG(WIFI_ERROR, "Failed to allocate memory.");
}
} else if (g_strcmp0(key, "DisconnectReason") == 0) {
ProfInfo->disconnect_reason = g_variant_get_int32(var);
return WIFI_MANAGER_ERROR_NONE;
}
+EXPORT_API int wifi_manager_ap_foreach_vsie(wifi_manager_ap_h ap,
+ wifi_manager_ap_vsie_cb callback, void *user_data)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_ap_validity(ap) == false || callback == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ net_profile_info_s *profile_info = ap;
+
+ bool rv;
+ GSList *list;
+ for (list = profile_info->vsie_list; list; list = list->next) {
+ unsigned char *vsie = (unsigned char *)list->data;
+ int length = vsie[1] + 2;
+
+ rv = callback(vsie, length, user_data);
+ if (rv == false)
+ break;
+ }
+ g_slist_free_full(profile_info->vsie_list, g_free);
+ profile_info->vsie_list = NULL;
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
EXPORT_API int wifi_manager_ap_get_max_speed(wifi_manager_ap_h ap, int *max_speed)
{
__NETWORK_CAPI_FUNC_ENTER__;
return true;
}
+static int __test_convert_byte_to_txt(const unsigned char *src, char **dst, int src_len)
+{
+ int dst_length = 0;
+ int i = 0;
+ char *buf = NULL;
+
+ if (src_len <= 0) {
+ printf("Invalid source length\n");
+ return -1;
+ }
+
+ *dst = (char *)malloc((2*src_len)+1);
+ if (!(*dst)) {
+ printf("failed to allocate memory to buffer\n");
+ return -1;
+ }
+
+ buf = (*dst);
+
+ for (i = 0; i < src_len; i++) {
+ snprintf(buf, 3, "%02x", src[i]);
+ buf += 2;
+ dst_length += 2;
+ }
+
+ return dst_length;
+}
+
+static bool __test_vendor_specific_callback(unsigned char *vsie_bytes, int vsie_len, void *user_data)
+{
+ if (!vsie_bytes)
+ return false;
+
+ char *vsie = NULL;
+ int buf_len = __test_convert_byte_to_txt(vsie_bytes, &vsie, vsie_len);
+ if (buf_len > 0)
+ printf("vsie_len: %d, vsie: %s\n", vsie_len, vsie);
+
+ if (vsie)
+ free(vsie);
+
+ return true;
+}
+
static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user_data)
{
int rv, address_type = 0;
wifi_manager_disconnect_reason_e disconnect_reason;
wifi_manager_assoc_status_code_e status_code;
wifi_manager_rssi_level_e rssi_level;
- char *vsie;
- int length;
rv = wifi_manager_ap_get_essid(ap, &ap_name);
if (rv != WIFI_MANAGER_ERROR_NONE) {
else
printf("Fail to get Frequency\n");
- if (wifi_manager_ap_get_vsie(ap, &vsie, &length) == WIFI_MANAGER_ERROR_NONE) {
- printf("VSIE Len: %d vendor element: %s\n", length, vsie);
- free(vsie);
- } else
- printf("Fail to get VSIE\n");
+ if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL)
+ != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get vsie\n");
if (wifi_manager_ap_get_max_speed(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
printf("Max speed : %d\n", int_value);