#define WIFI_CONFIG_IPV6_METHOD "IPv6.method"
#define WIFI_CONFIG_IPV4_ADDRESS "IPv4.local_address"
#define WIFI_CONFIG_IPV4_SUBNET_MASK "IPv4.netmask_prefixlen"
+#define WIFI_CONFIG_IPV6_PREFIX_LEN "IPv6.netmask_prefixlen"
#define WIFI_CONFIG_IPV4_GATEWAY_ADDRESS "IPv4.gateway"
#define WIFI_CONFIG_IPV4_DNS_METHOD "Nameservers.IPv4method"
#define WIFI_CONFIG_DNS_ADDRESS "Nameservers"
int _wifi_forget_ap_async(wifi_manager_h wifi, wifi_manager_ap_h ap,
wifi_manager_forget_ap_finished_cb callback,
void* user_data);
+int __ap_convert_netmask_to_prefix_len(const char *netmask);
void _wifi_rssi_level_changed_cb(keynode_t *node, void *user_data);
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_SUBNET_MASK,
g_variant_new_string(ip_info->subnet_mask));
+ if (ip_info->prefix_length > 0)
+ g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV6_PREFIX_LEN,
+ g_variant_new_int32(ip_info->prefix_length));
+
if (ip_info->gateway_address)
g_variant_builder_add(b, "{sv}", WIFI_CONFIG_IPV4_GATEWAY_ADDRESS,
g_variant_new_string(ip_info->gateway_address));
} else if (g_strcmp0(field, WIFI_CONFIG_IPV4_SUBNET_MASK) == 0) {
const gchar *subnet_mask = g_variant_get_string(value, NULL);
(*ip_info)->subnet_mask = g_strdup(subnet_mask);
+ } else if (g_strcmp0(field, WIFI_CONFIG_IPV6_PREFIX_LEN) == 0) {
+ int prefix_len = g_variant_get_int32(value);
+ (*ip_info)->prefix_length = prefix_len;
} else if (g_strcmp0(field, WIFI_CONFIG_IPV4_GATEWAY_ADDRESS) == 0) {
const gchar *gateway_address = g_variant_get_string(value, NULL);
(*ip_info)->gateway_address = g_strdup(gateway_address);
return buf;
}
-static int __ap_convert_netmask_to_prefix_len(const char *netmask)
+int __ap_convert_netmask_to_prefix_len(const char *netmask)
{
if (netmask == NULL)
return 0;
wifi_config_s *h = (wifi_config_s *)config;
if (_wifi_check_config_validity(config) == false || subnet_mask == NULL ||
- (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
- address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
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;
if (_wifi_check_config_validity(config) == false ||
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4) {
+ 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
+ }
+
+ h->ip_info->subnet_mask = g_strdup(subnet_mask);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_get_prefix_length(wifi_manager_config_h config,
+ wifi_manager_address_family_e address_family, int *prefix_len)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false || prefix_len == NULL ||
(address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 &&
address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6)) {
WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- h->ip_info->subnet_mask = g_strdup(subnet_mask);
+ if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+ *prefix_len = __ap_convert_netmask_to_prefix_len(h->ip_info->subnet_mask);
+ else
+ *prefix_len = h->ip_info->prefix_length;
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_config_set_prefix_length(wifi_manager_config_h config,
+ wifi_manager_address_family_e address_family, int prefix_len)
+{
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ wifi_config_s *h = (wifi_config_s *)config;
+
+ if (_wifi_check_config_validity(config) == false ||
+ address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+ 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
+ }
+
+ h->ip_info->prefix_length = prefix_len;
__NETWORK_CAPI_FUNC_EXIT__;
int hidden = 0;
int address_type = 0;
char ip_addr[40] = { 0, };
+ int prefix_len;
wifi_manager_config_h config;
int ip_update = 0;
}
}
- printf("Input new subnet mask (x:skip, 0:clear) :\n");
- rv = scanf("%39s", ip_addr);
- if (rv > 0) {
- switch (ip_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_config_set_subnet_mask(config, address_type,
- NULL);
- break;
- default:
- rv = wifi_manager_config_set_subnet_mask(config, address_type,
- ip_addr);
+ if (address_type == 0) {
+ printf("Input new subnet mask (x:skip, 0:clear) :\n");
+ rv = scanf("%39s", ip_addr);
+ if (rv > 0) {
+ switch (ip_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_config_set_subnet_mask(config, address_type,
+ NULL);
+ break;
+ default:
+ rv = wifi_manager_config_set_subnet_mask(config, address_type,
+ ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set subnet mask[%s]\n",
+ __test_convert_error_to_string(rv));
+ return -1;
+ }
}
+ } else {
+ printf("Input new prefix length (x:skip) :\n");
+ rv = scanf("%d", &prefix_len);
+ if (rv > 0) {
+ if (prefix_len == 'x')
+ rv = WIFI_MANAGER_ERROR_NONE;
+ else
+ rv = wifi_manager_config_set_prefix_length(config, address_type, prefix_len);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set subnet mask[%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set prefix length[%s]\n",
+ __test_convert_error_to_string(rv));
+ return -1;
+ }
}
}