Skip to content

Commit 635c003

Browse files
committed
Refs #23432. Pass transport_priority on locator filter in test_UDPv4Transport.
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
1 parent 084186d commit 635c003

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

include/fastdds/rtps/transport/test_UDPv4TransportDescriptor.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor
4242
//! Custom message filtering functions
4343
typedef std::function<bool (eprosima::fastdds::rtps::CDRMessage_t& msg)> filter;
4444
//! Locator filtering function
45-
typedef std::function<bool (const Locator& destination)> DestinationLocatorFilter;
45+
typedef std::function<bool (const Locator& destination, int32_t priority)> DestinationLocatorFilter;
4646

4747
//! Test transport options
4848
std::shared_ptr<TestUDPv4TransportOptions> test_transport_options = std::make_shared<TestUDPv4TransportOptions>();
@@ -115,7 +115,7 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor
115115
};
116116

117117
//! Filtering function for dropping messages to specific destinations
118-
DestinationLocatorFilter locator_filter_ = [](const Locator&)
118+
DestinationLocatorFilter locator_filter_ = [](const Locator&, int32_t)
119119
{
120120
return false;
121121
};
@@ -168,7 +168,7 @@ struct TestUDPv4TransportOptions
168168
std::atomic<uint32_t> test_UDPv4Transport_DropLogLength{0};
169169
std::atomic<bool> always_drop_participant_builtin_topic_data{false};
170170
std::atomic<bool> simulate_no_interfaces{false};
171-
test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter = [](const Locator&)
171+
test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter = [](const Locator&, int32_t)
172172
{
173173
return false;
174174
};

src/cpp/rtps/transport/test_UDPv4Transport.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ bool test_UDPv4Transport::send(
153153
bool only_multicast_purpose,
154154
bool whitelisted,
155155
const std::chrono::steady_clock::time_point& max_blocking_time_point,
156-
int32_t /* transport_priority */)
156+
int32_t transport_priority)
157157
{
158158
fastdds::rtps::LocatorsIterator& it = *destination_locators_begin;
159159

@@ -177,7 +177,8 @@ bool test_UDPv4Transport::send(
177177
*it,
178178
only_multicast_purpose,
179179
whitelisted,
180-
std::chrono::duration_cast<std::chrono::microseconds>(now - max_blocking_time_point));
180+
std::chrono::duration_cast<std::chrono::microseconds>(now - max_blocking_time_point),
181+
transport_priority);
181182

182183
++it;
183184
}
@@ -198,12 +199,13 @@ bool test_UDPv4Transport::send(
198199
const Locator& remote_locator,
199200
bool only_multicast_purpose,
200201
bool whitelisted,
201-
const std::chrono::microseconds& timeout)
202+
const std::chrono::microseconds& timeout,
203+
int32_t transport_priority)
202204
{
203205
bool is_multicast_remote_address = fastdds::rtps::IPLocator::IPLocator::isMulticast(remote_locator);
204206
if (is_multicast_remote_address == only_multicast_purpose || whitelisted)
205207
{
206-
if (packet_should_drop(buffers, total_bytes) || should_drop_locator(remote_locator))
208+
if (packet_should_drop(buffers, total_bytes) || should_drop_locator(remote_locator, transport_priority))
207209
{
208210
statistics_info_.set_statistics_message_data(remote_locator, buffers.back(), total_bytes);
209211
log_drop(buffers, total_bytes);
@@ -254,10 +256,11 @@ static bool ReadSubmessageHeader(
254256
}
255257

256258
bool test_UDPv4Transport::should_drop_locator(
257-
const Locator& remote_locator)
259+
const Locator& remote_locator,
260+
int32_t transport_priority)
258261
{
259-
return test_transport_options->locator_filter(remote_locator) ||
260-
locator_filter_(remote_locator) ||
262+
return test_transport_options->locator_filter(remote_locator, transport_priority) ||
263+
locator_filter_(remote_locator, transport_priority) ||
261264
// If there are no interfaces (simulate_no_interfaces), only multicast and localhost traffic is sent
262265
(test_transport_options->simulate_no_interfaces &&
263266
!fastdds::rtps::IPLocator::isMulticast(remote_locator) &&

src/cpp/rtps/transport/test_UDPv4Transport.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ class test_UDPv4Transport : public UDPv4Transport
102102
test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter_;
103103

104104
bool should_drop_locator(
105-
const Locator& remote_locator);
105+
const Locator& remote_locator,
106+
int32_t transport_priority);
106107

107108
bool log_drop(
108109
const std::vector<NetworkBuffer>& buffer,
@@ -121,7 +122,8 @@ class test_UDPv4Transport : public UDPv4Transport
121122
const Locator& remote_locator,
122123
bool only_multicast_purpose,
123124
bool whitelisted,
124-
const std::chrono::microseconds& timeout);
125+
const std::chrono::microseconds& timeout,
126+
int32_t transport_priority);
125127
};
126128

127129
} // namespace rtps

test/blackbox/common/BlackboxTestsDiscovery.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ TEST(Discovery, LocalInitialPeersDiferrentLocators)
820820

821821
// Install hook on the test transport to check for destination locators on the writer participant
822822
Checker checker;
823-
auto locator_printer = [&checker](const eprosima::fastdds::rtps::Locator& destination)
823+
auto locator_printer = [&checker](const eprosima::fastdds::rtps::Locator& destination, int32_t)
824824
{
825825
checker.check(destination);
826826
return false;
@@ -1351,7 +1351,7 @@ TEST_P(Discovery, AsymmeticIgnoreParticipantFlags)
13511351
std::atomic<uint32_t> messages_on_port{ 0 };
13521352
test_transport->interfaceWhiteList.push_back("127.0.0.1");
13531353
test_transport->locator_filter_ = [&multicast_port, &messages_on_port](
1354-
const eprosima::fastdds::rtps::Locator& destination)
1354+
const eprosima::fastdds::rtps::Locator& destination, int32_t)
13551355
{
13561356
if (IPLocator::isMulticast(destination))
13571357
{
@@ -1406,7 +1406,7 @@ TEST_P(Discovery, single_unicast_pdp_response)
14061406
auto test_transport = std::make_shared<test_UDPv4TransportDescriptor>();
14071407
test_transport->interfaceWhiteList.push_back("127.0.0.1");
14081408
test_transport->locator_filter_ = [&num_unicast_sends, &multicast_port](
1409-
const eprosima::fastdds::rtps::Locator& destination)
1409+
const eprosima::fastdds::rtps::Locator& destination, int32_t)
14101410
{
14111411
if (IPLocator::isMulticast(destination))
14121412
{
@@ -1516,7 +1516,7 @@ TEST_P(Discovery, single_unicast_pdp_response_flowcontroller)
15161516
auto test_transport = std::make_shared<test_UDPv4TransportDescriptor>();
15171517
test_transport->interfaceWhiteList.push_back("127.0.0.1");
15181518
test_transport->locator_filter_ = [&num_unicast_sends, &multicast_port](
1519-
const eprosima::fastdds::rtps::Locator& destination)
1519+
const eprosima::fastdds::rtps::Locator& destination, int32_t)
15201520
{
15211521
if (IPLocator::isMulticast(destination))
15221522
{
@@ -1648,7 +1648,7 @@ TEST_P(Discovery, single_unicast_pdp_response_flowcontroller_limited)
16481648
auto test_transport = std::make_shared<test_UDPv4TransportDescriptor>();
16491649
test_transport->interfaceWhiteList.push_back("127.0.0.1");
16501650
test_transport->locator_filter_ = [&num_unicast_sends, &multicast_port](
1651-
const eprosima::fastdds::rtps::Locator& destination)
1651+
const eprosima::fastdds::rtps::Locator& destination, int32_t)
16521652
{
16531653
if (IPLocator::isMulticast(destination))
16541654
{

test/blackbox/common/DDSBlackboxTestsDiscovery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ TEST(DDSDiscovery, multicast_only_one_packet_sent_when_multiple_multicast_reader
24382438
multicast_locators.push_back(new_multicast_locator);
24392439

24402440
writer_test_transport->locator_filter_ = [&n_multicast_times_sent, &new_multicast_locator](
2441-
const eprosima::fastdds::rtps::Locator& destination)
2441+
const eprosima::fastdds::rtps::Locator& destination, int32_t)
24422442
{
24432443
if (destination == new_multicast_locator)
24442444
{

test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void run_parametrized_test(
118118
auto pub_udp_descriptor = std::make_shared<eprosima::fastdds::rtps::test_UDPv4TransportDescriptor>();
119119
std::atomic<uint32_t> messages_on_odd_port{ 0 }; // Messages corresponding to user data
120120
pub_udp_descriptor->locator_filter_ = [&messages_on_odd_port](
121-
const eprosima::fastdds::rtps::Locator& destination)
121+
const eprosima::fastdds::rtps::Locator& destination, int32_t)
122122
{
123123
if (0 != (destination.port % 2))
124124
{

0 commit comments

Comments
 (0)