From 0dcbf38a20dd8af1664f8be59794c005e4e257d8 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Thu, 12 Jun 2014 01:19:58 +0200 Subject: [PATCH] drop received packet if it is not received on the correct interface --- net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net.c b/net.c index eab947e3..35747adf 100644 --- a/net.c +++ b/net.c @@ -849,7 +849,12 @@ coap_read( coap_context_t *ctx ) { } else { #ifdef WITH_POSIX /* FIXME: make sure that dst == ctx->endpoint->addr */ - result = coap_handle_message(ctx, ctx->endpoint, packet); + if (coap_address_isany(&ctx->endpoint->addr) || + coap_address_equals(&packet->dst, &ctx->endpoint->addr)) { + result = coap_handle_message(ctx, ctx->endpoint, packet); + } else { + coap_log(LOG_DEBUG, "packet received on wrong interface, dropped\n"); + } #endif /* WITH_POSIX */ #ifdef WITH_LWIP result = coap_handle_message(ctx, &src,