g_free(conf->ip_info->subnet_mask);
g_free(conf->ip_info->gateway_address);
g_free(conf->ip_info->dns_type);
+ conf->ip_info->prefix_length = 0;
int i = 0, count = conf->ip_info->dns_count;
while (i < count) {
}
mac[12] = '\0';
*mac_address = g_strdup(mac);
+ g_free(tmp);
return TRUE;
}
config->is_hidden = g_strdup("FALSE");
DBG("is_hidden [%s]", config->is_hidden);
- config->ip_info->ip_type = g_key_file_get_string(keyfile, group_name,
- WIFI_CONFIG_IPV4_METHOD, NULL);
- if (config->ip_info->ip_type)
- DBG("IPv4.Method:%s", config->ip_info->ip_type);
-
- config->ip_info->ip_address = g_key_file_get_string(keyfile, group_name,
- WIFI_CONFIG_IPV4_ADDRESS, NULL);
- if (config->ip_info->ip_address)
- DBG("IPv4.Address:%s", config->ip_info->ip_address);
-
- int prefix_len;
- in_addr_t addr;
- struct in_addr netmask;
- char *mask;
- prefix_len = g_key_file_get_integer(keyfile, group_name,
- WIFI_CONFIG_IPV4_SUBNET_MASK, NULL);
- addr = 0xffffffff << (32 - prefix_len);
- netmask.s_addr = htonl(addr);
- mask = inet_ntoa(netmask);
- config->ip_info->subnet_mask = g_strdup(mask);
- if (config->ip_info->subnet_mask)
- DBG("IPv4.SubnetMask:%s", config->ip_info->subnet_mask);
-
- config->ip_info->gateway_address = g_key_file_get_string(keyfile,
- group_name, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS,
- NULL);
- if (config->ip_info->gateway_address)
- DBG("IPv4.gateway:%s", config->ip_info->gateway_address);
-
- config->ip_info->dns_type = g_key_file_get_string(keyfile, group_name,
- WIFI_CONFIG_IPV4_DNS_METHOD, NULL);
- if (config->ip_info->dns_type)
- DBG("DNS.IPv4Method:%s", config->ip_info->dns_type);
-
- char **nameservers;
- gsize length;
- nameservers = g_key_file_get_string_list(keyfile, group_name,
- WIFI_CONFIG_DNS_ADDRESS, &length, NULL);
- if (nameservers) {
- if (length > 0) {
- config->ip_info->dns_count = length;
- int i = 0;
- while (i < NET_DNS_ADDR_MAX && nameservers[i]) {
- config->ip_info->dns_address[i] = g_strdup(nameservers[i]);
- DBG("DNSAddress[%d]:%s", i+1, config->ip_info->dns_address[i]);
- i += 1;
+ if (config->ip_info) {
+ GError *error = NULL;
+ config->ip_info->ip_type = g_key_file_get_string(keyfile, group_name,
+ WIFI_CONFIG_IPV4_METHOD, NULL);
+ if (config->ip_info->ip_type)
+ DBG("IPv4.Method:%s", config->ip_info->ip_type);
+
+ config->ip_info->ip_address = g_key_file_get_string(keyfile, group_name,
+ WIFI_CONFIG_IPV4_ADDRESS, NULL);
+ if (config->ip_info->ip_address)
+ DBG("IPv4.Address:%s", config->ip_info->ip_address);
+
+ int prefix_len;
+ in_addr_t addr;
+ struct in_addr netmask;
+ char *mask;
+ prefix_len = g_key_file_get_integer(keyfile, group_name,
+ WIFI_CONFIG_IPV4_SUBNET_MASK, &error);
+ if (error != NULL) {
+ DBG("g_key_file_get_integer failed error[%d: %s]", error->code, error->message);
+ g_error_free(error);
+ } else {
+ if (prefix_len > 0 && prefix_len < 32) {
+ addr = 0xffffffff << (32 - prefix_len);
+ netmask.s_addr = htonl(addr);
+ mask = inet_ntoa(netmask);
+ config->ip_info->subnet_mask = g_strdup(mask);
+ }
+ if (config->ip_info->subnet_mask)
+ DBG("IPv4.SubnetMask:%s", config->ip_info->subnet_mask);
+ }
+
+ config->ip_info->gateway_address = g_key_file_get_string(keyfile,
+ group_name, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, NULL);
+ if (config->ip_info->gateway_address)
+ DBG("IPv4.gateway:%s", config->ip_info->gateway_address);
+
+ config->ip_info->dns_type = g_key_file_get_string(keyfile, group_name,
+ WIFI_CONFIG_IPV4_DNS_METHOD, NULL);
+ if (config->ip_info->dns_type)
+ DBG("DNS.IPv4Method:%s", config->ip_info->dns_type);
+
+ char **nameservers;
+ gsize length;
+ nameservers = g_key_file_get_string_list(keyfile, group_name,
+ WIFI_CONFIG_DNS_ADDRESS, &length, NULL);
+ if (nameservers) {
+ if (length > 0) {
+ config->ip_info->dns_count = length;
+ int i = 0;
+ while (i < NET_DNS_ADDR_MAX && nameservers[i]) {
+ config->ip_info->dns_address[i] = g_strdup(nameservers[i]);
+ DBG("DNSAddress[%d]:%s", i+1, config->ip_info->dns_address[i]);
+ i += 1;
+ }
}
+ g_strfreev(nameservers);
}
- g_strfreev(nameservers);
}
if (conf->ip_info->subnet_mask != NULL)
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_SUBNET_MASK, g_variant_new_string(conf->ip_info->subnet_mask));
+ if (conf->ip_info->prefix_length > 0)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV6_PREFIX_LEN, g_variant_new_int32(conf->ip_info->prefix_length));
+
if (conf->ip_info->gateway_address != NULL)
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, g_variant_new_string(conf->ip_info->gateway_address));
} else {
conf->ip_info->subnet_mask = NULL;
}
+ } else if (g_strcmp0(field, WIFI_CONFIG_IPV6_PREFIX_LEN) == 0) {
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) {
+ conf->ip_info->prefix_length = g_variant_get_int32(value);
+ DBG("IPv6 Prefix Length [%d]", conf->ip_info->prefix_length);
+ } else {
+ conf->ip_info->prefix_length = 0;
+ }
} else if (g_strcmp0(field, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS) == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
conf->ip_info->gateway_address = g_strdup(g_variant_get_string(value, NULL));
if (conf->ip_info->subnet_mask != NULL) {
unsigned char prefix_len;
prefix_len = __netconfig_convert_netmask_to_prefixlen(
- conf->ip_info->subnet_mask);
- g_key_file_set_integer(keyfile, group_name,
- WIFI_CONFIG_IPV4_SUBNET_MASK, prefix_len);
+ conf->ip_info->subnet_mask);
+ if (prefix_len > 0 && prefix_len < 32)
+ g_key_file_set_integer(keyfile, group_name,
+ WIFI_CONFIG_IPV4_SUBNET_MASK, prefix_len);
}
+ if (conf->ip_info->prefix_length > 0)
+ g_key_file_set_integer(keyfile, group_name,
+ WIFI_CONFIG_IPV6_PREFIX_LEN, conf->ip_info->prefix_length);
+
if (conf->ip_info->gateway_address != NULL)
g_key_file_set_string(keyfile, group_name,
WIFI_CONFIG_IPV4_GATEWAY_ADDRESS, conf->ip_info->gateway_address);
conf = g_new0(struct wifi_config, 1);
conf->eap_config = g_new0(struct wifi_eap_config, 1);
+ conf->ip_info = g_new0(wifi_ip_info_s, 1);
ret = _load_configuration(config_id, conf);
if (ret != TRUE) {
g_free(conf->eap_config);
+ g_free(conf->ip_info);
g_free(conf);
ERR("Fail to _load_configuration");
netconfig_error_no_profile(context);
g_return_val_if_fail(config_id != NULL, TRUE);
g_return_val_if_fail(key != NULL, TRUE);
- DBG("Key[%s] Value[%d]", key, value);
+ DBG("Key[%s] Value[%s]", key, value);
if (g_strcmp0(key, WIFI_CONFIG_PROXYADDRESS) == 0) {
ret = _set_field(config_id, WIFI_CONFIG_PROXY_METHOD, "manual");