/src/Fast-DDS/include/fastdds/rtps/builtin/data/ParticipantProxyData.h
Line | Count | Source (jump to first uncovered line) |
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 | | /** |
16 | | * @file ParticipantProxyData.h |
17 | | * |
18 | | */ |
19 | | |
20 | | #ifndef _FASTDDS_RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_ |
21 | | #define _FASTDDS_RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_ |
22 | | |
23 | | #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
24 | | #include <fastrtps/qos/QosPolicies.h> |
25 | | |
26 | | #include <fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp> |
27 | | #include <fastdds/rtps/attributes/WriterAttributes.h> |
28 | | #include <fastdds/rtps/attributes/ReaderAttributes.h> |
29 | | #include <fastdds/rtps/common/Token.h> |
30 | | #include <fastdds/rtps/common/RemoteLocators.hpp> |
31 | | |
32 | | #if HAVE_SECURITY |
33 | | #include <fastdds/rtps/security/accesscontrol/ParticipantSecurityAttributes.h> |
34 | | #endif // if HAVE_SECURITY |
35 | | |
36 | | #include <chrono> |
37 | | |
38 | 0 | #define BUILTIN_PARTICIPANT_DATA_MAX_SIZE 100 |
39 | 0 | #define TYPELOOKUP_DATA_MAX_SIZE 5000 |
40 | | |
41 | 0 | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER (0x00000001 << 0) |
42 | 0 | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_DETECTOR (0x00000001 << 1) |
43 | 0 | #define DISC_BUILTIN_ENDPOINT_PUBLICATION_ANNOUNCER (0x00000001 << 2) |
44 | 0 | #define DISC_BUILTIN_ENDPOINT_PUBLICATION_DETECTOR (0x00000001 << 3) |
45 | 0 | #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_ANNOUNCER (0x00000001 << 4) |
46 | 0 | #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_DETECTOR (0x00000001 << 5) |
47 | | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_ANNOUNCER (0x00000001 << 6) |
48 | | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_DETECTOR (0x00000001 << 7) |
49 | | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_ANNOUNCER (0x00000001 << 8) |
50 | | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_DETECTOR (0x00000001 << 9) |
51 | 0 | #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER (0x00000001 << 10) |
52 | 0 | #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_READER (0x00000001 << 11) |
53 | 0 | #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REQUEST_DATA_WRITER (0x00000001 << 12) |
54 | 0 | #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REQUEST_DATA_READER (0x00000001 << 13) |
55 | 0 | #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REPLY_DATA_WRITER (0x00000001 << 14) |
56 | 0 | #define BUILTIN_ENDPOINT_TYPELOOKUP_SERVICE_REPLY_DATA_READER (0x00000001 << 15) |
57 | | #define DISC_BUILTIN_ENDPOINT_PUBLICATION_SECURE_ANNOUNCER (0x00000001 << 16) |
58 | | #define DISC_BUILTIN_ENDPOINT_PUBLICATION_SECURE_DETECTOR (0x00000001 << 17) |
59 | | #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_SECURE_ANNOUNCER (0x00000001 << 18) |
60 | | #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_SECURE_DETECTOR (0x00000001 << 19) |
61 | | #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_SECURE_DATA_WRITER (0x00000001 << 20) |
62 | | #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_SECURE_DATA_READER (0x00000001 << 21) |
63 | | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_SECURE_ANNOUNCER (0x00000001 << 26) |
64 | | #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_SECURE_DETECTOR (0x00000001 << 27) |
65 | | |
66 | | namespace eprosima { |
67 | | namespace fastrtps { |
68 | | namespace rtps { |
69 | | |
70 | | struct CDRMessage_t; |
71 | | class PDPSimple; |
72 | | class TimedEvent; |
73 | | class RTPSParticipantImpl; |
74 | | class ReaderProxyData; |
75 | | class WriterProxyData; |
76 | | class NetworkFactory; |
77 | | |
78 | | // proxy specific declarations |
79 | | template<class Proxy> |
80 | | class ProxyHashTable; |
81 | | |
82 | | /** |
83 | | * ParticipantProxyData class is used to store and convert the information Participants send to each other during the PDP phase. |
84 | | *@ingroup BUILTIN_MODULE |
85 | | */ |
86 | | class ParticipantProxyData |
87 | | { |
88 | | public: |
89 | | |
90 | | ParticipantProxyData( |
91 | | const RTPSParticipantAllocationAttributes& allocation); |
92 | | |
93 | | ParticipantProxyData( |
94 | | const ParticipantProxyData& pdata); |
95 | | |
96 | | virtual ~ParticipantProxyData(); |
97 | | |
98 | | //!Protocol version |
99 | | ProtocolVersion_t m_protocolVersion; |
100 | | //!GUID |
101 | | GUID_t m_guid; |
102 | | //!Vendor ID |
103 | | VendorId_t m_VendorId; |
104 | | //!Expects Inline QOS. |
105 | | bool m_expectsInlineQos; |
106 | | //!Available builtin endpoints |
107 | | BuiltinEndpointSet_t m_availableBuiltinEndpoints; |
108 | | //!Metatraffic locators |
109 | | RemoteLocatorList metatraffic_locators; |
110 | | //!Default locators |
111 | | RemoteLocatorList default_locators; |
112 | | //!Manual liveliness count |
113 | | Count_t m_manualLivelinessCount; |
114 | | //!Participant name |
115 | | string_255 m_participantName; |
116 | | //! |
117 | | InstanceHandle_t m_key; |
118 | | //! |
119 | | Duration_t m_leaseDuration; |
120 | | #if HAVE_SECURITY |
121 | | //! |
122 | | IdentityToken identity_token_; |
123 | | //! |
124 | | PermissionsToken permissions_token_; |
125 | | //! |
126 | | security::ParticipantSecurityAttributesMask security_attributes_; |
127 | | //! |
128 | | security::PluginParticipantSecurityAttributesMask plugin_security_attributes_; |
129 | | #endif // if HAVE_SECURITY |
130 | | //! |
131 | | bool isAlive; |
132 | | //! |
133 | | ParameterPropertyList_t m_properties; |
134 | | //! |
135 | | UserDataQosPolicy m_userData; |
136 | | //! |
137 | | TimedEvent* lease_duration_event; |
138 | | //! |
139 | | bool should_check_lease_duration; |
140 | | //! |
141 | | ProxyHashTable<ReaderProxyData>* m_readers = nullptr; |
142 | | //! |
143 | | ProxyHashTable<WriterProxyData>* m_writers = nullptr; |
144 | | |
145 | | /** |
146 | | * Update the data. |
147 | | * @param pdata Object to copy the data from |
148 | | * @return True on success |
149 | | */ |
150 | | bool updateData( |
151 | | ParticipantProxyData& pdata); |
152 | | |
153 | | /** |
154 | | * Get the size in bytes of the CDR serialization of this object. |
155 | | * @param include_encapsulation Whether to include the size of the encapsulation info. |
156 | | * @return size in bytes of the CDR serialization. |
157 | | */ |
158 | | uint32_t get_serialized_size( |
159 | | bool include_encapsulation) const; |
160 | | |
161 | | /** |
162 | | * Write as a parameter list on a CDRMessage_t |
163 | | * @return True on success |
164 | | */ |
165 | | bool writeToCDRMessage( |
166 | | CDRMessage_t* msg, |
167 | | bool write_encapsulation); |
168 | | |
169 | | /** |
170 | | * Read the parameter list from a received CDRMessage_t |
171 | | * @return True on success |
172 | | */ |
173 | | bool readFromCDRMessage( |
174 | | CDRMessage_t* msg, |
175 | | bool use_encapsulation, |
176 | | const NetworkFactory& network, |
177 | | bool is_shm_transport_available); |
178 | | |
179 | | //! Clear the data (restore to default state). |
180 | | void clear(); |
181 | | |
182 | | /** |
183 | | * Copy the data from another object. |
184 | | * @param pdata Object to copy the data from |
185 | | */ |
186 | | void copy( |
187 | | const ParticipantProxyData& pdata); |
188 | | |
189 | | /** |
190 | | * Set participant persistent GUID_t |
191 | | * @param guid valid GUID_t |
192 | | */ |
193 | | void set_persistence_guid( |
194 | | const GUID_t& guid); |
195 | | |
196 | | /** |
197 | | * Retrieve participant persistent GUID_t |
198 | | * @return guid persistent GUID_t or c_Guid_Unknown |
199 | | */ |
200 | | GUID_t get_persistence_guid() const; |
201 | | |
202 | | /** |
203 | | * Set participant client server sample identity |
204 | | * @param sid valid SampleIdentity |
205 | | */ |
206 | | void set_sample_identity( |
207 | | const SampleIdentity& sid); |
208 | | |
209 | | /** |
210 | | * Retrieve participant SampleIdentity |
211 | | * @return SampleIdentity |
212 | | */ |
213 | | SampleIdentity get_sample_identity() const; |
214 | | |
215 | | /** |
216 | | * Identifies the participant as client of the given server |
217 | | * @param guid valid backup server GUID |
218 | | */ |
219 | | void set_backup_stamp( |
220 | | const GUID_t& guid); |
221 | | |
222 | | /** |
223 | | * Retrieves BACKUP server stamp. On deserialization hints if lease duration must be enforced |
224 | | * @return GUID |
225 | | */ |
226 | | GUID_t get_backup_stamp() const; |
227 | | |
228 | | void assert_liveliness(); |
229 | | |
230 | | const std::chrono::steady_clock::time_point& last_received_message_tm() const |
231 | 0 | { |
232 | 0 | return last_received_message_tm_; |
233 | 0 | } |
234 | | |
235 | | const std::chrono::microseconds& lease_duration() const |
236 | 0 | { |
237 | 0 | return lease_duration_; |
238 | 0 | } |
239 | | |
240 | | private: |
241 | | |
242 | | //! Store the last timestamp it was received a RTPS message from the remote participant. |
243 | | std::chrono::steady_clock::time_point last_received_message_tm_; |
244 | | |
245 | | //! Remote participant lease duration in microseconds. |
246 | | std::chrono::microseconds lease_duration_; |
247 | | }; |
248 | | |
249 | | } /* namespace rtps */ |
250 | | } /* namespace fastrtps */ |
251 | | } /* namespace eprosima */ |
252 | | |
253 | | #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
254 | | |
255 | | #endif // _FASTDDS_RTPS_BUILTIN_DATA_PARTICIPANTPROXYDATA_H_ |