1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gcoap: Do not send responses from multicast addresses

This commit is contained in:
chrysn 2023-02-13 20:17:25 +01:00
parent 54037f5c2d
commit ac3a9cdf83

View File

@ -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);
}
}