/*****************************************************************************
# *
# Copyright 2020 AT&T Intellectual Property *
+# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved. *
# *
# Licensed under the Apache License, Version 2.0 (the "License"); *
# you may not use this file except in compliance with the License. *
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;
}
+void encoding::generate_e2apv1_service_update(E2AP_PDU_t *e2ap_pdu, std::vector<encoding::ran_func_info> all_funcs) {
+ char* ran_function_op_type = getenv("RAN_FUNCTION_OP_TYPE");
+ LOG_D("Ran funciton : %s", ran_function_op_type);
+ ProtocolIE_ID_t prID;
+ if (ran_function_op_type != NULL)
+ {
+ if (strcmp(ran_function_op_type, "ADD") == 0)
+ {
+ prID = ProtocolIE_ID_id_RANfunctionsAdded;
+ }
+ else if (strcmp(ran_function_op_type, "DELETE"))
+ {
+ prID = ProtocolIE_ID_id_RANfunctionsDeleted;
+ }
+ }
+ else
+ {
+ prID = ProtocolIE_ID_id_RANfunctionsModified;
+ }
+
+
+ RICserviceUpdate_IEs_t *e2serviceUpdateList = (RICserviceUpdate_IEs_t *)calloc(1, sizeof(RICserviceUpdate_IEs_t));
+ e2serviceUpdateList->id = prID;
+ e2serviceUpdateList->criticality = Criticality_reject;
+ e2serviceUpdateList->value.present = RICserviceUpdate_IEs__value_PR_RANfunctions_List;
+
+
+ for (int i=0; i<all_funcs.size(); i++) {
+
+ encoding::ran_func_info nextRanFunc = all_funcs.at(i);
+ long nextRanFuncId = nextRanFunc.ranFunctionId;
+ OCTET_STRING_t *nextRanFuncDesc = nextRanFunc.ranFunctionDesc;
+ long nextRanFuncRev = nextRanFunc.ranFunctionRev;
+
+ 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;
+
+ itemIes->value.choice.RANfunction_Item.ranFunctionDefinition = *nextRanFuncDesc;
+ itemIes->value.choice.RANfunction_Item.ranFunctionRevision = nextRanFuncRev + 1;
+
+ ASN_SEQUENCE_ADD(&e2serviceUpdateList->value.choice.RANfunctions_List.list, itemIes);
+ }
+
+ RICserviceUpdate_t *ricServiceUpdate = (RICserviceUpdate_t *)calloc(1, sizeof(RICserviceUpdate_t));
+ ASN_SEQUENCE_ADD(&ricServiceUpdate->protocolIEs.list, e2serviceUpdateList);
+
+ InitiatingMessage_t *initiatingMessage = (InitiatingMessage_t *)calloc(1, sizeof(InitiatingMessage_t));
+ initiatingMessage->criticality = Criticality_reject;
+ initiatingMessage->procedureCode = ProcedureCode_id_RICserviceUpdate;
+ initiatingMessage->value.present = InitiatingMessage__value_PR_RICserviceUpdate;
+ initiatingMessage->value.choice.RICserviceUpdate = *ricServiceUpdate;
+
+ E2AP_PDU_PR pres6 = E2AP_PDU_PR_initiatingMessage;
+ e2ap_pdu->present = pres6;
+ e2ap_pdu->choice.initiatingMessage = initiatingMessage;
+}
+
void encoding::generate_e2apv1_setup_request_parameterized(E2AP_PDU_t *e2ap_pdu, std::vector<ran_func_info> all_funcs) {
// long ranFunctionId, uint8_t *ranFuncDescEncoded, int ranFuncLength) {
GNB_ID_Choice_PR pres2 = GNB_ID_Choice_PR_gnb_ID;
gnbchoice->present = pres2;
gnbchoice->choice.gnb_ID = *gnb_bstring;
+ if (gnb_bstring) free(gnb_bstring);
GlobalgNB_ID_t *gnb = (GlobalgNB_ID_t*)calloc(1, sizeof(GlobalgNB_ID_t));
gnb->plmn_id = *plmn;
gnb->gnb_id = *gnbchoice;
+ if (plmn) free(plmn);
+ if (gnbchoice) free(gnbchoice);
GlobalE2node_gNB_ID_t *e2gnb = (GlobalE2node_gNB_ID_t*)calloc(1, sizeof(GlobalE2node_gNB_ID_t));
e2gnb->global_gNB_ID = *gnb;
+ if (gnb) free(gnb);
GlobalE2node_ID_t *globale2nodeid = (GlobalE2node_ID_t*)calloc(1, sizeof(GlobalE2node_ID_t));
GlobalE2node_ID_PR pres;
e2setuprid->criticality = 0;
e2setuprid->value.choice.GlobalE2node_ID = *globale2nodeid;
e2setuprid->value.present = pres3;
+ if(globale2nodeid) free(globale2nodeid);
auto *ranFlistIEs = (E2setupRequestIEs_t *)calloc(1, sizeof(E2setupRequestIEs_t));
initmsg->criticality = Criticality_reject;
initmsg->value.present = pres4;
initmsg->value.choice.E2setupRequest = *e2setupreq;
+ if (e2setupreq) free(e2setupreq);
E2AP_PDU_PR pres5;
pres5 = E2AP_PDU_PR_initiatingMessage;
e2ap_pdu->present = pres5;
e2ap_pdu->choice.initiatingMessage = initmsg;
- char *error_buf = (char*)calloc(300, sizeof(char));;
- size_t errlen;
+ char error_buf[300] = {0, };
+ size_t errlen = 0;
asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
printf("error length %d\n", errlen);
RICaction_Admitted_List_t* admlist =
(RICaction_Admitted_List_t*)calloc(1,sizeof(RICaction_Admitted_List_t));
ricactionadmitted->value.choice.RICaction_Admitted_List = *admlist;
+ if (admlist) free(admlist);
int numAccept = accept_size;
successoutcome->criticality = 0;
successoutcome->value.present = pres2;
successoutcome->value.choice.RICsubscriptionResponse = *ricsubresp;
+ if (ricsubresp) free(ricsubresp);
E2AP_PDU_PR pres5 = E2AP_PDU_PR_successfulOutcome;
e2ap_pdu->present = pres5;
e2ap_pdu->choice.successfulOutcome = successoutcome;
- char *error_buf = (char*)calloc(300, sizeof(char));
- size_t errlen;
+ char error_buf[300] = {0, };
+ size_t errlen = 0;
asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
printf("error length %d\n", errlen);
e2ap_pdu->present = pres5;
e2ap_pdu->choice.successfulOutcome = successoutcome;
- char *error_buf = (char*)calloc(300, sizeof(char));
- size_t errlen;
+ char error_buf[300] = {0, };
+ size_t errlen = 0;
asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
printf("error length %d\n", errlen);
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);
initmsg->criticality = 1;
initmsg->value.present = pres4;
initmsg->value.choice.RICindication = *ricindication;
+ if (ricindication) free(ricindication);
E2AP_PDU_PR pres5;
pres5 = E2AP_PDU_PR_initiatingMessage;
e2ap_pdu->present = pres5;
e2ap_pdu->choice.initiatingMessage = initmsg;
-
- char *error_buf = (char*)calloc(300, sizeof(char));
- size_t errlen;
+ char error_buf[300] = {0, };
+ size_t errlen = 0;
asn_check_constraints(&asn_DEF_E2AP_PDU, e2ap_pdu, error_buf, &errlen);
printf("error length %d\n", errlen);