From 12e69461633a71c15230ffe5150e020cbea0edd8 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sun, 26 May 2019 12:12:00 +0200 Subject: [PATCH] Remove QoS duplication between DDS and DDSI All this duplication was rather useless: the values are standardized anyway and the conversion was a simple type cast without any check. This commit unifies the definitions. * DDSI now uses the definitions of the various QoS "kind" values from the header file; * The durations in the QoS objects are no longer in wire-format representation, the conversions now happen only in conversion to/from wire format; * The core DDSI stack no longer uses DDSI time representations for time stamps, instead using the "native" one; * QoS policy ids duplication has been eliminated, again using the IDs visible in the API -- the actual values are meaningless to the DDSI stack anyway. Signed-off-by: Erik Boasson --- src/core/ddsc/CMakeLists.txt | 1 + .../ddsc/include/dds/ddsc/dds_public_impl.h | 2 - .../ddsc/include/dds/ddsc/dds_public_qos.h | 121 +-- .../include/dds/ddsc/dds_public_qosdefs.h | 132 +++ src/core/ddsc/src/dds__qos.h | 12 +- src/core/ddsc/src/dds__rhc.h | 4 +- src/core/ddsc/src/dds__serdata_builtintopic.h | 2 +- src/core/ddsc/src/dds_builtin.c | 2 +- src/core/ddsc/src/dds_qos.c | 139 ++- src/core/ddsc/src/dds_reader.c | 4 +- src/core/ddsc/src/dds_rhc.c | 12 +- src/core/ddsc/src/dds_serdata_builtintopic.c | 2 +- src/core/ddsc/src/dds_topic.c | 2 +- src/core/ddsc/src/dds_write.c | 4 +- src/core/ddsc/src/dds_writer.c | 10 +- src/core/ddsc/tests/entity_status.c | 9 +- .../ddsi/include/dds/ddsi/ddsi_rhc_plugin.h | 6 +- src/core/ddsi/include/dds/ddsi/q_entity.h | 18 +- src/core/ddsi/include/dds/ddsi/q_globals.h | 18 +- src/core/ddsi/include/dds/ddsi/q_plist.h | 31 +- src/core/ddsi/include/dds/ddsi/q_protocol.h | 6 +- src/core/ddsi/include/dds/ddsi/q_qosmatch.h | 6 +- src/core/ddsi/include/dds/ddsi/q_radmin.h | 2 +- src/core/ddsi/include/dds/ddsi/q_time.h | 24 +- src/core/ddsi/include/dds/ddsi/q_xmsg.h | 30 +- src/core/ddsi/include/dds/ddsi/q_xqos.h | 350 ++++---- src/core/ddsi/src/ddsi_rhc_plugin.c | 2 +- src/core/ddsi/src/q_ddsi_discovery.c | 32 +- src/core/ddsi/src/q_debmon.c | 4 +- src/core/ddsi/src/q_entity.c | 94 +- src/core/ddsi/src/q_init.c | 10 +- src/core/ddsi/src/q_plist.c | 844 ++++++++---------- src/core/ddsi/src/q_qosmatch.c | 161 ++-- src/core/ddsi/src/q_receive.c | 42 +- src/core/ddsi/src/q_time.c | 26 +- src/core/ddsi/src/q_transmit.c | 8 +- src/core/ddsi/src/q_xmsg.c | 134 ++- src/core/xtests/rhc_torture/rhc_torture.c | 10 +- 38 files changed, 1074 insertions(+), 1242 deletions(-) create mode 100644 src/core/ddsc/include/dds/ddsc/dds_public_qosdefs.h diff --git a/src/core/ddsc/CMakeLists.txt b/src/core/ddsc/CMakeLists.txt index 3475af6..9c0d16d 100644 --- a/src/core/ddsc/CMakeLists.txt +++ b/src/core/ddsc/CMakeLists.txt @@ -46,6 +46,7 @@ PREPEND(hdrs_public_ddsc "$wr.xqos) && !qos_has_resource_limits (qos); + return !qos_match_p (qos, bwr->wr.xqos, NULL) && !qos_has_resource_limits (qos); } } diff --git a/src/core/ddsc/src/dds_qos.c b/src/core/ddsc/src/dds_qos.c index a1771f8..3d2ccb1 100644 --- a/src/core/ddsc/src/dds_qos.c +++ b/src/core/ddsc/src/dds_qos.c @@ -14,12 +14,7 @@ #include "dds__qos.h" #include "dds/ddsi/q_config.h" -/* TODO: dd_duration_t is converted to nn_ddsi_time_t declared in q_time.h - This structure contain seconds and fractions. - Revisit on the conversion as default values are { 0x7fffffff, 0xffffffff } -*/ - -static void dds_qos_data_copy_in (nn_octetseq_t *data, const void * __restrict value, size_t sz) +static void dds_qos_data_copy_in (ddsi_octetseq_t *data, const void * __restrict value, size_t sz) { if (data->value) { @@ -34,7 +29,7 @@ static void dds_qos_data_copy_in (nn_octetseq_t *data, const void * __restrict v } } -static bool dds_qos_data_copy_out (const nn_octetseq_t *data, void **value, size_t *sz) +static bool dds_qos_data_copy_out (const ddsi_octetseq_t *data, void **value, size_t *sz) { assert (data->length < UINT32_MAX); if (sz == NULL && value != NULL) @@ -57,13 +52,13 @@ static bool dds_qos_data_copy_out (const nn_octetseq_t *data, void **value, size return true; } -bool validate_octetseq (const nn_octetseq_t *seq) +bool validate_octetseq (const ddsi_octetseq_t *seq) { /* default value is NULL with length 0 */ return ((seq->length == 0 && seq->value == NULL) || (seq->length > 0 && seq->length < UINT32_MAX)); } -bool validate_stringseq (const nn_stringseq_t *seq) +bool validate_stringseq (const ddsi_stringseq_t *seq) { if (seq->n == 0) return (seq->strs == NULL); @@ -76,30 +71,30 @@ bool validate_stringseq (const nn_stringseq_t *seq) } } -bool validate_entityfactory_qospolicy (const nn_entity_factory_qospolicy_t *entityfactory) +bool validate_entityfactory_qospolicy (const dds_entity_factory_qospolicy_t *entityfactory) { /* Bools must be 0 or 1, i.e., only the lsb may be set */ return !(entityfactory->autoenable_created_entities & ~1); } -bool validate_reliability_qospolicy (const nn_reliability_qospolicy_t *reliability) +bool validate_reliability_qospolicy (const dds_reliability_qospolicy_t *reliability) { - return ((reliability->kind == NN_BEST_EFFORT_RELIABILITY_QOS || reliability->kind == NN_RELIABLE_RELIABILITY_QOS) && - (validate_duration (&reliability->max_blocking_time) == 0)); + return ((reliability->kind == DDS_RELIABILITY_BEST_EFFORT || reliability->kind == DDS_RELIABILITY_RELIABLE) && + (validate_duration (reliability->max_blocking_time) == 0)); } -bool validate_deadline_and_timebased_filter (const nn_duration_t deadline, const nn_duration_t minimum_separation) +bool validate_deadline_and_timebased_filter (const dds_duration_t deadline, const dds_duration_t minimum_separation) { - return (validate_duration (&deadline) == DDS_RETCODE_OK && - validate_duration (&minimum_separation) == DDS_RETCODE_OK && - nn_from_ddsi_duration (minimum_separation) <= nn_from_ddsi_duration (deadline)); + return (validate_duration (deadline) == DDS_RETCODE_OK && + validate_duration (minimum_separation) == DDS_RETCODE_OK && + minimum_separation <= deadline); } bool dds_qos_validate_common (const dds_qos_t *qos) { return !(((qos->present & QP_DURABILITY) && validate_durability_qospolicy (&qos->durability) != DDS_RETCODE_OK) || - ((qos->present & QP_DEADLINE) && validate_duration (&qos->deadline.deadline) != DDS_RETCODE_OK) || - ((qos->present & QP_LATENCY_BUDGET) && validate_duration (&qos->latency_budget.duration) != DDS_RETCODE_OK) || + ((qos->present & QP_DEADLINE) && validate_duration (qos->deadline.deadline) != DDS_RETCODE_OK) || + ((qos->present & QP_LATENCY_BUDGET) && validate_duration (qos->latency_budget.duration) != DDS_RETCODE_OK) || ((qos->present & QP_OWNERSHIP) && validate_ownership_qospolicy (&qos->ownership) != DDS_RETCODE_OK) || ((qos->present & QP_LIVELINESS) && validate_liveliness_qospolicy (&qos->liveliness) != DDS_RETCODE_OK) || ((qos->present & QP_RELIABILITY) && ! validate_reliability_qospolicy (&qos->reliability)) || @@ -134,32 +129,32 @@ static void dds_qos_init_defaults (dds_qos_t * __restrict qos) { assert (qos); memset (qos, 0, sizeof (*qos)); - qos->durability.kind = (nn_durability_kind_t) DDS_DURABILITY_VOLATILE; - qos->deadline.deadline = nn_to_ddsi_duration (DDS_INFINITY); - qos->durability_service.service_cleanup_delay = nn_to_ddsi_duration (0); - qos->durability_service.history.kind = (nn_history_kind_t) DDS_HISTORY_KEEP_LAST; + qos->durability.kind = DDS_DURABILITY_VOLATILE; + qos->deadline.deadline = DDS_INFINITY; + qos->durability_service.service_cleanup_delay = 0; + qos->durability_service.history.kind = DDS_HISTORY_KEEP_LAST; qos->durability_service.history.depth = 1; qos->durability_service.resource_limits.max_samples = DDS_LENGTH_UNLIMITED; qos->durability_service.resource_limits.max_instances = DDS_LENGTH_UNLIMITED; qos->durability_service.resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED; - qos->presentation.access_scope = (nn_presentation_access_scope_kind_t) DDS_PRESENTATION_INSTANCE; - qos->latency_budget.duration = nn_to_ddsi_duration (0); - qos->ownership.kind = (nn_ownership_kind_t) DDS_OWNERSHIP_SHARED; - qos->liveliness.kind = (nn_liveliness_kind_t) DDS_LIVELINESS_AUTOMATIC; - qos->liveliness.lease_duration = nn_to_ddsi_duration (DDS_INFINITY); - qos->time_based_filter.minimum_separation = nn_to_ddsi_duration (0); - qos->reliability.kind = (nn_reliability_kind_t) DDS_RELIABILITY_BEST_EFFORT; - qos->reliability.max_blocking_time = nn_to_ddsi_duration (DDS_MSECS (100)); - qos->lifespan.duration = nn_to_ddsi_duration (DDS_INFINITY); - qos->destination_order.kind = (nn_destination_order_kind_t) DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP; - qos->history.kind = (nn_history_kind_t) DDS_HISTORY_KEEP_LAST; + qos->presentation.access_scope = DDS_PRESENTATION_INSTANCE; + qos->latency_budget.duration = 0; + qos->ownership.kind = DDS_OWNERSHIP_SHARED; + qos->liveliness.kind = DDS_LIVELINESS_AUTOMATIC; + qos->liveliness.lease_duration = DDS_INFINITY; + qos->time_based_filter.minimum_separation = 0; + qos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT; + qos->reliability.max_blocking_time = DDS_MSECS (100); + qos->lifespan.duration = DDS_INFINITY; + qos->destination_order.kind = DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP; + qos->history.kind = DDS_HISTORY_KEEP_LAST; qos->history.depth = 1; qos->resource_limits.max_samples = DDS_LENGTH_UNLIMITED; qos->resource_limits.max_instances = DDS_LENGTH_UNLIMITED; qos->resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED; qos->writer_data_lifecycle.autodispose_unregistered_instances = true; - qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = nn_to_ddsi_duration (DDS_INFINITY); - qos->reader_data_lifecycle.autopurge_disposed_samples_delay = nn_to_ddsi_duration (DDS_INFINITY); + qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = DDS_INFINITY; + qos->reader_data_lifecycle.autopurge_disposed_samples_delay = DDS_INFINITY; } dds_qos_t *dds_create_qos (void) @@ -269,7 +264,7 @@ void dds_qset_durability (dds_qos_t * __restrict qos, dds_durability_kind_t kind { if (qos != NULL) { - qos->durability.kind = (nn_durability_kind_t) kind; + qos->durability.kind = kind; qos->present |= QP_DURABILITY; } } @@ -278,7 +273,7 @@ void dds_qset_history (dds_qos_t * __restrict qos, dds_history_kind_t kind, int3 { if (qos != NULL) { - qos->history.kind = (nn_history_kind_t) kind; + qos->history.kind = kind; qos->history.depth = depth; qos->present |= QP_HISTORY; } @@ -299,7 +294,7 @@ void dds_qset_presentation (dds_qos_t * __restrict qos, dds_presentation_access_ { if (qos != NULL) { - qos->presentation.access_scope = (nn_presentation_access_scope_kind_t) access_scope; + qos->presentation.access_scope = access_scope; qos->presentation.coherent_access = coherent_access; qos->presentation.ordered_access = ordered_access; qos->present |= QP_PRESENTATION; @@ -310,7 +305,7 @@ void dds_qset_lifespan (dds_qos_t * __restrict qos, dds_duration_t lifespan) { if (qos != NULL) { - qos->lifespan.duration = nn_to_ddsi_duration (lifespan); + qos->lifespan.duration = lifespan; qos->present |= QP_LIFESPAN; } } @@ -319,7 +314,7 @@ void dds_qset_deadline (dds_qos_t * __restrict qos, dds_duration_t deadline) { if (qos != NULL) { - qos->deadline.deadline = nn_to_ddsi_duration (deadline); + qos->deadline.deadline = deadline; qos->present |= QP_DEADLINE; } } @@ -328,7 +323,7 @@ void dds_qset_latency_budget (dds_qos_t * __restrict qos, dds_duration_t duratio { if (qos != NULL) { - qos->latency_budget.duration = nn_to_ddsi_duration (duration); + qos->latency_budget.duration = duration; qos->present |= QP_LATENCY_BUDGET; } } @@ -337,7 +332,7 @@ void dds_qset_ownership (dds_qos_t * __restrict qos, dds_ownership_kind_t kind) { if (qos != NULL) { - qos->ownership.kind = (nn_ownership_kind_t) kind; + qos->ownership.kind = kind; qos->present |= QP_OWNERSHIP; } } @@ -355,8 +350,8 @@ void dds_qset_liveliness (dds_qos_t * __restrict qos, dds_liveliness_kind_t kind { if (qos != NULL) { - qos->liveliness.kind = (nn_liveliness_kind_t) kind; - qos->liveliness.lease_duration = nn_to_ddsi_duration (lease_duration); + qos->liveliness.kind = kind; + qos->liveliness.lease_duration = lease_duration; qos->present |= QP_LIVELINESS; } } @@ -365,7 +360,7 @@ void dds_qset_time_based_filter (dds_qos_t * __restrict qos, dds_duration_t mini { if (qos != NULL) { - qos->time_based_filter.minimum_separation = nn_to_ddsi_duration (minimum_separation); + qos->time_based_filter.minimum_separation = minimum_separation; qos->present |= QP_TIME_BASED_FILTER; } } @@ -405,8 +400,8 @@ void dds_qset_reliability (dds_qos_t * __restrict qos, dds_reliability_kind_t ki { if (qos != NULL) { - qos->reliability.kind = (nn_reliability_kind_t) kind; - qos->reliability.max_blocking_time = nn_to_ddsi_duration (max_blocking_time); + qos->reliability.kind = kind; + qos->reliability.max_blocking_time = max_blocking_time; qos->present |= QP_RELIABILITY; } } @@ -424,7 +419,7 @@ void dds_qset_destination_order (dds_qos_t * __restrict qos, dds_destination_ord { if (qos != NULL) { - qos->destination_order.kind = (nn_destination_order_kind_t) kind; + qos->destination_order.kind = kind; qos->present |= QP_DESTINATION_ORDER; } } @@ -442,8 +437,8 @@ void dds_qset_reader_data_lifecycle (dds_qos_t * __restrict qos, dds_duration_t { if (qos != NULL) { - qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = nn_to_ddsi_duration (autopurge_nowriter_samples_delay); - qos->reader_data_lifecycle.autopurge_disposed_samples_delay = nn_to_ddsi_duration (autopurge_disposed_samples_delay); + qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = autopurge_nowriter_samples_delay; + qos->reader_data_lifecycle.autopurge_disposed_samples_delay = autopurge_disposed_samples_delay; qos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE; } } @@ -452,8 +447,8 @@ void dds_qset_durability_service (dds_qos_t * __restrict qos, dds_duration_t ser { if (qos != NULL) { - qos->durability_service.service_cleanup_delay = nn_to_ddsi_duration (service_cleanup_delay); - qos->durability_service.history.kind = (nn_history_kind_t) history_kind; + qos->durability_service.service_cleanup_delay = service_cleanup_delay; + qos->durability_service.history.kind = history_kind; qos->durability_service.history.depth = history_depth; qos->durability_service.resource_limits.max_samples = max_samples; qos->durability_service.resource_limits.max_instances = max_instances; @@ -466,7 +461,7 @@ void dds_qset_ignorelocal (dds_qos_t * __restrict qos, dds_ignorelocal_kind_t ig { if (qos != NULL) { - qos->ignorelocal.value = (nn_ignorelocal_kind_t) ignore; + qos->ignorelocal.value = ignore; qos->present |= QP_CYCLONE_IGNORELOCAL; } } @@ -497,7 +492,7 @@ bool dds_qget_durability (const dds_qos_t * __restrict qos, dds_durability_kind_ if (qos == NULL || !(qos->present & QP_DURABILITY)) return false; if (kind) - *kind = (dds_durability_kind_t) qos->durability.kind; + *kind = qos->durability.kind; return true; } @@ -506,7 +501,7 @@ bool dds_qget_history (const dds_qos_t * __restrict qos, dds_history_kind_t *kin if (qos == NULL || !(qos->present & QP_HISTORY)) return false; if (kind) - *kind = (dds_history_kind_t) qos->history.kind; + *kind = qos->history.kind; if (depth) *depth = qos->history.depth; return true; @@ -530,7 +525,7 @@ bool dds_qget_presentation (const dds_qos_t * __restrict qos, dds_presentation_a if (qos == NULL || !(qos->present & QP_PRESENTATION)) return false; if (access_scope) - *access_scope = (dds_presentation_access_scope_kind_t) qos->presentation.access_scope; + *access_scope = qos->presentation.access_scope; if (coherent_access) *coherent_access = qos->presentation.coherent_access; if (ordered_access) @@ -543,7 +538,7 @@ bool dds_qget_lifespan (const dds_qos_t * __restrict qos, dds_duration_t *lifesp if (qos == NULL || !(qos->present & QP_LIFESPAN)) return false; if (lifespan) - *lifespan = nn_from_ddsi_duration (qos->lifespan.duration); + *lifespan = qos->lifespan.duration; return true; } @@ -552,7 +547,7 @@ bool dds_qget_deadline (const dds_qos_t * __restrict qos, dds_duration_t *deadli if (qos == NULL || !(qos->present & QP_DEADLINE)) return false; if (deadline) - *deadline = nn_from_ddsi_duration (qos->deadline.deadline); + *deadline = qos->deadline.deadline; return true; } @@ -561,7 +556,7 @@ bool dds_qget_latency_budget (const dds_qos_t * __restrict qos, dds_duration_t * if (qos == NULL || !(qos->present & QP_LATENCY_BUDGET)) return false; if (duration) - *duration = nn_from_ddsi_duration (qos->latency_budget.duration); + *duration = qos->latency_budget.duration; return true; } @@ -570,7 +565,7 @@ bool dds_qget_ownership (const dds_qos_t * __restrict qos, dds_ownership_kind_t if (qos == NULL || !(qos->present & QP_OWNERSHIP)) return false; if (kind) - *kind = (dds_ownership_kind_t) qos->ownership.kind; + *kind = qos->ownership.kind; return true; } @@ -588,9 +583,9 @@ bool dds_qget_liveliness (const dds_qos_t * __restrict qos, dds_liveliness_kind_ if (qos == NULL || !(qos->present & QP_LIVELINESS)) return false; if (kind) - *kind = (dds_liveliness_kind_t) qos->liveliness.kind; + *kind = qos->liveliness.kind; if (lease_duration) - *lease_duration = nn_from_ddsi_duration (qos->liveliness.lease_duration); + *lease_duration = qos->liveliness.lease_duration; return true; } @@ -599,7 +594,7 @@ bool dds_qget_time_based_filter (const dds_qos_t * __restrict qos, dds_duration_ if (qos == NULL || !(qos->present & QP_TIME_BASED_FILTER)) return false; if (minimum_separation) - *minimum_separation = nn_from_ddsi_duration (qos->time_based_filter.minimum_separation); + *minimum_separation = qos->time_based_filter.minimum_separation; return true; } @@ -630,9 +625,9 @@ bool dds_qget_reliability (const dds_qos_t * __restrict qos, dds_reliability_kin if (qos == NULL || !(qos->present & QP_RELIABILITY)) return false; if (kind) - *kind = (dds_reliability_kind_t) qos->reliability.kind; + *kind = qos->reliability.kind; if (max_blocking_time) - *max_blocking_time = nn_from_ddsi_duration (qos->reliability.max_blocking_time); + *max_blocking_time = qos->reliability.max_blocking_time; return true; } @@ -650,7 +645,7 @@ bool dds_qget_destination_order (const dds_qos_t * __restrict qos, dds_destinati if (qos == NULL || !(qos->present & QP_DESTINATION_ORDER)) return false; if (kind) - *kind = (dds_destination_order_kind_t) qos->destination_order.kind; + *kind = qos->destination_order.kind; return true; } @@ -668,9 +663,9 @@ bool dds_qget_reader_data_lifecycle (const dds_qos_t * __restrict qos, dds_durat if (qos == NULL || !(qos->present & QP_PRISMTECH_READER_DATA_LIFECYCLE)) return false; if (autopurge_nowriter_samples_delay) - *autopurge_nowriter_samples_delay = nn_from_ddsi_duration (qos->reader_data_lifecycle.autopurge_nowriter_samples_delay); + *autopurge_nowriter_samples_delay = qos->reader_data_lifecycle.autopurge_nowriter_samples_delay; if (autopurge_disposed_samples_delay) - *autopurge_disposed_samples_delay = nn_from_ddsi_duration (qos->reader_data_lifecycle.autopurge_disposed_samples_delay); + *autopurge_disposed_samples_delay = qos->reader_data_lifecycle.autopurge_disposed_samples_delay; return true; } @@ -679,9 +674,9 @@ bool dds_qget_durability_service (const dds_qos_t * __restrict qos, dds_duration if (qos == NULL || !(qos->present & QP_DURABILITY_SERVICE)) return false; if (service_cleanup_delay) - *service_cleanup_delay = nn_from_ddsi_duration (qos->durability_service.service_cleanup_delay); + *service_cleanup_delay = qos->durability_service.service_cleanup_delay; if (history_kind) - *history_kind = (dds_history_kind_t) qos->durability_service.history.kind; + *history_kind = qos->durability_service.history.kind; if (history_depth) *history_depth = qos->durability_service.history.depth; if (max_samples) @@ -698,6 +693,6 @@ bool dds_qget_ignorelocal (const dds_qos_t * __restrict qos, dds_ignorelocal_kin if (qos == NULL || !(qos->present & QP_CYCLONE_IGNORELOCAL)) return false; if (ignore) - *ignore = (dds_ignorelocal_kind_t) qos->ignorelocal.value; + *ignore = qos->ignorelocal.value; return true; } diff --git a/src/core/ddsc/src/dds_reader.c b/src/core/ddsc/src/dds_reader.c index 8638251..6392124 100644 --- a/src/core/ddsc/src/dds_reader.c +++ b/src/core/ddsc/src/dds_reader.c @@ -87,7 +87,7 @@ static dds_return_t dds_reader_qos_validate (const dds_qos_t *qos, bool enabled) return DDS_RETCODE_INCONSISTENT_POLICY; if ((qos->present & QP_PRISMTECH_READER_DATA_LIFECYCLE) && validate_reader_data_lifecycle (&qos->reader_data_lifecycle) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; - if ((qos->present & QP_TIME_BASED_FILTER) && validate_duration (&qos->time_based_filter.minimum_separation) < 0) + if ((qos->present & QP_TIME_BASED_FILTER) && validate_duration (qos->time_based_filter.minimum_separation) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && validate_history_and_resource_limits (&qos->history, &qos->resource_limits) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; @@ -432,7 +432,7 @@ dds_entity_t dds_create_reader (dds_entity_t participant_or_subscriber, dds_enti thread_state_asleep (lookup_thread_state ()); /* For persistent data register reader with durability */ - if (dds_global.m_dur_reader && (rd->m_entity.m_qos->durability.kind > NN_TRANSIENT_LOCAL_DURABILITY_QOS)) { + if (dds_global.m_dur_reader && (rd->m_entity.m_qos->durability.kind > DDS_DURABILITY_TRANSIENT_LOCAL)) { (dds_global.m_dur_reader) (rd, rhc); } dds_topic_unlock (tp); diff --git a/src/core/ddsc/src/dds_rhc.c b/src/core/ddsc/src/dds_rhc.c index 99f4508..e2c9f2b 100644 --- a/src/core/ddsc/src/dds_rhc.c +++ b/src/core/ddsc/src/dds_rhc.c @@ -464,18 +464,18 @@ struct rhc * dds_rhc_new (dds_reader * reader, const struct ddsi_sertopic * topi return rhc; } -void dds_rhc_set_qos (struct rhc * rhc, const nn_xqos_t * qos) +void dds_rhc_set_qos (struct rhc * rhc, const dds_qos_t * qos) { /* Set read related QoS */ rhc->max_samples = qos->resource_limits.max_samples; rhc->max_instances = qos->resource_limits.max_instances; rhc->max_samples_per_instance = qos->resource_limits.max_samples_per_instance; - rhc->by_source_ordering = (qos->destination_order.kind == NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS); - rhc->exclusive_ownership = (qos->ownership.kind == NN_EXCLUSIVE_OWNERSHIP_QOS); - rhc->reliable = (qos->reliability.kind == NN_RELIABLE_RELIABILITY_QOS); - assert(qos->history.kind != NN_KEEP_LAST_HISTORY_QOS || qos->history.depth > 0); - rhc->history_depth = (qos->history.kind == NN_KEEP_LAST_HISTORY_QOS) ? (uint32_t)qos->history.depth : ~0u; + rhc->by_source_ordering = (qos->destination_order.kind == DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP); + rhc->exclusive_ownership = (qos->ownership.kind == DDS_OWNERSHIP_EXCLUSIVE); + rhc->reliable = (qos->reliability.kind == DDS_RELIABILITY_RELIABLE); + assert(qos->history.kind != DDS_HISTORY_KEEP_LAST || qos->history.depth > 0); + rhc->history_depth = (qos->history.kind == DDS_HISTORY_KEEP_LAST) ? (uint32_t)qos->history.depth : ~0u; } static bool eval_predicate_sample (const struct rhc *rhc, const struct ddsi_serdata *sample, bool (*pred) (const void *sample)) diff --git a/src/core/ddsc/src/dds_serdata_builtintopic.c b/src/core/ddsc/src/dds_serdata_builtintopic.c index f043783..03b6409 100644 --- a/src/core/ddsc/src/dds_serdata_builtintopic.c +++ b/src/core/ddsc/src/dds_serdata_builtintopic.c @@ -186,7 +186,7 @@ static char *dds_string_dup_reuse (char *old, const char *src) return memcpy (new, src, size); } -static dds_qos_t *dds_qos_from_xqos_reuse (dds_qos_t *old, const nn_xqos_t *src) +static dds_qos_t *dds_qos_from_xqos_reuse (dds_qos_t *old, const dds_qos_t *src) { if (old == NULL) { diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c index 13a6680..31390cf 100644 --- a/src/core/ddsc/src/dds_topic.c +++ b/src/core/ddsc/src/dds_topic.c @@ -188,7 +188,7 @@ static dds_return_t dds_topic_qos_validate (const dds_qos_t *qos, bool enabled) return DDS_RETCODE_INCONSISTENT_POLICY; if ((qos->present & QP_DURABILITY_SERVICE) && validate_durability_service_qospolicy(&qos->durability_service) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; - if ((qos->present & QP_LIFESPAN) && validate_duration(&qos->lifespan.duration) < 0) + if ((qos->present & QP_LIFESPAN) && validate_duration(qos->lifespan.duration) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && validate_history_and_resource_limits(&qos->history, &qos->resource_limits) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; diff --git a/src/core/ddsc/src/dds_write.c b/src/core/ddsc/src/dds_write.c index 70cd6c7..d399e80 100644 --- a/src/core/ddsc/src/dds_write.c +++ b/src/core/ddsc/src/dds_write.c @@ -96,7 +96,7 @@ static dds_return_t deliver_locally (struct writer *wr, struct ddsi_serdata *pay struct reader ** const rdary = wr->rdary.rdary; if (rdary[0]) { - dds_duration_t max_block_ms = nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time); + dds_duration_t max_block_ms = wr->xqos->reliability.max_blocking_time; struct proxy_writer_info pwr_info; unsigned i; make_proxy_writer_info (&pwr_info, &wr->e, wr->xqos); @@ -121,7 +121,7 @@ static dds_return_t deliver_locally (struct writer *wr, struct ddsi_serdata *pay ddsrt_avl_iter_t it; struct pwr_rd_match *m; struct proxy_writer_info pwr_info; - dds_duration_t max_block_ms = nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time); + dds_duration_t max_block_ms = wr->xqos->reliability.max_blocking_time; ddsrt_mutex_unlock (&wr->rdary.rdary_lock); make_proxy_writer_info (&pwr_info, &wr->e, wr->xqos); ddsrt_mutex_lock (&wr->e.lock); diff --git a/src/core/ddsc/src/dds_writer.c b/src/core/ddsc/src/dds_writer.c index e8749fc..542be62 100644 --- a/src/core/ddsc/src/dds_writer.c +++ b/src/core/ddsc/src/dds_writer.c @@ -162,7 +162,7 @@ static void dds_writer_status_cb (void *ventity, const status_cb_data_t *data) ddsrt_mutex_unlock (&entity->m_observers_lock); } -static uint32_t get_bandwidth_limit (nn_transport_priority_qospolicy_t transport_priority) +static uint32_t get_bandwidth_limit (dds_transport_priority_qospolicy_t transport_priority) { #ifdef DDSI_INCLUDE_NETWORK_CHANNELS struct config_channel_listelem *channel = find_channel (transport_priority); @@ -214,7 +214,7 @@ static dds_return_t dds_writer_qos_validate (const dds_qos_t *qos, bool enabled) return DDS_RETCODE_INCONSISTENT_POLICY; if ((qos->present & QP_DURABILITY_SERVICE) && validate_durability_service_qospolicy (&qos->durability_service) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; - if ((qos->present & QP_LIFESPAN) && validate_duration (&qos->lifespan.duration) < 0) + if ((qos->present & QP_LIFESPAN) && validate_duration (qos->lifespan.duration) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && validate_history_and_resource_limits(&qos->history, &qos->resource_limits) < 0) return DDS_RETCODE_INCONSISTENT_POLICY; @@ -264,8 +264,8 @@ static struct whc *make_whc (const dds_qos_t *qos) /* Construct WHC -- if aggressive_keep_last1 is set, the WHC will drop all samples for which a later update is available. This forces it to maintain a tlidx. */ - handle_as_transient_local = (qos->durability.kind == NN_TRANSIENT_LOCAL_DURABILITY_QOS); - if (qos->history.kind == NN_KEEP_ALL_HISTORY_QOS) + handle_as_transient_local = (qos->durability.kind == DDS_DURABILITY_TRANSIENT_LOCAL); + if (qos->history.kind == DDS_HISTORY_KEEP_ALL) hdepth = 0; else hdepth = (unsigned) qos->history.depth; @@ -273,7 +273,7 @@ static struct whc *make_whc (const dds_qos_t *qos) tldepth = 0; else { - if (qos->durability_service.history.kind == NN_KEEP_ALL_HISTORY_QOS) + if (qos->durability_service.history.kind == DDS_HISTORY_KEEP_ALL) tldepth = 0; else tldepth = (unsigned) qos->durability_service.history.depth; diff --git a/src/core/ddsc/tests/entity_status.c b/src/core/ddsc/tests/entity_status.c index 737fbf7..662d3ae 100644 --- a/src/core/ddsc/tests/entity_status.c +++ b/src/core/ddsc/tests/entity_status.c @@ -41,7 +41,14 @@ static dds_time_t waitTimeout = DDS_SECS (2); static dds_time_t shortTimeout = DDS_MSECS (10); static dds_publication_matched_status_t publication_matched; static dds_subscription_matched_status_t subscription_matched; -static dds_resource_limits_qospolicy_t resource_limits = {1,1,1}; + +struct reslimits { + int32_t max_samples; + int32_t max_instances; + int32_t max_samples_per_instance; +}; + +static struct reslimits resource_limits = {1,1,1}; static dds_instance_handle_t reader_i_hdl = 0; static dds_instance_handle_t writer_i_hdl = 0; diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_rhc_plugin.h b/src/core/ddsi/include/dds/ddsi/ddsi_rhc_plugin.h index 1d37ecf..20754fd 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_rhc_plugin.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_rhc_plugin.h @@ -17,7 +17,7 @@ extern "C" { #endif struct rhc; -struct nn_xqos; +struct dds_qos; struct ddsi_tkmap_instance; struct ddsi_serdata; struct ddsi_sertopic; @@ -41,10 +41,10 @@ struct ddsi_rhc_plugin (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info); void (*rhc_relinquish_ownership_fn) (struct rhc * __restrict rhc, const uint64_t wr_iid); - void (*rhc_set_qos_fn) (struct rhc * rhc, const struct nn_xqos * qos); + void (*rhc_set_qos_fn) (struct rhc * rhc, const struct dds_qos * qos); }; -DDS_EXPORT void make_proxy_writer_info(struct proxy_writer_info *pwr_info, const struct entity_common *e, const struct nn_xqos *xqos); +DDS_EXPORT void make_proxy_writer_info(struct proxy_writer_info *pwr_info, const struct entity_common *e, const struct dds_qos *xqos); #if defined (__cplusplus) } diff --git a/src/core/ddsi/include/dds/ddsi/q_entity.h b/src/core/ddsi/include/dds/ddsi/q_entity.h index 0312e6d..709ad36 100644 --- a/src/core/ddsi/include/dds/ddsi/q_entity.h +++ b/src/core/ddsi/include/dds/ddsi/q_entity.h @@ -38,7 +38,7 @@ struct nn_rdata; struct addrset; struct ddsi_sertopic; struct whc; -struct nn_xqos; +struct dds_qos; struct nn_plist; struct lease; @@ -228,7 +228,7 @@ struct writer nn_count_t hbfragcount; /* last hb frag seq number */ int throttling; /* non-zero when some thread is waiting for the WHC to shrink */ struct hbcontrol hbcontrol; /* controls heartbeat timing, piggybacking */ - struct nn_xqos *xqos; + struct dds_qos *xqos; enum writer_state state; unsigned reliable: 1; /* iff 1, writer is reliable <=> heartbeat_xevent != NULL */ unsigned handle_as_transient_local: 1; /* controls whether data is retained in WHC */ @@ -270,7 +270,7 @@ struct reader status_cb_t status_cb; void * status_cb_entity; struct rhc * rhc; /* reader history, tracks registrations and data */ - struct nn_xqos *xqos; + struct dds_qos *xqos; unsigned reliable: 1; /* 1 iff reader is reliable */ unsigned handle_as_transient_local: 1; /* 1 iff reader wants historical data from proxy writers */ #ifdef DDSI_INCLUDE_SSM @@ -323,7 +323,7 @@ struct proxy_group { nn_guid_t guid; char *name; struct proxy_participant *proxypp; /* uncounted backref to proxy participant */ - struct nn_xqos *xqos; /* publisher/subscriber QoS */ + struct dds_qos *xqos; /* publisher/subscriber QoS */ }; struct proxy_endpoint_common @@ -331,7 +331,7 @@ struct proxy_endpoint_common struct proxy_participant *proxypp; /* counted backref to proxy participant */ struct proxy_endpoint_common *next_ep; /* next \ endpoint belonging to this proxy participant */ struct proxy_endpoint_common *prev_ep; /* prev / -- this is in arbitrary ordering */ - struct nn_xqos *xqos; /* proxy endpoint QoS lives here; FIXME: local ones should have it moved to common as well */ + struct dds_qos *xqos; /* proxy endpoint QoS lives here; FIXME: local ones should have it moved to common as well */ struct ddsi_sertopic * topic; /* topic may be NULL: for built-ins, but also for never-yet matched proxies (so we don't have to know the topic; when we match, we certainly do know) */ struct addrset *as; /* address set to use for communicating with this endpoint */ nn_guid_t group_guid; /* 0:0:0:0 if not available */ @@ -539,9 +539,9 @@ struct writer *get_builtin_writer (const struct participant *pp, unsigned entity GUID "ppguid". May return NULL if participant unknown or writer/reader already known. */ -dds_return_t new_writer (struct writer **wr_out, struct nn_guid *wrguid, const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc * whc, status_cb_t status_cb, void *status_cb_arg); +dds_return_t new_writer (struct writer **wr_out, struct nn_guid *wrguid, const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc * whc, status_cb_t status_cb, void *status_cb_arg); -dds_return_t new_reader (struct reader **rd_out, struct nn_guid *rdguid, const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct rhc * rhc, status_cb_t status_cb, void *status_cb_arg); +dds_return_t new_reader (struct reader **rd_out, struct nn_guid *rdguid, const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct rhc * rhc, status_cb_t status_cb, void *status_cb_arg); struct whc_node; struct whc_state; @@ -561,7 +561,7 @@ uint64_t reader_instance_id (const struct nn_guid *guid); struct local_orphan_writer { struct writer wr; }; -struct local_orphan_writer *new_local_orphan_writer (nn_entityid_t entityid, struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc *whc); +struct local_orphan_writer *new_local_orphan_writer (nn_entityid_t entityid, struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc *whc); void delete_local_orphan_writer (struct local_orphan_writer *wr); /* To create or delete a new proxy participant: "guid" MUST have the @@ -623,7 +623,7 @@ int delete_proxy_reader (const struct nn_guid *guid, nn_wctime_t timestamp, int void update_proxy_reader (struct proxy_reader * prd, struct addrset *as); void update_proxy_writer (struct proxy_writer * pwr, struct addrset *as); -int new_proxy_group (const struct nn_guid *guid, const char *name, const struct nn_xqos *xqos, nn_wctime_t timestamp); +int new_proxy_group (const struct nn_guid *guid, const char *name, const struct dds_qos *xqos, nn_wctime_t timestamp); void delete_proxy_group (const struct nn_guid *guid, nn_wctime_t timestamp, int isimplicit); uint64_t writer_instance_id (const struct nn_guid *guid); diff --git a/src/core/ddsi/include/dds/ddsi/q_globals.h b/src/core/ddsi/include/dds/ddsi/q_globals.h index 857bd4c..418fd88 100644 --- a/src/core/ddsi/include/dds/ddsi/q_globals.h +++ b/src/core/ddsi/include/dds/ddsi/q_globals.h @@ -233,15 +233,15 @@ struct q_globals { packets); plus the actual QoSs needed for the builtin endpoints. */ nn_plist_t default_plist_pp; - nn_xqos_t default_xqos_rd; - nn_xqos_t default_xqos_wr; - nn_xqos_t default_xqos_wr_nad; - nn_xqos_t default_xqos_tp; - nn_xqos_t default_xqos_sub; - nn_xqos_t default_xqos_pub; - nn_xqos_t spdp_endpoint_xqos; - nn_xqos_t builtin_endpoint_xqos_rd; - nn_xqos_t builtin_endpoint_xqos_wr; + dds_qos_t default_xqos_rd; + dds_qos_t default_xqos_wr; + dds_qos_t default_xqos_wr_nad; + dds_qos_t default_xqos_tp; + dds_qos_t default_xqos_sub; + dds_qos_t default_xqos_pub; + dds_qos_t spdp_endpoint_xqos; + dds_qos_t builtin_endpoint_xqos_rd; + dds_qos_t builtin_endpoint_xqos_wr; /* SPDP packets get very special treatment (they're the only packets we accept from writers we don't know) and have their very own diff --git a/src/core/ddsi/include/dds/ddsi/q_plist.h b/src/core/ddsi/include/dds/ddsi/q_plist.h index 639401f..98b9466 100644 --- a/src/core/ddsi/include/dds/ddsi/q_plist.h +++ b/src/core/ddsi/include/dds/ddsi/q_plist.h @@ -137,7 +137,7 @@ typedef struct nn_plist { uint64_t aliased; int unalias_needs_bswap; - nn_xqos_t qos; + dds_qos_t qos; nn_protocol_version_t protocol_version; nn_vendorid_t vendorid; @@ -151,7 +151,7 @@ typedef struct nn_plist { unsigned char expects_inline_qos; nn_count_t participant_manual_liveliness_count; unsigned participant_builtin_endpoints; - nn_duration_t participant_lease_duration; + dds_duration_t participant_lease_duration; /* nn_content_filter_property_t content_filter_property; */ nn_guid_t participant_guid; nn_guid_t endpoint_guid; @@ -245,20 +245,19 @@ DDS_EXPORT void nn_plist_fini (nn_plist_t *ps); DDS_EXPORT void nn_plist_addtomsg (struct nn_xmsg *m, const nn_plist_t *ps, uint64_t pwanted, uint64_t qwanted); DDS_EXPORT void nn_plist_init_default_participant (nn_plist_t *plist); -DDS_EXPORT dds_return_t validate_history_qospolicy (const nn_history_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_durability_qospolicy (const nn_durability_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_resource_limits_qospolicy (const nn_resource_limits_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_history_and_resource_limits (const nn_history_qospolicy_t *qh, const nn_resource_limits_qospolicy_t *qr); -DDS_EXPORT dds_return_t validate_durability_service_qospolicy (const nn_durability_service_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_liveliness_qospolicy (const nn_liveliness_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_destination_order_qospolicy (const nn_destination_order_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_ownership_qospolicy (const nn_ownership_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_ownership_strength_qospolicy (const nn_ownership_strength_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_presentation_qospolicy (const nn_presentation_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_transport_priority_qospolicy (const nn_transport_priority_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_reader_data_lifecycle (const nn_reader_data_lifecycle_qospolicy_t *q); -DDS_EXPORT dds_return_t validate_duration (const nn_duration_t *d); - +DDS_EXPORT dds_return_t validate_history_qospolicy (const dds_history_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_durability_qospolicy (const dds_durability_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_resource_limits_qospolicy (const dds_resource_limits_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_history_and_resource_limits (const dds_history_qospolicy_t *qh, const dds_resource_limits_qospolicy_t *qr); +DDS_EXPORT dds_return_t validate_durability_service_qospolicy (const dds_durability_service_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_liveliness_qospolicy (const dds_liveliness_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_destination_order_qospolicy (const dds_destination_order_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_ownership_qospolicy (const dds_ownership_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_ownership_strength_qospolicy (const dds_ownership_strength_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_presentation_qospolicy (const dds_presentation_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_transport_priority_qospolicy (const dds_transport_priority_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_reader_data_lifecycle (const dds_reader_data_lifecycle_qospolicy_t *q); +DDS_EXPORT dds_return_t validate_duration (const dds_duration_t d); struct nn_rmsg; struct nn_rsample_info; diff --git a/src/core/ddsi/include/dds/ddsi/q_protocol.h b/src/core/ddsi/include/dds/ddsi/q_protocol.h index d0a3de2..f8f65d6 100644 --- a/src/core/ddsi/include/dds/ddsi/q_protocol.h +++ b/src/core/ddsi/include/dds/ddsi/q_protocol.h @@ -167,7 +167,7 @@ typedef enum SubmessageKind { typedef struct InfoTimestamp { SubmessageHeader_t smhdr; - nn_ddsi_time_t time; + ddsi_time_t time; } InfoTimestamp_t; typedef struct EntityId { @@ -196,7 +196,7 @@ typedef struct InfoSRC { #define PL_CDR_LE 0x0003u #endif -typedef unsigned short nn_parameterid_t; /* spec says short */ +typedef uint16_t nn_parameterid_t; /* spec says short */ typedef struct nn_parameter { nn_parameterid_t parameterid; uint16_t length; /* spec says signed short */ @@ -257,7 +257,7 @@ typedef struct Gap { typedef struct InfoTS { SubmessageHeader_t smhdr; - nn_ddsi_time_t time; + ddsi_time_t time; } InfoTS_t; #define INFOTS_INVALIDATE_FLAG 0x2u diff --git a/src/core/ddsi/include/dds/ddsi/q_qosmatch.h b/src/core/ddsi/include/dds/ddsi/q_qosmatch.h index d70c24c..7cfd371 100644 --- a/src/core/ddsi/include/dds/ddsi/q_qosmatch.h +++ b/src/core/ddsi/include/dds/ddsi/q_qosmatch.h @@ -16,13 +16,13 @@ extern "C" { #endif -struct nn_xqos; +struct dds_qos; -int partitions_match_p (const struct nn_xqos *a, const struct nn_xqos *b); +int partitions_match_p (const struct dds_qos *a, const struct dds_qos *b); /* Returns -1 on success, or QoS id of first mismatch (>=0) */ -int32_t qos_match_p (const struct nn_xqos *rd, const struct nn_xqos *wr); +bool qos_match_p (const struct dds_qos *rd, const struct dds_qos *wr, dds_qos_policy_id_t *reason) ddsrt_nonnull ((1, 2)); #if defined (__cplusplus) } diff --git a/src/core/ddsi/include/dds/ddsi/q_radmin.h b/src/core/ddsi/include/dds/ddsi/q_radmin.h index 95df0a7..bfba76c 100644 --- a/src/core/ddsi/include/dds/ddsi/q_radmin.h +++ b/src/core/ddsi/include/dds/ddsi/q_radmin.h @@ -115,7 +115,7 @@ struct nn_rsample_info { struct proxy_writer *pwr; uint32_t size; uint32_t fragsize; - nn_ddsi_time_t timestamp; + nn_wctime_t timestamp; nn_wctime_t reception_timestamp; /* OpenSplice extension -- but we get it essentially for free, so why not? */ unsigned statusinfo: 2; /* just the two defined bits from the status info */ unsigned pt_wr_info_zoff: 16; /* PrismTech writer info offset */ diff --git a/src/core/ddsi/include/dds/ddsi/q_time.h b/src/core/ddsi/include/dds/ddsi/q_time.h index 5c89cfa..7bdd5b0 100644 --- a/src/core/ddsi/include/dds/ddsi/q_time.h +++ b/src/core/ddsi/include/dds/ddsi/q_time.h @@ -26,11 +26,13 @@ extern "C" { #define T_MICROSECOND (T_MILLISECOND/1000) typedef struct { - int seconds; - unsigned fraction; -} nn_ddsi_time_t; + int32_t seconds; + uint32_t fraction; +} ddsi_time_t; +#define DDSI_TIME_INFINITE ((ddsi_time_t) { INT32_MAX, UINT32_MAX }) +#define DDSI_TIME_INVALID ((ddsi_time_t) { -1, UINT32_MAX }) -typedef nn_ddsi_time_t nn_duration_t; +typedef ddsi_time_t ddsi_duration_t; typedef struct { int64_t v; @@ -44,11 +46,9 @@ typedef struct { int64_t v; } nn_etime_t; -extern const nn_ddsi_time_t invalid_ddsi_timestamp; -extern const nn_ddsi_time_t ddsi_time_infinite; -extern const nn_duration_t duration_infinite; +#define NN_WCTIME_INVALID ((nn_wctime_t) { INT64_MIN }) -int valid_ddsi_timestamp (nn_ddsi_time_t t); +int valid_ddsi_timestamp (ddsi_time_t t); DDS_EXPORT nn_wctime_t now (void); /* wall clock time */ DDS_EXPORT nn_mtime_t now_mt (void); /* monotonic time */ @@ -61,10 +61,10 @@ DDS_EXPORT nn_mtime_t add_duration_to_mtime (nn_mtime_t t, int64_t d); DDS_EXPORT nn_wctime_t add_duration_to_wctime (nn_wctime_t t, int64_t d); DDS_EXPORT nn_etime_t add_duration_to_etime (nn_etime_t t, int64_t d); -DDS_EXPORT nn_ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t); -DDS_EXPORT nn_wctime_t nn_wctime_from_ddsi_time (nn_ddsi_time_t x); -DDS_EXPORT nn_duration_t nn_to_ddsi_duration (int64_t t); -DDS_EXPORT int64_t nn_from_ddsi_duration (nn_duration_t x); +DDS_EXPORT ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t); +DDS_EXPORT nn_wctime_t nn_wctime_from_ddsi_time (ddsi_time_t x); +DDS_EXPORT ddsi_duration_t nn_to_ddsi_duration (int64_t t); +DDS_EXPORT int64_t nn_from_ddsi_duration (ddsi_duration_t x); #if defined (__cplusplus) } diff --git a/src/core/ddsi/include/dds/ddsi/q_xmsg.h b/src/core/ddsi/include/dds/ddsi/q_xmsg.h index f9abcfa..9b7e1eb 100644 --- a/src/core/ddsi/include/dds/ddsi/q_xmsg.h +++ b/src/core/ddsi/include/dds/ddsi/q_xmsg.h @@ -121,21 +121,25 @@ void nn_xmsg_submsg_setnext (struct nn_xmsg *msg, struct nn_xmsg_marker marker); void nn_xmsg_submsg_init (struct nn_xmsg *msg, struct nn_xmsg_marker marker, SubmessageKind_t smkind); void nn_xmsg_add_timestamp (struct nn_xmsg *m, nn_wctime_t t); void nn_xmsg_add_entityid (struct nn_xmsg * m); -void *nn_xmsg_addpar (struct nn_xmsg *m, unsigned pid, size_t len); -void nn_xmsg_addpar_string (struct nn_xmsg *m, unsigned pid, const char *str); -void nn_xmsg_addpar_octetseq (struct nn_xmsg *m, unsigned pid, const nn_octetseq_t *oseq); -void nn_xmsg_addpar_stringseq (struct nn_xmsg *m, unsigned pid, const nn_stringseq_t *sseq); -void nn_xmsg_addpar_guid (struct nn_xmsg *m, unsigned pid, const nn_guid_t *guid); -void nn_xmsg_addpar_BE4u (struct nn_xmsg *m, unsigned pid, unsigned x); -void nn_xmsg_addpar_4u (struct nn_xmsg *m, unsigned pid, unsigned x); +void *nn_xmsg_addpar (struct nn_xmsg *m, nn_parameterid_t pid, size_t len); +void nn_xmsg_addpar_string (struct nn_xmsg *m, nn_parameterid_t pid, const char *str); +void nn_xmsg_addpar_octetseq (struct nn_xmsg *m, nn_parameterid_t pid, const ddsi_octetseq_t *oseq); +void nn_xmsg_addpar_stringseq (struct nn_xmsg *m, nn_parameterid_t pid, const ddsi_stringseq_t *sseq); +void nn_xmsg_addpar_guid (struct nn_xmsg *m, nn_parameterid_t pid, const nn_guid_t *guid); +void nn_xmsg_addpar_BE4u (struct nn_xmsg *m, nn_parameterid_t pid, uint32_t x); +void nn_xmsg_addpar_4u (struct nn_xmsg *m, nn_parameterid_t pid, uint32_t x); void nn_xmsg_addpar_keyhash (struct nn_xmsg *m, const struct ddsi_serdata *serdata); -void nn_xmsg_addpar_statusinfo (struct nn_xmsg *m, unsigned statusinfo); -void nn_xmsg_addpar_reliability (struct nn_xmsg *m, unsigned pid, const struct nn_reliability_qospolicy *rq); -void nn_xmsg_addpar_share (struct nn_xmsg *m, unsigned pid, const struct nn_share_qospolicy *rq); -void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, unsigned pid, const struct nn_subscription_keys_qospolicy *rq); +void nn_xmsg_addpar_statusinfo (struct nn_xmsg *m, uint32_t statusinfo); +void nn_xmsg_addpar_reliability (struct nn_xmsg *m, nn_parameterid_t pid, const struct dds_reliability_qospolicy *rq); +void nn_xmsg_addpar_duration (struct nn_xmsg *m, nn_parameterid_t pid, const dds_duration_t dur); +void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, nn_parameterid_t pid, const struct dds_subscription_keys_qospolicy *rq); +void nn_xmsg_addpar_durability_service (struct nn_xmsg *m, nn_parameterid_t pid, const dds_durability_service_qospolicy_t *rq); +void nn_xmsg_addpar_reader_lifespan (struct nn_xmsg *m, nn_parameterid_t pid, const dds_reader_lifespan_qospolicy_t *rq); +void nn_xmsg_addpar_reader_data_lifecycle (struct nn_xmsg *m, nn_parameterid_t pid, const dds_reader_data_lifecycle_qospolicy_t *rq); +void nn_xmsg_addpar_liveliness (struct nn_xmsg *m, nn_parameterid_t pid, const dds_liveliness_qospolicy_t *rq); -void nn_xmsg_addpar_parvinfo (struct nn_xmsg *m, unsigned pid, const struct nn_prismtech_participant_version_info *pvi); -void nn_xmsg_addpar_eotinfo (struct nn_xmsg *m, unsigned pid, const struct nn_prismtech_eotinfo *txnid); +void nn_xmsg_addpar_parvinfo (struct nn_xmsg *m, nn_parameterid_t pid, const struct nn_prismtech_participant_version_info *pvi); +void nn_xmsg_addpar_eotinfo (struct nn_xmsg *m, nn_parameterid_t pid, const struct nn_prismtech_eotinfo *txnid); void nn_xmsg_addpar_sentinel (struct nn_xmsg *m); int nn_xmsg_addpar_sentinel_ifparam (struct nn_xmsg *m); diff --git a/src/core/ddsi/include/dds/ddsi/q_xqos.h b/src/core/ddsi/include/dds/ddsi/q_xqos.h index d13207d..225e280 100644 --- a/src/core/ddsi/include/dds/ddsi/q_xqos.h +++ b/src/core/ddsi/include/dds/ddsi/q_xqos.h @@ -12,6 +12,7 @@ #ifndef NN_XQOS_H #define NN_XQOS_H +#include "dds/ddsc/dds_public_qosdefs.h" /*XXX*/ #include "dds/ddsi/q_protocol.h" #include "dds/ddsi/q_rtps.h" @@ -22,198 +23,164 @@ extern "C" { #endif -#define NN_DDS_LENGTH_UNLIMITED -1 - -typedef struct nn_octetseq { +typedef struct ddsi_octetseq { uint32_t length; unsigned char *value; -} nn_octetseq_t; +} ddsi_octetseq_t; -typedef nn_octetseq_t nn_userdata_qospolicy_t; -typedef nn_octetseq_t nn_topicdata_qospolicy_t; -typedef nn_octetseq_t nn_groupdata_qospolicy_t; +typedef ddsi_octetseq_t dds_userdata_qospolicy_t; +typedef ddsi_octetseq_t dds_topicdata_qospolicy_t; +typedef ddsi_octetseq_t dds_groupdata_qospolicy_t; -typedef enum nn_durability_kind { - NN_VOLATILE_DURABILITY_QOS, - NN_TRANSIENT_LOCAL_DURABILITY_QOS, - NN_TRANSIENT_DURABILITY_QOS, - NN_PERSISTENT_DURABILITY_QOS -} nn_durability_kind_t; +typedef struct dds_durability_qospolicy { + dds_durability_kind_t kind; +} dds_durability_qospolicy_t; -typedef struct nn_durability_qospolicy { - nn_durability_kind_t kind; -} nn_durability_qospolicy_t; - -typedef enum nn_history_kind { - NN_KEEP_LAST_HISTORY_QOS, - NN_KEEP_ALL_HISTORY_QOS -} nn_history_kind_t; - -typedef struct nn_history_qospolicy { - nn_history_kind_t kind; +typedef struct dds_history_qospolicy { + dds_history_kind_t kind; int32_t depth; -} nn_history_qospolicy_t; +} dds_history_qospolicy_t; -typedef struct nn_resource_limits_qospolicy { +typedef struct dds_resource_limits_qospolicy { int32_t max_samples; int32_t max_instances; int32_t max_samples_per_instance; -} nn_resource_limits_qospolicy_t; +} dds_resource_limits_qospolicy_t; -typedef struct nn_durability_service_qospolicy { - nn_duration_t service_cleanup_delay; - nn_history_qospolicy_t history; - nn_resource_limits_qospolicy_t resource_limits; -} nn_durability_service_qospolicy_t; +typedef struct dds_durability_service_qospolicy { + dds_duration_t service_cleanup_delay; + dds_history_qospolicy_t history; + dds_resource_limits_qospolicy_t resource_limits; +} dds_durability_service_qospolicy_t; -typedef enum nn_presentation_access_scope_kind { - NN_INSTANCE_PRESENTATION_QOS, - NN_TOPIC_PRESENTATION_QOS, - NN_GROUP_PRESENTATION_QOS -} nn_presentation_access_scope_kind_t; +typedef struct dds_external_durability_service_qospolicy { + ddsi_duration_t service_cleanup_delay; + dds_history_qospolicy_t history; + dds_resource_limits_qospolicy_t resource_limits; +} dds_external_durability_service_qospolicy_t; -typedef struct nn_presentation_qospolicy { - nn_presentation_access_scope_kind_t access_scope; +typedef struct dds_presentation_qospolicy { + dds_presentation_access_scope_kind_t access_scope; unsigned char coherent_access; unsigned char ordered_access; -} nn_presentation_qospolicy_t; +} dds_presentation_qospolicy_t; -typedef struct nn_deadline_qospolicy { - nn_duration_t deadline; -} nn_deadline_qospolicy_t; +typedef struct dds_deadline_qospolicy { + dds_duration_t deadline; +} dds_deadline_qospolicy_t; -typedef struct nn_latency_budget_qospolicy { - nn_duration_t duration; -} nn_latency_budget_qospolicy_t; +typedef struct dds_external_deadline_qospolicy { + ddsi_duration_t deadline; +} dds_external_deadline_qospolicy_t; -typedef enum nn_ownership_kind { - NN_SHARED_OWNERSHIP_QOS, - NN_EXCLUSIVE_OWNERSHIP_QOS -} nn_ownership_kind_t; +typedef struct dds_latency_budget_qospolicy { + dds_duration_t duration; +} dds_latency_budget_qospolicy_t; -typedef struct nn_ownership_qospolicy { - nn_ownership_kind_t kind; -} nn_ownership_qospolicy_t; +typedef struct dds_external_latency_budget_qospolicy { + ddsi_duration_t duration; +} dds_external_latency_budget_qospolicy_t; -typedef struct nn_ownership_strength_qospolicy { +typedef struct dds_ownership_qospolicy { + dds_ownership_kind_t kind; +} dds_ownership_qospolicy_t; + +typedef struct dds_ownership_strength_qospolicy { int32_t value; -} nn_ownership_strength_qospolicy_t; +} dds_ownership_strength_qospolicy_t; -typedef enum nn_liveliness_kind { - NN_AUTOMATIC_LIVELINESS_QOS, - NN_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS, - NN_MANUAL_BY_TOPIC_LIVELINESS_QOS -} nn_liveliness_kind_t; +typedef struct dds_liveliness_qospolicy { + dds_liveliness_kind_t kind; + dds_duration_t lease_duration; +} dds_liveliness_qospolicy_t; -typedef struct nn_liveliness_qospolicy { - nn_liveliness_kind_t kind; - nn_duration_t lease_duration; -} nn_liveliness_qospolicy_t; +typedef struct dds_external_liveliness_qospolicy { + dds_liveliness_kind_t kind; + ddsi_duration_t lease_duration; +} dds_external_liveliness_qospolicy_t; -typedef struct nn_time_based_filter_qospolicy { - nn_duration_t minimum_separation; -} nn_time_based_filter_qospolicy_t; +typedef struct dds_time_based_filter_qospolicy { + dds_duration_t minimum_separation; +} dds_time_based_filter_qospolicy_t; -typedef struct nn_stringseq { +typedef struct dds_external_time_based_filter_qospolicy { + ddsi_duration_t minimum_separation; +} dds_external_time_based_filter_qospolicy_t; + +typedef struct ddsi_stringseq { uint32_t n; char **strs; -} nn_stringseq_t; +} ddsi_stringseq_t; -typedef nn_stringseq_t nn_partition_qospolicy_t; +typedef ddsi_stringseq_t dds_partition_qospolicy_t; -typedef enum nn_reliability_kind { - NN_BEST_EFFORT_RELIABILITY_QOS, - NN_RELIABLE_RELIABILITY_QOS -} nn_reliability_kind_t; +typedef struct dds_reliability_qospolicy { + dds_reliability_kind_t kind; + dds_duration_t max_blocking_time; +} dds_reliability_qospolicy_t; -typedef struct nn_reliability_qospolicy { - nn_reliability_kind_t kind; - nn_duration_t max_blocking_time; -} nn_reliability_qospolicy_t; +typedef enum dds_external_reliability_kind { + DDS_EXTERNAL_RELIABILITY_BEST_EFFORT = 1, + DDS_EXTERNAL_RELIABILITY_RELIABLE = 2 +} dds_external_reliability_kind_t; -typedef struct nn_external_reliability_qospolicy { - uint32_t kind; - nn_duration_t max_blocking_time; -} nn_external_reliability_qospolicy_t; +typedef struct dds_external_reliability_qospolicy { + dds_external_reliability_kind_t kind; + ddsi_duration_t max_blocking_time; +} dds_external_reliability_qospolicy_t; -#define NN_PEDANTIC_BEST_EFFORT_RELIABILITY_QOS 1 -#define NN_PEDANTIC_RELIABLE_RELIABILITY_QOS 3 /* <= see DDSI 2.1, table 9.4 */ -#define NN_INTEROP_BEST_EFFORT_RELIABILITY_QOS 1 -#define NN_INTEROP_RELIABLE_RELIABILITY_QOS 2 - -typedef struct nn_transport_priority_qospolicy { +typedef struct dds_transport_priority_qospolicy { int32_t value; -} nn_transport_priority_qospolicy_t; +} dds_transport_priority_qospolicy_t; -typedef struct nn_lifespan_qospolicy { - nn_duration_t duration; -} nn_lifespan_qospolicy_t; +typedef struct dds_lifespan_qospolicy { + dds_duration_t duration; +} dds_lifespan_qospolicy_t; -typedef enum nn_destination_order_kind { - NN_BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS, - NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS -} nn_destination_order_kind_t; +typedef struct dds_external_lifespan_qospolicy { + ddsi_duration_t duration; +} dds_external_lifespan_qospolicy_t; -typedef struct nn_destination_order_qospolicy { - nn_destination_order_kind_t kind; -} nn_destination_order_qospolicy_t; +typedef struct dds_destination_order_qospolicy { + dds_destination_order_kind_t kind; +} dds_destination_order_qospolicy_t; -typedef struct nn_entity_factory_qospolicy { +typedef struct dds_entity_factory_qospolicy { unsigned char autoenable_created_entities; -} nn_entity_factory_qospolicy_t; +} dds_entity_factory_qospolicy_t; -typedef struct nn_writer_data_lifecycle_qospolicy { +typedef struct dds_writer_data_lifecycle_qospolicy { unsigned char autodispose_unregistered_instances; - nn_duration_t autopurge_suspended_samples_delay; /* OpenSplice extension */ - nn_duration_t autounregister_instance_delay; /* OpenSplice extension */ -} nn_writer_data_lifecycle_qospolicy_t; +} dds_writer_data_lifecycle_qospolicy_t; -typedef enum nn_invalid_sample_visibility_kind { - NN_NO_INVALID_SAMPLE_VISIBILITY_QOS, - NN_MINIMUM_INVALID_SAMPLE_VISIBILITY_QOS, - NN_ALL_INVALID_SAMPLE_VISIBILITY_QOS -} nn_invalid_sample_visibility_kind_t; +typedef struct dds_reader_data_lifecycle_qospolicy { + dds_duration_t autopurge_nowriter_samples_delay; + dds_duration_t autopurge_disposed_samples_delay; +} dds_reader_data_lifecycle_qospolicy_t; -typedef struct nn_reader_data_lifecycle_qospolicy { - nn_duration_t autopurge_nowriter_samples_delay; - nn_duration_t autopurge_disposed_samples_delay; - unsigned char autopurge_dispose_all; /* OpenSplice extension */ - unsigned char enable_invalid_samples; /* OpenSplice extension */ - nn_invalid_sample_visibility_kind_t invalid_sample_visibility; /* OpenSplice extension */ -} nn_reader_data_lifecycle_qospolicy_t; +typedef struct dds_external_reader_data_lifecycle_qospolicy { + ddsi_duration_t autopurge_nowriter_samples_delay; + ddsi_duration_t autopurge_disposed_samples_delay; +} dds_external_reader_data_lifecycle_qospolicy_t; -typedef struct nn_synchronous_endpoint_qospolicy { - unsigned char value; -} nn_synchronous_endpoint_qospolicy_t; - -typedef struct nn_relaxed_qos_matching_qospolicy { - unsigned char value; -} nn_relaxed_qos_matching_qospolicy_t; - -typedef struct nn_subscription_keys_qospolicy { +typedef struct dds_subscription_keys_qospolicy { unsigned char use_key_list; - nn_stringseq_t key_list; -} nn_subscription_keys_qospolicy_t; + ddsi_stringseq_t key_list; +} dds_subscription_keys_qospolicy_t; -typedef struct nn_reader_lifespan_qospolicy { +typedef struct dds_reader_lifespan_qospolicy { unsigned char use_lifespan; - nn_duration_t duration; -} nn_reader_lifespan_qospolicy_t; + dds_duration_t duration; +} dds_reader_lifespan_qospolicy_t; -typedef struct nn_share_qospolicy { - unsigned char enable; - char *name; -} nn_share_qospolicy_t; +typedef struct dds_external_reader_lifespan_qospolicy { + unsigned char use_lifespan; + ddsi_duration_t duration; +} dds_external_reader_lifespan_qospolicy_t; -typedef enum nn_ignorelocal_kind { - NN_NONE_IGNORELOCAL_QOS, - NN_PARTICIPANT_IGNORELOCAL_QOS, - NN_PROCESS_IGNORELOCAL_QOS -} nn_ignorelocal_kind_t; - -typedef struct nn_ignorelocal_qospolicy { - nn_ignorelocal_kind_t value; -} nn_ignorelocal_qospolicy_t; +typedef struct dds_ignorelocal_qospolicy { + dds_ignorelocal_kind_t value; +} dds_ignorelocal_qospolicy_t; /***/ @@ -241,11 +208,9 @@ typedef struct nn_ignorelocal_qospolicy { #define QP_TIME_BASED_FILTER ((uint64_t)1 << 20) #define QP_PRISMTECH_WRITER_DATA_LIFECYCLE ((uint64_t)1 << 21) #define QP_PRISMTECH_READER_DATA_LIFECYCLE ((uint64_t)1 << 22) -#define QP_PRISMTECH_RELAXED_QOS_MATCHING ((uint64_t)1 << 23) #define QP_PRISMTECH_READER_LIFESPAN ((uint64_t)1 << 24) #define QP_PRISMTECH_SUBSCRIPTION_KEYS ((uint64_t)1 << 25) #define QP_PRISMTECH_ENTITY_FACTORY ((uint64_t)1 << 27) -#define QP_PRISMTECH_SYNCHRONOUS_ENDPOINT ((uint64_t)1 << 28) #define QP_RTI_TYPECODE ((uint64_t)1 << 29) #define QP_CYCLONE_IGNORELOCAL ((uint64_t)1 << 30) @@ -253,13 +218,13 @@ typedef struct nn_ignorelocal_qospolicy { section 7.1.3), but communication will not take place unless it matches. Same for topic and type. Relaxed qos matching is a bit of a weird one, but it affects matching, so ... */ -#define QP_RXO_MASK (QP_DURABILITY | QP_PRESENTATION | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_RELIABILITY | QP_DESTINATION_ORDER | QP_PRISMTECH_RELAXED_QOS_MATCHING | QP_PRISMTECH_SYNCHRONOUS_ENDPOINT) +#define QP_RXO_MASK (QP_DURABILITY | QP_PRESENTATION | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_RELIABILITY | QP_DESTINATION_ORDER) #define QP_CHANGEABLE_MASK (QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP_STRENGTH | QP_TIME_BASED_FILTER | QP_PARTITION | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_PRISMTECH_ENTITY_FACTORY | QP_PRISMTECH_WRITER_DATA_LIFECYCLE | QP_PRISMTECH_READER_DATA_LIFECYCLE) -#define QP_UNRECOGNIZED_INCOMPATIBLE_MASK (QP_PRISMTECH_RELAXED_QOS_MATCHING) +#define QP_UNRECOGNIZED_INCOMPATIBLE_MASK ((uint64_t) 0) /* readers & writers have an extended qos, hence why it is a separate type */ -typedef struct nn_xqos { +struct dds_qos { /* Entries present, for sparse QoS */ uint64_t present; uint64_t aliased; @@ -272,57 +237,54 @@ typedef struct nn_xqos { /* xx */char *topic_name; /* xx */char *type_name; /* PublisherQos, SubscriberQos: */ - /*xxx */nn_presentation_qospolicy_t presentation; - /*xxx */nn_partition_qospolicy_t partition; - /*xxx */nn_groupdata_qospolicy_t group_data; - /*x xX*/nn_entity_factory_qospolicy_t entity_factory; + /*xxx */dds_presentation_qospolicy_t presentation; + /*xxx */dds_partition_qospolicy_t partition; + /*xxx */dds_groupdata_qospolicy_t group_data; + /*x xX*/dds_entity_factory_qospolicy_t entity_factory; /* TopicQos: */ - /*xxx */nn_topicdata_qospolicy_t topic_data; + /*xxx */dds_topicdata_qospolicy_t topic_data; /* DataWriterQos, DataReaderQos: */ - /*xxx */nn_durability_qospolicy_t durability; - /*xxx */nn_durability_service_qospolicy_t durability_service; - /*xxx */nn_deadline_qospolicy_t deadline; - /*xxx */nn_latency_budget_qospolicy_t latency_budget; - /*xxx */nn_liveliness_qospolicy_t liveliness; - /*xxx */nn_reliability_qospolicy_t reliability; - /*xxx */nn_destination_order_qospolicy_t destination_order; - /*x x */nn_history_qospolicy_t history; - /*x x */nn_resource_limits_qospolicy_t resource_limits; - /*x x */nn_transport_priority_qospolicy_t transport_priority; - /*xxx */nn_lifespan_qospolicy_t lifespan; - /*xxx */nn_userdata_qospolicy_t user_data; - /*xxx */nn_ownership_qospolicy_t ownership; - /*xxxW*/nn_ownership_strength_qospolicy_t ownership_strength; - /*xxxR*/nn_time_based_filter_qospolicy_t time_based_filter; - /*x W*/nn_writer_data_lifecycle_qospolicy_t writer_data_lifecycle; - /*x xR*/nn_reader_data_lifecycle_qospolicy_t reader_data_lifecycle; - /*x x */nn_relaxed_qos_matching_qospolicy_t relaxed_qos_matching; - /*x xR*/nn_subscription_keys_qospolicy_t subscription_keys; - /*x xR*/nn_reader_lifespan_qospolicy_t reader_lifespan; - /*x xR*/nn_share_qospolicy_t share; - /*xxx */nn_synchronous_endpoint_qospolicy_t synchronous_endpoint; - /* x */nn_ignorelocal_qospolicy_t ignorelocal; + /*xxx */dds_durability_qospolicy_t durability; + /*xxx */dds_durability_service_qospolicy_t durability_service; + /*xxx */dds_deadline_qospolicy_t deadline; + /*xxx */dds_latency_budget_qospolicy_t latency_budget; + /*xxx */dds_liveliness_qospolicy_t liveliness; + /*xxx */dds_reliability_qospolicy_t reliability; + /*xxx */dds_destination_order_qospolicy_t destination_order; + /*x x */dds_history_qospolicy_t history; + /*x x */dds_resource_limits_qospolicy_t resource_limits; + /*x x */dds_transport_priority_qospolicy_t transport_priority; + /*xxx */dds_lifespan_qospolicy_t lifespan; + /*xxx */dds_userdata_qospolicy_t user_data; + /*xxx */dds_ownership_qospolicy_t ownership; + /*xxxW*/dds_ownership_strength_qospolicy_t ownership_strength; + /*xxxR*/dds_time_based_filter_qospolicy_t time_based_filter; + /*x W*/dds_writer_data_lifecycle_qospolicy_t writer_data_lifecycle; + /*x xR*/dds_reader_data_lifecycle_qospolicy_t reader_data_lifecycle; + /*x xR*/dds_subscription_keys_qospolicy_t subscription_keys; + /*x xR*/dds_reader_lifespan_qospolicy_t reader_lifespan; + /* x */dds_ignorelocal_qospolicy_t ignorelocal; - /* X*/nn_octetseq_t rti_typecode; -} nn_xqos_t; + /* X*/ddsi_octetseq_t rti_typecode; +}; struct nn_xmsg; -DDS_EXPORT void nn_xqos_init_empty (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_init_default_reader (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_init_default_writer (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_init_default_writer_noautodispose (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_init_default_subscriber (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_init_default_publisher (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_init_default_topic (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_copy (nn_xqos_t *dst, const nn_xqos_t *src); -DDS_EXPORT void nn_xqos_unalias (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_fini (nn_xqos_t *xqos); -DDS_EXPORT void nn_xqos_mergein_missing (nn_xqos_t *a, const nn_xqos_t *b); -DDS_EXPORT uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask); -DDS_EXPORT void nn_xqos_addtomsg (struct nn_xmsg *m, const nn_xqos_t *xqos, uint64_t wanted); -DDS_EXPORT void nn_log_xqos (uint32_t cat, const nn_xqos_t *xqos); -DDS_EXPORT nn_xqos_t *nn_xqos_dup (const nn_xqos_t *src); +DDS_EXPORT void nn_xqos_init_empty (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_init_default_reader (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_init_default_writer (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_init_default_writer_noautodispose (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_init_default_subscriber (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_init_default_publisher (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_init_default_topic (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_copy (dds_qos_t *dst, const dds_qos_t *src); +DDS_EXPORT void nn_xqos_unalias (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_fini (dds_qos_t *xqos); +DDS_EXPORT void nn_xqos_mergein_missing (dds_qos_t *a, const dds_qos_t *b); +DDS_EXPORT uint64_t nn_xqos_delta (const dds_qos_t *a, const dds_qos_t *b, uint64_t mask); +DDS_EXPORT void nn_xqos_addtomsg (struct nn_xmsg *m, const dds_qos_t *xqos, uint64_t wanted); +DDS_EXPORT void nn_log_xqos (uint32_t cat, const dds_qos_t *xqos); +DDS_EXPORT dds_qos_t *nn_xqos_dup (const dds_qos_t *src); #if defined (__cplusplus) } diff --git a/src/core/ddsi/src/ddsi_rhc_plugin.c b/src/core/ddsi/src/ddsi_rhc_plugin.c index 969c753..be1caa3 100644 --- a/src/core/ddsi/src/ddsi_rhc_plugin.c +++ b/src/core/ddsi/src/ddsi_rhc_plugin.c @@ -13,7 +13,7 @@ #include "dds/ddsi/q_xqos.h" #include "dds/ddsi/ddsi_rhc_plugin.h" -DDS_EXPORT void make_proxy_writer_info(struct proxy_writer_info *pwr_info, const struct entity_common *e, const struct nn_xqos *xqos) +DDS_EXPORT void make_proxy_writer_info(struct proxy_writer_info *pwr_info, const struct entity_common *e, const struct dds_qos *xqos) { pwr_info->guid = e->guid; pwr_info->ownership_strength = xqos->ownership_strength.value; diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c index 654ce2c..9e5b1a8 100644 --- a/src/core/ddsi/src/q_ddsi_discovery.c +++ b/src/core/ddsi/src/q_ddsi_discovery.c @@ -284,7 +284,7 @@ int spdp_write (struct participant *pp) meta_multi_loc_one.loc = gv.loc_meta_mc; } } - ps.participant_lease_duration = nn_to_ddsi_duration (pp->lease_duration); + ps.participant_lease_duration = pp->lease_duration; /* Add PrismTech specific version information */ { @@ -515,7 +515,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time unsigned builtin_endpoint_set; unsigned prismtech_builtin_endpoint_set; nn_guid_t privileged_pp_guid; - nn_duration_t lease_duration; + dds_duration_t lease_duration; unsigned custom_flags = 0; if (!(datap->present & PP_PARTICIPANT_GUID) || !(datap->present & PP_BUILTIN_ENDPOINT_SET)) @@ -611,7 +611,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time else { DDS_LOG(DDS_LC_DISCOVERY, " (PARTICIPANT_LEASE_DURATION defaulting to 100s)"); - lease_duration = nn_to_ddsi_duration (100 * T_SECOND); + lease_duration = 100 * T_SECOND; } if (datap->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) { @@ -645,7 +645,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time DDS_LOG(DDS_LC_DISCOVERY, " (depends on "PGUIDFMT")", PGUID (privileged_pp_guid)); /* never expire lease for this proxy: it won't actually expire until the "privileged" one expires anyway */ - lease_duration = nn_to_ddsi_duration (T_NEVER); + lease_duration = T_NEVER; } else if (vendor_is_eclipse_or_opensplice (rst->vendor) && !(custom_flags & CF_PARTICIPANT_IS_DDSI2)) { @@ -657,7 +657,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time else { privileged_pp_guid.prefix = ddsi2->e.guid.prefix; - lease_duration = nn_to_ddsi_duration (T_NEVER); + lease_duration = T_NEVER; DDS_LOG(DDS_LC_DISCOVERY, " (depends on "PGUIDFMT")", PGUID (privileged_pp_guid)); } } @@ -735,7 +735,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time as_default, as_meta, datap, - nn_from_ddsi_duration (lease_duration), + lease_duration, rst->vendor, custom_flags, timestamp @@ -865,9 +865,9 @@ static int sedp_write_endpoint ( struct writer *wr, int alive, const nn_guid_t *epguid, const struct entity_common *common, const struct endpoint_common *epcommon, - const nn_xqos_t *xqos, struct addrset *as) + const dds_qos_t *xqos, struct addrset *as) { - const nn_xqos_t *defqos = is_writer_entityid (epguid->entityid) ? &gv.default_xqos_wr : &gv.default_xqos_rd; + const dds_qos_t *defqos = is_writer_entityid (epguid->entityid) ? &gv.default_xqos_wr : &gv.default_xqos_rd; struct nn_xmsg *mpayload; uint64_t qosdiff; nn_plist_t ps; @@ -1006,14 +1006,14 @@ int sedp_dispose_unregister_reader (struct reader *rd) return 0; } -static const char *durability_to_string (nn_durability_kind_t k) +static const char *durability_to_string (dds_durability_kind_t k) { switch (k) { - case NN_VOLATILE_DURABILITY_QOS: return "volatile"; - case NN_TRANSIENT_LOCAL_DURABILITY_QOS: return "transient-local"; - case NN_TRANSIENT_DURABILITY_QOS: return "transient"; - case NN_PERSISTENT_DURABILITY_QOS: return "persistent"; + case DDS_DURABILITY_VOLATILE: return "volatile"; + case DDS_DURABILITY_TRANSIENT_LOCAL: return "transient-local"; + case DDS_DURABILITY_TRANSIENT: return "transient"; + case DDS_DURABILITY_PERSISTENT: return "persistent"; } return "undefined-durability"; } @@ -1105,7 +1105,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat struct proxy_writer * pwr = NULL; struct proxy_reader * prd = NULL; nn_guid_t ppguid; - nn_xqos_t *xqos; + dds_qos_t *xqos; int reliable; struct addrset *as; int is_writer; @@ -1158,7 +1158,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat assert ((xqos->present & datap->qos.present) == datap->qos.present); assert (xqos->present & QP_RELIABILITY); assert (xqos->present & QP_DURABILITY); - reliable = (xqos->reliability.kind == NN_RELIABLE_RELIABILITY_QOS); + reliable = (xqos->reliability.kind == DDS_RELIABILITY_RELIABLE); DDS_LOG(DDS_LC_DISCOVERY, " %s %s %s: %s%s.%s/%s", reliable ? "reliable" : "best-effort", @@ -1860,7 +1860,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str goto done_upd_deliv; } - timestamp = valid_ddsi_timestamp(sampleinfo->timestamp) ? nn_wctime_from_ddsi_time(sampleinfo->timestamp): now(); + timestamp = (sampleinfo->timestamp.v != NN_WCTIME_INVALID.v) ? sampleinfo->timestamp : now (); switch (srcguid.entityid.u) { case NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER: diff --git a/src/core/ddsi/src/q_debmon.c b/src/core/ddsi/src/q_debmon.c index a3362cb..c555bc2 100644 --- a/src/core/ddsi/src/q_debmon.c +++ b/src/core/ddsi/src/q_debmon.c @@ -107,7 +107,7 @@ static int print_addrset_if_notempty (ddsi_tran_conn_t conn, const char *prefix, } static int print_any_endpoint_common (ddsi_tran_conn_t conn, const char *label, const struct entity_common *e, - const struct nn_xqos *xqos, const struct ddsi_sertopic *topic) + const struct dds_qos *xqos, const struct ddsi_sertopic *topic) { int x = 0; x += cpf (conn, " %s %x:%x:%x:%x ", label, PGUID (e->guid)); @@ -126,7 +126,7 @@ static int print_any_endpoint_common (ddsi_tran_conn_t conn, const char *label, return x; } -static int print_endpoint_common (ddsi_tran_conn_t conn, const char *label, const struct entity_common *e, const struct endpoint_common *c, const struct nn_xqos *xqos, const struct ddsi_sertopic *topic) +static int print_endpoint_common (ddsi_tran_conn_t conn, const char *label, const struct entity_common *e, const struct endpoint_common *c, const struct dds_qos *xqos, const struct ddsi_sertopic *topic) { DDSRT_UNUSED_ARG (c); return print_any_endpoint_common (conn, label, e, xqos, topic); diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c index 6cfca79..b34e167 100644 --- a/src/core/ddsi/src/q_entity.c +++ b/src/core/ddsi/src/q_entity.c @@ -87,8 +87,8 @@ static const unsigned prismtech_builtin_writers_besmask = NN_DISC_BUILTIN_ENDPOINT_CM_PUBLISHER_WRITER | NN_DISC_BUILTIN_ENDPOINT_CM_SUBSCRIBER_WRITER; -static dds_return_t new_writer_guid (struct writer **wr_out, const struct nn_guid *guid, const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc *whc, status_cb_t status_cb, void *status_cbarg); -static dds_return_t new_reader_guid (struct reader **rd_out, const struct nn_guid *guid, const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct rhc *rhc, status_cb_t status_cb, void *status_cbarg); +static dds_return_t new_writer_guid (struct writer **wr_out, const struct nn_guid *guid, const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc *whc, status_cb_t status_cb, void *status_cbarg); +static dds_return_t new_reader_guid (struct reader **rd_out, const struct nn_guid *guid, const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct rhc *rhc, status_cb_t status_cb, void *status_cbarg); static struct participant *ref_participant (struct participant *pp, const struct nn_guid *guid_of_refing_entity); static void unref_participant (struct participant *pp, const struct nn_guid *guid_of_refing_entity); static void delete_proxy_group_locked (struct proxy_group *pgroup, nn_wctime_t timestamp, int isimplicit); @@ -1545,7 +1545,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd) ddsrt_avl_ipath_t path; int pretend_everything_acked; m->prd_guid = prd->e.guid; - m->is_reliable = (prd->c.xqos->reliability.kind > NN_BEST_EFFORT_RELIABILITY_QOS); + m->is_reliable = (prd->c.xqos->reliability.kind > DDS_RELIABILITY_BEST_EFFORT); m->assumed_in_sync = (config.retransmit_merging == REXMIT_MERGE_ALWAYS); m->has_replied_to_hb = !m->is_reliable; m->all_have_replied_to_hb = 0; @@ -1655,7 +1655,7 @@ static void writer_add_local_connection (struct writer *wr, struct reader *rd) historical data for best-effort data over the wire, so also not locally). FIXME: should limit ourselves to what it is available because of durability history, not writer history */ - if (rd->xqos->reliability.kind > NN_BEST_EFFORT_RELIABILITY_QOS && rd->xqos->durability.kind > NN_VOLATILE_DURABILITY_QOS) + if (rd->xqos->reliability.kind > DDS_RELIABILITY_BEST_EFFORT && rd->xqos->durability.kind > DDS_DURABILITY_VOLATILE) { struct whc_sample_iter it; struct whc_borrowed_sample sample; @@ -2021,7 +2021,7 @@ static nn_entityid_t builtin_entityid_match (nn_entityid_t x) return res; } -static void writer_qos_mismatch (struct writer * wr, uint32_t reason) +static void writer_qos_mismatch (struct writer * wr, dds_qos_policy_id_t reason) { /* When the reason is DDS_INVALID_QOS_POLICY_ID, it means that we compared * readers/writers from different topics: ignore that. */ @@ -2041,7 +2041,7 @@ static void writer_qos_mismatch (struct writer * wr, uint32_t reason) } } -static void reader_qos_mismatch (struct reader * rd, uint32_t reason) +static void reader_qos_mismatch (struct reader * rd, dds_qos_policy_id_t reason) { /* When the reason is DDS_INVALID_QOS_POLICY_ID, it means that we compared * readers/writers from different topics: ignore that. */ @@ -2066,15 +2066,15 @@ static void connect_writer_with_proxy_reader (struct writer *wr, struct proxy_re { const int isb0 = (is_builtin_entityid (wr->e.guid.entityid, NN_VENDORID_ECLIPSE) != 0); const int isb1 = (is_builtin_entityid (prd->e.guid.entityid, prd->c.vendor) != 0); - int32_t reason; + dds_qos_policy_id_t reason; DDSRT_UNUSED_ARG(tnow); if (isb0 != isb1) return; if (wr->e.onlylocal) return; - if (!isb0 && (reason = qos_match_p (prd->c.xqos, wr->xqos)) >= 0) + if (!isb0 && !qos_match_p (prd->c.xqos, wr->xqos, &reason)) { - writer_qos_mismatch (wr, (uint32_t)reason); + writer_qos_mismatch (wr, reason); return; } proxy_reader_add_connection (prd, wr); @@ -2085,41 +2085,41 @@ static void connect_proxy_writer_with_reader (struct proxy_writer *pwr, struct r { const int isb0 = (is_builtin_entityid (pwr->e.guid.entityid, pwr->c.vendor) != 0); const int isb1 = (is_builtin_entityid (rd->e.guid.entityid, NN_VENDORID_ECLIPSE) != 0); - int32_t reason; + dds_qos_policy_id_t reason; nn_count_t init_count; if (isb0 != isb1) return; if (rd->e.onlylocal) return; - if (!isb0 && (reason = qos_match_p (rd->xqos, pwr->c.xqos)) >= 0) + if (!isb0 && !qos_match_p (rd->xqos, pwr->c.xqos, &reason)) { - reader_qos_mismatch (rd, (uint32_t)reason); + reader_qos_mismatch (rd, reason); return; } reader_add_connection (rd, pwr, &init_count); proxy_writer_add_connection (pwr, rd, tnow, init_count); } -static bool ignore_local_p (const nn_guid_t *guid1, const nn_guid_t *guid2, const struct nn_xqos *xqos1, const struct nn_xqos *xqos2) +static bool ignore_local_p (const nn_guid_t *guid1, const nn_guid_t *guid2, const struct dds_qos *xqos1, const struct dds_qos *xqos2) { assert (xqos1->present & QP_CYCLONE_IGNORELOCAL); assert (xqos2->present & QP_CYCLONE_IGNORELOCAL); switch (xqos1->ignorelocal.value) { - case NN_NONE_IGNORELOCAL_QOS: + case DDS_IGNORELOCAL_NONE: break; - case NN_PARTICIPANT_IGNORELOCAL_QOS: + case DDS_IGNORELOCAL_PARTICIPANT: return memcmp (&guid1->prefix, &guid2->prefix, sizeof (guid1->prefix)) == 0; - case NN_PROCESS_IGNORELOCAL_QOS: + case DDS_IGNORELOCAL_PROCESS: return true; } switch (xqos2->ignorelocal.value) { - case NN_NONE_IGNORELOCAL_QOS: + case DDS_IGNORELOCAL_NONE: break; - case NN_PARTICIPANT_IGNORELOCAL_QOS: + case DDS_IGNORELOCAL_PARTICIPANT: return memcmp (&guid1->prefix, &guid2->prefix, sizeof (guid1->prefix)) == 0; - case NN_PROCESS_IGNORELOCAL_QOS: + case DDS_IGNORELOCAL_PROCESS: return true; } return false; @@ -2127,16 +2127,16 @@ static bool ignore_local_p (const nn_guid_t *guid1, const nn_guid_t *guid2, cons static void connect_writer_with_reader (struct writer *wr, struct reader *rd, nn_mtime_t tnow) { - int32_t reason; + dds_qos_policy_id_t reason; (void)tnow; if (!is_local_orphan_endpoint (&wr->e) && (is_builtin_entityid (wr->e.guid.entityid, NN_VENDORID_ECLIPSE) || is_builtin_entityid (rd->e.guid.entityid, NN_VENDORID_ECLIPSE))) return; if (ignore_local_p (&wr->e.guid, &rd->e.guid, wr->xqos, rd->xqos)) return; - if ((reason = qos_match_p (rd->xqos, wr->xqos)) >= 0) + if (!qos_match_p (rd->xqos, wr->xqos, &reason)) { - writer_qos_mismatch (wr, (uint32_t)reason); - reader_qos_mismatch (rd, (uint32_t)reason); + writer_qos_mismatch (wr, reason); + reader_qos_mismatch (rd, reason); return; } reader_add_local_connection (rd, wr); @@ -2402,7 +2402,7 @@ static void match_proxy_reader_with_writers (struct proxy_reader *prd, nn_mtime_ /* ENDPOINT --------------------------------------------------------- */ -static void new_reader_writer_common (const struct nn_guid *guid, const struct ddsi_sertopic * topic, const struct nn_xqos *xqos) +static void new_reader_writer_common (const struct nn_guid *guid, const struct ddsi_sertopic * topic, const struct dds_qos *xqos) { const char *partition = "(default)"; const char *partition_suffix = ""; @@ -2452,7 +2452,7 @@ static void endpoint_common_fini (struct entity_common *e, struct endpoint_commo entity_common_fini (e); } -static int set_topic_type_name (nn_xqos_t *xqos, const struct ddsi_sertopic * topic) +static int set_topic_type_name (dds_qos_t *xqos, const struct ddsi_sertopic * topic) { if (!(xqos->present & QP_TYPE_NAME) && topic) { @@ -2655,7 +2655,7 @@ unsigned remove_acked_messages (struct writer *wr, struct whc_state *whcst, stru return n; } -static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc *whc, status_cb_t status_cb, void * status_entity) +static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc *whc, status_cb_t status_cb, void * status_entity) { ddsrt_cond_init (&wr->throttle_cond); wr->seq = 0; @@ -2693,14 +2693,14 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se DDS_LOG(DDS_LC_DISCOVERY, "}\n"); assert (wr->xqos->present & QP_RELIABILITY); - wr->reliable = (wr->xqos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS); + wr->reliable = (wr->xqos->reliability.kind != DDS_RELIABILITY_BEST_EFFORT); assert (wr->xqos->present & QP_DURABILITY); if (is_builtin_entityid (wr->e.guid.entityid, NN_VENDORID_ECLIPSE)) { - assert (wr->xqos->history.kind == NN_KEEP_LAST_HISTORY_QOS); - assert (wr->xqos->durability.kind == NN_TRANSIENT_LOCAL_DURABILITY_QOS); + assert (wr->xqos->history.kind == DDS_HISTORY_KEEP_LAST); + assert (wr->xqos->durability.kind == DDS_DURABILITY_TRANSIENT_LOCAL); } - wr->handle_as_transient_local = (wr->xqos->durability.kind == NN_TRANSIENT_LOCAL_DURABILITY_QOS); + wr->handle_as_transient_local = (wr->xqos->durability.kind == DDS_DURABILITY_TRANSIENT_LOCAL); wr->include_keyhash = config.generate_keyhash && ((wr->e.guid.entityid.u & NN_ENTITYID_KIND_MASK) == NN_ENTITYID_KIND_WRITER_WITH_KEY); @@ -2790,15 +2790,14 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se wr->heartbeat_xevent = NULL; } assert (wr->xqos->present & QP_LIVELINESS); - if (wr->xqos->liveliness.kind != NN_AUTOMATIC_LIVELINESS_QOS || - nn_from_ddsi_duration (wr->xqos->liveliness.lease_duration) != T_NEVER) + if (wr->xqos->liveliness.kind != DDS_LIVELINESS_AUTOMATIC || wr->xqos->liveliness.lease_duration != T_NEVER) { - DDS_LOG(DDS_LC_DISCOVERY, "writer "PGUIDFMT": incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (wr->e.guid), (int) wr->xqos->liveliness.kind, nn_from_ddsi_duration (wr->xqos->liveliness.lease_duration)); + DDS_LOG(DDS_LC_DISCOVERY, "writer "PGUIDFMT": incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (wr->e.guid), (int) wr->xqos->liveliness.kind, wr->xqos->liveliness.lease_duration); } wr->lease_duration = T_NEVER; /* FIXME */ wr->whc = whc; - if (wr->xqos->history.kind == NN_KEEP_LAST_HISTORY_QOS) + if (wr->xqos->history.kind == DDS_HISTORY_KEEP_LAST) { /* hdepth > 0 => "aggressive keep last", and in that case: why bother blocking for a slow receiver when the entire point of @@ -2820,7 +2819,7 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se local_reader_ary_init (&wr->rdary); } -static dds_return_t new_writer_guid (struct writer **wr_out, const struct nn_guid *guid, const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc *whc, status_cb_t status_cb, void *status_entity) +static dds_return_t new_writer_guid (struct writer **wr_out, const struct nn_guid *guid, const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc *whc, status_cb_t status_cb, void *status_entity) { struct writer *wr; nn_mtime_t tnow = now_mt (); @@ -2870,7 +2869,7 @@ static dds_return_t new_writer_guid (struct writer **wr_out, const struct nn_gui return 0; } -dds_return_t new_writer (struct writer **wr_out, struct nn_guid *wrguid, const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc * whc, status_cb_t status_cb, void *status_cb_arg) +dds_return_t new_writer (struct writer **wr_out, struct nn_guid *wrguid, const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc * whc, status_cb_t status_cb, void *status_cb_arg) { struct participant *pp; dds_return_t rc; @@ -2889,7 +2888,7 @@ dds_return_t new_writer (struct writer **wr_out, struct nn_guid *wrguid, const s return new_writer_guid (wr_out, wrguid, group_guid, pp, topic, xqos, whc, status_cb, status_cb_arg); } -struct local_orphan_writer *new_local_orphan_writer (nn_entityid_t entityid, struct ddsi_sertopic *topic, const struct nn_xqos *xqos, struct whc *whc) +struct local_orphan_writer *new_local_orphan_writer (nn_entityid_t entityid, struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc *whc) { nn_guid_t guid; struct local_orphan_writer *lowr; @@ -3203,7 +3202,7 @@ static dds_return_t new_reader_guid const struct nn_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, - const struct nn_xqos *xqos, + const struct dds_qos *xqos, struct rhc *rhc, status_cb_t status_cb, void * status_entity @@ -3239,9 +3238,9 @@ static dds_return_t new_reader_guid DDS_LOG(DDS_LC_DISCOVERY, "}\n"); } assert (rd->xqos->present & QP_RELIABILITY); - rd->reliable = (rd->xqos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS); + rd->reliable = (rd->xqos->reliability.kind != DDS_RELIABILITY_BEST_EFFORT); assert (rd->xqos->present & QP_DURABILITY); - rd->handle_as_transient_local = (rd->xqos->durability.kind == NN_TRANSIENT_LOCAL_DURABILITY_QOS); + rd->handle_as_transient_local = (rd->xqos->durability.kind == DDS_DURABILITY_TRANSIENT_LOCAL); rd->topic = ddsi_sertopic_ref (topic); rd->ddsi2direct_cb = 0; rd->ddsi2direct_cbarg = 0; @@ -3262,10 +3261,9 @@ static dds_return_t new_reader_guid (ddsi_plugin.rhc_plugin.rhc_set_qos_fn) (rd->rhc, rd->xqos); } assert (rd->xqos->present & QP_LIVELINESS); - if (rd->xqos->liveliness.kind != NN_AUTOMATIC_LIVELINESS_QOS || - nn_from_ddsi_duration (rd->xqos->liveliness.lease_duration) != T_NEVER) + if (rd->xqos->liveliness.kind != DDS_LIVELINESS_AUTOMATIC || rd->xqos->liveliness.lease_duration != T_NEVER) { - DDS_LOG(DDS_LC_DISCOVERY, "reader "PGUIDFMT": incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (rd->e.guid), (int) rd->xqos->liveliness.kind, nn_from_ddsi_duration (rd->xqos->liveliness.lease_duration)); + DDS_LOG(DDS_LC_DISCOVERY, "reader "PGUIDFMT": incorrectly treating it as of automatic liveliness kind with lease duration = inf (%d, %"PRId64")\n", PGUID (rd->e.guid), (int) rd->xqos->liveliness.kind, rd->xqos->liveliness.lease_duration); } #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS @@ -3342,7 +3340,7 @@ dds_return_t new_reader const struct nn_guid *group_guid, const struct nn_guid *ppguid, const struct ddsi_sertopic *topic, - const struct nn_xqos *xqos, + const struct dds_qos *xqos, struct rhc * rhc, status_cb_t status_cb, void * status_cbarg @@ -3947,7 +3945,7 @@ uint64_t participant_instance_id (const struct nn_guid *guid) /* PROXY-GROUP --------------------------------------------------- */ -int new_proxy_group (const struct nn_guid *guid, const char *name, const struct nn_xqos *xqos, nn_wctime_t timestamp) +int new_proxy_group (const struct nn_guid *guid, const char *name, const struct dds_qos *xqos, nn_wctime_t timestamp) { struct proxy_participant *proxypp; nn_guid_t ppguid; @@ -4121,7 +4119,7 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid, /* The DDSI built-in proxy writers always deliver asynchronously */ pwr->deliver_synchronously = 0; - } else if (nn_from_ddsi_duration (pwr->c.xqos->latency_budget.duration) <= config.synchronous_delivery_latency_bound && + } else if (pwr->c.xqos->latency_budget.duration <= config.synchronous_delivery_latency_bound && pwr->c.xqos->transport_priority.value >= config.synchronous_delivery_priority_threshold) { /* Regular proxy-writers with a sufficiently low latency_budget and a sufficiently high transport_priority deliver @@ -4131,7 +4129,7 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid, pwr->deliver_synchronously = 0; } /* Pretend we have seen a heartbeat if the proxy writer is a best-effort one */ - isreliable = (pwr->c.xqos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS); + isreliable = (pwr->c.xqos->reliability.kind != DDS_RELIABILITY_BEST_EFFORT); pwr->have_seen_heartbeat = !isreliable; pwr->local_matching_inprogress = 1; #ifdef DDSI_INCLUDE_SSM @@ -4144,7 +4142,7 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid, (unsigned) !!config.arrival_of_data_asserts_pp_and_ep_liveliness; assert (pwr->c.xqos->present & QP_LIVELINESS); - if (pwr->c.xqos->liveliness.kind != NN_AUTOMATIC_LIVELINESS_QOS) + if (pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_AUTOMATIC) DDS_LOG(DDS_LC_DISCOVERY, " FIXME: only AUTOMATIC liveliness supported"); #if 0 pwr->tlease_dur = nn_from_ddsi_duration (pwr->c.xqos->liveliness.lease_duration); diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c index c20b06c..9abc779 100644 --- a/src/core/ddsi/src/q_init.c +++ b/src/core/ddsi/src/q_init.c @@ -131,12 +131,12 @@ static int make_uc_sockets (uint32_t * pdisc, uint32_t * pdata, int ppid) return gv.data_conn_uc ? 0 : -1; } -static void make_builtin_endpoint_xqos (nn_xqos_t *q, const nn_xqos_t *template) +static void make_builtin_endpoint_xqos (dds_qos_t *q, const dds_qos_t *template) { nn_xqos_copy (q, template); - q->reliability.kind = NN_RELIABLE_RELIABILITY_QOS; - q->reliability.max_blocking_time = nn_to_ddsi_duration (100 * T_MILLISECOND); - q->durability.kind = NN_TRANSIENT_LOCAL_DURABILITY_QOS; + q->reliability.kind = DDS_RELIABILITY_RELIABLE; + q->reliability.max_blocking_time = 100 * T_MILLISECOND; + q->durability.kind = DDS_DURABILITY_TRANSIENT_LOCAL; } static int set_recvips (void) @@ -1006,7 +1006,7 @@ int rtps_init (void) nn_xqos_init_default_subscriber (&gv.default_xqos_sub); nn_xqos_init_default_publisher (&gv.default_xqos_pub); nn_xqos_copy (&gv.spdp_endpoint_xqos, &gv.default_xqos_rd); - gv.spdp_endpoint_xqos.durability.kind = NN_TRANSIENT_LOCAL_DURABILITY_QOS; + gv.spdp_endpoint_xqos.durability.kind = DDS_DURABILITY_TRANSIENT_LOCAL; make_builtin_endpoint_xqos (&gv.builtin_endpoint_xqos_rd, &gv.default_xqos_rd); make_builtin_endpoint_xqos (&gv.builtin_endpoint_xqos_wr, &gv.default_xqos_wr); diff --git a/src/core/ddsi/src/q_plist.c b/src/core/ddsi/src/q_plist.c index e930218..1e65ee5 100644 --- a/src/core/ddsi/src/q_plist.c +++ b/src/core/ddsi/src/q_plist.c @@ -35,6 +35,11 @@ #include "dds/ddsrt/avl.h" #include "dds/ddsi/q_misc.h" /* for vendor_is_... */ +/* I am tempted to change LENGTH_UNLIMITED to 0 in the API (with -1 + supported for backwards compatibility) ... on the wire however + it must be -1 */ +DDSRT_STATIC_ASSERT(DDS_LENGTH_UNLIMITED == -1); + /* These are internal to the parameter list processing. We never generate them, and we never want to do see them anywhere outside the actual parsing of an incoming parameter list. (There are @@ -50,7 +55,7 @@ #define PPTMP_METATRAFFIC_MULTICAST_PORT (1 << 6) typedef struct nn_ipaddress_params_tmp { - unsigned present; + uint32_t present; nn_ipv4address_t multicast_ipaddress; nn_ipv4address_t default_unicast_ipaddress; @@ -70,11 +75,11 @@ struct dd { }; struct cdroctetseq { - unsigned len; + uint32_t len; unsigned char value[1]; }; -static void log_octetseq (uint32_t cat, unsigned n, const unsigned char *xs); +static void log_octetseq (uint32_t cat, uint32_t n, const unsigned char *xs); static size_t align4u (size_t x) { @@ -124,15 +129,15 @@ static dds_return_t alias_string (const unsigned char **ptr, const struct dd *dd static void unalias_string (char **str, int bswap) { const char *alias = *str; - unsigned len; + uint32_t len; if (bswap == 0 || bswap == 1) { - const unsigned *plen = (const unsigned *) alias - 1; + const uint32_t *plen = (const uint32_t *) alias - 1; len = bswap ? bswap4u (*plen) : *plen; } else { - len = (unsigned) strlen (alias) + 1; + len = (uint32_t) strlen (alias) + 1; } *str = ddsrt_malloc (len); memcpy (*str, alias, len); @@ -149,7 +154,7 @@ static dds_return_t validate_octetseq (const struct dd *dd, size_t *len) return 0; } -static dds_return_t alias_octetseq (nn_octetseq_t *oseq, const struct dd *dd) +static dds_return_t alias_octetseq (ddsi_octetseq_t *oseq, const struct dd *dd) { size_t len; dds_return_t rc; @@ -165,7 +170,7 @@ static dds_return_t alias_octetseq (nn_octetseq_t *oseq, const struct dd *dd) } } -static dds_return_t alias_blob (nn_octetseq_t *oseq, const struct dd *dd) +static dds_return_t alias_blob (ddsi_octetseq_t *oseq, const struct dd *dd) { assert (dd->bufsz < UINT32_MAX); oseq->length = (uint32_t)dd->bufsz; @@ -173,7 +178,7 @@ static dds_return_t alias_blob (nn_octetseq_t *oseq, const struct dd *dd) return 0; } -static void unalias_octetseq (nn_octetseq_t *oseq, UNUSED_ARG (int bswap)) +static void unalias_octetseq (ddsi_octetseq_t *oseq, UNUSED_ARG (int bswap)) { if (oseq->length != 0) { @@ -234,7 +239,7 @@ static dds_return_t validate_stringseq (const struct dd *dd) return 0; } -static dds_return_t alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd) +static dds_return_t alias_stringseq (ddsi_stringseq_t *strseq, const struct dd *dd) { /* Not truly an alias: it allocates an array of pointers that alias the individual null-terminated strings. Also: see @@ -243,7 +248,7 @@ static dds_return_t alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd const unsigned char *seqend = seq + dd->bufsz; struct dd dd1 = *dd; char **strs; - unsigned i; + uint32_t i; dds_return_t result; if (dd->bufsz < sizeof (int)) { @@ -295,18 +300,18 @@ static dds_return_t alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd return result; } -static void free_stringseq (nn_stringseq_t *strseq) +static void free_stringseq (ddsi_stringseq_t *strseq) { - unsigned i; + uint32_t i; for (i = 0; i < strseq->n; i++) if (strseq->strs[i]) ddsrt_free (strseq->strs[i]); ddsrt_free (strseq->strs); } -static dds_return_t unalias_stringseq (nn_stringseq_t *strseq, int bswap) +static dds_return_t unalias_stringseq (ddsi_stringseq_t *strseq, int bswap) { - unsigned i; + uint32_t i; char **strs; if (strseq->n != 0) { @@ -322,9 +327,9 @@ static dds_return_t unalias_stringseq (nn_stringseq_t *strseq, int bswap) return 0; } -static void duplicate_stringseq (nn_stringseq_t *dest, const nn_stringseq_t *src) +static void duplicate_stringseq (ddsi_stringseq_t *dest, const ddsi_stringseq_t *src) { - unsigned i; + uint32_t i; dest->n = src->n; assert (dest->strs == NULL); if (dest->n == 0) @@ -460,7 +465,7 @@ void nn_plist_unalias (nn_plist_t *ps) } #endif -static dds_return_t do_octetseq (nn_octetseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd) +static dds_return_t do_octetseq (ddsi_octetseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd) { dds_return_t res; size_t len; @@ -474,7 +479,7 @@ static dds_return_t do_octetseq (nn_octetseq_t *dst, uint64_t *present, uint64_t return res; } -static dds_return_t do_blob (nn_octetseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd) +static dds_return_t do_blob (ddsi_octetseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd) { dds_return_t res; if (!(wanted & fl)) @@ -501,7 +506,7 @@ static dds_return_t do_string (char **dst, uint64_t *present, uint64_t *aliased, return res; } -static dds_return_t do_stringseq (nn_stringseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd) +static dds_return_t do_stringseq (ddsi_stringseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd) { dds_return_t res; if (!(wanted & fl)) @@ -514,13 +519,13 @@ static dds_return_t do_stringseq (nn_stringseq_t *dst, uint64_t *present, uint64 return res; } -static void bswap_time (nn_ddsi_time_t *t) +static void bswap_time (ddsi_time_t *t) { t->seconds = bswap4 (t->seconds); t->fraction = bswap4u (t->fraction); } -static dds_return_t validate_time (const nn_ddsi_time_t *t) +static dds_return_t validate_time (const ddsi_time_t *t) { /* Accepted are zero, positive, infinite or invalid as defined in the DDS 2.1 spec, table 9.4. */ @@ -535,46 +540,53 @@ static dds_return_t validate_time (const nn_ddsi_time_t *t) } } -static void bswap_duration (nn_duration_t *d) +static void bswap_external_duration (ddsi_duration_t *d) { bswap_time (d); } -dds_return_t validate_duration (const nn_duration_t *d) +static dds_return_t validate_external_duration (const ddsi_duration_t *d) { return validate_time (d); } -static dds_return_t do_duration (nn_duration_t *q, uint64_t *present, uint64_t fl, const struct dd *dd) +dds_return_t validate_duration (const dds_duration_t d) { + return (d >= 0 && d <= DDS_INFINITY) ? DDS_RETCODE_OK : DDS_RETCODE_BAD_PARAMETER; +} + +static dds_return_t do_duration (dds_duration_t *q, uint64_t *present, uint64_t fl, const struct dd *dd) +{ + ddsi_duration_t extq; dds_return_t res; - if (dd->bufsz < sizeof (*q)) + if (dd->bufsz < sizeof (extq)) { DDS_TRACE("plist/do_duration: buffer too small\n"); return DDS_RETCODE_BAD_PARAMETER; } - memcpy (q, dd->buf, sizeof (*q)); + memcpy (&extq, dd->buf, sizeof (extq)); if (dd->bswap) - bswap_duration (q); - if ((res = validate_duration (q)) < 0) + bswap_external_duration (&extq); + if ((res = validate_external_duration (&extq)) < 0) return res; + *q = nn_from_ddsi_duration (extq); *present |= fl; return 0; } -static void bswap_durability_qospolicy (nn_durability_qospolicy_t *q) +static void bswap_durability_qospolicy (dds_durability_qospolicy_t *q) { q->kind = bswap4u (q->kind); } -dds_return_t validate_durability_qospolicy (const nn_durability_qospolicy_t *q) +dds_return_t validate_durability_qospolicy (const dds_durability_qospolicy_t *q) { switch (q->kind) { - case NN_VOLATILE_DURABILITY_QOS: - case NN_TRANSIENT_LOCAL_DURABILITY_QOS: - case NN_TRANSIENT_DURABILITY_QOS: - case NN_PERSISTENT_DURABILITY_QOS: + case DDS_DURABILITY_VOLATILE: + case DDS_DURABILITY_TRANSIENT_LOCAL: + case DDS_DURABILITY_TRANSIENT: + case DDS_DURABILITY_PERSISTENT: break; default: DDS_TRACE("plist/validate_durability_qospolicy: invalid kind (%d)\n", (int) q->kind); @@ -583,18 +595,18 @@ dds_return_t validate_durability_qospolicy (const nn_durability_qospolicy_t *q) return 0; } -static void bswap_history_qospolicy (nn_history_qospolicy_t *q) +static void bswap_history_qospolicy (dds_history_qospolicy_t *q) { q->kind = bswap4u (q->kind); q->depth = bswap4 (q->depth); } -static int history_qospolicy_allzero (const nn_history_qospolicy_t *q) +static int history_qospolicy_allzero (const dds_history_qospolicy_t *q) { - return q->kind == NN_KEEP_LAST_HISTORY_QOS && q->depth == 0; + return q->kind == DDS_HISTORY_KEEP_LAST && q->depth == 0; } -dds_return_t validate_history_qospolicy (const nn_history_qospolicy_t *q) +dds_return_t validate_history_qospolicy (const dds_history_qospolicy_t *q) { /* Validity of history setting and of resource limits are dependent, but we don't have access to the resource limits here ... the @@ -605,15 +617,15 @@ dds_return_t validate_history_qospolicy (const nn_history_qospolicy_t *q) n possibly unlimited. */ switch (q->kind) { - case NN_KEEP_LAST_HISTORY_QOS: - case NN_KEEP_ALL_HISTORY_QOS: + case DDS_HISTORY_KEEP_LAST: + case DDS_HISTORY_KEEP_ALL: break; default: DDS_TRACE("plist/validate_history_qospolicy: invalid kind (%d)\n", (int) q->kind); return DDS_RETCODE_BAD_PARAMETER; } /* Accept all values for depth if kind = ALL */ - if (q->kind == NN_KEEP_LAST_HISTORY_QOS) + if (q->kind == DDS_HISTORY_KEEP_LAST) { if (q->depth < 1) { @@ -624,21 +636,21 @@ dds_return_t validate_history_qospolicy (const nn_history_qospolicy_t *q) return 0; } -static void bswap_resource_limits_qospolicy (nn_resource_limits_qospolicy_t *q) +static void bswap_resource_limits_qospolicy (dds_resource_limits_qospolicy_t *q) { q->max_samples = bswap4 (q->max_samples); q->max_instances = bswap4 (q->max_instances); q->max_samples_per_instance = bswap4 (q->max_samples_per_instance); } -static int resource_limits_qospolicy_allzero (const nn_resource_limits_qospolicy_t *q) +static int resource_limits_qospolicy_allzero (const dds_resource_limits_qospolicy_t *q) { return q->max_samples == 0 && q->max_instances == 0 && q->max_samples_per_instance == 0; } -dds_return_t validate_resource_limits_qospolicy (const nn_resource_limits_qospolicy_t *q) +dds_return_t validate_resource_limits_qospolicy (const dds_resource_limits_qospolicy_t *q) { - const int unlimited = NN_DDS_LENGTH_UNLIMITED; + const int unlimited = DDS_LENGTH_UNLIMITED; /* Note: dependent on history setting as well (see validate_history_qospolicy). Verifying only the internal consistency of the resource limits. */ @@ -670,9 +682,9 @@ dds_return_t validate_resource_limits_qospolicy (const nn_resource_limits_qospol return 0; } -dds_return_t validate_history_and_resource_limits (const nn_history_qospolicy_t *qh, const nn_resource_limits_qospolicy_t *qr) +dds_return_t validate_history_and_resource_limits (const dds_history_qospolicy_t *qh, const dds_resource_limits_qospolicy_t *qr) { - const int unlimited = NN_DDS_LENGTH_UNLIMITED; + const int unlimited = DDS_LENGTH_UNLIMITED; dds_return_t res; if ((res = validate_history_qospolicy (qh)) < 0) { @@ -686,7 +698,7 @@ dds_return_t validate_history_and_resource_limits (const nn_history_qospolicy_t } switch (qh->kind) { - case NN_KEEP_ALL_HISTORY_QOS: + case DDS_HISTORY_KEEP_ALL: #if 0 /* See comment in validate_resource_limits, ref'ing 7.1.3.19 */ if (qr->max_samples_per_instance != unlimited) { @@ -695,7 +707,7 @@ dds_return_t validate_history_and_resource_limits (const nn_history_qospolicy_t } #endif break; - case NN_KEEP_LAST_HISTORY_QOS: + case DDS_HISTORY_KEEP_LAST: if (qr->max_samples_per_instance != unlimited && qh->depth > qr->max_samples_per_instance) { DDS_TRACE("plist/validate_history_and_resource_limits: depth (%d) and max_samples_per_instance (%d) incompatible with KEEP_LAST policy\n", (int) qh->depth, (int) qr->max_samples_per_instance); @@ -706,26 +718,33 @@ dds_return_t validate_history_and_resource_limits (const nn_history_qospolicy_t return 0; } -static void bswap_durability_service_qospolicy (nn_durability_service_qospolicy_t *q) +static void bswap_external_durability_service_qospolicy (dds_external_durability_service_qospolicy_t *q) { - bswap_duration (&q->service_cleanup_delay); + bswap_external_duration (&q->service_cleanup_delay); bswap_history_qospolicy (&q->history); bswap_resource_limits_qospolicy (&q->resource_limits); } -static int durability_service_qospolicy_allzero (const nn_durability_service_qospolicy_t *q) +static int durability_service_qospolicy_allzero (const dds_durability_service_qospolicy_t *q) +{ + return (history_qospolicy_allzero (&q->history) && + resource_limits_qospolicy_allzero (&q->resource_limits) && + q->service_cleanup_delay == 0); +} + +static int external_durability_service_qospolicy_allzero (const dds_external_durability_service_qospolicy_t *q) { return (history_qospolicy_allzero (&q->history) && resource_limits_qospolicy_allzero (&q->resource_limits) && q->service_cleanup_delay.seconds == 0 && q->service_cleanup_delay.fraction == 0); } -static dds_return_t validate_durability_service_qospolicy_acceptzero (const nn_durability_service_qospolicy_t *q, bool acceptzero) +static dds_return_t validate_external_durability_service_qospolicy_acceptzero (const dds_external_durability_service_qospolicy_t *q, bool acceptzero) { dds_return_t res; - if (acceptzero && durability_service_qospolicy_allzero (q)) + if (acceptzero && external_durability_service_qospolicy_allzero (q)) return 0; - if ((res = validate_duration (&q->service_cleanup_delay)) < 0) + if ((res = validate_external_duration (&q->service_cleanup_delay)) < 0) { DDS_TRACE("plist/validate_durability_service_qospolicy: duration invalid\n"); return res; @@ -738,26 +757,30 @@ static dds_return_t validate_durability_service_qospolicy_acceptzero (const nn_d return 0; } -dds_return_t validate_durability_service_qospolicy (const nn_durability_service_qospolicy_t *q) +dds_return_t validate_durability_service_qospolicy (const dds_durability_service_qospolicy_t *q) { - return validate_durability_service_qospolicy_acceptzero (q, false); + dds_external_durability_service_qospolicy_t qext; + qext.history = q->history; + qext.resource_limits = q->resource_limits; + qext.service_cleanup_delay = nn_to_ddsi_duration (q->service_cleanup_delay); + return validate_external_durability_service_qospolicy_acceptzero (&qext, false); } -static void bswap_liveliness_qospolicy (nn_liveliness_qospolicy_t *q) +static void bswap_external_liveliness_qospolicy (dds_external_liveliness_qospolicy_t *q) { q->kind = bswap4u (q->kind); - bswap_duration (&q->lease_duration); + bswap_external_duration (&q->lease_duration); } -dds_return_t validate_liveliness_qospolicy (const nn_liveliness_qospolicy_t *q) +static dds_return_t validate_external_liveliness_qospolicy (const dds_external_liveliness_qospolicy_t *q) { dds_return_t res; switch (q->kind) { - case NN_AUTOMATIC_LIVELINESS_QOS: - case NN_MANUAL_BY_PARTICIPANT_LIVELINESS_QOS: - case NN_MANUAL_BY_TOPIC_LIVELINESS_QOS: - if ((res = validate_duration (&q->lease_duration)) < 0) + case DDS_LIVELINESS_AUTOMATIC: + case DDS_LIVELINESS_MANUAL_BY_PARTICIPANT: + case DDS_LIVELINESS_MANUAL_BY_TOPIC: + if ((res = validate_external_duration (&q->lease_duration)) < 0) DDS_TRACE("plist/validate_liveliness_qospolicy: invalid lease duration\n"); return res; default: @@ -766,63 +789,51 @@ dds_return_t validate_liveliness_qospolicy (const nn_liveliness_qospolicy_t *q) } } -static void bswap_external_reliability_qospolicy (nn_external_reliability_qospolicy_t *qext) +dds_return_t validate_liveliness_qospolicy (const dds_liveliness_qospolicy_t *q) +{ + dds_external_liveliness_qospolicy_t qext; + qext.kind = q->kind; + qext.lease_duration = nn_to_ddsi_duration (q->lease_duration); + return validate_external_liveliness_qospolicy (&qext); +} + +static void bswap_external_reliability_qospolicy (dds_external_reliability_qospolicy_t *qext) { qext->kind = bswap4u (qext->kind); - bswap_duration (&qext->max_blocking_time); + bswap_external_duration (&qext->max_blocking_time); } -static dds_return_t validate_xform_reliability_qospolicy (nn_reliability_qospolicy_t *qdst, const nn_external_reliability_qospolicy_t *qext) +static dds_return_t validate_xform_reliability_qospolicy (dds_reliability_qospolicy_t *qdst, const dds_external_reliability_qospolicy_t *qext) { dds_return_t res; - qdst->max_blocking_time = qext->max_blocking_time; - if (NN_PEDANTIC_P) + qdst->max_blocking_time = nn_from_ddsi_duration (qext->max_blocking_time); + switch (qext->kind) { - switch (qext->kind) - { - case NN_PEDANTIC_BEST_EFFORT_RELIABILITY_QOS: - qdst->kind = NN_BEST_EFFORT_RELIABILITY_QOS; - return 0; - case NN_PEDANTIC_RELIABLE_RELIABILITY_QOS: - qdst->kind = NN_RELIABLE_RELIABILITY_QOS; - if ((res = validate_duration (&qdst->max_blocking_time)) < 0) - DDS_TRACE("plist/validate_xform_reliability_qospolicy[pedantic]: max_blocking_time invalid\n"); - return res; - default: - DDS_TRACE("plist/validate_xform_reliability_qospolicy[pedantic]: invalid kind (%d)\n", (int) qext->kind); - return DDS_RETCODE_BAD_PARAMETER; - } - } - else - { - switch (qext->kind) - { - case NN_INTEROP_BEST_EFFORT_RELIABILITY_QOS: - qdst->kind = NN_BEST_EFFORT_RELIABILITY_QOS; - return 0; - case NN_INTEROP_RELIABLE_RELIABILITY_QOS: - qdst->kind = NN_RELIABLE_RELIABILITY_QOS; - if ((res = validate_duration (&qdst->max_blocking_time)) < 0) - DDS_TRACE("plist/validate_xform_reliability_qospolicy[!pedantic]: max_blocking time invalid\n"); - return res; - default: - DDS_TRACE("plist/validate_xform_reliability_qospolicy[!pedantic]: invalid kind (%d)\n", (int) qext->kind); - return DDS_RETCODE_BAD_PARAMETER; - } + case DDS_EXTERNAL_RELIABILITY_BEST_EFFORT: + qdst->kind = DDS_RELIABILITY_BEST_EFFORT; + return 0; + case DDS_EXTERNAL_RELIABILITY_RELIABLE: + qdst->kind = DDS_RELIABILITY_RELIABLE; + if ((res = validate_external_duration (&qext->max_blocking_time)) < 0) + DDS_TRACE("plist/validate_xform_reliability_qospolicy[!pedantic]: max_blocking time invalid\n"); + return res; + default: + DDS_TRACE("plist/validate_xform_reliability_qospolicy[!pedantic]: invalid kind (%d)\n", (int) qext->kind); + return DDS_RETCODE_BAD_PARAMETER; } } -static void bswap_destination_order_qospolicy (nn_destination_order_qospolicy_t *q) +static void bswap_destination_order_qospolicy (dds_destination_order_qospolicy_t *q) { q->kind = bswap4u (q->kind); } -dds_return_t validate_destination_order_qospolicy (const nn_destination_order_qospolicy_t *q) +dds_return_t validate_destination_order_qospolicy (const dds_destination_order_qospolicy_t *q) { switch (q->kind) { - case NN_BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS: - case NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS: + case DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP: + case DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP: return 0; default: DDS_TRACE("plist/validate_destination_order_qospolicy: invalid kind (%d)\n", (int) q->kind); @@ -830,17 +841,17 @@ dds_return_t validate_destination_order_qospolicy (const nn_destination_order_qo } } -static void bswap_ownership_qospolicy (nn_ownership_qospolicy_t *q) +static void bswap_ownership_qospolicy (dds_ownership_qospolicy_t *q) { q->kind = bswap4u (q->kind); } -dds_return_t validate_ownership_qospolicy (const nn_ownership_qospolicy_t *q) +dds_return_t validate_ownership_qospolicy (const dds_ownership_qospolicy_t *q) { switch (q->kind) { - case NN_SHARED_OWNERSHIP_QOS: - case NN_EXCLUSIVE_OWNERSHIP_QOS: + case DDS_OWNERSHIP_SHARED: + case DDS_OWNERSHIP_EXCLUSIVE: return 0; default: DDS_TRACE("plist/validate_ownership_qospolicy: invalid kind (%d)\n", (int) q->kind); @@ -848,28 +859,28 @@ dds_return_t validate_ownership_qospolicy (const nn_ownership_qospolicy_t *q) } } -static void bswap_ownership_strength_qospolicy (nn_ownership_strength_qospolicy_t *q) +static void bswap_ownership_strength_qospolicy (dds_ownership_strength_qospolicy_t *q) { q->value = bswap4 (q->value); } -dds_return_t validate_ownership_strength_qospolicy (UNUSED_ARG (const nn_ownership_strength_qospolicy_t *q)) +dds_return_t validate_ownership_strength_qospolicy (UNUSED_ARG (const dds_ownership_strength_qospolicy_t *q)) { return 0; } -static void bswap_presentation_qospolicy (nn_presentation_qospolicy_t *q) +static void bswap_presentation_qospolicy (dds_presentation_qospolicy_t *q) { q->access_scope = bswap4u (q->access_scope); } -dds_return_t validate_presentation_qospolicy (const nn_presentation_qospolicy_t *q) +dds_return_t validate_presentation_qospolicy (const dds_presentation_qospolicy_t *q) { switch (q->access_scope) { - case NN_INSTANCE_PRESENTATION_QOS: - case NN_TOPIC_PRESENTATION_QOS: - case NN_GROUP_PRESENTATION_QOS: + case DDS_PRESENTATION_INSTANCE: + case DDS_PRESENTATION_TOPIC: + case DDS_PRESENTATION_GROUP: break; default: DDS_TRACE("plist/validate_presentation_qospolicy: invalid access_scope (%d)\n", (int) q->access_scope); @@ -892,12 +903,12 @@ dds_return_t validate_presentation_qospolicy (const nn_presentation_qospolicy_t return 0; } -static void bswap_transport_priority_qospolicy (nn_transport_priority_qospolicy_t *q) +static void bswap_transport_priority_qospolicy (dds_transport_priority_qospolicy_t *q) { q->value = bswap4 (q->value); } -dds_return_t validate_transport_priority_qospolicy (UNUSED_ARG (const nn_transport_priority_qospolicy_t *q)) +dds_return_t validate_transport_priority_qospolicy (UNUSED_ARG (const dds_transport_priority_qospolicy_t *q)) { return 0; } @@ -935,14 +946,14 @@ static int locator_address_prefix12_zero (const nn_locator_t *loc) /* loc has has 32 bit ints preceding the address, hence address is 4-byte aligned; reading char* as unsigneds isn't illegal type punning */ - const unsigned *u = (const unsigned *) loc->address; + const uint32_t *u = (const uint32_t *) loc->address; return (u[0] == 0 && u[1] == 0 && u[2] == 0); } static int locator_address_zero (const nn_locator_t *loc) { /* see locator_address_prefix12_zero */ - const unsigned *u = (const unsigned *) loc->address; + const uint32_t *u = (const uint32_t *) loc->address; return (u[0] == 0 && u[1] == 0 && u[2] == 0 && u[3] == 0); } @@ -1038,12 +1049,12 @@ static void locator_from_ipv4address_port (nn_locator_t *loc, const nn_ipv4addre memcpy (loc->address + 12, a, 4); } -static dds_return_t do_ipv4address (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp, uint64_t wanted, unsigned fl_tmp, const struct dd *dd) +static dds_return_t do_ipv4address (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp, uint64_t wanted, uint32_t fl_tmp, const struct dd *dd) { nn_ipv4address_t *a; nn_port_t *p; nn_locators_t *ls; - unsigned fl1_tmp; + uint32_t fl1_tmp; uint64_t fldest; if (dd->bufsz < sizeof (*a)) { @@ -1108,13 +1119,13 @@ static dds_return_t do_ipv4address (nn_plist_t *dest, nn_ipaddress_params_tmp_t } } -static dds_return_t do_port (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp, uint64_t wanted, unsigned fl_tmp, const struct dd *dd) +static dds_return_t do_port (nn_plist_t *dest, nn_ipaddress_params_tmp_t *dest_tmp, uint64_t wanted, uint32_t fl_tmp, const struct dd *dd) { nn_ipv4address_t *a; nn_port_t *p; nn_locators_t *ls; uint64_t fldest; - unsigned fl1_tmp; + uint32_t fl1_tmp; if (dd->bufsz < sizeof (*p)) { DDS_TRACE("plist/do_port: buffer too small\n"); @@ -1359,7 +1370,7 @@ static dds_return_t do_prismtech_participant_version_info (nn_prismtech_particip else { dds_return_t res; - unsigned sz = NN_PRISMTECH_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE - sizeof(uint32_t); + uint32_t sz = NN_PRISMTECH_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE - sizeof(uint32_t); uint32_t *pu = (uint32_t *)dd->buf; size_t len; struct dd dd1 = *dd; @@ -1380,7 +1391,7 @@ static dds_return_t do_prismtech_participant_version_info (nn_prismtech_particip } } -static dds_return_t do_subscription_keys_qospolicy (nn_subscription_keys_qospolicy_t *q, uint64_t *present, uint64_t *aliased, uint64_t fl, const struct dd *dd) +static dds_return_t do_subscription_keys_qospolicy (dds_subscription_keys_qospolicy_t *q, uint64_t *present, uint64_t *aliased, uint64_t fl, const struct dd *dd) { struct dd dd1; dds_return_t res; @@ -1406,33 +1417,37 @@ static dds_return_t do_subscription_keys_qospolicy (nn_subscription_keys_qospoli return res; } -static dds_return_t unalias_subscription_keys_qospolicy (nn_subscription_keys_qospolicy_t *q, int bswap) +static dds_return_t unalias_subscription_keys_qospolicy (dds_subscription_keys_qospolicy_t *q, int bswap) { return unalias_stringseq (&q->key_list, bswap); } -static dds_return_t do_reader_lifespan_qospolicy (nn_reader_lifespan_qospolicy_t *q, uint64_t *present, uint64_t fl, const struct dd *dd) +static dds_return_t do_reader_lifespan_qospolicy (dds_reader_lifespan_qospolicy_t *q, uint64_t *present, uint64_t fl, const struct dd *dd) { + dds_external_reader_lifespan_qospolicy_t qext; dds_return_t res; - if (dd->bufsz < sizeof (*q)) + if (dd->bufsz < sizeof (qext)) { DDS_TRACE("plist/do_reader_lifespan: buffer too small\n"); return DDS_RETCODE_BAD_PARAMETER; } - *q = *((nn_reader_lifespan_qospolicy_t *) dd->buf); + memcpy (&qext, dd->buf, sizeof (qext)); if (dd->bswap) - bswap_duration (&q->duration); - if (q->use_lifespan != 0 && q->use_lifespan != 1) + bswap_external_duration (&qext.duration); + if (qext.use_lifespan != 0 && qext.use_lifespan != 1) { - DDS_TRACE("plist/do_reader_lifespan: invalid use_lifespan (%d)\n", (int) q->use_lifespan); + DDS_TRACE("plist/do_reader_lifespan: invalid use_lifespan (%d)\n", (int) qext.use_lifespan); return DDS_RETCODE_BAD_PARAMETER; } - if ((res = validate_duration (&q->duration)) >= 0) - *present |= fl; - return res; + if ((res = validate_external_duration (&qext.duration)) < 0) + return res; + q->use_lifespan = qext.use_lifespan; + q->duration = nn_from_ddsi_duration (qext.duration); + *present |= fl; + return 0; } -static dds_return_t do_entity_factory_qospolicy (nn_entity_factory_qospolicy_t *q, uint64_t *present, uint64_t fl, const struct dd *dd) +static dds_return_t do_entity_factory_qospolicy (dds_entity_factory_qospolicy_t *q, uint64_t *present, uint64_t fl, const struct dd *dd) { if (dd->bufsz < sizeof (*q)) { @@ -1449,62 +1464,40 @@ static dds_return_t do_entity_factory_qospolicy (nn_entity_factory_qospolicy_t * return 0; } -dds_return_t validate_reader_data_lifecycle (const nn_reader_data_lifecycle_qospolicy_t *q) +static dds_return_t validate_external_reader_data_lifecycle (const dds_external_reader_data_lifecycle_qospolicy_t *q) { - if (validate_duration (&q->autopurge_nowriter_samples_delay) < 0 || - validate_duration (&q->autopurge_disposed_samples_delay) < 0) + if (validate_external_duration (&q->autopurge_nowriter_samples_delay) < 0 || + validate_external_duration (&q->autopurge_disposed_samples_delay) < 0) { DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid autopurge_nowriter_sample_delay or autopurge_disposed_samples_delay\n"); return DDS_RETCODE_BAD_PARAMETER; } - if (q->autopurge_dispose_all != 0 && q->autopurge_dispose_all != 1) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid autopurge_dispose_all\n"); - return DDS_RETCODE_BAD_PARAMETER; - } - if (q->enable_invalid_samples != 0 && q->enable_invalid_samples != 1) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid enable_invalid_samples\n"); - return DDS_RETCODE_BAD_PARAMETER; - } - /* Don't check consistency between enable_invalid_samples and invalid_samples_mode (yet) */ - switch (q->invalid_sample_visibility) - { - case NN_NO_INVALID_SAMPLE_VISIBILITY_QOS: - case NN_MINIMUM_INVALID_SAMPLE_VISIBILITY_QOS: - case NN_ALL_INVALID_SAMPLE_VISIBILITY_QOS: - break; - default: - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: invalid invalid_sample_visibility\n"); - return DDS_RETCODE_BAD_PARAMETER; - } return 0; } -static dds_return_t do_reader_data_lifecycle_v0 (nn_reader_data_lifecycle_qospolicy_t *q, const struct dd *dd) +dds_return_t validate_reader_data_lifecycle (const dds_reader_data_lifecycle_qospolicy_t *q) { - memcpy (q, dd->buf, 2 * sizeof (nn_duration_t)); - q->autopurge_dispose_all = 0; - q->enable_invalid_samples = 1; - q->invalid_sample_visibility = NN_MINIMUM_INVALID_SAMPLE_VISIBILITY_QOS; - if (dd->bswap) - { - bswap_duration (&q->autopurge_nowriter_samples_delay); - bswap_duration (&q->autopurge_disposed_samples_delay); - } - return validate_reader_data_lifecycle (q); + dds_external_reader_data_lifecycle_qospolicy_t qext; + qext.autopurge_disposed_samples_delay = nn_to_ddsi_duration (q->autopurge_disposed_samples_delay); + qext.autopurge_nowriter_samples_delay = nn_to_ddsi_duration (q->autopurge_nowriter_samples_delay); + return validate_external_reader_data_lifecycle (&qext); } -static dds_return_t do_reader_data_lifecycle_v1 (nn_reader_data_lifecycle_qospolicy_t *q, const struct dd *dd) +static dds_return_t do_reader_data_lifecycle (dds_reader_data_lifecycle_qospolicy_t *q, const struct dd *dd) { - memcpy (q, dd->buf, sizeof (*q)); + dds_external_reader_data_lifecycle_qospolicy_t qext; + dds_return_t ret; + memcpy (&qext, dd->buf, sizeof (qext)); if (dd->bswap) { - bswap_duration (&q->autopurge_nowriter_samples_delay); - bswap_duration (&q->autopurge_disposed_samples_delay); - q->invalid_sample_visibility = (nn_invalid_sample_visibility_kind_t) bswap4u ((unsigned) q->invalid_sample_visibility); + bswap_external_duration (&qext.autopurge_nowriter_samples_delay); + bswap_external_duration (&qext.autopurge_disposed_samples_delay); } - return validate_reader_data_lifecycle (q); + if ((ret = validate_external_reader_data_lifecycle (&qext)) < 0) + return ret; + q->autopurge_disposed_samples_delay = nn_from_ddsi_duration (qext.autopurge_disposed_samples_delay); + q->autopurge_nowriter_samples_delay = nn_from_ddsi_duration (qext.autopurge_nowriter_samples_delay); + return 0; } static dds_return_t init_one_parameter @@ -1513,7 +1506,7 @@ static dds_return_t init_one_parameter nn_ipaddress_params_tmp_t *dest_tmp, uint64_t pwanted, uint64_t qwanted, - unsigned short pid, + uint16_t pid, const struct dd *dd ) { @@ -1525,15 +1518,15 @@ static dds_return_t init_one_parameter return 0; /* Extended QoS data: */ -#define Q(NAME_, name_) case PID_##NAME_: \ - if (dd->bufsz < sizeof (nn_##name_##_qospolicy_t)) \ +#define Q(NAME_, prefix_, name_) case PID_##NAME_: \ + if (dd->bufsz < sizeof (prefix_##_##name_##_qospolicy_t)) \ { \ DDS_TRACE("plist/init_one_parameter[pid=%s]: buffer too small\n", #NAME_); \ - return DDS_RETCODE_BAD_PARAMETER; \ + return DDS_RETCODE_BAD_PARAMETER; \ } \ else \ { \ - nn_##name_##_qospolicy_t *q = &dest->qos.name_; \ + prefix_##_##name_##_qospolicy_t *q = &dest->qos.name_; \ memcpy (q, dd->buf, sizeof (*q)); \ if (dd->bswap) bswap_##name_##_qospolicy (q); \ if ((res = validate_##name_##_qospolicy (q)) < 0) \ @@ -1541,34 +1534,58 @@ static dds_return_t init_one_parameter dest->qos.present |= QP_##NAME_; \ } \ return 0 - Q (DURABILITY, durability); - Q (LIVELINESS, liveliness); - Q (DESTINATION_ORDER, destination_order); - Q (HISTORY, history); - Q (RESOURCE_LIMITS, resource_limits); - Q (OWNERSHIP, ownership); - Q (OWNERSHIP_STRENGTH, ownership_strength); - Q (PRESENTATION, presentation); - Q (TRANSPORT_PRIORITY, transport_priority); + Q (DURABILITY, dds, durability); + Q (DESTINATION_ORDER, dds, destination_order); + Q (HISTORY, dds, history); + Q (RESOURCE_LIMITS, dds, resource_limits); + Q (OWNERSHIP, dds, ownership); + Q (OWNERSHIP_STRENGTH, dds, ownership_strength); + Q (PRESENTATION, dds, presentation); + Q (TRANSPORT_PRIORITY, dds, transport_priority); #undef Q + case PID_LIVELINESS: + if (dd->bufsz < sizeof (dds_external_liveliness_qospolicy_t)) + { + DDS_TRACE("plist/init_one_parameter[pid=LIVELINESS]: buffer too small\n"); + return DDS_RETCODE_BAD_PARAMETER; + } + else + { + dds_external_liveliness_qospolicy_t qext; + dds_liveliness_qospolicy_t *q = &dest->qos.liveliness; + memcpy (&qext, dd->buf, sizeof (qext)); + if (dd->bswap) + bswap_external_liveliness_qospolicy (&qext); + if ((res = validate_external_liveliness_qospolicy (&qext)) < 0) + return res; + q->kind = qext.kind; + q->lease_duration = nn_from_ddsi_duration (qext.lease_duration); + dest->qos.present |= QP_LIVELINESS; + } + return 0; + case PID_DURABILITY_SERVICE: - if (dd->bufsz < sizeof (nn_durability_service_qospolicy_t)) + if (dd->bufsz < sizeof (dds_external_durability_service_qospolicy_t)) { DDS_TRACE("plist/init_one_parameter[pid=DURABILITY_SERVICE]: buffer too small\n"); return DDS_RETCODE_BAD_PARAMETER; } else { - nn_durability_service_qospolicy_t *q = &dest->qos.durability_service; + dds_external_durability_service_qospolicy_t qext; + dds_durability_service_qospolicy_t *q = &dest->qos.durability_service; /* All-zero durability service is illegal, but at least CoreDX sometimes advertises it in some harmless cases. So accept all-zero durability service, then handle it in final_validation, where we can determine whether it really is harmless or not */ - memcpy (q, dd->buf, sizeof (*q)); + memcpy (&qext, dd->buf, sizeof (qext)); if (dd->bswap) - bswap_durability_service_qospolicy (q); - if ((res = validate_durability_service_qospolicy_acceptzero (q, true)) < 0) + bswap_external_durability_service_qospolicy (&qext); + if ((res = validate_external_durability_service_qospolicy_acceptzero (&qext, true)) < 0) return res; + q->history = qext.history; + q->resource_limits = qext.resource_limits; + q->service_cleanup_delay = nn_from_ddsi_duration (qext.service_cleanup_delay); dest->qos.present |= QP_DURABILITY_SERVICE; } return 0; @@ -1580,15 +1597,15 @@ static dds_return_t init_one_parameter the case, it would've been an ordinary Q (RELIABILITY, reliability). */ case PID_RELIABILITY: - if (dd->bufsz < sizeof (nn_external_reliability_qospolicy_t)) + if (dd->bufsz < sizeof (dds_external_reliability_qospolicy_t)) { DDS_TRACE("plist/init_one_parameter[pid=RELIABILITY]: buffer too small\n"); return DDS_RETCODE_BAD_PARAMETER; } else { - nn_reliability_qospolicy_t *q = &dest->qos.reliability; - nn_external_reliability_qospolicy_t qext; + dds_reliability_qospolicy_t *q = &dest->qos.reliability; + dds_external_reliability_qospolicy_t qext; memcpy (&qext, dd->buf, sizeof (qext)); if (dd->bswap) bswap_external_reliability_qospolicy (&qext); @@ -1627,10 +1644,8 @@ static dds_return_t init_one_parameter dds_return_t ret; if (!vendor_is_eclipse_or_prismtech (dd->vendorid)) return 0; - if (dd->bufsz >= sizeof (nn_reader_data_lifecycle_qospolicy_t)) - ret = do_reader_data_lifecycle_v1 (&dest->qos.reader_data_lifecycle, dd); - else if (dd->bufsz >= 2 * sizeof (nn_duration_t)) - ret = do_reader_data_lifecycle_v0 (&dest->qos.reader_data_lifecycle, dd); + if (dd->bufsz >= sizeof (dds_external_reader_data_lifecycle_qospolicy_t)) + ret = do_reader_data_lifecycle (&dest->qos.reader_data_lifecycle, dd); else { DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_READER_DATA_LIFECYCLE]: buffer too small\n"); @@ -1645,85 +1660,22 @@ static dds_return_t init_one_parameter return 0; else { - nn_writer_data_lifecycle_qospolicy_t *q = &dest->qos.writer_data_lifecycle; - if (dd->bufsz < 1) + dds_writer_data_lifecycle_qospolicy_t *q = &dest->qos.writer_data_lifecycle; + if (dd->bufsz < sizeof (*q)) { DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: buffer too small\n"); return DDS_RETCODE_BAD_PARAMETER; } - else if (dd->bufsz < sizeof (*q)) - { - /* Spec form, with just autodispose_unregistered_instances */ - q->autodispose_unregistered_instances = dd->buf[0]; - q->autounregister_instance_delay = nn_to_ddsi_duration (T_NEVER); - q->autopurge_suspended_samples_delay = nn_to_ddsi_duration (T_NEVER); - } - else - { - memcpy (q, dd->buf, sizeof (*q)); - if (dd->bswap) - { - bswap_duration (&q->autounregister_instance_delay); - bswap_duration (&q->autopurge_suspended_samples_delay); - } - } + q->autodispose_unregistered_instances = dd->buf[0]; if (q->autodispose_unregistered_instances & ~1) { DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: invalid autodispose_unregistered_instances (%d)\n", (int) q->autodispose_unregistered_instances); return DDS_RETCODE_BAD_PARAMETER; } - if (validate_duration (&q->autounregister_instance_delay) < 0 || - validate_duration (&q->autopurge_suspended_samples_delay) < 0) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_WRITER_DATA_LIFECYCLE]: invalid autounregister_instance_delay or autopurge_suspended_samples_delay\n"); - return DDS_RETCODE_BAD_PARAMETER; - } dest->qos.present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE; return 0; } - case PID_PRISMTECH_RELAXED_QOS_MATCHING: - if (!vendor_is_eclipse_or_prismtech (dd->vendorid)) - return 0; - else if (dd->bufsz < sizeof (dest->qos.relaxed_qos_matching)) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_RELAXED_QOS_MATCHING]: buffer too small\n"); - return DDS_RETCODE_BAD_PARAMETER; - } - else - { - nn_relaxed_qos_matching_qospolicy_t *rqm = &dest->qos.relaxed_qos_matching; - memcpy (rqm, dd->buf, sizeof (*rqm)); - if (rqm->value != 0 && rqm->value != 1) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_RELAXED_QOS_MATCHING]: invalid\n"); - return DDS_RETCODE_BAD_PARAMETER; - } - dest->qos.present |= QP_PRISMTECH_RELAXED_QOS_MATCHING; - return 0; - } - - case PID_PRISMTECH_SYNCHRONOUS_ENDPOINT: /* PrismTech specific */ - if (!vendor_is_eclipse_or_prismtech (dd->vendorid)) - return 0; - else if (dd->bufsz < sizeof (dest->qos.synchronous_endpoint)) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_SYNCHRONOUS_ENDPOINT]: buffer too small\n"); - return DDS_RETCODE_BAD_PARAMETER; - } - else - { - nn_synchronous_endpoint_qospolicy_t *q = &dest->qos.synchronous_endpoint; - memcpy (q, dd->buf, sizeof (*q)); - if (q->value != 0 && q->value != 1) - { - DDS_TRACE("plist/init_one_parameter[pid=PRISMTECH_SYNCHRONOUS_ENDPOINT]: invalid value for synchronous flag\n"); - return DDS_RETCODE_BAD_PARAMETER; - } - dest->qos.present |= QP_PRISMTECH_SYNCHRONOUS_ENDPOINT; - return 0; - } - /* Other plist */ case PID_PROTOCOL_VERSION: if (dd->bufsz < sizeof (nn_protocol_version_t)) @@ -2183,16 +2135,16 @@ static dds_return_t init_one_parameter return DDS_RETCODE_BAD_PARAMETER; } -static void default_resource_limits (nn_resource_limits_qospolicy_t *q) +static void default_resource_limits (dds_resource_limits_qospolicy_t *q) { - q->max_instances = NN_DDS_LENGTH_UNLIMITED; - q->max_samples = NN_DDS_LENGTH_UNLIMITED; - q->max_samples_per_instance = NN_DDS_LENGTH_UNLIMITED; + q->max_instances = DDS_LENGTH_UNLIMITED; + q->max_samples = DDS_LENGTH_UNLIMITED; + q->max_samples_per_instance = DDS_LENGTH_UNLIMITED; } -static void default_history (nn_history_qospolicy_t *q) +static void default_history (dds_history_qospolicy_t *q) { - q->kind = NN_KEEP_LAST_HISTORY_QOS; + q->kind = DDS_HISTORY_KEEP_LAST; q->depth = 1; } @@ -2322,7 +2274,7 @@ static dds_return_t final_validation (nn_plist_t *dest, nn_protocol_version_t pr is valid or delete it if irrelevant. */ if (dest->qos.present & QP_DURABILITY_SERVICE) { - const nn_durability_kind_t durkind = (dest->qos.present & QP_DURABILITY) ? dest->qos.durability.kind : NN_VOLATILE_DURABILITY_QOS; + const dds_durability_kind_t durkind = (dest->qos.present & QP_DURABILITY) ? dest->qos.durability.kind : DDS_DURABILITY_VOLATILE; bool acceptzero; /* Use a somewhat convoluted rule to decide whether or not to "accept" an all-zero durability service setting, to find a @@ -2335,14 +2287,14 @@ static dds_return_t final_validation (nn_plist_t *dest, nn_protocol_version_t pr acceptzero = !vendor_is_eclipse (vendorid); switch (durkind) { - case NN_VOLATILE_DURABILITY_QOS: - case NN_TRANSIENT_LOCAL_DURABILITY_QOS: + case DDS_DURABILITY_VOLATILE: + case DDS_DURABILITY_TRANSIENT_LOCAL: /* pretend we never saw it if it is all zero */ if (acceptzero && durability_service_qospolicy_allzero (&dest->qos.durability_service)) dest->qos.present &= ~QP_DURABILITY_SERVICE; break; - case NN_TRANSIENT_DURABILITY_QOS: - case NN_PERSISTENT_DURABILITY_QOS: + case DDS_DURABILITY_TRANSIENT: + case DDS_DURABILITY_PERSISTENT: break; } /* if it is still present, it must be valid */ @@ -2409,17 +2361,17 @@ dds_return_t nn_plist_init_frommsg { nn_parameter_t *par = (nn_parameter_t *) pl; nn_parameterid_t pid; - unsigned short length; + uint16_t length; dds_return_t res; /* swapping header partially based on wireshark dissector output, partially on intuition, and in a small part based on the spec */ pid = (nn_parameterid_t) (dd.bswap ? bswap2u (par->parameterid) : par->parameterid); - length = (unsigned short) (dd.bswap ? bswap2u (par->length) : par->length); + length = (uint16_t) (dd.bswap ? bswap2u (par->length) : par->length); if (pid == PID_SENTINEL) { /* Sentinel terminates list, the length is ignored, DDSI 9.4.2.11. */ - DDS_LOG(DDS_LC_PLIST, "%4x PID %x\n", (unsigned) (pl - src->buf), pid); + DDS_LOG(DDS_LC_PLIST, "%4"PRIx32" PID %"PRIx16"\n", (uint32_t) (pl - src->buf), pid); if ((res = final_validation (dest, src->protocol_version, src->vendorid)) < 0) { nn_plist_fini (dest); @@ -2433,16 +2385,16 @@ dds_return_t nn_plist_init_frommsg return 0; } } - if (length > src->bufsz - sizeof (*par) - (unsigned) (pl - src->buf)) + if (length > src->bufsz - sizeof (*par) - (uint32_t) (pl - src->buf)) { - DDS_WARNING("plist(vendor %u.%u): parameter length %u out of bounds\n", + DDS_WARNING("plist(vendor %u.%u): parameter length %"PRIu16" out of bounds\n", src->vendorid.id[0], src->vendorid.id[1], length); nn_plist_fini (dest); return DDS_RETCODE_BAD_PARAMETER; } if ((length % 4) != 0) /* DDSI 9.4.2.11 */ { - DDS_WARNING("plist(vendor %u.%u): parameter length %u mod 4 != 0\n", + DDS_WARNING("plist(vendor %u.%u): parameter length %"PRIu16" mod 4 != 0\n", src->vendorid.id[0], src->vendorid.id[1], length); nn_plist_fini (dest); return DDS_RETCODE_BAD_PARAMETER; @@ -2450,7 +2402,7 @@ dds_return_t nn_plist_init_frommsg if (dds_get_log_mask() & DDS_LC_PLIST) { - DDS_LOG(DDS_LC_PLIST, "%4x PID %x len %u ", (unsigned) (pl - src->buf), pid, length); + DDS_LOG(DDS_LC_PLIST, "%4"PRIx32" PID %"PRIx16" len %"PRIu16" ", (uint32_t) (pl - src->buf), pid, length); log_octetseq(DDS_LC_PLIST, length, (const unsigned char *) (par + 1)); DDS_LOG(DDS_LC_PLIST, "\n"); } @@ -2460,7 +2412,7 @@ dds_return_t nn_plist_init_frommsg if ((res = init_one_parameter (dest, &dest_tmp, pwanted, qwanted, pid, &dd)) < 0) { /* make sure we print a trace message on error */ - DDS_TRACE("plist(vendor %u.%u): failed at pid=%u\n", src->vendorid.id[0], src->vendorid.id[1], pid); + DDS_TRACE("plist(vendor %u.%u): failed at pid=%"PRIx16"\n", src->vendorid.id[0], src->vendorid.id[1], pid); nn_plist_fini (dest); return res; } @@ -2535,13 +2487,13 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn return (unsigned char *) pl; if (length > src->bufsz - (size_t)(pl - src->buf)) { - DDS_WARNING("plist(vendor %u.%u): quickscan: parameter length %u out of bounds\n", + DDS_WARNING("plist(vendor %u.%u): quickscan: parameter length %"PRIu16" out of bounds\n", src->vendorid.id[0], src->vendorid.id[1], length); return NULL; } if ((length % 4) != 0) /* DDSI 9.4.2.11 */ { - DDS_WARNING("plist(vendor %u.%u): quickscan: parameter length %u mod 4 != 0\n", + DDS_WARNING("plist(vendor %u.%u): quickscan: parameter length %"PRIu16" mod 4 != 0\n", src->vendorid.id[0], src->vendorid.id[1], length); return NULL; } @@ -2558,8 +2510,8 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn } else { - unsigned stinfo = fromBE4u (*((unsigned *) pl)); - unsigned stinfox = (length < 8 || !vendor_is_eclipse_or_opensplice(src->vendorid)) ? 0 : fromBE4u (*((unsigned *) pl + 1)); + uint32_t stinfo = fromBE4u (*((uint32_t *) pl)); + uint32_t stinfox = (length < 8 || !vendor_is_eclipse_or_opensplice(src->vendorid)) ? 0 : fromBE4u (*((uint32_t *) pl + 1)); #if (NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER) != 3 #error "expected dispose/unregister to be in lowest 2 bits" #endif @@ -2569,7 +2521,7 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn } break; default: - DDS_LOG(DDS_LC_PLIST, "(pid=%x complex_qos=1)", pid); + DDS_LOG(DDS_LC_PLIST, "(pid=%"PRIx16" complex_qos=1)", pid); dest->complex_qos = 1; break; } @@ -2582,7 +2534,7 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn return NULL; } -void nn_xqos_init_empty (nn_xqos_t *dest) +void nn_xqos_init_empty (dds_qos_t *dest) { #ifndef NDEBUG memset (dest, 0, sizeof (*dest)); @@ -2597,7 +2549,7 @@ void nn_plist_init_default_participant (nn_plist_t *plist) plist->qos.entity_factory.autoenable_created_entities = 0; } -static void xqos_init_default_common (nn_xqos_t *xqos) +static void xqos_init_default_common (dds_qos_t *xqos) { nn_xqos_init_empty (xqos); @@ -2606,72 +2558,62 @@ static void xqos_init_default_common (nn_xqos_t *xqos) xqos->partition.strs = NULL; xqos->present |= QP_PRESENTATION; - xqos->presentation.access_scope = NN_INSTANCE_PRESENTATION_QOS; + xqos->presentation.access_scope = DDS_PRESENTATION_INSTANCE; xqos->presentation.coherent_access = 0; xqos->presentation.ordered_access = 0; xqos->present |= QP_DURABILITY; - xqos->durability.kind = NN_VOLATILE_DURABILITY_QOS; + xqos->durability.kind = DDS_DURABILITY_VOLATILE; xqos->present |= QP_DEADLINE; - xqos->deadline.deadline = nn_to_ddsi_duration (T_NEVER); + xqos->deadline.deadline = T_NEVER; xqos->present |= QP_LATENCY_BUDGET; - xqos->latency_budget.duration = nn_to_ddsi_duration (0); + xqos->latency_budget.duration = 0; xqos->present |= QP_LIVELINESS; - xqos->liveliness.kind = NN_AUTOMATIC_LIVELINESS_QOS; - xqos->liveliness.lease_duration = nn_to_ddsi_duration (T_NEVER); + xqos->liveliness.kind = DDS_LIVELINESS_AUTOMATIC; + xqos->liveliness.lease_duration = T_NEVER; xqos->present |= QP_DESTINATION_ORDER; - xqos->destination_order.kind = NN_BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS; + xqos->destination_order.kind = DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP; xqos->present |= QP_HISTORY; - xqos->history.kind = NN_KEEP_LAST_HISTORY_QOS; + xqos->history.kind = DDS_HISTORY_KEEP_LAST; xqos->history.depth = 1; xqos->present |= QP_RESOURCE_LIMITS; - xqos->resource_limits.max_samples = NN_DDS_LENGTH_UNLIMITED; - xqos->resource_limits.max_instances = NN_DDS_LENGTH_UNLIMITED; - xqos->resource_limits.max_samples_per_instance = NN_DDS_LENGTH_UNLIMITED; + xqos->resource_limits.max_samples = DDS_LENGTH_UNLIMITED; + xqos->resource_limits.max_instances = DDS_LENGTH_UNLIMITED; + xqos->resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED; xqos->present |= QP_TRANSPORT_PRIORITY; xqos->transport_priority.value = 0; xqos->present |= QP_OWNERSHIP; - xqos->ownership.kind = NN_SHARED_OWNERSHIP_QOS; - - xqos->present |= QP_PRISMTECH_RELAXED_QOS_MATCHING; - xqos->relaxed_qos_matching.value = 0; - - xqos->present |= QP_PRISMTECH_SYNCHRONOUS_ENDPOINT; - xqos->synchronous_endpoint.value = 0; + xqos->ownership.kind = DDS_OWNERSHIP_SHARED; xqos->present |= QP_CYCLONE_IGNORELOCAL; - xqos->ignorelocal.value = NN_NONE_IGNORELOCAL_QOS; + xqos->ignorelocal.value = DDS_IGNORELOCAL_NONE; } -void nn_xqos_init_default_reader (nn_xqos_t *xqos) +void nn_xqos_init_default_reader (dds_qos_t *xqos) { xqos_init_default_common (xqos); xqos->present |= QP_RELIABILITY; - xqos->reliability.kind = NN_BEST_EFFORT_RELIABILITY_QOS; + xqos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT; xqos->present |= QP_TIME_BASED_FILTER; - xqos->time_based_filter.minimum_separation = nn_to_ddsi_duration (0); + xqos->time_based_filter.minimum_separation = 0; xqos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE; - xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay = nn_to_ddsi_duration (T_NEVER); - xqos->reader_data_lifecycle.autopurge_disposed_samples_delay = nn_to_ddsi_duration (T_NEVER); - xqos->reader_data_lifecycle.autopurge_dispose_all = 0; - xqos->reader_data_lifecycle.enable_invalid_samples = 1; - xqos->reader_data_lifecycle.invalid_sample_visibility = NN_MINIMUM_INVALID_SAMPLE_VISIBILITY_QOS; + xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay = T_NEVER; + xqos->reader_data_lifecycle.autopurge_disposed_samples_delay = T_NEVER; xqos->present |= QP_PRISMTECH_READER_LIFESPAN; xqos->reader_lifespan.use_lifespan = 0; - xqos->reader_lifespan.duration = nn_to_ddsi_duration (T_NEVER); - + xqos->reader_lifespan.duration = T_NEVER; xqos->present |= QP_PRISMTECH_SUBSCRIPTION_KEYS; xqos->subscription_keys.use_key_list = 0; @@ -2679,21 +2621,21 @@ void nn_xqos_init_default_reader (nn_xqos_t *xqos) xqos->subscription_keys.key_list.strs = NULL; } -void nn_xqos_init_default_writer (nn_xqos_t *xqos) +void nn_xqos_init_default_writer (dds_qos_t *xqos) { xqos_init_default_common (xqos); xqos->present |= QP_DURABILITY_SERVICE; - xqos->durability_service.service_cleanup_delay = nn_to_ddsi_duration (0); - xqos->durability_service.history.kind = NN_KEEP_LAST_HISTORY_QOS; + xqos->durability_service.service_cleanup_delay = 0; + xqos->durability_service.history.kind = DDS_HISTORY_KEEP_LAST; xqos->durability_service.history.depth = 1; - xqos->durability_service.resource_limits.max_samples = NN_DDS_LENGTH_UNLIMITED; - xqos->durability_service.resource_limits.max_instances = NN_DDS_LENGTH_UNLIMITED; - xqos->durability_service.resource_limits.max_samples_per_instance = NN_DDS_LENGTH_UNLIMITED; + xqos->durability_service.resource_limits.max_samples = DDS_LENGTH_UNLIMITED; + xqos->durability_service.resource_limits.max_instances = DDS_LENGTH_UNLIMITED; + xqos->durability_service.resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED; xqos->present |= QP_RELIABILITY; - xqos->reliability.kind = NN_RELIABLE_RELIABILITY_QOS; - xqos->reliability.max_blocking_time = nn_to_ddsi_duration (100 * T_MILLISECOND); + xqos->reliability.kind = DDS_RELIABILITY_RELIABLE; + xqos->reliability.max_blocking_time = 100 * T_MILLISECOND; xqos->present |= QP_OWNERSHIP_STRENGTH; xqos->ownership_strength.value = 0; @@ -2702,41 +2644,39 @@ void nn_xqos_init_default_writer (nn_xqos_t *xqos) xqos->transport_priority.value = 0; xqos->present |= QP_LIFESPAN; - xqos->lifespan.duration = nn_to_ddsi_duration (T_NEVER); + xqos->lifespan.duration = T_NEVER; xqos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE; xqos->writer_data_lifecycle.autodispose_unregistered_instances = 1; - xqos->writer_data_lifecycle.autounregister_instance_delay = nn_to_ddsi_duration (T_NEVER); - xqos->writer_data_lifecycle.autopurge_suspended_samples_delay = nn_to_ddsi_duration (T_NEVER); } -void nn_xqos_init_default_writer_noautodispose (nn_xqos_t *xqos) +void nn_xqos_init_default_writer_noautodispose (dds_qos_t *xqos) { nn_xqos_init_default_writer (xqos); xqos->writer_data_lifecycle.autodispose_unregistered_instances = 0; } -void nn_xqos_init_default_topic (nn_xqos_t *xqos) +void nn_xqos_init_default_topic (dds_qos_t *xqos) { xqos_init_default_common (xqos); xqos->present |= QP_DURABILITY_SERVICE; - xqos->durability_service.service_cleanup_delay = nn_to_ddsi_duration (0); - xqos->durability_service.history.kind = NN_KEEP_LAST_HISTORY_QOS; + xqos->durability_service.service_cleanup_delay = 0; + xqos->durability_service.history.kind = DDS_HISTORY_KEEP_LAST; xqos->durability_service.history.depth = 1; - xqos->durability_service.resource_limits.max_samples = NN_DDS_LENGTH_UNLIMITED; - xqos->durability_service.resource_limits.max_instances = NN_DDS_LENGTH_UNLIMITED; - xqos->durability_service.resource_limits.max_samples_per_instance = NN_DDS_LENGTH_UNLIMITED; + xqos->durability_service.resource_limits.max_samples = DDS_LENGTH_UNLIMITED; + xqos->durability_service.resource_limits.max_instances = DDS_LENGTH_UNLIMITED; + xqos->durability_service.resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED; xqos->present |= QP_RELIABILITY; - xqos->reliability.kind = NN_BEST_EFFORT_RELIABILITY_QOS; - xqos->reliability.max_blocking_time = nn_to_ddsi_duration (100 * T_MILLISECOND); + xqos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT; + xqos->reliability.max_blocking_time = 100 * T_MILLISECOND; xqos->present |= QP_TRANSPORT_PRIORITY; xqos->transport_priority.value = 0; xqos->present |= QP_LIFESPAN; - xqos->lifespan.duration = nn_to_ddsi_duration (T_NEVER); + xqos->lifespan.duration = T_NEVER; xqos->present |= QP_PRISMTECH_SUBSCRIPTION_KEYS; xqos->subscription_keys.use_key_list = 0; @@ -2744,7 +2684,7 @@ void nn_xqos_init_default_topic (nn_xqos_t *xqos) xqos->subscription_keys.key_list.strs = NULL; } -void nn_xqos_init_default_subscriber (nn_xqos_t *xqos) +void nn_xqos_init_default_subscriber (dds_qos_t *xqos) { nn_xqos_init_empty (xqos); @@ -2757,7 +2697,7 @@ void nn_xqos_init_default_subscriber (nn_xqos_t *xqos) xqos->partition.strs = NULL; } -void nn_xqos_init_default_publisher (nn_xqos_t *xqos) +void nn_xqos_init_default_publisher (dds_qos_t *xqos) { nn_xqos_init_empty (xqos); @@ -2769,7 +2709,7 @@ void nn_xqos_init_default_publisher (nn_xqos_t *xqos) xqos->partition.strs = NULL; } -void nn_xqos_mergein_missing (nn_xqos_t *a, const nn_xqos_t *b) +void nn_xqos_mergein_missing (dds_qos_t *a, const dds_qos_t *b) { /* Adds QoS's from B to A (duplicating memory) (only those not present in A, obviously) */ @@ -2799,10 +2739,8 @@ void nn_xqos_mergein_missing (nn_xqos_t *a, const nn_xqos_t *b) CQ (TIME_BASED_FILTER, time_based_filter); CQ (PRISMTECH_READER_DATA_LIFECYCLE, reader_data_lifecycle); CQ (PRISMTECH_WRITER_DATA_LIFECYCLE, writer_data_lifecycle); - CQ (PRISMTECH_RELAXED_QOS_MATCHING, relaxed_qos_matching); CQ (PRISMTECH_READER_LIFESPAN, reader_lifespan); CQ (PRISMTECH_ENTITY_FACTORY, entity_factory); - CQ (PRISMTECH_SYNCHRONOUS_ENDPOINT, synchronous_endpoint); CQ (CYCLONE_IGNORELOCAL, ignorelocal); #undef CQ @@ -2818,12 +2756,12 @@ void nn_xqos_mergein_missing (nn_xqos_t *a, const nn_xqos_t *b) a->present |= QP_##fl_; \ } \ } while (0) - CQ (GROUP_DATA, group_data, octetseq, nn_octetseq_t); - CQ (TOPIC_DATA, topic_data, octetseq, nn_octetseq_t); - CQ (USER_DATA, user_data, octetseq, nn_octetseq_t); + CQ (GROUP_DATA, group_data, octetseq, ddsi_octetseq_t); + CQ (TOPIC_DATA, topic_data, octetseq, ddsi_octetseq_t); + CQ (USER_DATA, user_data, octetseq, ddsi_octetseq_t); CQ (TOPIC_NAME, topic_name, string, char *); CQ (TYPE_NAME, type_name, string, char *); - CQ (RTI_TYPECODE, rti_typecode, octetseq, nn_octetseq_t); + CQ (RTI_TYPECODE, rti_typecode, octetseq, ddsi_octetseq_t); #undef CQ if (!(a->present & QP_PRISMTECH_SUBSCRIPTION_KEYS) && (b->present & QP_PRISMTECH_SUBSCRIPTION_KEYS)) { @@ -2838,13 +2776,13 @@ void nn_xqos_mergein_missing (nn_xqos_t *a, const nn_xqos_t *b) } } -void nn_xqos_copy (nn_xqos_t *dst, const nn_xqos_t *src) +void nn_xqos_copy (dds_qos_t *dst, const dds_qos_t *src) { nn_xqos_init_empty (dst); nn_xqos_mergein_missing (dst, src); } -void nn_xqos_unalias (nn_xqos_t *xqos) +void nn_xqos_unalias (dds_qos_t *xqos) { DDS_LOG(DDS_LC_PLIST, "NN_XQOS_UNALIAS\n"); #define Q(name_, func_, field_) do { \ @@ -2865,20 +2803,19 @@ void nn_xqos_unalias (nn_xqos_t *xqos) assert (xqos->aliased == 0); } -void nn_xqos_fini (nn_xqos_t *xqos) +void nn_xqos_fini (dds_qos_t *xqos) { struct t { uint64_t fl; size_t off; }; static const struct t qos_simple[] = { - { QP_GROUP_DATA, offsetof (nn_xqos_t, group_data.value) }, - { QP_TOPIC_DATA, offsetof (nn_xqos_t, topic_data.value) }, - { QP_USER_DATA, offsetof (nn_xqos_t, user_data.value) }, - { QP_TOPIC_NAME, offsetof (nn_xqos_t, topic_name) }, - { QP_TYPE_NAME, offsetof (nn_xqos_t, type_name) }, - { QP_RTI_TYPECODE, offsetof (nn_xqos_t, rti_typecode.value) } + { QP_GROUP_DATA, offsetof (dds_qos_t, group_data.value) }, + { QP_TOPIC_DATA, offsetof (dds_qos_t, topic_data.value) }, + { QP_USER_DATA, offsetof (dds_qos_t, user_data.value) }, + { QP_TOPIC_NAME, offsetof (dds_qos_t, topic_name) }, + { QP_TYPE_NAME, offsetof (dds_qos_t, type_name) }, + { QP_RTI_TYPECODE, offsetof (dds_qos_t, rti_typecode.value) } }; - int i; DDS_LOG(DDS_LC_PLIST, "NN_XQOS_FINI\n"); - for (i = 0; i < (int) (sizeof (qos_simple) / sizeof (*qos_simple)); i++) + for (size_t i = 0; i < sizeof (qos_simple) / sizeof (*qos_simple); i++) { if ((xqos->present & qos_simple[i].fl) && !(xqos->aliased & qos_simple[i].fl)) { @@ -2914,27 +2851,22 @@ void nn_xqos_fini (nn_xqos_t *xqos) xqos->present = 0; } -nn_xqos_t * nn_xqos_dup (const nn_xqos_t *src) +dds_qos_t * nn_xqos_dup (const dds_qos_t *src) { - nn_xqos_t *dst = ddsrt_malloc (sizeof (*dst)); + dds_qos_t *dst = ddsrt_malloc (sizeof (*dst)); nn_xqos_copy (dst, src); assert (dst->aliased == 0); return dst; } -static int octetseqs_differ (const nn_octetseq_t *a, const nn_octetseq_t *b) +static int octetseqs_differ (const ddsi_octetseq_t *a, const ddsi_octetseq_t *b) { return (a->length != b->length || memcmp (a->value, b->value, a->length) != 0); } -static int durations_differ (const nn_duration_t *a, const nn_duration_t *b) +static int stringseqs_differ (const ddsi_stringseq_t *a, const ddsi_stringseq_t *b) { - return (a->seconds != b->seconds || a->fraction != b->fraction); -} - -static int stringseqs_differ (const nn_stringseq_t *a, const nn_stringseq_t *b) -{ - unsigned i; + uint32_t i; if (a->n != b->n) return 1; for (i = 0; i < a->n; i++) @@ -2943,29 +2875,29 @@ static int stringseqs_differ (const nn_stringseq_t *a, const nn_stringseq_t *b) return 0; } -static int histories_differ (const nn_history_qospolicy_t *a, const nn_history_qospolicy_t *b) +static int histories_differ (const dds_history_qospolicy_t *a, const dds_history_qospolicy_t *b) { - return (a->kind != b->kind || (a->kind == NN_KEEP_LAST_HISTORY_QOS && a->depth != b->depth)); + return (a->kind != b->kind || (a->kind == DDS_HISTORY_KEEP_LAST && a->depth != b->depth)); } -static int resource_limits_differ (const nn_resource_limits_qospolicy_t *a, const nn_resource_limits_qospolicy_t *b) +static int resource_limits_differ (const dds_resource_limits_qospolicy_t *a, const dds_resource_limits_qospolicy_t *b) { return (a->max_samples != b->max_samples || a->max_instances != b->max_instances || a->max_samples_per_instance != b->max_samples_per_instance); } -static int partition_is_default (const nn_partition_qospolicy_t *a) +static int partition_is_default (const dds_partition_qospolicy_t *a) { - unsigned i; + uint32_t i; for (i = 0; i < a->n; i++) if (strcmp (a->strs[i], "") != 0) return 0; return 1; } -static int partitions_equal_n2 (const nn_partition_qospolicy_t *a, const nn_partition_qospolicy_t *b) +static int partitions_equal_n2 (const dds_partition_qospolicy_t *a, const dds_partition_qospolicy_t *b) { - unsigned i, j; + uint32_t i, j; for (i = 0; i < a->n; i++) { for (j = 0; j < b->n; j++) @@ -2977,22 +2909,27 @@ static int partitions_equal_n2 (const nn_partition_qospolicy_t *a, const nn_part return 1; } -static int partitions_equal_nlogn (const nn_partition_qospolicy_t *a, const nn_partition_qospolicy_t *b) +static int strcmp_wrapper (const void *a, const void *b) +{ + return strcmp (a, b); +} + +static int partitions_equal_nlogn (const dds_partition_qospolicy_t *a, const dds_partition_qospolicy_t *b) { char *statictab[8], **tab; int equal = 1; - unsigned i; + uint32_t i; - if (a->n <= (int) (sizeof (statictab) / sizeof (*statictab))) + if (a->n <= sizeof (statictab) / sizeof (*statictab)) tab = statictab; else tab = ddsrt_malloc (a->n * sizeof (*tab)); for (i = 0; i < a->n; i++) tab[i] = a->strs[i]; - qsort (tab, a->n, sizeof (*tab), (int (*) (const void *, const void *)) strcmp); + qsort (tab, a->n, sizeof (*tab), strcmp_wrapper); for (i = 0; i < b->n; i++) - if (bsearch (b->strs[i], tab, a->n, sizeof (*tab), (int (*) (const void *, const void *)) strcmp) == NULL) + if (bsearch (b->strs[i], tab, a->n, sizeof (*tab), strcmp_wrapper) == NULL) { equal = 0; break; @@ -3002,7 +2939,7 @@ static int partitions_equal_nlogn (const nn_partition_qospolicy_t *a, const nn_p return equal; } -static int partitions_equal (const nn_partition_qospolicy_t *a, const nn_partition_qospolicy_t *b) +static int partitions_equal (const dds_partition_qospolicy_t *a, const dds_partition_qospolicy_t *b) { /* Return true iff (the set a->strs) equals (the set b->strs); that is, order doesn't matter. One could argue that "**" and "*" are @@ -3023,7 +2960,7 @@ static int partitions_equal (const nn_partition_qospolicy_t *a, const nn_partiti assuming that |A| >= |B|. */ if (a->n < b->n) { - const nn_partition_qospolicy_t *x = a; + const dds_partition_qospolicy_t *x = a; a = b; b = x; } @@ -3040,7 +2977,7 @@ static int partitions_equal (const nn_partition_qospolicy_t *a, const nn_partiti } } -uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask) +uint64_t nn_xqos_delta (const dds_qos_t *a, const dds_qos_t *b, uint64_t mask) { /* Returns QP_... set for RxO settings where a differs from b; if present in a but not in b (or in b but not in a) it counts as a @@ -3079,29 +3016,27 @@ uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask) } if (check & QP_DURABILITY_SERVICE) { - const nn_durability_service_qospolicy_t *qa = &a->durability_service; - const nn_durability_service_qospolicy_t *qb = &b->durability_service; - if (durations_differ (&qa->service_cleanup_delay, &qb->service_cleanup_delay) || + const dds_durability_service_qospolicy_t *qa = &a->durability_service; + const dds_durability_service_qospolicy_t *qb = &b->durability_service; + if (qa->service_cleanup_delay != qb->service_cleanup_delay || histories_differ (&qa->history, &qb->history) || resource_limits_differ (&qa->resource_limits, &qb->resource_limits)) delta |= QP_DURABILITY_SERVICE; } if (check & QP_DEADLINE) { - if (durations_differ (&a->deadline.deadline, &b->deadline.deadline)) + if (a->deadline.deadline != b->deadline.deadline) delta |= QP_DEADLINE; } if (check & QP_LATENCY_BUDGET) { - if (durations_differ (&a->latency_budget.duration, &b->latency_budget.duration)) + if (a->latency_budget.duration != b->latency_budget.duration) delta |= QP_LATENCY_BUDGET; } if (check & QP_LIVELINESS) { - if (a->liveliness.kind != b->liveliness.kind || - durations_differ (&a->liveliness.lease_duration, &b->liveliness.lease_duration)) + if (a->liveliness.kind != b->liveliness.kind || a->liveliness.lease_duration != b->liveliness.lease_duration) delta |= QP_LIVELINESS; } if (check & QP_RELIABILITY) { - if (a->reliability.kind != b->reliability.kind || - durations_differ (&a->reliability.max_blocking_time, &b->reliability.max_blocking_time)) + if (a->reliability.kind != b->reliability.kind || a->reliability.max_blocking_time != b->reliability.max_blocking_time) delta |= QP_RELIABILITY; } if (check & QP_DESTINATION_ORDER) { @@ -3121,7 +3056,7 @@ uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask) delta |= QP_TRANSPORT_PRIORITY; } if (check & QP_LIFESPAN) { - if (durations_differ (&a->lifespan.duration, &b->lifespan.duration)) + if (a->lifespan.duration != b->lifespan.duration) delta |= QP_LIFESPAN; } if (check & QP_USER_DATA) { @@ -3137,38 +3072,24 @@ uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask) delta |= QP_OWNERSHIP_STRENGTH; } if (check & QP_TIME_BASED_FILTER) { - if (durations_differ (&a->time_based_filter.minimum_separation, &b->time_based_filter.minimum_separation)) + if (a->time_based_filter.minimum_separation != b->time_based_filter.minimum_separation) delta |= QP_TIME_BASED_FILTER; } if (check & QP_PRISMTECH_READER_DATA_LIFECYCLE) { - if (durations_differ (&a->reader_data_lifecycle.autopurge_disposed_samples_delay, - &b->reader_data_lifecycle.autopurge_disposed_samples_delay) || - durations_differ (&a->reader_data_lifecycle.autopurge_nowriter_samples_delay, - &b->reader_data_lifecycle.autopurge_nowriter_samples_delay) || - a->reader_data_lifecycle.autopurge_dispose_all != b->reader_data_lifecycle.autopurge_dispose_all || - a->reader_data_lifecycle.enable_invalid_samples != b->reader_data_lifecycle.enable_invalid_samples || - a->reader_data_lifecycle.invalid_sample_visibility != b->reader_data_lifecycle.invalid_sample_visibility) + if (a->reader_data_lifecycle.autopurge_disposed_samples_delay != b->reader_data_lifecycle.autopurge_disposed_samples_delay || + a->reader_data_lifecycle.autopurge_nowriter_samples_delay != b->reader_data_lifecycle.autopurge_nowriter_samples_delay) delta |= QP_PRISMTECH_READER_DATA_LIFECYCLE; } if (check & QP_PRISMTECH_WRITER_DATA_LIFECYCLE) { if (a->writer_data_lifecycle.autodispose_unregistered_instances != - b->writer_data_lifecycle.autodispose_unregistered_instances || - durations_differ (&a->writer_data_lifecycle.autopurge_suspended_samples_delay, - &b->writer_data_lifecycle.autopurge_suspended_samples_delay) || - durations_differ (&a->writer_data_lifecycle.autounregister_instance_delay, - &b->writer_data_lifecycle.autounregister_instance_delay)) + b->writer_data_lifecycle.autodispose_unregistered_instances) delta |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE; } - if (check & QP_PRISMTECH_RELAXED_QOS_MATCHING) { - if (a->relaxed_qos_matching.value != - b->relaxed_qos_matching.value) - delta |= QP_PRISMTECH_RELAXED_QOS_MATCHING; - } if (check & QP_PRISMTECH_READER_LIFESPAN) { /* Note: the conjunction need not test both a & b for having use_lifespan set */ if (a->reader_lifespan.use_lifespan != b->reader_lifespan.use_lifespan || (a->reader_lifespan.use_lifespan && b->reader_lifespan.use_lifespan && - durations_differ (&a->reader_lifespan.duration, &b->reader_lifespan.duration))) + a->reader_lifespan.duration != b->reader_lifespan.duration)) delta |= QP_PRISMTECH_READER_LIFESPAN; } if (check & QP_PRISMTECH_SUBSCRIPTION_KEYS) { @@ -3183,10 +3104,6 @@ uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask) b->entity_factory.autoenable_created_entities) delta |= QP_PRISMTECH_ENTITY_FACTORY; } - if (check & QP_PRISMTECH_SYNCHRONOUS_ENDPOINT) { - if (a->synchronous_endpoint.value != b->synchronous_endpoint.value) - delta |= QP_PRISMTECH_SYNCHRONOUS_ENDPOINT; - } if (check & QP_RTI_TYPECODE) { if (octetseqs_differ (&a->rti_typecode, &b->rti_typecode)) delta |= QP_RTI_TYPECODE; @@ -3200,17 +3117,17 @@ uint64_t nn_xqos_delta (const nn_xqos_t *a, const nn_xqos_t *b, uint64_t mask) /*************************/ -void nn_xqos_addtomsg (struct nn_xmsg *m, const nn_xqos_t *xqos, uint64_t wanted) +void nn_xqos_addtomsg (struct nn_xmsg *m, const dds_qos_t *xqos, uint64_t wanted) { /* Returns new nn_xmsg pointer (currently, reallocs may happen) */ uint64_t w = xqos->present & wanted; char *tmp; -#define SIMPLE(name_, field_) \ +#define SIMPLE(name_, prefix_, field_) \ do { \ if (w & QP_##name_) { \ tmp = nn_xmsg_addpar (m, PID_##name_, sizeof (xqos->field_)); \ - *((nn_##field_##_qospolicy_t *) tmp) = xqos->field_; \ + *((prefix_##_##field_##_qospolicy_t *) tmp) = xqos->field_; \ } \ } while (0) #define FUNC_BY_REF(name_, field_, func_) \ @@ -3228,32 +3145,30 @@ void nn_xqos_addtomsg (struct nn_xmsg *m, const nn_xqos_t *xqos, uint64_t wanted FUNC_BY_VAL (TOPIC_NAME, topic_name, string); FUNC_BY_VAL (TYPE_NAME, type_name, string); - SIMPLE (PRESENTATION, presentation); + SIMPLE (PRESENTATION, dds, presentation); FUNC_BY_REF (PARTITION, partition, stringseq); FUNC_BY_REF (GROUP_DATA, group_data, octetseq); FUNC_BY_REF (TOPIC_DATA, topic_data, octetseq); - SIMPLE (DURABILITY, durability); - SIMPLE (DURABILITY_SERVICE, durability_service); - SIMPLE (DEADLINE, deadline); - SIMPLE (LATENCY_BUDGET, latency_budget); - SIMPLE (LIVELINESS, liveliness); + SIMPLE (DURABILITY, dds, durability); + FUNC_BY_REF (DURABILITY_SERVICE, durability_service, durability_service); + FUNC_BY_VAL (DEADLINE, deadline.deadline, duration); + FUNC_BY_VAL (LATENCY_BUDGET, latency_budget.duration, duration); + FUNC_BY_REF (LIVELINESS, liveliness, liveliness); FUNC_BY_REF (RELIABILITY, reliability, reliability); - SIMPLE (DESTINATION_ORDER, destination_order); - SIMPLE (HISTORY, history); - SIMPLE (RESOURCE_LIMITS, resource_limits); - SIMPLE (TRANSPORT_PRIORITY, transport_priority); - SIMPLE (LIFESPAN, lifespan); + SIMPLE (DESTINATION_ORDER, dds, destination_order); + SIMPLE (HISTORY, dds, history); + SIMPLE (RESOURCE_LIMITS, dds, resource_limits); + SIMPLE (TRANSPORT_PRIORITY, dds, transport_priority); + FUNC_BY_VAL (LIFESPAN, lifespan.duration, duration); FUNC_BY_REF (USER_DATA, user_data, octetseq); - SIMPLE (OWNERSHIP, ownership); - SIMPLE (OWNERSHIP_STRENGTH, ownership_strength); - SIMPLE (TIME_BASED_FILTER, time_based_filter); - SIMPLE (PRISMTECH_READER_DATA_LIFECYCLE, reader_data_lifecycle); - SIMPLE (PRISMTECH_WRITER_DATA_LIFECYCLE, writer_data_lifecycle); - SIMPLE (PRISMTECH_RELAXED_QOS_MATCHING, relaxed_qos_matching); - SIMPLE (PRISMTECH_READER_LIFESPAN, reader_lifespan); + SIMPLE (OWNERSHIP, dds, ownership); + SIMPLE (OWNERSHIP_STRENGTH, dds, ownership_strength); + FUNC_BY_VAL (TIME_BASED_FILTER, time_based_filter.minimum_separation, duration); + FUNC_BY_REF (PRISMTECH_READER_DATA_LIFECYCLE, reader_data_lifecycle, reader_data_lifecycle); + SIMPLE (PRISMTECH_WRITER_DATA_LIFECYCLE, dds, writer_data_lifecycle); + FUNC_BY_REF (PRISMTECH_READER_LIFESPAN, reader_lifespan, reader_lifespan); FUNC_BY_REF (PRISMTECH_SUBSCRIPTION_KEYS, subscription_keys, subscription_keys); - SIMPLE (PRISMTECH_ENTITY_FACTORY, entity_factory); - SIMPLE (PRISMTECH_SYNCHRONOUS_ENDPOINT, synchronous_endpoint); + SIMPLE (PRISMTECH_ENTITY_FACTORY, dds, entity_factory); FUNC_BY_REF (RTI_TYPECODE, rti_typecode, octetseq); /* CYCLONE_IGNORELOCAL is not visible on the wire */ #undef FUNC_BY_REF @@ -3261,7 +3176,7 @@ void nn_xqos_addtomsg (struct nn_xmsg *m, const nn_xqos_t *xqos, uint64_t wanted #undef SIMPLE } -static void add_locators (struct nn_xmsg *m, uint64_t present, uint64_t flag, const nn_locators_t *ls, unsigned pid) +static void add_locators (struct nn_xmsg *m, uint64_t present, uint64_t flag, const nn_locators_t *ls, nn_parameterid_t pid) { const struct nn_locators_one *l; if (present & flag) @@ -3313,7 +3228,7 @@ void nn_plist_addtomsg (struct nn_xmsg *m, const nn_plist_t *ps, uint64_t pwante add_locators (m, ps->present, PP_METATRAFFIC_MULTICAST_LOCATOR, &ps->metatraffic_multicast_locators, PID_METATRAFFIC_MULTICAST_LOCATOR); SIMPLE_TYPE (EXPECTS_INLINE_QOS, expects_inline_qos, unsigned char); - SIMPLE_TYPE (PARTICIPANT_LEASE_DURATION, participant_lease_duration, nn_duration_t); + FUNC_BY_VAL (PARTICIPANT_LEASE_DURATION, participant_lease_duration, duration); FUNC_BY_REF (PARTICIPANT_GUID, participant_guid, guid); SIMPLE_TYPE (BUILTIN_ENDPOINT_SET, builtin_endpoint_set, unsigned); SIMPLE_TYPE (KEYHASH, keyhash, nn_keyhash_t); @@ -3349,21 +3264,21 @@ void nn_plist_addtomsg (struct nn_xmsg *m, const nn_plist_t *ps, uint64_t pwante /*************************/ -static unsigned isprint_runlen (unsigned n, const unsigned char *xs) +static uint32_t isprint_runlen (uint32_t n, const unsigned char *xs) { - unsigned m; + uint32_t m; for (m = 0; m < n && xs[m] != '"' && isprint (xs[m]); m++) ; return m; } -static void log_octetseq (uint32_t cat, unsigned n, const unsigned char *xs) +static void log_octetseq (uint32_t cat, uint32_t n, const unsigned char *xs) { - unsigned i = 0; + uint32_t i = 0; while (i < n) { - unsigned m = isprint_runlen(n - i, xs); + uint32_t m = isprint_runlen(n - i, xs); if (m >= 4) { DDS_LOG(cat, "%s\"%*.*s\"", i == 0 ? "" : ",", m, m, xs); @@ -3383,7 +3298,7 @@ static void log_octetseq (uint32_t cat, unsigned n, const unsigned char *xs) } } -void nn_log_xqos (uint32_t cat, const nn_xqos_t *xqos) +void nn_log_xqos (uint32_t cat, const dds_qos_t *xqos) { uint64_t p = xqos->present; const char *prefix = ""; @@ -3395,16 +3310,15 @@ void nn_log_xqos (uint32_t cat, const nn_xqos_t *xqos) #define LOGB5(fmt_, arg0_, arg1_, arg2_, arg3_, arg4_) DDS_LOG(cat, "%s" fmt_, prefix, arg0_, arg1_, arg2_, arg3_, arg4_) #define DO(name_, body_) do { if (p & QP_##name_) { { body_ } prefix = ","; } } while (0) -#define FMT_DUR "%d.%09d" -#define PRINTARG_DUR(d) (d).seconds, (int) ((d).fraction/4.294967296) +#define FMT_DUR "%"PRId64".%09"PRId32 +#define PRINTARG_DUR(d) ((int64_t) ((d) / 1000000000)), ((int32_t) ((d) % 1000000000)) DO (TOPIC_NAME, { LOGB1 ("topic=%s", xqos->topic_name); }); DO (TYPE_NAME, { LOGB1 ("type=%s", xqos->type_name); }); DO (PRESENTATION, { LOGB3 ("presentation=%d:%u:%u", xqos->presentation.access_scope, xqos->presentation.coherent_access, xqos->presentation.ordered_access); }); DO (PARTITION, { - unsigned i; LOGB0 ("partition={"); - for (i = 0; i < xqos->partition.n; i++) { + for (uint32_t i = 0; i < xqos->partition.n; i++) { DDS_LOG(cat, "%s%s", (i == 0) ? "" : ",", xqos->partition.strs[i]); } DDS_LOG(cat, "}"); @@ -3443,24 +3357,18 @@ void nn_log_xqos (uint32_t cat, const nn_xqos_t *xqos) DO (OWNERSHIP, { LOGB1 ("ownership=%d", xqos->ownership.kind); }); DO (OWNERSHIP_STRENGTH, { LOGB1 ("ownership_strength=%"PRId32, xqos->ownership_strength.value); }); DO (TIME_BASED_FILTER, { LOGB1 ("time_based_filter="FMT_DUR, PRINTARG_DUR (xqos->time_based_filter.minimum_separation)); }); - DO (PRISMTECH_READER_DATA_LIFECYCLE, { LOGB5 ("reader_data_lifecycle="FMT_DUR":"FMT_DUR":%u:%u:%d", PRINTARG_DUR (xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay), PRINTARG_DUR (xqos->reader_data_lifecycle.autopurge_disposed_samples_delay), xqos->reader_data_lifecycle.autopurge_dispose_all, xqos->reader_data_lifecycle.enable_invalid_samples, (int) xqos->reader_data_lifecycle.invalid_sample_visibility); }); + DO (PRISMTECH_READER_DATA_LIFECYCLE, { LOGB2 ("reader_data_lifecycle="FMT_DUR":"FMT_DUR, PRINTARG_DUR (xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay), PRINTARG_DUR (xqos->reader_data_lifecycle.autopurge_disposed_samples_delay)); }); DO (PRISMTECH_WRITER_DATA_LIFECYCLE, { - LOGB3 ("writer_data_lifecycle={%u,"FMT_DUR","FMT_DUR"}", - xqos->writer_data_lifecycle.autodispose_unregistered_instances, - PRINTARG_DUR (xqos->writer_data_lifecycle.autounregister_instance_delay), - PRINTARG_DUR (xqos->writer_data_lifecycle.autopurge_suspended_samples_delay)); }); - DO (PRISMTECH_RELAXED_QOS_MATCHING, { LOGB1 ("relaxed_qos_matching=%u", xqos->relaxed_qos_matching.value); }); + LOGB1 ("writer_data_lifecycle={%u}", xqos->writer_data_lifecycle.autodispose_unregistered_instances); }); DO (PRISMTECH_READER_LIFESPAN, { LOGB2 ("reader_lifespan={%u,"FMT_DUR"}", xqos->reader_lifespan.use_lifespan, PRINTARG_DUR (xqos->reader_lifespan.duration)); }); DO (PRISMTECH_SUBSCRIPTION_KEYS, { - unsigned i; LOGB1 ("subscription_keys={%u,{", xqos->subscription_keys.use_key_list); - for (i = 0; i < xqos->subscription_keys.key_list.n; i++) { + for (uint32_t i = 0; i < xqos->subscription_keys.key_list.n; i++) { DDS_LOG(cat, "%s%s", (i == 0) ? "" : ",", xqos->subscription_keys.key_list.strs[i]); } DDS_LOG(cat, "}}"); }); DO (PRISMTECH_ENTITY_FACTORY, { LOGB1 ("entity_factory=%u", xqos->entity_factory.autoenable_created_entities); }); - DO (PRISMTECH_SYNCHRONOUS_ENDPOINT, { LOGB1 ("synchronous_endpoint=%u", xqos->synchronous_endpoint.value); }); DO (RTI_TYPECODE, { LOGB1 ("rti_typecode=%"PRIu32"<", xqos->rti_typecode.length); log_octetseq (cat, xqos->rti_typecode.length, xqos->rti_typecode.value); diff --git a/src/core/ddsi/src/q_qosmatch.c b/src/core/ddsi/src/q_qosmatch.c index f7ee363..ec2afd1 100644 --- a/src/core/ddsi/src/q_qosmatch.c +++ b/src/core/ddsi/src/q_qosmatch.c @@ -35,7 +35,7 @@ static int partition_patmatch_p (const char *pat, const char *name) return ddsi2_patmatch (pat, name); } -static int partitions_match_default (const nn_xqos_t *x) +static int partitions_match_default (const dds_qos_t *x) { unsigned i; if (!(x->present & QP_PARTITION) || x->partition.n == 0) @@ -46,7 +46,7 @@ static int partitions_match_default (const nn_xqos_t *x) return 0; } -int partitions_match_p (const nn_xqos_t *a, const nn_xqos_t *b) +int partitions_match_p (const dds_qos_t *a, const dds_qos_t *b) { if (!(a->present & QP_PARTITION) || a->partition.n == 0) return partitions_match_default (b); @@ -66,117 +66,74 @@ int partitions_match_p (const nn_xqos_t *a, const nn_xqos_t *b) } } -static int ddsi_duration_is_lt (nn_duration_t a0, nn_duration_t b0) -{ - /* inf counts as <= inf */ - const int64_t a = nn_from_ddsi_duration (a0); - const int64_t b = nn_from_ddsi_duration (b0); - if (a == T_NEVER) - return 0; - else if (b == T_NEVER) - return 1; - else - return a < b; -} +static bool qos_match_internal_p (const dds_qos_t *rd, const dds_qos_t *wr, dds_qos_policy_id_t *reason) ddsrt_nonnull_all; -/* Duplicates of DDS policy ids to avoid inclusion of actual definitions */ - -#define Q_INVALID_QOS_POLICY_ID 0 -#define Q_USERDATA_QOS_POLICY_ID 1 -#define Q_DURABILITY_QOS_POLICY_ID 2 -#define Q_PRESENTATION_QOS_POLICY_ID 3 -#define Q_DEADLINE_QOS_POLICY_ID 4 -#define Q_LATENCYBUDGET_QOS_POLICY_ID 5 -#define Q_OWNERSHIP_QOS_POLICY_ID 6 -#define Q_OWNERSHIPSTRENGTH_QOS_POLICY_ID 7 -#define Q_LIVELINESS_QOS_POLICY_ID 8 -#define Q_TIMEBASEDFILTER_QOS_POLICY_ID 9 -#define Q_PARTITION_QOS_POLICY_ID 10 -#define Q_RELIABILITY_QOS_POLICY_ID 11 -#define Q_DESTINATIONORDER_QOS_POLICY_ID 12 -#define Q_HISTORY_QOS_POLICY_ID 13 -#define Q_RESOURCELIMITS_QOS_POLICY_ID 14 -#define Q_ENTITYFACTORY_QOS_POLICY_ID 15 -#define Q_WRITERDATALIFECYCLE_QOS_POLICY_ID 16 -#define Q_READERDATALIFECYCLE_QOS_POLICY_ID 17 -#define Q_TOPICDATA_QOS_POLICY_ID 18 -#define Q_GROUPDATA_QOS_POLICY_ID 19 -#define Q_TRANSPORTPRIORITY_QOS_POLICY_ID 20 -#define Q_LIFESPAN_QOS_POLICY_ID 21 -#define Q_DURABILITYSERVICE_QOS_POLICY_ID 22 - -int32_t qos_match_p (const nn_xqos_t *rd, const nn_xqos_t *wr) +static bool qos_match_internal_p (const dds_qos_t *rd, const dds_qos_t *wr, dds_qos_policy_id_t *reason) { #ifndef NDEBUG unsigned musthave = (QP_RXO_MASK | QP_PARTITION | QP_TOPIC_NAME | QP_TYPE_NAME); assert ((rd->present & musthave) == musthave); assert ((wr->present & musthave) == musthave); #endif + *reason = DDS_INVALID_QOS_POLICY_ID; if (strcmp (rd->topic_name, wr->topic_name) != 0) - { - return Q_INVALID_QOS_POLICY_ID; - } + return false; if (strcmp (rd->type_name, wr->type_name) != 0) - { - return Q_INVALID_QOS_POLICY_ID; + return false; + + if (rd->reliability.kind > wr->reliability.kind) { + *reason = DDS_RELIABILITY_QOS_POLICY_ID; + return false; } - if (rd->relaxed_qos_matching.value || wr->relaxed_qos_matching.value) - { - if (rd->reliability.kind != wr->reliability.kind) - { - return Q_RELIABILITY_QOS_POLICY_ID; - } + if (rd->durability.kind > wr->durability.kind) { + *reason = DDS_DURABILITY_QOS_POLICY_ID; + return false; } - else - { - if (rd->reliability.kind > wr->reliability.kind) - { - return Q_RELIABILITY_QOS_POLICY_ID; - } - if (rd->durability.kind > wr->durability.kind) - { - return Q_DURABILITY_QOS_POLICY_ID; - } - if (rd->presentation.access_scope > wr->presentation.access_scope) - { - return Q_PRESENTATION_QOS_POLICY_ID; - } - if (rd->presentation.coherent_access > wr->presentation.coherent_access) - { - return Q_PRESENTATION_QOS_POLICY_ID; - } - if (rd->presentation.ordered_access > wr->presentation.ordered_access) - { - return Q_PRESENTATION_QOS_POLICY_ID; - } - if (ddsi_duration_is_lt (rd->deadline.deadline, wr->deadline.deadline)) - { - return Q_DEADLINE_QOS_POLICY_ID; - } - if (ddsi_duration_is_lt (rd->latency_budget.duration, wr->latency_budget.duration)) - { - return Q_LATENCYBUDGET_QOS_POLICY_ID; - } - if (rd->ownership.kind != wr->ownership.kind) - { - return Q_OWNERSHIP_QOS_POLICY_ID; - } - if (rd->liveliness.kind > wr->liveliness.kind) - { - return Q_LIVELINESS_QOS_POLICY_ID; - } - if (ddsi_duration_is_lt (rd->liveliness.lease_duration, wr->liveliness.lease_duration)) - { - return Q_LIVELINESS_QOS_POLICY_ID; - } - if (rd->destination_order.kind > wr->destination_order.kind) - { - return Q_DESTINATIONORDER_QOS_POLICY_ID; - } + if (rd->presentation.access_scope > wr->presentation.access_scope) { + *reason = DDS_PRESENTATION_QOS_POLICY_ID; + return false; } - if (!partitions_match_p (rd, wr)) - { - return Q_PARTITION_QOS_POLICY_ID; + if (rd->presentation.coherent_access > wr->presentation.coherent_access) { + *reason = DDS_PRESENTATION_QOS_POLICY_ID; + return false; } - return -1; + if (rd->presentation.ordered_access > wr->presentation.ordered_access) { + *reason = DDS_PRESENTATION_QOS_POLICY_ID; + return false; + } + if (rd->deadline.deadline < wr->deadline.deadline) { + *reason = DDS_DEADLINE_QOS_POLICY_ID; + return false; + } + if (rd->latency_budget.duration < wr->latency_budget.duration) { + *reason = DDS_LATENCYBUDGET_QOS_POLICY_ID; + return false; + } + if (rd->ownership.kind != wr->ownership.kind) { + *reason = DDS_OWNERSHIP_QOS_POLICY_ID; + return false; + } + if (rd->liveliness.kind > wr->liveliness.kind) { + *reason = DDS_LIVELINESS_QOS_POLICY_ID; + return false; + } + if (rd->liveliness.lease_duration < wr->liveliness.lease_duration) { + *reason = DDS_LIVELINESS_QOS_POLICY_ID; + return false; + } + if (rd->destination_order.kind > wr->destination_order.kind) { + *reason = DDS_DESTINATIONORDER_QOS_POLICY_ID; + return false; + } + if (!partitions_match_p (rd, wr)) { + *reason = DDS_PARTITION_QOS_POLICY_ID; + return false; + } + return true; +} + +bool qos_match_p (const dds_qos_t *rd, const dds_qos_t *wr, dds_qos_policy_id_t *reason) +{ + dds_qos_policy_id_t dummy; + return qos_match_internal_p (rd, wr, reason ? reason : &dummy); } diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c index aff4669..b4f5176 100644 --- a/src/core/ddsi/src/q_receive.c +++ b/src/core/ddsi/src/q_receive.c @@ -657,7 +657,7 @@ static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_cou return 1; } -static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const AckNack_t *msg, nn_ddsi_time_t timestamp) +static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const AckNack_t *msg, nn_wctime_t timestamp) { struct proxy_reader *prd; struct wr_prd_match *rn; @@ -757,11 +757,10 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac work so well if the timestamp can be a left over from some other submessage -- but then, it is no more than a quick hack at the moment. */ - if (config.meas_hb_to_ack_latency && valid_ddsi_timestamp (timestamp)) + if (config.meas_hb_to_ack_latency && timestamp.v) { nn_wctime_t tstamp_now = now (); - nn_wctime_t tstamp_msg = nn_wctime_from_ddsi_time (timestamp); - nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - tstamp_msg.v); + nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - timestamp.v); if ((dds_get_log_mask() & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + 10 * T_SECOND) { nn_lat_estim_log (DDS_LC_TRACE, NULL, &rn->hb_to_ack_latency); @@ -794,7 +793,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac /* If this reader was marked as "non-responsive" in the past, it's now responding again, so update its status */ - if (rn->seq == MAX_SEQ_NUMBER && prd->c.xqos->reliability.kind == NN_RELIABLE_RELIABILITY_QOS) + if (rn->seq == MAX_SEQ_NUMBER && prd->c.xqos->reliability.kind == DDS_RELIABILITY_RELIABLE) { seqno_t oldest_seq; oldest_seq = WHCST_ISEMPTY(&whcst) ? wr->seq : whcst.max_seq; @@ -888,7 +887,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac a future request'll fix it. */ enqueued = 1; seq_xmit = READ_SEQ_XMIT(wr); - const bool gap_for_already_acked = vendor_is_eclipse (rst->vendor) && prd->c.xqos->durability.kind == NN_VOLATILE_DURABILITY_QOS && seqbase <= rn->seq; + const bool gap_for_already_acked = vendor_is_eclipse (rst->vendor) && prd->c.xqos->durability.kind == DDS_DURABILITY_VOLATILE && seqbase <= rn->seq; const seqno_t min_seq_to_rexmit = gap_for_already_acked ? rn->seq + 1 : 0; for (i = 0; i < numbits && seqbase + i <= seq_xmit && enqueued; i++) { @@ -1088,7 +1087,7 @@ struct handle_Heartbeat_helper_arg { struct receiver_state *rst; const Heartbeat_t *msg; struct proxy_writer *pwr; - nn_ddsi_time_t timestamp; + nn_wctime_t timestamp; nn_etime_t tnow; nn_mtime_t tnow_mt; }; @@ -1145,13 +1144,13 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand } if (resched_xevent_if_earlier (wn->acknack_xevent, tsched)) { - if (config.meas_hb_to_ack_latency && valid_ddsi_timestamp (arg->timestamp)) - wn->hb_timestamp = nn_wctime_from_ddsi_time (arg->timestamp); + if (config.meas_hb_to_ack_latency && arg->timestamp.v) + wn->hb_timestamp = arg->timestamp; } } } -static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Heartbeat_t *msg, nn_ddsi_time_t timestamp) +static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Heartbeat_t *msg, nn_wctime_t timestamp) { /* We now cheat: and process the heartbeat for _all_ readers, always, regardless of the destination address in the Heartbeat @@ -1567,22 +1566,19 @@ static int handle_InfoSRC (struct receiver_state *rst, const InfoSRC_t *msg) return 1; } -static int handle_InfoTS (const InfoTS_t *msg, nn_ddsi_time_t *timestamp) +static int handle_InfoTS (const InfoTS_t *msg, nn_wctime_t *timestamp) { DDS_TRACE("INFOTS("); if (msg->smhdr.flags & INFOTS_INVALIDATE_FLAG) { - *timestamp = invalid_ddsi_timestamp; + *timestamp = NN_WCTIME_INVALID; DDS_TRACE("invalidate"); } else { - *timestamp = msg->time; + *timestamp = nn_wctime_from_ddsi_time (msg->time); if (dds_get_log_mask() & DDS_LC_TRACE) - { - nn_wctime_t t = nn_wctime_from_ddsi_time (* timestamp); - DDS_TRACE("%d.%09d", (int) (t.v / 1000000000), (int) (t.v % 1000000000)); - } + DDS_TRACE("%d.%09d", (int) (timestamp->v / 1000000000), (int) (timestamp->v % 1000000000)); } DDS_TRACE(")"); return 1; @@ -1974,8 +1970,8 @@ static int deliver_user_data (const struct nn_rsample_info *sampleinfo, const st worry about it. */ { nn_wctime_t tstamp; - if (valid_ddsi_timestamp (sampleinfo->timestamp)) - tstamp = nn_wctime_from_ddsi_time (sampleinfo->timestamp); + if (sampleinfo->timestamp.v != NN_WCTIME_INVALID.v) + tstamp = sampleinfo->timestamp; else tstamp.v = 0; payload = extract_sample_from_data (sampleinfo, data_smhdr_flags, &qos, fragchain, statusinfo, tstamp, topic); @@ -2663,7 +2659,7 @@ static int handle_submsg_sequence Header_t * hdr = (Header_t *) msg; struct receiver_state *rst; int rst_live, ts_for_latmeas; - nn_ddsi_time_t timestamp; + nn_wctime_t timestamp; size_t submsg_size = 0; unsigned char * end = msg + len; struct nn_dqueue *deferred_wakeup = NULL; @@ -2693,7 +2689,7 @@ static int handle_submsg_sequence rst->srcloc = *srcloc; rst_live = 0; ts_for_latmeas = 0; - timestamp = invalid_ddsi_timestamp; + timestamp = NN_WCTIME_INVALID; assert (thread_is_asleep ()); thread_state_awake (ts1); @@ -2748,14 +2744,14 @@ static int handle_submsg_sequence state = "parse:acknack"; if (!valid_AckNack (&sm->acknack, submsg_size, byteswap)) goto malformed; - handle_AckNack (rst, tnowE, &sm->acknack, ts_for_latmeas ? timestamp : invalid_ddsi_timestamp); + handle_AckNack (rst, tnowE, &sm->acknack, ts_for_latmeas ? timestamp : NN_WCTIME_INVALID); ts_for_latmeas = 0; break; case SMID_HEARTBEAT: state = "parse:heartbeat"; if (!valid_Heartbeat (&sm->heartbeat, submsg_size, byteswap)) goto malformed; - handle_Heartbeat (rst, tnowE, rmsg, &sm->heartbeat, ts_for_latmeas ? timestamp : invalid_ddsi_timestamp); + handle_Heartbeat (rst, tnowE, rmsg, &sm->heartbeat, ts_for_latmeas ? timestamp : NN_WCTIME_INVALID); ts_for_latmeas = 0; break; case SMID_GAP: diff --git a/src/core/ddsi/src/q_time.c b/src/core/ddsi/src/q_time.c index 05878b3..79cfcf3 100644 --- a/src/core/ddsi/src/q_time.c +++ b/src/core/ddsi/src/q_time.c @@ -14,10 +14,6 @@ #include "dds/ddsrt/time.h" #include "dds/ddsi/q_time.h" -const nn_ddsi_time_t invalid_ddsi_timestamp = { -1, UINT32_MAX }; -const nn_ddsi_time_t ddsi_time_infinite = { INT32_MAX, UINT32_MAX }; -const nn_duration_t duration_infinite = { INT32_MAX, UINT32_MAX }; - nn_wctime_t now (void) { /* This function uses the wall clock. @@ -131,21 +127,21 @@ nn_etime_t add_duration_to_etime (nn_etime_t t, int64_t d) return u; } -int valid_ddsi_timestamp (nn_ddsi_time_t t) +int valid_ddsi_timestamp (ddsi_time_t t) { - return t.seconds != invalid_ddsi_timestamp.seconds && t.fraction != invalid_ddsi_timestamp.fraction; + return t.seconds != DDSI_TIME_INVALID.seconds && t.fraction != DDSI_TIME_INVALID.fraction; } -static nn_ddsi_time_t nn_to_ddsi_time (int64_t t) +static ddsi_time_t nn_to_ddsi_time (int64_t t) { if (t == T_NEVER) - return ddsi_time_infinite; + return DDSI_TIME_INFINITE; else { /* ceiling(ns * 2^32/10^9) -- can't change the ceiling to round-to-nearest because that would break backwards compatibility, but round-to-nearest of the inverse is correctly rounded anyway, so it shouldn't ever matter. */ - nn_ddsi_time_t x; + ddsi_time_t x; int ns = (int) (t % T_SECOND); x.seconds = (int) (t / T_SECOND); x.fraction = (unsigned) (((T_SECOND-1) + ((int64_t) ns << 32)) / T_SECOND); @@ -153,14 +149,14 @@ static nn_ddsi_time_t nn_to_ddsi_time (int64_t t) } } -nn_ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t) +ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t) { return nn_to_ddsi_time (t.v); } -static int64_t nn_from_ddsi_time (nn_ddsi_time_t x) +static int64_t nn_from_ddsi_time (ddsi_time_t x) { - if (x.seconds == ddsi_time_infinite.seconds && x.fraction == ddsi_time_infinite.fraction) + if (x.seconds == DDSI_TIME_INFINITE.seconds && x.fraction == DDSI_TIME_INFINITE.fraction) return T_NEVER; else { @@ -170,19 +166,19 @@ static int64_t nn_from_ddsi_time (nn_ddsi_time_t x) } } -nn_wctime_t nn_wctime_from_ddsi_time (nn_ddsi_time_t x) +nn_wctime_t nn_wctime_from_ddsi_time (ddsi_time_t x) { nn_wctime_t t; t.v = nn_from_ddsi_time (x); return t; } -nn_duration_t nn_to_ddsi_duration (int64_t x) +ddsi_duration_t nn_to_ddsi_duration (int64_t x) { return nn_to_ddsi_time (x); } -int64_t nn_from_ddsi_duration (nn_duration_t x) +int64_t nn_from_ddsi_duration (ddsi_duration_t x) { return nn_from_ddsi_time (x); } diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c index a47c12c..c6f85aa 100644 --- a/src/core/ddsi/src/q_transmit.c +++ b/src/core/ddsi/src/q_transmit.c @@ -424,7 +424,7 @@ static dds_return_t create_fragment_message_simple (struct writer *wr, seqno_t s #endif nn_xmsg_setdstN (*pmsg, wr->as, wr->as_group); - nn_xmsg_setmaxdelay (*pmsg, nn_from_ddsi_duration (wr->xqos->latency_budget.duration)); + nn_xmsg_setmaxdelay (*pmsg, wr->xqos->latency_budget.duration); nn_xmsg_add_timestamp (*pmsg, serdata->timestamp); data = nn_xmsg_append (*pmsg, &sm_marker, sizeof (Data_t)); @@ -521,7 +521,7 @@ dds_return_t create_fragment_message (struct writer *wr, seqno_t seq, const stru else { nn_xmsg_setdstN (*pmsg, wr->as, wr->as_group); - nn_xmsg_setmaxdelay (*pmsg, nn_from_ddsi_duration (wr->xqos->latency_budget.duration)); + nn_xmsg_setmaxdelay (*pmsg, wr->xqos->latency_budget.duration); } /* Timestamp only needed once, for the first fragment */ @@ -938,7 +938,7 @@ static dds_return_t throttle_writer (struct thread_state1 * const ts1, struct nn dds_return_t result = DDS_RETCODE_OK; nn_mtime_t tnow = now_mt (); - const nn_mtime_t abstimeout = add_duration_to_mtime (tnow, nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time)); + const nn_mtime_t abstimeout = add_duration_to_mtime (tnow, wr->xqos->reliability.max_blocking_time); struct whc_state whcst; whc_get_state (wr->whc, &whcst); @@ -1024,7 +1024,7 @@ static int write_sample_eot (struct thread_state1 * const ts1, struct nn_xpack * nn_mtime_t tnow; /* If GC not allowed, we must be sure to never block when writing. That is only the case for (true, aggressive) KEEP_LAST writers, and also only if there is no limit to how much unacknowledged data the WHC may contain. */ - assert(gc_allowed || (wr->xqos->history.kind == NN_KEEP_LAST_HISTORY_QOS && wr->whc_low == INT32_MAX)); + assert(gc_allowed || (wr->xqos->history.kind == DDS_HISTORY_KEEP_LAST && wr->whc_low == INT32_MAX)); (void)gc_allowed; if (ddsi_serdata_size (serdata) > config.max_sample_size) diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c index b443e25..924c663 100644 --- a/src/core/ddsi/src/q_xmsg.c +++ b/src/core/ddsi/src/q_xmsg.c @@ -782,7 +782,7 @@ size_t nn_xmsg_add_string_padded(unsigned char *buf, char *str) return len; } -size_t nn_xmsg_add_octseq_padded(unsigned char *buf, nn_octetseq_t *seq) +size_t nn_xmsg_add_octseq_padded(unsigned char *buf, ddsi_octetseq_t *seq) { unsigned len = seq->length; if (buf) { @@ -799,15 +799,16 @@ size_t nn_xmsg_add_octseq_padded(unsigned char *buf, nn_octetseq_t *seq) align4u(len); /* seqlen + possible padding */ } -void * nn_xmsg_addpar (struct nn_xmsg *m, unsigned pid, size_t len) +void *nn_xmsg_addpar (struct nn_xmsg *m, nn_parameterid_t pid, size_t len) { - const size_t len4 = (len + 3) & (size_t)-4; /* must alloc a multiple of 4 */ + const size_t len4 = (len + 3) & ~(size_t)3; /* must alloc a multiple of 4 */ nn_parameter_t *phdr; char *p; + assert (len4 < UINT16_MAX); /* FIXME: return error */ m->have_params = 1; phdr = nn_xmsg_append (m, NULL, sizeof (nn_parameter_t) + len4); - phdr->parameterid = (nn_parameterid_t) pid; - phdr->length = (unsigned short) len4; + phdr->parameterid = pid; + phdr->length = (uint16_t) len4; p = (char *) (phdr + 1); if (len4 > len) { @@ -819,23 +820,23 @@ void * nn_xmsg_addpar (struct nn_xmsg *m, unsigned pid, size_t len) return p; } -void nn_xmsg_addpar_string (struct nn_xmsg *m, unsigned pid, const char *str) +void nn_xmsg_addpar_string (struct nn_xmsg *m, nn_parameterid_t pid, const char *str) { struct cdrstring *p; - unsigned len = (unsigned) strlen (str) + 1; + size_t len = strlen (str) + 1; p = nn_xmsg_addpar (m, pid, 4 + len); - p->length = len; + p->length = (uint32_t) len; memcpy (p->contents, str, len); } -void nn_xmsg_addpar_octetseq (struct nn_xmsg *m, unsigned pid, const nn_octetseq_t *oseq) +void nn_xmsg_addpar_octetseq (struct nn_xmsg *m, nn_parameterid_t pid, const ddsi_octetseq_t *oseq) { char *p = nn_xmsg_addpar (m, pid, 4 + oseq->length); *((unsigned *) p) = oseq->length; memcpy (p + sizeof (int), oseq->value, oseq->length); } -void nn_xmsg_addpar_stringseq (struct nn_xmsg *m, unsigned pid, const nn_stringseq_t *sseq) +void nn_xmsg_addpar_stringseq (struct nn_xmsg *m, nn_parameterid_t pid, const ddsi_stringseq_t *sseq) { unsigned char *tmp; uint32_t i; @@ -866,7 +867,7 @@ void nn_xmsg_addpar_keyhash (struct nn_xmsg *m, const struct ddsi_serdata *serda } } -void nn_xmsg_addpar_guid (struct nn_xmsg *m, unsigned pid, const nn_guid_t *guid) +void nn_xmsg_addpar_guid (struct nn_xmsg *m, nn_parameterid_t pid, const nn_guid_t *guid) { unsigned *pu; int i; @@ -878,50 +879,68 @@ void nn_xmsg_addpar_guid (struct nn_xmsg *m, unsigned pid, const nn_guid_t *guid pu[i] = toBE4u (guid->entityid.u); } -void nn_xmsg_addpar_reliability (struct nn_xmsg *m, unsigned pid, const struct nn_reliability_qospolicy *rq) +void nn_xmsg_addpar_reliability (struct nn_xmsg *m, nn_parameterid_t pid, const struct dds_reliability_qospolicy *rq) { - struct nn_external_reliability_qospolicy *p; + struct dds_external_reliability_qospolicy *p; p = nn_xmsg_addpar (m, pid, sizeof (*p)); - if (NN_PEDANTIC_P) + switch (rq->kind) { - switch (rq->kind) - { - case NN_BEST_EFFORT_RELIABILITY_QOS: - p->kind = NN_PEDANTIC_BEST_EFFORT_RELIABILITY_QOS; - break; - case NN_RELIABLE_RELIABILITY_QOS: - p->kind = NN_PEDANTIC_RELIABLE_RELIABILITY_QOS; - break; - default: - assert (0); - } + case DDS_RELIABILITY_BEST_EFFORT: + p->kind = DDS_EXTERNAL_RELIABILITY_BEST_EFFORT; + break; + case DDS_RELIABILITY_RELIABLE: + p->kind = DDS_EXTERNAL_RELIABILITY_RELIABLE; + break; + default: + assert (0); } - else - { - switch (rq->kind) - { - case NN_BEST_EFFORT_RELIABILITY_QOS: - p->kind = NN_INTEROP_BEST_EFFORT_RELIABILITY_QOS; - break; - case NN_RELIABLE_RELIABILITY_QOS: - p->kind = NN_INTEROP_RELIABLE_RELIABILITY_QOS; - break; - default: - assert (0); - } - } - p->max_blocking_time = rq->max_blocking_time; + p->max_blocking_time = nn_to_ddsi_duration (rq->max_blocking_time); } -void nn_xmsg_addpar_4u (struct nn_xmsg *m, unsigned pid, unsigned x) +void nn_xmsg_addpar_duration (struct nn_xmsg *m, nn_parameterid_t pid, const dds_duration_t rq) { - unsigned *p = nn_xmsg_addpar (m, pid, 4); + ddsi_duration_t *p = nn_xmsg_addpar (m, pid, sizeof (*p)); + *p = nn_to_ddsi_duration (rq); +} + +void nn_xmsg_addpar_durability_service (struct nn_xmsg *m, nn_parameterid_t pid, const dds_durability_service_qospolicy_t *rq) +{ + dds_external_durability_service_qospolicy_t *p = nn_xmsg_addpar (m, pid, sizeof (*p)); + p->history = rq->history; + p->resource_limits = rq->resource_limits; + p->service_cleanup_delay = nn_to_ddsi_duration (rq->service_cleanup_delay); +} + +void nn_xmsg_addpar_reader_lifespan (struct nn_xmsg *m, nn_parameterid_t pid, const dds_reader_lifespan_qospolicy_t *rq) +{ + dds_external_reader_lifespan_qospolicy_t *p = nn_xmsg_addpar (m, pid, sizeof (*p)); + p->use_lifespan = rq->use_lifespan; + p->duration = nn_to_ddsi_duration (rq->duration); +} + +void nn_xmsg_addpar_reader_data_lifecycle (struct nn_xmsg *m, nn_parameterid_t pid, const dds_reader_data_lifecycle_qospolicy_t *rq) +{ + dds_external_reader_data_lifecycle_qospolicy_t *p = nn_xmsg_addpar (m, pid, sizeof (*p)); + p->autopurge_disposed_samples_delay = nn_to_ddsi_duration (rq->autopurge_disposed_samples_delay); + p->autopurge_nowriter_samples_delay = nn_to_ddsi_duration (rq->autopurge_nowriter_samples_delay); +} + +void nn_xmsg_addpar_liveliness (struct nn_xmsg *m, nn_parameterid_t pid, const dds_liveliness_qospolicy_t *rq) +{ + dds_external_liveliness_qospolicy_t *p = nn_xmsg_addpar (m, pid, sizeof (*p)); + p->kind = rq->kind; + p->lease_duration = nn_to_ddsi_duration (rq->lease_duration); +} + +void nn_xmsg_addpar_4u (struct nn_xmsg *m, nn_parameterid_t pid, uint32_t x) +{ + unsigned *p = nn_xmsg_addpar (m, pid, sizeof (x)); *p = x; } -void nn_xmsg_addpar_BE4u (struct nn_xmsg *m, unsigned pid, unsigned x) +void nn_xmsg_addpar_BE4u (struct nn_xmsg *m, nn_parameterid_t pid, uint32_t x) { - unsigned *p = nn_xmsg_addpar (m, pid, 4); + unsigned *p = nn_xmsg_addpar (m, pid, sizeof (x)); *p = toBE4u (x); } @@ -941,28 +960,7 @@ void nn_xmsg_addpar_statusinfo (struct nn_xmsg *m, unsigned statusinfo) } } - -void nn_xmsg_addpar_share (struct nn_xmsg *m, unsigned pid, const struct nn_share_qospolicy *q) -{ - /* Written thus to allow q->name to be a null pointer if enable = false */ - const unsigned fixed_len = 4 + 4; - const unsigned len = (q->enable ? (unsigned) strlen (q->name) : 0) + 1; - unsigned char *p; - struct cdrstring *ps; - p = nn_xmsg_addpar (m, pid, fixed_len + len); - p[0] = q->enable; - p[1] = 0; - p[2] = 0; - p[3] = 0; - ps = (struct cdrstring *) (p + 4); - ps->length = len; - if (q->enable) - memcpy (ps->contents, q->name, len); - else - ps->contents[0] = 0; -} - -void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, unsigned pid, const struct nn_subscription_keys_qospolicy *q) +void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, nn_parameterid_t pid, const struct dds_subscription_keys_qospolicy *q) { unsigned char *tmp; size_t len = 8; /* use_key_list, length of key_list */ @@ -1012,7 +1010,7 @@ int nn_xmsg_addpar_sentinel_ifparam (struct nn_xmsg * m) return 0; } -void nn_xmsg_addpar_parvinfo (struct nn_xmsg *m, unsigned pid, const struct nn_prismtech_participant_version_info *pvi) +void nn_xmsg_addpar_parvinfo (struct nn_xmsg *m, nn_parameterid_t pid, const struct nn_prismtech_participant_version_info *pvi) { int i; unsigned slen; @@ -1033,7 +1031,7 @@ void nn_xmsg_addpar_parvinfo (struct nn_xmsg *m, unsigned pid, const struct nn_p memcpy(ps->contents, pvi->internals, slen); } -void nn_xmsg_addpar_eotinfo (struct nn_xmsg *m, unsigned pid, const struct nn_prismtech_eotinfo *txnid) +void nn_xmsg_addpar_eotinfo (struct nn_xmsg *m, nn_parameterid_t pid, const struct nn_prismtech_eotinfo *txnid) { uint32_t *pu, i; pu = nn_xmsg_addpar (m, pid, 2 * sizeof (uint32_t) + txnid->n * sizeof (txnid->tids[0])); diff --git a/src/core/xtests/rhc_torture/rhc_torture.c b/src/core/xtests/rhc_torture/rhc_torture.c index 245d057..f743c12 100644 --- a/src/core/xtests/rhc_torture/rhc_torture.c +++ b/src/core/xtests/rhc_torture/rhc_torture.c @@ -140,7 +140,7 @@ static uint64_t store (struct rhc *rhc, struct proxy_writer *wr, struct ddsi_ser static struct proxy_writer *mkwr (bool auto_dispose) { struct proxy_writer *pwr; - struct nn_xqos *xqos; + struct dds_qos *xqos; uint64_t wr_iid; pwr = ddsrt_malloc (sizeof (*pwr)); xqos = ddsrt_malloc (sizeof (*xqos)); @@ -161,10 +161,10 @@ static void fwr (struct proxy_writer *wr) free (wr); } -static struct rhc *mkrhc (dds_reader *rd, nn_history_kind_t hk, int32_t hdepth, nn_destination_order_kind_t dok) +static struct rhc *mkrhc (dds_reader *rd, dds_history_kind_t hk, int32_t hdepth, dds_destination_order_kind_t dok) { struct rhc *rhc; - nn_xqos_t rqos; + dds_qos_t rqos; nn_xqos_init_empty (&rqos); rqos.present |= QP_HISTORY | QP_DESTINATION_ORDER; rqos.history.kind = hk; @@ -848,7 +848,7 @@ int main (int argc, char **argv) { if (print) printf ("************* 0 *************\n"); - struct rhc *rhc = mkrhc (NULL, NN_KEEP_LAST_HISTORY_QOS, 1, NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS); + struct rhc *rhc = mkrhc (NULL, DDS_HISTORY_KEEP_LAST, 1, DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP); struct proxy_writer *wr0 = mkwr (1); uint64_t iid0, iid1, iid_t; iid0 = store (rhc, wr0, mksample (0, 0), print); @@ -894,7 +894,7 @@ int main (int argc, char **argv) { if (print) printf ("************* 1 *************\n"); - struct rhc *rhc = mkrhc (NULL, NN_KEEP_LAST_HISTORY_QOS, 4, NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS); + struct rhc *rhc = mkrhc (NULL, DDS_HISTORY_KEEP_LAST, 4, DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP); struct proxy_writer *wr[] = { mkwr (0), mkwr (0), mkwr (0) }; uint64_t iid0, iid_t; int nregs = 3, isreg[] = { 1, 1, 1 };