X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=e2sim%2Fsrc%2Fencoding%2Fencode_e2apv1.cpp;h=12e2c93fb9789e91415b705f539cee80fdf93105;hb=661a923827b94ee9db70aae77769c24eb53afbd2;hp=d1c2c06a8bb92758f490ea1b958325d24b527b93;hpb=50c32c08fb607bb7b1ac098f90c4b3a21eac169c;p=sim%2Fe2-interface.git diff --git a/e2sim/src/encoding/encode_e2apv1.cpp b/e2sim/src/encoding/encode_e2apv1.cpp old mode 100644 new mode 100755 index d1c2c06..12e2c93 --- a/e2sim/src/encoding/encode_e2apv1.cpp +++ b/e2sim/src/encoding/encode_e2apv1.cpp @@ -3,6 +3,7 @@ /***************************************************************************** # * # Copyright 2020 AT&T Intellectual Property * +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved. * # * # Licensed under the Apache License, Version 2.0 (the "License"); * # you may not use this file except in compliance with the License. * @@ -52,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" } @@ -59,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; @@ -95,6 +97,66 @@ long encoding::get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) { } +void encoding::generate_e2apv1_service_update(E2AP_PDU_t *e2ap_pdu, std::vector all_funcs) { + char* ran_function_op_type = getenv("RAN_FUNCTION_OP_TYPE"); + LOG_D("Ran funciton : %s", ran_function_op_type); + ProtocolIE_ID_t prID; + if (ran_function_op_type != NULL) + { + if (strcmp(ran_function_op_type, "ADD") == 0) + { + prID = ProtocolIE_ID_id_RANfunctionsAdded; + } + else if (strcmp(ran_function_op_type, "DELETE")) + { + prID = ProtocolIE_ID_id_RANfunctionsDeleted; + } + } + else + { + prID = ProtocolIE_ID_id_RANfunctionsModified; + } + + + RICserviceUpdate_IEs_t *e2serviceUpdateList = (RICserviceUpdate_IEs_t *)calloc(1, sizeof(RICserviceUpdate_IEs_t)); + e2serviceUpdateList->id = prID; + e2serviceUpdateList->criticality = Criticality_reject; + e2serviceUpdateList->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List; + + + for (int i=0; iid = ProtocolIE_ID_id_RANfunction_Item; + itemIes->criticality = Criticality_reject; + itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; + itemIes->value.choice.RANfunction_Item.ranFunctionID = 1; + + itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *nextRanFuncDesc; + itemIes->value.choice.RANfunction_Item.ranFunctionRevision = nextRanFuncRev + 1; + + ASN_SEQUENCE_ADD(&e2serviceUpdateList->value.choice.RANfunctions_List.list, itemIes); + } + + RICserviceUpdate_t *ricServiceUpdate = (RICserviceUpdate_t *)calloc(1, sizeof(RICserviceUpdate_t)); + ASN_SEQUENCE_ADD(&ricServiceUpdate->protocolIEs.list, e2serviceUpdateList); + + InitiatingMessage_t *initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t)); + initiatingMessage->criticality = Criticality_reject; + initiatingMessage->procedureCode = ProcedureCode_id_RICserviceUpdate; + initiatingMessage->value.present = InitiatingMessage__value_PR_RICserviceUpdate; + initiatingMessage->value.choice.RICserviceUpdate = *ricServiceUpdate; + + E2AP_PDU_PR pres6 = E2AP_PDU_PR_initiatingMessage; + e2ap_pdu->present = pres6; + e2ap_pdu->choice.initiatingMessage = initiatingMessage; +} + void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, std::vector all_funcs) { // long ranFunctionId, uint8_t *ranFuncDescEncoded, int ranFuncLength) { @@ -120,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; @@ -141,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)); @@ -162,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; @@ -172,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; @@ -184,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; @@ -349,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); @@ -390,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; @@ -454,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); @@ -615,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); @@ -685,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); @@ -784,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);