From af91f971681842c22dc0fad165c0cbf7ebaa0e4d Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Fri, 24 Jan 2020 08:38:47 +0200 Subject: [PATCH] Fixed function id handling and improved ut fail handling Change-Id: I8c0f6455f4e6268a89d0f3ddd42a7bc6cdaaedde Signed-off-by: Juha Hyttinen --- e2ap/pkg/e2ap/msg_e2ap.go | 197 ++++++++++++++++++++--------------- e2ap/pkg/e2ap_wrapper/packer_e2ap.go | 3 +- pkg/control/control.go | 2 +- pkg/control/messaging_test.go | 52 ++++++--- 4 files changed, 151 insertions(+), 103 deletions(-) diff --git a/e2ap/pkg/e2ap/msg_e2ap.go b/e2ap/pkg/e2ap/msg_e2ap.go index 0c8693f..eecf8b8 100644 --- a/e2ap/pkg/e2ap/msg_e2ap.go +++ b/e2ap/pkg/e2ap/msg_e2ap.go @@ -27,125 +27,150 @@ import ( //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- +const ( + E2AP_InitiatingMessage uint64 = 1 + E2AP_SuccessfulOutcome uint64 = 2 + E2AP_UnsuccessfulOutcome uint64 = 3 +) +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- // E2AP messages // Initiating message -const E2AP_RICSubscriptionRequest uint64 = 1 -const E2AP_RICSubscriptionDeleteRequest uint64 = 2 - -// const E2AP_RICServiceUpdate uint64 = 3 -// const E2AP_RICControlRequest uint64 = 4 -// -// //const E2AP_X2SetupRequest uint64 = 5; -// const E2AP_ENDCX2SetupRequest uint64 = 6 -// const E2AP_ResourceStatusRequest uint64 = 7 -// const E2AP_ENBConfigurationUpdate uint64 = 8 -// const E2AP_ENDCConfigurationUpdate uint64 = 9 -// const E2AP_ResetRequest uint64 = 10 -// const E2AP_RICIndication uint64 = 11 - -// const E2AP_RICServiceQuery uint64 = 12 -// const E2AP_LoadInformation uint64 = 13 -// const E2AP_GNBStatusIndication uint64 = 14 -// const E2AP_ResourceStatusUpdate uint64 = 15 -// const E2AP_ErrorIndication uint64 = 16 -// -// // Successful outcome -const E2AP_RICSubscriptionResponse uint64 = 1 -const E2AP_RICSubscriptionDeleteResponse uint64 = 2 - -// const E2AP_RICserviceUpdateAcknowledge uint64 = 3 -// const E2AP_RICcontrolAcknowledge uint64 = 4 -// -// //const E2AP_X2SetupResponse uint64 = 5; -// const E2AP_ENDCX2SetupResponse uint64 = 6 -// const E2AP_ResourceStatusResponse uint64 = 7 -// const E2AP_ENBConfigurationUpdateAcknowledge uint64 = 8 -// const E2AP_ENDCConfigurationUpdateAcknowledge uint64 = 9 -// const E2AP_ResetResponse uint64 = 10 -// -// // Unsuccessful outcome -const E2AP_RICSubscriptionFailure uint64 = 1 -const E2AP_RICSubscriptionDeleteFailure uint64 = 2 +const ( + E2AP_RICSubscriptionRequest uint64 = 1 + E2AP_RICSubscriptionDeleteRequest uint64 = 2 + + // E2AP_RICServiceUpdate uint64 = 3 + // E2AP_RICControlRequest uint64 = 4 + // + // //E2AP_X2SetupRequest uint64 = 5; + // E2AP_ENDCX2SetupRequest uint64 = 6 + // E2AP_ResourceStatusRequest uint64 = 7 + // E2AP_ENBConfigurationUpdate uint64 = 8 + // E2AP_ENDCConfigurationUpdate uint64 = 9 + // E2AP_ResetRequest uint64 = 10 + // E2AP_RICIndication uint64 = 11 + + // E2AP_RICServiceQuery uint64 = 12 + // E2AP_LoadInformation uint64 = 13 + // E2AP_GNBStatusIndication uint64 = 14 + // E2AP_ResourceStatusUpdate uint64 = 15 + // E2AP_ErrorIndication uint64 = 16 + // +) -// const E2AP_RICserviceUpdateFailure uint64 = 3 -// const E2AP_RICcontrolFailure uint64 = 4 -// -// //const E2AP_X2SetupFailure uint64 = 5; -// const E2AP_ENDCX2SetupFailure uint64 = 6 -// const E2AP_ResourceStatusFailure uint64 = 7 -// const E2AP_ENBConfigurationUpdateFailure uint64 = 8 -// const E2AP_ENDCConfigurationUpdateFailure uint64 = 9 -// +// E2AP messages +// Successful outcome +const ( + E2AP_RICSubscriptionResponse uint64 = 1 + E2AP_RICSubscriptionDeleteResponse uint64 = 2 + + // E2AP_RICserviceUpdateAcknowledge uint64 = 3 + // E2AP_RICcontrolAcknowledge uint64 = 4 + // + // //E2AP_X2SetupResponse uint64 = 5; + // E2AP_ENDCX2SetupResponse uint64 = 6 + // E2AP_ResourceStatusResponse uint64 = 7 + // E2AP_ENBConfigurationUpdateAcknowledge uint64 = 8 + // E2AP_ENDCConfigurationUpdateAcknowledge uint64 = 9 + // E2AP_ResetResponse uint64 = 10 + // +) -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -const E2AP_IndicationTypeReport uint64 = 0 -const E2AP_IndicationTypeInsert uint64 = 1 +// E2AP messages +// Unsuccessful outcome +const ( + E2AP_RICSubscriptionFailure uint64 = 1 + E2AP_RICSubscriptionDeleteFailure uint64 = 2 + + // E2AP_RICserviceUpdateFailure uint64 = 3 + // E2AP_RICcontrolFailure uint64 = 4 + // + // //E2AP_X2SetupFailure uint64 = 5; + // E2AP_ENDCX2SetupFailure uint64 = 6 + // E2AP_ResourceStatusFailure uint64 = 7 + // E2AP_ENBConfigurationUpdateFailure uint64 = 8 + // E2AP_ENDCConfigurationUpdateFailure uint64 = 9 + // +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_ActionTypeReport uint64 = 0 -const E2AP_ActionTypeInsert uint64 = 1 -const E2AP_ActionTypePolicy uint64 = 2 +const ( + E2AP_IndicationTypeReport uint64 = 0 + E2AP_IndicationTypeInsert uint64 = 1 +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_SubSeqActionTypeContinue uint64 = 0 -const E2AP_SubSeqActionTypeWait uint64 = 1 +const ( + E2AP_ActionTypeReport uint64 = 0 + E2AP_ActionTypeInsert uint64 = 1 + E2AP_ActionTypePolicy uint64 = 2 +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_TimeToWaitZero uint64 = 0 -const E2AP_TimeToWaitW1ms uint64 = 1 -const E2AP_TimeToWaitW2ms uint64 = 2 -const E2AP_TimeToWaitW5ms uint64 = 3 -const E2AP_TimeToWaitW10ms uint64 = 4 -const E2AP_TimeToWaitW20ms uint64 = 4 -const E2AP_TimeToWaitW30ms uint64 = 5 -const E2AP_TimeToWaitW40ms uint64 = 6 -const E2AP_TimeToWaitW50ms uint64 = 7 -const E2AP_TimeToWaitW100ms uint64 = 8 -const E2AP_TimeToWaitW200ms uint64 = 9 -const E2AP_TimeToWaitW500ms uint64 = 10 -const E2AP_TimeToWaitW1s uint64 = 11 -const E2AP_TimeToWaitW2s uint64 = 12 -const E2AP_TimeToWaitW5s uint64 = 13 -const E2AP_TimeToWaitW10s uint64 = 14 -const E2AP_TimeToWaitW20s uint64 = 15 -const E2AP_TimeToWaitW60 uint64 = 16 +const ( + E2AP_SubSeqActionTypeContinue uint64 = 0 + E2AP_SubSeqActionTypeWait uint64 = 1 +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_InterfaceDirectionIncoming uint32 = 0 -const E2AP_InterfaceDirectionOutgoing uint32 = 1 +const ( + E2AP_TimeToWaitZero uint64 = 0 + E2AP_TimeToWaitW1ms uint64 = 1 + E2AP_TimeToWaitW2ms uint64 = 2 + E2AP_TimeToWaitW5ms uint64 = 3 + E2AP_TimeToWaitW10ms uint64 = 4 + E2AP_TimeToWaitW20ms uint64 = 4 + E2AP_TimeToWaitW30ms uint64 = 5 + E2AP_TimeToWaitW40ms uint64 = 6 + E2AP_TimeToWaitW50ms uint64 = 7 + E2AP_TimeToWaitW100ms uint64 = 8 + E2AP_TimeToWaitW200ms uint64 = 9 + E2AP_TimeToWaitW500ms uint64 = 10 + E2AP_TimeToWaitW1s uint64 = 11 + E2AP_TimeToWaitW2s uint64 = 12 + E2AP_TimeToWaitW5s uint64 = 13 + E2AP_TimeToWaitW10s uint64 = 14 + E2AP_TimeToWaitW20s uint64 = 15 + E2AP_TimeToWaitW60 uint64 = 16 +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_CriticalityReject uint8 = 0 -const E2AP_CriticalityIgnore uint8 = 1 -const E2AP_CriticalityNotify uint8 = 2 +const ( + E2AP_InterfaceDirectionIncoming uint32 = 0 + E2AP_InterfaceDirectionOutgoing uint32 = 1 +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_ENBIDMacroPBits20 uint8 = 20 -const E2AP_ENBIDHomeBits28 uint8 = 28 -const E2AP_ENBIDShortMacroits18 uint8 = 18 -const E2AP_ENBIDlongMacroBits21 uint8 = 21 +const ( + E2AP_CriticalityReject uint8 = 0 + E2AP_CriticalityIgnore uint8 = 1 + E2AP_CriticalityNotify uint8 = 2 +) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -const E2AP_InitiatingMessage uint64 = 1 -const E2AP_SuccessfulOutcome uint64 = 2 -const E2AP_UnsuccessfulOutcome uint64 = 3 +const ( + E2AP_ENBIDMacroPBits20 uint8 = 20 + E2AP_ENBIDHomeBits28 uint8 = 28 + E2AP_ENBIDShortMacroits18 uint8 = 18 + E2AP_ENBIDlongMacroBits21 uint8 = 21 +) //----------------------------------------------------------------------------- // diff --git a/e2ap/pkg/e2ap_wrapper/packer_e2ap.go b/e2ap/pkg/e2ap_wrapper/packer_e2ap.go index 05ac04a..868c344 100644 --- a/e2ap/pkg/e2ap_wrapper/packer_e2ap.go +++ b/e2ap/pkg/e2ap_wrapper/packer_e2ap.go @@ -326,10 +326,11 @@ func (item *e2apEntryNotAdmittedList) set(data *e2ap.ActionNotAdmittedList) erro item.entry.contentLength = 0 for i := 0; i < len(data.Items); i++ { item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricActionID = (C.ulong)(data.Items[i].ActionId) - item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.content = (C.uchar)(data.Items[i].Cause.Content) // C.cRICCauseRadioNetwork + item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.content = (C.uchar)(data.Items[i].Cause.Content) item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.cause = (C.uchar)(data.Items[i].Cause.CauseVal) item.entry.contentLength++ } + return nil } diff --git a/pkg/control/control.go b/pkg/control/control.go index 3c75523..c2b33b7 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -394,7 +394,7 @@ func (c *Control) sendE2TSubscriptionDeleteRequest(subs *Subscription, trans *Tr subDelReqMsg := &e2ap.E2APSubscriptionDeleteRequest{} subDelReqMsg.RequestId.Id = 123 subDelReqMsg.RequestId.Seq = uint32(subs.GetSubId()) - subDelReqMsg.FunctionId = 0 + subDelReqMsg.FunctionId = subs.SubReqMsg.FunctionId trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionDeleteRequest(subDelReqMsg) if err != nil { xapp.Logger.Error("SUBS-SubDelReq: %s parent %s", idstring(trans, subs, err), parentTrans.String()) diff --git a/pkg/control/messaging_test.go b/pkg/control/messaging_test.go index 007a432..4465d6c 100644 --- a/pkg/control/messaging_test.go +++ b/pkg/control/messaging_test.go @@ -362,7 +362,39 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, re //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -func (e2termConn *testingE2termControl) handle_e2term_subs_fail(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *RMRParams) { +type test_subs_fail_params struct { + req *e2ap.E2APSubscriptionRequest + fail *e2ap.E2APSubscriptionFailure +} + +func (p *test_subs_fail_params) Set(req *e2ap.E2APSubscriptionRequest) { + p.req = req + + p.fail = &e2ap.E2APSubscriptionFailure{} + p.fail.RequestId.Id = p.req.RequestId.Id + p.fail.RequestId.Seq = p.req.RequestId.Seq + p.fail.FunctionId = p.req.FunctionId + p.fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.req.ActionSetups)) + for index := int(0); index < len(p.fail.ActionNotAdmittedList.Items); index++ { + p.fail.ActionNotAdmittedList.Items[index].ActionId = p.req.ActionSetups[index].ActionId + p.SetCauseVal(index, 5, 1) + } +} + +func (p *test_subs_fail_params) SetCauseVal(ind int, content uint8, causeval uint8) { + + if ind < 0 { + for index := int(0); index < len(p.fail.ActionNotAdmittedList.Items); index++ { + p.fail.ActionNotAdmittedList.Items[index].Cause.Content = content + p.fail.ActionNotAdmittedList.Items[index].Cause.CauseVal = causeval + } + return + } + p.fail.ActionNotAdmittedList.Items[ind].Cause.Content = content + p.fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval +} + +func (e2termConn *testingE2termControl) handle_e2term_subs_fail(t *testing.T, fparams *test_subs_fail_params, msg *RMRParams) { xapp.Logger.Info("(%s) handle_e2term_subs_fail", e2termConn.desc) e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure() @@ -371,19 +403,7 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_fail(t *testing.T, re //--------------------------------- xapp.Logger.Info("(%s) Send Subs Fail", e2termConn.desc) - resp := &e2ap.E2APSubscriptionFailure{} - resp.RequestId.Id = req.RequestId.Id - resp.RequestId.Seq = req.RequestId.Seq - resp.FunctionId = req.FunctionId - - resp.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(resp.ActionNotAdmittedList.Items)) - for index := int(0); index < len(resp.ActionNotAdmittedList.Items); index++ { - resp.ActionNotAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId - resp.ActionNotAdmittedList.Items[index].Cause.Content = 3 // CauseMisc - resp.ActionNotAdmittedList.Items[index].Cause.CauseVal = 4 // unspecified - } - - e2SubsFail.Set(resp) + e2SubsFail.Set(fparams.fail) xapp.Logger.Debug("%s", e2SubsFail.String()) packerr, packedMsg := e2SubsFail.Pack(nil) if packerr != nil { @@ -1236,7 +1256,9 @@ func TestSubReqSubFailRespInSubmgr(t *testing.T) { // E2t: Receive SubsReq and send SubsFail crereq, cremsg := e2termConn.handle_e2term_subs_req(t) - e2termConn.handle_e2term_subs_fail(t, crereq, cremsg) + fparams := &test_subs_fail_params{} + fparams.Set(crereq) + e2termConn.handle_e2term_subs_fail(t, fparams, cremsg) // Xapp: Receive SubsFail e2SubsId := xappConn1.handle_xapp_subs_fail(t, cretrans) -- 2.16.6