From f580f41f15c8d3e1d2478718dd7f3809bd8c7508 Mon Sep 17 00:00:00 2001
From: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
Date: Mon, 26 Feb 2024 11:15:51 +0100
Subject: [PATCH] node: add configPath member

we need the path of the config file in the nodes in case we want to
parse a separate sub-config with relative path names. This is required
for the fpga node type to parse the ips config file from Fpga::parse.

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
---
 include/villas/node.hpp | 2 ++
 lib/node.cpp            | 2 +-
 lib/super_node.cpp      | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/villas/node.hpp b/include/villas/node.hpp
index 4c54eee06..b6746b9c8 100644
--- a/include/villas/node.hpp
+++ b/include/villas/node.hpp
@@ -7,6 +7,7 @@
 
 #pragma once
 
+#include <filesystem>
 #include <fmt/ostream.h>
 #include <iostream>
 #include <jansson.h>
@@ -65,6 +66,7 @@ public:
   PathSourceList sources; // A list of path sources which reference this node.
   PathDestinationList
       destinations; // A list of path destinations which reference this node.
+  std::filesystem::path configPath;
 
 #ifdef __linux__
   int fwmark; // Socket mark for netem, routing and filtering
diff --git a/lib/node.cpp b/lib/node.cpp
index f55789fe0..a4d1a4f23 100644
--- a/lib/node.cpp
+++ b/lib/node.cpp
@@ -44,7 +44,7 @@ using namespace villas::utils;
 Node::Node(const uuid_t &id, const std::string &name)
     : logger(logging.get("node")), sequence_init(0), sequence(0),
       in(NodeDirection::Direction::IN, this),
-      out(NodeDirection::Direction::OUT, this),
+      out(NodeDirection::Direction::OUT, this), configPath(),
 #ifdef __linux__
       fwmark(-1),
 #endif // __linux__
diff --git a/lib/super_node.cpp b/lib/super_node.cpp
index 8cda7a3b3..921b015c5 100644
--- a/lib/super_node.cpp
+++ b/lib/super_node.cpp
@@ -147,6 +147,8 @@ void SuperNode::parse(json_t *root) {
       if (!n)
         throw MemoryAllocationError();
 
+      n->configPath = getConfigPath();
+
       ret = n->parse(json_node);
       if (ret) {
         auto config_id = fmt::format("node-config-node-{}", node_type);