ParameterListConverter.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "ParameterListConverter.h"
00009 
00010 #include "dds/DCPS/GuidUtils.h"
00011 #include "dds/DCPS/Qos_Helper.h"
00012 #include "dds/DCPS/Service_Participant.h"
00013 
00014 #include "dds/DCPS/RTPS/BaseMessageUtils.h"
00015 
00016 #if defined(OPENDDS_SECURITY)
00017 #include "dds/DCPS/RTPS/SecurityHelpers.h"
00018 #endif
00019 
00020 #include <cstring>
00021 
00022 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 namespace OpenDDS {
00025 namespace RTPS {
00026 
00027 #ifndef OPENDDS_SAFETY_PROFILE
00028 using DCPS::operator!=;
00029 #endif
00030 
00031 namespace {
00032 
00033   void add_param(ParameterList& param_list, const Parameter& param) {
00034     const CORBA::ULong length = param_list.length();
00035     param_list.length(length + 1);
00036     param_list[length] = param;
00037   }
00038 
00039   void add_param_locator_seq(ParameterList& param_list,
00040                              const DCPS::LocatorSeq& locator_seq,
00041                              const ParameterId_t pid) {
00042     const CORBA::ULong length = locator_seq.length();
00043     for (CORBA::ULong i = 0; i < length; ++i) {
00044       Parameter param;
00045       param.locator(locator_seq[i]);
00046       param._d(pid);
00047       add_param(param_list, param);
00048     }
00049   }
00050 
00051   void add_param_rtps_locator(ParameterList& param_list,
00052                               const DCPS::TransportLocator& dcps_locator,
00053                               bool map /*map IPV4 to IPV6 addr*/) {
00054     // Convert the tls blob to an RTPS locator seq
00055     DCPS::LocatorSeq locators;
00056     DDS::ReturnCode_t result = blob_to_locators(dcps_locator.data, locators);
00057     if (result == DDS::RETCODE_OK) {
00058       const CORBA::ULong locators_len = locators.length();
00059       for (CORBA::ULong i = 0; i < locators_len; ++i) {
00060         DCPS::Locator_t& rtps_locator = locators[i];
00061         ACE_INET_Addr address;
00062         if (locator_to_address(address, rtps_locator, map) == 0) {
00063           Parameter param;
00064           param.locator(rtps_locator);
00065           if (address.is_multicast()) {
00066             param._d(PID_MULTICAST_LOCATOR);
00067           } else {
00068             param._d(PID_UNICAST_LOCATOR);
00069           }
00070           add_param(param_list, param);
00071         }
00072       }
00073     } else {
00074       ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: add_param_rtps_locator - ")
00075                            ACE_TEXT("Unable to convert dcps_rtps ")
00076                            ACE_TEXT("TransportLocator blob to LocatorSeq\n")));
00077     }
00078   }
00079 
00080   void add_param_dcps_locator(ParameterList& param_list,
00081                       const DCPS::TransportLocator& dcps_locator) {
00082     Parameter param;
00083     param.opendds_locator(dcps_locator);
00084     param._d(PID_OPENDDS_LOCATOR);
00085     add_param(param_list, param);
00086   }
00087 
00088   void append_locator(DCPS::LocatorSeq& list, const DCPS::Locator_t& locator) {
00089     const CORBA::ULong length = list.length();
00090     list.length(length + 1);
00091     list[length] = locator;
00092   }
00093 
00094   void append_locator(
00095       DCPS::TransportLocatorSeq& list,
00096       const DCPS::TransportLocator& locator) {
00097     const CORBA::ULong length = list.length();
00098     list.length(length + 1);
00099     list[length] = locator;
00100   }
00101 
00102   void append_locators_if_present(
00103       DCPS::TransportLocatorSeq& list,
00104       const DCPS::LocatorSeq& rtps_udp_locators) {
00105     if (rtps_udp_locators.length()) {
00106       const CORBA::ULong length = list.length();
00107       list.length(length + 1);
00108       list[length].transport_type = "rtps_udp";
00109       locators_to_blob(rtps_udp_locators, list[length].data);
00110     }
00111   }
00112   enum LocatorState {
00113     locator_undefined,
00114     locator_complete,
00115     locator_address_only,
00116     locator_port_only
00117   };
00118 
00119   void append_associated_writer(DCPS::DiscoveredReaderData& reader_data,
00120                                 const Parameter& param)
00121   {
00122     const CORBA::ULong len = reader_data.readerProxy.associatedWriters.length();
00123     reader_data.readerProxy.associatedWriters.length(len + 1);
00124     reader_data.readerProxy.associatedWriters[len] = param.guid();
00125   }
00126 
00127   void set_ipaddress(DCPS::LocatorSeq& locators,
00128                      LocatorState& last_state,
00129                      const unsigned long addr) {
00130     const CORBA::ULong length = locators.length();
00131     // Update last locator if the last state is port only
00132     if (last_state == locator_port_only && length > 0) {
00133       // Update last locator
00134       DCPS::Locator_t& partial = locators[length - 1];
00135       assign(partial.address, addr);
00136       // there is no longer a partially complete locator, set state
00137       last_state = locator_complete;
00138     // Else there is no partially complete locator available
00139     } else {
00140       // initialize and append new locator
00141       DCPS::Locator_t locator;
00142       locator.kind = LOCATOR_KIND_UDPv4;
00143       locator.port = 0;
00144       assign(locator.address, addr);
00145       locators.length(length + 1);
00146       locators[length] = locator;
00147       // there is now a paritally complete locator, set state
00148       last_state = locator_address_only;
00149     }
00150   }
00151 
00152   void set_port(DCPS::LocatorSeq& locators,
00153                 LocatorState& last_state,
00154                 const unsigned long port) {
00155     const CORBA::ULong length = locators.length();
00156     // Update last locator if the last state is address only
00157     if (last_state == locator_address_only && length > 0) {
00158       // Update last locator
00159       DCPS::Locator_t& partial = locators[length - 1];
00160       partial.port = port;
00161       // there is no longer a partially complete locator, set state
00162       last_state = locator_complete;
00163     // Else there is no partially complete locator available
00164     } else {
00165       // initialize and append new locator
00166       DCPS::Locator_t locator;
00167       locator.kind = LOCATOR_KIND_UDPv4;
00168       locator.port = port;
00169       assign(locator.address, 0);
00170       locators.length(length + 1);
00171       locators[length] = locator;
00172       // there is now a paritally complete locator, set state
00173       last_state = locator_port_only;
00174     }
00175   }
00176 
00177   bool not_default(const DDS::UserDataQosPolicy& qos) {
00178     DDS::UserDataQosPolicy def_qos =
00179         TheServiceParticipant->initial_UserDataQosPolicy();
00180     return qos != def_qos;
00181   }
00182   bool not_default(const DDS::GroupDataQosPolicy& qos) {
00183     DDS::GroupDataQosPolicy def_qos =
00184         TheServiceParticipant->initial_GroupDataQosPolicy();
00185     return qos != def_qos;
00186   }
00187   bool not_default(const DDS::TopicDataQosPolicy& qos) {
00188     DDS::TopicDataQosPolicy def_qos =
00189         TheServiceParticipant->initial_TopicDataQosPolicy();
00190     return qos != def_qos;
00191   }
00192   bool not_default(const DDS::DurabilityQosPolicy& qos) {
00193     DDS::DurabilityQosPolicy def_qos =
00194         TheServiceParticipant->initial_DurabilityQosPolicy();
00195     return qos != def_qos;
00196   }
00197   bool not_default(const DDS::DurabilityServiceQosPolicy& qos) {
00198     DDS::DurabilityServiceQosPolicy def_qos =
00199         TheServiceParticipant->initial_DurabilityServiceQosPolicy();
00200     return qos != def_qos;
00201   }
00202   bool not_default(const DDS::LifespanQosPolicy& qos) {
00203     DDS::LifespanQosPolicy def_qos =
00204         TheServiceParticipant->initial_LifespanQosPolicy();
00205     return qos != def_qos;
00206   }
00207   bool not_default(const DDS::DeadlineQosPolicy& qos) {
00208     DDS::DeadlineQosPolicy def_qos =
00209         TheServiceParticipant->initial_DeadlineQosPolicy();
00210     return qos != def_qos;
00211   }
00212   bool not_default(const DDS::LatencyBudgetQosPolicy& qos) {
00213     DDS::LatencyBudgetQosPolicy def_qos =
00214         TheServiceParticipant->initial_LatencyBudgetQosPolicy();
00215     return qos != def_qos;
00216   }
00217   bool not_default(const DDS::LivelinessQosPolicy& qos) {
00218     DDS::LivelinessQosPolicy def_qos =
00219         TheServiceParticipant->initial_LivelinessQosPolicy();
00220     return qos != def_qos;
00221   }
00222   bool not_default(const DDS::OwnershipQosPolicy& qos) {
00223     DDS::OwnershipQosPolicy def_qos =
00224         TheServiceParticipant->initial_OwnershipQosPolicy();
00225     return qos != def_qos;
00226   }
00227   bool not_default(const DDS::OwnershipStrengthQosPolicy& qos) {
00228 #ifdef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00229     ACE_UNUSED_ARG(qos);
00230     return false;
00231 #else
00232     DDS::OwnershipStrengthQosPolicy def_qos =
00233         TheServiceParticipant->initial_OwnershipStrengthQosPolicy();
00234     return qos != def_qos;
00235 #endif
00236   }
00237   bool not_default(const DDS::DestinationOrderQosPolicy& qos) {
00238     DDS::DestinationOrderQosPolicy def_qos =
00239         TheServiceParticipant->initial_DestinationOrderQosPolicy();
00240     return qos != def_qos;
00241   }
00242   bool not_default(const DDS::PresentationQosPolicy& qos) {
00243     DDS::PresentationQosPolicy def_qos =
00244         TheServiceParticipant->initial_PresentationQosPolicy();
00245     return qos != def_qos;
00246   }
00247   bool not_default(const DDS::PartitionQosPolicy& qos) {
00248     DDS::PartitionQosPolicy def_qos =
00249         TheServiceParticipant->initial_PartitionQosPolicy();
00250     return qos != def_qos;
00251   }
00252 
00253 #if defined(OPENDDS_SECURITY)
00254   bool not_default(const DDS::PropertyQosPolicy& qos) {
00255     for (unsigned int i = 0; i < qos.value.length(); ++i) {
00256       if (qos.value[i].propagate) {
00257         return true;
00258       }
00259     }
00260     // binary_value is not sent in the parameter list (DDSSEC12-37)
00261     return false;
00262   }
00263 #endif
00264 
00265   bool not_default(const DDS::TimeBasedFilterQosPolicy& qos)
00266   {
00267     DDS::TimeBasedFilterQosPolicy def_qos =
00268       TheServiceParticipant->initial_TimeBasedFilterQosPolicy();
00269     return qos != def_qos;
00270   }
00271 
00272   bool not_default(const DCPS::ContentFilterProperty_t& cfprop)
00273   {
00274     return std::strlen(cfprop.filterExpression);
00275   }
00276 
00277   void normalize(DDS::Duration_t& dur)
00278   {
00279     // Interoperability note:
00280     // Some other DDS implementations were observed sending
00281     // "infinite" durations using 0xffffffff nanoseconds
00282     if (dur.sec == DDS::DURATION_INFINITE_SEC &&
00283         dur.nanosec == DDS::TIME_INVALID_NSEC) {
00284       dur.nanosec = DDS::DURATION_INFINITE_NSEC;
00285     }
00286   }
00287 
00288   OpenDDS::Security::DiscoveredParticipantDataKind find_data_kind(const ParameterList& param_list)
00289   {
00290     enum FieldMaskNames {
00291       ID_TOKEN_FIELD = 0x01,
00292       PERM_TOKEN_FIELD = 0x02,
00293       PROPERTY_LIST_FIELD = 0x04,
00294       PARTICIPANT_SECURITY_INFO_FIELD = 0x08,
00295       IDENTITY_STATUS_TOKEN_FIELD = 0x10
00296     };
00297 
00298     unsigned char field_mask = 0x00;
00299 
00300     CORBA::ULong length = param_list.length();
00301     for (CORBA::ULong i = 0; i < length; ++i) {
00302       const Parameter& param = param_list[i];
00303       switch (param._d()) {
00304         case DDS::Security::PID_IDENTITY_TOKEN:
00305           field_mask |= ID_TOKEN_FIELD;
00306           break;
00307         case DDS::Security::PID_PERMISSIONS_TOKEN:
00308           field_mask |= PERM_TOKEN_FIELD;
00309           break;
00310         case PID_PROPERTY_LIST:
00311           field_mask |= PROPERTY_LIST_FIELD;
00312           break;
00313         case DDS::Security::PID_PARTICIPANT_SECURITY_INFO:
00314           field_mask |= PARTICIPANT_SECURITY_INFO_FIELD;
00315           break;
00316         case DDS::Security::PID_IDENTITY_STATUS_TOKEN:
00317           field_mask |= IDENTITY_STATUS_TOKEN_FIELD;
00318           break;
00319       }
00320     }
00321 
00322     if ((field_mask & (ID_TOKEN_FIELD | PERM_TOKEN_FIELD)) == (ID_TOKEN_FIELD | PERM_TOKEN_FIELD)) {
00323       if ((field_mask & IDENTITY_STATUS_TOKEN_FIELD) == IDENTITY_STATUS_TOKEN_FIELD) {
00324         return OpenDDS::Security::DPDK_SECURE;
00325       } else {
00326         return OpenDDS::Security::DPDK_ENHANCED;
00327       }
00328     }
00329 
00330     return OpenDDS::Security::DPDK_ORIGINAL;
00331   }
00332 
00333 
00334 };
00335 
00336 namespace ParameterListConverter {
00337 
00338 // DDS::ParticipantBuiltinTopicData
00339 
00340 int to_param_list(const DDS::ParticipantBuiltinTopicData& pbtd,
00341                   ParameterList& param_list)
00342 {
00343   if (not_default(pbtd.user_data))
00344   {
00345     Parameter param_ud;
00346     param_ud.user_data(pbtd.user_data);
00347     add_param(param_list, param_ud);
00348   }
00349 
00350   return 0;
00351 }
00352 
00353 int from_param_list(const ParameterList& param_list,
00354                     DDS::ParticipantBuiltinTopicData& pbtd)
00355 {
00356   pbtd.user_data.value.length(0);
00357 
00358   CORBA::ULong length = param_list.length();
00359   for (CORBA::ULong i = 0; i < length; ++i) {
00360     const Parameter& param = param_list[i];
00361     switch (param._d()) {
00362       case PID_USER_DATA:
00363         pbtd.user_data = param.user_data();
00364         break;
00365       default:
00366         if (param._d() & PIDMASK_INCOMPATIBLE) {
00367           return -1;
00368         }
00369     }
00370   }
00371 
00372   return 0;
00373 }
00374 
00375 #if defined(OPENDDS_SECURITY)
00376 int to_param_list(const DDS::Security::ParticipantBuiltinTopicData& pbtd,
00377                   ParameterList& param_list)
00378 {
00379   to_param_list(pbtd.base, param_list);
00380 
00381   Parameter param_it;
00382   param_it.identity_token(pbtd.identity_token);
00383   add_param(param_list, param_it);
00384 
00385   Parameter param_pt;
00386   param_pt.permissions_token(pbtd.permissions_token);
00387   add_param(param_list, param_pt);
00388 
00389   if (not_default(pbtd.property))
00390   {
00391     Parameter param_p;
00392     param_p.property(pbtd.property);
00393     add_param(param_list, param_p);
00394   }
00395 
00396   Parameter param_psi;
00397   param_psi.participant_security_info(pbtd.security_info);
00398   add_param(param_list, param_psi);
00399 
00400   return 0;
00401 }
00402 
00403 int from_param_list(const ParameterList& param_list,
00404                     DDS::Security::ParticipantBuiltinTopicData& pbtd)
00405 {
00406   if (from_param_list(param_list, pbtd.base) != 0)
00407     return -1;
00408 
00409   pbtd.security_info.participant_security_attributes = 0;
00410   pbtd.security_info.plugin_participant_security_attributes = 0;
00411 
00412   CORBA::ULong length = param_list.length();
00413   for (CORBA::ULong i = 0; i < length; ++i) {
00414     const Parameter& param = param_list[i];
00415     switch (param._d()) {
00416       case DDS::Security::PID_IDENTITY_TOKEN:
00417         pbtd.identity_token = param.identity_token();
00418         break;
00419       case DDS::Security::PID_PERMISSIONS_TOKEN:
00420         pbtd.permissions_token = param.permissions_token();
00421         break;
00422       case PID_PROPERTY_LIST:
00423         pbtd.property = param.property();
00424         break;
00425       case DDS::Security::PID_PARTICIPANT_SECURITY_INFO:
00426         pbtd.security_info = param.participant_security_info();
00427         break;
00428       default:
00429         if (param._d() & PIDMASK_INCOMPATIBLE) {
00430           return -1;
00431         }
00432     }
00433   }
00434 
00435   return 0;
00436 }
00437 
00438 int to_param_list(const DDS::Security::ParticipantBuiltinTopicDataSecure& pbtds,
00439                   ParameterList& param_list)
00440 {
00441   to_param_list(pbtds.base, param_list);
00442 
00443   Parameter param_ist;
00444   param_ist.identity_status_token(pbtds.identity_status_token);
00445   add_param(param_list, param_ist);
00446 
00447   return 0;
00448 }
00449 
00450 int from_param_list(const ParameterList& param_list,
00451                     DDS::Security::ParticipantBuiltinTopicDataSecure& pbtds)
00452 {
00453   if (from_param_list(param_list, pbtds.base) != 0)
00454     return -1;
00455 
00456   CORBA::ULong length = param_list.length();
00457   for (CORBA::ULong i = 0; i < length; ++i) {
00458     const Parameter& param = param_list[i];
00459     switch (param._d()) {
00460       case DDS::Security::PID_IDENTITY_STATUS_TOKEN:
00461         pbtds.identity_status_token = param.identity_status_token();
00462         break;
00463       default:
00464         if (param._d() & PIDMASK_INCOMPATIBLE) {
00465           return -1;
00466         }
00467     }
00468   }
00469 
00470   return 0;
00471 }
00472 #endif
00473 
00474 OpenDDS_Rtps_Export
00475 int to_param_list(const ParticipantProxy_t& proxy,
00476                   ParameterList& param_list)
00477 {
00478   Parameter pv_param;
00479   pv_param.version(proxy.protocolVersion);
00480   add_param(param_list, pv_param);
00481 
00482   // For guid prefix, copy into guid, and force some values
00483   Parameter gp_param;
00484   GUID_t guid;
00485   ACE_OS::memcpy(guid.guidPrefix,
00486                  proxy.guidPrefix,
00487                  sizeof(guid.guidPrefix));
00488   guid.entityId = DCPS::ENTITYID_PARTICIPANT;
00489 
00490   gp_param.guid(guid);
00491   gp_param._d(PID_PARTICIPANT_GUID);
00492   add_param(param_list, gp_param);
00493 
00494   Parameter vid_param;
00495   vid_param.vendor(proxy.vendorId);
00496   add_param(param_list, vid_param);
00497 
00498   if (proxy.expectsInlineQos != false)
00499   {
00500     Parameter eiq_param; // Default is false
00501     eiq_param.expects_inline_qos(
00502         proxy.expectsInlineQos);
00503     add_param(param_list, eiq_param);
00504   }
00505 
00506   Parameter abe_param;
00507   abe_param.participant_builtin_endpoints(
00508     proxy.availableBuiltinEndpoints);
00509   add_param(param_list, abe_param);
00510 
00511   // Interoperability note:
00512   // For interoperability with other DDS implemenations, we'll encode the
00513   // availableBuiltinEndpoints as PID_BUILTIN_ENDPOINT_SET in addition to
00514   // PID_PARTICIPANT_BUILTIN_ENDPOINTS (above).
00515   Parameter be_param;
00516   be_param.builtin_endpoints(
00517     proxy.availableBuiltinEndpoints);
00518   add_param(param_list, be_param);
00519 
00520   // Each locator
00521   add_param_locator_seq(
00522       param_list,
00523       proxy.metatrafficUnicastLocatorList,
00524       PID_METATRAFFIC_UNICAST_LOCATOR);
00525 
00526   add_param_locator_seq(
00527       param_list,
00528       proxy.metatrafficMulticastLocatorList,
00529       PID_METATRAFFIC_MULTICAST_LOCATOR);
00530 
00531   add_param_locator_seq(
00532       param_list,
00533       proxy.defaultUnicastLocatorList,
00534       PID_DEFAULT_UNICAST_LOCATOR);
00535 
00536   add_param_locator_seq(
00537       param_list,
00538       proxy.defaultMulticastLocatorList,
00539       PID_DEFAULT_MULTICAST_LOCATOR);
00540 
00541   Parameter ml_param;
00542   ml_param.count(proxy.manualLivelinessCount);
00543   add_param(param_list, ml_param);
00544 
00545   return 0;
00546 }
00547 
00548 int from_param_list(const ParameterList& param_list,
00549                     ParticipantProxy_t& proxy)
00550 {
00551   // Track the state of our locators
00552   LocatorState du_last_state = locator_undefined;
00553   LocatorState mu_last_state = locator_undefined;
00554   LocatorState mm_last_state = locator_undefined;
00555 
00556   // Start by setting defaults
00557   proxy.availableBuiltinEndpoints = 0;
00558   proxy.expectsInlineQos = false;
00559 
00560   CORBA::ULong length = param_list.length();
00561   for (CORBA::ULong i = 0; i < length; ++i) {
00562     const Parameter& param = param_list[i];
00563     switch (param._d()) {
00564       case PID_PROTOCOL_VERSION:
00565         proxy.protocolVersion = param.version();
00566         break;
00567       case PID_PARTICIPANT_GUID:
00568         ACE_OS::memcpy(proxy.guidPrefix,
00569                param.guid().guidPrefix, sizeof(GuidPrefix_t));
00570         break;
00571       case PID_VENDORID:
00572         ACE_OS::memcpy(proxy.vendorId.vendorId,
00573                param.vendor().vendorId, sizeof(OctetArray2));
00574         break;
00575       case PID_EXPECTS_INLINE_QOS:
00576         proxy.expectsInlineQos =
00577             param.expects_inline_qos();
00578         break;
00579       case PID_PARTICIPANT_BUILTIN_ENDPOINTS:
00580         proxy.availableBuiltinEndpoints =
00581             param.participant_builtin_endpoints();
00582         break;
00583       case PID_BUILTIN_ENDPOINT_SET:
00584         // Interoperability note:
00585         // OpenSplice uses this in place of PID_PARTICIPANT_BUILTIN_ENDPOINTS
00586         // Table 9.13 indicates that PID_PARTICIPANT_BUILTIN_ENDPOINTS should be
00587         // used to represent ParticipantProxy::availableBuiltinEndpoints
00588         proxy.availableBuiltinEndpoints =
00589             param.builtin_endpoints();
00590         break;
00591       case PID_METATRAFFIC_UNICAST_LOCATOR:
00592         append_locator(
00593             proxy.metatrafficUnicastLocatorList,
00594             param.locator());
00595         break;
00596       case PID_METATRAFFIC_MULTICAST_LOCATOR:
00597         append_locator(
00598             proxy.metatrafficMulticastLocatorList,
00599             param.locator());
00600         break;
00601       case PID_DEFAULT_UNICAST_LOCATOR:
00602         append_locator(
00603             proxy.defaultUnicastLocatorList,
00604             param.locator());
00605         break;
00606       case PID_DEFAULT_MULTICAST_LOCATOR:
00607         append_locator(
00608             proxy.defaultMulticastLocatorList,
00609             param.locator());
00610         break;
00611       case PID_PARTICIPANT_MANUAL_LIVELINESS_COUNT:
00612         proxy.manualLivelinessCount.value =
00613             param.count().value;
00614         break;
00615       case PID_DEFAULT_UNICAST_IPADDRESS:
00616         set_ipaddress(
00617           proxy.defaultUnicastLocatorList,
00618           du_last_state,
00619           param.ipv4_address());
00620         break;
00621       case PID_METATRAFFIC_UNICAST_IPADDRESS:
00622         set_ipaddress(
00623           proxy.metatrafficUnicastLocatorList,
00624           mu_last_state,
00625           param.ipv4_address());
00626         break;
00627       case PID_METATRAFFIC_MULTICAST_IPADDRESS:
00628         set_ipaddress(
00629           proxy.metatrafficMulticastLocatorList,
00630           mm_last_state,
00631           param.ipv4_address());
00632         break;
00633       case PID_DEFAULT_UNICAST_PORT:
00634         set_port(proxy.defaultUnicastLocatorList,
00635                  du_last_state,
00636                  param.udpv4_port());
00637         break;
00638       case PID_METATRAFFIC_UNICAST_PORT:
00639         set_port(proxy.metatrafficUnicastLocatorList,
00640                  mu_last_state,
00641                  param.udpv4_port());
00642         break;
00643       case PID_METATRAFFIC_MULTICAST_PORT:
00644         set_port(proxy.metatrafficMulticastLocatorList,
00645                  mm_last_state,
00646                  param.udpv4_port());
00647         break;
00648       case PID_SENTINEL:
00649       case PID_PAD:
00650         // ignore
00651         break;
00652       default:
00653         if (param._d() & PIDMASK_INCOMPATIBLE) {
00654           return -1;
00655         }
00656     }
00657   }
00658 
00659   return 0;
00660 }
00661 
00662 // OpenDDS::RTPS::Duration_t
00663 
00664 OpenDDS_Rtps_Export
00665 int to_param_list(const Duration_t& duration,
00666                   ParameterList& param_list)
00667 {
00668   if ((duration.seconds != 100) ||
00669       (duration.fraction != 0))
00670   {
00671     Parameter ld_param;
00672     ld_param.duration(duration);
00673     add_param(param_list, ld_param);
00674   }
00675 
00676   return 0;
00677 }
00678 
00679 OpenDDS_Rtps_Export
00680 int from_param_list(const ParameterList& param_list,
00681                     Duration_t& duration)
00682 {
00683   duration.seconds = 100;
00684   duration.fraction = 0;
00685 
00686   CORBA::ULong length = param_list.length();
00687   for (CORBA::ULong i = 0; i < length; ++i) {
00688     const Parameter& param = param_list[i];
00689     switch (param._d()) {
00690       case PID_PARTICIPANT_LEASE_DURATION:
00691         duration = param.duration();
00692         break;
00693       default:
00694         if (param._d() & PIDMASK_INCOMPATIBLE) {
00695           return -1;
00696         }
00697     }
00698   }
00699   return 0;
00700 }
00701 
00702 // OpenDDS::RTPS::SPDPdiscoveredParticipantData
00703 
00704 OpenDDS_Rtps_Export
00705 int to_param_list(const SPDPdiscoveredParticipantData& participant_data,
00706                   ParameterList& param_list)
00707 {
00708   to_param_list(participant_data.ddsParticipantData, param_list);
00709   to_param_list(participant_data.participantProxy, param_list);
00710   to_param_list(participant_data.leaseDuration, param_list);
00711 
00712   return 0;
00713 }
00714 
00715 int from_param_list(const ParameterList& param_list,
00716                     SPDPdiscoveredParticipantData& participant_data)
00717 {
00718   int result = from_param_list(param_list, participant_data.ddsParticipantData);
00719   if (!result) {
00720     result = from_param_list(param_list, participant_data.participantProxy);
00721     if (!result) {
00722       result = from_param_list(param_list, participant_data.leaseDuration);
00723     }
00724   }
00725 
00726   return result;
00727 }
00728 
00729 int to_param_list(const OpenDDS::Security::SPDPdiscoveredParticipantData& participant_data,
00730                   ParameterList& param_list)
00731 {
00732 
00733 #if defined(OPENDDS_SECURITY)
00734   if (participant_data.dataKind == OpenDDS::Security::DPDK_SECURE) {
00735     to_param_list(participant_data.ddsParticipantDataSecure, param_list);
00736 
00737   } else if (participant_data.dataKind == OpenDDS::Security::DPDK_ENHANCED) {
00738     to_param_list(participant_data.ddsParticipantDataSecure.base, param_list);
00739 
00740   } else {
00741 #endif
00742 
00743     to_param_list(participant_data.ddsParticipantDataSecure.base.base, param_list);
00744 
00745 #if defined(OPENDDS_SECURITY)
00746   }
00747 #endif
00748 
00749   to_param_list(participant_data.participantProxy, param_list);
00750   to_param_list(participant_data.leaseDuration, param_list);
00751 
00752   return 0;
00753 }
00754 
00755 int from_param_list(const ParameterList& param_list,
00756                     OpenDDS::Security::SPDPdiscoveredParticipantData& participant_data)
00757 {
00758   int result = 0;
00759 
00760   participant_data.dataKind = find_data_kind(param_list);
00761   switch (participant_data.dataKind) {
00762 
00763 #if defined(OPENDDS_SECURITY)
00764     case OpenDDS::Security::DPDK_SECURE: {
00765       result = from_param_list(param_list, participant_data.ddsParticipantDataSecure);
00766       break;
00767     }
00768 
00769     case OpenDDS::Security::DPDK_ENHANCED: {
00770       result = from_param_list(param_list, participant_data.ddsParticipantDataSecure.base);
00771       break;
00772     }
00773 #endif
00774 
00775     default : {
00776       result = from_param_list(param_list, participant_data.ddsParticipantDataSecure.base.base);
00777       break;
00778     }
00779   }
00780 
00781   if (!result) {
00782     result = from_param_list(param_list, participant_data.participantProxy);
00783     if (!result) {
00784       result = from_param_list(param_list, participant_data.leaseDuration);
00785     }
00786   }
00787 
00788   return result;
00789 }
00790 
00791 
00792 // OpenDDS::DCPS::DiscoveredWriterData
00793 
00794 int to_param_list(const DCPS::DiscoveredWriterData& writer_data,
00795                   ParameterList& param_list,
00796                   bool map)
00797 {
00798   // Ignore builtin topic key
00799 
00800   {
00801     Parameter param;
00802     param.string_data(writer_data.ddsPublicationData.topic_name);
00803     param._d(PID_TOPIC_NAME);
00804     add_param(param_list, param);
00805   }
00806   {
00807     Parameter param;
00808     param.string_data(writer_data.ddsPublicationData.type_name);
00809     param._d(PID_TYPE_NAME);
00810     add_param(param_list, param);
00811   }
00812 
00813   if (not_default(writer_data.ddsPublicationData.durability))
00814   {
00815     Parameter param;
00816     param.durability(writer_data.ddsPublicationData.durability);
00817     add_param(param_list, param);
00818   }
00819 
00820   if (not_default(writer_data.ddsPublicationData.durability_service))
00821   {
00822     Parameter param;
00823     param.durability_service(writer_data.ddsPublicationData.durability_service);
00824     add_param(param_list, param);
00825   }
00826 
00827   if (not_default(writer_data.ddsPublicationData.deadline))
00828   {
00829     Parameter param;
00830     param.deadline(writer_data.ddsPublicationData.deadline);
00831     add_param(param_list, param);
00832   }
00833 
00834   if (not_default(writer_data.ddsPublicationData.latency_budget))
00835   {
00836     Parameter param;
00837     param.latency_budget(writer_data.ddsPublicationData.latency_budget);
00838     add_param(param_list, param);
00839   }
00840 
00841   if (not_default(writer_data.ddsPublicationData.liveliness))
00842   {
00843     Parameter param;
00844     param.liveliness(writer_data.ddsPublicationData.liveliness);
00845     add_param(param_list, param);
00846   }
00847 
00848   // Interoperability note:
00849   // For interoperability, always write the reliability info
00850   {
00851     Parameter param;
00852     // Interoperability note:
00853     // Spec creators for RTPS have reliability indexed at 1
00854     DDS::ReliabilityQosPolicy reliability_copy =
00855         writer_data.ddsPublicationData.reliability;
00856     reliability_copy.kind =
00857         (DDS::ReliabilityQosPolicyKind)((int)reliability_copy.kind + 1);
00858     param.reliability(reliability_copy);
00859     add_param(param_list, param);
00860   }
00861 
00862   if (not_default(writer_data.ddsPublicationData.lifespan))
00863   {
00864     Parameter param;
00865     param.lifespan(writer_data.ddsPublicationData.lifespan);
00866     add_param(param_list, param);
00867   }
00868 
00869   if (not_default(writer_data.ddsPublicationData.user_data))
00870   {
00871     Parameter param;
00872     param.user_data(writer_data.ddsPublicationData.user_data);
00873     add_param(param_list, param);
00874   }
00875 
00876   if (not_default(writer_data.ddsPublicationData.ownership))
00877   {
00878     Parameter param;
00879     param.ownership(writer_data.ddsPublicationData.ownership);
00880     add_param(param_list, param);
00881   }
00882 
00883   if (not_default(writer_data.ddsPublicationData.ownership_strength))
00884   {
00885     Parameter param;
00886     param.ownership_strength(writer_data.ddsPublicationData.ownership_strength);
00887     add_param(param_list, param);
00888   }
00889 
00890   if (not_default(writer_data.ddsPublicationData.destination_order))
00891   {
00892     Parameter param;
00893     param.destination_order(writer_data.ddsPublicationData.destination_order);
00894     add_param(param_list, param);
00895   }
00896 
00897   if (not_default(writer_data.ddsPublicationData.presentation))
00898   {
00899     Parameter param;
00900     param.presentation(writer_data.ddsPublicationData.presentation);
00901     add_param(param_list, param);
00902   }
00903 
00904   if (not_default(writer_data.ddsPublicationData.partition))
00905   {
00906     Parameter param;
00907     param.partition(writer_data.ddsPublicationData.partition);
00908     add_param(param_list, param);
00909   }
00910 
00911   if (not_default(writer_data.ddsPublicationData.topic_data))
00912   {
00913     Parameter param;
00914     param.topic_data(writer_data.ddsPublicationData.topic_data);
00915     add_param(param_list, param);
00916   }
00917 
00918   if (not_default(writer_data.ddsPublicationData.group_data))
00919   {
00920     Parameter param;
00921     param.group_data(writer_data.ddsPublicationData.group_data);
00922     add_param(param_list, param);
00923   }
00924 
00925   {
00926     Parameter param;
00927     param.guid(writer_data.writerProxy.remoteWriterGuid);
00928     param._d(PID_ENDPOINT_GUID);
00929     add_param(param_list, param);
00930   }
00931   CORBA::ULong locator_len = writer_data.writerProxy.allLocators.length();
00932 
00933   // Serialize from allLocators, rather than the unicastLocatorList
00934   // and multicastLocatorList.  This allows OpenDDS transports to be
00935   // serialized in the proper order using custom PIDs.
00936   for (CORBA::ULong i = 0; i < locator_len; ++i) {
00937     // Each locator has a blob of interest
00938     const DCPS::TransportLocator& tl = writer_data.writerProxy.allLocators[i];
00939     // If this is an rtps udp transport
00940     if (!std::strcmp(tl.transport_type, "rtps_udp")) {
00941       // Append the locator's deserialized locator and an RTPS PID
00942       add_param_rtps_locator(param_list, tl, map);
00943     // Otherwise, this is an OpenDDS, custom transport
00944     } else {
00945       // Append the blob and a custom PID
00946       add_param_dcps_locator(param_list, tl);
00947       if (!std::strcmp(tl.transport_type, "multicast")) {
00948         ACE_DEBUG((LM_WARNING,
00949                    ACE_TEXT("(%P|%t) to_param_list(dwd) - ")
00950                    ACE_TEXT("Multicast transport with RTPS ")
00951                    ACE_TEXT("discovery has known issues")));
00952       }
00953     }
00954   }
00955 
00956   return 0;
00957 }
00958 
00959 int from_param_list(const ParameterList& param_list,
00960                     DCPS::DiscoveredWriterData& writer_data)
00961 {
00962   LocatorState last_state = locator_undefined;  // Track state of locator
00963   // Collect the rtps_udp locators before appending them to allLocators
00964   DCPS::LocatorSeq rtps_udp_locators;
00965 
00966   // Start by setting defaults
00967   writer_data.ddsPublicationData.topic_name = "";
00968   writer_data.ddsPublicationData.type_name  = "";
00969   writer_data.ddsPublicationData.durability =
00970       TheServiceParticipant->initial_DurabilityQosPolicy();
00971   writer_data.ddsPublicationData.durability_service =
00972       TheServiceParticipant->initial_DurabilityServiceQosPolicy();
00973   writer_data.ddsPublicationData.deadline =
00974       TheServiceParticipant->initial_DeadlineQosPolicy();
00975   writer_data.ddsPublicationData.latency_budget =
00976       TheServiceParticipant->initial_LatencyBudgetQosPolicy();
00977   writer_data.ddsPublicationData.liveliness =
00978       TheServiceParticipant->initial_LivelinessQosPolicy();
00979   writer_data.ddsPublicationData.reliability =
00980       TheServiceParticipant->initial_DataWriterQos().reliability;
00981   writer_data.ddsPublicationData.lifespan =
00982       TheServiceParticipant->initial_LifespanQosPolicy();
00983   writer_data.ddsPublicationData.user_data =
00984       TheServiceParticipant->initial_UserDataQosPolicy();
00985   writer_data.ddsPublicationData.ownership =
00986       TheServiceParticipant->initial_OwnershipQosPolicy();
00987 #ifdef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00988   writer_data.ddsPublicationData.ownership_strength.value = 0;
00989 #else
00990   writer_data.ddsPublicationData.ownership_strength =
00991       TheServiceParticipant->initial_OwnershipStrengthQosPolicy();
00992 #endif
00993   writer_data.ddsPublicationData.destination_order =
00994       TheServiceParticipant->initial_DestinationOrderQosPolicy();
00995   writer_data.ddsPublicationData.presentation =
00996       TheServiceParticipant->initial_PresentationQosPolicy();
00997   writer_data.ddsPublicationData.partition =
00998       TheServiceParticipant->initial_PartitionQosPolicy();
00999   writer_data.ddsPublicationData.topic_data =
01000       TheServiceParticipant->initial_TopicDataQosPolicy();
01001   writer_data.ddsPublicationData.group_data =
01002       TheServiceParticipant->initial_GroupDataQosPolicy();
01003   writer_data.writerProxy.unicastLocatorList.length(0);
01004   writer_data.writerProxy.multicastLocatorList.length(0);
01005 
01006   CORBA::ULong length = param_list.length();
01007   for (CORBA::ULong i = 0; i < length; ++i) {
01008     const Parameter& param = param_list[i];
01009     switch (param._d()) {
01010       case PID_TOPIC_NAME:
01011         writer_data.ddsPublicationData.topic_name = param.string_data();
01012         break;
01013       case PID_TYPE_NAME:
01014         writer_data.ddsPublicationData.type_name = param.string_data();
01015         break;
01016       case PID_DURABILITY:
01017         writer_data.ddsPublicationData.durability = param.durability();
01018         break;
01019       case PID_DURABILITY_SERVICE:
01020         writer_data.ddsPublicationData.durability_service =
01021              param.durability_service();
01022         // Interoperability note: calling normalize() shouldn't be required
01023         normalize(writer_data.ddsPublicationData.durability_service.service_cleanup_delay);
01024         break;
01025       case PID_DEADLINE:
01026         writer_data.ddsPublicationData.deadline = param.deadline();
01027         // Interoperability note: calling normalize() shouldn't be required
01028         normalize(writer_data.ddsPublicationData.deadline.period);
01029         break;
01030       case PID_LATENCY_BUDGET:
01031         writer_data.ddsPublicationData.latency_budget = param.latency_budget();
01032         // Interoperability note: calling normalize() shouldn't be required
01033         normalize(writer_data.ddsPublicationData.latency_budget.duration);
01034         break;
01035       case PID_LIVELINESS:
01036         writer_data.ddsPublicationData.liveliness = param.liveliness();
01037         // Interoperability note: calling normalize() shouldn't be required
01038         normalize(writer_data.ddsPublicationData.liveliness.lease_duration);
01039         break;
01040       case PID_RELIABILITY:
01041         writer_data.ddsPublicationData.reliability = param.reliability();
01042         // Interoperability note:
01043         // Spec creators for RTPS have reliability indexed at 1
01044         writer_data.ddsPublicationData.reliability.kind =
01045           (DDS::ReliabilityQosPolicyKind)
01046               ((int)writer_data.ddsPublicationData.reliability.kind - 1);
01047         normalize(writer_data.ddsPublicationData.reliability.max_blocking_time);
01048         break;
01049       case PID_LIFESPAN:
01050         writer_data.ddsPublicationData.lifespan = param.lifespan();
01051         // Interoperability note: calling normalize() shouldn't be required
01052         normalize(writer_data.ddsPublicationData.lifespan.duration);
01053         break;
01054       case PID_USER_DATA:
01055         writer_data.ddsPublicationData.user_data = param.user_data();
01056         break;
01057       case PID_OWNERSHIP:
01058         writer_data.ddsPublicationData.ownership = param.ownership();
01059         break;
01060       case PID_OWNERSHIP_STRENGTH:
01061         writer_data.ddsPublicationData.ownership_strength = param.ownership_strength();
01062         break;
01063       case PID_DESTINATION_ORDER:
01064         writer_data.ddsPublicationData.destination_order = param.destination_order();
01065         break;
01066       case PID_PRESENTATION:
01067         writer_data.ddsPublicationData.presentation = param.presentation();
01068         break;
01069       case PID_PARTITION:
01070         writer_data.ddsPublicationData.partition = param.partition();
01071         break;
01072       case PID_TOPIC_DATA:
01073         writer_data.ddsPublicationData.topic_data = param.topic_data();
01074         break;
01075       case PID_GROUP_DATA:
01076         writer_data.ddsPublicationData.group_data = param.group_data();
01077         break;
01078       case PID_ENDPOINT_GUID:
01079         writer_data.writerProxy.remoteWriterGuid = param.guid();
01080         break;
01081       case PID_UNICAST_LOCATOR:
01082         append_locator(rtps_udp_locators, param.locator());
01083         break;
01084       case PID_MULTICAST_LOCATOR:
01085         append_locator(rtps_udp_locators, param.locator());
01086         break;
01087       case PID_MULTICAST_IPADDRESS:
01088         set_ipaddress(rtps_udp_locators,
01089                       last_state,
01090                       param.ipv4_address());
01091         break;
01092       case PID_OPENDDS_LOCATOR:
01093         // Append the rtps_udp_locators, if any, first, to preserve order
01094         append_locators_if_present(writer_data.writerProxy.allLocators,
01095                                    rtps_udp_locators);
01096         rtps_udp_locators.length(0);
01097         append_locator(writer_data.writerProxy.allLocators,
01098                        param.opendds_locator());
01099         break;
01100       case PID_SENTINEL:
01101       case PID_PAD:
01102         // ignore
01103         break;
01104       default:
01105         if (param._d() & PIDMASK_INCOMPATIBLE) {
01106           return -1;
01107         }
01108     }
01109   }
01110   // Append additional rtps_udp_locators, if any
01111   append_locators_if_present(writer_data.writerProxy.allLocators,
01112                              rtps_udp_locators);
01113   rtps_udp_locators.length(0);
01114   return 0;
01115 }
01116 
01117 // OpenDDS::DCPS::DiscoveredReaderData
01118 
01119 int to_param_list(const DCPS::DiscoveredReaderData& reader_data,
01120                   ParameterList& param_list,
01121                   bool map)
01122 {
01123   // Ignore builtin topic key
01124   {
01125     Parameter param;
01126     param.string_data(reader_data.ddsSubscriptionData.topic_name);
01127     param._d(PID_TOPIC_NAME);
01128     add_param(param_list, param);
01129   }
01130   {
01131     Parameter param;
01132     param.string_data(reader_data.ddsSubscriptionData.type_name);
01133     param._d(PID_TYPE_NAME);
01134     add_param(param_list, param);
01135   }
01136 
01137   if (not_default(reader_data.ddsSubscriptionData.durability))
01138   {
01139     Parameter param;
01140     param.durability(reader_data.ddsSubscriptionData.durability);
01141     add_param(param_list, param);
01142   }
01143 
01144   if (not_default(reader_data.ddsSubscriptionData.deadline))
01145   {
01146     Parameter param;
01147     param.deadline(reader_data.ddsSubscriptionData.deadline);
01148     add_param(param_list, param);
01149   }
01150 
01151   if (not_default(reader_data.ddsSubscriptionData.latency_budget))
01152   {
01153     Parameter param;
01154     param.latency_budget(reader_data.ddsSubscriptionData.latency_budget);
01155     add_param(param_list, param);
01156   }
01157 
01158   if (not_default(reader_data.ddsSubscriptionData.liveliness))
01159   {
01160     Parameter param;
01161     param.liveliness(reader_data.ddsSubscriptionData.liveliness);
01162     add_param(param_list, param);
01163   }
01164 
01165   // Interoperability note:
01166   // For interoperability, always write the reliability info
01167   // if (not_default(reader_data.ddsSubscriptionData.reliability, false))
01168   {
01169     Parameter param;
01170     // Interoperability note:
01171     // Spec creators for RTPS have reliability indexed at 1
01172     DDS::ReliabilityQosPolicy reliability_copy =
01173         reader_data.ddsSubscriptionData.reliability;
01174     reliability_copy.kind =
01175         (DDS::ReliabilityQosPolicyKind)((int)reliability_copy.kind + 1);
01176     param.reliability(reliability_copy);
01177     add_param(param_list, param);
01178   }
01179 
01180   if (not_default(reader_data.ddsSubscriptionData.user_data))
01181   {
01182     Parameter param;
01183     param.user_data(reader_data.ddsSubscriptionData.user_data);
01184     add_param(param_list, param);
01185   }
01186 
01187   if (not_default(reader_data.ddsSubscriptionData.ownership))
01188   {
01189     Parameter param;
01190     param.ownership(reader_data.ddsSubscriptionData.ownership);
01191     add_param(param_list, param);
01192   }
01193 
01194   if (not_default(reader_data.ddsSubscriptionData.destination_order))
01195   {
01196     Parameter param;
01197     param.destination_order(reader_data.ddsSubscriptionData.destination_order);
01198     add_param(param_list, param);
01199   }
01200 
01201   if (not_default(reader_data.ddsSubscriptionData.time_based_filter))
01202   {
01203     Parameter param;
01204     param.time_based_filter(reader_data.ddsSubscriptionData.time_based_filter);
01205     add_param(param_list, param);
01206   }
01207 
01208   if (not_default(reader_data.ddsSubscriptionData.presentation))
01209   {
01210     Parameter param;
01211     param.presentation(reader_data.ddsSubscriptionData.presentation);
01212     add_param(param_list, param);
01213   }
01214 
01215   if (not_default(reader_data.ddsSubscriptionData.partition))
01216   {
01217     Parameter param;
01218     param.partition(reader_data.ddsSubscriptionData.partition);
01219     add_param(param_list, param);
01220   }
01221 
01222   if (not_default(reader_data.ddsSubscriptionData.topic_data))
01223   {
01224     Parameter param;
01225     param.topic_data(reader_data.ddsSubscriptionData.topic_data);
01226     add_param(param_list, param);
01227   }
01228 
01229   if (not_default(reader_data.ddsSubscriptionData.group_data))
01230   {
01231     Parameter param;
01232     param.group_data(reader_data.ddsSubscriptionData.group_data);
01233     add_param(param_list, param);
01234   }
01235 
01236   {
01237     Parameter param;
01238     param.guid(reader_data.readerProxy.remoteReaderGuid);
01239     param._d(PID_ENDPOINT_GUID);
01240     add_param(param_list, param);
01241   }
01242 
01243   if (not_default(reader_data.contentFilterProperty))
01244   {
01245     Parameter param;
01246     DCPS::ContentFilterProperty_t cfprop_copy = reader_data.contentFilterProperty;
01247     if (!std::strlen(cfprop_copy.filterClassName)) {
01248       cfprop_copy.filterClassName = "DDSSQL";
01249     }
01250     param.content_filter_property(cfprop_copy);
01251     add_param(param_list, param);
01252   }
01253 
01254   CORBA::ULong i;
01255   CORBA::ULong locator_len = reader_data.readerProxy.allLocators.length();
01256   // Serialize from allLocators, rather than the unicastLocatorList
01257   // and multicastLocatorList.  This allows OpenDDS transports to be
01258   // serialized in the proper order using custom PIDs.
01259   for (i = 0; i < locator_len; ++i) {
01260     // Each locator has a blob of interest
01261     const DCPS::TransportLocator& tl = reader_data.readerProxy.allLocators[i];
01262     // If this is an rtps udp transport
01263     if (!std::strcmp(tl.transport_type, "rtps_udp")) {
01264       // Append the locator's deserialized locator and an RTPS PID
01265       add_param_rtps_locator(param_list, tl, map);
01266     // Otherwise, this is an OpenDDS, custom transport
01267     } else {
01268       // Append the blob and a custom PID
01269       add_param_dcps_locator(param_list, tl);
01270       if (!std::strcmp(tl.transport_type, "multicast")) {
01271         ACE_DEBUG((LM_WARNING,
01272                    ACE_TEXT("(%P|%t) to_param_list(drd) - ")
01273                    ACE_TEXT("Multicast transport with RTPS ")
01274                    ACE_TEXT("discovery has known issues")));
01275       }
01276     }
01277   }
01278 
01279   CORBA::ULong num_associations =
01280       reader_data.readerProxy.associatedWriters.length();
01281   for (i = 0; i < num_associations; ++i) {
01282     Parameter param;
01283     param.guid(reader_data.readerProxy.associatedWriters[i]);
01284     param._d(PID_OPENDDS_ASSOCIATED_WRITER);
01285     add_param(param_list, param);
01286   }
01287   return 0;
01288 }
01289 
01290 int from_param_list(const ParameterList& param_list,
01291                     DCPS::DiscoveredReaderData& reader_data)
01292 {
01293   LocatorState last_state = locator_undefined;  // Track state of locator
01294   // Collect the rtps_udp locators before appending them to allLocators
01295 
01296   DCPS::LocatorSeq rtps_udp_locators;
01297   // Start by setting defaults
01298   reader_data.ddsSubscriptionData.topic_name = "";
01299   reader_data.ddsSubscriptionData.type_name  = "";
01300   reader_data.ddsSubscriptionData.durability =
01301       TheServiceParticipant->initial_DurabilityQosPolicy();
01302   reader_data.ddsSubscriptionData.deadline =
01303       TheServiceParticipant->initial_DeadlineQosPolicy();
01304   reader_data.ddsSubscriptionData.latency_budget =
01305       TheServiceParticipant->initial_LatencyBudgetQosPolicy();
01306   reader_data.ddsSubscriptionData.liveliness =
01307       TheServiceParticipant->initial_LivelinessQosPolicy();
01308   reader_data.ddsSubscriptionData.reliability =
01309       TheServiceParticipant->initial_DataReaderQos().reliability;
01310   reader_data.ddsSubscriptionData.ownership =
01311       TheServiceParticipant->initial_OwnershipQosPolicy();
01312   reader_data.ddsSubscriptionData.destination_order =
01313       TheServiceParticipant->initial_DestinationOrderQosPolicy();
01314   reader_data.ddsSubscriptionData.user_data =
01315       TheServiceParticipant->initial_UserDataQosPolicy();
01316   reader_data.ddsSubscriptionData.time_based_filter =
01317       TheServiceParticipant->initial_TimeBasedFilterQosPolicy();
01318   reader_data.ddsSubscriptionData.presentation =
01319       TheServiceParticipant->initial_PresentationQosPolicy();
01320   reader_data.ddsSubscriptionData.partition =
01321       TheServiceParticipant->initial_PartitionQosPolicy();
01322   reader_data.ddsSubscriptionData.topic_data =
01323       TheServiceParticipant->initial_TopicDataQosPolicy();
01324   reader_data.ddsSubscriptionData.group_data =
01325       TheServiceParticipant->initial_GroupDataQosPolicy();
01326   reader_data.readerProxy.unicastLocatorList.length(0);
01327   reader_data.readerProxy.multicastLocatorList.length(0);
01328   reader_data.readerProxy.expectsInlineQos = false;
01329   reader_data.contentFilterProperty.contentFilteredTopicName = "";
01330   reader_data.contentFilterProperty.relatedTopicName = "";
01331   reader_data.contentFilterProperty.filterClassName = "";
01332   reader_data.contentFilterProperty.filterExpression = "";
01333   reader_data.contentFilterProperty.expressionParameters.length(0);
01334 
01335   CORBA::ULong length = param_list.length();
01336   for (CORBA::ULong i = 0; i < length; ++i) {
01337     const Parameter& param = param_list[i];
01338     switch (param._d()) {
01339       case PID_TOPIC_NAME:
01340         reader_data.ddsSubscriptionData.topic_name = param.string_data();
01341         break;
01342       case PID_TYPE_NAME:
01343         reader_data.ddsSubscriptionData.type_name = param.string_data();
01344         break;
01345       case PID_DURABILITY:
01346         reader_data.ddsSubscriptionData.durability = param.durability();
01347         break;
01348       case PID_DEADLINE:
01349         reader_data.ddsSubscriptionData.deadline = param.deadline();
01350         // Interoperability note: calling normalize() shouldn't be required
01351         normalize(reader_data.ddsSubscriptionData.deadline.period);
01352         break;
01353       case PID_LATENCY_BUDGET:
01354         reader_data.ddsSubscriptionData.latency_budget = param.latency_budget();
01355         // Interoperability note: calling normalize() shouldn't be required
01356         normalize(reader_data.ddsSubscriptionData.latency_budget.duration);
01357         break;
01358       case PID_LIVELINESS:
01359         reader_data.ddsSubscriptionData.liveliness = param.liveliness();
01360         // Interoperability note: calling normalize() shouldn't be required
01361         normalize(reader_data.ddsSubscriptionData.liveliness.lease_duration);
01362         break;
01363       case PID_RELIABILITY:
01364         reader_data.ddsSubscriptionData.reliability = param.reliability();
01365         // Interoperability note:
01366         // Spec creators for RTPS have reliability indexed at 1
01367         reader_data.ddsSubscriptionData.reliability.kind =
01368           (DDS::ReliabilityQosPolicyKind)
01369               ((int)reader_data.ddsSubscriptionData.reliability.kind - 1);
01370         break;
01371       case PID_USER_DATA:
01372         reader_data.ddsSubscriptionData.user_data = param.user_data();
01373         break;
01374       case PID_OWNERSHIP:
01375         reader_data.ddsSubscriptionData.ownership = param.ownership();
01376         break;
01377       case PID_DESTINATION_ORDER:
01378         reader_data.ddsSubscriptionData.destination_order = param.destination_order();
01379         break;
01380       case PID_TIME_BASED_FILTER:
01381         reader_data.ddsSubscriptionData.time_based_filter = param.time_based_filter();
01382         // Interoperability note: calling normalize() shouldn't be required
01383         normalize(reader_data.ddsSubscriptionData.time_based_filter.minimum_separation);
01384         break;
01385       case PID_PRESENTATION:
01386         reader_data.ddsSubscriptionData.presentation = param.presentation();
01387         break;
01388       case PID_PARTITION:
01389         reader_data.ddsSubscriptionData.partition = param.partition();
01390         break;
01391       case PID_TOPIC_DATA:
01392         reader_data.ddsSubscriptionData.topic_data = param.topic_data();
01393         break;
01394       case PID_GROUP_DATA:
01395         reader_data.ddsSubscriptionData.group_data = param.group_data();
01396         break;
01397       case PID_ENDPOINT_GUID:
01398         reader_data.readerProxy.remoteReaderGuid = param.guid();
01399         break;
01400       case PID_UNICAST_LOCATOR:
01401         append_locator(rtps_udp_locators, param.locator());
01402         break;
01403       case PID_MULTICAST_LOCATOR:
01404         append_locator(rtps_udp_locators, param.locator());
01405         break;
01406       case PID_CONTENT_FILTER_PROPERTY:
01407         reader_data.contentFilterProperty = param.content_filter_property();
01408         break;
01409       case PID_MULTICAST_IPADDRESS:
01410         set_ipaddress(rtps_udp_locators,
01411                       last_state,
01412                       param.ipv4_address());
01413         break;
01414       case PID_OPENDDS_LOCATOR:
01415         // Append the rtps_udp_locators, if any, first, to preserve order
01416         append_locators_if_present(reader_data.readerProxy.allLocators,
01417                                    rtps_udp_locators);
01418         rtps_udp_locators.length(0);
01419         append_locator(reader_data.readerProxy.allLocators,
01420                        param.opendds_locator());
01421         break;
01422       case PID_OPENDDS_ASSOCIATED_WRITER:
01423         append_associated_writer(reader_data, param);
01424         break;
01425       case PID_SENTINEL:
01426       case PID_PAD:
01427         // ignore
01428         break;
01429       default:
01430         if (param._d() & PIDMASK_INCOMPATIBLE) {
01431           return -1;
01432         }
01433     }
01434   }
01435   // Append additional rtps_udp_locators, if any
01436   append_locators_if_present(reader_data.readerProxy.allLocators,
01437                              rtps_udp_locators);
01438   rtps_udp_locators.length(0);
01439   return 0;
01440 }
01441 
01442 #if defined(OPENDDS_SECURITY)
01443 int to_param_list(const DDS::Security::EndpointSecurityInfo& info,
01444                   ParameterList& param_list)
01445 {
01446   Parameter param;
01447   param.endpoint_security_info(info);
01448   add_param(param_list, param);
01449   return 0;
01450 }
01451 
01452 int from_param_list(const ParameterList& param_list,
01453                     DDS::Security::EndpointSecurityInfo& info)
01454 {
01455   info.endpoint_security_attributes = 0;
01456   info.plugin_endpoint_security_attributes = 0;
01457 
01458   size_t len = param_list.length();
01459   for (size_t i = 0; i < len; ++i) {
01460     const Parameter& p = param_list[i];
01461     switch(p._d()) {
01462     case DDS::Security::PID_ENDPOINT_SECURITY_INFO:
01463       info = p.endpoint_security_info();
01464       break;
01465     default:
01466       if (p._d() & PIDMASK_INCOMPATIBLE) {
01467           return -1;
01468       }
01469     }
01470   }
01471 
01472   return 0;
01473 }
01474 
01475 int to_param_list(const DDS::Security::DataTags& tags,
01476                   ParameterList& param_list)
01477 {
01478   Parameter param;
01479   param.data_tags(tags);
01480   add_param(param_list, param);
01481   return 0;
01482 }
01483 
01484 int from_param_list(const ParameterList& param_list,
01485                     DDS::Security::DataTags& tags)
01486 {
01487   tags.tags.length(0);
01488 
01489   size_t len = param_list.length();
01490   for (size_t i = 0; i < len; ++i) {
01491     const Parameter& p = param_list[i];
01492     switch(p._d()) {
01493     case DDS::Security::PID_DATA_TAGS:
01494       tags = p.data_tags();
01495       break;
01496     default:
01497       if (p._d() & PIDMASK_INCOMPATIBLE) {
01498           return -1;
01499       }
01500     }
01501   }
01502 
01503   return 0;
01504 }
01505 
01506 int to_param_list(const DiscoveredWriterData_SecurityWrapper& wrapper,
01507                   ParameterList& param_list,
01508                   bool map)
01509 {
01510   int result = to_param_list(wrapper.data, param_list, map);
01511 
01512   to_param_list(wrapper.security_info, param_list);
01513   to_param_list(wrapper.data_tags, param_list);
01514 
01515   return result;
01516 }
01517 
01518 int from_param_list(const ParameterList& param_list,
01519                     DiscoveredWriterData_SecurityWrapper& wrapper)
01520 {
01521   int result = from_param_list(param_list, wrapper.data) ||
01522                from_param_list(param_list, wrapper.security_info) ||
01523                from_param_list(param_list, wrapper.data_tags);
01524 
01525   return result;
01526 }
01527 
01528 int to_param_list(const DiscoveredReaderData_SecurityWrapper& wrapper,
01529                   ParameterList& param_list,
01530                   bool map)
01531 {
01532   int result = to_param_list(wrapper.data, param_list, map);
01533 
01534   to_param_list(wrapper.security_info, param_list);
01535   to_param_list(wrapper.data_tags, param_list);
01536 
01537   return result;
01538 }
01539 
01540 int from_param_list(const ParameterList& param_list,
01541                     DiscoveredReaderData_SecurityWrapper& wrapper)
01542 {
01543   int result = from_param_list(param_list, wrapper.data) ||
01544                from_param_list(param_list, wrapper.security_info) ||
01545                from_param_list(param_list, wrapper.data_tags);
01546 
01547   return result;
01548 }
01549 #endif
01550 
01551 } // ParameterListConverter
01552 } // RTPS
01553 } // OpenDDS
01554 
01555 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1