Updated Test Application for new APIs 37/83837/1
authorSumit Aggarwal <aggarwal.s@samsung.com>
Fri, 12 Aug 2016 10:18:30 +0000 (15:48 +0530)
committerSumit Aggarwal <aggarwal.s@samsung.com>
Fri, 12 Aug 2016 10:19:06 +0000 (15:49 +0530)
a./ wifi_ap_set_prefix_length()
b./ wifi_ap_get_prefix_length()
c./ wifi_ap_set_dns_config_type()
d./ wifi_ap_get_dns_config_type()

Change-Id: I4ffd558bf40188ce2cfa704844d59b7dad1bd737
Signed-off-by: Sumit Aggarwal <aggarwal.s@samsung.com>
test/wifi_test.c

index 5cb3b986475b71223f116080ac8e2fa3cff8bb93..2032107fba65b33ea81040e4f098b8b41bf8538e 100755 (executable)
@@ -517,6 +517,8 @@ static bool __test_found_change_ip_method_callback(wifi_ap_h ap, void *user_data
                wifi_ip_config_type_e type;
                int method;
                int address_type;
+               int dns_input;
+               char ip_addr[40];
 
                printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
                rv = scanf("%9d", &method);
@@ -557,7 +559,11 @@ static bool __test_found_change_ip_method_callback(wifi_ap_h ap, void *user_data
                        char ip_addr[16];
 
                        printf("Input new ip address (x:skip, 0:clear) :\n");
-                       rv = scanf("%15s", ip_addr);
+                       if(address_type == WIFI_ADDRESS_FAMILY_IPV4)
+                               rv = scanf("%15s", ip_addr);
+                       else
+                               rv = scanf("%39s", ip_addr);
+
                        if (rv > 0) {
                                switch (ip_addr[0]) {
                                case 'x':
@@ -575,27 +581,42 @@ static bool __test_found_change_ip_method_callback(wifi_ap_h ap, void *user_data
                                                        __test_convert_error_to_string(rv));
                        }
 
-                       printf("Input new subnet mask (x:skip, 0:clear) :\n");
-                       rv = scanf("%15s", ip_addr);
-                       if (rv > 0) {
-                               switch (ip_addr[0]) {
-                               case 'x':
-                                       rv = WIFI_ERROR_NONE;
-                                       break;
-                               case '0':
-                                       rv = wifi_ap_set_subnet_mask(ap, address_type, NULL);
-                                       break;
-                               default:
-                                       rv = wifi_ap_set_subnet_mask(ap, address_type, ip_addr);
+                       if(address_type == WIFI_ADDRESS_FAMILY_IPV4) {
+                               printf("Input new subnet mask (x:skip, 0:clear) :\n");
+                               rv = scanf("%15s", ip_addr);
+                               if (rv > 0) {
+                                       switch (ip_addr[0]) {
+                                       case 'x':
+                                               rv = WIFI_ERROR_NONE;
+                                               break;
+                                       case '0':
+                                               rv = wifi_ap_set_subnet_mask(ap,
+                                                       address_type, NULL);
+                                               break;
+                                       default:
+                                               rv = wifi_ap_set_subnet_mask(ap,
+                                                       address_type, ip_addr);
+                                       }
+
+                                       if (rv != WIFI_ERROR_NONE)
+                                               printf("Fail to set subnet mask[%s]\n",
+                                       __test_convert_error_to_string(rv));
                                }
-
+                       } else {
+                               unsigned char prefix = 0;
+                               printf("Input Prefix Length - (Enter for skip) :\n");
+                               scanf("%u", (unsigned int *)&prefix);
+                               rv = wifi_ap_set_prefix_length(ap, prefix);
                                if (rv != WIFI_ERROR_NONE)
-                                       printf("Fail to set subnet mask[%s]\n",
-                                                       __test_convert_error_to_string(rv));
+                                       return -1;
                        }
 
-                       printf("Input new gateway address (x:skip, 0:clear) :\n");
-                       rv = scanf("%15s", ip_addr);
+                       printf("Input new gateway address(x:skip, 0:clear):\n");
+                       if (address_type == WIFI_ADDRESS_FAMILY_IPV4)
+                               rv = scanf("%15s", ip_addr);
+                       else
+                               rv = scanf("%39s", ip_addr);
+
                        if (rv > 0) {
                                switch (ip_addr[0]) {
                                case 'x':
@@ -614,6 +635,71 @@ static bool __test_found_change_ip_method_callback(wifi_ap_h ap, void *user_data
                        }
                }
 
+               if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
+                                     " - (Enter for skip) :",&dns_input)) {
+                       switch (dns_input) {
+                       case 1:
+                               rv = wifi_ap_set_dns_config_type(ap,
+                                               address_type,
+                                               WIFI_DNS_CONFIG_TYPE_STATIC);
+                               if (rv != WIFI_ERROR_NONE)
+                                       return -1;
+                               /*   Set DNS Type */
+                               printf("Input DNS1 address (x:skip, 0:clear) :\n");
+                               if (address_type == WIFI_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_ERROR_NONE;
+                                               break;
+                                       case '0':
+                                               rv = wifi_ap_set_dns_address(ap,
+                                                       1, address_type, NULL);
+                                               break;
+                                       default:
+                                               rv = wifi_ap_set_dns_address(ap,
+                                               1, address_type, ip_addr);
+                                       }
+
+                                       if (rv != WIFI_ERROR_NONE)
+                                               return -1;
+
+                                       printf("Input DNS2 address (x:skip, 0:clear) :\n");
+                                       if (address_type ==
+                                           WIFI_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_ERROR_NONE;
+                                                       break;
+                                               case '0':
+                                                       rv = wifi_ap_set_dns_address
+                                                       (ap, 2, address_type, NULL);
+                                                       break;
+                                               default:
+                                                       rv = wifi_ap_set_dns_address(
+                                                       ap, 2, address_type, ip_addr);
+                                               }
+                                               if (rv != WIFI_ERROR_NONE)
+                                                       return -1;
+                                       }
+                               }
+                               break;
+                       case 2:
+                               rv = wifi_ap_set_dns_config_type(ap,
+                                               address_type,
+                                               WIFI_DNS_CONFIG_TYPE_DYNAMIC);
+                               if (rv != WIFI_ERROR_NONE)
+                                       return -1;
+                               break;
+                       }
+               }
                g_free(ap_name);
                return false;
        }
@@ -709,7 +795,8 @@ static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
        char *str_value;
        int int_value;
        wifi_connection_state_e conn_state;
-       wifi_ip_config_type_e ip_type;
+
+       wifi_dns_config_type_e dns_type;
        wifi_proxy_type_e proxy_type;
        wifi_security_type_e sec_type;
        wifi_encryption_type_e enc_type;
@@ -717,6 +804,10 @@ static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
        wifi_eap_auth_type_e eap_auth_type;
        bool bool_value;
        char *ap_name_part = (char*)user_data;
+#if defined TIZEN_TV
+       wifi_ip_config_type_e ip_type;
+       unsigned char prefix = 0;
+#endif
 
        rv = wifi_ap_get_essid(ap, &ap_name);
        if (rv != WIFI_ERROR_NONE) {
@@ -780,17 +871,40 @@ static bool __test_found_print_ap_info_callback(wifi_ap_h ap, void *user_data)
                } else
                        printf("Fail to get IP\n");
 
-               if (wifi_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
-                       printf("Subnet mask : %s\n", str_value);
-                       g_free(str_value);
-               } else
-                       printf("Fail to get Subnet mask\n");
+               if (address_type == WIFI_ADDRESS_FAMILY_IPV4) {
+                       if (wifi_ap_get_subnet_mask(ap, address_type, &str_value)
+                           == WIFI_ERROR_NONE) {
+                               printf("Subnet mask : %s\n", str_value);
+                               g_free(str_value);
+                       } else
+                               printf("Fail to get Subnet mask\n");
+               }
+#if defined TIZEN_TV
+               else {
+                       if (wifi_ap_get_prefix_length(ap, &prefix) ==
+                           WIFI_ERROR_NONE) {
+                               printf("Prefix Length : %u\n", prefix);
+                       } else
+                               printf("Fail to get Prefix Length\n");
+               }
+#endif
 
                if (wifi_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_ERROR_NONE) {
                        printf("Gateway : %s\n", str_value);
                        g_free(str_value);
                } else
                        printf("Fail to get Gateway\n");
+#if defined TIZEN_TV
+               if (wifi_ap_get_dns_config_type(ap, address_type, &dns_type) == WIFI_ERROR_NONE) {
+                       if(dns_type == WIFI_DNS_CONFIG_TYPE_STATIC)
+                               printf("1 DNS config type : %s\n", "WIFI_DNS_CONFIG_TYPE_STATIC");
+                       else if(dns_type == WIFI_DNS_CONFIG_TYPE_DYNAMIC)
+                               printf("2 DNS config type : %s\n", "WIFI_DNS_CONFIG_TYPE_DYNAMIC");
+                       else
+                               printf("3 DNS config type : %d\n", dns_type);
+               } else
+                       printf("Fail to get DNS config type!\n");
+#endif
 
                if (wifi_ap_get_proxy_type(ap, &proxy_type) == WIFI_ERROR_NONE)
                        printf("Proxy type : %d\n", proxy_type);