Merge "Add APIs to support DHCP state changes" into tizen
[platform/core/api/connection.git] / test / connection_test.c
index dc3d86b..29c962b 100755 (executable)
@@ -290,6 +290,13 @@ static void test_internet_state_changed_callback(connection_internet_state_e sta
        printf("Internet state changed callback, state : %d\n", state);
 }
 
+static void test_dhcp_state_changed_callback(connection_dhcp_state_e state,
+               const char *interface_name, connection_error_e result, void *user_data)
+{
+       printf("DHCP state changed callback, ifname: %s, state: %d, result: %d\n",
+                       interface_name, state, result);
+}
+
 static void test_profile_state_callback(connection_profile_state_e state, void* user_data)
 {
        char *profile_name;
@@ -1098,6 +1105,7 @@ int test_register_client(void)
                connection_set_ethernet_cable_state_changed_cb(connection,
                                        test_get_ethernet_cable_state_callback, NULL);
                connection_set_internet_state_changed_cb(connection, test_internet_state_changed_callback, NULL);
+               connection_set_dhcp_state_changed_cb(connection, test_dhcp_state_changed_callback, NULL);
        } else {
                printf("Client registration failed [%s]\n", test_print_error(err));
                return -1;
@@ -2271,6 +2279,29 @@ int test_get_ethernet_cable_state(void)
        return 1;
 }
 
+int test_get_dhcp_state(void)
+{
+       int rv = 0;
+       connection_dhcp_state_e dhcp_state;
+       char if_name[40] = {0};
+
+       if (test_get_user_string("Input Interface name: ", if_name, 40) == false)
+               return -1;
+
+       g_strstrip(if_name);
+
+       rv = connection_get_dhcp_state(connection, if_name, &dhcp_state);
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Fail to get DHCP state [%s]\n", test_print_error(rv));
+               return -1;
+       }
+
+       printf("Retval = [%s], DHCP state [%d]\n", test_print_error(rv), dhcp_state);
+
+       return 1;
+}
+
 int test_reset_profile(void)
 {
        int type, sim_id, rv;
@@ -3118,6 +3149,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("v   - Get all cellular default profiles\n");
                printf("w   - Get mac address\n");
                printf("x   - Get ethernet cable state\n");
+               printf("y   - Get DHCP state\n");
                printf("B   - Add IPv6 new route\n");
                printf("C   - Remove IPv6 route\n");
                printf("D   - Add new route entry\n");
@@ -3248,6 +3280,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'x':
                rv = test_get_ethernet_cable_state();
                break;
+       case 'y':
+               rv = test_get_dhcp_state();
+               break;
        case 'B':
                rv = test_add_route_ipv6();
                break;