mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-16 21:14:55 +03:00
ESP-IDF: Fix handling broadcast address
This commit is contained in:
1 parent
7146a45fd0
commit
65f0be894e
1 file changed
+11
-5
+11
-5
@@ -139,10 +139,10 @@ coap_is_mcast(const coap_address_t *a) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(WIN32) && !defined(ESPIDF_VERSION)
|
||||
#if !defined(WIN32)
|
||||
|
||||
#ifndef COAP_BCST_CNT
|
||||
#define COAP_BCST_CNT 6
|
||||
#define COAP_BCST_CNT 15
|
||||
#endif /* COAP_BCST_CNT */
|
||||
|
||||
/* How frequently to refresh the list of valid IPv4 broadcast addresses */
|
||||
@@ -150,21 +150,25 @@ coap_is_mcast(const coap_address_t *a) {
|
||||
#define COAP_BCST_REFRESH_SECS 30
|
||||
#endif /* COAP_BCST_REFRESH_SECS */
|
||||
|
||||
#if COAP_IPV4_SUPPORT
|
||||
#if COAP_IPV4_SUPPORT && !defined(ESPIDF_VERSION)
|
||||
static int bcst_cnt = -1;
|
||||
static coap_tick_t last_refresh;
|
||||
static struct in_addr b_ipv4[COAP_BCST_CNT];
|
||||
#endif /* COAP_IPV4_SUPPORT */
|
||||
#endif /* COAP_IPV4_SUPPORT && ! ESPIDF_VERSION */
|
||||
|
||||
#if !defined(ESPIDF_VERSION)
|
||||
#include <net/if.h>
|
||||
#include <ifaddrs.h>
|
||||
#endif /* ! ESPIDF_VERSION */
|
||||
|
||||
int
|
||||
coap_is_bcast(const coap_address_t *a) {
|
||||
#if COAP_IPV4_SUPPORT
|
||||
struct in_addr ipv4;
|
||||
#if !defined(ESPIDF_VERSION)
|
||||
int i;
|
||||
coap_tick_t now;
|
||||
#endif /* ! ESPIDF_VERSION */
|
||||
#endif /* COAP_IPV4_SUPPORT */
|
||||
|
||||
if (!a)
|
||||
@@ -194,6 +198,7 @@ coap_is_bcast(const coap_address_t *a) {
|
||||
if (ipv4.s_addr == INADDR_BROADCAST)
|
||||
return 1;
|
||||
|
||||
#if !defined(ESPIDF_VERSION)
|
||||
coap_ticks(&now);
|
||||
if (bcst_cnt == -1 ||
|
||||
(now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
|
||||
@@ -225,10 +230,11 @@ coap_is_bcast(const coap_address_t *a) {
|
||||
if (ipv4.s_addr == b_ipv4[i].s_addr)
|
||||
return 1;
|
||||
}
|
||||
#endif /* ESPIDF_VERSION */
|
||||
return 0;
|
||||
#endif /* COAP_IPV4_SUPPORT */
|
||||
}
|
||||
#else /* WIN32 || ESPIDF_VERSION */
|
||||
#else /* WIN32 */
|
||||
int
|
||||
coap_is_bcast(const coap_address_t *a) {
|
||||
(void)a;
|
||||
|
||||
Reference in new issue
Block a user