Added Configupdate for E2AP v1.01
[sim/e2-interface.git] / e2sim / src / encoding / encode_e2apv1.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 6f8c589..12e2c93
@@ -53,6 +53,10 @@ extern "C" {
 #include "RICsubsequentActionType.h"
 #include "RICsubsequentAction.h"  
 #include "RICtimeToWait.h"
+#include "E2nodeComponentGNB-CU-UP-ID.h"
+#include "E2nodeComponentID.h"
+#include "E2nodeComponentConfigUpdate.h"
+#include "E2nodeComponentConfigUpdateGNB.h"
   
 }
 
@@ -60,10 +64,7 @@ long encoding::get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) {
 
   RICsubscriptionRequest_t orig_req =
     e2ap_pdu->choice.initiatingMessage->value.choice.RICsubscriptionRequest;
-  
-  RICsubscriptionResponse_IEs_t *ricreqid =
-    (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
-                                          
+
   int count = orig_req.protocolIEs.list.count;
   int size = orig_req.protocolIEs.list.size;
   
@@ -181,13 +182,17 @@ void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu,
   GNB_ID_Choice_PR pres2 = GNB_ID_Choice_PR_gnb_ID;
   gnbchoice->present = pres2;
   gnbchoice->choice.gnb_ID = *gnb_bstring;
+  if (gnb_bstring) free(gnb_bstring);
 
   GlobalgNB_ID_t *gnb = (GlobalgNB_ID_t*)calloc(1, sizeof(GlobalgNB_ID_t));
   gnb->plmn_id = *plmn;
   gnb->gnb_id = *gnbchoice;
+  if (plmn) free(plmn);
+  if (gnbchoice) free(gnbchoice);
 
   GlobalE2node_gNB_ID_t *e2gnb = (GlobalE2node_gNB_ID_t*)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
   e2gnb->global_gNB_ID = *gnb;
+  if (gnb) free(gnb);
 
   GlobalE2node_ID_t *globale2nodeid = (GlobalE2node_ID_t*)calloc(1, sizeof(GlobalE2node_ID_t));
   GlobalE2node_ID_PR pres;
@@ -202,6 +207,7 @@ void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu,
   e2setuprid->criticality = 0;
   e2setuprid->value.choice.GlobalE2node_ID = *globale2nodeid;
   e2setuprid->value.present = pres3;
+  if(globale2nodeid) free(globale2nodeid);
 
 
   auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
@@ -223,7 +229,7 @@ void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu,
     itemIes->criticality = Criticality_reject;
     itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
     itemIes->value.choice.RANfunction_Item.ranFunctionID = nextRanFuncId;
-
+    itemIes->value.choice.RANfunction_Item.ranFunctionOID = nextRanFunc.ranFunctionOId;
     int ranFuncLength = strlen((char*)nextRanFuncDesc);
 
     itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *nextRanFuncDesc;
@@ -233,9 +239,71 @@ void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu,
 
   }
 
+    auto *e2nodeconfigupdatelistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
+  ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, e2nodeconfigupdatelistIEs);
+  e2nodeconfigupdatelistIEs->criticality = 0;
+  e2nodeconfigupdatelistIEs->id = ProtocolIE_ID_id_E2nodeComponentConfigUpdate;
+  e2nodeconfigupdatelistIEs->value.present = E2setupRequestIEs__value_PR_E2nodeComponentConfigUpdate_List;
+
+
+  OCTET_STRING_t *ngAPconfigUpdate =  (OCTET_STRING_t *)calloc(1,sizeof(OCTET_STRING_t));
+  ngAPconfigUpdate->buf = (uint8_t*)calloc(1,13);
+  memcpy(ngAPconfigUpdate->buf, (uint8_t *)"gnbngapupdate", 13);
+  ngAPconfigUpdate->size = 13;
+
+  OCTET_STRING_t *xnAPconfigUpdate =  (OCTET_STRING_t *)calloc(1,sizeof(OCTET_STRING_t));
+  xnAPconfigUpdate->buf = (uint8_t*)calloc(1,13);
+  memcpy(xnAPconfigUpdate->buf, (uint8_t *)"gnbxnapupdate", 13);
+  xnAPconfigUpdate->size = 13;
+
+  OCTET_STRING_t *e1APconfigUpdate =  (OCTET_STRING_t *)calloc(1,sizeof(OCTET_STRING_t));
+  e1APconfigUpdate->buf = (uint8_t*)calloc(1,13);
+  memcpy(e1APconfigUpdate->buf, (uint8_t *)"gnbe1apupdate", 13);
+  e1APconfigUpdate->size = 13;
+
+  OCTET_STRING_t *f1APconfigUpdate =  (OCTET_STRING_t *)calloc(1,sizeof(OCTET_STRING_t));
+  f1APconfigUpdate->buf = (uint8_t*)calloc(1,13);
+  memcpy(f1APconfigUpdate->buf, (uint8_t *)"gnbf1apupdate", 13);
+  f1APconfigUpdate->size = 13;
+
+  E2nodeComponentConfigUpdateGNB_t *e2nodecomponentconfigupdategnb = (E2nodeComponentConfigUpdateGNB_t *)calloc(1,sizeof(E2nodeComponentConfigUpdateGNB_t));
+  e2nodecomponentconfigupdategnb->ngAPconfigUpdate = ngAPconfigUpdate;
+  e2nodecomponentconfigupdategnb->xnAPconfigUpdate = xnAPconfigUpdate;
+  e2nodecomponentconfigupdategnb->e1APconfigUpdate = e1APconfigUpdate;
+  e2nodecomponentconfigupdategnb->f1APconfigUpdate = f1APconfigUpdate;
+
+  E2nodeComponentConfigUpdate_t e2nodecomponentconfigupdate = {};
+  e2nodecomponentconfigupdate.present = E2nodeComponentConfigUpdate_PR_gNBconfigUpdate;
+  e2nodecomponentconfigupdate.choice.gNBconfigUpdate = e2nodecomponentconfigupdategnb;
+
+  GNB_CU_UP_ID_t gnbcuupid = {};
+  gnbcuupid.buf = (uint8_t*)calloc(1,4);
+  memcpy(gnbcuupid.buf, (uint8_t *)"1234", 4);
+  gnbcuupid.size = 4;
+
+  E2nodeComponentGNB_CU_UP_ID_t *e2nodecomponentgnbcuupid = (E2nodeComponentGNB_CU_UP_ID_t *)calloc(1,sizeof(E2nodeComponentGNB_CU_UP_ID_t));
+  e2nodecomponentgnbcuupid->gNB_CU_UP_ID = gnbcuupid;
+
+  E2nodeComponentID_t *e2nodecomponentid = (E2nodeComponentID_t*)calloc(1, sizeof(E2nodeComponentID_t));
+
+  e2nodecomponentid->present = E2nodeComponentID_PR_e2nodeComponentTypeGNB_CU_UP;
+  e2nodecomponentid->choice.e2nodeComponentTypeGNB_CU_UP = e2nodecomponentgnbcuupid;
+
+  auto *configupdateitemIes = (E2nodeComponentConfigUpdate_ItemIEs_t *)calloc(1, sizeof(E2nodeComponentConfigUpdate_ItemIEs_t));
+  configupdateitemIes->id = ProtocolIE_ID_id_E2nodeComponentConfigUpdate_Item;
+  configupdateitemIes->criticality = Criticality_reject;
+  configupdateitemIes->value.present = E2nodeComponentConfigUpdate_ItemIEs__value_PR_E2nodeComponentConfigUpdate_Item;
+  configupdateitemIes->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentType = E2nodeComponentType_gNB_CU_UP;
+  configupdateitemIes->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentID = e2nodecomponentid;
+  configupdateitemIes->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentConfigUpdate = e2nodecomponentconfigupdate;
+
+  ASN_SEQUENCE_ADD(&e2nodeconfigupdatelistIEs->value.choice.E2nodeComponentConfigUpdate_List.list, configupdateitemIes);
+
   E2setupRequest_t *e2setupreq = (E2setupRequest_t*)calloc(1, sizeof(E2setupRequest_t));
   ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, e2setuprid);
   ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, ranFlistIEs);
+  ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, e2nodeconfigupdatelistIEs);
+
 
   InitiatingMessage__value_PR pres4;
   pres4 = InitiatingMessage__value_PR_E2setupRequest;
@@ -245,6 +313,7 @@ void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu,
   initmsg->criticality = Criticality_reject;
   initmsg->value.present = pres4;
   initmsg->value.choice.E2setupRequest = *e2setupreq;
+  if (e2setupreq) free(e2setupreq);
 
   E2AP_PDU_PR pres5;
   pres5 = E2AP_PDU_PR_initiatingMessage;
@@ -410,8 +479,8 @@ void encoding::generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) {
   e2ap_pdu->present = pres5;
   e2ap_pdu->choice.initiatingMessage = initmsg;
 
-  char *error_buf = (char*)calloc(300, sizeof(char));;
-  size_t errlen;
+  char error_buf[300] = {0, };
+  size_t errlen = 0;
                                                                          
   asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
   printf("error length %d\n", errlen);
@@ -451,6 +520,7 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu,
   RICaction_Admitted_List_t* admlist = 
     (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t));
   ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist;
+  if (admlist) free(admlist);
 
 
   int numAccept = accept_size;
@@ -515,14 +585,15 @@ void encoding::generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu,
   successoutcome->criticality = 0;
   successoutcome->value.present = pres2;
   successoutcome->value.choice.RICsubscriptionResponse = *ricsubresp;
+  if (ricsubresp) free(ricsubresp);
 
   E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome;
   
   e2ap_pdu->present = pres5;
   e2ap_pdu->choice.successfulOutcome = successoutcome;
 
-  char *error_buf = (char*)calloc(300, sizeof(char));
-  size_t errlen;
+  char error_buf[300] = {0, };
+  size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
   printf("error length %d\n", errlen);
@@ -676,8 +747,8 @@ void encoding::generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PD
   e2ap_pdu->present = pres5;
   e2ap_pdu->choice.successfulOutcome = successoutcome;
 
-  char *error_buf = (char*)calloc(300, sizeof(char));
-  size_t errlen;
+  char error_buf[300] = {0, };
+  size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
   printf("error length %d\n", errlen);
@@ -746,14 +817,6 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p
   ricind_ies5->value.present = pres3;
   ricind_ies5->value.choice.RICindicationType = 0;
 
-
-  uint8_t *buf2 = (uint8_t *)"reportheader";
-  OCTET_STRING_t *hdr_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
-
-  hdr_str->buf = (uint8_t*)calloc(1,header_length);
-  hdr_str->size = header_length;
-  memcpy(hdr_str->buf, ind_header_buf, header_length);
-
   fprintf(stderr, "ind3\n");
 
   ricind_ies6->value.choice.RICindicationHeader.buf = (uint8_t*)calloc(1,header_length);
@@ -845,15 +908,15 @@ void encoding::generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_p
   initmsg->criticality = 1;
   initmsg->value.present = pres4;
   initmsg->value.choice.RICindication = *ricindication;
+  if (ricindication) free(ricindication);
 
   E2AP_PDU_PR pres5;
   pres5 = E2AP_PDU_PR_initiatingMessage;
   
   e2ap_pdu->present = pres5;
   e2ap_pdu->choice.initiatingMessage = initmsg;
-
-  char *error_buf = (char*)calloc(300, sizeof(char));
-  size_t errlen;
+  char error_buf[300] = {0, };
+  size_t errlen = 0;
 
   asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
   printf("error length %d\n", errlen);