diff --git a/include/villas/node.h b/include/villas/node.h
index 901bdafac..8c428084d 100644
--- a/include/villas/node.h
+++ b/include/villas/node.h
@@ -51,6 +51,8 @@
struct rtnl_cls;
#endif /* WITH_NETEM */
+#define REGEX_NODE_NAME "[a-z0-9_-]{3,32}"
+
/** The data structure for a node.
*
* Every entity which exchanges messages is represented by a node.
diff --git a/lib/node.cpp b/lib/node.cpp
index 82071c5b4..aec2f1465 100644
--- a/lib/node.cpp
+++ b/lib/node.cpp
@@ -20,6 +20,7 @@
* along with this program. If not, see .
*********************************************************************************/
+#include
#include
#include
#include
@@ -645,14 +646,9 @@ invalid2:
bool node_is_valid_name(const char *name)
{
- for (const char *p = name; *p; p++) {
- if (isalnum(*p) || (*p == '_') || (*p == '-'))
- continue;
+ std::regex re(REGEX_NODE_NAME);
- return false;
- }
-
- return true;
+ return std::regex_match(name, re);
}
bool node_is_enabled(const struct node *n)