From 1024475cfd3da3180f9d033a87880cece3f72531 Mon Sep 17 00:00:00 2001 From: Tobias Stark Date: Wed, 19 Jun 2024 13:56:42 +0000 Subject: [PATCH] Change config format of topic allow/denylists to XML elements --- docs/manual/config/config_file_reference.rst | 101 ++++++++++++++----- docs/manual/options.md | 65 ++++++++---- etc/cyclonedds.rnc | 52 ++++++---- etc/cyclonedds.xsd | 64 ++++++++---- src/core/ddsc/src/dds_psmx.c | 36 +++---- src/core/ddsi/defconfig.c | 10 +- src/core/ddsi/include/dds/ddsi/ddsi_config.h | 14 +-- src/core/ddsi/src/ddsi__cfgelems.h | 55 +++++++--- src/core/ddsi/src/ddsi_config.c | 41 +------- src/tools/_confgen/_confgen.h | 1 - src/tools/_confgen/generate_defconfig.c | 12 --- 11 files changed, 280 insertions(+), 171 deletions(-) diff --git a/docs/manual/config/config_file_reference.rst b/docs/manual/config/config_file_reference.rst index 199709a2a8..797058b7b9 100644 --- a/docs/manual/config/config_file_reference.rst +++ b/docs/manual/config/config_file_reference.rst @@ -654,7 +654,8 @@ The default value is: ``default`` //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Attributes: :ref:`config`, :ref:`forbiddenTopics`, :ref:`library`, :ref:`name`, :ref:`onlyForTopics`, :ref:`priority` +Attributes: :ref:`config`, :ref:`library`, :ref:`name`, :ref:`priority` +Children: :ref:`forbiddenTopics`, :ref:`onlyForTopics` This element defines a PSMX. @@ -671,18 +672,6 @@ This attribute specifies any configuration data for the PSMX instance.This has n The default value is: ```` -.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics]`: - -//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics] -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Text - -A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics. - -The default value is: ```` - - .. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library]`: //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library] @@ -707,28 +696,86 @@ This attribute specifies the name of the interface. The default value is: ```` -.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@onlyForTopics]`: +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority]`: -//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@onlyForTopics] -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority] +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Text -A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics. +This attribute specifies the interface priority (decimal integer or default). The default value for a PSMX is 0. + +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[@priority]`: +.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value]`: -//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority] -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] +____________________________________________________________________________________________ Text -This attribute specifies the interface priority (decimal integer or default). The default value for a PSMX is 0. -The default value is: ``default`` +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`: @@ -2728,14 +2775,14 @@ The categorisation of tracing output is incomplete and hence most of the verbosi The default value is: ``none`` .. - generated from ddsi_config.h[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d] + generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71] generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] - generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8] - generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2] - generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab] + generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] + generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d] + generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01] generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4] generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0] - generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae] + generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830] diff --git a/docs/manual/options.md b/docs/manual/options.md index b8ef648685..03a94d3e13 100644 --- a/docs/manual/options.md +++ b/docs/manual/options.md @@ -437,7 +437,8 @@ The default value is: `default` ##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange -Attributes: [config](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeconfig), [forbiddenTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopics), [library](#cycloneddsdomaingeneralinterfacespubsubmessageexchangelibrary), [name](#cycloneddsdomaingeneralinterfacespubsubmessageexchangename), [onlyForTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeonlyfortopics), [priority](#cycloneddsdomaingeneralinterfacespubsubmessageexchangepriority) +Attributes: [config](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeconfig), [library](#cycloneddsdomaingeneralinterfacespubsubmessageexchangelibrary), [name](#cycloneddsdomaingeneralinterfacespubsubmessageexchangename), [priority](#cycloneddsdomaingeneralinterfacespubsubmessageexchangepriority) +Children: [forbiddenTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopics), [onlyForTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeonlyfortopics) This element defines a PSMX. @@ -450,44 +451,74 @@ This attribute specifies any configuration data for the PSMX instance.This has n The default value is: `` -##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics] +##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library] Text -A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics. +This attribute specifies the filename of the interface library. The default value is: `` -##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library] +##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@name] Text -This attribute specifies the filename of the interface library. +This attribute specifies the name of the interface. The default value is: `` -##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@name] +##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority] Text -This attribute specifies the name of the interface. +This attribute specifies the interface priority (decimal integer or default). The default value for a PSMX is 0. + +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[@onlyForTopics] +####### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] Text -A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics. The default value is: `` -##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority] +###### //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 -This attribute specifies the interface priority (decimal integer or default). The default value for a PSMX is 0. +A pattern (with ? and \* wildcards) that is matched against topics. -The default value is: `default` +The default value is: `` + + +####### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange/forbiddenTopics/Pattern[@value] +Text + + +The default value is: `` #### //CycloneDDS/Domain/General/MaxMessageSize @@ -1914,14 +1945,14 @@ 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 6209957a25..44f6a20acb 100644 --- a/etc/cyclonedds.rnc +++ b/etc/cyclonedds.rnc @@ -317,12 +317,6 @@ CycloneDDS configuration""" ] ] text }? & [ a:documentation [ xml:lang="en" """ -

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

-

The default value is: <empty>

""" ] ] - attribute forbiddenTopics { - text - }? - & [ a:documentation [ xml:lang="en" """

This attribute specifies the filename of the interface library.

The default value is: <empty>

""" ] ] attribute library { @@ -335,17 +329,41 @@ CycloneDDS configuration""" ] ] text }? & [ a:documentation [ xml:lang="en" """ -

A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics.

-

The default value is: <empty>

""" ] ] - attribute onlyForTopics { - text - }? - & [ a:documentation [ xml:lang="en" """

This attribute specifies the interface priority (decimal integer or default). The default value for a PSMX is 0.

The default value is: default

""" ] ] 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" """ @@ -1325,14 +1343,14 @@ 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[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d] +# generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71] # generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] -# generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8] -# generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2] -# generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab] +# generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] +# generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d] +# generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] # generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] # generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] # generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01] # generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4] # generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0] -# generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae] +# generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830] diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd index 2a8077fb62..2d810743f7 100644 --- a/etc/cyclonedds.xsd +++ b/etc/cyclonedds.xsd @@ -498,17 +498,14 @@ CycloneDDS configuration <p>This element defines a PSMX.</p> + + + + <p>This attribute specifies any configuration data for the PSMX instance.This has no meaning in CycloneDDS itself, and its parsing is deferred to thePSMX implementation.</p> -<p>The default value is: <code>&lt;empty&gt;</code></p> - - - - - -<p>A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics.</p> <p>The default value is: <code>&lt;empty&gt;</code></p> @@ -526,22 +523,53 @@ CycloneDDS configuration <p>The default value is: <code>&lt;empty&gt;</code></p> - + -<p>A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics.</p> -<p>The default value is: <code>&lt;empty&gt;</code></p> +<p>This attribute specifies the interface priority (decimal integer or <i>default</i>). The default value for a PSMX is 0.</p> +<p>The default value is: <code>default</code></p> - + + + + + +<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>This attribute specifies the interface priority (decimal integer or <i>default</i>). The default value for a PSMX is 0.</p> -<p>The default value is: <code>default</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> + + + + + + + @@ -1985,14 +2013,14 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==<br> - + - - - + + + - + diff --git a/src/core/ddsc/src/dds_psmx.c b/src/core/ddsc/src/dds_psmx.c index 76e2412102..a9e8fd6424 100644 --- a/src/core/ddsc/src/dds_psmx.c +++ b/src/core/ddsc/src/dds_psmx.c @@ -331,36 +331,38 @@ static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, const st } psmx_instance->priority = config->priority.value; - if (config->only_for_topics.size > 0 && config->forbidden_topics.size > 0) { + 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 the only_for_topics and forbidden_topics array, switching to nullptr-terminated array of separately-allocated strings psmx_instance->only_for_topics = psmx_instance->forbidden_topics = NULL; + // 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 = config->only_for_topics ? config->only_for_topics : config->forbidden_topics; + char *** pattern_array_ptr = config->only_for_topics ? &psmx_instance->only_for_topics : &psmx_instance->forbidden_topics; + 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 - psmx_instance->only_for_topics = ddsrt_calloc_s(config->only_for_topics.size + 1, sizeof(char*)); - psmx_instance->forbidden_topics = ddsrt_calloc_s(config->forbidden_topics.size + 1, sizeof(char*)); - if (!psmx_instance->only_for_topics || !psmx_instance->forbidden_topics) { + *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_topic_arrays_oom; + goto err_init; } - for (size_t i = 0 ; i < config->only_for_topics.size; i++) { - psmx_instance->only_for_topics[i] = ddsrt_strdup(config->only_for_topics.topics[i]); - if (psmx_instance->only_for_topics[i] == NULL) { - GVERROR ("Failed to initialize PSMX instance '%s': out of memory", - config->name); - goto err_topic_arrays_oom; - } - } - for (size_t i = 0 ; i < config->forbidden_topics.size; i++) { - psmx_instance->forbidden_topics[i] = ddsrt_strdup(config->forbidden_topics.topics[i]); - if (psmx_instance->forbidden_topics[i] == NULL) { + + 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; diff --git a/src/core/ddsi/defconfig.c b/src/core/ddsi/defconfig.c index c6953d5947..89d88cd119 100644 --- a/src/core/ddsi/defconfig.c +++ b/src/core/ddsi/defconfig.c @@ -99,14 +99,14 @@ 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[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d] */ +/* generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71] */ /* generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] */ -/* generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8] */ -/* generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2] */ -/* generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab] */ +/* generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] */ +/* generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d] */ +/* generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] */ /* generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] */ /* generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] */ /* generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01] */ /* generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4] */ /* generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0] */ -/* generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae] */ +/* generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830] */ diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_config.h b/src/core/ddsi/include/dds/ddsi/ddsi_config.h index 890e6c5ce8..0aa2518828 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_config.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_config.h @@ -237,13 +237,9 @@ enum ddsi_config_entity_naming_mode { DDSI_ENTITY_NAMING_DEFAULT_FANCY }; -// The array is stored as size + pointer to pointer array. -// If size is zero, the pointer is NULL rather than a pointer to an empty array. -// The pointed-to strings are allocated right after the array, so -// a simple `free(topics)` frees everything -struct ddsi_config_topic_array { - size_t size; - char **topics; +struct ddsi_config_topic_pattern_listelem { + struct ddsi_config_topic_pattern_listelem *next; + const char *pattern; }; struct ddsi_config_psmx { @@ -251,8 +247,8 @@ struct ddsi_config_psmx { char *library; char *config; struct ddsi_config_maybe_int32 priority; - struct ddsi_config_topic_array forbidden_topics; - struct ddsi_config_topic_array only_for_topics; + 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 c93be2c109..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), @@ -134,20 +162,23 @@ static struct cfgelem psmx_attributes[] = { "This has no meaning in CycloneDDS itself, and its parsing is deferred to the" "PSMX implementation.

" )), - STRING("forbiddenTopics", NULL, 1, "", - MEMBEROF(ddsi_config_psmx_listelem, cfg.forbidden_topics), - FUNCTIONS(if_topic_array, uf_topic_array, ff_topic_array, pf_topic_array), + END_MARKER +}; + +static struct cfgelem psmx_cfgelems[] = { + GROUP("forbiddenTopics", forbidden_topics_cfgelem, NULL, 1, + NOMEMBER, + NOFUNCTIONS, DESCRIPTION( - "

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

" + "

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

" )), - STRING("onlyForTopics", NULL, 1, "", - MEMBEROF(ddsi_config_psmx_listelem, cfg.only_for_topics), - FUNCTIONS(if_topic_array, uf_topic_array, ff_topic_array, pf_topic_array), + GROUP("onlyForTopics", only_for_topics_cfgelem, NULL, 1, + NOMEMBER, + NOFUNCTIONS, DESCRIPTION( - "

A comma-separated list of all the topics that should use this PSMX." - "This option can be used to restrict the PSMX to a selected list of topics." - "Mutually exclusive with forbiddenTopics.

" + "

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

" )), END_MARKER }; @@ -161,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_config.c b/src/core/ddsi/src/ddsi_config.c index dd9a990906..4ad5084182 100644 --- a/src/core/ddsi/src/ddsi_config.c +++ b/src/core/ddsi/src/ddsi_config.c @@ -197,7 +197,6 @@ DU(deaf_mute); DUPF(min_tls_version); #endif DUPF(shm_loglevel); -DUPF(topic_array); #undef DUPF #undef DU #undef PF @@ -205,7 +204,6 @@ DUPF(topic_array); #define DF(fname) static void fname (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem) DF(ff_free); DF(ff_networkAddresses); -DF(ff_topic_array); #undef DF #define DI(fname) static int fname (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem) @@ -221,7 +219,7 @@ DI(if_thread_properties); #ifdef DDS_HAS_SECURITY DI(if_omg_security); #endif -DI(if_topic_array); +DI(if_topic_pattern_list); #undef DI /* drop extra information, i.e. DESCRIPTION, RANGE, UNIT and VALUES */ @@ -1285,42 +1283,13 @@ static void ff_networkAddresses (struct ddsi_cfgst *cfgst, void *parent, struct ddsrt_free (*elem); } -static int if_topic_array(struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem) { - struct ddsi_config_topic_array * elem = cfg_address (cfgst, parent, cfgelem); - elem->size = 0; - elem->topics = NULL; +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; } -static enum update_result uf_topic_array (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value) { - struct ddsi_config_topic_array * elem = cfg_address (cfgst, parent, cfgelem); - free(elem->topics); - if (*value == '\0') { - elem->size = 0; - elem->topics = NULL; - } else { - elem->topics = split_at_comma(value, &elem->size); - } - return URES_SUCCESS; -} - -static void ff_topic_array (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem) { - struct ddsi_config_topic_array * elem = cfg_address (cfgst, parent, cfgelem); - free(elem->topics); -} - -static void pf_topic_array (struct ddsi_cfgst *cfgst, UNUSED_ARG (void *parent), UNUSED_ARG (struct cfgelem const * const cfgelem), uint32_t sources) { - struct ddsi_config_topic_array * elem = cfg_address (cfgst, parent, cfgelem); - if (elem->size == 0) { - // Just passing "" produces a "zero-length format string" warning - cfg_logelem (cfgst, sources, "%s", ""); - } else { - for (size_t i = 0; i < elem->size; ++i) { - cfg_logelem (cfgst, sources, "%s", elem->topics[i]); - } - } -} - #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/tools/_confgen/_confgen.h b/src/tools/_confgen/_confgen.h index b404bacca1..cd64e8ae90 100644 --- a/src/tools/_confgen/_confgen.h +++ b/src/tools/_confgen/_confgen.h @@ -53,7 +53,6 @@ void gendef_pf_transport_selector (FILE *fp, void *parent, struct cfgelem const void gendef_pf_many_sockets_mode (FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_standards_conformance (FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_shm_loglevel (FILE *fp, void *parent, struct cfgelem const * const cfgelem); -void gendef_pf_topic_array (FILE *fp, void *parent, struct cfgelem const * const cfgelem); struct cfgunit { const char *name; diff --git a/src/tools/_confgen/generate_defconfig.c b/src/tools/_confgen/generate_defconfig.c index e96eca7c94..1122998307 100644 --- a/src/tools/_confgen/generate_defconfig.c +++ b/src/tools/_confgen/generate_defconfig.c @@ -193,18 +193,6 @@ void gendef_pf_standards_conformance (FILE *out, void *parent, struct cfgelem co void gendef_pf_shm_loglevel (FILE *out, void *parent, struct cfgelem const * const cfgelem) { gendef_pf_int (out, parent, cfgelem); } -void gendef_pf_topic_array (FILE *out, void *parent, struct cfgelem const * const cfgelem) { - struct ddsi_config_topic_array * elem = cfg_address (parent, cfgelem); - if (elem->size == 0) { - // The default zero-initialization does the right thing, nothing to do here - } else { - // Creating an initializer out of a dds_config_topic_array is a bit involved (we'd need to - // glue the topics back together with commas and also set up the allocation just like split_at_comma - // does it). At the same time, it's probably not useful. So restrict the gendef to empty arrays for now - // and implement this once it's actually needed. - fprintf(out, "#error \"Non-empty topic arrays not supported in default config\"\n"); - } -} static void gen_defaults (FILE *out, void *parent, struct cfgelem const * const cfgelem) {