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 23, 2024
1 parent e220c37 commit c2b34da
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/coap_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c2b34da

Please sign in to comment.