Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sender address and port verification to UDPSOCKET_ECHOTEST #11836

Merged
merged 1 commit into from Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion TESTS/netsocket/udp/udpsocket_echotest.cpp
Expand Up @@ -63,6 +63,7 @@ static void _sigio_handler()
void UDPSOCKET_ECHOTEST()
{
SocketAddress udp_addr;
SocketAddress recv_addr;
NetworkInterface::get_default_instance()->gethostbyname(ECHO_SERVER_ADDR, &udp_addr);
udp_addr.set_port(ECHO_SERVER_PORT);

Expand Down Expand Up @@ -94,7 +95,7 @@ void UDPSOCKET_ECHOTEST()

do {
received_duplicate_packet = false;
recvd = sock.recvfrom(NULL, rx_buffer, pkt_s);
recvd = sock.recvfrom(&recv_addr, rx_buffer, pkt_s);
//Check if received duplicated packet
for (unsigned int d_idx = 0; d_idx < PKTS; ++d_idx) {
if (pkt_received[d_idx] && d_idx != s_idx && recvd == pkt_sizes[d_idx]) {
Expand All @@ -111,6 +112,10 @@ void UDPSOCKET_ECHOTEST()
printf("[Round#%02d - Receiver] error, returned %d\n", s_idx, recvd);
}
}
// Verify received address is correct
TEST_ASSERT(udp_addr == recv_addr);
TEST_ASSERT_EQUAL(udp_addr.get_port(), recv_addr.get_port());

if (memcmp(tx_buffer, rx_buffer, pkt_s) == 0) {
packets_recv++;
pkt_received[s_idx] = true;
Expand Down