From 90fe232d4ef733461b703bfaf5f8b56319f83339 Mon Sep 17 00:00:00 2001 From: rajalakshmisv Date: Thu, 30 Jun 2022 14:00:14 +0000 Subject: [PATCH 1/1] HandleControlFailure added as part of this commit Signed-off-by: rajalakshmisv Change-Id: I910b954405b6099dd73e812ce67cf2290ed9f019 --- control/rcControl.go | 22 +++++++++++++ control/rcE2AP.go | 23 +++++++++++++ control/rcTypes.go | 12 +++++++ e2ap/wrapper.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ e2ap/wrapper.h | 16 +++++++++ e2sm/wrapper.c | 37 --------------------- e2sm/wrapper.h | 12 ------- 7 files changed, 165 insertions(+), 49 deletions(-) diff --git a/control/rcControl.go b/control/rcControl.go index 5bf5994..32209db 100644 --- a/control/rcControl.go +++ b/control/rcControl.go @@ -357,8 +357,30 @@ func HandleControlResponse(params *xapp.RMRParams) (err error) { func HandleControlFailure(params *xapp.RMRParams) (err error) { + var e2ap *E2ap + xapp.Logger.Debug("The SubId in RIC_CONTROL_FAILURE is %d", params.SubId) log.Printf("The SubId in RIC_CONTROL_FAILURE is %d", params.SubId) + controlAck, err := e2ap.GetControlFailureMsg(params.Payload) + if err != nil { + xapp.Logger.Debug("Failed to decode RIC Control message: %v", err) + log.Println("Failed to decode RIC Control Ack: %v", err) + return + } + log.Println("E2ap RIC Control Ack message decoded \n") + xapp.Logger.Debug("E2ap RIC Control Ack message decoded \n") + + gControlData.eventRicControlReqExpiredMu.Lock() + _, ok := gControlData.eventRicControlReqExpiredMap[int(controlAck.InstanceId)] + if !ok { + gControlData.eventRicControlReqExpiredMu.Unlock() + xapp.Logger.Debug("RIC_CONTROL_REQ has been deleted!") + log.Printf("RIC_CONTROL_REQ has been deleted!") + return nil + } else { + gControlData.eventRicControlReqExpiredMap[int(controlAck.InstanceId)] = true + gControlData.eventRicControlReqExpiredMu.Unlock() + } return nil } diff --git a/control/rcE2AP.go b/control/rcE2AP.go index e305125..c2beae3 100644 --- a/control/rcE2AP.go +++ b/control/rcE2AP.go @@ -61,3 +61,26 @@ func (c *E2ap) GetControlAckMsg(payload []byte) (decodedMsg *ControlAckMsg, err decodedMsg.ControlOutcomeLength = int32(decodedCMsg.ricControlOutComeSize) return } + +func (c *E2ap) GetControlFailureMsg(payload []byte) (decodedMsg *ControlFailureMsg, err error) { + cptr := unsafe.Pointer(&payload[0]) + decodedMsg = &ControlFailureMsg{} + decodedCMsg := C.e2ap_decode_ric_control_failure_message(cptr, C.size_t(len(payload))) + if decodedCMsg == nil { + return decodedMsg, errors.New("e2ap wrapper is unable to decode control failure message due to wrong or invalid payload") + } + defer C.e2ap_free_decoded_ric_control_failure(decodedCMsg) + + decodedMsg.RequestID = int32(decodedCMsg.requestorID) + decodedMsg.InstanceId = int32(decodedCMsg.instanceID) + decodedMsg.FuncID = int32(decodedCMsg.ranfunctionID) + callproc := unsafe.Pointer(decodedCMsg.callProcessID) + decodedMsg.CallProcessID = C.GoBytes(callproc, C.int(decodedCMsg.callProcessIDSize)) + decodedMsg.CallProcessIDLength = int32(decodedCMsg.callProcessIDSize) + decodedMsg.CauseType = int32(decodedCMsg.causeType) + decodedMsg.CauseValue = int64(decodedCMsg.causeValue) + controlOutcome := unsafe.Pointer(decodedCMsg.ricControlOutCome) + decodedMsg.ControlOutcome = C.GoBytes(controlOutcome, C.int(decodedCMsg.ricControlOutComeSize)) + decodedMsg.ControlOutcomeLength = int32(decodedCMsg.ricControlOutComeSize) + return +} diff --git a/control/rcTypes.go b/control/rcTypes.go index e558d02..4ce92e3 100644 --- a/control/rcTypes.go +++ b/control/rcTypes.go @@ -89,3 +89,15 @@ type ControlOutcomeMsg struct { ControlOutcomeType int32 ControlOutcome interface{} } + +type ControlFailureMsg struct { + RequestID int32 + InstanceId int32 + FuncID int32 + CallProcessID []byte + CallProcessIDLength int32 + CauseType int32 + CauseValue int64 + ControlOutcome []byte + ControlOutcomeLength int32 +} diff --git a/e2ap/wrapper.c b/e2ap/wrapper.c index 7dad60c..d7a6395 100644 --- a/e2ap/wrapper.c +++ b/e2ap/wrapper.c @@ -212,3 +212,95 @@ void e2ap_free_decoded_ric_control_ack(RICControlAcknowledge* msg) { free(msg); msg = NULL; } + +RICControlFailure* e2ap_decode_ric_control_failure_message(void *buffer, size_t buf_size) +{ + E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); + if ( pdu != NULL && pdu->present == E2AP_PDU_PR_unsuccessfulOutcome) + { + UnsuccessfulOutcome_t* unSuccessfulOutcome = pdu->choice.unsuccessfulOutcome; + if ( unSuccessfulOutcome->procedureCode == ProcedureCode_id_RICcontrol + && unSuccessfulOutcome->value.present == UnsuccessfulOutcome__value_PR_RICcontrolFailure) + { + RICcontrolFailure_t *controlFailure = &(unSuccessfulOutcome->value.choice.RICcontrolFailure); + RICControlFailure *msg = (RICControlFailure *)calloc(1, sizeof(RICControlFailure)); + int i = 0; + for (i; i < controlFailure->protocolIEs.list.count; ++i ) + { + if(controlFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID) + { + msg->requestorID = controlFailure->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestorID; + msg->instanceID = controlFailure->protocolIEs.list.array[i]->value.choice.RICrequestID.ricInstanceID; + } + else if (controlFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RANfunctionID) { + msg->ranfunctionID = controlFailure->protocolIEs.list.array[i]->value.choice.RANfunctionID; + } + else if(controlFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICcallProcessID) { + size_t callProcessIDSize = controlFailure->protocolIEs.list.array[i]->value.choice.RICcallProcessID.size; + msg->callProcessID = calloc(1, callProcessIDSize); + if (!msg->callProcessID) { + fprintf(stderr, "alloc RICcallProcessID failed\n"); + e2ap_free_decoded_ric_control_failure(msg); + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu); + return NULL; + } + + memcpy(msg->callProcessID, controlFailure->protocolIEs.list.array[i]->value.choice.RICcallProcessID.buf, callProcessIDSize); + msg->callProcessIDSize = callProcessIDSize; + } + else if(controlFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICcontrolOutcome) { + msg->causeType = controlFailure->protocolIEs.list.array[i]->value.choice.Cause.present; + if (msg->causeType == Cause_PR_ricRequest) { + msg->causeValue = controlFailure->protocolIEs.list.array[i]->value.choice.Cause.choice.ricRequest; + } else if (msg->causeType == Cause_PR_ricService) { + msg->causeValue = controlFailure->protocolIEs.list.array[i]->value.choice.Cause.choice.ricService; + } else if (msg->causeType == Cause_PR_transport) { + msg->causeValue = controlFailure->protocolIEs.list.array[i]->value.choice.Cause.choice.transport; + } else if (msg->causeType == Cause_PR_protocol) { + msg->causeValue = controlFailure->protocolIEs.list.array[i]->value.choice.Cause.choice.protocol; + } else if (msg->causeType == Cause_PR_misc) { + msg->causeValue = controlFailure->protocolIEs.list.array[i]->value.choice.Cause.choice.misc; + }else { + msg->causeType == Cause_PR_NOTHING; + } + } + else if(controlFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICcontrolOutcome) { + size_t ricControlOutComeSize = controlFailure->protocolIEs.list.array[i]->value.choice.RICcontrolOutcome.size; + msg->ricControlOutCome = calloc(1, ricControlOutComeSize); + if (!msg->ricControlOutCome) { + fprintf(stderr, "alloc ricControlOutCome failed\n"); + e2ap_free_decoded_ric_control_failure(msg); + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu); + return NULL; + } + + memcpy(msg->ricControlOutCome, controlFailure->protocolIEs.list.array[i]->value.choice.RICcontrolOutcome.buf, ricControlOutComeSize); + msg->ricControlOutComeSize = ricControlOutComeSize; + + } + } + return msg; + } + } + + if(pdu != NULL) + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu); + + return NULL; +} + +void e2ap_free_decoded_ric_control_failure(RICControlFailure* msg) { + if(msg == NULL) { + return; + } + if(msg->callProcessID != NULL) { + free(msg->callProcessID); + msg->callProcessID = NULL; + } + if(msg->ricControlOutCome != NULL) { + free(msg->ricControlOutCome); + msg->ricControlOutCome = NULL; + } + free(msg); + msg = NULL; +} diff --git a/e2ap/wrapper.h b/e2ap/wrapper.h index e8dbadb..8d43176 100644 --- a/e2ap/wrapper.h +++ b/e2ap/wrapper.h @@ -22,6 +22,19 @@ typedef struct RICControlAcknowledgeMsg { size_t ricControlOutComeSize; }RICControlAcknowledge; +typedef struct RICControlFailureMsg { + long requestorID; + long instanceID; + long ranfunctionID; + uint8_t *callProcessID; + size_t callProcessIDSize; + uint8_t *ricControlOutCome; + size_t ricControlOutComeSize; + int causeType; + long causeValue; + +}RICControlFailure; + size_t encode_E2AP_PDU(E2AP_PDU_t* pdu, void* buffer, size_t buf_size); E2AP_PDU_t* decode_E2AP_PDU(const void* buffer, size_t buf_size); @@ -30,4 +43,7 @@ ssize_t e2ap_encode_ric_control_request_message(void *buffer, size_t buf_size, l RICControlAcknowledge* e2ap_decode_ric_control_acknowledge_message(void *buffer, size_t buf_size); void e2ap_free_decoded_ric_control_ack(RICControlAcknowledge* msg); + +RICControlFailure* e2ap_decode_ric_control_failure_message(void *buffer, size_t buf_size); +void e2ap_free_decoded_ric_control_failure(RICControlFailure* msg); #endif /* _WRAPPER_H_ */ diff --git a/e2sm/wrapper.c b/e2sm/wrapper.c index 1d5deb2..c1d0be6 100755 --- a/e2sm/wrapper.c +++ b/e2sm/wrapper.c @@ -2,7 +2,6 @@ #include "wrapper.h" #include "OCTET_STRING.h" -//ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID *inUEID,long f1AP[1],long e1AP[1],long ricControlStyleType, long ricControlActionID) ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID *inUEID,long f1AP[],size_t f1AP_len,long e1AP[],size_t e1Ap_len,long ricControlStyleType, long ricControlActionID, void* plmnId, size_t plmnIdSize) { fprintf(stderr,"e2SM wrapper function Entered\n"); @@ -88,15 +87,6 @@ ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE); return -1; } - /* - UEID_GNB_CU_CP_F1AP_ID_Item_t *F1AP_ID_Item = (UEID_GNB_CU_CP_F1AP_ID_Item_t *)calloc (1, sizeof(UEID_GNB_CU_CP_F1AP_ID_Item_t )); - if(! F1AP_ID_Item) - { - fprintf(stderr, "alloc UEID_GNB_CU_CP_F1AP_ID_Item failed\n"); - ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE); - return -1; - } - */ //f1AP is an array of data //int n = sizeof(f1AP)/sizeof(long int); for(int i =0; i < f1AP_len; i++) @@ -115,7 +105,6 @@ ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID //F1AP_ID_Item->gNB_CU_UE_F1AP_ID = f1AP[0]; //ASN_SEQUENCE_ADD(&controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_UE_F1AP_ID_List->list,F1AP_ID_Item); - controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List = (UEID_GNB_CU_CP_E1AP_ID_List_t *)calloc(1,sizeof(UEID_GNB_CU_CP_E1AP_ID_List_t)); @@ -145,37 +134,11 @@ ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID } - /*UEID_GNB_CU_CP_E1AP_ID_Item_t *E1AP_ID_Item = (UEID_GNB_CU_CP_E1AP_ID_Item_t *)calloc (1, sizeof(UEID_GNB_CU_CP_E1AP_ID_Item_t )); - if(! E1AP_ID_Item) - { - fprintf(stderr, "alloc UEID_GNB_CU_CP_E1AP_ID_Item failed\n"); - ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE); - return -1; - - } - E1AP_ID_Item->gNB_CU_CP_UE_E1AP_ID = e1AP[0]; - ASN_SEQUENCE_ADD(&controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List->list,E1AP_ID_Item); - */ controlHeader_Fmt1->ric_Style_Type = ricControlStyleType; controlHeader_Fmt1->ric_ControlAction_ID = ricControlActionID; controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1 = controlHeader_Fmt1; - fprintf(stderr, "Manju string %s\n",controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->amf_UE_NGAP_ID.buf) ; - - fprintf(stderr, "Manju string %s\n",controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->guami.pLMNIdentity.buf); - - - fprintf(stderr, "Manju string %s\n",controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf); - -fprintf(stderr, "Manju string %s\n",controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->guami.aMFSetID.buf); - -fprintf(stderr, "Manju string %s\n",controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->guami.aMFPointer.buf); - -fprintf(stderr, "Manju string %lu\n",(**(controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List->list.array)).gNB_CU_CP_UE_E1AP_ID); - -fprintf(stderr, "Manju string %lu\n",(**(controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1->ueID.choice.gNB_UEID->gNB_CU_UE_F1AP_ID_List->list.array)).gNB_CU_UE_F1AP_ID); - fprintf(stderr, "showing xer of asn_DEF_E2SM_RC_ControlHeader data\n"); xer_fprint(stderr, &asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE); diff --git a/e2sm/wrapper.h b/e2sm/wrapper.h index b41dab2..2c36983 100755 --- a/e2sm/wrapper.h +++ b/e2sm/wrapper.h @@ -1,12 +1,9 @@ #ifndef _WRAPPER_H_ #define _WRAPPER_H_ -//#include "ARP.h" #include "BOOLEAN.h" #include "NativeReal.h" -//#include "NULL.h" #include "REAL.h" -//#include "TimeStamp.h" #include "OCTET_STRING.h" #include "E2SM-RC-ControlHeader-Format1.h" #include "E2SM-RC-ControlHeader.h" @@ -17,10 +14,7 @@ #include "NativeInteger.h" #include "OPEN_TYPE.h" #include "PrintableString.h" -//#include "RAN-ControlParameter-Item.h" -//#include "RANParameter-ELEMENT.h" #include "RANParameter-ID.h" -//#include "RANParameter-Item.h" #include "RANParameter-LIST.h" #include "RANParameter-Name.h" #include "RANParameter-STRUCTURE.h" @@ -28,14 +22,10 @@ #include "RANParameter-ValueType.h" #include "RANfunction-Name.h" #include "RIC-ControlAction-ID.h" -//#include "RIC-ControlAction-Item.h" #include "RIC-ControlAction-Name.h" -//#include "RIC-ControlStyle-Item.h" -//#include "RIC-EventTriggerStyle-Item.h" #include "RIC-Format-Type.h" #include "RIC-Style-Name.h" #include "RIC-Style-Type.h" -//#include "UE-Identity.h" #include "RANParameter-ValueType-Choice-ElementFalse.h" #include "RANParameter-ValueType-Choice-Structure.h" #include "UEID.h" @@ -67,7 +57,6 @@ struct uEID { size_t aMFPointer_size; }; -//extern ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID *in,long f1AP[1],long e1AP[1],long ricControlStyleType, long ricControlActionID); extern ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID *in,long f1AP[],size_t f1AP_len,long e1AP[],size_t e1Ap_len,long ricControlStyleType, long ricControlActionID, void *ranParameterValue, size_t ranParameterValue_size); @@ -78,5 +67,4 @@ extern void e2sm_free_ric_call_process_outcome(E2SM_RC_ControlOutcome_t* control extern ssize_t e2sm_encode_nrcgi(NR_CGI_t *nr_cgi, void* ranParameterValue, size_t ranParameterValue_size, ulong lNRCellId,uint8_t* buffer, size_t buf_size); -//extern ssize_t encodeRANParameterTestingItemForStructure(RANParameter_ValueType_Choice_Structure_t **ranParameterChoiceItemStruct,E2SM_RC_ControlMessage_Format1_Item_t **ranParameterItem,long ranParameterID); #endif /* _WRAPPER_H_ */ -- 2.16.6