From: Seonah Moon Date: Mon, 20 Mar 2017 02:03:07 +0000 (+0900) Subject: Implement APIs for IPv6 and DNS configuration X-Git-Tag: accepted/tizen/common/20170322.153706~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F119689%2F3;p=platform%2Fcore%2Fapi%2Fwifi-manager.git Implement APIs for IPv6 and DNS configuration Change-Id: I78af5eceed53ca053f6013df6a0342cf98722003 Signed-off-by: Seonah Moon --- diff --git a/include/network_config.h b/include/network_config.h index a0a08e1..ca8cce0 100755 --- a/include/network_config.h +++ b/include/network_config.h @@ -69,6 +69,12 @@ typedef enum { NET_IP_CONFIG_TYPE_OFF, /** Don't use any method */ } net_ip_config_type_e; +typedef enum { + NET_DNS_CONFIG_TYPE_UNKNOWN = 0x00, /** Not defined */ + NET_DNS_CONFIG_TYPE_STATIC = 0x01, /** Manual DNS configuration */ + NET_DNS_CONFIG_TYPE_DYNAMIC, /** Config DNS using DHCP client */ +} net_dns_config_type_e; + typedef union { struct in_addr Ipv4; /** IP Version 4 address */ struct in6_addr Ipv6; /** IP Version 6 address */ @@ -86,11 +92,14 @@ typedef struct { typedef struct { char ProfileName[NET_PROFILE_NAME_LEN_MAX+1]; /** Profile Name of the connection link */ char DevName[NET_MAX_DEVICE_NAME_LEN+1]; /** Device Name of the connection link */ + net_dns_config_type_e DnsConfigType; /** IPv4 Dns configuration type */ + net_dns_config_type_e DnsConfigType6; /** IPv6 Dns configuration type */ net_addr_s DnsAddr[NET_DNS_ADDR_MAX]; /** IPv4 Dns Server Address of the connection link */ net_addr_s DnsAddr6[NET_DNS_ADDR_MAX]; /** IPv6 Dns Server Address of the connection link */ int DnsCount; /** No of IPv4 DNS Address for the connection link */ int DnsCount6; /** No of IPv6 DNS Address for the connection link */ - net_ip_config_type_e IpConfigType; /** Net IP configuration Type */ + net_ip_config_type_e IpConfigType; /** Net IPv4 configuration Type */ + net_ip_config_type_e IpConfigType6; /** Net IPv6 configuration Type */ net_addr_s IpAddr; /** IP Address for the connection link */ char BNetmask; /** Whether subnet mask present or not. */ net_addr_s SubnetMask; /** Subnet mask */ @@ -99,7 +108,6 @@ typedef struct { net_proxy_type_e ProxyMethod; /** Proxy Method type */ char ProxyAddr[NET_PROXY_LEN_MAX+1]; /** Proxy address */ char MacAddr[NET_MAX_MAC_ADDR_LEN+1]; /** MAC address */ - net_ip_config_type_e IpConfigType6; /** Net IP configuration Type */ net_addr_s IpAddr6; /** IP Address for the connection link */ int PrefixLen6; /** Prefix Length for the connection link */ char BDefGateway6; /** Whether gateway address present or not */ diff --git a/include/wifi-manager.h b/include/wifi-manager.h index 4a70919..cd961b6 100755 --- a/include/wifi-manager.h +++ b/include/wifi-manager.h @@ -244,8 +244,7 @@ typedef enum { * @brief Enumeration for DNS Configuration type. * @since_tizen 4.0 */ -typedef enum -{ +typedef enum { WIFI_MANAGER_DNS_CONFIG_TYPE_NONE = 0, /**< Not defined */ WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC = 1, /**< Manual DNS configuration */ WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC = 2, /**< Config DNS using DHCP client*/ @@ -1241,8 +1240,8 @@ int wifi_manager_connect_by_wps_pbc_without_ssid(wifi_manager_h wifi, * @see wifi_manager_disconnect() * @see wifi_manager_ap_is_wps_supported() */ - int wifi_manager_connect_by_wps_pin_without_ssid(wifi_manager_h wifi, - const char *pin, wifi_manager_connected_cb callback, void *user_data); +int wifi_manager_connect_by_wps_pin_without_ssid(wifi_manager_h wifi, + const char *pin, wifi_manager_connected_cb callback, void *user_data); /** * @brief Stops ongoing WPS provisioning / disconnects from the connected access point. diff --git a/packaging/capi-network-wifi-manager.spec b/packaging/capi-network-wifi-manager.spec index 7de095e..82f3952 100755 --- a/packaging/capi-network-wifi-manager.spec +++ b/packaging/capi-network-wifi-manager.spec @@ -1,6 +1,6 @@ Name: capi-network-wifi-manager Summary: Network Wi-Fi library in TIZEN C API -Version: 1.0.12 +Version: 1.0.13 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/network_dbus.c b/src/network_dbus.c index b76fbe2..d7f390d 100755 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -1447,11 +1447,20 @@ int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name) __NETWORK_FUNC_ENTER__; const char *prop_nameserver_configuration = "Nameservers.Configuration"; + + const char *manual_method = "ipv4.manual"; + const char *dhcp_method = "ipv4.dhcp"; + const char *ipv6_manual_method = "ipv6.manual"; + const char *ipv6_dhcp_method = "ipv6.dhcp"; + char dns_buffer[NET_DNS_ADDR_MAX][NET_IPV4_STR_LEN_MAX+1]; char *dns_address[NET_DNS_ADDR_MAX]; + char ipv6_dns_buffer[NET_DNS_ADDR_MAX][NET_IPV6_STR_LEN_MAX + 1]; + char *ipv6_dns_address[NET_DNS_ADDR_MAX]; + net_err_e Error = NET_ERR_NONE; GVariant *params = NULL; - GVariantBuilder *builder; + GVariantBuilder *builder = NULL; int i = 0; net_dev_info_s *profile_net_info = NULL; GVariant *message = NULL; @@ -1465,9 +1474,9 @@ int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name) profile_net_info = &(prof_info->net_info); if (profile_net_info->DnsCount > NET_DNS_ADDR_MAX) { - WIFI_LOG(WIFI_ERROR, "Invalid parameter\n"); - __NETWORK_FUNC_EXIT__; - return NET_ERR_INVALID_PARAM; + WIFI_LOG(WIFI_ERROR, "Invalid parameter\n"); + __NETWORK_FUNC_EXIT__; + return NET_ERR_INVALID_PARAM; } for (i = 0; i < profile_net_info->DnsCount; i++) { @@ -1479,31 +1488,89 @@ int _net_dbus_set_profile_dns(net_profile_info_s* prof_info, char* profile_name) inet_ntoa(profile_net_info->DnsAddr[i].Data.Ipv4), NET_IPV4_STR_LEN_MAX + 1); - dns_address[i] = dns_buffer[i]; + if (profile_net_info->DnsConfigType == NET_DNS_CONFIG_TYPE_STATIC) + dns_address[i] = dns_buffer[i]; } - if (profile_net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) { + for (i = 0; i < profile_net_info->DnsCount6; i++) { + ipv6_dns_buffer[i][0] = '\0'; + ipv6_dns_address[i] = NULL; + if (profile_net_info->DnsAddr6[i].Type == NET_ADDR_IPV6) { + inet_ntop(AF_INET6, + &profile_net_info->DnsAddr6[i].Data.Ipv6, + ipv6_dns_buffer[i], INET6_ADDRSTRLEN); + } + + if (profile_net_info->DnsConfigType6 == NET_DNS_CONFIG_TYPE_STATIC) + ipv6_dns_address[i] = ipv6_dns_buffer[i]; + } + + if (profile_net_info->DnsConfigType == NET_DNS_CONFIG_TYPE_STATIC || + profile_net_info->DnsConfigType == NET_DNS_CONFIG_TYPE_DYNAMIC || + profile_net_info->DnsConfigType6 == NET_DNS_CONFIG_TYPE_STATIC || + profile_net_info->DnsConfigType6 == NET_DNS_CONFIG_TYPE_DYNAMIC) { builder = g_variant_builder_new(G_VARIANT_TYPE("as")); - for (i = 0; i < profile_net_info->DnsCount; i++) - g_variant_builder_add(builder, "s", dns_address[i]); - - params = g_variant_new("(sv)", prop_nameserver_configuration, g_variant_builder_end(builder)); - g_variant_builder_unref(builder); - - message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name, - CONNMAN_SERVICE_INTERFACE, "SetProperty", params, - &Error); - if (message == NULL) { - WIFI_LOG(WIFI_ERROR, "Failed to set " - "Nameservers.Configuration"); - __NETWORK_FUNC_EXIT__; - return Error; + + WIFI_LOG(WIFI_INFO, "IPv4 DnsConfigType: %d\n", profile_net_info->DnsConfigType); + if (profile_net_info->DnsConfigType == + NET_DNS_CONFIG_TYPE_STATIC || + profile_net_info->DnsConfigType6 == + NET_DNS_CONFIG_TYPE_STATIC) + g_variant_builder_add(builder, "s", + manual_method); + else + g_variant_builder_add(builder, "s", + dhcp_method); + + WIFI_LOG(WIFI_INFO, "IPv6 DnsConfigType: %d\n", profile_net_info->DnsConfigType6); + if (profile_net_info->DnsConfigType6 == + NET_DNS_CONFIG_TYPE_STATIC) + g_variant_builder_add(builder, "s", + ipv6_manual_method); + else if (profile_net_info->DnsConfigType6 == + NET_DNS_CONFIG_TYPE_DYNAMIC) + g_variant_builder_add(builder, "s", + ipv6_dhcp_method); + + for (i = 0; i < profile_net_info->DnsCount; i++) { + if (profile_net_info->DnsConfigType == + NET_DNS_CONFIG_TYPE_STATIC) { + if (dns_address[i] == NULL) + g_strlcpy(dns_address[i], "0.0.0.0", + NET_IPV4_STR_LEN_MIN + 1); + g_variant_builder_add(builder, "s", + dns_address[i]); + } + WIFI_LOG(WIFI_INFO, "IPv4 DNS Address added in g_variant: %s\n", dns_address[i]); + } + + for (i = 0; i < profile_net_info->DnsCount6; i++) { + if (profile_net_info->DnsConfigType6 == + NET_DNS_CONFIG_TYPE_STATIC) { + if (ipv6_dns_address[i] == NULL) + g_strlcpy(ipv6_dns_address[i], "::", + NET_IPV6_STR_LEN_MIN + 1); + g_variant_builder_add(builder, "s", + ipv6_dns_address[i]); + } + WIFI_LOG(WIFI_INFO, "IPv6 DNS Address added in g_variant: %s\n", ipv6_dns_address[i]); } - WIFI_LOG(WIFI_INFO, "Successfully configured Nameservers.Configuration\n"); - g_variant_unref(message); } + params = g_variant_new("(sv)", prop_nameserver_configuration, g_variant_builder_end(builder)); + g_variant_builder_unref(builder); + + message = _net_invoke_dbus_method(CONNMAN_SERVICE, profile_name, + CONNMAN_SERVICE_INTERFACE, "SetProperty", params, + &Error); + if (message == NULL) { + __NETWORK_FUNC_EXIT__; + return Error; + } + WIFI_LOG(WIFI_INFO, "Successfully configured Nameservers.Configuration\n"); + g_variant_unref(message); + __NETWORK_FUNC_EXIT__; return Error; } diff --git a/src/network_interface.c b/src/network_interface.c index 424ed7a..32c2680 100755 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -158,6 +158,18 @@ static int __net_extract_ip(const gchar *value, net_addr_s *ipAddr) return NET_ERR_NONE; } +static gboolean __net_check_address_type(int address_family, const char *address) +{ + unsigned char buf[sizeof(struct in6_addr)] = {0, }; + int err = 0; + + err = inet_pton(address_family, address, buf); + if (err > 0) + return TRUE; + + return FALSE; +} + static int __net_extract_common_info(const char *key, GVariant *variant, net_profile_info_s* ProfInfo) { __NETWORK_FUNC_ENTER__; @@ -369,44 +381,98 @@ static int __net_extract_common_info(const char *key, GVariant *variant, net_pro g_variant_iter_free(iter); } else if (g_strcmp0(key, "Nameservers") == 0) { int dnsCount = 0; + int dnsCount6 = 0; + gchar *dns_value = NULL; + gchar *dns_type = NULL; g_variant_get(variant, "as", &iter); - while (g_variant_iter_loop(iter, "s", &value)) { - if (g_strcmp0(value, "dhcp") == 0 || g_strcmp0(value, "manual") == 0) - continue; - __net_extract_ip(value, &net_info->DnsAddr[dnsCount]); - - dnsCount++; - if (dnsCount >= NET_DNS_ADDR_MAX) { - if (NULL != value) - g_free((gchar*)value); - break; + + while (g_variant_iter_loop(iter, "s", &dns_value)) { + if (__net_check_address_type(AF_INET6, dns_value)) { + if (dnsCount6 < NET_DNS_ADDR_MAX) { + net_info->DnsAddr6[dnsCount6].Type = + NET_ADDR_IPV6; + inet_pton(AF_INET6, dns_value, + &net_info->DnsAddr6[dnsCount6]\ + .Data.Ipv6); + dnsCount6++; + } + } else if (__net_check_address_type(AF_INET, dns_value)) { + if (dnsCount < NET_DNS_ADDR_MAX) { + net_info->DnsAddr[dnsCount].Type = + NET_ADDR_IPV4; + __net_extract_ip(dns_value, + &net_info->DnsAddr[dnsCount]); + dnsCount++; + } + } else { /* DNS Type */ + dns_type = g_strdup(dns_value); + if (g_strcmp0(dns_type, "ipv4.manual") == 0) + net_info->DnsConfigType = + NET_DNS_CONFIG_TYPE_STATIC; + else if (g_strcmp0(dns_type, "ipv4.dhcp") == 0) + net_info->DnsConfigType = + NET_DNS_CONFIG_TYPE_DYNAMIC; + if (g_strcmp0(dns_type, "ipv6.manual") == 0) + net_info->DnsConfigType6 = + NET_DNS_CONFIG_TYPE_STATIC; + else if (g_strcmp0(dns_type, "ipv6.dhcp") == 0) + net_info->DnsConfigType6 = + NET_DNS_CONFIG_TYPE_DYNAMIC; } } - + g_free(dns_type); g_variant_iter_free(iter); net_info->DnsCount = dnsCount; + net_info->DnsCount6 = dnsCount6; } else if (g_strcmp0(key, "Nameservers.Configuration") == 0 && net_info->DnsCount == 0) { int dnsCount = 0; + int dnsCount6 = 0; + gchar *dns_value = NULL; + gchar *dns_type = NULL; g_variant_get(variant, "as", &iter); - while (g_variant_iter_loop(iter, "s", &value)) { - if (g_strcmp0(value, "dhcp") == 0 || g_strcmp0(value, "manual") == 0 - || g_strcmp0(value, "unknown") == 0) - continue; - __net_extract_ip(value, &net_info->DnsAddr[dnsCount]); - - dnsCount++; - if (dnsCount >= NET_DNS_ADDR_MAX) { - if (NULL != value) - g_free((gchar*)value); - break; + + while (g_variant_iter_loop(iter, "s", &dns_value)) { + if (__net_check_address_type(AF_INET6, dns_value)) { + if (dnsCount6 < NET_DNS_ADDR_MAX) { + net_info->DnsAddr6[dnsCount6].Type = + NET_ADDR_IPV6; + inet_pton(AF_INET6, dns_value, + &net_info->DnsAddr6[dnsCount6]\ + .Data.Ipv6); + dnsCount6++; + } + } else if (__net_check_address_type(AF_INET, dns_value)) { + if (dnsCount < NET_DNS_ADDR_MAX) { + net_info->DnsAddr[dnsCount].Type = + NET_ADDR_IPV4; + __net_extract_ip(dns_value, + &net_info->DnsAddr[dnsCount]); + dnsCount++; + } + } else { /* DNS Type */ + dns_type = g_strdup(dns_value); + if (g_strcmp0(dns_type, "ipv4.manual") == 0) + net_info->DnsConfigType = + NET_DNS_CONFIG_TYPE_STATIC; + else if (g_strcmp0(dns_type, "ipv4.dhcp") == 0) + net_info->DnsConfigType = + NET_DNS_CONFIG_TYPE_DYNAMIC; + if (g_strcmp0(dns_type, "ipv6.manual") == 0) + net_info->DnsConfigType6 = + NET_DNS_CONFIG_TYPE_STATIC; + else if (g_strcmp0(dns_type, "ipv6.dhcp") == 0) + net_info->DnsConfigType6 = + NET_DNS_CONFIG_TYPE_DYNAMIC; } } + g_free(dns_type); g_variant_iter_free(iter); net_info->DnsCount = dnsCount; + net_info->DnsCount6 = dnsCount6; } else if (g_strcmp0(key, "Domains") == 0) { } else if (g_strcmp0(key, "Domains.Configuration") == 0) { } else if (g_strcmp0(key, "Proxy") == 0) { @@ -634,7 +700,9 @@ static int __net_wifi_modify_profile(const char* ProfileName, break; } - if (i < net_info->DnsCount) { + if (i < net_info->DnsCount || + ex_net_info->DnsConfigType != net_info->DnsConfigType || + ex_net_info->DnsConfigType6 != net_info->DnsConfigType6) { Error = _net_dbus_set_profile_dns(ProfInfo, profilePath); if (Error != NET_ERR_NONE) { @@ -883,7 +951,6 @@ static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* Prof } else if (g_strcmp0(key, "Keymgmt") == 0) { ProfInfo->security_info.keymgmt = (unsigned int)g_variant_get_uint32(var); - } else Error = __net_extract_common_info(key, var, ProfInfo); } diff --git a/src/wifi_ap.c b/src/wifi_ap.c index 305dfc8..00e23d5 100755 --- a/src/wifi_ap.c +++ b/src/wifi_ap.c @@ -727,6 +727,45 @@ EXPORT_API int wifi_manager_ap_set_subnet_mask(wifi_manager_ap_h ap, return WIFI_MANAGER_ERROR_NONE; } +EXPORT_API int wifi_manager_ap_get_prefix_length(wifi_manager_ap_h ap, + wifi_manager_address_family_e address_family, int *prefix_len) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_check_ap_validity(ap) == false || + (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 && + address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) || + prefix_len == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + net_profile_info_s *profile_info = ap; + + *prefix_len = profile_info->net_info.PrefixLen6; + + return WIFI_MANAGER_ERROR_NONE; +} + +EXPORT_API int wifi_manager_ap_set_prefix_length(wifi_manager_ap_h ap, + wifi_manager_address_family_e address_family, int prefix_len) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_check_ap_validity(ap) == false || + (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 + } + + net_profile_info_s *profile_info = ap; + + profile_info->net_info.PrefixLen6 = prefix_len; + + return WIFI_MANAGER_ERROR_NONE; +} + EXPORT_API int wifi_manager_ap_get_gateway_address(wifi_manager_ap_h ap, wifi_manager_address_family_e address_family, char **gateway_address) { @@ -906,6 +945,78 @@ EXPORT_API int wifi_manager_ap_set_proxy_type(wifi_manager_ap_h ap, return WIFI_MANAGER_ERROR_NONE; } +EXPORT_API int wifi_manager_ap_get_dns_config_type(wifi_manager_ap_h ap, + wifi_manager_address_family_e address_family, wifi_manager_dns_config_type_e *type) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_check_ap_validity(ap) == false || + (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 + } + + net_profile_info_s *profile_info = ap; + net_dns_config_type_e dns_type; + + if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) + dns_type = profile_info->net_info.DnsConfigType; + else + dns_type = profile_info->net_info.DnsConfigType6; + + switch (dns_type) { + case NET_DNS_CONFIG_TYPE_STATIC: + *type = WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC; + break; + case NET_DNS_CONFIG_TYPE_DYNAMIC: + *type = WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC; + break; + default: + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + return WIFI_MANAGER_ERROR_NONE; +} + +EXPORT_API int wifi_manager_ap_set_dns_config_type(wifi_manager_ap_h ap, + wifi_manager_address_family_e address_family, wifi_manager_dns_config_type_e type) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_check_ap_validity(ap) == false || + (address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV4 && + address_family != WIFI_MANAGER_ADDRESS_FAMILY_IPV6) || + (type != WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC && + type != WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC)) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + net_profile_info_s *profile_info = ap; + net_dns_config_type_e *dns_type; + + if (address_family == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) { + dns_type = &profile_info->net_info.DnsConfigType; + + profile_info->net_info.DnsAddr[0].Data.Ipv4.s_addr = 0; + profile_info->net_info.DnsAddr[1].Data.Ipv4.s_addr = 0; + + *dns_type = type; + } else { + dns_type = &profile_info->net_info.DnsConfigType6; + + inet_pton(AF_INET6, "::", + &profile_info->net_info.DnsAddr6[0].Data.Ipv6); + inet_pton(AF_INET6, "::", + &profile_info->net_info.DnsAddr6[1].Data.Ipv6); + + *dns_type = type; + } + + return WIFI_MANAGER_ERROR_NONE; +} + EXPORT_API int wifi_manager_ap_get_dns_address(wifi_manager_ap_h ap, int order, wifi_manager_address_family_e address_family, char **dns_address) { diff --git a/test/wifi_manager_test.c b/test/wifi_manager_test.c index f7a9867..660ab0f 100755 --- a/test/wifi_manager_test.c +++ b/test/wifi_manager_test.c @@ -553,6 +553,8 @@ static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *u wifi_manager_ip_config_type_e type; int method; int address_type; + int dns_type; + int prefix_len; printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n"); rv = scanf("%9d", &method); @@ -590,7 +592,7 @@ static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *u printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv)); if (type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) { - char ip_addr[16]; + char ip_addr[40]; printf("Input new ip address (x:skip, 0:clear) :\n"); rv = scanf("%15s", ip_addr); @@ -630,6 +632,19 @@ static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *u __test_convert_error_to_string(rv)); } + 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_ap_set_prefix_length(ap, address_type, prefix_len); + + if (rv != WIFI_MANAGER_ERROR_NONE) + printf("Fail to set subnet mask[%s]\n", + __test_convert_error_to_string(rv)); + } + printf("Input new gateway address (x:skip, 0:clear) :\n"); rv = scanf("%15s", ip_addr); if (rv > 0) { @@ -648,6 +663,72 @@ static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *u printf("Fail to set gateway address[%s]\n", __test_convert_error_to_string(rv)); } + + rv = test_get_user_int("Input DNS config type (0:STATIC, 1:DYNAMIC)" + "- (Enter for skip) : ", &dns_type); + if (rv == false) { + printf("Invalid input!!\n"); + return false; + } + switch (dns_type) { + case 0: + rv = wifi_manager_ap_set_dns_config_type(ap, + address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC); + if (rv == WIFI_MANAGER_ERROR_NONE) { + printf("Input DNS1 address (x: skip, 0: clear) : \n"); + if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) + rv = scanf("%15s", ip_addr); + else + 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_ap_set_dns_address(ap, + 1, address_type, NULL); + break; + default: + rv = wifi_manager_ap_set_dns_address(ap, + 1, address_type, ip_addr); + break; + } + } + if (rv != WIFI_MANAGER_ERROR_NONE) + return -1; + + printf("Input DNS2 address (x: skip, 0: clear) : \n"); + if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4) + rv = scanf("%15s", ip_addr); + else + 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_ap_set_dns_address(ap, + 2, address_type, NULL); + break; + default: + rv = wifi_manager_ap_set_dns_address(ap, + 2, address_type, ip_addr); + break; + } + } + if (rv != WIFI_MANAGER_ERROR_NONE) + return -1; + } + break; + case 1: + rv = wifi_manager_ap_set_dns_config_type(ap, + address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC); + if (rv != WIFI_MANAGER_ERROR_NONE) + return -1; + break; + } } rv = wifi_manager_update_ap(wifi, ap); @@ -756,6 +837,7 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user wifi_manager_encryption_type_e enc_type; wifi_manager_eap_type_e eap_type; wifi_manager_eap_auth_type_e eap_auth_type; + wifi_manager_dns_config_type_e dns_type; bool bool_value; char *ap_name_part = (char*)user_data; wifi_manager_disconnect_reason_e disconnect_reason; @@ -833,6 +915,11 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user } else printf("Fail to get Subnet mask\n"); + if (wifi_manager_ap_get_prefix_length(ap, address_type, &int_value) == WIFI_MANAGER_ERROR_NONE) + printf("Prefix length : %d\n", int_value); + else + printf("Fail to get Subnet mask\n"); + if (wifi_manager_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) { printf("Gateway : %s\n", str_value); g_free(str_value); @@ -850,6 +937,16 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user } else printf("Fail to get Proxy\n"); + if (wifi_manager_ap_get_dns_config_type(ap, address_type, &dns_type) == WIFI_MANAGER_ERROR_NONE) { + if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC) + printf("DNS config type : STATIC\n"); + else if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC) + printf("DNS config type : DYNAMIC\n"); + else + printf("DNS config type : %d\n", dns_type); + } else + printf("Fail to get DNS config type\n"); + if (wifi_manager_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) { printf("DNS1 : %s\n", str_value); g_free(str_value);