ParticipantProxyData.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @file ParticipantProxyData.h
  16. *
  17. */
  18. #ifndef _FASTDDS_RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_
  19. #define _FASTDDS_RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_
  20. #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
  21. #include <fastrtps/qos/QosPolicies.h>
  22. #include <fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp>
  23. #include <fastdds/rtps/attributes/WriterAttributes.h>
  24. #include <fastdds/rtps/attributes/ReaderAttributes.h>
  25. #include <fastdds/rtps/common/Token.h>
  26. #include <fastdds/rtps/common/RemoteLocators.hpp>
  27. #if HAVE_SECURITY
  28. #include <fastdds/rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
  29. #endif
  30. #include <chrono>
  31. #define BUILTIN_PARTICIPANT_DATA_MAX_SIZE 100
  32. #define TYPELOOKUP_DATA_MAX_SIZE 5000
  33. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER (0x00000001 << 0)
  34. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_DETECTOR (0x00000001 << 1)
  35. #define DISC_BUILTIN_ENDPOINT_PUBLICATION_ANNOUNCER (0x00000001 << 2)
  36. #define DISC_BUILTIN_ENDPOINT_PUBLICATION_DETECTOR (0x00000001 << 3)
  37. #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_ANNOUNCER (0x00000001 << 4)
  38. #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_DETECTOR (0x00000001 << 5)
  39. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_ANNOUNCER (0x00000001 << 6)
  40. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_DETECTOR (0x00000001 << 7)
  41. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_ANNOUNCER (0x00000001 << 8)
  42. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_DETECTOR (0x00000001 << 9)
  43. #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER (0x00000001 << 10)
  44. #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_READER (0x00000001 << 11)
  45. #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REQUEST_DATA_WRITER (0x00000001 << 12)
  46. #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REQUEST_DATA_READER (0x00000001 << 13)
  47. #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REPLY_DATA_WRITER (0x00000001 << 14)
  48. #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REPLY_DATA_READER (0x00000001 << 15)
  49. #define DISC_BUILTIN_ENDPOINT_PUBLICATION_SECURE_ANNOUNCER (0x00000001 << 16)
  50. #define DISC_BUILTIN_ENDPOINT_PUBLICATION_SECURE_DETECTOR (0x00000001 << 17)
  51. #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_SECURE_ANNOUNCER (0x00000001 << 18)
  52. #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_SECURE_DETECTOR (0x00000001 << 19)
  53. #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_SECURE_DATA_WRITER (0x00000001 << 20)
  54. #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_SECURE_DATA_READER (0x00000001 << 21)
  55. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_SECURE_ANNOUNCER (0x00000001 << 26)
  56. #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_SECURE_DETECTOR (0x00000001 << 27)
  57. namespace eprosima {
  58. namespace fastrtps {
  59. namespace rtps {
  60. struct CDRMessage_t;
  61. class PDPSimple;
  62. class TimedEvent;
  63. class RTPSParticipantImpl;
  64. class ReaderProxyData;
  65. class WriterProxyData;
  66. class NetworkFactory;
  67. // proxy specific declarations
  68. template<class Proxy>
  69. class ProxyHashTable;
  70. /**
  71. * ParticipantProxyData class is used to store and convert the information Participants send to each other during the PDP phase.
  72. *@ingroup BUILTIN_MODULE
  73. */
  74. class ParticipantProxyData
  75. {
  76. public:
  77. ParticipantProxyData(
  78. const RTPSParticipantAllocationAttributes& allocation);
  79. ParticipantProxyData(
  80. const ParticipantProxyData& pdata);
  81. virtual ~ParticipantProxyData();
  82. //!Protocol version
  83. ProtocolVersion_t m_protocolVersion;
  84. //!GUID
  85. GUID_t m_guid;
  86. //!Vendor ID
  87. VendorId_t m_VendorId;
  88. //!Expects Inline QOS.
  89. bool m_expectsInlineQos;
  90. //!Available builtin endpoints
  91. BuiltinEndpointSet_t m_availableBuiltinEndpoints;
  92. //!Metatraffic locators
  93. RemoteLocatorList metatraffic_locators;
  94. //!Default locators
  95. RemoteLocatorList default_locators;
  96. //!Manual liveliness count
  97. Count_t m_manualLivelinessCount;
  98. //!Participant name
  99. string_255 m_participantName;
  100. //!
  101. InstanceHandle_t m_key;
  102. //!
  103. Duration_t m_leaseDuration;
  104. #if HAVE_SECURITY
  105. //!
  106. IdentityToken identity_token_;
  107. //!
  108. PermissionsToken permissions_token_;
  109. //!
  110. security::ParticipantSecurityAttributesMask security_attributes_;
  111. //!
  112. security::PluginParticipantSecurityAttributesMask plugin_security_attributes_;
  113. #endif
  114. //!
  115. bool isAlive;
  116. //!
  117. ParameterPropertyList_t m_properties;
  118. //!
  119. UserDataQosPolicy m_userData;
  120. //!
  121. TimedEvent* lease_duration_event;
  122. //!
  123. bool should_check_lease_duration;
  124. //!
  125. ProxyHashTable<ReaderProxyData>* m_readers = nullptr;
  126. //!
  127. ProxyHashTable<WriterProxyData>* m_writers = nullptr;
  128. /**
  129. * Update the data.
  130. * @param pdata Object to copy the data from
  131. * @return True on success
  132. */
  133. bool updateData(
  134. ParticipantProxyData& pdata);
  135. /**
  136. * Get the size in bytes of the CDR serialization of this object.
  137. * @param include_encapsulation Whether to include the size of the encapsulation info.
  138. * @return size in bytes of the CDR serialization.
  139. */
  140. uint32_t get_serialized_size(
  141. bool include_encapsulation) const;
  142. /**
  143. * Write as a parameter list on a CDRMessage_t
  144. * @return True on success
  145. */
  146. bool writeToCDRMessage(
  147. CDRMessage_t* msg,
  148. bool write_encapsulation);
  149. /**
  150. * Read the parameter list from a recevied CDRMessage_t
  151. * @return True on success
  152. */
  153. bool readFromCDRMessage(
  154. CDRMessage_t* msg,
  155. bool use_encapsulation,
  156. const NetworkFactory& network,
  157. bool is_shm_transport_available);
  158. //! Clear the data (restore to default state).
  159. void clear();
  160. /**
  161. * Copy the data from another object.
  162. * @param pdata Object to copy the data from
  163. */
  164. void copy(
  165. const ParticipantProxyData& pdata);
  166. /**
  167. * Set participant persistent GUID_t
  168. * @param guid valid GUID_t
  169. */
  170. void set_persistence_guid(
  171. const GUID_t& guid);
  172. /**
  173. * Retrieve participant persistent GUID_t
  174. * @return guid persistent GUID_t or c_Guid_Unknown
  175. */
  176. GUID_t get_persistence_guid() const;
  177. void assert_liveliness();
  178. const std::chrono::steady_clock::time_point& last_received_message_tm() const
  179. {
  180. return last_received_message_tm_;
  181. }
  182. const std::chrono::microseconds& lease_duration() const
  183. {
  184. return lease_duration_;
  185. }
  186. private:
  187. //! Store the last timestamp it was received a RTPS message from the remote participant.
  188. std::chrono::steady_clock::time_point last_received_message_tm_;
  189. //! Remote participant lease duration in microseconds.
  190. std::chrono::microseconds lease_duration_;
  191. };
  192. } /* namespace rtps */
  193. } /* namespace fastrtps */
  194. } /* namespace eprosima */
  195. #endif
  196. #endif // _FASTDDS_RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_