Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions include/netutils/netlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,41 @@ int netlib_getifstatistics(FAR const char *ifname,
int netlib_check_ifconflict(FAR const char *ifname);
#endif

#ifdef CONFIG_NETUTILS_PING
/**
* @brief
* Check network connectivity by pinging a remote IP address.
* If ip is NULL, ping the gateway of each network interface,
* and optionally the routers from the routing table. If ping
* is disabled, just check the status of the IP network card.
*
* @param ip The ipv4 address to check, or NULL to ping gateways
* @param timeout The max timeout of each ping
* @param retry The retry times of ping
*
* @return
* nums of remote reply of ping; a negative on failure
*/

int netlib_check_ipconnectivity(FAR const char *ip, int timeout, int retry);

#ifdef CONFIG_NETUTILS_PING

/**
* @brief
* Check network connectivity by pinging the default gateway
* of the specified network interface.
*
* @param ifname The name of the interface to use
* @param timeout The timeout of ping
* @param retry The retry times of ping
*
* @return
* nums of gateway reply of ping; a negative on failure.
*/

int netlib_check_ifconnectivity(FAR const char *ifname,
int timeout, int retry);
#else
#define netlib_check_ipconnectivity(i, t, r) 1
#define netlib_check_ifconnectivity(i, t, r) 1
#endif

Expand Down
4 changes: 3 additions & 1 deletion netutils/netlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ if(CONFIG_NETUTILS_NETLIB)
list(APPEND SRCS netlib_getiobinfo.c)
endif()

list(APPEND SRCS netlib_checkipconnectivity.c)

if(CONFIG_NETUTILS_PING)
list(APPEND SRCS netlib_checkipconnectivity.c netlib_checkifconnectivity.c)
list(APPEND SRCS netlib_checkifconnectivity.c)
endif()

list(APPEND SRCS netlib_checkhttpconnectivity.c)
Expand Down
4 changes: 3 additions & 1 deletion netutils/netlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ ifeq ($(CONFIG_MM_IOB),y)
CSRCS += netlib_getiobinfo.c
endif

CSRCS += netlib_checkipconnectivity.c

ifeq ($(CONFIG_NETUTILS_PING),y)
CSRCS += netlib_checkipconnectivity.c netlib_checkifconnectivity.c
CSRCS += netlib_checkifconnectivity.c
endif

CSRCS += netlib_checkhttpconnectivity.c
Expand Down
7 changes: 4 additions & 3 deletions netutils/netlib/netlib_checkifconnectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@
* Name: netlib_check_ifconnectivity
*
* Description:
* Check network interface connectivity by pinging the gateway
* Check network connectivity by pinging the default gateway
* of the specified network interface.
*
* Parameters:
* ifname The name of the interface to use
* timeout The timeout of ping
* retry The retry times of ping
*
* Return:
* nums of gateway reply of ping; a nagtive on failure.
* nums of gateway reply of ping; a negative on failure.
*
****************************************************************************/

Expand Down Expand Up @@ -86,4 +87,4 @@ int netlib_check_ifconnectivity(FAR const char *ifname,
return netlib_check_ipconnectivity(destip, timeout, retry);
}

#endif /* CONFIG_NETUTILS_PING */
#endif /* CONFIG_NETUTILS_PING */
Loading
Loading