//& set: Inm
+/**
+* @function PrintUrlResult
+* @description Helper function
+* @parameter inm_reachable_urls_check_result_e err
+* @return char pointer
+*/
+static inline char * PrintUrlResult(inm_reachable_urls_check_result_e err)
+{
+ switch (err) {
+ case INM_REACHABLE_URL_CHECK_RESULT_SUCCESS:
+ return "SUCCESS\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_MALFORMED_URL:
+ return "MALFORMED_URL error\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_DNS_RESOLVE:
+ return "DNS_RESOLVE error\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_TCP_CONNECT:
+ return "TCP_CONNECT error\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_SSL:
+ return "SSL error\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_HTTP:
+ return "HTTP error\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_FILE_NOT_FOUND:
+ return "FILE_NOT_FOUND error\n";
+ case INM_REACHABLE_URL_CHECK_RESULT_ERROR_UNKNOWN:
+ return "UNKNOWN error\n";
+ }
+}
+
+/**
+* @function InmReachableUrlsCheckResultDefaultCallback
+* @description Callback
+* @parameter inm_reachable_urls_check_result_e result, const char *url, void *user_data
+* @return NA
+*/
+static void InmReachableUrlsCheckResultDefaultCallback(inm_reachable_urls_check_result_e result, const char *url, void *user_data)
+{
+ g_bDefaultUrlFound = (result == INM_REACHABLE_URL_CHECK_RESULT_SUCCESS);
+ FPRINTF("[Line : %d][%s] %s %s\\n", __LINE__, API_NAMESPACE, url, PrintUrlResult(result));
+ QUIT_GMAIN_LOOP;
+}
+
+/**
+* @function InmDefaultDnsLookupResultCallback
+* @description Callback
+* @parameter bool found, void *user_data
+* @return NA
+*/
+static void InmDefaultDnsLookupResultCallback(bool found, void *user_data)
+{
+ g_bDnsLookupFinished = found;
+ FPRINTF("[Line : %d][%s] DNS lookup accomplished\\n", __LINE__, API_NAMESPACE);
+ QUIT_GMAIN_LOOP;
+}
+
+/**
+* @function InmDefaultGatewayFoundCallback
+* @description Callback
+* @parameter bool found, const char *ip, void *user_data
+* @return NA
+*/
+static void InmDefaultGatewayFoundCallback(bool found, const char *ip, void *user_data)
+{
+ g_bGatewayFound = found;
+ FPRINTF("[Line : %d][%s] Gateway %s found\\n", __LINE__, API_NAMESPACE, ip);
+ QUIT_GMAIN_LOOP;
+}
+
+/**
+* @function InmArpRequestIpFoundCallback
+* @description Callback
+* @parameter bool found, const char *ip, void *user_data
+* @return NA
+*/
+static void InmArpRequestIpFoundCallback(bool found, const char *ip, void *user_data)
+{
+ FPRINTF("[Line : %d][%s] Callback invoked\\n", __LINE__, API_NAMESPACE);
+ if (g_strcmp0(ip, g_pszArpRequestedIpStr) == 0) {
+ g_bArpRequestedIpFound = found;
+ FPRINTF("[Line : %d][%s] ARP requested %s found\\n", __LINE__, API_NAMESPACE, ip);
+ }
+ QUIT_GMAIN_LOOP;
+}
+
/**
* @function ITs_inm_startup
* @description Called before each test
return 0;
}
+
+/**
+* @testcase ITc_inm_refresh_links_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Refreshes link information held by a handle.
+* @scenario Refreshes link information held by a handle.
+* @apicovered inm_refresh_links
+* @passcase When inm_refresh_links is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Refreshes link information held by a handle.
+//& type: auto
+int ITc_inm_refresh_links_p(void)
+{
+ START_TEST;
+
+ int nRet = INM_ERROR_NONE;
+
+ nRet = inm_refresh_links(g_hInm); //target API
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_refresh_links", InmGetError(nRet));
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_arp_request_set_get_packet_interval_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Sets and gets the ARP packet interval which is used to find targets IP on local network.
+* @scenario Sets and gets the ARP packet interval which is used to find targets IP on local network.
+* @apicovered inm_arp_request_set_packet_interval, inm_arp_request_get_packet_interval
+* @passcase When inm_arp_request_set_packet_interval and inm_arp_request_get_packet_interval is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Sets and gets the ARP packet interval which is used to find targets IP on local network.
+//& type: auto
+int ITc_inm_arp_request_set_get_packet_interval_p(void)
+{
+ START_TEST;
+
+ int nSetInterval = ARP_REQUEST_PACKET_INTERVAL;
+ int nGetInterval = -1;
+
+ int nRet = inm_arp_request_set_packet_interval(g_hInm, nSetInterval); //target API
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_arp_request_set_packet_interval", InmGetError(nRet));
+
+ nRet = inm_arp_request_get_packet_interval(g_hInm, &nGetInterval);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_arp_request_get_packet_interval", InmGetError(nRet));
+ if(nGetInterval != nSetInterval) {
+ FPRINTF("[Line : %d][%s] SetInterval %d not equal to GetInterval %d.\\n", __LINE__, API_NAMESPACE, nSetInterval, nGetInterval);
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_arp_request_start_stop_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Starts and stops sending ARP packets to find a target_ip.
+* @scenario Starts and stops sending ARP packets to find a target_ip.
+* @apicovered inm_arp_request_start, inm_arp_request_stop
+* @passcase When inm_arp_request_start and inm_arp_request_stop is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Starts and stops sending ARP packets to find a target_ip.
+//& type: auto
+
+int ITc_inm_arp_request_start_stop_p(void)
+{
+ START_TEST;
+
+ inm_connection_h hProfile = NULL;
+ g_bArpRequestedIpFound = false;
+ g_pszArpRequestedIpStr = NULL;
+
+ int nRet = InmGetAnyProfile(&hProfile);
+ if(nRet == FEATURE_NOT_SUPPORTED)
+ return 0;
+
+ nRet = inm_connection_get_gateway_address(hProfile, INM_ADDRESS_FAMILY_IPV4, &g_pszArpRequestedIpStr);
+ PRINT_RESULT_CLEANUP(nRet, INM_ERROR_NONE, "inm_connection_get_gateway_address", InmGetError(nRet), inm_connection_destroy(&hProfile));
+ CHECK_HANDLE_CLEANUP(g_pszArpRequestedIpStr, "inm_connection_get_gateway_address", inm_connection_destroy(&hProfile));
+
+ nRet = inm_arp_request_start(g_hInm, g_pszArpRequestedIpStr, InmArpRequestIpFoundCallback, NULL);
+ PRINT_RESULT_CLEANUP(nRet, INM_ERROR_NONE, "inm_arp_request_start", InmGetError(nRet), inm_connection_destroy(&hProfile);FREE_MEMORY_TC(g_pszArpRequestedIpStr));
+
+ RUN_POLLING_LOOP;
+
+ nRet = inm_arp_request_stop(g_hInm, g_pszArpRequestedIpStr);
+ PRINT_RESULT_CLEANUP(nRet, INM_ERROR_NONE, "inm_arp_request_stop", InmGetError(nRet), inm_connection_destroy(&hProfile);FREE_MEMORY_TC(g_pszArpRequestedIpStr));
+
+ nRet = inm_connection_destroy(&hProfile);
+ PRINT_RESULT_NORETURN(nRet, INM_ERROR_NONE, "inm_connection_destroy", InmGetError(nRet));
+
+ FREE_MEMORY_TC(g_pszArpRequestedIpStr);
+
+ if (!g_bArpRequestedIpFound) {
+ FPRINTF("[Line : %d][%s] ARP requested IP not found\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_default_gateway_start_stop_checking_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Starts and stops to send ARP packets to find gateway during timeout, in seconds.
+* @scenario Starts and stops to send ARP packets to find gateway during timeout, in seconds.
+* @apicovered inm_default_gateway_start_checking, inm_default_gateway_stop_checking
+* @passcase When inm_default_gateway_start_checking and inm_default_gateway_stop_checking is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Starts and stops to send ARP packets to find gateway during timeout, in seconds.
+//& type: auto
+int ITc_inm_default_gateway_start_stop_checking_p(void)
+{
+ START_TEST;
+
+ g_bGatewayFound = false;
+ int nRet = inm_default_gateway_start_checking(g_hInm, 0, InmDefaultGatewayFoundCallback, NULL);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_default_gateway_start_checking", InmGetError(nRet));
+
+ RUN_POLLING_LOOP;
+
+ nRet = inm_default_gateway_stop_checking(g_hInm);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_default_gateway_stop_checking", InmGetError(nRet));
+
+ if (!g_bGatewayFound) {
+ FPRINTF("[Line : %d][%s] Gateway IP not found\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_default_dns_lookup_check_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Checks DNS lookup of the target to check whether DNS server is valid or not.
+* @scenario Checks DNS lookup of the target to check whether DNS server is valid or not.
+* @apicovered inm_default_dns_lookup_check
+* @passcase When inm_default_dns_lookup_check is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Checks DNS lookup of the target to check whether DNS server is valid or not.
+//& type: auto
+int ITc_inm_default_dns_lookup_check_p(void)
+{
+ START_TEST;
+
+ g_bDnsLookupFinished = false;
+ int nRet = inm_default_dns_lookup_check(g_hInm, InmDefaultDnsLookupResultCallback, NULL);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_default_dns_lookup_check", InmGetError(nRet));
+
+ RUN_POLLING_LOOP;
+
+ if (!g_bDnsLookupFinished) {
+ FPRINTF("[Line : %d][%s] DNS lookup is not finished\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_reachable_urls_add_remove_url_to_check_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Adds URL to check reachability by inm_start_checking_reachable_urls
+* @scenario Adds URL to check reachability by inm_start_checking_reachable_urls
+* @apicovered inm_reachable_urls_add_url_to_check, inm_reachable_urls_remove_url_to_check
+* @passcase When inm_reachable_urls_add_url_to_check and inm_reachable_urls_remove_url_to_check is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Adds URL to check reachability by inm_start_checking_reachable_urls
+//& type: auto
+int ITc_inm_reachable_urls_add_remove_url_to_check_p(void)
+{
+ START_TEST;
+
+ int nRet = inm_reachable_urls_add_url_to_check(g_hInm, REACHABILITY_TEST_URL);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_reachable_urls_add_url_to_check", InmGetError(nRet));
+
+ nRet = inm_reachable_urls_remove_url_to_check(g_hInm, REACHABILITY_TEST_URL);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_reachable_urls_remove_url_to_check", InmGetError(nRet));
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_reachable_urls_start_stop_checking_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Starts to send HTTP GET requests with curl to check reachability of URLs of the given type and stops.
+* @scenario This function just checks if URLs in the list can be reachable once. If you want to check again, you need to call this function again with the target URL list.
+* @apicovered inm_reachable_urls_start_checking, inm_reachable_urls_stop_checking
+* @passcase When inm_reachable_urls_start_checking and inm_reachable_urls_stop_checking is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Starts to send HTTP GET requests with curl to check reachability of URLs of the given type and stops.
+//& type: auto
+int ITc_inm_reachable_urls_start_stop_checking_p(void)
+{
+ START_TEST;
+
+ g_bDefaultUrlFound = false;
+
+ int nRet = inm_reachable_urls_start_checking(g_hInm, INM_URL_LIST_TYPE_DEFAULT, InmReachableUrlsCheckResultDefaultCallback, NULL);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_reachable_urls_start_checking", InmGetError(nRet));
+
+ RUN_POLLING_LOOP;
+
+ if (!g_bDefaultUrlFound) {
+ FPRINTF("[Line : %d][%s] Default URL is not reachable\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ nRet = inm_reachable_urls_stop_checking(g_hInm, INM_URL_LIST_TYPE_DEFAULT);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_reachable_urls_stop_checking", InmGetError(nRet));
+
+ return 0;
+}
+
+/**
+* @testcase ITc_inm_reachable_urls_is_check_running_p
+* @since_tizen 5.5
+* @author SRID(karanam.s)
+* @reviewer SRID(manoj.g2)
+* @type auto
+* @description Gets whether the reachable URLs check is running or not.
+* @scenario Gets whether the reachable URLs check is running or not.
+* @apicovered inm_reachable_urls_is_check_running
+* @passcase When inm_reachable_urls_is_check_running is successful.
+* @failcase If target API fails or any precondition API fails
+* @precondition None
+* @postcondition None
+*/
+//& purpose: Gets whether the reachable URLs check is running or not.
+//& type: auto
+int ITc_inm_reachable_urls_is_check_running_p(void)
+{
+ START_TEST;
+
+ bool bIsRunning = FALSE;
+ int nRet = inm_reachable_urls_start_checking(g_hInm, INM_URL_LIST_TYPE_DEFAULT, InmReachableUrlsCheckResultDefaultCallback, NULL);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_reachable_urls_start_checking", InmGetError(nRet));
+
+ RUN_POLLING_LOOP;
+
+ nRet = inm_reachable_urls_is_check_running(g_hInm, INM_URL_LIST_TYPE_DEFAULT, &bIsRunning);
+ PRINT_RESULT(nRet, INM_ERROR_NONE, "inm_reachable_urls_is_check_running", InmGetError(nRet));
+ if (!bIsRunning) {
+ FPRINTF("[Line : %d][%s] Url reachability is not running\\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+
+ nRet = inm_reachable_urls_stop_checking(g_hInm, INM_URL_LIST_TYPE_DEFAULT);
+ PRINT_RESULT_NORETURN(nRet, INM_ERROR_NONE, "inm_reachable_urls_stop_checking", InmGetError(nRet));
+
+ return 0;
+}
+
/** @} */
/** @} */