GVariant *message = NULL;
const char *manual_method = "manual";
const char *dhcp_method = "dhcp";
+ int i;
+ char *dns_address = NULL, *temp = NULL;
b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(name));
if (ip_info->dns_type == NET_DNS_CONFIG_TYPE_STATIC)
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_DNS_METHOD,
g_variant_new_string(manual_method));
+
+ for (i = 0; i < ip_info->dns_count; i++) {
+ if (temp)
+ dns_address = g_strdup_printf("%s%s;", temp,
+ ip_info->dns_address[i]);
+ else
+ dns_address = g_strdup_printf("%s;", ip_info->dns_address[i]);
+
+ g_free(temp);
+ temp = dns_address;
+ }
+
+ if (ip_info->dns_count > 0)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_DNS_ADDRESS,
+ g_variant_new_string(dns_address));
+
+ g_free(dns_address);
+
break;
case NET_IP_CONFIG_TYPE_DYNAMIC:
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_METHOD,
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_DNS_METHOD,
g_variant_new_string(dhcp_method));
- else if (ip_info->dns_type == NET_DNS_CONFIG_TYPE_STATIC)
+ else if (ip_info->dns_type == NET_DNS_CONFIG_TYPE_STATIC) {
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_DNS_METHOD,
- g_variant_new_string(manual_method));
+ g_variant_new_string(manual_method));
+
+ for (i = 0; i < ip_info->dns_count; i++) {
+ if (temp)
+ dns_address = g_strdup_printf("%s%s;", temp,
+ ip_info->dns_address[i]);
+ else
+ dns_address = g_strdup_printf("%s;",
+ ip_info->dns_address[i]);
+
+ g_free(temp);
+ temp = dns_address;
+ }
+
+ if (ip_info->dns_count > 0)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_DNS_ADDRESS,
+ g_variant_new_string(dns_address));
+
+ g_free(dns_address);
+ }
break;
default:
break;
h->ip_info->prefix_length = 0;
h->ip_info->gateway_address = NULL;
h->ip_info->dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_NONE;
- h->ip_info->dns_address = NULL;
+ h->ip_info->dns_count = 0;
if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
h->eap_config = g_new0(wifi_eap_config_s, 1);
wifi_config_s *h = NULL;
wifi_config_s *config = NULL;
+ int i;
if (_wifi_check_config_validity(origin) == false || cloned_config == NULL) {
WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
h->ip_info->prefix_length = config->ip_info->prefix_length;
h->ip_info->gateway_address = g_strdup(config->ip_info->gateway_address);
h->ip_info->dns_type = config->ip_info->dns_type;
- h->ip_info->dns_address = g_strdup(config->ip_info->dns_address);
+ h->ip_info->dns_count = config->ip_info->dns_count;
+ for (i = 0; i < config->ip_info->dns_count; i++)
+ h->ip_info->dns_address[i] = g_strdup(config->ip_info->dns_address[i]);
}
if (config->eap_config) {
g_free(h->ip_info->ip_address); //LCOV_EXCL_LINE
g_free(h->ip_info->subnet_mask); //LCOV_EXCL_LINE
g_free(h->ip_info->gateway_address); //LCOV_EXCL_LINE
- g_free(h->ip_info->dns_address); //LCOV_EXCL_LINE
+ for (i = 0; i < h->ip_info->dns_count; i++) //LCOV_EXCL_LINE
+ g_free(h->ip_info->dns_address[i]); //LCOV_EXCL_LINE
g_free(h->ip_info); //LCOV_EXCL_LINE
g_free(h); //LCOV_EXCL_LINE
__NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
wifi_config_s *h = (wifi_config_s *)config;
+ int i;
if (_wifi_check_config_validity(config) == false) {
WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
g_free(h->ip_info->ip_address);
g_free(h->ip_info->subnet_mask);
g_free(h->ip_info->gateway_address);
- g_free(h->ip_info->dns_address);
+ for (i = 0; i < h->ip_info->dns_count; i++)
+ g_free(h->ip_info->dns_address[i]);
g_free(h->ip_info);
}
if (h->eap_config) {
return WIFI_MANAGER_ERROR_NONE;
}
+EXPORT_API int wifi_manager_config_set_dns_address(wifi_manager_config_h config,
+ int order, wifi_manager_address_family_e address_family,
+ const char *dns_address)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_wifi_check_config_validity(config) == false ||
+ (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) ||
+ order <= 0 ||
+ order > NET_DNS_ADDR_MAX) {
+ 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
+ }
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ h->ip_info->dns_address[order-1] = g_strdup(dns_address);
+ if (order == 1 || order == 2)
+ h->ip_info->dns_count += 1;
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
EXPORT_API int wifi_manager_config_get_eap_anonymous_identity(wifi_manager_config_h config,
char **anonymous_identity)
{