Skip to content

Commit

Permalink
Internal refactor on port handling (#3440) (#4698)
Browse files Browse the repository at this point in the history
* Internal refactor on port handling (#3440)

* Refs #18002. Avoid mutation of multicast ports.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Move security initalization up.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Prepare for refactor of locators setup.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Refactor metatraffic related code.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Refactor initial peers related code.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Refactor user traffic related code.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Refactor output traffic related code.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Safe metatraffic unicast port on a new attribute.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. User unicast port calculated on participant instead of NetworkFactory.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Update metatraffic_unicast_port_ inside applyLocatorAdaptRule.

Signed-off-by: Miguel Company <[email protected]>

* Apply suggestion

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Always create unicast receiver resources first.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Improve warning message.

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Refactor createReceiverResources

Signed-off-by: Miguel Company <[email protected]>

* Refs #18002. Improve SHM.SamePortUnicastMulticast blackbox test

Signed-off-by: Miguel Company <[email protected]>

---------

Signed-off-by: Miguel Company <[email protected]>
Signed-off-by: Miguel Company <[email protected]>
(cherry picked from commit ea5af48)

# Conflicts:
#	src/cpp/rtps/network/NetworkFactory.h
#	src/cpp/rtps/participant/RTPSParticipantImpl.cpp

* Fix conflicts.

Signed-off-by: Miguel Company <[email protected]>

---------

Signed-off-by: Miguel Company <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
  • Loading branch information
mergify[bot] and MiguelCompany authored May 15, 2024
1 parent d24584c commit a429ccf
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 124 deletions.
11 changes: 4 additions & 7 deletions src/cpp/rtps/network/NetworkFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,30 +371,27 @@ bool NetworkFactory::configureInitialPeerLocator(
}

bool NetworkFactory::getDefaultUnicastLocators(
uint32_t domain_id,
LocatorList_t& locators,
const RTPSParticipantAttributes& m_att) const
uint32_t port) const
{
bool result = false;
for (auto& transport : mRegisteredTransports)
{
result |= transport->getDefaultUnicastLocators(locators, calculate_well_known_port(domain_id, m_att, false));
result |= transport->getDefaultUnicastLocators(locators, port);
}
return result;
}

bool NetworkFactory::fill_default_locator_port(
uint32_t domain_id,
Locator_t& locator,
const RTPSParticipantAttributes& m_att,
bool is_multicast) const
uint32_t port) const
{
bool result = false;
for (auto& transport : mRegisteredTransports)
{
if (transport->IsLocatorSupported(locator))
{
result |= transport->fillUnicastLocator(locator, calculate_well_known_port(domain_id, m_att, is_multicast));
result |= transport->fillUnicastLocator(locator, port);
}
}
return result;
Expand Down
23 changes: 10 additions & 13 deletions src/cpp/rtps/network/NetworkFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,15 @@ class NetworkFactory
* Add locators to the default unicast configuration.
* */
bool getDefaultUnicastLocators(
uint32_t domain_id,
LocatorList_t& locators,
const RTPSParticipantAttributes& m_att) const;
uint32_t port) const;

/**
* Fill the locator with the default unicast configuration.
* */
bool fill_default_locator_port(
uint32_t domain_id,
Locator_t& locator,
const RTPSParticipantAttributes& m_att,
bool is_multicast) const;
uint32_t port) const;

/**
* Shutdown method to close the connections of the transports.
Expand All @@ -230,6 +227,14 @@ class NetworkFactory
const LocatorList_t& remote_participant_locators,
const LocatorList_t& participant_initial_peers) const;

/**
* Calculate well-known ports.
*/
uint16_t calculate_well_known_port(
uint32_t domain_id,
const RTPSParticipantAttributes& att,
bool is_multicast) const;

private:

std::vector<std::unique_ptr<fastdds::rtps::TransportInterface>> mRegisteredTransports;
Expand All @@ -243,14 +248,6 @@ class NetworkFactory

// Whether multicast metatraffic on SHM transport should always be used
bool enforce_shm_multicast_metatraffic_ = false;

/**
* Calculate well-known ports.
*/
uint16_t calculate_well_known_port(
uint32_t domain_id,
const RTPSParticipantAttributes& att,
bool is_multicast) const;
};

} // namespace rtps
Expand Down
Loading

0 comments on commit a429ccf

Please sign in to comment.