*/
int wifi_manager_get_country_code(wifi_manager_h wifi, char **country_code);
+/**
+ * @brief Gets the Wi-Fi Vendor Specific Information Elements (VSIE) from DHCP ack packet of the connected network.
+ * @since_tizen 9.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks @a vsie_str must be released with free().
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[out] vsie_str The DHCP VSIE data. If the connection is established but there is no VSIE data, this parameter will be set to NULL.
+ *
+ * @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
+ * @retval #WIFI_MANAGER_ERROR_NO_CONNECTION Not Connected
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation Failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ */
+int wifi_manager_get_dhcp_vsie(wifi_manager_h wifi, char **vsie_str);
+
/**
* @brief Sets the Wi-Fi band to scan.
* @since_tizen 9.0
return Error;
}
+static void _net_extract_dhcp_vsie_from_ipv4(GVariant *variant, char **vsie)
+{
+ GVariant *var = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *value = NULL;
+ const gchar *subKey = NULL;
+
+ g_variant_get(variant, "a{sv}", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &subKey, &var)) {
+ if (g_strcmp0(subKey, "DHCPVsie") == 0) {
+ value = g_variant_get_string(var, NULL);
+ *vsie = g_strdup(value);
+ }
+ }
+
+ g_variant_iter_free(iter);
+}
+
+static int __net_extract_dhcp_vsie(GVariantIter *array, char **vsie)
+{
+ GVariant *var = NULL;
+ const gchar *key = NULL;
+
+ __NETWORK_FUNC_ENTER__;
+
+ while (g_variant_iter_loop(array, "{sv}", &key, &var)) {
+ if (g_strcmp0(key, "IPv4") == 0)
+ _net_extract_dhcp_vsie_from_ipv4(var, vsie);
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
int _net_extract_service_info(network_info_s *network_info,
const char* ProfileName, GVariantIter *iter,
net_profile_info_s* ProfInfo)
return err;
}
+static int __net_extract_dhcp_vsie_from_connected_profile(network_info_s *network_info,
+ GVariant *message, char **vsie)
+{
+ int err = NET_ERR_NONE;
+ gchar *obj_path = NULL;
+ GVariantIter *iter = NULL;
+
+ __NETWORK_FUNC_ENTER__;
+
+ if (!g_variant_is_of_type(message, G_VARIANT_TYPE("(oa{sv})"))) {
+ WIFI_LOG(WIFI_ERROR, "There is no connected service");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NO_PROFILE;
+ }
+
+ g_variant_get(message, "(oa{sv})", &obj_path, &iter);
+
+ if (g_str_has_prefix(obj_path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) != TRUE) {
+ WIFI_LOG(WIFI_ERROR, "No wifi service");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NO_PROFILE;
+ }
+
+ err = __net_extract_dhcp_vsie(iter, vsie);
+
+ g_variant_iter_free(iter);
+ g_free(obj_path);
+
+ __NETWORK_FUNC_EXIT__;
+ return err;
+}
+
static void _net_clear_cb_timers(void)
{
if (connection_cb_timer > 0) {
return err;
}
+int _net_get_dhcp_vsie_from_connected_profile(network_info_s *network_info,
+ const char *ifname, char **vsie)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e err = NET_ERR_NO_PROFILE;
+ GVariant *message;
+ GVariant *params = NULL;
+
+ params = g_variant_new("(s)", ifname);
+
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "GetConnectedService",
+ params, &err);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get connected service(profile)"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return err; //LCOV_EXCL_LINE
+ }
+
+ err = __net_extract_dhcp_vsie_from_connected_profile(network_info, message, vsie);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return err;
+}
+
int net_init_profile_info(network_info_s *network_info, net_profile_info_s *ProfInfo)
{
int i = 0;
int _net_get_profile_list(network_info_s *network_info, GSList **profile_list);
int _net_get_connected_profile(network_info_s *network_info,
const char *ifname, net_profile_info_s *profile_info);
+int _net_get_dhcp_vsie_from_connected_profile(network_info_s *network_info,
+ const char *ifname, char **vsie);
net_err_e _net_get_wifi_state(network_info_s *network_info);
void _net_clear_request_table(network_info_s *network_info);
}
//LCOV_EXCL_START
+int _wifi_get_dhcp_vsie(wifi_manager_h wifi, char **vsie)
+{
+ int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
+ const char *ifname = wifi_handle->interface_name;
+
+ rv = _net_get_dhcp_vsie_from_connected_profile(wifi_handle->network_info, ifname, vsie);
+ if (rv != NET_ERR_NONE) {
+ if (rv == NET_ERR_NO_PROFILE)
+ return WIFI_MANAGER_ERROR_NO_CONNECTION;
+ else if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied");
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+ } else if (rv == NET_ERR_INVALID_PARAM)
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ else
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
int _wifi_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band)
{
int rv;
int _wifi_set_country_code(wifi_manager_h wifi, const char *country);
int _wifi_get_country_code(wifi_manager_h wifi, char **country);
+int _wifi_get_dhcp_vsie(wifi_manager_h wifi, char **vsie);
int _wifi_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band);
int _wifi_get_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e *scan_band);
return rv;
}
+EXPORT_API int wifi_manager_get_dhcp_vsie(wifi_manager_h wifi, char **vsie_str)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv = WIFI_MANAGER_ERROR_NONE;
+ char *vsie = NULL;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (vsie_str == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+ rv = _wifi_get_dhcp_vsie(wifi, &vsie);
+ if (vsie) {
+ *vsie_str = strdup(vsie);
+ g_free(vsie);
+ } else {
+ *vsie_str = NULL;
+ }
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
+}
+
EXPORT_API int wifi_manager_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band)
{
int rv;
return 1;
}
+
+int wman_test_get_dhcp_vsie(wifi_manager_h wifi)
+{
+ int rv;
+ char *vsie = NULL;
+
+ rv = wifi_manager_get_dhcp_vsie(wifi, &vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get DHCP VSIE[%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+ printf("DHCP VSIE: %s\n", vsie);
+ free(vsie);
+
+ return 1;
+}
+
int wman_test_set_power_save_mode(wifi_manager_h wifi);
int wman_test_get_scan_band(wifi_manager_h wifi);
int wman_test_set_scan_band(wifi_manager_h wifi);
+int wman_test_get_dhcp_vsie(wifi_manager_h wifi);
printf(", - Get Wi-Fi passphrase\n");
printf(". - Get Wi-Fi band for scanning\n");
printf("/ - Set Wi-Fi band for scanning\n");
+ printf("_ - Gets the Wi-Fi VSIE from DHCP ack packet\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
case '/':
rv = wman_test_set_scan_band(wifi);
break;
+ case '_':
+ rv = wman_test_get_dhcp_vsie(wifi);
+ break;
default:
break;
}