From fde312782346d2a7207baa120a843274c76b9e39 Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Fri, 21 Aug 2020 10:11:20 +0200
Subject: [PATCH] FlexRAN Agent reconfiguration: call
 flexran_agent_handle_apps()

---
 openair2/ENB_APP/flexran_agent_common.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c
index 7a7b4febd9..2df188635b 100644
--- a/openair2/ENB_APP/flexran_agent_common.c
+++ b/openair2/ENB_APP/flexran_agent_common.c
@@ -507,7 +507,23 @@ int flexran_agent_map_name_to_delegated_object(mid_t mod_id, const char *name,
 int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
   Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
   Protocol__FlexAgentReconfiguration *agent_reconfiguration_msg = input->agent_reconfiguration_msg;
-  apply_reconfiguration_policy(mod_id, agent_reconfiguration_msg->policy, strlen(agent_reconfiguration_msg->policy));
+  if (agent_reconfiguration_msg->policy) {
+    /* for compatibility: call old YAML configuration code, although we don't
+     * use it anymore */
+    apply_reconfiguration_policy(mod_id,
+                                 agent_reconfiguration_msg->policy,
+                                 strlen(agent_reconfiguration_msg->policy));
+  }
+  for (int i = 0; i < agent_reconfiguration_msg->n_systems; ++i) {
+    const Protocol__FlexAgentReconfigurationSystem *sys = agent_reconfiguration_msg->systems[i];
+    if (strcmp(sys->system, "app") == 0) {
+      flexran_agent_handle_apps(mod_id, sys->subsystems, sys->n_subsystems);
+    } else {
+      LOG_E(FLEXRAN_AGENT,
+            "unknown system name %s in flex_agent_reconfiguration message\n",
+            sys->system);
+    }
+  }
   *msg = NULL;
   return 0;
 }
-- 
2.26.2