1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

node: use regex to check node name

This commit is contained in:
Steffen Vogel 2020-08-25 20:24:46 +02:00
parent 2f29e30c33
commit b552fbe47f
2 changed files with 5 additions and 7 deletions

View file

@ -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.

View file

@ -20,6 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <regex>
#include <cstring>
#include <cctype>
#include <openssl/md5.h>
@ -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)