mcast_loop: Drop mcast packet that server sent on different socket

Server enabled for mcast receipt.  When the server is acting as a proxy
sends a mcast packet out over a slave client type socket, it receives
the mcast packet on the server socket (which could then be forward out
of the client socket....).

This change prevents the server socket from passing up the libcoap stack
a mcast packet that it knows the client socket is sending.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2024-08-23 10:51:20 +01:00
1 parent e220c371be
commit c2b34daa9b
1 file changed
+13
+13
View File
@@ -1074,6 +1074,19 @@ coap_endpoint_get_session(coap_endpoint_t *endpoint,
return session;
}
#if COAP_CLIENT_SUPPORT
if (coap_is_mcast(&packet->addr_info.local)) {
/* Check if this a proxy client packet we sent on another socket */
SESSIONS_ITER(endpoint->context->sessions, session, rtmp) {
if (coap_address_equals(&session->addr_info.remote, &packet->addr_info.local) &&
coap_address_get_port(&session->addr_info.local) ==
coap_address_get_port(&packet->addr_info.remote)) {
/* Drop looped back packet to stop recursion / confusion */
return NULL;
}
}
}
#endif /* COAP_CLIENT_SUPPORT */
SESSIONS_ITER(endpoint->sessions, session, rtmp) {
if (session->ref == 0 && session->delayqueue == NULL) {
if (session->type == COAP_SESSION_TYPE_SERVER) {