diff --git a/docs/manual/config/config_file_reference.rst b/docs/manual/config/config_file_reference.rst index ffe85c57b5..776a9907fb 100644 --- a/docs/manual/config/config_file_reference.rst +++ b/docs/manual/config/config_file_reference.rst @@ -655,6 +655,7 @@ The default value is: ``default`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Attributes: :ref:`config`, :ref:`library`, :ref:`name`, :ref:`priority` +Children: :ref:`forbiddenTopics`, :ref:`onlyForTopics` This element defines a PSMX. @@ -707,6 +708,76 @@ This attribute specifies the interface priority (decimal integer or default). Th The default value is: ``default`` +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics`: + +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +Children: :ref:`Pattern` + +A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics. + + +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern`: + +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern +____________________________________________________________________________________ + +Attributes: :ref:`value` + +Text + +A pattern (with ? and \* wildcards) that is matched against topics. + +The default value is: ```` + + +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value]`: + +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] +____________________________________________________________________________________________ + +Text + + +The default value is: ```` + + +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/onlyForTopics`: + +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/onlyForTopics +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +Children: :ref:`Pattern` + +A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics. + + +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/onlyForTopics/Pattern`: + +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/onlyForTopics/Pattern +__________________________________________________________________________________ + +Attributes: :ref:`value` + +Text + +A pattern (with ? and \* wildcards) that is matched against topics. + +The default value is: ```` + + +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value]`: + +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] +____________________________________________________________________________________________ + +Text + + +The default value is: ```` + + .. _`//CycloneDDS/Domain/General/MaxMessageSize`: //CycloneDDS/Domain/General/MaxMessageSize @@ -2704,10 +2775,10 @@ The categorisation of tracing output is incomplete and hence most of the verbosi The default value is: ``none`` .. - generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f] + generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c] generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] - generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1] - generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b] + generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] + generated from ddsi_config.c[6fa39d18f6f0d241b7592a0dc23741e2a934ff2e] generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] diff --git a/docs/manual/options.md b/docs/manual/options.md index 217bb09790..48717e1727 100644 --- a/docs/manual/options.md +++ b/docs/manual/options.md @@ -438,6 +438,7 @@ The default value is: `default` ##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange Attributes: [config](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeconfig), [library](#cycloneddsdomaingeneralinterfacespubsubmessageexchangelibrary), [name](#cycloneddsdomaingeneralinterfacespubsubmessageexchangename), [priority](#cycloneddsdomaingeneralinterfacespubsubmessageexchangepriority) +Children: [forbiddenTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopics), [onlyForTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeonlyfortopics) This element defines a PSMX. @@ -474,6 +475,52 @@ This attribute specifies the interface priority (decimal integer or default). Th The default value is: `default` +###### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics +Children: [Pattern](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopicspattern) + +A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics. + + +####### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern +Attributes: [value](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopicspatternvalue) + +Text + +A pattern (with ? and \* wildcards) that is matched against topics. + +The default value is: `` + + +####### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] +Text + + +The default value is: `` + + +###### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/onlyForTopics +Children: [Pattern](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeonlyfortopicspattern) + +A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics. + + +####### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/onlyForTopics/Pattern +Attributes: [value](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopicspatternvalue) + +Text + +A pattern (with ? and \* wildcards) that is matched against topics. + +The default value is: `` + + +####### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] +Text + + +The default value is: `` + + #### //CycloneDDS/Domain/General/MaxMessageSize Number-with-unit @@ -1898,10 +1945,10 @@ While none prevents any message from being written to a DDSI2 log file. The categorisation of tracing output is incomplete and hence most of the verbosity levels and categories are not of much use in the current release. This is an ongoing process and here we describe the target situation rather than the current situation. Currently, the most useful verbosity levels are config, fine and finest. The default value is: `none` - + - - + + diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc index f1d4c36265..3ca7939d2f 100644 --- a/etc/cyclonedds.rnc +++ b/etc/cyclonedds.rnc @@ -334,6 +334,36 @@ CycloneDDS configuration""" ] ] attribute priority { text }? + & [ a:documentation [ xml:lang="en" """ +

A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics.

""" ] ] + element forbiddenTopics { + [ a:documentation [ xml:lang="en" """ +

A pattern (with ? and * wildcards) that is matched against topics.

+

The default value is: <empty>

""" ] ] + element Pattern { + [ a:documentation [ xml:lang="en" """ + +

The default value is: <empty>

""" ] ] + attribute value { + text + } + }* + }? + & [ a:documentation [ xml:lang="en" """ +

A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics.

""" ] ] + element onlyForTopics { + [ a:documentation [ xml:lang="en" """ +

A pattern (with ? and * wildcards) that is matched against topics.

+

The default value is: <empty>

""" ] ] + element Pattern { + [ a:documentation [ xml:lang="en" """ + +

The default value is: <empty>

""" ] ] + attribute value { + text + } + }* + }? }* }? & [ a:documentation [ xml:lang="en" """ @@ -1313,10 +1343,10 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==
duration_inf = xsd:token { pattern = "inf|0|(\d+(\.\d*)?([Ee][\-+]?\d+)?|\.\d+([Ee][\-+]?\d+)?) *([num]?s|min|hr|day)" } memsize = xsd:token { pattern = "0|(\d+(\.\d*)?([Ee][\-+]?\d+)?|\.\d+([Ee][\-+]?\d+)?) *([kMG]i?)?B" } } -# generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f] +# generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c] # generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] -# generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1] -# generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b] +# generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] +# generated from ddsi_config.c[6fa39d18f6f0d241b7592a0dc23741e2a934ff2e] # generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] # generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] # generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd index c314d2fdb2..f927c0524d 100644 --- a/etc/cyclonedds.xsd +++ b/etc/cyclonedds.xsd @@ -498,6 +498,10 @@ CycloneDDS configuration <p>This element defines a PSMX.</p> + + + + @@ -528,6 +532,44 @@ CycloneDDS configuration + + + +<p>A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics. </p> + + + + + + + + + + +<p>A pattern (with ? and * wildcards) that is matched against topics. </p> +<p>The default value is: <code>&lt;empty&gt;</code></p> + + + + + + +<p>The default value is: <code>&lt;empty&gt;</code></p> + + + + + + + +<p>A list of topics that should never use this psmx. Mutually exclusive with onlyForTopics. </p> + + + + + + + @@ -1971,10 +2013,10 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==<br> - + - - + + diff --git a/src/core/ddsc/include/dds/ddsc/dds_psmx.h b/src/core/ddsc/include/dds/ddsc/dds_psmx.h index 2ccf4e87d9..18ecd1dc85 100644 --- a/src/core/ddsc/include/dds/ddsc/dds_psmx.h +++ b/src/core/ddsc/include/dds/ddsc/dds_psmx.h @@ -260,6 +260,8 @@ typedef struct dds_psmx { dds_psmx_ops_t ops; //!< associated functions const char *instance_name; //!< name of this PSMX instance int32_t priority; //!< priority of choosing this interface + char ** only_for_topics; //!< See ddsi_config_psmx. Format is nullptr-terminated array of separately allocated char* + char ** forbidden_topics; //!< See ddsi_config_psmx. Format is nullptr-terminated array of separately allocated char* const struct ddsi_locator *locator; //!< the locator for this PSMX instance dds_psmx_instance_id_t instance_id; //!< the identifier of this PSMX instance struct dds_psmx_topic_list_elem *psmx_topics; //!< associated topics diff --git a/src/core/ddsc/src/dds_psmx.c b/src/core/ddsc/src/dds_psmx.c index d382c1524d..e48dab5042 100644 --- a/src/core/ddsc/src/dds_psmx.c +++ b/src/core/ddsc/src/dds_psmx.c @@ -11,6 +11,7 @@ #include #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/string.h" #include "dds/ddsrt/dynlib.h" #include "dds/ddsrt/mh3.h" #include "dds/ddsrt/io.h" @@ -27,6 +28,8 @@ static struct dds_psmx_endpoint * psmx_create_endpoint (struct dds_psmx_topic *psmx_topic, const struct dds_qos *qos, dds_psmx_endpoint_type_t endpoint_type); static dds_return_t psmx_delete_endpoint (struct dds_psmx_endpoint *psmx_endpoint); +void deep_cleanup_topic_array(char **topic_array); + dds_return_t dds_add_psmx_topic_to_list (struct dds_psmx_topic *psmx_topic, struct dds_psmx_topic_list_elem **list) { if (!psmx_topic) @@ -84,6 +87,14 @@ dds_return_t dds_remove_psmx_topic_from_list (struct dds_psmx_topic *psmx_topic, return ret; } +// Free all members of a nullptr-terminated array of separately allocated char pointers +void deep_cleanup_topic_array(char **topic_array) { + for (char * topic = *topic_array; topic; topic++) { + ddsrt_free((void*)topic); + } + ddsrt_free((void*)topic_array); +} + dds_return_t dds_add_psmx_endpoint_to_list (struct dds_psmx_endpoint *psmx_endpoint, struct dds_psmx_endpoint_list_elem **list) { if (!psmx_endpoint) @@ -164,6 +175,12 @@ dds_return_t dds_psmx_cleanup_generic (struct dds_psmx *psmx) dds_free ((void *) psmx->instance_name); dds_free ((void *) psmx->locator); + deep_cleanup_topic_array(psmx->only_for_topics); + psmx->only_for_topics = NULL; + + deep_cleanup_topic_array(psmx->forbidden_topics); + psmx->forbidden_topics = NULL; + while (ret == DDS_RETCODE_OK && psmx->psmx_topics) ret = dds_remove_psmx_topic_from_list (psmx->psmx_topics->topic, &psmx->psmx_topics); @@ -313,11 +330,67 @@ static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, const st goto err_init; } psmx_instance->priority = config->priority.value; + + if (config->only_for_topics && config->forbidden_topics) { + ret = DDS_RETCODE_UNSUPPORTED; + GVERROR ("Failed to initialize PSMX instance '%s': conflicting options only_for_topics and forbidden_topics were both present", + config->name); + goto err_init; + } + + // Copy over either the only_for_topics or the forbidden_topics list, switching to nullptr-terminated array of separately-allocated strings + struct ddsi_config_topic_pattern_listelem * pattern_list; + char *** pattern_array_ptr; + + if (config->only_for_topics) { + pattern_list = config->only_for_topics; + pattern_array_ptr = &psmx_instance->only_for_topics; + psmx_instance->forbidden_topics = ddsrt_calloc_s(1, sizeof(char*)); + } else if (config->forbidden_topics) { + pattern_list = config->forbidden_topics; + pattern_array_ptr = &psmx_instance->forbidden_topics; + psmx_instance->only_for_topics = ddsrt_calloc_s(1, sizeof(char*)); + } + + size_t list_size = 0; + for (struct ddsi_config_topic_pattern_listelem * elem = pattern_list; + elem; + elem = elem->next) { + list_size++; + } + + + // Allocate +1 for the final nullptr terminator + *pattern_array_ptr = ddsrt_calloc_s(list_size + 1, sizeof(char*)); + if (!*pattern_array_ptr) { + GVERROR ("Failed to initialize PSMX instance '%s': out of memory", + config->name); + goto err_init; + } + + + const struct ddsi_config_topic_pattern_listelem * elem = pattern_list; + for (int i = 0; elem; i++, elem = elem->next) { + (*pattern_array_ptr)[i] = ddsrt_strdup(elem->pattern); + if ((*pattern_array_ptr)[i] == NULL) { + GVERROR ("Failed to initialize PSMX instance '%s': out of memory", + config->name); + goto err_topic_arrays_oom; + } + } + *out = psmx_instance; *lib_handle = handle; ddsrt_free (configstr); return DDS_RETCODE_OK; +err_topic_arrays_oom: + if (psmx_instance->only_for_topics) { + deep_cleanup_topic_array(psmx_instance->only_for_topics); + } + if (psmx_instance->forbidden_topics) { + deep_cleanup_topic_array(psmx_instance->forbidden_topics); + } err_init: err_dlsym: ddsrt_dlclose (handle); diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c index 3165b62f06..f3cda67667 100644 --- a/src/core/ddsc/src/dds_topic.c +++ b/src/core/ddsc/src/dds_topic.c @@ -28,6 +28,7 @@ #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_endpoint.h" #include "dds/ddsi/ddsi_entity_index.h" +#include "dds/ddsi/ddsi_misc.h" #include "dds/ddsi/ddsi_thread.h" #include "dds/ddsi/ddsi_sertype.h" #include "dds/ddsi/ddsi_iid.h" @@ -583,6 +584,31 @@ dds_entity_t dds_create_topic_impl ( struct dds_psmx *psmx = dom->psmx_instances.instances[i]; if (!psmx->ops.type_qos_supported (psmx, DDS_PSMX_ENDPOINT_TYPE_UNSET, sertype_registered->data_type_props, new_qos)) continue; + + // Check if the topic is in the forbiddenTopics or NOT in the onlyForTopics list, depending + // on which one is used. + // First off, topics not mentioned are allowed iff only_for_topics is unused + bool allowed_by_config = psmx->only_for_topics[0] == NULL; + // Then any topic in only_for_topics is allowed + for (char **pattern = psmx->only_for_topics; *pattern; pattern++) { + printf("Matching %s against pattern %s\n", ktp->name, *pattern); + if (ddsi_patmatch(*pattern, ktp->name)) { + allowed_by_config = true; + break; + } + } + // And any topic in forbidden_topics is forbidden + for (char **pattern = psmx->forbidden_topics; *pattern; pattern++) { + if (ddsi_patmatch(*pattern, ktp->name)) { + allowed_by_config = false; + break; + } + } + + if (!allowed_by_config) { + continue; + } + struct dds_psmx_topic *psmx_topic = psmx->ops.create_topic (psmx, ktp->name, sertype_registered->type_name, sertype_registered->data_type_props); if (psmx_topic == NULL) { diff --git a/src/core/ddsc/tests/config.c b/src/core/ddsc/tests/config.c index 33d45bfc3f..f10831291e 100644 --- a/src/core/ddsc/tests/config.c +++ b/src/core/ddsc/tests/config.c @@ -18,6 +18,7 @@ #include "dds/ddsrt/cdtors.h" #include "dds/ddsrt/environ.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsi/ddsi_misc.h" #include "ddsi__misc.h" #include "dds/ddsi/ddsi_xqos.h" diff --git a/src/core/ddsc/tests/redundantnw.c b/src/core/ddsc/tests/redundantnw.c index b7e8400d75..25c54b3b57 100644 --- a/src/core/ddsc/tests/redundantnw.c +++ b/src/core/ddsc/tests/redundantnw.c @@ -19,6 +19,7 @@ #include "dds/ddsrt/io.h" #include "dds/ddsrt/misc.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsi/ddsi_misc.h" #include "dds__entity.h" #include "ddsi__addrset.h" diff --git a/src/core/ddsi/CMakeLists.txt b/src/core/ddsi/CMakeLists.txt index 685594b693..61bbd66d30 100644 --- a/src/core/ddsi/CMakeLists.txt +++ b/src/core/ddsi/CMakeLists.txt @@ -139,6 +139,7 @@ set(hdrs_ddsi ddsi_xevent.h ddsi_xmsg.h ddsi_psmx.h + ddsi_misc.h ) set(hdrs_private_ddsi diff --git a/src/core/ddsi/defconfig.c b/src/core/ddsi/defconfig.c index b84a164347..f374f380ad 100644 --- a/src/core/ddsi/defconfig.c +++ b/src/core/ddsi/defconfig.c @@ -99,10 +99,10 @@ void ddsi_config_init_default (struct ddsi_config *cfg) cfg->ssl_min_version.minor = 3; #endif /* DDS_HAS_TCP_TLS */ } -/* generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f] */ +/* generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c] */ /* generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] */ -/* generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1] */ -/* generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b] */ +/* generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] */ +/* generated from ddsi_config.c[6fa39d18f6f0d241b7592a0dc23741e2a934ff2e] */ /* generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] */ /* generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] */ /* generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] */ diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_config.h b/src/core/ddsi/include/dds/ddsi/ddsi_config.h index 0abc6fe808..0aa2518828 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_config.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_config.h @@ -237,11 +237,18 @@ enum ddsi_config_entity_naming_mode { DDSI_ENTITY_NAMING_DEFAULT_FANCY }; +struct ddsi_config_topic_pattern_listelem { + struct ddsi_config_topic_pattern_listelem *next; + const char *pattern; +}; + struct ddsi_config_psmx { char *name; char *library; char *config; struct ddsi_config_maybe_int32 priority; + struct ddsi_config_topic_pattern_listelem *forbidden_topics; + struct ddsi_config_topic_pattern_listelem *only_for_topics; }; struct ddsi_config_psmx_listelem { diff --git a/src/core/ddsi/src/ddsi__cfgelems.h b/src/core/ddsi/src/ddsi__cfgelems.h index 2b17969bb6..696544267e 100644 --- a/src/core/ddsi/src/ddsi__cfgelems.h +++ b/src/core/ddsi/src/ddsi__cfgelems.h @@ -106,6 +106,34 @@ static struct cfgelem network_interface_attributes[] = { END_MARKER }; +static struct cfgelem topic_pattern_cfgattr[] = { + STRING("value", NULL, 1, NULL, + MEMBEROF(ddsi_config_topic_pattern_listelem, pattern), + FUNCTIONS(0, uf_string, ff_free, pf_string), + DESCRIPTION("")), + END_MARKER +}; + +static struct cfgelem only_for_topics_cfgelem[] = { + STRING("Pattern", topic_pattern_cfgattr, INT_MAX, NULL, + MEMBEROF(ddsi_config_psmx_listelem, cfg.only_for_topics), + FUNCTIONS(if_topic_pattern_list, 0, 0, 0), + DESCRIPTION( + "

A pattern (with ? and * wildcards) that is matched against topics.

" + )), + END_MARKER +}; + +static struct cfgelem forbidden_topics_cfgelem[] = { + STRING("Pattern", topic_pattern_cfgattr, INT_MAX, NULL, + MEMBEROF(ddsi_config_psmx_listelem, cfg.forbidden_topics), + FUNCTIONS(if_topic_pattern_list, 0, 0, 0), + DESCRIPTION( + "

A pattern (with ? and * wildcards) that is matched against topics.

" + )), + END_MARKER +}; + static struct cfgelem psmx_attributes[] = { STRING("name", NULL, 1, "", MEMBEROF(ddsi_config_psmx_listelem, cfg.name), @@ -137,6 +165,24 @@ static struct cfgelem psmx_attributes[] = { END_MARKER }; +static struct cfgelem psmx_cfgelems[] = { + GROUP("forbiddenTopics", forbidden_topics_cfgelem, NULL, 1, + NOMEMBER, + NOFUNCTIONS, + DESCRIPTION( + "

A list of topics that should never use this psmx. " + "Mutually exclusive with onlyForTopics.

" + )), + GROUP("onlyForTopics", only_for_topics_cfgelem, NULL, 1, + NOMEMBER, + NOFUNCTIONS, + DESCRIPTION( + "

A list of topics that should never use this psmx. " + "Mutually exclusive with onlyForTopics.

" + )), + END_MARKER +}; + static struct cfgelem interfaces_cfgelems[] = { GROUP("NetworkInterface", NULL, network_interface_attributes, INT_MAX, MEMBER(network_interfaces), @@ -146,7 +192,7 @@ static struct cfgelem interfaces_cfgelems[] = { "to autoselect the interface CycloneDDS considers the highest quality. If " "autodetermine=\"false\" (the default), you must specify the name and/or address " "attribute. If you specify both, they must match the same interface.

")), - GROUP("PubSubMessageExchange", NULL, psmx_attributes, INT_MAX, + GROUP("PubSubMessageExchange", psmx_cfgelems, psmx_attributes, INT_MAX, MEMBER(psmx_instances), FUNCTIONS(if_psmx, 0, 0, 0), DESCRIPTION( diff --git a/src/core/ddsi/src/ddsi__misc.h b/src/core/ddsi/src/ddsi__misc.h index e940865f47..1498ef82a7 100644 --- a/src/core/ddsi/src/ddsi__misc.h +++ b/src/core/ddsi/src/ddsi__misc.h @@ -65,9 +65,6 @@ int ddsi_guid_prefix_eq (const ddsi_guid_prefix_t *a, const ddsi_guid_prefix_t * /** @component misc */ int ddsi_guid_eq (const struct ddsi_guid *a, const struct ddsi_guid *b); -/** @component misc */ -int ddsi_patmatch (const char *pat, const char *str); - #if defined (__cplusplus) } #endif diff --git a/src/core/ddsi/src/ddsi_config.c b/src/core/ddsi/src/ddsi_config.c index 4db60cf602..b6983127b3 100644 --- a/src/core/ddsi/src/ddsi_config.c +++ b/src/core/ddsi/src/ddsi_config.c @@ -52,6 +52,11 @@ typedef enum update_result (*update_fun_t) (struct ddsi_cfgst *cfgst, void *pare typedef void (*free_fun_t) (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem); typedef void (*print_fun_t) (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources); +// Split the given string at commas. Returns a freshly allocated char* array pointing to the +// split words and returns the number of words found in *nwords. The pointed-to strings are +// contained in the returned allocation, so a single `free` on the return value frees everything +static char **split_at_comma (const char *str, size_t *nwords); + struct unit { const char *name; int64_t multiplier; @@ -214,6 +219,7 @@ DI(if_thread_properties); #ifdef DDS_HAS_SECURITY DI(if_omg_security); #endif +DI(if_topic_pattern_list); #undef DI /* drop extra information, i.e. DESCRIPTION, RANGE, UNIT and VALUES */ @@ -661,7 +667,6 @@ static int if_thread_properties (struct ddsi_cfgst *cfgst, void *parent, struct struct ddsi_config_thread_properties_listelem *new = if_common (cfgst, parent, cfgelem, sizeof(*new)); if (new == NULL) return -1; - new->name = NULL; return 0; } @@ -670,8 +675,6 @@ static int if_network_interfaces(struct ddsi_cfgst *cfgst, void *parent, struct struct ddsi_config_network_interface_listelem *new = if_common (cfgst, parent, cfgelem, sizeof(*new)); if (new == NULL) return -1; - new->cfg.name = NULL; - new->cfg.address = NULL; return 0; } @@ -680,9 +683,6 @@ static int if_psmx(struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const struct ddsi_config_psmx_listelem *new = if_common (cfgst, parent, cfgelem, sizeof(*new)); if (new == NULL) return -1; - new->cfg.name = NULL; - new->cfg.library = NULL; - new->cfg.config = NULL; return 0; } @@ -692,14 +692,6 @@ static int if_network_partition (struct ddsi_cfgst *cfgst, void *parent, struct struct ddsi_config_networkpartition_listelem *new = if_common (cfgst, parent, cfgelem, sizeof(*new)); if (new == NULL) return -1; - new->address_string = NULL; - new->interface_names = NULL; - new->uc_addresses = NULL; - new->asm_addresses = NULL; -#ifdef DDSRT_HAVE_SSM - new->ssm_addresses = NULL; -#endif - new->name = NULL; return 0; } @@ -708,7 +700,6 @@ static int if_ignored_partition (struct ddsi_cfgst *cfgst, void *parent, struct struct ddsi_config_ignoredpartition_listelem *new = if_common (cfgst, parent, cfgelem, sizeof(*new)); if (new == NULL) return -1; - new->DCPSPartitionTopic = NULL; return 0; } @@ -717,9 +708,6 @@ static int if_partition_mapping (struct ddsi_cfgst *cfgst, void *parent, struct struct ddsi_config_partitionmapping_listelem *new = if_common (cfgst, parent, cfgelem, sizeof(*new)); if (new == NULL) return -1; - new->DCPSPartitionTopic = NULL; - new->networkPartition = NULL; - new->partition = NULL; return 0; } #endif /* DDS_HAS_NETWORK_PARTITIONS */ @@ -729,7 +717,6 @@ static int if_peer (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const struct ddsi_config_peer_listelem *new = if_common (cfgst, parent, cfgelem, sizeof (*new)); if (new == NULL) return -1; - new->peer = NULL; return 0; } @@ -739,7 +726,6 @@ static int if_omg_security (struct ddsi_cfgst *cfgst, void *parent, struct cfgel struct ddsi_config_omg_security_listelem *new = if_common (cfgst, parent, cfgelem, sizeof (*new)); if (new == NULL) return -1; - memset(&new->cfg, 0, sizeof(new->cfg)); return 0; } #endif @@ -1279,6 +1265,13 @@ static void ff_networkAddresses (struct ddsi_cfgst *cfgst, void *parent, struct ddsrt_free (*elem); } +static int if_topic_pattern_list(struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem) { + struct ddsi_config_topic_pattern_listelem * new = if_common (cfgst, parent, cfgelem, sizeof(*new)); + if (new == NULL) + return -1; + return 0; +} + #ifdef DDSRT_HAVE_SSM static const char *allow_multicast_names[] = { "false", "spdp", "asm", "ssm", "true", NULL }; static const uint32_t allow_multicast_codes[] = { DDSI_AMC_FALSE, DDSI_AMC_SPDP, DDSI_AMC_ASM, DDSI_AMC_SSM, DDSI_AMC_TRUE }; diff --git a/src/core/ddsi/src/ddsi_misc.c b/src/core/ddsi/src/ddsi_misc.c index fd8b71cc89..1d228a82b1 100644 --- a/src/core/ddsi/src/ddsi_misc.c +++ b/src/core/ddsi/src/ddsi_misc.c @@ -13,6 +13,7 @@ #include "dds/ddsrt/md5.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsi/ddsi_misc.h" #include "ddsi__misc.h" extern inline ddsi_seqno_t ddsi_from_seqno (const ddsi_sequence_number_t sn); diff --git a/src/core/ddsi/src/ddsi_qosmatch.c b/src/core/ddsi/src/ddsi_qosmatch.c index ed3ee4e442..d756233374 100644 --- a/src/core/ddsi/src/ddsi_qosmatch.c +++ b/src/core/ddsi/src/ddsi_qosmatch.c @@ -16,6 +16,7 @@ #include "dds/ddsi/ddsi_domaingv.h" #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_qosmatch.h" +#include "dds/ddsi/ddsi_misc.h" #include "ddsi__typelookup.h" #include "ddsi__misc.h" #include "ddsi__typelib.h" diff --git a/src/security/core/tests/config.c b/src/security/core/tests/config.c index 0f763a04cd..9b24600120 100644 --- a/src/security/core/tests/config.c +++ b/src/security/core/tests/config.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/environ.h" #include "dds/ddsrt/heap.h" #include "dds/ddsi/ddsi_xqos.h" +#include "dds/ddsi/ddsi_misc.h" #include "ddsi__misc.h" #include "dds/security/dds_security_api_defs.h" #include "common/config_env.h" diff --git a/src/security/core/tests/plugin_loading.c b/src/security/core/tests/plugin_loading.c index 266eb00593..8a1fbbdae5 100644 --- a/src/security/core/tests/plugin_loading.c +++ b/src/security/core/tests/plugin_loading.c @@ -14,6 +14,7 @@ #include "dds/ddsrt/cdtors.h" #include "dds/ddsrt/environ.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsi/ddsi_misc.h" #include "ddsi__misc.h" #include "dds/security/dds_security_api_defs.h" #include "common/config_env.h"