OpenDDS  Snapshot(2023/04/28-20:55)
ParameterListConverter.cpp
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
9 
10 #include "MessageUtils.h"
11 
12 #include <dds/DCPS/DCPS_Utils.h>
13 #include <dds/DCPS/GuidUtils.h>
14 #include <dds/DCPS/Qos_Helper.h>
15 #include <dds/DCPS/DCPS_Utils.h>
18 
19 #include <cstring>
20 
22 
23 namespace OpenDDS {
24 namespace RTPS {
25 
26 #ifndef OPENDDS_SAFETY_PROFILE
27 using DCPS::operator!=;
28 #endif
29 
30 namespace {
31 
32  void extract_type_info_param(const Parameter& param, XTypes::TypeInformation& type_info)
33  {
34  if (!XTypes::deserialize_type_info(type_info, param.type_information())) {
35  type_info.minimal.typeid_with_size.type_id = XTypes::TypeIdentifier();
36  type_info.complete.typeid_with_size.type_id = XTypes::TypeIdentifier();
37  }
38  }
39 
40  void add_type_info_param(ParameterList& param_list, const XTypes::TypeInformation& type_info)
41  {
42  Parameter param;
43  DDS::OctetSeq seq;
45  DCPS::Encoding encoding = XTypes::get_typeobject_encoding();
46  encoding.skip_sequence_dheader(true);
47  XTypes::serialize_type_info(type_info, seq, &encoding);
48 
49  } else {
50  XTypes::serialize_type_info(type_info, seq);
51  }
52 
53  param.type_information(seq);
54  DCPS::push_back(param_list, param);
55  }
56 
57  void push_back_locator_seq(ParameterList& param_list,
58  const DCPS::LocatorSeq& locator_seq,
59  const ParameterId_t pid)
60  {
61  const CORBA::ULong length = locator_seq.length();
62  for (CORBA::ULong i = 0; i < length; ++i) {
63  Parameter param;
64  param.locator(locator_seq[i]);
65  param._d(pid);
66  DCPS::push_back(param_list, param);
67  }
68  }
69 
70  void push_back_rtps_locator(ParameterList& param_list,
71  const DCPS::TransportLocator& dcps_locator,
72  bool map /*map IPV4 to IPV6 addr*/)
73  {
74  // Convert the tls blob to an RTPS locator seq
75  DCPS::LocatorSeq locators;
76  const DDS::ReturnCode_t result = blob_to_locators(dcps_locator.data, locators);
77  if (result == DDS::RETCODE_OK) {
78  const CORBA::ULong locators_len = locators.length();
79  for (CORBA::ULong i = 0; i < locators_len; ++i) {
80  DCPS::Locator_t& rtps_locator = locators[i];
81  ACE_INET_Addr address;
82  if (locator_to_address(address, rtps_locator, map) == 0) {
83  Parameter param;
84  param.locator(rtps_locator);
85  if (address.is_multicast()) {
86  param._d(PID_MULTICAST_LOCATOR);
87  } else {
88  param._d(PID_UNICAST_LOCATOR);
89  }
90  DCPS::push_back(param_list, param);
91  }
92  }
93  } else {
94  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: push_back_rtps_locator - ")
95  ACE_TEXT("Unable to convert dcps_rtps ")
96  ACE_TEXT("TransportLocator blob to LocatorSeq\n")));
97  }
98  }
99 
100  void push_back_dcps_locator(ParameterList& param_list,
101  const DCPS::TransportLocator& dcps_locator)
102  {
103  Parameter param;
104  param.opendds_locator(dcps_locator);
105  param._d(PID_OPENDDS_LOCATOR);
106  DCPS::push_back(param_list, param);
107  }
108 
109  void append_locators_if_present(DCPS::TransportLocatorSeq& list,
110  const DCPS::LocatorSeq& rtps_udp_locators)
111  {
112  if (rtps_udp_locators.length()) {
113  DCPS::TransportLocator& tl = list[DCPS::grow(list) - 1];
114  tl.transport_type = "rtps_udp";
115  locators_to_blob(rtps_udp_locators, tl.data);
116  }
117  }
118 
120  locator_undefined,
121  locator_complete,
122  locator_address_only,
123  locator_port_only
124  };
125 
126  bool not_default(const DDS::UserDataQosPolicy& qos)
127  {
128  DDS::UserDataQosPolicy def_qos =
129  TheServiceParticipant->initial_UserDataQosPolicy();
130  return qos != def_qos;
131  }
132 
133  bool not_default(const DDS::GroupDataQosPolicy& qos)
134  {
135  DDS::GroupDataQosPolicy def_qos =
136  TheServiceParticipant->initial_GroupDataQosPolicy();
137  return qos != def_qos;
138  }
139 
140  bool not_default(const DDS::TopicDataQosPolicy& qos)
141  {
142  DDS::TopicDataQosPolicy def_qos =
143  TheServiceParticipant->initial_TopicDataQosPolicy();
144  return qos != def_qos;
145  }
146 
147  bool not_default(const DDS::DurabilityQosPolicy& qos)
148  {
149  DDS::DurabilityQosPolicy def_qos =
150  TheServiceParticipant->initial_DurabilityQosPolicy();
151  return qos != def_qos;
152  }
153 
154  bool not_default(const DDS::DurabilityServiceQosPolicy& qos)
155  {
157  TheServiceParticipant->initial_DurabilityServiceQosPolicy();
158  return qos != def_qos;
159  }
160 
161  bool not_default(const DDS::LifespanQosPolicy& qos)
162  {
163  DDS::LifespanQosPolicy def_qos =
164  TheServiceParticipant->initial_LifespanQosPolicy();
165  return qos != def_qos;
166  }
167 
168  bool not_default(const DDS::DeadlineQosPolicy& qos)
169  {
170  DDS::DeadlineQosPolicy def_qos =
171  TheServiceParticipant->initial_DeadlineQosPolicy();
172  return qos != def_qos;
173  }
174 
175  bool not_default(const DDS::LatencyBudgetQosPolicy& qos)
176  {
178  TheServiceParticipant->initial_LatencyBudgetQosPolicy();
179  return qos != def_qos;
180  }
181 
182  bool not_default(const DDS::LivelinessQosPolicy& qos)
183  {
184  DDS::LivelinessQosPolicy def_qos =
185  TheServiceParticipant->initial_LivelinessQosPolicy();
186  return qos != def_qos;
187  }
188 
189  bool not_default(const DDS::OwnershipQosPolicy& qos)
190  {
191  DDS::OwnershipQosPolicy def_qos =
192  TheServiceParticipant->initial_OwnershipQosPolicy();
193  return qos != def_qos;
194  }
195 
196  bool not_default(const DDS::OwnershipStrengthQosPolicy& qos)
197  {
198 #ifdef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
199  ACE_UNUSED_ARG(qos);
200  return false;
201 #else
203  TheServiceParticipant->initial_OwnershipStrengthQosPolicy();
204  return qos != def_qos;
205 #endif
206  }
207 
208  bool not_default(const DDS::DestinationOrderQosPolicy& qos)
209  {
211  TheServiceParticipant->initial_DestinationOrderQosPolicy();
212  return qos != def_qos;
213  }
214 
215  bool not_default(const DDS::PresentationQosPolicy& qos)
216  {
218  TheServiceParticipant->initial_PresentationQosPolicy();
219  return qos != def_qos;
220  }
221 
222  bool not_default(const DDS::PartitionQosPolicy& qos)
223  {
224  DDS::PartitionQosPolicy def_qos =
225  TheServiceParticipant->initial_PartitionQosPolicy();
226  return qos != def_qos;
227  }
228 
229  bool not_default(const DDS::TypeConsistencyEnforcementQosPolicy& qos)
230  {
232  TheServiceParticipant->initial_TypeConsistencyEnforcementQosPolicy();
233  return qos != def_qos;
234  }
235 
236  bool not_default(const DDS::PropertyQosPolicy& qos)
237  {
238  for (unsigned int i = 0; i < qos.value.length(); ++i) {
239  if (qos.value[i].propagate) {
240  return true;
241  }
242  }
243  // binary_value is not sent in the parameter list (DDSSEC12-37)
244  return false;
245  }
246 
247  bool not_default(const DDS::TimeBasedFilterQosPolicy& qos)
248  {
250  TheServiceParticipant->initial_TimeBasedFilterQosPolicy();
251  return qos != def_qos;
252  }
253 
254  bool not_default(const DCPS::ContentFilterProperty_t& cfprop)
255  {
256  return std::strlen(cfprop.filterExpression);
257  }
258 
259  bool not_default(const OpenDDSParticipantFlags_t& flags)
260  {
261  return flags.bits != PFLAGS_EMPTY;
262  }
263 
264  void normalize(DDS::Duration_t& dur)
265  {
266  // Interoperability note:
267  // Some other DDS implementations were observed sending
268  // "infinite" durations using 0xffffffff nanoseconds
269  if (dur.sec == DDS::DURATION_INFINITE_SEC &&
272  }
273  }
274 
275 #ifdef OPENDDS_SECURITY
276  OpenDDS::Security::DiscoveredParticipantDataKind find_data_kind(const ParameterList& param_list)
277  {
278  enum FieldMaskNames {
279  ID_TOKEN_FIELD = 0x01,
280  PERM_TOKEN_FIELD = 0x02,
281  PROPERTY_LIST_FIELD = 0x04,
282  PARTICIPANT_SECURITY_INFO_FIELD = 0x08,
283  IDENTITY_STATUS_TOKEN_FIELD = 0x10,
284  EXTENDED_BUILTIN_ENDPOINTS = 0x20
285  };
286 
287  unsigned char field_mask = 0x00;
288 
289  const CORBA::ULong length = param_list.length();
290  for (CORBA::ULong i = 0; i < length; ++i) {
291  const Parameter& param = param_list[i];
292  switch (param._d()) {
294  field_mask |= ID_TOKEN_FIELD;
295  break;
297  field_mask |= PERM_TOKEN_FIELD;
298  break;
299  case PID_PROPERTY_LIST:
300  field_mask |= PROPERTY_LIST_FIELD;
301  break;
303  field_mask |= PARTICIPANT_SECURITY_INFO_FIELD;
304  break;
306  field_mask |= IDENTITY_STATUS_TOKEN_FIELD;
307  break;
309  field_mask |= EXTENDED_BUILTIN_ENDPOINTS;
310  break;
311  }
312  }
313 
314  if ((field_mask & (ID_TOKEN_FIELD | PERM_TOKEN_FIELD)) == (ID_TOKEN_FIELD | PERM_TOKEN_FIELD)) {
315  if ((field_mask & IDENTITY_STATUS_TOKEN_FIELD) == IDENTITY_STATUS_TOKEN_FIELD) {
317  } else {
319  }
320  }
321 
323  }
324 #endif
325 
326 };
327 
328 namespace ParameterListConverter {
329 
330 // DDS::ParticipantBuiltinTopicData
331 
333  ParameterList& param_list)
334 {
335  if (not_default(pbtd.user_data)) {
336  Parameter param_ud;
337  param_ud.user_data(pbtd.user_data);
338  DCPS::push_back(param_list, param_ud);
339  }
340 
341  return true;
342 }
343 
344 bool from_param_list(const ParameterList& param_list,
346 {
347  pbtd.user_data.value.length(0);
348 
349  const CORBA::ULong length = param_list.length();
350  for (CORBA::ULong i = 0; i < length; ++i) {
351  const Parameter& param = param_list[i];
352  switch (param._d()) {
353  case PID_USER_DATA:
354  pbtd.user_data = param.user_data();
355  break;
356  default:
357  if (param._d() & PIDMASK_INCOMPATIBLE) {
358  return false;
359  }
360  }
361  }
362 
363  return true;
364 }
365 
366 #ifdef OPENDDS_SECURITY
368  ParameterList& param_list)
369 {
370  to_param_list(pbtd.base, param_list);
371 
372  Parameter param_it;
373  param_it.identity_token(pbtd.identity_token);
374  DCPS::push_back(param_list, param_it);
375 
376  Parameter param_pt;
377  param_pt.permissions_token(pbtd.permissions_token);
378  DCPS::push_back(param_list, param_pt);
379 
380  if (not_default(pbtd.property)) {
381  Parameter param_p;
382  param_p.property(pbtd.property);
383  DCPS::push_back(param_list, param_p);
384  }
385 
386  Parameter param_psi;
388  DCPS::push_back(param_list, param_psi);
389 
390  Parameter param_ebe;
392  DCPS::push_back(param_list, param_ebe);
393 
394  return true;
395 }
396 
397 bool from_param_list(const ParameterList& param_list,
399 {
400  if (!from_param_list(param_list, pbtd.base))
401  return false;
402 
405 
406  const CORBA::ULong length = param_list.length();
407  for (CORBA::ULong i = 0; i < length; ++i) {
408  const Parameter& param = param_list[i];
409  switch (param._d()) {
411  pbtd.identity_token = param.identity_token();
412  break;
414  pbtd.permissions_token = param.permissions_token();
415  break;
416  case PID_PROPERTY_LIST:
417  pbtd.property = param.property();
418  break;
421  break;
424  break;
425  default:
426  if (param._d() & PIDMASK_INCOMPATIBLE) {
427  return false;
428  }
429  }
430  }
431 
432  return true;
433 }
434 
436  ParameterList& param_list)
437 {
438  to_param_list(pbtds.base, param_list);
439 
440  Parameter param_ist;
442  DCPS::push_back(param_list, param_ist);
443 
444  return true;
445 }
446 
447 bool from_param_list(const ParameterList& param_list,
449 {
450  if (!from_param_list(param_list, pbtds.base))
451  return false;
452 
453  const CORBA::ULong length = param_list.length();
454  for (CORBA::ULong i = 0; i < length; ++i) {
455  const Parameter& param = param_list[i];
456  switch (param._d()) {
459  break;
460  default:
461  if (param._d() & PIDMASK_INCOMPATIBLE) {
462  return false;
463  }
464  }
465  }
466 
467  return true;
468 }
469 #endif
470 
473  ParameterList& param_list)
474 {
475  Parameter beq_param;
476  beq_param.builtinEndpointQos(proxy.builtinEndpointQos);
477  DCPS::push_back(param_list, beq_param);
478 
479  Parameter pd_param;
480  pd_param.domainId(proxy.domainId);
481  DCPS::push_back(param_list, pd_param);
482 
483  Parameter pv_param;
484  pv_param.version(proxy.protocolVersion);
485  DCPS::push_back(param_list, pv_param);
486 
487  Parameter gp_param;
488  gp_param.guid(DCPS::make_part_guid(proxy.guidPrefix));
489  gp_param._d(PID_PARTICIPANT_GUID);
490  DCPS::push_back(param_list, gp_param);
491 
492  Parameter vid_param;
493  vid_param.vendor(proxy.vendorId);
494  DCPS::push_back(param_list, vid_param);
495 
496  if (proxy.expectsInlineQos) {
497  Parameter eiq_param; // Default is false
498  eiq_param.expects_inline_qos(proxy.expectsInlineQos);
499  DCPS::push_back(param_list, eiq_param);
500  }
501 
502  Parameter abe_param;
505  DCPS::push_back(param_list, abe_param);
506 
507  // Interoperability note:
508  // For interoperability with other DDS implemenations, we'll encode the
509  // availableBuiltinEndpoints as PID_BUILTIN_ENDPOINT_SET in addition to
510  // PID_PARTICIPANT_BUILTIN_ENDPOINTS (above).
511  Parameter be_param;
512  be_param.builtin_endpoints(
514  DCPS::push_back(param_list, be_param);
515 
516 #ifdef OPENDDS_SECURITY
517  Parameter ebe_param;
518  ebe_param.extended_builtin_endpoints(
520  DCPS::push_back(param_list, ebe_param);
521 #endif
522 
523  // Each locator
524  push_back_locator_seq(
525  param_list,
528 
529  push_back_locator_seq(
530  param_list,
533 
534  push_back_locator_seq(
535  param_list,
538 
539  push_back_locator_seq(
540  param_list,
543 
544  Parameter ml_param;
545  ml_param.count(proxy.manualLivelinessCount);
546  DCPS::push_back(param_list, ml_param);
547 
548  if (not_default(proxy.property)) {
549  Parameter param_p;
550  param_p.property(proxy.property);
551  DCPS::push_back(param_list, param_p);
552  }
553 
554  if (not_default(proxy.opendds_participant_flags)) {
555  Parameter param_opf;
557  DCPS::push_back(param_list, param_opf);
558  }
559 
561  Parameter param;
563  DCPS::push_back(param_list, param);
564  }
565 
566  return true;
567 }
568 
569 bool from_param_list(const ParameterList& param_list,
570  ParticipantProxy_t& proxy)
571 {
572  // Start by setting defaults
573  proxy.availableBuiltinEndpoints = 0;
574 #ifdef OPENDDS_SECURITY
576 #endif
577  proxy.expectsInlineQos = false;
580 
581  const CORBA::ULong length = param_list.length();
582  for (CORBA::ULong i = 0; i < length; ++i) {
583  const Parameter& param = param_list[i];
584  switch (param._d()) {
586  proxy.builtinEndpointQos = param.builtinEndpointQos();
587  break;
588  case PID_DOMAIN_ID:
589  proxy.domainId = param.domainId();
590  break;
592  proxy.protocolVersion = param.version();
593  break;
596  param.guid().guidPrefix, sizeof(GuidPrefix_t));
597  break;
598  case PID_VENDORID:
600  param.vendor().vendorId, sizeof(OctetArray2));
601  break;
603  proxy.expectsInlineQos =
604  param.expects_inline_qos();
605  break;
609  break;
611  // Interoperability note:
612  // OpenSplice uses this in place of PID_PARTICIPANT_BUILTIN_ENDPOINTS
613  // Table 9.13 indicates that PID_PARTICIPANT_BUILTIN_ENDPOINTS should be
614  // used to represent ParticipantProxy::availableBuiltinEndpoints
616  param.builtin_endpoints();
617  break;
618 #ifdef OPENDDS_SECURITY
622  break;
623 #endif
627  param.locator());
628  break;
632  param.locator());
633  break;
637  param.locator());
638  break;
642  param.locator());
643  break;
646  param.count().value;
647  break;
648  case PID_PROPERTY_LIST:
649  proxy.property = param.property();
650  break;
653  break;
656  break;
657  case PID_SENTINEL:
658  case PID_PAD:
659  // ignore
660  break;
661  default:
662  if (param._d() & PIDMASK_INCOMPATIBLE) {
663  return false;
664  }
665  }
666  }
667 
668  return true;
669 }
670 
671 // OpenDDS::RTPS::Duration_t
672 
674 bool to_param_list(const Duration_t& duration,
675  ParameterList& param_list)
676 {
677  if ((duration.seconds != 100) ||
678  (duration.fraction != 0)) {
679  Parameter ld_param;
680  ld_param.duration(duration);
681  DCPS::push_back(param_list, ld_param);
682  }
683 
684  return true;
685 }
686 
688 bool from_param_list(const ParameterList& param_list,
689  Duration_t& duration)
690 {
691  duration.seconds = 100;
692  duration.fraction = 0;
693 
694  const CORBA::ULong length = param_list.length();
695  for (CORBA::ULong i = 0; i < length; ++i) {
696  const Parameter& param = param_list[i];
697  switch (param._d()) {
699  duration = param.duration();
700  break;
701  default:
702  if (param._d() & PIDMASK_INCOMPATIBLE) {
703  return false;
704  }
705  }
706  }
707  return true;
708 }
709 
710 // OpenDDS::RTPS::SPDPdiscoveredParticipantData
711 
713 bool to_param_list(const SPDPdiscoveredParticipantData& participant_data,
714  ParameterList& param_list)
715 {
716  to_param_list(participant_data.ddsParticipantData, param_list);
717  to_param_list(participant_data.participantProxy, param_list);
718  to_param_list(participant_data.leaseDuration, param_list);
719 
720  return true;
721 }
722 
723 bool from_param_list(const ParameterList& param_list,
724  SPDPdiscoveredParticipantData& participant_data)
725 {
726  bool result = from_param_list(param_list, participant_data.ddsParticipantData);
727  if (result) {
728  result = from_param_list(param_list, participant_data.participantProxy);
729  if (result) {
730  result = from_param_list(param_list, participant_data.leaseDuration);
731  }
732  }
733 
734  return result;
735 }
736 
737 #ifdef OPENDDS_SECURITY
739  ParameterList& param_list)
740 {
741  if (participant_data.dataKind == OpenDDS::Security::DPDK_SECURE) {
742  to_param_list(participant_data.ddsParticipantDataSecure, param_list);
743  } else if (participant_data.dataKind == OpenDDS::Security::DPDK_ENHANCED) {
744  to_param_list(participant_data.ddsParticipantDataSecure.base, param_list);
745  } else {
746  to_param_list(participant_data.ddsParticipantDataSecure.base.base, param_list);
747  }
748 
749  to_param_list(participant_data.participantProxy, param_list);
750  to_param_list(participant_data.leaseDuration, param_list);
751 
752  return true;
753 }
754 
755 bool from_param_list(const ParameterList& param_list,
757 {
758  bool result = false;
759 
760  participant_data.dataKind = find_data_kind(param_list);
761  switch (participant_data.dataKind) {
763  result = from_param_list(param_list, participant_data.ddsParticipantDataSecure);
764  break;
765  }
767  result = from_param_list(param_list, participant_data.ddsParticipantDataSecure.base);
768  break;
769  }
770  default: {
771  result = from_param_list(param_list, participant_data.ddsParticipantDataSecure.base.base);
772  break;
773  }
774  }
775 
776  if (result) {
777  result = from_param_list(param_list, participant_data.participantProxy);
778  if (result) {
779  result = from_param_list(param_list, participant_data.leaseDuration);
780  }
781  }
782 
783  return result;
784 }
785 #endif
786 
787 // OpenDDS::DCPS::DiscoveredWriterData
788 
790 {
792  dr_qos.value = ids;
794  if (dr_qos.value.length() != 1 || dr_qos.value[0] != DDS::XCDR_DATA_REPRESENTATION) {
795  Parameter param;
796  param.representation(dr_qos);
797  DCPS::push_back(param_list, param);
798  }
799 }
800 
802  ParameterList& param_list,
803  bool use_xtypes,
804  const XTypes::TypeInformation& type_info,
805  bool map)
806 {
807  // Ignore builtin topic key
808 
809  {
810  Parameter param;
811  param.string_data(writer_data.ddsPublicationData.topic_name);
812  param._d(PID_TOPIC_NAME);
813  DCPS::push_back(param_list, param);
814  }
815 
816  {
817  Parameter param;
818  param.string_data(writer_data.ddsPublicationData.type_name);
819  param._d(PID_TYPE_NAME);
820  DCPS::push_back(param_list, param);
821  }
822 
823  if (use_xtypes) {
824  add_type_info_param(param_list, type_info);
825  }
826 
827  if (not_default(writer_data.ddsPublicationData.durability)) {
828  Parameter param;
829  param.durability(writer_data.ddsPublicationData.durability);
830  DCPS::push_back(param_list, param);
831  }
832 
833  if (not_default(writer_data.ddsPublicationData.durability_service)) {
834  Parameter param;
835  param.durability_service(writer_data.ddsPublicationData.durability_service);
836  DCPS::push_back(param_list, param);
837  }
838 
839  if (not_default(writer_data.ddsPublicationData.deadline)) {
840  Parameter param;
841  param.deadline(writer_data.ddsPublicationData.deadline);
842  DCPS::push_back(param_list, param);
843  }
844 
845  if (not_default(writer_data.ddsPublicationData.latency_budget)) {
846  Parameter param;
847  param.latency_budget(writer_data.ddsPublicationData.latency_budget);
848  DCPS::push_back(param_list, param);
849  }
850 
851  if (not_default(writer_data.ddsPublicationData.liveliness)) {
852  Parameter param;
853  param.liveliness(writer_data.ddsPublicationData.liveliness);
854  DCPS::push_back(param_list, param);
855  }
856 
857  // Interoperability note:
858  // For interoperability, always write the reliability info
859  {
860  Parameter param;
861  ReliabilityQosPolicyRtps reliability;
862  reliability.max_blocking_time = writer_data.ddsPublicationData.reliability.max_blocking_time;
863 
864  if (writer_data.ddsPublicationData.reliability.kind == DDS::BEST_EFFORT_RELIABILITY_QOS) {
865  reliability.kind.value = RTPS::BEST_EFFORT;
866  } else { // default to RELIABLE for writers
867  reliability.kind.value = RTPS::RELIABLE;
868  }
869 
870  param.reliability(reliability);
871  DCPS::push_back(param_list, param);
872  }
873 
874  if (not_default(writer_data.ddsPublicationData.lifespan)) {
875  Parameter param;
876  param.lifespan(writer_data.ddsPublicationData.lifespan);
877  DCPS::push_back(param_list, param);
878  }
879 
880  if (not_default(writer_data.ddsPublicationData.user_data)) {
881  Parameter param;
882  param.user_data(writer_data.ddsPublicationData.user_data);
883  DCPS::push_back(param_list, param);
884  }
885 
886  if (not_default(writer_data.ddsPublicationData.ownership)) {
887  Parameter param;
888  param.ownership(writer_data.ddsPublicationData.ownership);
889  DCPS::push_back(param_list, param);
890  }
891 
892  if (not_default(writer_data.ddsPublicationData.ownership_strength)) {
893  Parameter param;
894  param.ownership_strength(writer_data.ddsPublicationData.ownership_strength);
895  DCPS::push_back(param_list, param);
896  }
897 
898  if (not_default(writer_data.ddsPublicationData.destination_order)) {
899  Parameter param;
900  param.destination_order(writer_data.ddsPublicationData.destination_order);
901  DCPS::push_back(param_list, param);
902  }
903 
904  if (not_default(writer_data.ddsPublicationData.presentation)) {
905  Parameter param;
906  param.presentation(writer_data.ddsPublicationData.presentation);
907  DCPS::push_back(param_list, param);
908  }
909 
910  if (not_default(writer_data.ddsPublicationData.partition)) {
911  Parameter param;
912  param.partition(writer_data.ddsPublicationData.partition);
913  DCPS::push_back(param_list, param);
914  }
915 
916  if (not_default(writer_data.ddsPublicationData.topic_data)) {
917  Parameter param;
918  param.topic_data(writer_data.ddsPublicationData.topic_data);
919  DCPS::push_back(param_list, param);
920  }
921 
922  if (not_default(writer_data.ddsPublicationData.group_data)) {
923  Parameter param;
924  param.group_data(writer_data.ddsPublicationData.group_data);
925  DCPS::push_back(param_list, param);
926  }
927 
928  add_DataRepresentationQos(param_list, writer_data.ddsPublicationData.representation.value);
929 
930  {
931  Parameter param;
932  param.guid(writer_data.writerProxy.remoteWriterGuid);
933  param._d(PID_ENDPOINT_GUID);
934  DCPS::push_back(param_list, param);
935  }
936  const CORBA::ULong locator_len = writer_data.writerProxy.allLocators.length();
937 
938  // Serialize from allLocators, rather than the unicastLocatorList
939  // and multicastLocatorList. This allows OpenDDS transports to be
940  // serialized in the proper order using custom PIDs.
941  for (CORBA::ULong i = 0; i < locator_len; ++i) {
942  // Each locator has a blob of interest
943  const DCPS::TransportLocator& tl = writer_data.writerProxy.allLocators[i];
944  // If this is an rtps udp transport
945  if (!std::strcmp(tl.transport_type, "rtps_udp")) {
946  // Append the locator's deserialized locator and an RTPS PID
947  push_back_rtps_locator(param_list, tl, map);
948  // Otherwise, this is an OpenDDS, custom transport
949  } else {
950  // Append the blob and a custom PID
951  push_back_dcps_locator(param_list, tl);
952  if (!std::strcmp(tl.transport_type, "multicast")
954  ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: ParameterListConverter::to_param_list(dwd): "
955  "Multicast transport with RTPS discovery has known issues\n"));
956  }
957  }
958  }
959 
960  return true;
961 }
962 
963 bool from_param_list(const ParameterList& param_list,
964  DCPS::DiscoveredWriterData& writer_data,
965  bool use_xtypes,
966  XTypes::TypeInformation& type_info)
967 {
968  // Collect the rtps_udp locators before appending them to allLocators
969  DCPS::LocatorSeq rtps_udp_locators;
970 
971  // Start by setting defaults
972  writer_data.ddsPublicationData.topic_name = "";
973  writer_data.ddsPublicationData.type_name = "";
974  writer_data.ddsPublicationData.durability =
975  TheServiceParticipant->initial_DurabilityQosPolicy();
976  writer_data.ddsPublicationData.durability_service =
977  TheServiceParticipant->initial_DurabilityServiceQosPolicy();
978  writer_data.ddsPublicationData.deadline =
979  TheServiceParticipant->initial_DeadlineQosPolicy();
980  writer_data.ddsPublicationData.latency_budget =
981  TheServiceParticipant->initial_LatencyBudgetQosPolicy();
982  writer_data.ddsPublicationData.liveliness =
983  TheServiceParticipant->initial_LivelinessQosPolicy();
984  writer_data.ddsPublicationData.reliability =
985  TheServiceParticipant->initial_DataWriterQos().reliability;
986  writer_data.ddsPublicationData.lifespan =
987  TheServiceParticipant->initial_LifespanQosPolicy();
988  writer_data.ddsPublicationData.user_data =
989  TheServiceParticipant->initial_UserDataQosPolicy();
990  writer_data.ddsPublicationData.ownership =
991  TheServiceParticipant->initial_OwnershipQosPolicy();
992 #ifdef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
993  writer_data.ddsPublicationData.ownership_strength.value = 0;
994 #else
995  writer_data.ddsPublicationData.ownership_strength =
996  TheServiceParticipant->initial_OwnershipStrengthQosPolicy();
997 #endif
998  writer_data.ddsPublicationData.destination_order =
999  TheServiceParticipant->initial_DestinationOrderQosPolicy();
1000  writer_data.ddsPublicationData.presentation =
1001  TheServiceParticipant->initial_PresentationQosPolicy();
1002  writer_data.ddsPublicationData.partition =
1003  TheServiceParticipant->initial_PartitionQosPolicy();
1004  writer_data.ddsPublicationData.topic_data =
1005  TheServiceParticipant->initial_TopicDataQosPolicy();
1006  writer_data.ddsPublicationData.group_data =
1007  TheServiceParticipant->initial_GroupDataQosPolicy();
1008  writer_data.ddsPublicationData.representation.value.length(1);
1009  writer_data.ddsPublicationData.representation.value[0] = DDS::XCDR_DATA_REPRESENTATION;
1010 
1011  const CORBA::ULong length = param_list.length();
1012  for (CORBA::ULong i = 0; i < length; ++i) {
1013  const Parameter& param = param_list[i];
1014  switch (param._d()) {
1015  case PID_TOPIC_NAME:
1016  writer_data.ddsPublicationData.topic_name = param.string_data();
1017  break;
1018  case PID_TYPE_NAME:
1019  writer_data.ddsPublicationData.type_name = param.string_data();
1020  break;
1021  case PID_DURABILITY:
1022  writer_data.ddsPublicationData.durability = param.durability();
1023  break;
1025  writer_data.ddsPublicationData.durability_service =
1026  param.durability_service();
1027  // Interoperability note: calling normalize() shouldn't be required
1028  normalize(writer_data.ddsPublicationData.durability_service.service_cleanup_delay);
1029  break;
1030  case PID_DEADLINE:
1031  writer_data.ddsPublicationData.deadline = param.deadline();
1032  // Interoperability note: calling normalize() shouldn't be required
1033  normalize(writer_data.ddsPublicationData.deadline.period);
1034  break;
1035  case PID_LATENCY_BUDGET:
1036  writer_data.ddsPublicationData.latency_budget = param.latency_budget();
1037  // Interoperability note: calling normalize() shouldn't be required
1038  normalize(writer_data.ddsPublicationData.latency_budget.duration);
1039  break;
1040  case PID_LIVELINESS:
1041  writer_data.ddsPublicationData.liveliness = param.liveliness();
1042  // Interoperability note: calling normalize() shouldn't be required
1043  normalize(writer_data.ddsPublicationData.liveliness.lease_duration);
1044  break;
1045  case PID_RELIABILITY:
1046  writer_data.ddsPublicationData.reliability.max_blocking_time = param.reliability().max_blocking_time;
1047  // Interoperability note:
1048  // Spec creators for RTPS have reliability indexed at 1
1049  {
1050  if (param.reliability().kind.value == RTPS::BEST_EFFORT) {
1051  writer_data.ddsPublicationData.reliability.kind = DDS::BEST_EFFORT_RELIABILITY_QOS;
1052  } else { // default to RELIABLE for writers
1053  writer_data.ddsPublicationData.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
1054  }
1055  }
1056  normalize(writer_data.ddsPublicationData.reliability.max_blocking_time);
1057  break;
1058  case PID_LIFESPAN:
1059  writer_data.ddsPublicationData.lifespan = param.lifespan();
1060  // Interoperability note: calling normalize() shouldn't be required
1061  normalize(writer_data.ddsPublicationData.lifespan.duration);
1062  break;
1063  case PID_USER_DATA:
1064  writer_data.ddsPublicationData.user_data = param.user_data();
1065  break;
1066  case PID_OWNERSHIP:
1067  writer_data.ddsPublicationData.ownership = param.ownership();
1068  break;
1070  writer_data.ddsPublicationData.ownership_strength = param.ownership_strength();
1071  break;
1072  case PID_DESTINATION_ORDER:
1073  writer_data.ddsPublicationData.destination_order = param.destination_order();
1074  break;
1075  case PID_PRESENTATION:
1076  writer_data.ddsPublicationData.presentation = param.presentation();
1077  break;
1078  case PID_PARTITION:
1079  writer_data.ddsPublicationData.partition = param.partition();
1080  break;
1081  case PID_TOPIC_DATA:
1082  writer_data.ddsPublicationData.topic_data = param.topic_data();
1083  break;
1084  case PID_GROUP_DATA:
1085  writer_data.ddsPublicationData.group_data = param.group_data();
1086  break;
1088  if (param.representation().value.length() != 0) {
1089  writer_data.ddsPublicationData.representation = param.representation();
1090  }
1091  break;
1092  case PID_ENDPOINT_GUID:
1093  writer_data.writerProxy.remoteWriterGuid = param.guid();
1094  break;
1095  case PID_UNICAST_LOCATOR:
1096  DCPS::push_back(rtps_udp_locators, param.locator());
1097  break;
1098  case PID_MULTICAST_LOCATOR:
1099  DCPS::push_back(rtps_udp_locators, param.locator());
1100  break;
1101  case PID_OPENDDS_LOCATOR:
1102  // Append the rtps_udp_locators, if any, first, to preserve order
1103  append_locators_if_present(writer_data.writerProxy.allLocators,
1104  rtps_udp_locators);
1105  rtps_udp_locators.length(0);
1107  param.opendds_locator());
1108  break;
1109  case PID_SENTINEL:
1110  case PID_PAD:
1111  // ignore
1112  break;
1114  if (use_xtypes) {
1115  extract_type_info_param(param, type_info);
1116  }
1117  break;
1118  default:
1119  if (param._d() & PIDMASK_INCOMPATIBLE) {
1120  return false;
1121  }
1122  }
1123  }
1124  // Append additional rtps_udp_locators, if any
1125  append_locators_if_present(writer_data.writerProxy.allLocators,
1126  rtps_udp_locators);
1127  rtps_udp_locators.length(0);
1128  return true;
1129 }
1130 
1131 // OpenDDS::DCPS::DiscoveredReaderData
1132 
1134  ParameterList& param_list,
1135  bool use_xtypes,
1136  const XTypes::TypeInformation& type_info,
1137  bool map)
1138 {
1139  // Ignore builtin topic key
1140  {
1141  Parameter param;
1142  param.string_data(reader_data.ddsSubscriptionData.topic_name);
1143  param._d(PID_TOPIC_NAME);
1144  DCPS::push_back(param_list, param);
1145  }
1146 
1147  if (use_xtypes) {
1148  add_type_info_param(param_list, type_info);
1149  }
1150 
1151  {
1152  Parameter param;
1153  param.string_data(reader_data.ddsSubscriptionData.type_name);
1154  param._d(PID_TYPE_NAME);
1155  DCPS::push_back(param_list, param);
1156  }
1157 
1158  if (not_default(reader_data.ddsSubscriptionData.durability)) {
1159  Parameter param;
1160  param.durability(reader_data.ddsSubscriptionData.durability);
1161  DCPS::push_back(param_list, param);
1162  }
1163 
1164  if (not_default(reader_data.ddsSubscriptionData.deadline)) {
1165  Parameter param;
1166  param.deadline(reader_data.ddsSubscriptionData.deadline);
1167  DCPS::push_back(param_list, param);
1168  }
1169 
1170  if (not_default(reader_data.ddsSubscriptionData.latency_budget)) {
1171  Parameter param;
1172  param.latency_budget(reader_data.ddsSubscriptionData.latency_budget);
1173  DCPS::push_back(param_list, param);
1174  }
1175 
1176  if (not_default(reader_data.ddsSubscriptionData.liveliness)) {
1177  Parameter param;
1178  param.liveliness(reader_data.ddsSubscriptionData.liveliness);
1179  DCPS::push_back(param_list, param);
1180  }
1181 
1182  // Interoperability note:
1183  // For interoperability, always write the reliability info
1184  // if (not_default(reader_data.ddsSubscriptionData.reliability, false))
1185  {
1186  Parameter param;
1187  ReliabilityQosPolicyRtps reliability;
1188  reliability.max_blocking_time = reader_data.ddsSubscriptionData.reliability.max_blocking_time;
1189 
1190  if (reader_data.ddsSubscriptionData.reliability.kind == DDS::RELIABLE_RELIABILITY_QOS) {
1191  reliability.kind.value = RTPS::RELIABLE;
1192  } else { // default to BEST_EFFORT for readers
1193  reliability.kind.value = RTPS::BEST_EFFORT;
1194  }
1195 
1196  param.reliability(reliability);
1197  DCPS::push_back(param_list, param);
1198  }
1199 
1200  if (not_default(reader_data.ddsSubscriptionData.ownership)) {
1201  Parameter param;
1202  param.ownership(reader_data.ddsSubscriptionData.ownership);
1203  DCPS::push_back(param_list, param);
1204  }
1205 
1206  if (not_default(reader_data.ddsSubscriptionData.destination_order)) {
1207  Parameter param;
1208  param.destination_order(reader_data.ddsSubscriptionData.destination_order);
1209  DCPS::push_back(param_list, param);
1210  }
1211 
1212  if (not_default(reader_data.ddsSubscriptionData.user_data)) {
1213  Parameter param;
1214  param.user_data(reader_data.ddsSubscriptionData.user_data);
1215  DCPS::push_back(param_list, param);
1216  }
1217 
1218  if (not_default(reader_data.ddsSubscriptionData.time_based_filter)) {
1219  Parameter param;
1220  param.time_based_filter(reader_data.ddsSubscriptionData.time_based_filter);
1221  DCPS::push_back(param_list, param);
1222  }
1223 
1224  if (not_default(reader_data.ddsSubscriptionData.presentation)) {
1225  Parameter param;
1226  param.presentation(reader_data.ddsSubscriptionData.presentation);
1227  DCPS::push_back(param_list, param);
1228  }
1229 
1230  if (not_default(reader_data.ddsSubscriptionData.partition)) {
1231  Parameter param;
1232  param.partition(reader_data.ddsSubscriptionData.partition);
1233  DCPS::push_back(param_list, param);
1234  }
1235 
1236  if (not_default(reader_data.ddsSubscriptionData.topic_data)) {
1237  Parameter param;
1238  param.topic_data(reader_data.ddsSubscriptionData.topic_data);
1239  DCPS::push_back(param_list, param);
1240  }
1241 
1242  if (not_default(reader_data.ddsSubscriptionData.group_data)) {
1243  Parameter param;
1244  param.group_data(reader_data.ddsSubscriptionData.group_data);
1245  DCPS::push_back(param_list, param);
1246  }
1247 
1248  add_DataRepresentationQos(param_list, reader_data.ddsSubscriptionData.representation.value);
1249 
1250  if (not_default(reader_data.ddsSubscriptionData.type_consistency)) {
1251  Parameter param;
1252  param.type_consistency(reader_data.ddsSubscriptionData.type_consistency);
1253  DCPS::push_back(param_list, param);
1254  }
1255 
1256  {
1257  Parameter param;
1258  param.guid(reader_data.readerProxy.remoteReaderGuid);
1259  param._d(PID_ENDPOINT_GUID);
1260  DCPS::push_back(param_list, param);
1261  }
1262 
1263  if (not_default(reader_data.contentFilterProperty)) {
1264  Parameter param;
1265  DCPS::ContentFilterProperty_t cfprop_copy = reader_data.contentFilterProperty;
1266  if (!std::strlen(cfprop_copy.filterClassName)) {
1267  cfprop_copy.filterClassName = "DDSSQL";
1268  }
1269  param.content_filter_property(cfprop_copy);
1270  DCPS::push_back(param_list, param);
1271  }
1272 
1273  CORBA::ULong i;
1274  const CORBA::ULong locator_len = reader_data.readerProxy.allLocators.length();
1275  // Serialize from allLocators, rather than the unicastLocatorList
1276  // and multicastLocatorList. This allows OpenDDS transports to be
1277  // serialized in the proper order using custom PIDs.
1278  for (i = 0; i < locator_len; ++i) {
1279  // Each locator has a blob of interest
1280  const DCPS::TransportLocator& tl = reader_data.readerProxy.allLocators[i];
1281  // If this is an rtps udp transport
1282  if (!std::strcmp(tl.transport_type, "rtps_udp")) {
1283  // Append the locator's deserialized locator and an RTPS PID
1284  push_back_rtps_locator(param_list, tl, map);
1285  // Otherwise, this is an OpenDDS, custom transport
1286  } else {
1287  // Append the blob and a custom PID
1288  push_back_dcps_locator(param_list, tl);
1289  if (!std::strcmp(tl.transport_type, "multicast")
1291  ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: ParameterListConverter::to_param_list(drd): "
1292  "Multicast transport with RTPS discovery has known issues\n"));
1293  }
1294  }
1295  }
1296 
1297  const CORBA::ULong num_associations = reader_data.readerProxy.associatedWriters.length();
1298  for (i = 0; i < num_associations; ++i) {
1299  Parameter param;
1300  param.guid(reader_data.readerProxy.associatedWriters[i]);
1302  DCPS::push_back(param_list, param);
1303  }
1304  return true;
1305 }
1306 
1307 bool from_param_list(const ParameterList& param_list,
1308  DCPS::DiscoveredReaderData& reader_data,
1309  bool use_xtypes,
1310  XTypes::TypeInformation& type_info)
1311 {
1312  // Collect the rtps_udp locators before appending them to allLocators
1313 
1314  DCPS::LocatorSeq rtps_udp_locators;
1315  // Start by setting defaults
1316  reader_data.ddsSubscriptionData.topic_name = "";
1317  reader_data.ddsSubscriptionData.type_name = "";
1318  reader_data.ddsSubscriptionData.durability =
1319  TheServiceParticipant->initial_DurabilityQosPolicy();
1320  reader_data.ddsSubscriptionData.deadline =
1321  TheServiceParticipant->initial_DeadlineQosPolicy();
1322  reader_data.ddsSubscriptionData.latency_budget =
1323  TheServiceParticipant->initial_LatencyBudgetQosPolicy();
1324  reader_data.ddsSubscriptionData.liveliness =
1325  TheServiceParticipant->initial_LivelinessQosPolicy();
1326  reader_data.ddsSubscriptionData.reliability =
1327  TheServiceParticipant->initial_DataReaderQos().reliability;
1328  reader_data.ddsSubscriptionData.ownership =
1329  TheServiceParticipant->initial_OwnershipQosPolicy();
1330  reader_data.ddsSubscriptionData.destination_order =
1331  TheServiceParticipant->initial_DestinationOrderQosPolicy();
1332  reader_data.ddsSubscriptionData.user_data =
1333  TheServiceParticipant->initial_UserDataQosPolicy();
1334  reader_data.ddsSubscriptionData.time_based_filter =
1335  TheServiceParticipant->initial_TimeBasedFilterQosPolicy();
1336  reader_data.ddsSubscriptionData.presentation =
1337  TheServiceParticipant->initial_PresentationQosPolicy();
1338  reader_data.ddsSubscriptionData.partition =
1339  TheServiceParticipant->initial_PartitionQosPolicy();
1340  reader_data.ddsSubscriptionData.topic_data =
1341  TheServiceParticipant->initial_TopicDataQosPolicy();
1342  reader_data.ddsSubscriptionData.group_data =
1343  TheServiceParticipant->initial_GroupDataQosPolicy();
1344  reader_data.ddsSubscriptionData.representation.value.length(1);
1345  reader_data.ddsSubscriptionData.representation.value[0] = DDS::XCDR_DATA_REPRESENTATION;
1346  reader_data.ddsSubscriptionData.type_consistency =
1347  TheServiceParticipant->initial_TypeConsistencyEnforcementQosPolicy();
1348  reader_data.readerProxy.expectsInlineQos = false;
1350  reader_data.contentFilterProperty.relatedTopicName = "";
1351  reader_data.contentFilterProperty.filterClassName = "";
1352  reader_data.contentFilterProperty.filterExpression = "";
1353  reader_data.contentFilterProperty.expressionParameters.length(0);
1354 
1355  const CORBA::ULong length = param_list.length();
1356  for (CORBA::ULong i = 0; i < length; ++i) {
1357  const Parameter& param = param_list[i];
1358  switch (param._d()) {
1359  case PID_TOPIC_NAME:
1360  reader_data.ddsSubscriptionData.topic_name = param.string_data();
1361  break;
1362  case PID_TYPE_NAME:
1363  reader_data.ddsSubscriptionData.type_name = param.string_data();
1364  break;
1365  case PID_DURABILITY:
1366  reader_data.ddsSubscriptionData.durability = param.durability();
1367  break;
1368  case PID_DEADLINE:
1369  reader_data.ddsSubscriptionData.deadline = param.deadline();
1370  // Interoperability note: calling normalize() shouldn't be required
1371  normalize(reader_data.ddsSubscriptionData.deadline.period);
1372  break;
1373  case PID_LATENCY_BUDGET:
1374  reader_data.ddsSubscriptionData.latency_budget = param.latency_budget();
1375  // Interoperability note: calling normalize() shouldn't be required
1376  normalize(reader_data.ddsSubscriptionData.latency_budget.duration);
1377  break;
1378  case PID_LIVELINESS:
1379  reader_data.ddsSubscriptionData.liveliness = param.liveliness();
1380  // Interoperability note: calling normalize() shouldn't be required
1381  normalize(reader_data.ddsSubscriptionData.liveliness.lease_duration);
1382  break;
1383  case PID_RELIABILITY:
1384  reader_data.ddsSubscriptionData.reliability.max_blocking_time = param.reliability().max_blocking_time;
1385  // Interoperability note:
1386  // Spec creators for RTPS have reliability indexed at 1
1387  {
1388  const CORBA::Short rtpsKind = param.reliability().kind.value;
1389  const CORBA::Short OLD_RELIABLE_VALUE = 3;
1390  if (rtpsKind == RTPS::RELIABLE || rtpsKind == OLD_RELIABLE_VALUE) {
1391  reader_data.ddsSubscriptionData.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
1392  } else { // default to BEST_EFFORT for readers
1393  reader_data.ddsSubscriptionData.reliability.kind = DDS::BEST_EFFORT_RELIABILITY_QOS;
1394  }
1395  }
1396  break;
1397  case PID_USER_DATA:
1398  reader_data.ddsSubscriptionData.user_data = param.user_data();
1399  break;
1400  case PID_OWNERSHIP:
1401  reader_data.ddsSubscriptionData.ownership = param.ownership();
1402  break;
1403  case PID_DESTINATION_ORDER:
1404  reader_data.ddsSubscriptionData.destination_order = param.destination_order();
1405  break;
1406  case PID_TIME_BASED_FILTER:
1407  reader_data.ddsSubscriptionData.time_based_filter = param.time_based_filter();
1408  // Interoperability note: calling normalize() shouldn't be required
1409  normalize(reader_data.ddsSubscriptionData.time_based_filter.minimum_separation);
1410  break;
1411  case PID_PRESENTATION:
1412  reader_data.ddsSubscriptionData.presentation = param.presentation();
1413  break;
1414  case PID_PARTITION:
1415  reader_data.ddsSubscriptionData.partition = param.partition();
1416  break;
1417  case PID_TOPIC_DATA:
1418  reader_data.ddsSubscriptionData.topic_data = param.topic_data();
1419  break;
1420  case PID_GROUP_DATA:
1421  reader_data.ddsSubscriptionData.group_data = param.group_data();
1422  break;
1424  if (param.representation().value.length() != 0) {
1425  reader_data.ddsSubscriptionData.representation = param.representation();
1426  }
1427  break;
1429  reader_data.ddsSubscriptionData.type_consistency = param.type_consistency();
1430  break;
1431  case PID_ENDPOINT_GUID:
1432  reader_data.readerProxy.remoteReaderGuid = param.guid();
1433  break;
1434  case PID_UNICAST_LOCATOR:
1435  DCPS::push_back(rtps_udp_locators, param.locator());
1436  break;
1437  case PID_MULTICAST_LOCATOR:
1438  DCPS::push_back(rtps_udp_locators, param.locator());
1439  break;
1441  reader_data.contentFilterProperty = param.content_filter_property();
1442  break;
1443  case PID_OPENDDS_LOCATOR:
1444  // Append the rtps_udp_locators, if any, first, to preserve order
1445  append_locators_if_present(reader_data.readerProxy.allLocators,
1446  rtps_udp_locators);
1447  rtps_udp_locators.length(0);
1449  param.opendds_locator());
1450  break;
1452  DCPS::push_back(reader_data.readerProxy.associatedWriters, param.guid());
1453  break;
1454  case PID_SENTINEL:
1455  case PID_PAD:
1456  // ignore
1457  break;
1459  if (use_xtypes) {
1460  extract_type_info_param(param, type_info);
1461  }
1462  break;
1463  default:
1464  if (param._d() & PIDMASK_INCOMPATIBLE) {
1465  return false;
1466  }
1467  }
1468  }
1469  // Append additional rtps_udp_locators, if any
1470  append_locators_if_present(reader_data.readerProxy.allLocators,
1471  rtps_udp_locators);
1472  rtps_udp_locators.length(0);
1473  return true;
1474 }
1475 
1476 #ifdef OPENDDS_SECURITY
1478  ParameterList& param_list)
1479 {
1480  Parameter param;
1481  param.endpoint_security_info(info);
1482  DCPS::push_back(param_list, param);
1483  return true;
1484 }
1485 
1486 bool from_param_list(const ParameterList& param_list,
1488 {
1491 
1492  const unsigned int len = param_list.length();
1493  for (unsigned int i = 0; i < len; ++i) {
1494  const Parameter& p = param_list[i];
1495  switch (p._d()) {
1497  info = p.endpoint_security_info();
1498  break;
1499  default:
1500  if (p._d() & PIDMASK_INCOMPATIBLE) {
1501  return false;
1502  }
1503  }
1504  }
1505 
1506  return true;
1507 }
1508 
1510  ParameterList& param_list)
1511 {
1512  Parameter param;
1513  param.data_tags(tags);
1514  DCPS::push_back(param_list, param);
1515  return true;
1516 }
1517 
1518 bool from_param_list(const ParameterList& param_list,
1520 {
1521  tags.tags.length(0);
1522 
1523  const unsigned int len = param_list.length();
1524  for (unsigned int i = 0; i < len; ++i) {
1525  const Parameter& p = param_list[i];
1526  switch (p._d()) {
1528  tags = p.data_tags();
1529  break;
1530  default:
1531  if (p._d() & PIDMASK_INCOMPATIBLE) {
1532  return false;
1533  }
1534  }
1535  }
1536 
1537  return true;
1538 }
1539 
1541  ParameterList& param_list,
1542  bool use_xtypes,
1543  const XTypes::TypeInformation& type_info,
1544  bool map)
1545 {
1546  bool result = to_param_list(wrapper.data, param_list, use_xtypes, type_info, map);
1547 
1548  to_param_list(wrapper.security_info, param_list);
1549  to_param_list(wrapper.data_tags, param_list);
1550 
1551  return result;
1552 }
1553 
1554 bool from_param_list(const ParameterList& param_list,
1556  bool use_xtypes,
1557  XTypes::TypeInformation& type_info)
1558 {
1559  bool result = from_param_list(param_list, wrapper.data, use_xtypes, type_info) &&
1560  from_param_list(param_list, wrapper.security_info) &&
1561  from_param_list(param_list, wrapper.data_tags);
1562 
1563  return result;
1564 }
1565 
1567  ParameterList& param_list,
1568  bool use_xtypes,
1569  const XTypes::TypeInformation& type_info,
1570  bool map)
1571 {
1572  bool result = to_param_list(wrapper.data, param_list, use_xtypes, type_info, map);
1573 
1574  to_param_list(wrapper.security_info, param_list);
1575  to_param_list(wrapper.data_tags, param_list);
1576 
1577  return result;
1578 }
1579 
1580 bool from_param_list(const ParameterList& param_list,
1582  bool use_xtypes,
1583  XTypes::TypeInformation& type_info)
1584 {
1585  bool result = from_param_list(param_list, wrapper.data, use_xtypes, type_info) &&
1586  from_param_list(param_list, wrapper.security_info) &&
1587  from_param_list(param_list, wrapper.data_tags);
1588 
1589  return result;
1590 }
1591 
1592 bool to_param_list(const ICE::AgentInfoMap& ai_map,
1593  ParameterList& param_list)
1594 {
1595  for (ICE::AgentInfoMap::const_iterator map_pos = ai_map.begin(), limit = ai_map.end(); map_pos != limit; ++map_pos) {
1596  const ICE::AgentInfo& agent_info = map_pos->second;
1597  IceGeneral_t ice_general;
1598  ice_general.key = map_pos->first.c_str();
1599  ice_general.agent_type = agent_info.type;
1600  ice_general.username = agent_info.username.c_str();
1601  ice_general.password = agent_info.password.c_str();
1602 
1603  Parameter param_general;
1604  param_general.ice_general(ice_general);
1605  DCPS::push_back(param_list, param_general);
1606 
1607  for (ICE::AgentInfo::CandidatesType::const_iterator pos = agent_info.candidates.begin(),
1608  limit = agent_info.candidates.end(); pos != limit; ++pos) {
1609  IceCandidate_t ice_candidate;
1610  ice_candidate.key = map_pos->first.c_str();
1611  address_to_locator(ice_candidate.locator, pos->address);
1612  ice_candidate.foundation = pos->foundation.c_str();
1613  ice_candidate.priority = pos->priority;
1614  ice_candidate.type = pos->type;
1615 
1616  Parameter param;
1617  param.ice_candidate(ice_candidate);
1618  DCPS::push_back(param_list, param);
1619  }
1620  }
1621 
1622  return true;
1623 }
1624 
1625 bool from_param_list(const ParameterList& param_list,
1626  ICE::AgentInfoMap& ai_map)
1627 {
1628  for (CORBA::ULong idx = 0, count = param_list.length(); idx != count; ++idx) {
1629  const Parameter& parameter = param_list[idx];
1630  switch (parameter._d()) {
1631  case PID_OPENDDS_ICE_GENERAL: {
1632  const IceGeneral_t& ice_general = parameter.ice_general();
1633  ICE::AgentInfo& agent_info = ai_map[OPENDDS_STRING(ice_general.key.in())];
1634  agent_info.type = static_cast<ICE::AgentType>(ice_general.agent_type);
1635  agent_info.username = ice_general.username;
1636  agent_info.password = ice_general.password;
1637  break;
1638  }
1640  const IceCandidate_t& ice_candidate = parameter.ice_candidate();
1641  ICE::Candidate candidate;
1642 #if IPV6_V6ONLY
1643  // https://tools.ietf.org/html/rfc8445
1644 
1645  // IPv4-mapped IPv6 addresses SHOULD NOT be included in the
1646  // address candidates unless the application using ICE does not
1647  // support IPv4 (i.e., it is an IPv6-only application
1648  // [RFC4038]).
1649  const bool map_ipv4_to_ipv6 = true;
1650 #else
1651  const bool map_ipv4_to_ipv6 = false;
1652 #endif
1653  if (locator_to_address(candidate.address, ice_candidate.locator, map_ipv4_to_ipv6) != 0) {
1654  return false;
1655  }
1656  candidate.foundation = ice_candidate.foundation;
1657  candidate.priority = ice_candidate.priority;
1658  candidate.type = static_cast<ICE::CandidateType>(ice_candidate.type);
1659  ai_map[OPENDDS_STRING(ice_candidate.key.in())].candidates.push_back(candidate);
1660  break;
1661  }
1662  default:
1663  // Do nothing.
1664  break;
1665  }
1666  }
1667  return true;
1668 }
1669 #endif
1670 
1671 } // ParameterListConverter
1672 } // RTPS
1673 } // OpenDDS
1674 
AgentType type
Definition: Ice.h:75
DDS::PropertyQosPolicy property
Definition: RtpsCore.idl:444
bool from_param_list(const ParameterList &param_list, DDS::ParticipantBuiltinTopicData &pbtd)
DDS::DataRepresentationQosPolicy representation
Definition: RtpsCore.idl:512
DDS::Security::DataTags data_tags
Definition: RtpsCore.idl:478
const ParameterId_t PID_XTYPES_TYPE_INFORMATION
Definition: RtpsCore.idl:310
#define ACE_ERROR(X)
ProtocolVersion_t version
Definition: RtpsCore.idl:396
const ParameterId_t PID_DEADLINE
Definition: RtpsCore.idl:262
const ParameterId_t PID_PROPERTY_LIST
Definition: RtpsCore.idl:292
DCPS::LocatorSeq defaultMulticastLocatorList
Definition: RtpsCore.idl:613
const ParameterId_t PID_TOPIC_DATA
Definition: RtpsCore.idl:259
const Encoding & get_typeobject_encoding()
Definition: TypeObject.cpp:27
const ParameterId_t PID_BUILTIN_ENDPOINT_QOS
Definition: RtpsCore.idl:319
const long DURATION_INFINITE_SEC
Definition: DdsDcpsCore.idl:72
DDS::Security::IdentityStatusToken identity_status_token
Definition: RtpsCore.idl:487
const ParameterId_t PID_PARTICIPANT_GUID
Definition: RtpsCore.idl:289
const ParameterId_t PID_OPENDDS_RTPS_RELAY_APPLICATION_PARTICIPANT
Definition: RtpsCore.idl:344
DDS::Security::PermissionsToken permissions_token
Definition: RtpsCore.idl:475
const short BEST_EFFORT
Definition: RtpsCore.idl:142
const ParameterId_t PID_VENDORID
Definition: RtpsCore.idl:277
void * memcpy(void *t, const void *s, size_t len)
int locator_to_address(ACE_INET_Addr &dest, const DCPS::Locator_t &locator, bool map)
const ParameterId_t PID_EXTENDED_BUILTIN_ENDPOINTS
const ParameterId_t PID_PARTITION
Definition: RtpsCore.idl:273
const ParameterId_t PID_OWNERSHIP_STRENGTH
Definition: RtpsCore.idl:271
ACE_CDR::Short Short
const ParameterId_t PID_OPENDDS_ICE_GENERAL
Definition: RtpsCore.idl:341
DCPS::TransportLocator opendds_locator
Definition: RtpsCore.idl:468
const ParameterId_t PID_DATA_REPRESENTATION
Definition: RtpsCore.idl:304
DDS::GroupDataQosPolicy group_data
Definition: RtpsCore.idl:358
AgentType
Definition: Ice.h:30
BuiltinEndpointQos_t builtinEndpointQos
Definition: RtpsCore.idl:506
const ParameterId_t PID_TIME_BASED_FILTER
Definition: RtpsCore.idl:274
sequence< Locator_t > LocatorSeq
const ParameterId_t PID_DEFAULT_MULTICAST_LOCATOR
Definition: RtpsCore.idl:281
PluginParticipantSecurityAttributesMask plugin_participant_security_attributes
const ParameterId_t PID_SENTINEL
Definition: RtpsCore.idl:254
key GuidPrefix_t guidPrefix
Definition: DdsDcpsGuid.idl:58
sequence< TransportLocator > TransportLocatorSeq
DDS::Security::EndpointSecurityInfo endpoint_security_info
Definition: RtpsCore.idl:481
const DataRepresentationId_t XCDR_DATA_REPRESENTATION
const ParameterId_t PIDMASK_INCOMPATIBLE
Definition: RtpsCore.idl:314
PluginEndpointSecurityAttributesMask plugin_endpoint_security_attributes
DDS::DeadlineQosPolicy deadline
Definition: RtpsCore.idl:366
sequence< DataRepresentationId_t > DataRepresentationIdSeq
boolean opendds_rtps_relay_application_participant
Definition: RtpsCore.idl:618
OpenDDSParticipantFlagsBits_t bits
Definition: RtpsCore.idl:330
DDS::TimeBasedFilterQosPolicy time_based_filter
Definition: RtpsCore.idl:390
IceCandidate_t ice_candidate
Definition: RtpsCore.idl:497
void add_DataRepresentationQos(ParameterList &param_list, const DDS::DataRepresentationIdSeq &ids)
DDS::PublicationBuiltinTopicData ddsPublicationData
void set_reader_effective_data_rep_qos(DDS::DataRepresentationIdSeq &qos)
Definition: DCPS_Utils.cpp:517
const ParameterId_t PID_USER_DATA
Definition: RtpsCore.idl:255
DDS::LivelinessQosPolicy liveliness
Definition: RtpsCore.idl:370
DDS::SubscriptionBuiltinTopicData ddsSubscriptionData
DDS::DurabilityServiceQosPolicy durability_service
Definition: RtpsCore.idl:364
const ParameterId_t PID_PROTOCOL_VERSION
Definition: RtpsCore.idl:276
ACE_INET_Addr address
Definition: Ice.h:46
OpenDDS::RTPS::ParticipantProxy_t participantProxy
DCPS::ContentFilterProperty_t content_filter_property
Definition: RtpsCore.idl:422
const ParameterId_t PID_OPENDDS_ICE_CANDIDATE
Definition: RtpsCore.idl:342
EndpointSecurityAttributesMask endpoint_security_attributes
DCPS::LocatorSeq metatrafficMulticastLocatorList
Definition: RtpsCore.idl:612
OpenDDS_Dcps_Export void address_to_locator(Locator_t &locator, const ACE_INET_Addr &addr)
BuiltinEndpointSet_t builtin_endpoints
Definition: RtpsCore.idl:438
ProtocolVersion_t protocolVersion
Definition: RtpsCore.idl:605
DDS::PartitionQosPolicy partition
Definition: RtpsCore.idl:388
#define OPENDDS_STRING
DDS::Security::ParticipantBuiltinTopicDataSecure ddsParticipantDataSecure
OpenDDSParticipantFlags_t participant_flags
Definition: RtpsCore.idl:432
unsigned short ParameterId_t
Definition: RtpsCore.idl:249
const ParameterId_t PID_DATA_TAGS
const ParameterId_t PID_LIFESPAN
Definition: RtpsCore.idl:266
DDS::DestinationOrderQosPolicy destination_order
Definition: RtpsCore.idl:376
const ParameterId_t PID_METATRAFFIC_MULTICAST_LOCATOR
Definition: RtpsCore.idl:283
DCPS::Locator_t locator
Definition: RtpsCore.idl:407
ParticipantSecurityAttributesMask participant_security_attributes
const ParameterId_t PID_METATRAFFIC_UNICAST_LOCATOR
Definition: RtpsCore.idl:282
const ParameterId_t PID_MULTICAST_LOCATOR
Definition: RtpsCore.idl:279
DDS::PresentationQosPolicy presentation
Definition: RtpsCore.idl:386
ACE_CDR::ULong ULong
const ParameterId_t PID_ENDPOINT_GUID
Definition: RtpsCore.idl:298
const ParameterId_t PID_PERMISSIONS_TOKEN
const ParameterId_t PID_IDENTITY_TOKEN
unsigned long nanosec
Definition: DdsDcpsCore.idl:69
ExtendedBuiltinEndpointSet_t extended_builtin_endpoints
const ParameterId_t PID_EXPECTS_INLINE_QOS
Definition: RtpsCore.idl:284
CandidateType type
Definition: Ice.h:51
DDS::Security::ExtendedBuiltinEndpointSet_t extended_builtin_endpoints
Definition: RtpsCore.idl:490
const ParameterId_t PID_GROUP_DATA
Definition: RtpsCore.idl:258
IceAgentType_t agent_type
Definition: RtpsCore.idl:178
boolean opendds_rtps_relay_application_participant
Definition: RtpsCore.idl:435
#define OpenDDS_Rtps_Export
Definition: rtps_export.h:23
const ParameterId_t PID_CONTENT_FILTER_PROPERTY
Definition: RtpsCore.idl:288
unsigned long fraction
Definition: RtpsCore.idl:106
DDS::ParticipantBuiltinTopicData ddsParticipantData
Definition: RtpsCore.idl:626
void serialize_type_info(const TypeInformation &type_info, T &seq, const DCPS::Encoding *encoding_option=0)
Definition: TypeObject.h:3382
const ParameterId_t PID_XTYPES_TYPE_CONSISTENCY
Definition: RtpsCore.idl:307
const ParameterId_t PID_LIVELINESS
Definition: RtpsCore.idl:264
const ParameterId_t PID_OPENDDS_PARTICIPANT_FLAGS
Definition: RtpsCore.idl:343
std::string username
Definition: Ice.h:77
const ParameterId_t PID_OPENDDS_ASSOCIATED_WRITER
Definition: RtpsCore.idl:340
const ParameterId_t PID_BUILTIN_ENDPOINT_SET
Definition: RtpsCore.idl:291
CandidatesType candidates
Definition: Ice.h:74
DDS::OwnershipStrengthQosPolicy ownership_strength
Definition: RtpsCore.idl:384
DDS::Security::ExtendedBuiltinEndpointSet_t availableExtendedBuiltinEndpoints
Definition: RtpsCore.idl:620
bool deserialize_type_info(TypeInformation &type_info, const T &seq)
Definition: TypeObject.h:3397
DCPS::LocatorSeq metatrafficUnicastLocatorList
Definition: RtpsCore.idl:611
std::string foundation
Definition: Ice.h:48
const short RELIABLE
Definition: RtpsCore.idl:143
const OpenDDSParticipantFlagsBits_t PFLAGS_EMPTY
Definition: RtpsCore.idl:322
Seq::size_type grow(Seq &seq)
Definition: Util.h:151
DDS::LatencyBudgetQosPolicy latency_budget
Definition: RtpsCore.idl:368
const ParameterId_t PID_PARTICIPANT_BUILTIN_ENDPOINTS
Definition: RtpsCore.idl:286
const ParameterId_t PID_RELIABILITY
Definition: RtpsCore.idl:265
const ParameterId_t PID_PAD
Definition: RtpsCore.idl:253
const ParameterId_t PID_DURABILITY
Definition: RtpsCore.idl:260
LM_WARNING
sequence< octet > OctetSeq
Definition: DdsDcpsCore.idl:64
const ParameterId_t PID_OPENDDS_LOCATOR
Definition: RtpsCore.idl:339
const ParameterId_t PID_LATENCY_BUDGET
Definition: RtpsCore.idl:263
DDS::ParticipantBuiltinTopicData base
BuiltinEndpointQos_t builtinEndpointQos
Definition: RtpsCore.idl:610
const ParameterId_t PID_PRESENTATION
Definition: RtpsCore.idl:272
ReliabilityQosPolicyRtps reliability
Definition: RtpsCore.idl:372
const ParameterId_t PID_TOPIC_NAME
Definition: RtpsCore.idl:256
const ParameterId_t PID_IDENTITY_STATUS_TOKEN
octet OctetArray2[2]
Definition: RtpsCore.idl:22
sequence< Parameter > ParameterList
ACE_TEXT("TCP_Factory")
const unsigned long DURATION_INFINITE_NSEC
Definition: DdsDcpsCore.idl:73
OpenDDS_Dcps_Export GUID_t make_part_guid(const GuidPrefix_t &prefix)
Definition: GuidUtils.h:216
DCPS::LocatorSeq defaultUnicastLocatorList
Definition: RtpsCore.idl:614
const ParameterId_t PID_DURABILITY_SERVICE
Definition: RtpsCore.idl:261
const unsigned long TIME_INVALID_NSEC
BuiltinEndpointSet_t availableBuiltinEndpoints
Definition: RtpsCore.idl:609
const ParameterId_t PID_UNICAST_LOCATOR
Definition: RtpsCore.idl:278
void push_back(Seq &seq, const typename Seq::value_type &val)
std::vector-style push_back() for CORBA Sequences
Definition: Util.h:138
DDS::Security::ParticipantSecurityInfo participant_security_info
Definition: RtpsCore.idl:484
OpenDDS_Dcps_Export LogLevel log_level
DCPS::GuidPrefix_t guidPrefix
Definition: RtpsCore.idl:606
IceCandidateType_t type
Definition: RtpsCore.idl:194
const ParameterId_t PID_OWNERSHIP
Definition: RtpsCore.idl:270
OpenDDSParticipantFlags_t opendds_participant_flags
Definition: RtpsCore.idl:617
const ParameterId_t PID_ENDPOINT_SECURITY_INFO
const ParameterId_t PID_DESTINATION_ORDER
Definition: RtpsCore.idl:267
unsigned long participant_builtin_endpoints
Definition: RtpsCore.idl:416
bool is_multicast(void) const
octet GuidPrefix_t[12]
Definition: DdsDcpsGuid.idl:19
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ContentFilterProperty_t contentFilterProperty
bool to_param_list(const DDS::ParticipantBuiltinTopicData &pbtd, ParameterList &param_list)
DDS::DurabilityQosPolicy durability
Definition: RtpsCore.idl:362
string transport_type
The transport type (e.g. tcp or udp)
const ReturnCode_t RETCODE_OK
std::string password
Definition: Ice.h:78
CandidateType
Definition: Ice.h:35
DDS::TypeConsistencyEnforcementQosPolicy type_consistency
Definition: RtpsCore.idl:515
DDS::TopicDataQosPolicy topic_data
Definition: RtpsCore.idl:360
IceGeneral_t ice_general
Definition: RtpsCore.idl:494
DDS::UserDataQosPolicy user_data
Definition: RtpsCore.idl:356
DDS::ReturnCode_t blob_to_locators(const DCPS::TransportBLOB &blob, DCPS::LocatorSeq &locators, bool *requires_inline_qos, unsigned int *pBytesRead)
DataRepresentationIdSeq value
DDS::LifespanQosPolicy lifespan
Definition: RtpsCore.idl:374
DDS::PropertyQosPolicy property
Definition: RtpsCore.idl:616
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
const ParameterId_t PID_TYPE_NAME
Definition: RtpsCore.idl:257
#define TheServiceParticipant
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
const ParameterId_t PID_PARTICIPANT_LEASE_DURATION
Definition: RtpsCore.idl:287
void locators_to_blob(const DCPS::LocatorSeq &locators, DCPS::TransportBLOB &blob)
ACE_UINT32 priority
Definition: Ice.h:50
const ParameterId_t PID_DOMAIN_ID
Definition: RtpsCore.idl:316
DDS::Security::IdentityToken identity_token
Definition: RtpsCore.idl:472
const ParameterId_t PID_PARTICIPANT_SECURITY_INFO
DDS::DomainId_t domainId
Definition: RtpsCore.idl:500
DDS::OctetArray16 address
const ParameterId_t PID_DEFAULT_UNICAST_LOCATOR
Definition: RtpsCore.idl:280
DDS::OwnershipQosPolicy ownership
Definition: RtpsCore.idl:382
const ParameterId_t PID_PARTICIPANT_MANUAL_LIVELINESS_COUNT
Definition: RtpsCore.idl:285
OpenDDS::DCPS::String256 string_data
Definition: RtpsCore.idl:352