Skip to content

Commit faa4b07

Browse files
Interpret only-for-topics/forbidden topics as patterns
1 parent 1024475 commit faa4b07

File tree

15 files changed

+32
-16
lines changed

15 files changed

+32
-16
lines changed

docs/manual/config/config_file_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ The categorisation of tracing output is incomplete and hence most of the verbosi
27752775
The default value is: ``none``
27762776

27772777
..
2778-
generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71]
2778+
generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c]
27792779
generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa]
27802780
generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129]
27812781
generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d]

docs/manual/options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ While none prevents any message from being written to a DDSI2 log file.
19451945
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.
19461946

19471947
The default value is: `none`
1948-
<!--- generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71] -->
1948+
<!--- generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c] -->
19491949
<!--- generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] -->
19501950
<!--- generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] -->
19511951
<!--- generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d] -->

etc/cyclonedds.rnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==<br>
13431343
duration_inf = xsd:token { pattern = "inf|0|(\d+(\.\d*)?([Ee][\-+]?\d+)?|\.\d+([Ee][\-+]?\d+)?) *([num]?s|min|hr|day)" }
13441344
memsize = xsd:token { pattern = "0|(\d+(\.\d*)?([Ee][\-+]?\d+)?|\.\d+([Ee][\-+]?\d+)?) *([kMG]i?)?B" }
13451345
}
1346-
# generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71]
1346+
# generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c]
13471347
# generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa]
13481348
# generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129]
13491349
# generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d]

etc/cyclonedds.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==&lt;br&gt;
20132013
</xs:restriction>
20142014
</xs:simpleType>
20152015
</xs:schema>
2016-
<!--- generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71] -->
2016+
<!--- generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c] -->
20172017
<!--- generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] -->
20182018
<!--- generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] -->
20192019
<!--- generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d] -->

src/core/ddsc/src/dds_psmx.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,20 @@ static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, const st
338338
goto err_init;
339339
}
340340

341-
psmx_instance->only_for_topics = psmx_instance->forbidden_topics = NULL;
342341
// Copy over either the only_for_topics or the forbidden_topics list, switching to nullptr-terminated array of separately-allocated strings
343-
struct ddsi_config_topic_pattern_listelem * pattern_list = config->only_for_topics ? config->only_for_topics : config->forbidden_topics;
344-
char *** pattern_array_ptr = config->only_for_topics ? &psmx_instance->only_for_topics : &psmx_instance->forbidden_topics;
342+
struct ddsi_config_topic_pattern_listelem * pattern_list;
343+
char *** pattern_array_ptr;
344+
345+
if (config->only_for_topics) {
346+
pattern_list = config->only_for_topics;
347+
pattern_array_ptr = &psmx_instance->only_for_topics;
348+
psmx_instance->forbidden_topics = ddsrt_calloc_s(1, sizeof(char*));
349+
} else if (config->forbidden_topics) {
350+
pattern_list = config->forbidden_topics;
351+
pattern_array_ptr = &psmx_instance->forbidden_topics;
352+
psmx_instance->only_for_topics = ddsrt_calloc_s(1, sizeof(char*));
353+
}
354+
345355
size_t list_size = 0;
346356
for (struct ddsi_config_topic_pattern_listelem * elem = pattern_list;
347357
elem;

src/core/ddsc/src/dds_topic.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "dds/ddsi/ddsi_entity.h"
2929
#include "dds/ddsi/ddsi_endpoint.h"
3030
#include "dds/ddsi/ddsi_entity_index.h"
31+
#include "dds/ddsi/ddsi_misc.h"
3132
#include "dds/ddsi/ddsi_thread.h"
3233
#include "dds/ddsi/ddsi_sertype.h"
3334
#include "dds/ddsi/ddsi_iid.h"
@@ -587,17 +588,18 @@ dds_entity_t dds_create_topic_impl (
587588
// Check if the topic is in the forbiddenTopics or NOT in the onlyForTopics list, depending
588589
// on which one is used.
589590
// First off, topics not mentioned are allowed iff only_for_topics is unused
590-
bool allowed_by_config = !psmx->only_for_topics[0];
591+
bool allowed_by_config = psmx->only_for_topics[0] == NULL;
591592
// Then any topic in only_for_topics is allowed
592-
for (char **topic = psmx->only_for_topics; *topic; topic++) {
593-
if (strcmp(ktp->name, *topic) == 0) {
593+
for (char **pattern = psmx->only_for_topics; *pattern; pattern++) {
594+
printf("Matching %s against pattern %s\n", ktp->name, *pattern);
595+
if (ddsi_patmatch(*pattern, ktp->name)) {
594596
allowed_by_config = true;
595597
break;
596598
}
597599
}
598600
// And any topic in forbidden_topics is forbidden
599-
for (char **topic = psmx->forbidden_topics; *topic; topic++) {
600-
if (strcmp(ktp->name, *topic) == 0) {
601+
for (char **pattern = psmx->forbidden_topics; *pattern; pattern++) {
602+
if (ddsi_patmatch(*pattern, ktp->name)) {
601603
allowed_by_config = false;
602604
break;
603605
}

src/core/ddsc/tests/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "dds/ddsrt/cdtors.h"
1919
#include "dds/ddsrt/environ.h"
2020
#include "dds/ddsrt/heap.h"
21+
#include "dds/ddsi/ddsi_misc.h"
2122
#include "ddsi__misc.h"
2223
#include "dds/ddsi/ddsi_xqos.h"
2324

src/core/ddsc/tests/redundantnw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "dds/ddsrt/io.h"
2020
#include "dds/ddsrt/misc.h"
2121
#include "dds/ddsrt/heap.h"
22+
#include "dds/ddsi/ddsi_misc.h"
2223

2324
#include "dds__entity.h"
2425
#include "ddsi__addrset.h"

src/core/ddsi/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ set(hdrs_ddsi
139139
ddsi_xevent.h
140140
ddsi_xmsg.h
141141
ddsi_psmx.h
142+
ddsi_misc.h
142143
)
143144

144145
set(hdrs_private_ddsi

src/core/ddsi/defconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void ddsi_config_init_default (struct ddsi_config *cfg)
9999
cfg->ssl_min_version.minor = 3;
100100
#endif /* DDS_HAS_TCP_TLS */
101101
}
102-
/* generated from ddsi_config.h[58d1dd144dc0e8f3c3ef331fd4472eec7f797c71] */
102+
/* generated from ddsi_config.h[9296f1e4eceda8b8514e7859c5584f1cda35412c] */
103103
/* generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] */
104104
/* generated from ddsi__cfgelems.h[714f801d2988b476694a198097d36169f7e5e129] */
105105
/* generated from ddsi_config.c[4a1074588af66b81f8fd45393cdecff2b5d55b4d] */

0 commit comments

Comments
 (0)