Skip to content

Commit

Permalink
Internal refactor on port handling (#3440)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
MiguelCompany authored Apr 17, 2024
1 parent a35c846 commit ea5af48
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 130 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 @@ -460,30 +460,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 @@ -283,18 +283,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 Down Expand Up @@ -323,6 +320,14 @@ class NetworkFactory
*/
std::vector<fastdds::rtps::TransportNetmaskFilterInfo> netmask_filter_info() 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 @@ -339,14 +344,6 @@ class NetworkFactory

// Mask using transport kinds to indicate whether the transports allows localhost
NetworkConfigSet_t network_configuration_;

/**
* 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 ea5af48

Please sign in to comment.