|
62 | 62 | #endif // if HAVE_SECURITY
|
63 | 63 | #include <utils/shared_mutex.hpp>
|
64 | 64 | #include <utils/TimeConversion.hpp>
|
| 65 | +#include <rtps/writer/BaseWriter.hpp> |
| 66 | +#include <rtps/reader/BaseReader.hpp> |
65 | 67 |
|
66 | 68 | namespace eprosima {
|
67 | 69 | namespace fastdds {
|
@@ -1698,6 +1700,121 @@ void PDP::add_builtin_security_attributes(
|
1698 | 1700 |
|
1699 | 1701 | #endif // HAVE_SECURITY
|
1700 | 1702 |
|
| 1703 | +void PDP::local_participant_attributes_update_nts( |
| 1704 | + const RTPSParticipantAttributes& new_atts) |
| 1705 | +{ |
| 1706 | + // Update user data |
| 1707 | + auto participant_data = getLocalParticipantProxyData(); |
| 1708 | + participant_data->m_userData.data_vec(new_atts.userData); |
| 1709 | + |
| 1710 | + // If we are intraprocess only, we do not need to update locators |
| 1711 | + bool announce_locators = !mp_RTPSParticipant->is_intraprocess_only(); |
| 1712 | + if (announce_locators) |
| 1713 | + { |
| 1714 | + // Clear all locators |
| 1715 | + participant_data->metatraffic_locators.unicast.clear(); |
| 1716 | + participant_data->metatraffic_locators.multicast.clear(); |
| 1717 | + participant_data->default_locators.unicast.clear(); |
| 1718 | + participant_data->default_locators.multicast.clear(); |
| 1719 | + |
| 1720 | + // Update default locators |
| 1721 | + for (const Locator_t& loc : new_atts.defaultUnicastLocatorList) |
| 1722 | + { |
| 1723 | + participant_data->default_locators.add_unicast_locator(loc); |
| 1724 | + } |
| 1725 | + for (const Locator_t& loc : new_atts.defaultMulticastLocatorList) |
| 1726 | + { |
| 1727 | + participant_data->default_locators.add_multicast_locator(loc); |
| 1728 | + } |
| 1729 | + |
| 1730 | + // Update metatraffic locators |
| 1731 | + for (const auto& locator : new_atts.builtin.metatrafficUnicastLocatorList) |
| 1732 | + { |
| 1733 | + participant_data->metatraffic_locators.add_unicast_locator(locator); |
| 1734 | + } |
| 1735 | + if (!new_atts.builtin.avoid_builtin_multicast || participant_data->metatraffic_locators.unicast.empty()) |
| 1736 | + { |
| 1737 | + for (const auto& locator : new_atts.builtin.metatrafficMulticastLocatorList) |
| 1738 | + { |
| 1739 | + participant_data->metatraffic_locators.add_multicast_locator(locator); |
| 1740 | + } |
| 1741 | + } |
| 1742 | + |
| 1743 | + fastdds::rtps::network::external_locators::add_external_locators(*participant_data, |
| 1744 | + new_atts.builtin.metatraffic_external_unicast_locators, |
| 1745 | + new_atts.default_external_unicast_locators); |
| 1746 | + } |
| 1747 | +} |
| 1748 | + |
| 1749 | +void PDP::update_endpoint_locators_if_default_nts( |
| 1750 | + const std::vector<BaseWriter*>& writers, |
| 1751 | + const std::vector<BaseReader*>& readers, |
| 1752 | + const RTPSParticipantAttributes& old_atts, |
| 1753 | + const RTPSParticipantAttributes& new_atts) |
| 1754 | +{ |
| 1755 | + // Check if default locators have changed |
| 1756 | + const auto& old_default_unicast = old_atts.defaultUnicastLocatorList; |
| 1757 | + const auto& old_default_multicast = old_atts.defaultMulticastLocatorList; |
| 1758 | + const auto& new_default_unicast = new_atts.defaultUnicastLocatorList; |
| 1759 | + const auto& new_default_multicast = new_atts.defaultMulticastLocatorList; |
| 1760 | + |
| 1761 | + // Early return if there is no change in default unicast locators |
| 1762 | + if ((old_default_unicast == new_default_unicast) && |
| 1763 | + (old_default_multicast == new_default_multicast)) |
| 1764 | + { |
| 1765 | + return; |
| 1766 | + } |
| 1767 | + |
| 1768 | + // Update proxies of endpoints with default configured locators |
| 1769 | + EDP* edp = get_edp(); |
| 1770 | + for (BaseWriter* writer : writers) |
| 1771 | + { |
| 1772 | + if ((old_default_multicast == writer->getAttributes().multicastLocatorList) && |
| 1773 | + (old_default_unicast == writer->getAttributes().unicastLocatorList)) |
| 1774 | + { |
| 1775 | + writer->getAttributes().multicastLocatorList = new_default_multicast; |
| 1776 | + writer->getAttributes().unicastLocatorList = new_default_unicast; |
| 1777 | + |
| 1778 | + WriterProxyData* wdata = nullptr; |
| 1779 | + GUID_t participant_guid; |
| 1780 | + wdata = addWriterProxyData(writer->getGuid(), participant_guid, |
| 1781 | + [](WriterProxyData* proxy, bool is_update, const ParticipantProxyData& participant) |
| 1782 | + { |
| 1783 | + static_cast<void>(is_update); |
| 1784 | + assert(is_update); |
| 1785 | + |
| 1786 | + proxy->set_locators(participant.default_locators); |
| 1787 | + return true; |
| 1788 | + }); |
| 1789 | + assert(wdata != nullptr); |
| 1790 | + edp->process_writer_proxy_data(writer, wdata); |
| 1791 | + } |
| 1792 | + } |
| 1793 | + for (BaseReader* reader : readers) |
| 1794 | + { |
| 1795 | + if ((old_default_multicast == reader->getAttributes().multicastLocatorList) && |
| 1796 | + (old_default_unicast == reader->getAttributes().unicastLocatorList)) |
| 1797 | + { |
| 1798 | + reader->getAttributes().multicastLocatorList = new_default_multicast; |
| 1799 | + reader->getAttributes().unicastLocatorList = new_default_unicast; |
| 1800 | + |
| 1801 | + ReaderProxyData* rdata = nullptr; |
| 1802 | + GUID_t participant_guid; |
| 1803 | + rdata = addReaderProxyData(reader->getGuid(), participant_guid, |
| 1804 | + [](ReaderProxyData* proxy, bool is_update, const ParticipantProxyData& participant) |
| 1805 | + { |
| 1806 | + static_cast<void>(is_update); |
| 1807 | + assert(is_update); |
| 1808 | + |
| 1809 | + proxy->set_locators(participant.default_locators); |
| 1810 | + return true; |
| 1811 | + }); |
| 1812 | + assert(rdata != nullptr); |
| 1813 | + edp->process_reader_proxy_data(reader, rdata); |
| 1814 | + } |
| 1815 | + } |
| 1816 | +} |
| 1817 | + |
1701 | 1818 | } /* namespace rtps */
|
1702 | 1819 | } /* namespace fastdds */
|
1703 | 1820 | } /* namespace eprosima */
|
0 commit comments