From 84662c4f3e2273152fc849f74880108b6346bcad Mon Sep 17 00:00:00 2001 From: Himanshu Puorhit Date: Tue, 29 Aug 2023 15:46:18 +0530 Subject: [PATCH] Support for handling unordered IEs in RIC Subscription Response messgae Inorder to support interoperability with other RAN simulators, adding config parameter using which strict order checking of IEs can be enabled or disabled. Resolves RIC-963 partially. Change-Id: Ie9c60f9dcbb8159ae21ee29451da24901dad1d6f Change-Id: Icd660d38efb0331ad4f03b309dd7a3082a74e8e8 Signed-off-by: himanshup --- config/submgr-config.yaml | 1 + e2ap/libe2ap_wrapper/E2AP_if.c | 241 +++++++++++++--------- e2ap/libe2ap_wrapper/E2AP_if.h | 12 +- e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscription.go | 3 +- e2ap/pkg/e2ap_wrapper/packer_e2ap.go | 13 +- pkg/control/control.go | 6 + pkg/control/e2ap.go | 4 + pkg/control/ut_messaging_test.go | 94 +++++++++ 8 files changed, 267 insertions(+), 107 deletions(-) diff --git a/config/submgr-config.yaml b/config/submgr-config.yaml index 87bffbf..471bfed 100644 --- a/config/submgr-config.yaml +++ b/config/submgr-config.yaml @@ -26,3 +26,4 @@ "readSubsFromDb": "true" "dbTryCount": 200 "dbRetryForever": "true" + "checkE2IEOrder": 1 diff --git a/e2ap/libe2ap_wrapper/E2AP_if.c b/e2ap/libe2ap_wrapper/E2AP_if.c index 2515b81..2759f71 100644 --- a/e2ap/libe2ap_wrapper/E2AP_if.c +++ b/e2ap/libe2ap_wrapper/E2AP_if.c @@ -29,6 +29,11 @@ static bool debugPrints = false; +// Value of checkIEOrder defines if strict order to be followed while +// packing/unpacking of E2AP messages. +// Value 1 defines strict order and value 0 defines lenient order +static uint8_t checkIEOrder = 1; + const int64_t cMaxNrOfErrors = 256; const uint64_t cMaxSizeOfOctetString = 1024; @@ -75,6 +80,11 @@ void allowASN1DebugPrints(bool allowASN1DebugPrints) { debugPrints = allowASN1DebugPrints; } +////////////////////////////////////////////////////////////////////// +void allowOutOfOrderIEMsg(uint8_t e2IEOrderCheckEnabled) { + checkIEOrder = e2IEOrderCheckEnabled; +} + ////////////////////////////////////////////////////////////////////// const char* getE2ErrorString(uint64_t errorCode) { @@ -247,32 +257,39 @@ uint64_t packRICSubscriptionResponse(size_t* pDataBufferSize, byte* pDataBuffer, pE2AP_PDU->choice.initiatingMessage.value.present = SuccessfulOutcome__value_PR_RICsubscriptionResponse; // RICrequestID - RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - if (pRICsubscriptionResponse_IEs) { - pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RICrequestID; - pRICsubscriptionResponse_IEs->criticality = Criticality_reject; - pRICsubscriptionResponse_IEs->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID; - pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionResponse->ricRequestID.ricRequestorID; - pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricInstanceID = pRICSubscriptionResponse->ricRequestID.ricInstanceID; - ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs); + RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs_RicRequestID = calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); + if (pRICsubscriptionResponse_IEs_RicRequestID) { + pRICsubscriptionResponse_IEs_RicRequestID->id = ProtocolIE_ID_id_RICrequestID; + pRICsubscriptionResponse_IEs_RicRequestID->criticality = Criticality_reject; + pRICsubscriptionResponse_IEs_RicRequestID->value.present = RICsubscriptionResponse_IEs__value_PR_RICrequestID; + pRICsubscriptionResponse_IEs_RicRequestID->value.choice.RICrequestID.ricRequestorID = pRICSubscriptionResponse->ricRequestID.ricRequestorID; + pRICsubscriptionResponse_IEs_RicRequestID->value.choice.RICrequestID.ricInstanceID = pRICSubscriptionResponse->ricRequestID.ricInstanceID; } else return e2err_RICSubscriptionResponseAllocRICrequestIDFail; // RANfunctionID - pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); - if (pRICsubscriptionResponse_IEs) { - pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RANfunctionID; - pRICsubscriptionResponse_IEs->criticality = Criticality_reject; - pRICsubscriptionResponse_IEs->value.present = RICsubscriptionResponse_IEs__value_PR_RANfunctionID; - pRICsubscriptionResponse_IEs->value.choice.RANfunctionID = pRICSubscriptionResponse->ranFunctionID; - ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs); + RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs_RANFunctionID = calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); + if (pRICsubscriptionResponse_IEs_RANFunctionID) { + pRICsubscriptionResponse_IEs_RANFunctionID->id = ProtocolIE_ID_id_RANfunctionID; + pRICsubscriptionResponse_IEs_RANFunctionID->criticality = Criticality_reject; + pRICsubscriptionResponse_IEs_RANFunctionID->value.present = RICsubscriptionResponse_IEs__value_PR_RANfunctionID; + pRICsubscriptionResponse_IEs_RANFunctionID->value.choice.RANfunctionID = pRICSubscriptionResponse->ranFunctionID; } else return e2err_RICSubscriptionResponseAllocRANfunctionIDFail; + // Check if Out of order IE messages to be packed, add RANFunctionID IE before RICRequestID + if (checkIEOrder) { + ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs_RicRequestID); + ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs_RANFunctionID); + } else { + ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs_RANFunctionID); + ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs_RicRequestID); + } + // RICaction-Admitted list - pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); + RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); if (pRICsubscriptionResponse_IEs) { pRICsubscriptionResponse_IEs->id = ProtocolIE_ID_id_RICactions_Admitted; pRICsubscriptionResponse_IEs->criticality = Criticality_reject; @@ -865,104 +882,122 @@ uint64_t getRICSubscriptionResponseData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICSu RICsubscriptionResponse_t *asnRicSubscriptionResponse = &pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse; RICsubscriptionResponse_IEs_t* pRICsubscriptionResponse_IEs; - // RICrequestID - if (asnRicSubscriptionResponse->protocolIEs.list.count > 0 && - asnRicSubscriptionResponse->protocolIEs.list.array[0]->id == ProtocolIE_ID_id_RICrequestID) { - pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[0]; - pRICSubscriptionResponse->ricRequestID.ricRequestorID = pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestorID; - pRICSubscriptionResponse->ricRequestID.ricInstanceID = pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricInstanceID; + bool foundRICrequestID = false; + bool foundRANfunctionID = false; + bool foundRICactions_Admitted = false; + bool foundRICaction_NotAdmitted = false; + + for (int i = 0; i < asnRicSubscriptionResponse->protocolIEs.list.count; i++) { + if (asnRicSubscriptionResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID) { + if (checkIEOrder && i != 0) { + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); + return e2err_RICsubscriptionResponseRICrequestIDWrongOrder; + } + pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[i]; + pRICSubscriptionResponse->ricRequestID.ricRequestorID = pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricRequestorID; + pRICSubscriptionResponse->ricRequestID.ricInstanceID = pRICsubscriptionResponse_IEs->value.choice.RICrequestID.ricInstanceID; + foundRICrequestID = true; + } + else if (asnRicSubscriptionResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RANfunctionID) { + if (checkIEOrder && i != 1) { + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); + return e2err_RICsubscriptionResponseRANfunctionIDWrongOrder; + } + pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[i]; + pRICSubscriptionResponse->ranFunctionID = pRICsubscriptionResponse_IEs->value.choice.RANfunctionID; + foundRANfunctionID = true; + } + else if (asnRicSubscriptionResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICactions_Admitted) { + if (checkIEOrder && i != 2) { + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); + return e2err_RICsubscriptionResponseRICaction_Admitted_ListWrongOrder; + } + pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[i]; + pRICSubscriptionResponse->ricActionAdmittedList.contentLength = 0; + uint64_t index = 0; + while ((index < maxofRICactionID) && (index < pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list.count)) { + RICaction_Admitted_ItemIEs_t* pRICaction_Admitted_ItemIEs = + (RICaction_Admitted_ItemIEs_t*)pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list.array[index]; + + // RICActionID + pRICSubscriptionResponse->ricActionAdmittedList.ricActionID[index] = + pRICaction_Admitted_ItemIEs->value.choice.RICaction_Admitted_Item.ricActionID; + index++; + } + pRICSubscriptionResponse->ricActionAdmittedList.contentLength = index; + foundRICactions_Admitted = true; + } + else if (asnRicSubscriptionResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICactions_NotAdmitted) { + if (checkIEOrder && i != 3) { + ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); + return e2err_RICsubscriptionResponseRICaction_NotAdmitted_ListWrongOrder; + } + pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[i]; + if (pRICsubscriptionResponse_IEs->value.present == RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List) { + pRICSubscriptionResponse->ricActionNotAdmittedListPresent = true; + pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = 0; + uint64_t index = 0; + while ((index < maxofRICactionID) && (index < pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list.count)) { + RICaction_NotAdmitted_ItemIEs_t* pRICaction_NotAdmitted_ItemIEs = + (RICaction_NotAdmitted_ItemIEs_t*)pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list.array[index]; + + // RICActionID + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricActionID; + + // Cause + if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_ricRequest) { + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_ricRequest; + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.ricRequest; + } + else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_ricService) { + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_ricService; + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.ricService; + } + else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_e2Node) { + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_e2Node; + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.e2Node; + } + else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_transport) { + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_transport; + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.transport; + } + else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_protocol) { + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_protocol; + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.protocol; + } + else if(pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_misc) { + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_misc; + pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = + pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.misc; + } + index++; + } + pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = index; + foundRICaction_NotAdmitted = true; + } + } } - else { + + if (!foundRICrequestID) { ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); return e2err_RICsubscriptionResponseRICrequestIDMissing; } - - // RANfunctionID - if (asnRicSubscriptionResponse->protocolIEs.list.count > 1 && - asnRicSubscriptionResponse->protocolIEs.list.array[1]->id == ProtocolIE_ID_id_RANfunctionID) { - pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[1]; - pRICSubscriptionResponse->ranFunctionID = pRICsubscriptionResponse_IEs->value.choice.RANfunctionID; - } - else { + if (!foundRANfunctionID) { ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); return e2err_RICsubscriptionResponseRANfunctionIDMissing; } - - // RICaction-Admitted-List - if (asnRicSubscriptionResponse->protocolIEs.list.count > 2 && - asnRicSubscriptionResponse->protocolIEs.list.array[2]->id == ProtocolIE_ID_id_RICactions_Admitted) { - pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[2]; - pRICSubscriptionResponse->ricActionAdmittedList.contentLength = 0; - uint64_t index = 0; - while ((index < maxofRICactionID) && (index < pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list.count)) { - RICaction_Admitted_ItemIEs_t* pRICaction_Admitted_ItemIEs = - (RICaction_Admitted_ItemIEs_t*)pRICsubscriptionResponse_IEs->value.choice.RICaction_Admitted_List.list.array[index]; - - // RICActionID - pRICSubscriptionResponse->ricActionAdmittedList.ricActionID[index] = - pRICaction_Admitted_ItemIEs->value.choice.RICaction_Admitted_Item.ricActionID; - index++; - } - pRICSubscriptionResponse->ricActionAdmittedList.contentLength = index; - } - else { + if (!foundRICactions_Admitted) { ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU); return e2err_RICsubscriptionResponseRICaction_Admitted_ListMissing; } - // RICaction-NotAdmitted-List, OPTIONAL - if (asnRicSubscriptionResponse->protocolIEs.list.count > 3 && - asnRicSubscriptionResponse->protocolIEs.list.array[3]->id == ProtocolIE_ID_id_RICactions_NotAdmitted) { - pRICsubscriptionResponse_IEs = asnRicSubscriptionResponse->protocolIEs.list.array[3]; - if (pRICsubscriptionResponse_IEs->value.present == RICsubscriptionResponse_IEs__value_PR_RICaction_NotAdmitted_List) { - pRICSubscriptionResponse->ricActionNotAdmittedListPresent = true; - pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = 0; - uint64_t index = 0; - while ((index < maxofRICactionID) && (index < pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list.count)) { - RICaction_NotAdmitted_ItemIEs_t* pRICaction_NotAdmitted_ItemIEs = - (RICaction_NotAdmitted_ItemIEs_t*)pRICsubscriptionResponse_IEs->value.choice.RICaction_NotAdmitted_List.list.array[index]; - - // RICActionID - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.ricActionID; - - // Cause - if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_ricRequest) { - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_ricRequest; - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.ricRequest; - } - else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_ricService) { - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_ricService; - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.ricService; - } - else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_e2Node) { - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_e2Node; - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.e2Node; - } - else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_transport) { - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_transport; - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.transport; - } - else if (pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_protocol) { - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_protocol; - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.protocol; - } - else if(pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.present == Cause_PR_misc) { - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content = Cause_PR_misc; - pRICSubscriptionResponse->ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal = - pRICaction_NotAdmitted_ItemIEs->value.choice.RICaction_NotAdmitted_Item.cause.choice.misc; - } - index++; - } - pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = index; - } - } - else { + if (!foundRICaction_NotAdmitted) { pRICSubscriptionResponse->ricActionNotAdmittedListPresent = false; pRICSubscriptionResponse->ricActionNotAdmittedList.contentLength = 0; } diff --git a/e2ap/libe2ap_wrapper/E2AP_if.h b/e2ap/libe2ap_wrapper/E2AP_if.h index 32f1c19..10f2d2f 100644 --- a/e2ap/libe2ap_wrapper/E2AP_if.h +++ b/e2ap/libe2ap_wrapper/E2AP_if.h @@ -287,7 +287,11 @@ enum e2err { e2err_RICSubscriptionDeleteRequiredRANfunctionIDMissing, e2err_RICSubscriptionDeleteRequiredRICcauseMissing, e2err_RICSubscriptionDeleteRequiredEncodeFail, - e2err_RICSubscriptionDeleteRequiredAllocE2AP_PDUFail + e2err_RICSubscriptionDeleteRequiredAllocE2AP_PDUFail, + e2err_RICsubscriptionResponseRICrequestIDWrongOrder, + e2err_RICsubscriptionResponseRANfunctionIDWrongOrder, + e2err_RICsubscriptionResponseRICaction_Admitted_ListWrongOrder, + e2err_RICsubscriptionResponseRICaction_NotAdmitted_ListWrongOrder, }; static const char* const E2ErrorStrings[] = { @@ -349,6 +353,10 @@ static const char* const E2ErrorStrings[] = { "e2err_RICSubscriptionDeleteRequiredRICcauseMissing", "e2err_RICSubscriptionDeleteRequiredEncodeFail", "e2err_RICSubscriptionDeleteRequiredAllocE2AP_PDUFail", + "e2err_RICsubscriptionResponseRICrequestIDWrongOrder", + "e2err_RICsubscriptionResponseRANfunctionIDWrongOrder", + "e2err_RICsubscriptionResponseRICaction_Admitted_ListWrongOrder", + "e2err_RICsubscriptionResponseRICaction_NotAdmitted_ListWrongOrder", }; typedef struct { @@ -436,6 +444,8 @@ typedef struct { void allowASN1DebugPrints(bool); +void allowOutOfOrderIEMsg(uint8_t); + const char* getE2ErrorString(uint64_t); typedef void* e2ap_pdu_ptr_t; diff --git a/e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscription.go b/e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscription.go index eb95cc4..dbb20a6 100644 --- a/e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscription.go +++ b/e2ap/pkg/e2ap/e2ap_tests/msg_e2ap_subscription.go @@ -20,8 +20,9 @@ package e2ap_tests import ( - "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap" "testing" + + "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap" ) //----------------------------------------------------------------------------- diff --git a/e2ap/pkg/e2ap_wrapper/packer_e2ap.go b/e2ap/pkg/e2ap_wrapper/packer_e2ap.go index 3ebd689..bceb66f 100644 --- a/e2ap/pkg/e2ap_wrapper/packer_e2ap.go +++ b/e2ap/pkg/e2ap_wrapper/packer_e2ap.go @@ -52,10 +52,11 @@ import "C" import ( "bytes" "fmt" - "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv" - "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap" "strings" "unsafe" + + "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv" + "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap" ) const cLogBufferMaxSize = 40960 @@ -729,6 +730,7 @@ func (e2apMsg *e2apMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) ( if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil { return err, e2apMsg.msgG } + errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC) if err := e2apMsg.checkerr(errorNro); err != nil { return err, e2apMsg.msgG @@ -1213,6 +1215,13 @@ func SetASN1DebugPrintStatus(logLevel int) { } } +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +func SetE2IEOrderCheck(ieOrderCheck uint8) { + C.allowOutOfOrderIEMsg(C.uchar(ieOrderCheck)) +} + //----------------------------------------------------------------------------- // Public E2AP packer creators //----------------------------------------------------------------------------- diff --git a/pkg/control/control.go b/pkg/control/control.go index 227eb0c..b4667e0 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -72,6 +72,7 @@ var checkE2State string var readSubsFromDb string var dbRetryForever string var dbTryCount int +var e2IEOrderCheckValue uint8 type Control struct { *xapp.RMRClient @@ -348,6 +349,11 @@ func (c *Control) ReadConfigParameters(f string) { xapp.Logger.Debug("WARNING: Using hard coded default value for waitRouteCleanup_ms") } xapp.Logger.Debug("waitRouteCleanup= %v", waitRouteCleanup_ms) + + viper.SetDefault("controls.checkE2IEOrder", 1) + e2IEOrderCheckValue = uint8(viper.GetUint("controls.checkE2IEOrder")) + c.e2ap.SetE2IEOrderCheck(e2IEOrderCheckValue) + xapp.Logger.Debug("e2IEOrderCheck= %v", e2IEOrderCheckValue) } //------------------------------------------------------------------- diff --git a/pkg/control/e2ap.go b/pkg/control/e2ap.go index ae8c999..f233bc4 100644 --- a/pkg/control/e2ap.go +++ b/pkg/control/e2ap.go @@ -55,6 +55,10 @@ func (e *E2ap) SetASN1DebugPrintStatus(logLevel int) { e2ap_wrapper.SetASN1DebugPrintStatus(logLevel) } +func (e *E2ap) SetE2IEOrderCheck(ieOrderCheck uint8) { + e2ap_wrapper.SetE2IEOrderCheck(ieOrderCheck) +} + //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index c61a495..3d0b448 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -880,6 +880,100 @@ func TestSubReqAndSubDelOk(t *testing.T) { mainCtrl.VerifyCounterValues(t) } +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// TestSubReqAndSubDelOkOutofOrderIEs +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | (Out of Order IEs) +// | |<-------------| +// | | | +// | SubResp | | +// |<-------------| | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | +// +//----------------------------------------------------------------------------- + +func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) { + CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs") + + mainCtrl.c.e2ap.SetE2IEOrderCheck(0) + // Init counter check + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cSubReqFromXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cSubRespToXapp, 1}, + Counter{cSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cSubDelRespToXapp, 1}, + }) + + cretrans := xappConn1.SendSubsReq(t, nil, nil) + if cretrans == nil { + t.Logf("Could not send SubsReq") + t.FailNow() + } + crereq, cremsg := e2termConn1.RecvSubsReq(t) + if crereq == nil || cremsg == nil { + t.Logf("Could not recieve SubsReq") + t.FailNow() + } + + e2termConn1.SendSubsResp(t, crereq, cremsg) + + mainCtrl.c.e2ap.SetE2IEOrderCheck(0) + + e2SubsId := xappConn1.RecvSubsResp(t, cretrans) + resp, _ := xapp.Subscription.QuerySubscriptions() + assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId)) + assert.Equal(t, resp[0].Meid, "RAN_NAME_1") + assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"}) + + deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + xappConn1.RecvSubsDelResp(t, deltrans) + + //Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + xappConn2.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) + + mainCtrl.VerifyCounterValues(t) + mainCtrl.c.e2ap.SetE2IEOrderCheck(1) +} + +//----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // TestSubReqRetransmission // -- 2.16.6