mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-13 11:50:40 +03:00
getifaddrs(): Check for function support
This commit is contained in:
1 parent
3c685a2b4d
commit
5fb4cd8a9c
4 files changed
+11
-7
No files matched your search
@@ -314,6 +314,7 @@ if(MINGW OR WIN32)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "")
|
||||
endif()
|
||||
check_function_exists(getaddrinfo HAVE_GETADDRINFO)
|
||||
check_function_exists(getifaddrs HAVE_GETIFADDRS)
|
||||
check_function_exists(strnlen HAVE_STRNLEN)
|
||||
check_function_exists(strrchr HAVE_STRRCHR)
|
||||
check_function_exists(getrandom HAVE_GETRANDOM)
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
#cmakedefine HAVE_GETADDRINFO @HAVE_GETADDRINFO@
|
||||
|
||||
/* Define to 1 if you have the `getifaddrs' function. */
|
||||
#cmakedefine HAVE_GETIFADDRS @HAVE_GETIFADDRS@
|
||||
|
||||
/* Define to 1 if you have the `getrandom' function. */
|
||||
#cmakedefine HAVE_GETRANDOM @HAVE_GETRANDOM@
|
||||
|
||||
|
||||
+1
-1
@@ -1242,7 +1242,7 @@ AC_TYPE_SIZE_T
|
||||
AC_TYPE_SSIZE_T
|
||||
|
||||
# Checks for library functions.
|
||||
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo \
|
||||
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo getifaddrs \
|
||||
strnlen malloc pthread_mutex_lock getrandom random if_nametoindex])
|
||||
|
||||
# Check if -lsocket -lnsl is required (specifically Solaris)
|
||||
|
||||
+6
-6
@@ -180,20 +180,20 @@ coap_is_mcast(const coap_address_t *a) {
|
||||
#define COAP_BCST_REFRESH_SECS 30
|
||||
#endif /* COAP_BCST_REFRESH_SECS */
|
||||
|
||||
#if (COAP_IPV4_SUPPORT && defined(HAVE_IFADDRS_H) && !defined(__ZEPHYR__)) || defined(_WIN32)
|
||||
#if COAP_IPV4_SUPPORT && !defined(__ZEPHYR__) && (defined(HAVE_GETIFADDRS) || defined(_WIN32))
|
||||
static int bcst_cnt = -1;
|
||||
static coap_tick_t last_refresh;
|
||||
static struct in_addr b_ipv4[COAP_BCST_CNT];
|
||||
#endif /* (COAP_IPV4_SUPPORT && HAVE_IFADDRS_H && !defined(__ZEPHYR__)) || defined(_WIN32) */
|
||||
#endif /* COAP_IPV4_SUPPORT && !defined(__ZEPHYR__) && (defined(HAVE_GETIFADDRS) || defined(_WIN32)) */
|
||||
|
||||
int
|
||||
coap_is_bcast(const coap_address_t *a) {
|
||||
#if COAP_IPV4_SUPPORT
|
||||
struct in_addr ipv4;
|
||||
#if defined(HAVE_IFADDRS_H) && !defined(__ZEPHYR__)
|
||||
#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
|
||||
int i;
|
||||
coap_tick_t now;
|
||||
#endif /* HAVE_IFADDRS_H && !defined(__ZEPHYR__) */
|
||||
#endif /* HAVE_GETIFADDRS && !defined(__ZEPHYR__) */
|
||||
#endif /* COAP_IPV4_SUPPORT */
|
||||
|
||||
if (!a)
|
||||
@@ -226,7 +226,7 @@ coap_is_bcast(const coap_address_t *a) {
|
||||
if (ipv4.s_addr == INADDR_BROADCAST)
|
||||
return 1;
|
||||
|
||||
#if defined(HAVE_IFADDRS_H) && !defined(__ZEPHYR__) && !defined(_WIN32)
|
||||
#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
|
||||
coap_ticks(&now);
|
||||
if (bcst_cnt == -1 ||
|
||||
(now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
|
||||
@@ -268,7 +268,7 @@ coap_is_bcast(const coap_address_t *a) {
|
||||
if (ipv4.s_addr == b_ipv4[i].s_addr)
|
||||
return 1;
|
||||
}
|
||||
#endif /* HAVE_IFADDRS_H && !defined(__ZEPHYR__) && !defined(_WIN32) */
|
||||
#endif /* HAVE_GETIFADDRS && !defined(__ZEPHYR__) */
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
|
||||
Reference in new issue
Block a user