int _net_dbus_set_preassoc_mac_policy(network_info_s *network_info, unsigned int policy);
int _net_dbus_set_random_mac_lifetime(network_info_s *network_info, unsigned int lifetime);
+int _net_dbus_set_country_code(network_info_s *network_info, const char *country);
+
#ifdef __cplusplus
}
#endif
int net_wifi_set_preassoc_mac_policy(network_info_s *network_info, unsigned int policy);
int net_wifi_set_random_mac_lifetime(network_info_s *network_info, unsigned int lifetime);
+int net_wifi_set_country_code(network_info_s *network_info, const char *country);
+
/**
* \}
*/
int wifi_manager_get_random_mac_lifetime(wifi_manager_h wifi, unsigned int *lifetime);
/**
+ * @brief Sets the raw country code.
+ * @since_tizen 6.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ * @param[in] wifi The Wi-Fi handle.
+ * @param[in] country The ISO/IEC alpha2 country code.
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation Failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ */
+int wifi_manager_set_country_code(wifi_manager_h wifi, const char *country);
+
+/**
* @}
*/
unsigned int mac_policy;
unsigned int preassoc_mac_policy;
unsigned int random_mac_lifetime;
+ /**
+ * country - Country code
+ * The ISO/IEC alpha2 country code.
+ */
+ char country[3];
} wifi_manager_handle_s;
typedef struct {
int _wifi_set_random_mac_lifetime(wifi_manager_h wifi, unsigned int lifetime);
int _wifi_get_random_mac_lifetime(wifi_manager_h wifi, unsigned int *lifetime);
+int _wifi_set_country_code(wifi_manager_h wifi, const char *country);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Name: capi-network-wifi-manager
Summary: Network Wi-Fi library in TIZEN C API
Version: 1.3.8
-Release: 3
+Release: 4
Group: System/Network
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
__NETWORK_FUNC_EXIT__;
return Error;
}
+
+int _net_dbus_set_country_code(network_info_s *network_info, const char *country)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ const char *prop_key = "CountryCode";
+ const char *method = "SetProperty";
+ GVariant *params = NULL;
+
+ params = g_variant_new("(sv)", prop_key, g_variant_new_string(country));
+
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE,
+ method, params, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set country code");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
__NETWORK_FUNC_EXIT__;
return Error;
}
+
+int net_wifi_set_country_code(network_info_s *network_info, const char *country)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_dbus_set_country_code(network_info, country);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
return WIFI_MANAGER_ERROR_NONE;
}
+
+int _wifi_set_country_code(wifi_manager_h wifi, const char *country)
+{
+ int rv;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ rv = net_wifi_set_country_code(wifi_handle->network_info, country);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ memset(wifi_handle->country, 0, sizeof(wifi_handle->country));
+ g_strlcpy(wifi_handle->country, country, sizeof(wifi_handle->country));
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
__NETWORK_CAPI_FUNC_EXIT__;
return rv;
}
+
+EXPORT_API int wifi_manager_set_country_code(wifi_manager_h wifi, const char *country)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ int rv = WIFI_MANAGER_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (country == NULL || strlen(country) != 2) {
+ WIFI_LOG(WIFI_ERROR, "country code is invalid");
+ __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__);
+
+ WIFI_LOG(WIFI_INFO, "Country Code [%s]", country);
+ rv = _wifi_set_country_code(wifi, country);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
+}
return 1;
}
+int test_wifi_manager_set_country_code(void)
+{
+ int rv;
+ char country[3];
+
+ printf("Enter alpha2 country code (e.g. IN, JP, KR, US)\n");
+ rv = scanf("%2s", country);
+
+ rv = wifi_manager_set_country_code(wifi, (const char *)country);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set country code[%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
int main(int argc, char **argv)
{
GMainLoop *mainloop;
printf("@ - Set preassoc mac policy\n");
printf("# - Set random mac lifetime\n");
printf("$ - Get mac policies\n");
+ printf("^ - Set country code\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
case '$':
rv = test_wifi_manager_get_mac_policies();
break;
+ case '^':
+ rv = test_wifi_manager_set_country_code();
+ break;
default:
break;
}