+int test_add_route_entry(void)
+{
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+ int input;
+ bool input_rv;
+ int rv = 0;
+
+ input_rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
+
+ if (input_rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ switch (input) {
+ case 1:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+ break;
+
+ case 2:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+ break;
+
+ default:
+ printf("Wrong IP address family!!\n");
+ return -1;
+
+ }
+
+ return 1;
+
+}
+
+int test_remove_route_entry(void)
+{
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+ int input;
+ bool input_rv;
+ int rv = 0;
+
+ input_rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
+
+ if (input_rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ switch (input) {
+ case 1:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%s]\n", test_print_error(rv));
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+
+ break;
+
+ case 2:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%d]\n", rv);
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+ break;
+
+ default:
+ printf("Wrong IP address family!!\n");
+ return -1;
+
+ }
+
+ return 1;
+
+}
+