From 3a78d85f5ee621a860be73ad5a03ac2ff1e2a401 Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Mon, 23 Apr 2018 16:58:23 +0200
Subject: [PATCH] FlexRAN: Handle enb_config_reply reconfiguration message

---
 openair2/ENB_APP/flexran_agent_common.c  | 20 ++++++++++++++++++++
 openair2/ENB_APP/flexran_agent_common.h  |  7 +++++++
 openair2/ENB_APP/flexran_agent_handler.c |  2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c
index f1556deef2..1cbf411c65 100644
--- a/openair2/ENB_APP/flexran_agent_common.c
+++ b/openair2/ENB_APP/flexran_agent_common.c
@@ -1101,5 +1101,25 @@ int flexran_agent_destroy_rrc_measurement(Protocol__FlexranMessage *msg){
   return 0;
 }
 
+int flexran_agent_handle_enb_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg)
+{
+  Protocol__FlexranMessage *input = (Protocol__FlexranMessage *)params;
+  Protocol__FlexEnbConfigReply *enb_config = input->enb_config_reply_msg;
+
+  if (enb_config->n_cell_config == 0) {
+    LOG_W(FLEXRAN_AGENT,
+          "received enb_config_reply message does not contain a cell_config\n");
+    *msg = NULL;
+    return 0;
+  }
+
+  if (enb_config->n_cell_config > 1)
+    LOG_W(FLEXRAN_AGENT, "ignoring slice configs for other cell except cell 0\n");
+  if (enb_config->cell_config[0]->slice_config)
+    prepare_update_slice_config(mod_id, enb_config->cell_config[0]->slice_config);
 
+  /* could test for cell configs here and maybe reconfigure/soft-restart */
 
+  *msg = NULL;
+  return 0;
+}
diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h
index 057c5b9489..2738a2f3d3 100644
--- a/openair2/ENB_APP/flexran_agent_common.h
+++ b/openair2/ENB_APP/flexran_agent_common.h
@@ -167,4 +167,11 @@ void flexran_agent_send_update_stats(mid_t mod_id);
 err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, xid_t xid, stats_request_config_t *stats_req) ;
 err_code_t flexran_agent_disable_cont_stats_update(mid_t mod_id);
 
+/* Handle a received eNB config reply message as an "order" to reconfigure. It
+ * does not come as a reconfiguration message as this is a "structured"
+ * ProtoBuf message (as opposed to "unstructured" YAML). There is no destructor
+ * since we do not reply to this message (yet). Instead, the controller has to
+ * issue another eNB config request message. */
+int flexran_agent_handle_enb_config_reply(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg);
+
 #endif
diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c
index 66123fd71c..b3025bf769 100644
--- a/openair2/ENB_APP/flexran_agent_handler.c
+++ b/openair2/ENB_APP/flexran_agent_handler.c
@@ -46,7 +46,7 @@ flexran_agent_message_decoded_callback agent_messages_callback[][3] = {
   {0, 0, 0}, /*PROTOCOK__FLEXRAN_MESSAGE__MSG_SF_TRIGGER_MSG*/
   {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_UL_SR_INFO_MSG*/
   {flexran_agent_enb_config_reply, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_ENB_CONFIG_REQUEST_MSG*/
-  {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_ENB_CONFIG_REPLY_MSG*/
+  {flexran_agent_handle_enb_config_reply, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_ENB_CONFIG_REPLY_MSG*/
   {flexran_agent_ue_config_reply, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_CONFIG_REQUEST_MSG*/
   {0, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_UE_CONFIG_REPLY_MSG*/
   {flexran_agent_lc_config_reply, 0, 0}, /*PROTOCOL__FLEXRAN_MESSAGE__MSG_LC_CONFIG_REQUEST_MSG*/
-- 
GitLab