Skip to content

Commit

Permalink
mcast_loop: Drop mcast packet that server sent on different socket
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrdeep1 committed Aug 17, 2024
1 parent 3d790a5 commit 69cbefd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/coap_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,17 @@ coap_endpoint_get_session(coap_endpoint_t *endpoint,
return session;
}

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;
}
}
}
SESSIONS_ITER(endpoint->sessions, session, rtmp) {
if (session->ref == 0 && session->delayqueue == NULL) {
if (session->type == COAP_SESSION_TYPE_SERVER) {
Expand Down

0 comments on commit 69cbefd

Please sign in to comment.