Skip to content

Commit

Permalink
gcoap: Do not send responses from multicast addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Feb 13, 2023
1 parent 54037f5 commit ac3a9cd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,27 @@ static void _on_sock_udp_evt(sock_udp_t *sock, sock_async_flags_t type, void *ar
cursor += res;
}

/* make sure we reply with the same address that the request was destined for */
/* make sure we reply with the same address that the request was
* destined for -- except in the multicast case */
sock_udp_aux_tx_t *aux_out_ptr;
sock_udp_aux_tx_t aux_out = {
.flags = SOCK_AUX_SET_LOCAL,
.local = aux_in.local,
};
if (_ep_is_multicast(&aux_in.local)) {
/* This eventually gets passed to sock_udp_send_aux, where NULL
* simply does not set any flags */
aux_out_ptr = NULL;
} else {
aux_out_ptr = &aux_out;
}

gcoap_socket_t socket = {
.type = GCOAP_SOCKET_TYPE_UDP,
.socket.udp = sock,
};

_process_coap_pdu(&socket, &remote, &aux_out, _listen_buf, cursor, truncated);
_process_coap_pdu(&socket, &remote, aux_out_ptr, _listen_buf, cursor, truncated);
}
}

Expand Down

0 comments on commit ac3a9cd

Please sign in to comment.