From fc911464dd370b146f0495e0f8370d8b887316d8 Mon Sep 17 00:00:00 2001
From: Chieh-Chun Chen <chenc80348@gmail.com>
Date: Fri, 4 Nov 2022 16:25:03 +0100
Subject: [PATCH] Update E2 agent for FlexRIC dev 3a427b40

---
 executables/agent_if/byte_array.h     |  1 +
 executables/agent_if/ie/kpm_data_ie.h | 23 +++++++++++++++++++----
 executables/nr-softmodem.c            |  2 +-
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/executables/agent_if/byte_array.h b/executables/agent_if/byte_array.h
index 18aca02dab..1d012a4bda 100644
--- a/executables/agent_if/byte_array.h
+++ b/executables/agent_if/byte_array.h
@@ -53,6 +53,7 @@ typedef struct {
   memcpy(ba.buf, octet.buf, octet.size);\
   ba.len = octet.size;
 
+
 byte_array_t copy_byte_array(byte_array_t src);
 
 void free_byte_array(byte_array_t ba);
diff --git a/executables/agent_if/ie/kpm_data_ie.h b/executables/agent_if/ie/kpm_data_ie.h
index 746368c072..1b97cb3d74 100644
--- a/executables/agent_if/ie/kpm_data_ie.h
+++ b/executables/agent_if/ie/kpm_data_ie.h
@@ -109,8 +109,14 @@ typedef struct adapter_LabelInfoItem_t {
 void free_label_info(adapter_LabelInfoItem_t *l);
 void cp_label_info(adapter_LabelInfoItem_t *dst, adapter_LabelInfoItem_t const *src);
 
+typedef enum {
+    KPM_V2_MEASUREMENT_TYPE_NAME = 1, 
+    KPM_V2_MEASUREMENT_TYPE_ID = 2
+  }	meas_type_e;
+
+
 typedef struct MeasInfo_t {
-  enum {MeasurementType_NAME = 1, MeasurementType_ID=2}	measType;
+	meas_type_e meas_type;
   adapter_MeasurementTypeName_t	 measName;
 	adapter_MeasurementTypeID_t	   measID; 
 	adapter_LabelInfoItem_t	         *labelInfo;   // list implemented as array having a maximum of 'maxnoofLabelInfo' items
@@ -124,6 +130,14 @@ typedef struct kpm_event_trigger_t {
   unsigned long ms; // reporting period in milliseconds
 } kpm_event_trigger_t;
 
+
+
+typedef enum { 
+  KPMV2_CELL_ID_CHOICE_NOTHING = 0, 
+  KPMV2_CELL_ID_CHOICE_NR_CGI, 
+  KPMV2_CELL_ID_CHOICE_EUTRA_CGI 
+} cell_global_id_t;
+
 /*******************************************************
  * SEC 2. RIC Action Definition as per $8.2.1.2
  *******************************************************/
@@ -153,12 +167,13 @@ typedef struct kpm_action_def_t
   MeasInfo_t                    *MeasInfo;    
   
   // If cellGlobalIDtype == choice_NOTHING, the field 'cellGlobalID' in asn format will be NULL
-  enum { choice_NOTHING, choice_nR_CGI, choice_eUTRA_CGI } cellGlobalIDtype; 
-  
+  cell_global_id_t cell_global_id;
+
   adapter_NRCellIdentity_t      nRCellIdentity;
   adapter_PLMNIdentity_t	      pLMNIdentity;
 	adapter_EUTRACellIdentity_t   eUTRACellIdentity;
 
+
   /* 
    * XXX-extensions: below add all the info you might find in all the actions types . 
    * Still missing some fields for action_def_2, action_def_3, action_def_4, action_def_5.
@@ -279,4 +294,4 @@ void free_kpm_func_def(kpm_func_def_t* src);
 }
 #endif
 
-#endif
\ No newline at end of file
+#endif
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index e7e96dc096..94639a449c 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -1042,7 +1042,7 @@ void read_kpm_sm(kpm_ind_data_t* data)
       assert(msg->MeasInfo != NULL && "Memory exhausted" );
 
       MeasInfo_t* info = &msg->MeasInfo[0];
-      info->measType = MeasurementType_NAME;
+      info->meas_type = KPM_V2_MEASUREMENT_TYPE_NAME;
       char* measName = "PrbDlUsage";
       info->measName.len = strlen(measName);
       info->measName.buf = malloc(strlen(measName));
-- 
GitLab