diff --git a/dds/DCPS/RTPS/DiscoveredEntities.h b/dds/DCPS/RTPS/DiscoveredEntities.h index 2295af67b75..2f929e3ad57 100644 --- a/dds/DCPS/RTPS/DiscoveredEntities.h +++ b/dds/DCPS/RTPS/DiscoveredEntities.h @@ -118,6 +118,8 @@ struct DiscoveredParticipant { location_data_.ice6_timestamp.nanosec = 0; location_data_.relay6_timestamp.sec = 0; location_data_.relay6_timestamp.nanosec = 0; + location_data_.lease_duration.sec = 0; + location_data_.lease_duration.nanosec = 0; #ifdef OPENDDS_SECURITY security_info_.participant_security_attributes = 0; diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index 068b0123047..2bdad9bcf78 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -522,10 +522,16 @@ void Spdp::process_location_updates_i(const DiscoveredParticipantIter& iter, con ACE_DEBUG((LM_DEBUG, "(%P|%t) DEBUG: Spdp::process_location_updates_i: %@ %C has %B location update(s) force_publish=%d reason=%C\n", this, LogGuid(iter->first).c_str(), location_updates.size(), force_publish, reason)); } + const DCPS::TimeDuration leaseDuration = rtps_duration_to_time_duration(iter->second.pdata_.leaseDuration, + iter->second.pdata_.participantProxy.protocolVersion, + iter->second.pdata_.participantProxy.vendorId); + + DCPS::ParticipantLocationBuiltinTopicData& location_data = iter->second.location_data_; + location_data.lease_duration = leaseDuration.to_dds_duration(); + bool published = false; for (DiscoveredParticipant::LocationUpdateList::const_iterator pos = location_updates.begin(), - limit = location_updates.end(); iter != participants_.end() && pos != limit; ++pos) { - DCPS::ParticipantLocationBuiltinTopicData& location_data = iter->second.location_data_; + limit = location_updates.end(); pos != limit; ++pos) { OPENDDS_STRING addr = ""; const DCPS::ParticipantLocation old_mask = location_data.location; @@ -572,12 +578,8 @@ void Spdp::process_location_updates_i(const DiscoveredParticipantIter& iter, con break; } - const DDS::Time_t expr = - ( - pos->timestamp_ - rtps_duration_to_time_duration(iter->second.pdata_.leaseDuration, - iter->second.pdata_.participantProxy.protocolVersion, - iter->second.pdata_.participantProxy.vendorId) - ).to_dds_time(); + const DDS::Time_t expr = (pos->timestamp_ - leaseDuration).to_dds_time(); + if ((location_data.location & DCPS::LOCATION_LOCAL) && DCPS::operator<(location_data.local_timestamp, expr)) { location_data.location &= ~(DCPS::LOCATION_LOCAL); location_data.change_mask |= DCPS::LOCATION_LOCAL; diff --git a/dds/OpenddsDcpsExt.idl b/dds/OpenddsDcpsExt.idl index 8b9f931b0ad..84366fd3f89 100644 --- a/dds/OpenddsDcpsExt.idl +++ b/dds/OpenddsDcpsExt.idl @@ -55,6 +55,7 @@ module OpenDDS DDS::Time_t ice6_timestamp; string relay6_addr; DDS::Time_t relay6_timestamp; + DDS::Duration_t lease_duration; }; const string RTPS_RELAY_STUN_PROTOCOL = "RtpsRelay:STUN"; diff --git a/docs/devguide/built_in_topics.rst b/docs/devguide/built_in_topics.rst index 8fa303f4f70..89949c2fcea 100644 --- a/docs/devguide/built_in_topics.rst +++ b/docs/devguide/built_in_topics.rst @@ -253,6 +253,8 @@ The topic type ParticipantLocationBuiltinTopicData is defined in :ghfile:`dds/Op * ``local6_addr``, ``local6_timestamp``, ``ice6_addr``, ``ice6_timestamp``, ``relay6_addr``, and ``relay6_timestamp`` -- Are the IPV6 equivalents. +* ``lease_duration`` -- The remote participant's lease duration (see Lease Duration in :ref:`run_time_configuration--rtps-disc-config-options`) + .. _built_in_topics--openddsconnectionrecord-topic: OpenDDSConnectionRecord Topic diff --git a/docs/news.d/participant-location-duration.rst b/docs/news.d/participant-location-duration.rst new file mode 100644 index 00000000000..25a471d024e --- /dev/null +++ b/docs/news.d/participant-location-duration.rst @@ -0,0 +1,8 @@ +.. news-prs: 4545 + +.. news-start-section: Additions +- The data type for the OpenDDS-specific Built-in ParticipantLocation Topic now includes the lease duration. + + - See :ref:`built_in_topics--openddsparticipantlocation-topic` for details. + +.. news-end-section diff --git a/java/tests/participant_location/ParticipantLocationListener.java b/java/tests/participant_location/ParticipantLocationListener.java index bebee5716cb..28a5225d3c6 100644 --- a/java/tests/participant_location/ParticipantLocationListener.java +++ b/java/tests/participant_location/ParticipantLocationListener.java @@ -48,8 +48,8 @@ public synchronized void on_data_available(DDS.DataReader reader) { } ParticipantLocationBuiltinTopicDataHolder participant = new ParticipantLocationBuiltinTopicDataHolder( - new ParticipantLocationBuiltinTopicData(new byte[16], 0, 0, "", new DDS.Time_t(), "", new DDS.Time_t(), "", - new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t())); + new ParticipantLocationBuiltinTopicData(new byte[16], 0, 0, "", new DDS.Time_t(), "", new DDS.Time_t(), "", + new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t(), "", new DDS.Time_t(), new DDS.Duration_t())); SampleInfoHolder si = new SampleInfoHolder( new SampleInfo(0, 0, 0, new DDS.Time_t(), 0, 0, 0, 0, 0, 0, 0, false, 0)); @@ -93,6 +93,7 @@ public synchronized void on_data_available(DDS.DataReader reader) { System.out.println(" : " + participant.value.ice_timestamp.sec); System.out.println(" relay: " + participant.value.relay_addr); System.out.println(" : " + participant.value.relay_timestamp.sec); + System.out.println(" lease: " + participant.value.lease_duration.sec); // update locations if SampleInfo is valid if (si.value.valid_data) { diff --git a/tests/DCPS/ParticipantLocationTopic/ParticipantLocationListenerImpl.cpp b/tests/DCPS/ParticipantLocationTopic/ParticipantLocationListenerImpl.cpp index 3d157de4e86..eb866192995 100644 --- a/tests/DCPS/ParticipantLocationTopic/ParticipantLocationListenerImpl.cpp +++ b/tests/DCPS/ParticipantLocationTopic/ParticipantLocationListenerImpl.cpp @@ -86,7 +86,8 @@ void ParticipantLocationListenerImpl::on_data_available(DDS::DataReader_ptr read << " ice6: " << participant.ice6_addr << std::endl << " : " << participant.ice6_timestamp.sec << std::endl << "relay6: " << participant.relay6_addr << std::endl - << " : " << participant.relay6_timestamp.sec << std::endl; + << " : " << participant.relay6_timestamp.sec << std::endl + << " lease: " << OpenDDS::DCPS::TimeDuration(participant.lease_duration).str(9) << std::endl; // update locations if SampleInfo is valid. if (si.valid_data == 1) diff --git a/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp b/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp index c1256b2c6df..0f53ac3156a 100644 --- a/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp +++ b/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp @@ -83,6 +83,8 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredParticipant_ctor) EXPECT_EQ(uut.location_data_.ice6_timestamp.nanosec, 0u); EXPECT_EQ(uut.location_data_.relay6_timestamp.sec, 0); EXPECT_EQ(uut.location_data_.relay6_timestamp.nanosec, 0u); + EXPECT_EQ(uut.location_data_.lease_duration.sec, 0); + EXPECT_EQ(uut.location_data_.lease_duration.nanosec, 0u); #ifdef OPENDDS_SECURITY EXPECT_EQ(uut.have_spdp_info_, false);