aboutsummaryrefslogtreecommitdiffstats
path: root/src/server_register.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/server_register.c')
-rw-r--r--src/server_register.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/server_register.c b/src/server_register.c
index b1d87fd..b938ca4 100644
--- a/src/server_register.c
+++ b/src/server_register.c
@@ -10,6 +10,7 @@
#include "common.h"
#include "config.h"
+#include "nodes_config.h"
#include <open62541/client.h>
#include <open62541/client_config_default.h>
@@ -110,18 +111,36 @@ main (int argc, char **argv)
signal (SIGINT, _s_stop_handler);
signal (SIGTERM, _s_stop_handler);
- if (argc < 4 || argc > 5)
+ if (argc < 4 || argc > 6)
{
UA_LOG_FATAL (UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
"Usage: %s <server-config> <client-config> "
- "<discovery-url> [log-level]",
+ "<discovery-url> [nodes-config] [log-level]",
argv[0]);
return EXIT_FAILURE;
}
const char *discovery_endpoint = argv[3];
- const char *log_level_str = (argc == 5) ? argv[4] : "info";
+ /* Parse the optional [nodes-config] and [log-level] arguments.
+ When only one optional arg is given, disambiguate by checking
+ whether it is a valid log-level name. */
+ const char *nodes_config_path = NULL;
+ const char *log_level_str = "info";
+
+ if (argc == 6)
+ {
+ nodes_config_path = argv[4];
+ log_level_str = argv[5];
+ }
+ else if (argc == 5)
+ {
+ if (parse_log_level (argv[4]) >= 0)
+ log_level_str = argv[4];
+ else
+ nodes_config_path = argv[4];
+ }
+
int log_level = parse_log_level (log_level_str);
if (log_level < 0)
{
@@ -139,6 +158,7 @@ main (int argc, char **argv)
config client_cfg = { 0 };
security_config server_sec = { 0 };
security_config client_sec = { 0 };
+ nodes_config nodes_cfg = { 0 };
UA_Server *server = NULL;
if (config_load (argv[1], &server_cfg) != 0)
@@ -198,6 +218,18 @@ main (int argc, char **argv)
server_config->applicationDescription.applicationType
= UA_APPLICATIONTYPE_SERVER;
+ /* ── Load and create variable nodes (optional) ───────────── */
+
+ if (nodes_config_path)
+ {
+ if (nodes_config_load (nodes_config_path, &nodes_cfg) != 0)
+ goto cleanup;
+
+ if (nodes_cfg.count > 0 && nodes_config_add (server, &nodes_cfg) != 0)
+ UA_LOG_WARNING (UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
+ "Some nodes failed to initialize");
+ }
+
lds_client_params lds_params = {
.app_uri = client_app_uri,
.sec = client_sec,
@@ -250,6 +282,7 @@ main (int argc, char **argv)
cleanup:
if (server)
UA_Server_delete (server);
+ nodes_config_free (&nodes_cfg);
free_trust_store (client_sec.trust_paths, client_sec.trust_size);
free_trust_store (server_sec.trust_paths, server_sec.trust_size);
config_free (&client_cfg);