From 391d64013acb0333456cbba3a9ed5712c5c85bd2 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 24 Sep 2020 00:52:45 +0530 Subject: [PATCH] Implementation for supporting Service Update Implement Service Query message handling by responding with Service Update message. Remove some of temprory files. Issue-ID: SIM-43 Signed-off-by: subhash kumar singh Change-Id: Idaf0ca4d059a2b73516ca0028ddb15346735d5ff --- e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.cpp | 300 ++++-- e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.hpp | 21 + .../e2sim/src/E2APr/e2ap_message_handler.cpp | 147 ++- .../e2sim/src/E2APr/e2ap_message_handler.cpp~ | 267 ----- .../e2sim/src/E2APr/e2ap_message_handler.hpp | 3 + .../e2sim/src/E2APr/e2ap_message_handler.hpp~ | 47 - e2sim/previous/e2apv1sim/ricsim/CMakeLists.txt~ | 60 -- e2sim/previous/e2apv1sim/ricsim/encode_e2apv1.cpp~ | 1112 -------------------- .../ricsim/src/E2APr/e2ap_message_handler.cpp~ | 267 ----- .../ricsim/src/E2APr/e2ap_message_handler.hpp~ | 47 - 10 files changed, 328 insertions(+), 1943 deletions(-) delete mode 100644 e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp~ delete mode 100644 e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp~ delete mode 100644 e2sim/previous/e2apv1sim/ricsim/CMakeLists.txt~ delete mode 100644 e2sim/previous/e2apv1sim/ricsim/encode_e2apv1.cpp~ delete mode 100644 e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.cpp~ delete mode 100644 e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.hpp~ diff --git a/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.cpp b/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.cpp index bc4dbc2..11fd06d 100644 --- a/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.cpp +++ b/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +# * +# Copyright 2019 AT&T Intellectual Property * +# Copyright 2019 Nokia * +# 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. * +# You may obtain a copy of the License at * +# * +# http://www.apache.org/licenses/LICENSE-2.0 * +# * +# Unless required by applicable law or agreed to in writing, software * +# distributed under the License is distributed on an "AS IS" BASIS, * +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +# See the License for the specific language governing permissions and * +# limitations under the License. * +# * +******************************************************************************/ + #include #include #include @@ -30,22 +50,98 @@ extern "C" { #include "RANfunctions-List.h" #include "RICindication.h" #include "RICsubsequentActionType.h" -#include "RICsubsequentAction.h" +#include "RICsubsequentAction.h" #include "RICtimeToWait.h" - + +} + +void generate_e2apv1_service_update(E2AP_PDU_t *e2ap_pdu) { + + 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; + } + + auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t)); + itemIes->id = 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; + + E2SM_KPM_RANfunction_Description_t *ranfunc_desc = + (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); + encode_kpm_function_description(ranfunc_desc); + + uint8_t e2smbuffer[8192]; + size_t e2smbuffer_size = 8192; + + asn_codec_ctx_t *opt_cod; + + asn_enc_rval_t er = + asn_encode_to_buffer(opt_cod, + ATS_ALIGNED_BASIC_PER, + &asn_DEF_E2SM_KPM_RANfunction_Description, + ranfunc_desc, e2smbuffer, e2smbuffer_size); + + fprintf(stderr, "er encded is %d\n", er.encoded); + fprintf(stderr, "after encoding message\n"); + + OCTET_STRING_t *ranfuncdesc_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); + ranfuncdesc_str->buf = (uint8_t*)calloc(1,er.encoded); + ranfuncdesc_str->size = er.encoded; + memcpy(ranfuncdesc_str->buf, e2smbuffer, er.encoded); + + + + itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *ranfuncdesc_str; + itemIes->value.choice.RANfunction_Item.ranFunctionRevision = (long)3; + + + RICserviceUpdate_IEs_t *e2serviceUpdateList = (RICserviceUpdate_IEs_t *)calloc(1, sizeof(RICserviceUpdate_IEs_t)); + e2serviceUpdateList->id = prID; /// is it correct ??? + e2serviceUpdateList->criticality = Criticality_reject; + e2serviceUpdateList->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List; + 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; } long 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; - + RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array; fprintf(stderr, "count%d\n", count); @@ -58,16 +154,16 @@ long get_function_id_from_subscription(E2AP_PDU_t *e2ap_pdu) { for (int i=0; i < count; i++) { RICsubscriptionRequest_IEs_t *next_ie = ies[i]; pres = next_ie->value.present; - + fprintf(stderr, "next present value %d\n", pres); if (pres == RICsubscriptionRequest_IEs__value_PR_RANfunctionID) { func_id = next_ie->value.choice.RANfunctionID; } - + } - return func_id; + return func_id; } @@ -109,7 +205,7 @@ void generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, std::vect pres = GlobalE2node_ID_PR_gNB; globale2nodeid->present = pres; globale2nodeid->choice.gNB = e2gnb; - + E2setupRequestIEs_t *e2setuprid = (E2setupRequestIEs_t*)calloc(1, sizeof(E2setupRequestIEs_t)); E2setupRequestIEs__value_PR pres3; pres3 = E2setupRequestIEs__value_PR_GlobalE2node_ID; @@ -143,7 +239,7 @@ void generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, std::vect itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *nextRanFuncDesc; itemIes->value.choice.RANfunction_Item.ranFunctionRevision = nextRanFuncRev; - + ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes); } @@ -163,15 +259,15 @@ void generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, std::vect E2AP_PDU_PR pres5; pres5 = E2AP_PDU_PR_initiatingMessage; - + e2ap_pdu->present = pres5; - e2ap_pdu->choice.initiatingMessage = initmsg; + e2ap_pdu->choice.initiatingMessage = initmsg; } void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { - + // uint8_t *buf = (uint8_t *)"gnb1" BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; @@ -207,7 +303,7 @@ void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { pres = GlobalE2node_ID_PR_gNB; globale2nodeid->present = pres; globale2nodeid->choice.gNB = e2gnb; - + E2setupRequestIEs_t *e2setuprid = (E2setupRequestIEs_t*)calloc(1, sizeof(E2setupRequestIEs_t)); E2setupRequestIEs__value_PR pres3; pres3 = E2setupRequestIEs__value_PR_GlobalE2node_ID; @@ -236,14 +332,14 @@ void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { uint8_t e2smbuffer[8192]; size_t e2smbuffer_size = 8192; - asn_codec_ctx_t *opt_cod; + asn_codec_ctx_t *opt_cod; asn_enc_rval_t er = asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc, e2smbuffer, e2smbuffer_size); - + fprintf(stderr, "er encded is %d\n", er.encoded); fprintf(stderr, "after encoding message\n"); @@ -251,7 +347,7 @@ void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { ranfuncdesc_str->buf = (uint8_t*)calloc(1,er.encoded); ranfuncdesc_str->size = er.encoded; memcpy(ranfuncdesc_str->buf, e2smbuffer, er.encoded); - + itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *ranfuncdesc_str; itemIes->value.choice.RANfunction_Item.ranFunctionRevision = (long)2; @@ -273,7 +369,7 @@ void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { E2AP_PDU_PR pres5; pres5 = E2AP_PDU_PR_initiatingMessage; - + e2ap_pdu->present = pres5; e2ap_pdu->choice.initiatingMessage = initmsg; @@ -305,7 +401,7 @@ void generate_e2apv1_setup_response(E2AP_PDU_t *e2ap_pdu) { E2setupResponseIEs__value_PR pres1; pres1 = E2setupResponseIEs__value_PR_GlobalRIC_ID; - + resp_ies1->id = ProtocolIE_ID_id_GlobalRIC_ID; resp_ies1->criticality = 0; resp_ies1->value.present = pres1; @@ -324,10 +420,10 @@ void generate_e2apv1_setup_response(E2AP_PDU_t *e2ap_pdu) { successoutcome->value.choice.E2setupResponse = *e2setupresp; E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome; - + e2ap_pdu->present = pres5; e2ap_pdu->choice.successfulOutcome = successoutcome; - + } @@ -335,19 +431,19 @@ void generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) { fprintf(stderr, "in sub 1\n"); RICsubscriptionRequest_IEs_t *ricreqid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t)); - fprintf(stderr, "in sub 2\n"); + fprintf(stderr, "in sub 2\n"); ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ricreqid); - fprintf(stderr, "in sub 3\n"); + fprintf(stderr, "in sub 3\n"); auto *ricsubrid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t)); - fprintf(stderr, "in sub 4\n"); + fprintf(stderr, "in sub 4\n"); ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ricsubrid); - + fprintf(stderr, "in generate sub\n"); uint8_t *buf2 = (uint8_t *)"SubscriptionTriggers"; fprintf(stderr, "in gen sub 1\n"); OCTET_STRING_t *triggerdef = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); triggerdef->buf = (uint8_t *)calloc(1,20); - triggerdef->size = 20; + triggerdef->size = 20; memcpy(triggerdef->buf, buf2, triggerdef->size); @@ -363,15 +459,15 @@ void generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) { OCTET_STRING_t *actdef = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); actdef->buf = (uint8_t *)calloc(1,9); - actdef->size = 9; + actdef->size = 9; memcpy(triggerdef->buf, buf5, 9); auto *sa = (RICsubsequentAction_t *) calloc(1, sizeof(RICsubsequentAction_t)); ASN_STRUCT_RESET(asn_DEF_RICsubsequentAction, sa); - + sa->ricTimeToWait = RICtimeToWait_w500ms; sa->ricSubsequentActionType = RICsubsequentActionType_continue; - + printf("sub3\n"); RICaction_ToBeSetup_ItemIEs_t *action_item_ies = (RICaction_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(RICaction_ToBeSetup_Item_t)); @@ -386,21 +482,21 @@ void generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) { printf("sub5\n"); - + RICsubscriptionRequest_IEs__value_PR pres3; printf("sub6.1\n"); pres3 = RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails; ricsubrid->id = ProtocolIE_ID_id_RICsubscriptionDetails; printf("sub6.2\n"); - + ricsubrid->criticality = 0; ricsubrid->value.present = pres3; printf("sub6.3\n"); ricsubrid->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition = *triggerdef; printf("sub6.4\n"); - + ASN_SEQUENCE_ADD(&ricsubrid->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list, action_item_ies); printf("sub7\n"); @@ -429,14 +525,14 @@ void generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) { 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; - + asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); printf("error length %d\n", errlen); printf("error buf %s\n", error_buf); @@ -450,12 +546,12 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA RICsubscriptionResponse_IEs_t *respricreqid = (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - + respricreqid->id = ProtocolIE_ID_id_RICrequestID; respricreqid->criticality = 0; respricreqid->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID; respricreqid->value.choice.RICrequestID.ricRequestorID = reqRequestorId; - + respricreqid->value.choice.RICrequestID.ricInstanceID = reqInstanceId; @@ -465,7 +561,7 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA ricactionadmitted->criticality = 0; ricactionadmitted->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List; - RICaction_Admitted_List_t* admlist = + RICaction_Admitted_List_t* admlist = (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t)); ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist; @@ -474,7 +570,7 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA int numReject = reject_size; - + for (int i=0; i < numAccept ; i++) { fprintf(stderr, "in for loop i = %d\n", i); @@ -485,7 +581,7 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA admitie->criticality = 0; admitie->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item; admitie->value.choice.RICaction_Admitted_Item.ricActionID = aid; - + ASN_SEQUENCE_ADD(&ricactionadmitted->value.choice.RICaction_Admitted_List.list, admitie); } @@ -493,7 +589,7 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t)); ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid); ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted); - + if (numReject > 0) { @@ -502,24 +598,24 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA ricactionrejected->id = ProtocolIE_ID_id_RICactions_NotAdmitted; ricactionrejected->criticality = 0; ricactionrejected->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List; - - RICaction_NotAdmitted_List_t* rejectlist = + + RICaction_NotAdmitted_List_t* rejectlist = (RICaction_NotAdmitted_List_t*)calloc(1,sizeof(RICaction_NotAdmitted_List_t)); ricactionadmitted->value.choice.RICaction_NotAdmitted_List = *rejectlist; - + for (int i=0; i < numReject; i++) { fprintf(stderr, "in for loop i = %d\n", i); - + long aid = reqActionIdsRejected[i]; - + RICaction_NotAdmitted_ItemIEs_t *noadmitie = (RICaction_NotAdmitted_ItemIEs_t*)calloc(1,sizeof(RICaction_NotAdmitted_ItemIEs_t)); noadmitie->id = ProtocolIE_ID_id_RICaction_NotAdmitted_Item; noadmitie->criticality = 0; noadmitie->value.present = RICaction_NotAdmitted_ItemIEs__value_PR_RICaction_NotAdmitted_Item; noadmitie->value.choice.RICaction_NotAdmitted_Item.ricActionID = aid; - + ASN_SEQUENCE_ADD(&ricactionrejected->value.choice.RICaction_NotAdmitted_List.list, noadmitie); - ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionrejected); + ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionrejected); } } @@ -533,7 +629,7 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA successoutcome->value.choice.RICsubscriptionResponse = *ricsubresp; E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome; - + e2ap_pdu->present = pres5; e2ap_pdu->choice.successfulOutcome = successoutcome; @@ -544,7 +640,7 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA printf("error length %d\n", errlen); printf("error buf %s\n", error_buf); - + } void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req_pdu) { @@ -553,13 +649,13 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req RICsubscriptionRequest_t orig_req = sub_req_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; - + RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array; fprintf(stderr, "count%d\n", count); @@ -576,7 +672,7 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req for (int i=0; i < count; i++) { RICsubscriptionRequest_IEs_t *next_ie = ies[i]; pres = next_ie->value.present; - + fprintf(stderr, "next present value %d\n", pres); switch(pres) { @@ -589,17 +685,17 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req fprintf(stderr, "instanceId %d\n", instanceId); responseRequestorId = requestorId; responseInstanceId = instanceId; - + break; } case RICsubscriptionRequest_IEs__value_PR_RANfunctionID: break; case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails: { - RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; + RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition; RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List; - + int actionCount = actionList.list.count; fprintf(stderr, "action count%d\n", actionCount); @@ -613,11 +709,11 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req responseActionId = actionId; actionIds.push_back(responseActionId); } - + break; } } - + } fprintf(stderr, "After Processing Subscription Request\n"); @@ -628,18 +724,18 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req for (int i=0; i < actionIds.size(); i++) { fprintf(stderr, "Action ID %d %ld\n", i, actionIds.at(i)); - + } RICsubscriptionResponse_IEs_t *respricreqid = (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - + respricreqid->id = ProtocolIE_ID_id_RICrequestID; respricreqid->criticality = 0; respricreqid->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID; respricreqid->value.choice.RICrequestID.ricRequestorID = responseRequestorId; - + respricreqid->value.choice.RICrequestID.ricInstanceID = responseInstanceId; @@ -649,7 +745,7 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req ricactionadmitted->criticality = 0; ricactionadmitted->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List; - RICaction_Admitted_List_t* admlist = + RICaction_Admitted_List_t* admlist = (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t)); ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist; @@ -663,14 +759,14 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req admitie->criticality = 0; admitie->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item; admitie->value.choice.RICaction_Admitted_Item.ricActionID = aid; - + ASN_SEQUENCE_ADD(&ricactionadmitted->value.choice.RICaction_Admitted_List.list, admitie); } RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t)); - + ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid); ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted); @@ -684,7 +780,7 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req successoutcome->value.choice.RICsubscriptionResponse = *ricsubresp; E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome; - + e2ap_pdu->present = pres5; e2ap_pdu->choice.successfulOutcome = successoutcome; @@ -694,7 +790,7 @@ void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); printf("error length %d\n", errlen); printf("error buf %s\n", error_buf); - + } void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, @@ -735,7 +831,7 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, ricind_ies2->value.present = pres3; ricind_ies2->value.choice.RANfunctionID = ranFunctionId; - + ricind_ies3->id = ProtocolIE_ID_id_RICactionID; ricind_ies3->criticality = 0; pres3 = RICindication_IEs__value_PR_RICactionID; @@ -774,11 +870,11 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, ricind_ies6->value.present = pres3; ricind_ies6->value.choice.RICindicationHeader.size = header_length; memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, ind_header_buf, header_length); - + ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192); - + pres3 = RICindication_IEs__value_PR_RICindicationMessage; ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage; @@ -789,13 +885,13 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, fprintf(stderr, "after encoding message 2\n"); - fprintf(stderr, "after encoding message 3\n"); + fprintf(stderr, "after encoding message 3\n"); ricind_ies7->value.choice.RICindicationMessage.size = message_length; fprintf(stderr, "after encoding message 4\n"); memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, ind_message_buf, message_length); - fprintf(stderr, "after encoding message 5\n"); + fprintf(stderr, "after encoding message 5\n"); uint8_t *cpid_buf = (uint8_t *)"cpid"; OCTET_STRING_t cpid_str; @@ -818,11 +914,11 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t)); - + int ret; ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies); - + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2); printf("5.3\n"); @@ -830,22 +926,22 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3); printf("5.35\n"); - + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4); printf("5.36\n"); - + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5); printf("5.4\n"); - + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6); printf("5.5\n"); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); - - // ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); + + // ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); InitiatingMessage__value_PR pres4; @@ -858,7 +954,7 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, E2AP_PDU_PR pres5; pres5 = E2AP_PDU_PR_initiatingMessage; - + e2ap_pdu->present = pres5; e2ap_pdu->choice.initiatingMessage = initmsg; @@ -869,7 +965,7 @@ void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, printf("error length %d\n", errlen); printf("error buf %s\n", error_buf); - xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); + xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); } @@ -893,7 +989,7 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { ricind_ies->value.choice.RICrequestID.ricRequestorID = 25; ricind_ies->value.choice.RICrequestID.ricInstanceID = 3; - fprintf(stderr, "ind2\n"); + fprintf(stderr, "ind2\n"); pres3 = RICindication_IEs__value_PR_RANfunctionID; ricind_ies2->id = ProtocolIE_ID_id_RANfunctionID; @@ -901,7 +997,7 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { ricind_ies2->value.present = pres3; ricind_ies2->value.choice.RANfunctionID = 70; - + ricind_ies3->id = ProtocolIE_ID_id_RICactionID; ricind_ies3->criticality = 0; pres3 = RICindication_IEs__value_PR_RICactionID; @@ -938,7 +1034,7 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { ricind_ies6->value.present = pres3; ricind_ies6->value.choice.RICindicationHeader.size = 12; memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, buf2, 12); - + ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192); @@ -947,29 +1043,29 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); encode_kpm_function_description(e2sm_desc); - - + + uint8_t e2smbuffer[8192]; size_t e2smbuffer_size = 8192; asn_codec_ctx_t *opt_cod; - + asn_enc_rval_t er = asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_RANfunction_Description, e2sm_desc, e2smbuffer, e2smbuffer_size); - - + + fprintf(stderr, "er encded is %d\n", er.encoded); fprintf(stderr, "after encoding message\n"); - + OCTET_STRING_t *msg_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); msg_str->buf = (uint8_t*)calloc(1,er.encoded); msg_str->size = er.encoded; memcpy(msg_str->buf, e2smbuffer, er.encoded); - + pres3 = RICindication_IEs__value_PR_RICindicationMessage; ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage; @@ -980,18 +1076,18 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { fprintf(stderr, "after encoding message 2\n"); - fprintf(stderr, "after encoding message 3\n"); + fprintf(stderr, "after encoding message 3\n"); ricind_ies7->value.choice.RICindicationMessage.size = er.encoded; - fprintf(stderr, "after encoding message 4\n"); + fprintf(stderr, "after encoding message 4\n"); memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, e2smbuffer, er.encoded); - fprintf(stderr, "after encoding message 5\n"); + fprintf(stderr, "after encoding message 5\n"); uint8_t *buf4 = (uint8_t *)"cpid"; OCTET_STRING_t cpid_str; cpid_str.buf = buf4; - cpid_str.size = 4; + cpid_str.size = 4; pres3 = RICindication_IEs__value_PR_RICcallProcessID; @@ -1005,22 +1101,22 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t)); - + int ret; /* ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies); ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3); + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3); ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5); + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5); ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6); */ - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); + ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); InitiatingMessage__value_PR pres4; @@ -1033,12 +1129,12 @@ void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { 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; + size_t errlen; asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); printf("error length %d\n", errlen); diff --git a/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.hpp b/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.hpp index e65b8a9..c072c65 100644 --- a/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.hpp +++ b/e2sim/previous/e2apv1sim/e2sim/encode_e2apv1.hpp @@ -1,3 +1,22 @@ +/***************************************************************************** +# * +# Copyright 2019 AT&T Intellectual Property * +# Copyright 2019 Nokia * +# 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. * +# You may obtain a copy of the License at * +# * +# http://www.apache.org/licenses/LICENSE-2.0 * +# * +# Unless required by applicable law or agreed to in writing, software * +# distributed under the License is distributed on an "AS IS" BASIS, * +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +# See the License for the specific language governing permissions and * +# limitations under the License. * +# * +******************************************************************************/ #ifndef ENCODE_E2APV1_HPP #define ENCODE_E2APV1_HPP @@ -51,4 +70,6 @@ void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqA void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, long requestorId, long instanceId, long ranFunctionId, long actionId, long seqNum, uint8_t *ind_header_buf, int header_length, uint8_t *ind_message_buf, int message_length); +void generate_e2apv1_service_update(E2AP_PDU_t *e2ap_pdu); + #endif diff --git a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp b/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp index d3778c0..0bd6479 100644 --- a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp +++ b/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp @@ -1,9 +1,8 @@ - - /***************************************************************************** # * # Copyright 2019 AT&T Intellectual Property * # Copyright 2019 Nokia * +# 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. * @@ -38,27 +37,27 @@ void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc) fprintf(stderr, "decoding...\n"); asn_transfer_syntax syntax; - + syntax = ATS_ALIGNED_BASIC_PER; - + fprintf(stderr, "full buffer\n%s\n", data.buffer); // e2ap_asn1c_decode_pdu(pdu, data.buffer, data.len); auto rval = asn_decode(nullptr, syntax, &asn_DEF_E2AP_PDU, (void **) &pdu, data.buffer, data.len); - + int index = (int)pdu->present; fprintf(stderr, "length of data %d\n", rval.consumed); fprintf(stderr, "result %d\n", rval.code); fprintf(stderr, "index is %d\n", index); - - fprintf(stderr, "showing xer of data\n"); - + + fprintf(stderr, "showing xer of data\n"); + xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu); - + int procedureCode = e2ap_asn1c_get_procedureCode(pdu); index = (int)pdu->present; @@ -67,7 +66,7 @@ void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc) switch(procedureCode) { - + case ProcedureCode_id_E2setup: switch(index) { @@ -75,40 +74,40 @@ void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc) e2ap_handle_E2SetupRequest(pdu, socket_fd); LOG_I("[E2AP] Received SETUP-REQUEST"); break; - + case E2AP_PDU_PR_successfulOutcome: LOG_I("[E2AP] Received SETUP-RESPONSE-SUCCESS"); break; - + case E2AP_PDU_PR_unsuccessfulOutcome: LOG_I("[E2AP] Received SETUP-RESPONSE-FAILURE"); break; - + default: LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index); break; } - break; - + break; + case ProcedureCode_id_Reset: //reset = 7 switch(index) { case E2AP_PDU_PR_initiatingMessage: LOG_I("[E2AP] Received RESET-REQUEST"); break; - + case E2AP_PDU_PR_successfulOutcome: break; - + case E2AP_PDU_PR_unsuccessfulOutcome: break; - + default: LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index); break; } break; - + case ProcedureCode_id_RICindication: // 205 switch(index) { @@ -119,33 +118,103 @@ void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc) case E2AP_PDU_PR_successfulOutcome: LOG_I("[E2AP] Received RIC-INDICATION-RESPONSE"); break; - + case E2AP_PDU_PR_unsuccessfulOutcome: LOG_I("[E2AP] Received RIC-INDICATION-FAILURE"); break; - + default: LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index, (int)ProcedureCode_id_RICindication); break; } break; - + + case ProcedureCode_id_RICserviceQuery: + switch (index) + { + case E2AP_PDU_PR_initiatingMessage: + LOG_I("[E2AP] Received RIC-Service-Query") + e2ap_handle_E2SeviceUpdate(pdu, socket_fd); + break; + + default: + LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index, + (int)ProcedureCode_id_RICserviceQuery); + break; + } + break; + + case ProcedureCode_id_RICserviceUpdate: + switch (index) + { + case E2AP_PDU_PR_successfulOutcome: + LOG_I("[E2AP] Received RIC-SERVICE-UPDATE-SUCCESS") + break; + + case E2AP_PDU_PR_unsuccessfulOutcome: + LOG_I("[E2AP] Received RIC-SERVICE-UPDATE-FAILURE") + break; + + default: + LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index, + (int)ProcedureCode_id_RICserviceUpdate); + break; + } + break; + default: - + LOG_E("[E2AP] No available handler for procedureCode=%d", procedureCode); break; } } +void e2ap_handle_E2SeviceUpdate(E2AP_PDU_t* pdu, int &socket_fd) { + +auto buffer_size = MAX_SCTP_BUFFER; + unsigned char buffer[MAX_SCTP_BUFFER]; + E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); + generate_e2apv1_service_update(pdu); + + printf("After generating e2setup req\n"); + + xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu); + + printf("After XER Encoding\n"); + + sctp_buffer_t data; + + char *error_buf = (char*)calloc(300, sizeof(char)); + size_t errlen; + + asn_check_constraints(&asn_DEF_E2AP_PDU, pdu, error_buf, &errlen); + printf("error length %d\n", errlen); + printf("error buf %s\n", error_buf); + + auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu, buffer, buffer_size); + //auto er = asn_encode_to_buffer(nullptr, ATS_BASIC_XER, &asn_DEF_E2AP_PDU, pdu_setup, buffer, buffer_size); + data.len = er.encoded; + fprintf(stderr, "er encoded is %d\n", er.encoded); + + memcpy(data.buffer, buffer, er.encoded); + + //send response data over sctp + if(sctp_send_data(socket_fd, data) > 0) { + LOG_I("[SCTP] Sent E2-SERVICE-UPDATE"); + } else { + LOG_E("[SCTP] Unable to send E2-SERVICE-UPDATE to peer"); + } +} + void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) { - + E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU)); generate_e2apv1_setup_response(res_pdu); - + LOG_D("[E2AP] Created E2-SETUP-RESPONSE"); e2ap_asn1c_print_pdu(res_pdu); @@ -153,13 +222,13 @@ void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) { auto buffer_size = MAX_SCTP_BUFFER; unsigned char buffer[MAX_SCTP_BUFFER]; - + sctp_buffer_t data; auto er = asn_encode_to_buffer(nullptr, ATS_BASIC_XER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size); data.len = er.encoded; - fprintf(stderr, "er encoded is %d\n", er.encoded); - + fprintf(stderr, "er encoded is %d\n", er.encoded); + //data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf); memcpy(data.buffer, buffer, er.encoded); @@ -182,21 +251,21 @@ void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) { auto buffer_size2 = MAX_SCTP_BUFFER; unsigned char buffer2[MAX_SCTP_BUFFER]; - + sctp_buffer_t data2; auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_sub, buffer2, buffer_size2); - + data2.len = er2.encoded; memcpy(data2.buffer, buffer2, er2.encoded); - + fprintf(stderr, "er encded is %d\n", er2.encoded); if(sctp_send_data(socket_fd, data2) > 0) { LOG_I("[SCTP] Sent E2-SUBSCRIPTION-REQUEST"); } else { LOG_E("[SCTP] Unable to send E2-SUBSCRIPTION-REQUEST to peer"); - } + } } @@ -217,7 +286,7 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd) auto buffer_size2 = MAX_SCTP_BUFFER; unsigned char buffer2[MAX_SCTP_BUFFER]; - + sctp_buffer_t data2; auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_resp, buffer2, buffer_size2); @@ -232,8 +301,8 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd) } else { LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer"); } - - + + //Send back an Indication E2AP_PDU_t* pdu_ind = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); @@ -244,7 +313,7 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd) auto buffer_size = MAX_SCTP_BUFFER; unsigned char buffer[MAX_SCTP_BUFFER]; - + sctp_buffer_t data; auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_ind, buffer, buffer_size); @@ -258,10 +327,6 @@ void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd) LOG_I("[SCTP] Sent RIC-INDICATION-REQUEST"); } else { LOG_E("[SCTP] Unable to send RIC-INDICATION-REQUEST to peer"); - } + } } - - - - diff --git a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp~ b/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp~ deleted file mode 100644 index f12b09e..0000000 --- a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.cpp~ +++ /dev/null @@ -1,267 +0,0 @@ - - -/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# Copyright 2019 Nokia * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -******************************************************************************/ -#include "e2ap_message_handler.hpp" - -//#include -//#include - -#include "encode_e2apv1.hpp" -#include "kpm_callbacks.hpp" - -#include - -void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc) -{ - fprintf(stderr, "in e2ap_handle_sctp_data()\n"); - //decode the data into E2AP-PDU - E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU)); - ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu); - - fprintf(stderr, "decoding...\n"); - - asn_transfer_syntax syntax; - - - syntax = ATS_ALIGNED_BASIC_PER; - - - fprintf(stderr, "full buffer\n%s\n", data.buffer); - // e2ap_asn1c_decode_pdu(pdu, data.buffer, data.len); - - auto rval = asn_decode(nullptr, syntax, &asn_DEF_E2AP_PDU, (void **) &pdu, - data.buffer, data.len); - - - int index = (int)pdu->present; - fprintf(stderr, "length of data %d\n", rval.consumed); - fprintf(stderr, "result %d\n", rval.code); - fprintf(stderr, "index is %d\n", index); - - fprintf(stderr, "showing xer of data\n"); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu); - - int procedureCode = e2ap_asn1c_get_procedureCode(pdu); - index = (int)pdu->present; - - LOG_D("[E2AP] Unpacked E2AP-PDU: index = %d, procedureCode = %d\n", - index, procedureCode); - - switch(procedureCode) - { - - case ProcedureCode_id_E2setup: - switch(index) - { - case E2AP_PDU_PR_initiatingMessage: - e2ap_handle_E2SetupRequest(pdu, socket_fd); - LOG_I("[E2AP] Received SETUP-REQUEST"); - break; - - case E2AP_PDU_PR_successfulOutcome: - LOG_I("[E2AP] Received SETUP-RESPONSE-SUCCESS"); - break; - - case E2AP_PDU_PR_unsuccessfulOutcome: - LOG_I("[E2AP] Received SETUP-RESPONSE-FAILURE"); - break; - - default: - LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index); - break; - } - break; - - case ProcedureCode_id_Reset: //reset = 7 - switch(index) - { - case E2AP_PDU_PR_initiatingMessage: - LOG_I("[E2AP] Received RESET-REQUEST"); - break; - - case E2AP_PDU_PR_successfulOutcome: - break; - - case E2AP_PDU_PR_unsuccessfulOutcome: - break; - - default: - LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index); - break; - } - break; - - case ProcedureCode_id_RICindication: // 205 - switch(index) - { - case E2AP_PDU_PR_initiatingMessage: //initiatingMessage - LOG_I("[E2AP] Received RIC-INDICATION-REQUEST"); - // e2ap_handle_RICSubscriptionRequest(pdu, socket_fd); - break; - case E2AP_PDU_PR_successfulOutcome: - LOG_I("[E2AP] Received RIC-INDICATION-RESPONSE"); - break; - - case E2AP_PDU_PR_unsuccessfulOutcome: - LOG_I("[E2AP] Received RIC-INDICATION-FAILURE"); - break; - - default: - LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index, - (int)ProcedureCode_id_RICindication); - break; - } - break; - - default: - - LOG_E("[E2AP] No available handler for procedureCode=%d", procedureCode); - - break; - } -} - -void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) { - - - E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU)); - generate_e2apv1_setup_response(res_pdu); - - - LOG_D("[E2AP] Created E2-SETUP-RESPONSE"); - - e2ap_asn1c_print_pdu(res_pdu); - - - auto buffer_size = MAX_SCTP_BUFFER; - unsigned char buffer[MAX_SCTP_BUFFER]; - - sctp_buffer_t data; - auto er = asn_encode_to_buffer(nullptr, ATS_BASIC_XER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size); - - data.len = er.encoded; - fprintf(stderr, "er encoded is %d\n", er.encoded); - - //data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf); - memcpy(data.buffer, buffer, er.encoded); - - //send response data over sctp - if(sctp_send_data(socket_fd, data) > 0) { - LOG_I("[SCTP] Sent E2-SETUP-RESPONSE"); - } else { - LOG_E("[SCTP] Unable to send E2-SETUP-RESPONSE to peer"); - } - - sleep(5); - - //Sending Subscription Request - - E2AP_PDU_t* pdu_sub = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); - - generate_e2apv1_subscription_request(pdu_sub); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_sub); - - auto buffer_size2 = MAX_SCTP_BUFFER; - unsigned char buffer2[MAX_SCTP_BUFFER]; - - sctp_buffer_t data2; - - auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_sub, buffer2, buffer_size2); - - data2.len = er2.encoded; - memcpy(data2.buffer, buffer2, er2.encoded); - - fprintf(stderr, "er encded is %d\n", er2.encoded); - - if(sctp_send_data(socket_fd, data2) > 0) { - LOG_I("[SCTP] Sent E2-SUBSCRIPTION-REQUEST"); - } else { - LOG_E("[SCTP] Unable to send E2-SUBSCRIPTION-REQUEST to peer"); - } - - -} - - -void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd) -{ - - //Send back Subscription Success Response - - E2AP_PDU_t* pdu_resp = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); - - generate_e2apv1_subscription_response(pdu_resp, pdu); - - fprintf(stderr, "Subscription Response\n"); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_resp); - - auto buffer_size2 = MAX_SCTP_BUFFER; - unsigned char buffer2[MAX_SCTP_BUFFER]; - - sctp_buffer_t data2; - - auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_resp, buffer2, buffer_size2); - data2.len = er2.encoded; - - fprintf(stderr, "er encded is %d\n", er2.encoded); - - memcpy(data2.buffer, buffer2, er2.encoded); - - if(sctp_send_data(socket_fd, data2) > 0) { - LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE"); - } else { - LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer"); - } - - - //Send back an Indication - - E2AP_PDU_t* pdu_ind = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); - - generate_e2apv1_indication_request(pdu_ind); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_ind); - - auto buffer_size = MAX_SCTP_BUFFER; - unsigned char buffer[MAX_SCTP_BUFFER]; - - sctp_buffer_t data; - - auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_ind, buffer, buffer_size); - data.len = er.encoded; - - fprintf(stderr, "er encded is %d\n", er.encoded); - - memcpy(data.buffer, buffer, er.encoded); - - if(sctp_send_data(socket_fd, data) > 0) { - LOG_I("[SCTP] Sent RIC-INDICATION-REQUEST"); - } else { - LOG_E("[SCTP] Unable to send RIC-INDICATION-REQUEST to peer"); - } - -} - - - - diff --git a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp b/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp index 5d93836..323efa7 100644 --- a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp +++ b/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp @@ -2,6 +2,7 @@ # * # Copyright 2019 AT&T Intellectual Property * # Copyright 2019 Nokia * +# 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. * @@ -44,4 +45,6 @@ void e2ap_handle_RICSubscriptionRequest_securityDemo(E2AP_PDU_t* pdu, int &socke void e2ap_handle_ResourceStatusRequest(E2AP_PDU_t* pdu, int &socket_fd); +void e2ap_handle_E2SeviceUpdate(E2AP_PDU_t* pdu, int &socket_fd); + #endif diff --git a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp~ b/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp~ deleted file mode 100644 index 5ec288b..0000000 --- a/e2sim/previous/e2apv1sim/e2sim/src/E2APr/e2ap_message_handler.hpp~ +++ /dev/null @@ -1,47 +0,0 @@ -/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# Copyright 2019 Nokia * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -******************************************************************************/ -#ifndef E2AP_MESSAGE_HANDLER_HPP -#define E2AP_MESSAGE_HANDLER_HPP - -#include "e2sim.hpp" -#include "e2sim_sctp.hpp" - - -extern "C" { - #include "e2sim_defs.h" - #include "e2ap_asn1c_codec.h" -} - -void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc, E2Sim *e2sim); - -void e2ap_handle_X2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_X2SetupResponse(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_ENDCX2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_RICSubscriptionRequest_securityDemo(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_ResourceStatusRequest(E2AP_PDU_t* pdu, int &socket_fd); - -#endif diff --git a/e2sim/previous/e2apv1sim/ricsim/CMakeLists.txt~ b/e2sim/previous/e2apv1sim/ricsim/CMakeLists.txt~ deleted file mode 100644 index 9b9b361..0000000 --- a/e2sim/previous/e2apv1sim/ricsim/CMakeLists.txt~ +++ /dev/null @@ -1,60 +0,0 @@ -#/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# Copyright 2019 Nokia * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -#******************************************************************************/ - -cmake_minimum_required(VERSION 3.5.1) -set(CMAKE_CXX_COMPILER "/usr/bin/g++") -set(CMAKE_CXX_STANDARD 14) - - - -project(e2sim) - -set (E2SIM_ROOT ./) - - -include_directories("${E2SIM_ROOT}") -include_directories("${E2SIM_ROOT}/src") -include_directories("${E2SIM_ROOT}/src/DEF") -include_directories("${E2SIM_ROOT}/src/SCTP/") -include_directories("${E2SIM_ROOT}/src/E2APr") -include_directories("${E2SIM_ROOT}/src/E2AP/E2SM") -include_directories("${E2SIM_ROOT}/ASN1c") - - -#set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -set(THREADS_PREFER_PTHREAD_FLAG ON) - -find_library( SCTP_STD_LIB sctp ) #needed for sctp_sendmsgf -find_package( Threads REQUIRED ) - - -#---------------------------------------------- -file(GLOB RICSIM_SOURCES - - "${E2SIM_ROOT}/ricsim.cpp" - "${E2SIM_ROOT}/encode_e2apv1.cpp" - "${E2SIM_ROOT}/src/DEF/*.cpp" - "${E2SIM_ROOT}/src/SCTP/*.cpp" - "${E2SIM_ROOT}/src/E2APr/*.c" - "${E2SIM_ROOT}/src/E2APr/*.cpp" - "${E2SIM_ROOT}/ASN1c/*.c" - ) -add_executable(ricsim ${RICSIM_SOURCES}) -target_link_libraries( ricsim ${SCTP_STD_LIB} ) - diff --git a/e2sim/previous/e2apv1sim/ricsim/encode_e2apv1.cpp~ b/e2sim/previous/e2apv1sim/ricsim/encode_e2apv1.cpp~ deleted file mode 100644 index 7008f10..0000000 --- a/e2sim/previous/e2apv1sim/ricsim/encode_e2apv1.cpp~ +++ /dev/null @@ -1,1112 +0,0 @@ -#include -#include -#include -#include - -#include -#include - - -#include "encode_e2apv1.hpp" - -extern "C" { -#include "E2SM-KPM-RANfunction-Description.h" - -#include "e2ap_asn1c_codec.h" -#include "GlobalE2node-ID.h" -#include "GlobalE2node-gNB-ID.h" -#include "GlobalgNB-ID.h" -#include "OCTET_STRING.h" -#include "asn_application.h" -#include "GNB-ID-Choice.h" -#include "ProtocolIE-Field.h" -#include "E2setupRequest.h" -#include "RICaction-ToBeSetup-Item.h" -#include "RICactions-ToBeSetup-List.h" -#include "RICeventTriggerDefinition.h" -#include "RICsubscriptionRequest.h" -#include "RICsubscriptionResponse.h" -#include "ProtocolIE-SingleContainer.h" -#include "RANfunctions-List.h" -#include "RICindication.h" -#include "RICsubsequentActionType.h" -#include "RICsubsequentAction.h" -#include "RICtimeToWait.h" - -} - -long 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; - - RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array; - - fprintf(stderr, "count%d\n", count); - fprintf(stderr, "size%d\n", size); - - RICsubscriptionRequest_IEs__value_PR pres; - - long func_id; - - for (int i=0; i < count; i++) { - RICsubscriptionRequest_IEs_t *next_ie = ies[i]; - pres = next_ie->value.present; - - fprintf(stderr, "next present value %d\n", pres); - - if (pres == RICsubscriptionRequest_IEs__value_PR_RANfunctionID) { - func_id = next_ie->value.choice.RANfunctionID; - } - - } - - return func_id; - -} - -void generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, long ranFunctionId, uint8_t *ranFuncDescEncoded, int ranFuncLength) { - - // uint8_t *buf = (uint8_t *)"gnb1" - - BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; - gnb_bstring->buf = (uint8_t*)calloc(1,4); - gnb_bstring->size = 4; - gnb_bstring->buf[0] = 0xB5; - gnb_bstring->buf[1] = 0xC6; - gnb_bstring->buf[2] = 0x77; - gnb_bstring->buf[3] = 0x88; - - gnb_bstring->bits_unused = 3; - - uint8_t *buf2 = (uint8_t *)"747"; - OCTET_STRING_t *plmn = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); - plmn->buf = (uint8_t*)calloc(1,3); - memcpy(plmn->buf, buf2, 3); - plmn->size = 3; - - GNB_ID_Choice_t *gnbchoice = (GNB_ID_Choice_t*)calloc(1,sizeof(GNB_ID_Choice_t)); - GNB_ID_Choice_PR pres2 = GNB_ID_Choice_PR_gnb_ID; - gnbchoice->present = pres2; - gnbchoice->choice.gnb_ID = *gnb_bstring; - - GlobalgNB_ID_t *gnb = (GlobalgNB_ID_t*)calloc(1, sizeof(GlobalgNB_ID_t)); - gnb->plmn_id = *plmn; - gnb->gnb_id = *gnbchoice; - - GlobalE2node_gNB_ID_t *e2gnb = (GlobalE2node_gNB_ID_t*)calloc(1, sizeof(GlobalE2node_gNB_ID_t)); - e2gnb->global_gNB_ID = *gnb; - - GlobalE2node_ID_t *globale2nodeid = (GlobalE2node_ID_t*)calloc(1, sizeof(GlobalE2node_ID_t)); - GlobalE2node_ID_PR pres; - pres = GlobalE2node_ID_PR_gNB; - globale2nodeid->present = pres; - globale2nodeid->choice.gNB = e2gnb; - - E2setupRequestIEs_t *e2setuprid = (E2setupRequestIEs_t*)calloc(1, sizeof(E2setupRequestIEs_t)); - E2setupRequestIEs__value_PR pres3; - pres3 = E2setupRequestIEs__value_PR_GlobalE2node_ID; - e2setuprid->id = 3; - e2setuprid->criticality = 0; - e2setuprid->value.choice.GlobalE2node_ID = *globale2nodeid; - e2setuprid->value.present = pres3; - - - auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t)); - ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, ranFlistIEs); - ranFlistIEs->criticality = 0; - ranFlistIEs->id = ProtocolIE_ID_id_RANfunctionsAdded; - ranFlistIEs->value.present = E2setupRequestIEs__value_PR_RANfunctions_List; - - auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t)); - itemIes->id = ProtocolIE_ID_id_RANfunction_Item; - itemIes->criticality = Criticality_reject; - itemIes->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; - itemIes->value.choice.RANfunction_Item.ranFunctionID = ranFunctionId; - - E2SM_KPM_RANfunction_Description_t *ranfunc_desc = - (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); - encode_kpm_function_description(ranfunc_desc); - - uint8_t e2smbuffer[8192]; - size_t e2smbuffer_size = 8192; - - asn_codec_ctx_t *opt_cod; - - asn_enc_rval_t er = - asn_encode_to_buffer(opt_cod, - ATS_ALIGNED_BASIC_PER, - &asn_DEF_E2SM_KPM_RANfunction_Description, - ranfunc_desc, e2smbuffer, e2smbuffer_size); - - fprintf(stderr, "er encded is %d\n", er.encoded); - fprintf(stderr, "after encoding message\n"); - - OCTET_STRING_t *ranfuncdesc_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - // ranfuncdesc_str->buf = (uint8_t*)calloc(1,er.encoded); - ranfuncdesc_str->buf = (uint8_t*)calloc(1,ranFuncLength); - // ranfuncdesc_str->size = er.encoded; - ranfuncdesc_str->size = ranFuncLength; - // memcpy(ranfuncdesc_str->buf, e2smbuffer, er.encoded); - memcpy(ranfuncdesc_str->buf, ranFuncDescEncoded, ranFuncLength); - - - itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *ranfuncdesc_str; - itemIes->value.choice.RANfunction_Item.ranFunctionRevision = (long)2; - - ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes); - - E2setupRequest_t *e2setupreq = (E2setupRequest_t*)calloc(1, sizeof(E2setupRequest_t)); - ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, e2setuprid); - ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, ranFlistIEs); - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_E2setupRequest; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - - initmsg->procedureCode = ProcedureCode_id_E2setup; - initmsg->criticality = Criticality_reject; - initmsg->value.present = pres4; - initmsg->value.choice.E2setupRequest = *e2setupreq; - - E2AP_PDU_PR pres5; - pres5 = E2AP_PDU_PR_initiatingMessage; - - - e2ap_pdu->present = pres5; - e2ap_pdu->choice.initiatingMessage = initmsg; - -} - -void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) { - - // uint8_t *buf = (uint8_t *)"gnb1" - - BIT_STRING_t *gnb_bstring = (BIT_STRING_t*)calloc(1, sizeof(BIT_STRING_t));; - gnb_bstring->buf = (uint8_t*)calloc(1,4); - gnb_bstring->size = 4; - gnb_bstring->buf[0] = 0xB5; - gnb_bstring->buf[1] = 0xC6; - gnb_bstring->buf[2] = 0x77; - gnb_bstring->buf[3] = 0x88; - - gnb_bstring->bits_unused = 3; - - uint8_t *buf2 = (uint8_t *)"747"; - OCTET_STRING_t *plmn = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); - plmn->buf = (uint8_t*)calloc(1,3); - memcpy(plmn->buf, buf2, 3); - plmn->size = 3; - - GNB_ID_Choice_t *gnbchoice = (GNB_ID_Choice_t*)calloc(1,sizeof(GNB_ID_Choice_t)); - GNB_ID_Choice_PR pres2 = GNB_ID_Choice_PR_gnb_ID; - gnbchoice->present = pres2; - gnbchoice->choice.gnb_ID = *gnb_bstring; - - GlobalgNB_ID_t *gnb = (GlobalgNB_ID_t*)calloc(1, sizeof(GlobalgNB_ID_t)); - gnb->plmn_id = *plmn; - gnb->gnb_id = *gnbchoice; - - GlobalE2node_gNB_ID_t *e2gnb = (GlobalE2node_gNB_ID_t*)calloc(1, sizeof(GlobalE2node_gNB_ID_t)); - e2gnb->global_gNB_ID = *gnb; - - GlobalE2node_ID_t *globale2nodeid = (GlobalE2node_ID_t*)calloc(1, sizeof(GlobalE2node_ID_t)); - GlobalE2node_ID_PR pres; - pres = GlobalE2node_ID_PR_gNB; - globale2nodeid->present = pres; - globale2nodeid->choice.gNB = e2gnb; - - E2setupRequestIEs_t *e2setuprid = (E2setupRequestIEs_t*)calloc(1, sizeof(E2setupRequestIEs_t)); - E2setupRequestIEs__value_PR pres3; - pres3 = E2setupRequestIEs__value_PR_GlobalE2node_ID; - e2setuprid->id = 3; - e2setuprid->criticality = 0; - e2setuprid->value.choice.GlobalE2node_ID = *globale2nodeid; - e2setuprid->value.present = pres3; - - - auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t)); - ASN_STRUCT_RESET(asn_DEF_E2setupRequestIEs, ranFlistIEs); - ranFlistIEs->criticality = 0; - ranFlistIEs->id = ProtocolIE_ID_id_RANfunctionsAdded; - ranFlistIEs->value.present = E2setupRequestIEs__value_PR_RANfunctions_List; - - auto *itemIes = (RANfunction_ItemIEs_t *)calloc(1, sizeof(RANfunction_ItemIEs_t)); - itemIes->id = 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; - - E2SM_KPM_RANfunction_Description_t *ranfunc_desc = - (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); - encode_kpm_function_description(ranfunc_desc); - - uint8_t e2smbuffer[8192]; - size_t e2smbuffer_size = 8192; - - asn_codec_ctx_t *opt_cod; - - asn_enc_rval_t er = - asn_encode_to_buffer(opt_cod, - ATS_ALIGNED_BASIC_PER, - &asn_DEF_E2SM_KPM_RANfunction_Description, - ranfunc_desc, e2smbuffer, e2smbuffer_size); - - fprintf(stderr, "er encded is %d\n", er.encoded); - fprintf(stderr, "after encoding message\n"); - - OCTET_STRING_t *ranfuncdesc_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - ranfuncdesc_str->buf = (uint8_t*)calloc(1,er.encoded); - ranfuncdesc_str->size = er.encoded; - memcpy(ranfuncdesc_str->buf, e2smbuffer, er.encoded); - - - itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *ranfuncdesc_str; - itemIes->value.choice.RANfunction_Item.ranFunctionRevision = (long)2; - - ASN_SEQUENCE_ADD(&ranFlistIEs->value.choice.RANfunctions_List.list, itemIes); - - E2setupRequest_t *e2setupreq = (E2setupRequest_t*)calloc(1, sizeof(E2setupRequest_t)); - ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, e2setuprid); - ASN_SEQUENCE_ADD(&e2setupreq->protocolIEs.list, ranFlistIEs); - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_E2setupRequest; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - - initmsg->procedureCode = ProcedureCode_id_E2setup; - initmsg->criticality = Criticality_reject; - initmsg->value.present = pres4; - initmsg->value.choice.E2setupRequest = *e2setupreq; - - E2AP_PDU_PR pres5; - pres5 = E2AP_PDU_PR_initiatingMessage; - - - e2ap_pdu->present = pres5; - e2ap_pdu->choice.initiatingMessage = initmsg; - -} - - -void generate_e2apv1_setup_response(E2AP_PDU_t *e2ap_pdu) { - - E2setupResponseIEs *resp_ies1 = (E2setupResponseIEs_t*)calloc(1, sizeof(E2setupResponseIEs_t)); - E2setupResponseIEs *resp_ies2 = (E2setupResponseIEs_t*)calloc(1, sizeof(E2setupResponseIEs_t)); - E2setupResponseIEs *resp_ies3 = (E2setupResponseIEs_t*)calloc(1, sizeof(E2setupResponseIEs_t)); - - uint8_t *buf = (uint8_t *)"gnb1"; - - BIT_STRING_t *ricid_bstring = (BIT_STRING_t*)calloc(1,sizeof(BIT_STRING_t)); - ricid_bstring->buf = buf; - ricid_bstring->size = 4; - ricid_bstring->bits_unused = 0; - - uint8_t *buf2 = (uint8_t *)"plmn3"; - OCTET_STRING_t *plmn = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - plmn->buf = buf2; - plmn->size = 5; - - GlobalRIC_ID_t *globalricid = (GlobalRIC_ID_t*)calloc(1,sizeof(GlobalRIC_ID_t)); - globalricid->pLMN_Identity = *plmn; - globalricid->ric_ID = *ricid_bstring; - - E2setupResponseIEs__value_PR pres1; - pres1 = E2setupResponseIEs__value_PR_GlobalRIC_ID; - - resp_ies1->id = ProtocolIE_ID_id_GlobalRIC_ID; - resp_ies1->criticality = 0; - resp_ies1->value.present = pres1; - resp_ies1->value.choice.GlobalRIC_ID = *globalricid; - - E2setupResponse_t *e2setupresp = (E2setupResponse_t*)calloc(1,sizeof(E2setupResponse_t)); - int ret = ASN_SEQUENCE_ADD(&e2setupresp->protocolIEs.list, resp_ies1); - - - SuccessfulOutcome__value_PR pres; - pres = SuccessfulOutcome__value_PR_E2setupResponse; - SuccessfulOutcome_t *successoutcome = (SuccessfulOutcome_t*)calloc(1, sizeof(SuccessfulOutcome_t)); - successoutcome->procedureCode = 1; - successoutcome->criticality = 0; - successoutcome->value.present = pres; - successoutcome->value.choice.E2setupResponse = *e2setupresp; - - E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome; - - e2ap_pdu->present = pres5; - e2ap_pdu->choice.successfulOutcome = successoutcome; - -} - - -void generate_e2apv1_subscription_request(E2AP_PDU *e2ap_pdu) { - - fprintf(stderr, "in sub 1\n"); - RICsubscriptionRequest_IEs_t *ricreqid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t)); - fprintf(stderr, "in sub 2\n"); - ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ricreqid); - - - RICsubscriptionRequest_IEs_t *ranfuncid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t)); - fprintf(stderr, "in sub 2\n"); - ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ranfuncid); - - - fprintf(stderr, "in sub 3\n"); - auto *ricsubrid = (RICsubscriptionRequest_IEs_t*)calloc(1, sizeof(RICsubscriptionRequest_IEs_t)); - fprintf(stderr, "in sub 4\n"); - ASN_STRUCT_RESET(asn_DEF_RICsubscriptionRequest_IEs, ricsubrid); - - fprintf(stderr, "in generate sub\n"); - uint8_t *buf2 = (uint8_t *)"SubscriptionTriggers"; - fprintf(stderr, "in gen sub 1\n"); - OCTET_STRING_t *triggerdef = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); - triggerdef->buf = (uint8_t *)calloc(1,20); - triggerdef->size = 20; - memcpy(triggerdef->buf, buf2, triggerdef->size); - - - fprintf(stderr, "sub1\n"); - ProtocolIE_ID_t proto_id= ProtocolIE_ID_id_RICaction_ToBeSetup_Item; - - RICaction_ToBeSetup_ItemIEs__value_PR pres6; - pres6 = RICaction_ToBeSetup_ItemIEs__value_PR_RICaction_ToBeSetup_Item; - - printf("sub2\n"); - - uint8_t *buf5 = (uint8_t *)"ActionDef"; - - OCTET_STRING_t *actdef = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); - actdef->buf = (uint8_t *)calloc(1,9); - actdef->size = 9; - memcpy(triggerdef->buf, buf5, 9); - - auto *sa = (RICsubsequentAction_t *) calloc(1, sizeof(RICsubsequentAction_t)); - ASN_STRUCT_RESET(asn_DEF_RICsubsequentAction, sa); - - sa->ricTimeToWait = RICtimeToWait_w500ms; - sa->ricSubsequentActionType = RICsubsequentActionType_continue; - - /* - RICaction_ToBeSetup_Item_t *action_item = (RICaction_ToBeSetup_Item_t*)calloc(1, sizeof(RICaction_ToBeSetup_Item_t)); - action_item->ricActionID = 5; - action_item->ricActionType = 9; - action_item->ricActionDefinition = actdef; - action_item->ricSubsequentAction = sa; - */ - printf("sub3\n"); - - RICaction_ToBeSetup_ItemIEs_t *action_item_ies = (RICaction_ToBeSetup_ItemIEs_t *)calloc(1, sizeof(RICaction_ToBeSetup_Item_t)); - action_item_ies->id = proto_id; - action_item_ies->criticality = 0; - - action_item_ies->value.present = pres6; - action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricActionID = 5; - action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricActionType = RICactionType_report; - action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricActionDefinition = actdef; - action_item_ies->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = sa; - - - printf("sub5\n"); - /* - RICsubscriptionDetails_t *ricsubdetails = (RICsubscriptionDetails_t*)calloc(1, sizeof(RICsubscriptionDetails_t)); - printf("sub5.5\n"); - - ASN_SEQUENCE_ADD(&ricsubdetails->ricAction_ToBeSetup_List.list, action_item_ies); - ricsubdetails->ricEventTriggerDefinition = *triggerdef; - - printf("sub6\n"); - */ - - ranfuncid->id = ProtocolIE_ID_id_RICsubscriptionDetails;; - ranfuncid->criticality = 0; - ranfuncid->value.present = RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails; - ranfuncid->value.choice.RANfunctionID = 1; - - - RICsubscriptionRequest_IEs__value_PR pres3; - printf("sub6.1\n"); - pres3 = RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails; - ricsubrid->id = ProtocolIE_ID_id_RICsubscriptionDetails; - printf("sub6.2\n"); - - ricsubrid->criticality = 0; - ricsubrid->value.present = pres3; - printf("sub6.3\n"); - - ricsubrid->value.choice.RICsubscriptionDetails.ricEventTriggerDefinition = *triggerdef; - printf("sub6.4\n"); - - ASN_SEQUENCE_ADD(&ricsubrid->value.choice.RICsubscriptionDetails.ricAction_ToBeSetup_List.list, action_item_ies); - - printf("sub7\n"); - - - ricreqid->id = ProtocolIE_ID_id_RICrequestID; - ricreqid->criticality = 0; - ricreqid->value.present = RICsubscriptionRequest_IEs__value_PR_RICrequestID; - ricreqid->value.choice.RICrequestID.ricRequestorID = 22; - ricreqid->value.choice.RICrequestID.ricInstanceID = 6; - - RICsubscriptionRequest_t *ricsubreq = (RICsubscriptionRequest_t*)calloc(1, sizeof(RICsubscriptionRequest_t)); - - ASN_SEQUENCE_ADD(&ricsubreq->protocolIEs.list,ricreqid); - ASN_SEQUENCE_ADD(&ricsubreq->protocolIEs.list,ricsubrid); - ASN_SEQUENCE_ADD(&ricsubreq->protocolIEs.list,ranfuncid); - - - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_RICsubscriptionRequest; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - initmsg->procedureCode = ProcedureCode_id_RICsubscription; - initmsg->criticality = Criticality_reject; - initmsg->value.present = pres4; - initmsg->value.choice.RICsubscriptionRequest = *ricsubreq; - - 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; - - asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); - printf("error length %d\n", errlen); - printf("error buf %s\n", error_buf); - - // xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); - -} - -void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqActionIdsAccepted[], - long reqActionIdsRejected[], int accept_size, int reject_size, - long reqRequestorId, long reqInstanceId) { - - RICsubscriptionResponse_IEs_t *respricreqid = - (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - - respricreqid->id = ProtocolIE_ID_id_RICrequestID; - respricreqid->criticality = 0; - respricreqid->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID; - respricreqid->value.choice.RICrequestID.ricRequestorID = reqRequestorId; - - respricreqid->value.choice.RICrequestID.ricInstanceID = reqInstanceId; - - - RICsubscriptionResponse_IEs_t *ricactionadmitted = - (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - ricactionadmitted->id = ProtocolIE_ID_id_RICactions_Admitted; - ricactionadmitted->criticality = 0; - ricactionadmitted->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List; - - RICaction_Admitted_List_t* admlist = - (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t)); - ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist; - - // int numAccept = sizeof(reqActionIdsAccepted); - int numAccept = accept_size; - int numReject = reject_size; - // int numReject = sizeof(reqActionIdsRejected); - - - for (int i=0; i < numAccept ; i++) { - fprintf(stderr, "in for loop i = %d\n", i); - - long aid = reqActionIdsAccepted[i]; - - RICaction_Admitted_ItemIEs_t *admitie = (RICaction_Admitted_ItemIEs_t*)calloc(1,sizeof(RICaction_Admitted_ItemIEs_t)); - admitie->id = ProtocolIE_ID_id_RICaction_Admitted_Item; - admitie->criticality = 0; - admitie->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item; - admitie->value.choice.RICaction_Admitted_Item.ricActionID = aid; - - ASN_SEQUENCE_ADD(&ricactionadmitted->value.choice.RICaction_Admitted_List.list, admitie); - - } - - RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t)); - ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid); - ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted); - - - if (numReject > 0) { - - RICsubscriptionResponse_IEs_t *ricactionrejected = - (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - ricactionrejected->id = ProtocolIE_ID_id_RICactions_NotAdmitted; - ricactionrejected->criticality = 0; - ricactionrejected->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List; - - RICaction_NotAdmitted_List_t* rejectlist = - (RICaction_NotAdmitted_List_t*)calloc(1,sizeof(RICaction_NotAdmitted_List_t)); - ricactionadmitted->value.choice.RICaction_NotAdmitted_List = *rejectlist; - - for (int i=0; i < numReject; i++) { - fprintf(stderr, "in for loop i = %d\n", i); - - long aid = reqActionIdsRejected[i]; - - RICaction_NotAdmitted_ItemIEs_t *noadmitie = (RICaction_NotAdmitted_ItemIEs_t*)calloc(1,sizeof(RICaction_NotAdmitted_ItemIEs_t)); - noadmitie->id = ProtocolIE_ID_id_RICaction_NotAdmitted_Item; - noadmitie->criticality = 0; - noadmitie->value.present = RICaction_NotAdmitted_ItemIEs__value_PR_RICaction_NotAdmitted_Item; - noadmitie->value.choice.RICaction_NotAdmitted_Item.ricActionID = aid; - - ASN_SEQUENCE_ADD(&ricactionrejected->value.choice.RICaction_NotAdmitted_List.list, noadmitie); - ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionrejected); - } - } - - - SuccessfulOutcome__value_PR pres2; - pres2 = SuccessfulOutcome__value_PR_RICsubscriptionResponse; - SuccessfulOutcome_t *successoutcome = (SuccessfulOutcome_t*)calloc(1, sizeof(SuccessfulOutcome_t)); - successoutcome->procedureCode = ProcedureCode_id_RICsubscription; - successoutcome->criticality = 0; - successoutcome->value.present = pres2; - successoutcome->value.choice.RICsubscriptionResponse = *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; - - asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); - printf("error length %d\n", errlen); - printf("error buf %s\n", error_buf); - - -} - -void generate_e2apv1_subscription_response(E2AP_PDU *e2ap_pdu, E2AP_PDU *sub_req_pdu) { - - //Gather details of the request - - RICsubscriptionRequest_t orig_req = - sub_req_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; - - RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array; - - fprintf(stderr, "count%d\n", count); - fprintf(stderr, "size%d\n", size); - - RICsubscriptionRequest_IEs__value_PR pres; - - long responseRequestorId; - long responseInstanceId; - long responseActionId; - - std::vector actionIds; - - for (int i=0; i < count; i++) { - RICsubscriptionRequest_IEs_t *next_ie = ies[i]; - pres = next_ie->value.present; - - fprintf(stderr, "next present value %d\n", pres); - - switch(pres) { - case RICsubscriptionRequest_IEs__value_PR_RICrequestID: - { - RICrequestID_t reqId = next_ie->value.choice.RICrequestID; - long requestorId = reqId.ricRequestorID; - long instanceId = reqId.ricInstanceID; - fprintf(stderr, "requestorId %d\n", requestorId); - fprintf(stderr, "instanceId %d\n", instanceId); - responseRequestorId = requestorId; - responseInstanceId = instanceId; - - break; - } - case RICsubscriptionRequest_IEs__value_PR_RANfunctionID: - break; - case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails: - { - RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; - RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition; - RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List; - - int actionCount = actionList.list.count; - fprintf(stderr, "action count%d\n", actionCount); - - auto **item_array = actionList.list.array; - - for (int i=0; i < actionCount; i++) { - //RICaction_ToBeSetup_Item_t - auto *next_item = item_array[i]; - RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID; - fprintf(stderr, "Next Action ID %ld\n", actionId); - responseActionId = actionId; - actionIds.push_back(responseActionId); - } - - break; - } - } - - } - - fprintf(stderr, "After Processing Subscription Request\n"); - - fprintf(stderr, "requestorId %d\n", responseRequestorId); - fprintf(stderr, "instanceId %d\n", responseInstanceId); - - - for (int i=0; i < actionIds.size(); i++) { - fprintf(stderr, "Action ID %d %ld\n", i, actionIds.at(i)); - - } - - - RICsubscriptionResponse_IEs_t *respricreqid = - (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - - respricreqid->id = ProtocolIE_ID_id_RICrequestID; - respricreqid->criticality = 0; - respricreqid->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID; - respricreqid->value.choice.RICrequestID.ricRequestorID = responseRequestorId; - - respricreqid->value.choice.RICrequestID.ricInstanceID = responseInstanceId; - - - RICsubscriptionResponse_IEs_t *ricactionadmitted = - (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - ricactionadmitted->id = ProtocolIE_ID_id_RICactions_Admitted; - ricactionadmitted->criticality = 0; - ricactionadmitted->value.present = RICsubscriptionResponse_IEs__value_PR_RICaction_Admitted_List; - - RICaction_Admitted_List_t* admlist = - (RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t)); - ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist; - - for (int i=0; i < actionIds.size(); i++) { - fprintf(stderr, "in for loop i = %d\n", i); - - long aid = actionIds.at(i); - - RICaction_Admitted_ItemIEs_t *admitie = (RICaction_Admitted_ItemIEs_t*)calloc(1,sizeof(RICaction_Admitted_ItemIEs_t)); - admitie->id = ProtocolIE_ID_id_RICaction_Admitted_Item; - admitie->criticality = 0; - admitie->value.present = RICaction_Admitted_ItemIEs__value_PR_RICaction_Admitted_Item; - admitie->value.choice.RICaction_Admitted_Item.ricActionID = aid; - - ASN_SEQUENCE_ADD(&ricactionadmitted->value.choice.RICaction_Admitted_List.list, admitie); - - } - - - RICsubscriptionResponse_t *ricsubresp = (RICsubscriptionResponse_t*)calloc(1,sizeof(RICsubscriptionResponse_t)); - - ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, respricreqid); - ASN_SEQUENCE_ADD(&ricsubresp->protocolIEs.list, ricactionadmitted); - - - SuccessfulOutcome__value_PR pres2; - pres2 = SuccessfulOutcome__value_PR_RICsubscriptionResponse; - SuccessfulOutcome_t *successoutcome = (SuccessfulOutcome_t*)calloc(1, sizeof(SuccessfulOutcome_t)); - successoutcome->procedureCode = ProcedureCode_id_RICsubscription; - successoutcome->criticality = 0; - successoutcome->value.present = pres2; - successoutcome->value.choice.RICsubscriptionResponse = *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; - - asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); - printf("error length %d\n", errlen); - printf("error buf %s\n", error_buf); - -} - -void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, - long requestorId, - long instanceId, - long ranFunctionId, - long actionId, - long seqNum, - uint8_t *ind_header_buf, - int header_length, - uint8_t *ind_message_buf, - int message_length) { - - fprintf(stderr, "ind1\n"); - RICindication_IEs_t *ricind_ies = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies2 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies3 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies4 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies5 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies6 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies7 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies8 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - - RICindication_IEs__value_PR pres3; - - pres3 = RICindication_IEs__value_PR_RICrequestID; - ricind_ies->id = ProtocolIE_ID_id_RICrequestID; - ricind_ies->criticality = 0; - ricind_ies->value.present = pres3; - ricind_ies->value.choice.RICrequestID.ricRequestorID = requestorId; - ricind_ies->value.choice.RICrequestID.ricInstanceID = instanceId; - - fprintf(stderr, "ind2\n"); - - pres3 = RICindication_IEs__value_PR_RANfunctionID; - ricind_ies2->id = ProtocolIE_ID_id_RANfunctionID; - ricind_ies2->criticality = 0; - ricind_ies2->value.present = pres3; - ricind_ies2->value.choice.RANfunctionID = ranFunctionId; - - - ricind_ies3->id = ProtocolIE_ID_id_RICactionID; - ricind_ies3->criticality = 0; - pres3 = RICindication_IEs__value_PR_RICactionID; - ricind_ies3->value.present = pres3; - ricind_ies3->value.choice.RICactionID = actionId; - - - pres3 = RICindication_IEs__value_PR_RICindicationSN; - ricind_ies4->id = ProtocolIE_ID_id_RICindicationSN; - ricind_ies4->criticality = 0; - ricind_ies4->value.present = pres3; - ricind_ies4->value.choice.RICindicationSN = seqNum; - - //Indication type is REPORT - pres3 = RICindication_IEs__value_PR_RICindicationType; - ricind_ies5->id = ProtocolIE_ID_id_RICindicationType; - ricind_ies5->criticality = 0; - 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); - - pres3 = RICindication_IEs__value_PR_RICindicationHeader; - ricind_ies6->id = ProtocolIE_ID_id_RICindicationHeader; - ricind_ies6->criticality = 0; - ricind_ies6->value.present = pres3; - ricind_ies6->value.choice.RICindicationHeader.size = header_length; - memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, ind_header_buf, header_length); - - ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192); - - - - - pres3 = RICindication_IEs__value_PR_RICindicationMessage; - ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage; - fprintf(stderr, "after encoding message 1\n"); - - ricind_ies7->criticality = 0; - ricind_ies7->value.present = pres3; - - fprintf(stderr, "after encoding message 2\n"); - - fprintf(stderr, "after encoding message 3\n"); - ricind_ies7->value.choice.RICindicationMessage.size = message_length; - - fprintf(stderr, "after encoding message 4\n"); - memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, ind_message_buf, message_length); - - fprintf(stderr, "after encoding message 5\n"); - - uint8_t *cpid_buf = (uint8_t *)"cpid"; - OCTET_STRING_t cpid_str; - - printf("5.1\n"); - - int cpid_buf_len = strlen((char*)cpid_buf); - pres3 = RICindication_IEs__value_PR_RICcallProcessID; - ricind_ies8->id = ProtocolIE_ID_id_RICcallProcessID; - - ricind_ies8->criticality = 0; - ricind_ies8->value.present = pres3; - - ricind_ies8->value.choice.RICcallProcessID.buf = (uint8_t*)calloc(1,cpid_buf_len); - ricind_ies8->value.choice.RICcallProcessID.size = cpid_buf_len; - - memcpy(ricind_ies8->value.choice.RICcallProcessID.buf, cpid_buf, cpid_buf_len); - - printf("5.2\n"); - - RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t)); - - - int ret; - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2); - - printf("5.3\n"); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3); - - printf("5.35\n"); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4); - - printf("5.36\n"); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5); - - printf("5.4\n"); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6); - - printf("5.5\n"); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); - - // ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); - - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_RICindication; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - initmsg->procedureCode = 5; - initmsg->criticality = 1; - initmsg->value.present = pres4; - initmsg->value.choice.RICindication = *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; - - asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); - printf("error length %d\n", errlen); - printf("error buf %s\n", error_buf); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); - -} - -void generate_e2apv1_indication_request(E2AP_PDU *e2ap_pdu) { - fprintf(stderr, "ind1\n"); - RICindication_IEs_t *ricind_ies = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies2 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies3 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies4 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies5 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies6 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies7 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - RICindication_IEs_t *ricind_ies8 = (RICindication_IEs_t*)calloc(1, sizeof(RICindication_IEs_t)); - - RICindication_IEs__value_PR pres3; - - pres3 = RICindication_IEs__value_PR_RICrequestID; - ricind_ies->id = ProtocolIE_ID_id_RICrequestID; - ricind_ies->criticality = 0; - ricind_ies->value.present = pres3; - ricind_ies->value.choice.RICrequestID.ricRequestorID = 25; - ricind_ies->value.choice.RICrequestID.ricInstanceID = 3; - - fprintf(stderr, "ind2\n"); - - pres3 = RICindication_IEs__value_PR_RANfunctionID; - ricind_ies2->id = ProtocolIE_ID_id_RANfunctionID; - ricind_ies2->criticality = 0; - ricind_ies2->value.present = pres3; - ricind_ies2->value.choice.RANfunctionID = 70; - - - ricind_ies3->id = ProtocolIE_ID_id_RICactionID; - ricind_ies3->criticality = 0; - pres3 = RICindication_IEs__value_PR_RICactionID; - ricind_ies3->value.present = pres3; - ricind_ies3->value.choice.RICactionID = 80; - - - pres3 = RICindication_IEs__value_PR_RICindicationSN; - ricind_ies4->id = ProtocolIE_ID_id_RICindicationSN; - ricind_ies4->criticality = 0; - ricind_ies4->value.present = pres3; - ricind_ies4->value.choice.RICindicationSN = 45; - - pres3 = RICindication_IEs__value_PR_RICindicationType; - ricind_ies5->id = ProtocolIE_ID_id_RICindicationType; - ricind_ies5->criticality = 0; - 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,12); - hdr_str->size = 12; - memcpy(hdr_str->buf, buf2, 12); - - fprintf(stderr, "ind3\n"); - - ricind_ies6->value.choice.RICindicationHeader.buf = (uint8_t*)calloc(1,12); - - pres3 = RICindication_IEs__value_PR_RICindicationHeader; - ricind_ies6->id = ProtocolIE_ID_id_RICindicationHeader; - ricind_ies6->criticality = 0; - ricind_ies6->value.present = pres3; - ricind_ies6->value.choice.RICindicationHeader.size = 12; - memcpy(ricind_ies6->value.choice.RICindicationHeader.buf, buf2, 12); - - ricind_ies7->value.choice.RICindicationMessage.buf = (uint8_t*)calloc(1,8192); - // uint8_t *buf9 = (uint8_t *)"reportmsg"; - - /* - E2SM_KPM_IndicationMessage_t *e2sm_ind_msg = - (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t)); - - encode_kpm(e2sm_ind_msg); - */ - - E2SM_KPM_RANfunction_Description_t *e2sm_desc = - (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); - - encode_kpm_function_description(e2sm_desc); - - - uint8_t e2smbuffer[8192]; - size_t e2smbuffer_size = 8192; - - asn_codec_ctx_t *opt_cod; - - - asn_enc_rval_t er = - asn_encode_to_buffer(opt_cod, - ATS_ALIGNED_BASIC_PER, - &asn_DEF_E2SM_KPM_RANfunction_Description, - e2sm_desc, e2smbuffer, e2smbuffer_size); - - /* - asn_encode_to_buffer(opt_cod, - ATS_ALIGNED_BASIC_PER, - &asn_DEF_E2SM_KPM_IndicationMessage, - e2sm_ind_msg, e2smbuffer, e2smbuffer_size); - */ - - - - fprintf(stderr, "er encded is %d\n", er.encoded); - fprintf(stderr, "after encoding message\n"); - - OCTET_STRING_t *msg_str = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t)); - msg_str->buf = (uint8_t*)calloc(1,er.encoded); - msg_str->size = er.encoded; - memcpy(msg_str->buf, e2smbuffer, er.encoded); - - - pres3 = RICindication_IEs__value_PR_RICindicationMessage; - ricind_ies7->id = ProtocolIE_ID_id_RICindicationMessage; - fprintf(stderr, "after encoding message 1\n"); - - ricind_ies7->criticality = 0; - ricind_ies7->value.present = pres3; - - fprintf(stderr, "after encoding message 2\n"); - - fprintf(stderr, "after encoding message 3\n"); - ricind_ies7->value.choice.RICindicationMessage.size = er.encoded; - - fprintf(stderr, "after encoding message 4\n"); - memcpy(ricind_ies7->value.choice.RICindicationMessage.buf, e2smbuffer, er.encoded); - - fprintf(stderr, "after encoding message 5\n"); - - uint8_t *buf4 = (uint8_t *)"cpid"; - OCTET_STRING_t cpid_str; - cpid_str.buf = buf4; - cpid_str.size = 4; - - - pres3 = RICindication_IEs__value_PR_RICcallProcessID; - ricind_ies8->id = ProtocolIE_ID_id_RICcallProcessID; - - ricind_ies8->criticality = 0; - ricind_ies8->value.present = pres3; - - ricind_ies8->value.choice.RICcallProcessID = cpid_str; - - - RICindication_t *ricindication = (RICindication_t*)calloc(1, sizeof(RICindication_t)); - - - int ret; - /* - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies2); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies3); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies4); - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies5); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies6); - */ - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies7); - - ret = ASN_SEQUENCE_ADD(&ricindication->protocolIEs.list, ricind_ies8); - - - InitiatingMessage__value_PR pres4; - pres4 = InitiatingMessage__value_PR_RICindication; - InitiatingMessage_t *initmsg = (InitiatingMessage_t*)calloc(1, sizeof(InitiatingMessage_t)); - initmsg->procedureCode = 5; - initmsg->criticality = 1; - initmsg->value.present = pres4; - initmsg->value.choice.RICindication = *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; - - asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen); - printf("error length %d\n", errlen); - printf("error buf %s\n", error_buf); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, e2ap_pdu); -} - - -void generate_e2apv1_indication_response(E2AP_PDU *e2ap_pdu) { - - -} diff --git a/e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.cpp~ b/e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.cpp~ deleted file mode 100644 index f12b09e..0000000 --- a/e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.cpp~ +++ /dev/null @@ -1,267 +0,0 @@ - - -/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# Copyright 2019 Nokia * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -******************************************************************************/ -#include "e2ap_message_handler.hpp" - -//#include -//#include - -#include "encode_e2apv1.hpp" -#include "kpm_callbacks.hpp" - -#include - -void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc) -{ - fprintf(stderr, "in e2ap_handle_sctp_data()\n"); - //decode the data into E2AP-PDU - E2AP_PDU_t* pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU)); - ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu); - - fprintf(stderr, "decoding...\n"); - - asn_transfer_syntax syntax; - - - syntax = ATS_ALIGNED_BASIC_PER; - - - fprintf(stderr, "full buffer\n%s\n", data.buffer); - // e2ap_asn1c_decode_pdu(pdu, data.buffer, data.len); - - auto rval = asn_decode(nullptr, syntax, &asn_DEF_E2AP_PDU, (void **) &pdu, - data.buffer, data.len); - - - int index = (int)pdu->present; - fprintf(stderr, "length of data %d\n", rval.consumed); - fprintf(stderr, "result %d\n", rval.code); - fprintf(stderr, "index is %d\n", index); - - fprintf(stderr, "showing xer of data\n"); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu); - - int procedureCode = e2ap_asn1c_get_procedureCode(pdu); - index = (int)pdu->present; - - LOG_D("[E2AP] Unpacked E2AP-PDU: index = %d, procedureCode = %d\n", - index, procedureCode); - - switch(procedureCode) - { - - case ProcedureCode_id_E2setup: - switch(index) - { - case E2AP_PDU_PR_initiatingMessage: - e2ap_handle_E2SetupRequest(pdu, socket_fd); - LOG_I("[E2AP] Received SETUP-REQUEST"); - break; - - case E2AP_PDU_PR_successfulOutcome: - LOG_I("[E2AP] Received SETUP-RESPONSE-SUCCESS"); - break; - - case E2AP_PDU_PR_unsuccessfulOutcome: - LOG_I("[E2AP] Received SETUP-RESPONSE-FAILURE"); - break; - - default: - LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index); - break; - } - break; - - case ProcedureCode_id_Reset: //reset = 7 - switch(index) - { - case E2AP_PDU_PR_initiatingMessage: - LOG_I("[E2AP] Received RESET-REQUEST"); - break; - - case E2AP_PDU_PR_successfulOutcome: - break; - - case E2AP_PDU_PR_unsuccessfulOutcome: - break; - - default: - LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index); - break; - } - break; - - case ProcedureCode_id_RICindication: // 205 - switch(index) - { - case E2AP_PDU_PR_initiatingMessage: //initiatingMessage - LOG_I("[E2AP] Received RIC-INDICATION-REQUEST"); - // e2ap_handle_RICSubscriptionRequest(pdu, socket_fd); - break; - case E2AP_PDU_PR_successfulOutcome: - LOG_I("[E2AP] Received RIC-INDICATION-RESPONSE"); - break; - - case E2AP_PDU_PR_unsuccessfulOutcome: - LOG_I("[E2AP] Received RIC-INDICATION-FAILURE"); - break; - - default: - LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index, - (int)ProcedureCode_id_RICindication); - break; - } - break; - - default: - - LOG_E("[E2AP] No available handler for procedureCode=%d", procedureCode); - - break; - } -} - -void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd) { - - - E2AP_PDU_t* res_pdu = (E2AP_PDU_t*)calloc(1, sizeof(E2AP_PDU)); - generate_e2apv1_setup_response(res_pdu); - - - LOG_D("[E2AP] Created E2-SETUP-RESPONSE"); - - e2ap_asn1c_print_pdu(res_pdu); - - - auto buffer_size = MAX_SCTP_BUFFER; - unsigned char buffer[MAX_SCTP_BUFFER]; - - sctp_buffer_t data; - auto er = asn_encode_to_buffer(nullptr, ATS_BASIC_XER, &asn_DEF_E2AP_PDU, res_pdu, buffer, buffer_size); - - data.len = er.encoded; - fprintf(stderr, "er encoded is %d\n", er.encoded); - - //data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf); - memcpy(data.buffer, buffer, er.encoded); - - //send response data over sctp - if(sctp_send_data(socket_fd, data) > 0) { - LOG_I("[SCTP] Sent E2-SETUP-RESPONSE"); - } else { - LOG_E("[SCTP] Unable to send E2-SETUP-RESPONSE to peer"); - } - - sleep(5); - - //Sending Subscription Request - - E2AP_PDU_t* pdu_sub = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); - - generate_e2apv1_subscription_request(pdu_sub); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_sub); - - auto buffer_size2 = MAX_SCTP_BUFFER; - unsigned char buffer2[MAX_SCTP_BUFFER]; - - sctp_buffer_t data2; - - auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_sub, buffer2, buffer_size2); - - data2.len = er2.encoded; - memcpy(data2.buffer, buffer2, er2.encoded); - - fprintf(stderr, "er encded is %d\n", er2.encoded); - - if(sctp_send_data(socket_fd, data2) > 0) { - LOG_I("[SCTP] Sent E2-SUBSCRIPTION-REQUEST"); - } else { - LOG_E("[SCTP] Unable to send E2-SUBSCRIPTION-REQUEST to peer"); - } - - -} - - -void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd) -{ - - //Send back Subscription Success Response - - E2AP_PDU_t* pdu_resp = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); - - generate_e2apv1_subscription_response(pdu_resp, pdu); - - fprintf(stderr, "Subscription Response\n"); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_resp); - - auto buffer_size2 = MAX_SCTP_BUFFER; - unsigned char buffer2[MAX_SCTP_BUFFER]; - - sctp_buffer_t data2; - - auto er2 = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_resp, buffer2, buffer_size2); - data2.len = er2.encoded; - - fprintf(stderr, "er encded is %d\n", er2.encoded); - - memcpy(data2.buffer, buffer2, er2.encoded); - - if(sctp_send_data(socket_fd, data2) > 0) { - LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE"); - } else { - LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer"); - } - - - //Send back an Indication - - E2AP_PDU_t* pdu_ind = (E2AP_PDU_t*)calloc(1,sizeof(E2AP_PDU)); - - generate_e2apv1_indication_request(pdu_ind); - - xer_fprint(stderr, &asn_DEF_E2AP_PDU, pdu_ind); - - auto buffer_size = MAX_SCTP_BUFFER; - unsigned char buffer[MAX_SCTP_BUFFER]; - - sctp_buffer_t data; - - auto er = asn_encode_to_buffer(nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, pdu_ind, buffer, buffer_size); - data.len = er.encoded; - - fprintf(stderr, "er encded is %d\n", er.encoded); - - memcpy(data.buffer, buffer, er.encoded); - - if(sctp_send_data(socket_fd, data) > 0) { - LOG_I("[SCTP] Sent RIC-INDICATION-REQUEST"); - } else { - LOG_E("[SCTP] Unable to send RIC-INDICATION-REQUEST to peer"); - } - -} - - - - diff --git a/e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.hpp~ b/e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.hpp~ deleted file mode 100644 index 5d93836..0000000 --- a/e2sim/previous/e2apv1sim/ricsim/src/E2APr/e2ap_message_handler.hpp~ +++ /dev/null @@ -1,47 +0,0 @@ -/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# Copyright 2019 Nokia * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -******************************************************************************/ -#ifndef E2AP_MESSAGE_HANDLER_HPP -#define E2AP_MESSAGE_HANDLER_HPP - - -#include "e2sim_sctp.hpp" - - -extern "C" { - #include "e2sim_defs.h" - #include "e2ap_asn1c_codec.h" -} - -void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data, bool xmlenc, E2Sim *e2sim); - -void e2ap_handle_X2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_X2SetupResponse(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_ENDCX2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_E2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_RICSubscriptionRequest_securityDemo(E2AP_PDU_t* pdu, int &socket_fd); - -void e2ap_handle_ResourceStatusRequest(E2AP_PDU_t* pdu, int &socket_fd); - -#endif -- 2.16.6