-
Notifications
You must be signed in to change notification settings - Fork 140
test: HandleCreateUEContext #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
InertGas01
wants to merge
27
commits into
free5gc:main
Choose a base branch
from
InertGas01:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1d289f3
test: HandleCreateUEContext
bcc313b
fix: change logrus to testing.T.Fatal()
5c7f97a
feat: N2 Handover between different AMF
4debe76
feat: N2 handover between different AMFs
2033aaa
Merge branch 'main' of github.com:InertGas01/amf into main
142491e
fix: redund code in last merge.
4c06b72
fix: change context type PendingHandoverResponse variables from priva…
cc20ecb
fix: error handling and logging in CreateUeContext procedure and rela…
8b127d5
fix: recover go.mod & linter fix
9afeac2
fix: Skip 'Target RAN Node ID not found' error. Add error/debug log m…
e5ebd17
Merge branch 'main' into main
InertGas01 c66ad32
fix: Add UE context information for UpdateSMContext request and HANDO…
b180fa2
fix: Complete Create UE Context test
f1728f7
Merge branch 'free5gc:main' into main
InertGas01 a3ab9aa
fix: ci-lint for consumer/smf_service.go, createUeContext_test.go and…
042a19a
Merge branch 'main' of github.com:InertGas01/amf into main
116dd38
fix: error handling condition for SCTPConn.Close() in createUeContext…
003b729
fix: gci for consumer/smf_service.go and processor/ue_context.go
fb23ab1
fix: golangci-lint for ngap/handler.go, processor/ue_context.go
b3b2037
fix: gci for ue_context.go
432b090
fix: golangci-lint v2.1.6 for ue_context.go
44e3d6e
refactor: add comments and remove unused struct type in context.go
544d77b
fix: fix logger usage in context/context.go and add helper function f…
b305859
fix: ci-lint
954cbfb
fix: create channel using make instead of declaration
166ec15
fix: error handling for pendingHOResponseChan
9f16b7a
fix: golangci-lint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1490,7 +1490,38 @@ func handleHandoverRequestAcknowledgeMain(ran *context.AmfRan, | |
| if sourceUe == nil { | ||
| // TODO: Send Namf_Communication_CreateUEContext Response to S-AMF | ||
| ran.Log.Error("handover between different Ue has not been implement yet") | ||
|
|
||
| ueContextCreatedData := buildUeContextCreatedData(amfUe, pduSessionResourceHandoverList) | ||
|
|
||
| resp201 := models.CreateUeContextResponse201{ | ||
| JsonData: ueContextCreatedData, | ||
| BinaryDataN2Information: targetToSourceTransparentContainer.Value, | ||
| } | ||
|
|
||
| amfSelf := amfUe.ServingAMF() | ||
|
|
||
| // Create channel if not exist | ||
| // pendingHOResponseChan := make(chan context.PendingHandoverResponse) | ||
| var pendingHOResponseChan chan context.PendingHandoverResponse | ||
| value, ok := amfSelf.PendingHandovers.Load(amfUe.Supi) | ||
| if ok { | ||
| ran.Log.Info("PendingHandoverResponse channel created by CreateUEContextProcedure") | ||
| pendingHOResponseChan = value.(chan context.PendingHandoverResponse) | ||
| } else { | ||
| // error handling for nil channel value | ||
| // send UE Context Release Command to the target RAN | ||
| ran.Log.Error("PendingHandoverResponse channel not found") | ||
| ngap_message.SendUEContextReleaseCommand(targetUe, | ||
| context.UeContextReleaseHandover, ngapType.CausePresentRadioNetwork, | ||
| ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem) | ||
| } | ||
|
|
||
| // Send the Response to CreateUEContextProcedure() | ||
| pendingHOResponseChan <- context.PendingHandoverResponse{ | ||
| Response201: &resp201, | ||
| } | ||
| } else { | ||
| // Handover in the same AMF | ||
| ran.Log.Tracef("Source: RanUeNgapID[%d] AmfUeNgapID[%d]", sourceUe.RanUeNgapId, sourceUe.AmfUeNgapId) | ||
| ran.Log.Tracef("Target: RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId) | ||
| if len(pduSessionResourceHandoverList.List) == 0 { | ||
|
|
@@ -1510,6 +1541,68 @@ func handleHandoverRequestAcknowledgeMain(ran *context.AmfRan, | |
| } | ||
| } | ||
|
|
||
| func buildUeContextCreatedData(amfUe *context.AmfUe, | ||
| pduSessionResourceHandoverList ngapType.PDUSessionResourceHandoverList, | ||
| ) (ueContextCreatedData *models.UeContextCreatedData) { | ||
| ueContextCreatedData = new(models.UeContextCreatedData) | ||
|
|
||
| ueContextCreatedData.UeContext = new(models.UeContext) | ||
| ueContextCreatedData.UeContext.Supi = amfUe.Supi | ||
| ueContextCreatedData.UeContext.SupiUnauthInd = amfUe.UnauthenticatedSupi | ||
| if amfUe.Gpsi != "" { | ||
| ueContextCreatedData.UeContext.GpsiList = append(ueContextCreatedData.UeContext.GpsiList, amfUe.Gpsi) | ||
| } | ||
| if amfUe.Pei != "" { | ||
| ueContextCreatedData.UeContext.Pei = amfUe.Pei | ||
| } | ||
| if amfUe.UdmGroupId != "" { | ||
| ueContextCreatedData.UeContext.UdmGroupId = amfUe.UdmGroupId | ||
| } | ||
| if amfUe.AusfGroupId != "" { | ||
| ueContextCreatedData.UeContext.AusfGroupId = amfUe.AusfGroupId | ||
| } | ||
| if amfUe.AccessAndMobilitySubscriptionData != nil { | ||
| if amfUe.AccessAndMobilitySubscriptionData.SubscribedUeAmbr != nil { | ||
| ueContextCreatedData.UeContext.SubUeAmbr = &models.Ambr{ | ||
| Uplink: amfUe.AccessAndMobilitySubscriptionData.SubscribedUeAmbr.Uplink, | ||
| Downlink: amfUe.AccessAndMobilitySubscriptionData.SubscribedUeAmbr.Downlink, | ||
| } | ||
| } | ||
| if amfUe.AccessAndMobilitySubscriptionData.RfspIndex != 0 { | ||
| ueContextCreatedData.UeContext.SubRfsp = amfUe.AccessAndMobilitySubscriptionData.RfspIndex | ||
| } | ||
| } | ||
| if amfUe.PcfId != "" { | ||
| ueContextCreatedData.UeContext.PcfId = amfUe.PcfId | ||
| } | ||
| if amfUe.AmPolicyUri != "" { | ||
| ueContextCreatedData.UeContext.PcfAmPolicyUri = amfUe.AmPolicyUri | ||
| } | ||
| for _, eventSub := range amfUe.EventSubscriptionsInfo { | ||
| if eventSub.EventSubscription != nil { | ||
| ueContextCreatedData.UeContext.EventSubscriptionList = append( | ||
| ueContextCreatedData.UeContext.EventSubscriptionList, *eventSub.EventSubscription) | ||
| } | ||
| } | ||
| if amfUe.TraceData != nil { | ||
| ueContextCreatedData.UeContext.TraceData = amfUe.TraceData | ||
| } | ||
|
|
||
| ueContextCreatedData.TargetToSourceData = new(models.N2InfoContent) | ||
| ueContextCreatedData.TargetToSourceData.NgapIeType = models.AmfCommunicationNgapIeType_TAR_TO_SRC_CONTAINER | ||
|
|
||
| ueContextCreatedData.TargetToSourceData.NgapData = new(models.RefToBinaryData) | ||
| ueContextCreatedData.TargetToSourceData.NgapData.ContentId = "N2InfoContent" | ||
|
|
||
| for _, pduSessionResourceHandoverItem := range pduSessionResourceHandoverList.List { | ||
| ueContextCreatedData.PduSessionList = append(ueContextCreatedData.PduSessionList, models.N2SmInformation{ | ||
| PduSessionId: int32(pduSessionResourceHandoverItem.PDUSessionID.Value), | ||
| }) | ||
| } | ||
|
|
||
| return ueContextCreatedData | ||
| } | ||
|
|
||
| func handleHandoverFailureMain(ran *context.AmfRan, | ||
| targetUe *context.RanUe, | ||
| cause *ngapType.Cause, | ||
|
|
@@ -1633,10 +1726,161 @@ func handleHandoverRequiredMain(ran *context.AmfRan, | |
| // handover between different AMF | ||
| sourceUe.Log.Warnf("Handover required : cannot find target Ran Node Id[%+v] in this AMF", targetRanNodeId) | ||
| sourceUe.Log.Error("Handover between different AMF has not been implemented yet") | ||
|
|
||
| hoFailCause = business_metrics.HANDOVER_BETWEEN_DIFFERENT_AMF_NOT_SUPPORTED | ||
| return | ||
| // TODO: Send to T-AMF | ||
| // Described in (23.502 4.9.1.3.2) step 3.Namf_Communication_CreateUEContext Request | ||
| /* | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this section remain in comment condition? If it doesn't need now, please remove it or leave the comment with why you make it as comment. |
||
| var ueContextCreateData models.UeContextCreateData | ||
| ueContextCreateData.UeContext.Supi = amfUe.Supi | ||
| ueContextCreateData.UeContext.SupiUnauthInd = amfUe.UnauthenticatedSupi | ||
| ueContextCreateData.UeContext.UdmGroupId = amfUe.UdmGroupId | ||
| ueContextCreateData.UeContext.AusfGroupId = amfUe.AusfGroupId | ||
| ueContextCreateData.UeContext.RestrictedPrimaryRatList[0] = amfUe.RatType | ||
|
|
||
| ueContextCreateData.TargetId.RanNodeId = &targetRanNodeId | ||
| ueContextCreateData.TargetId.Tai = &amfUe.Tai | ||
|
|
||
| ueContextCreateData.PduSessionList = make([]models.N2SmInformation, 0) | ||
| for _, pDUSessionResourceHoItem := range pDUSessionResourceListHORqd.List { | ||
| pduSessionID := int32(pDUSessionResourceHoItem.PDUSessionID.Value) | ||
| smContext, okSmContextFindByPDUSessionID := amfUe.SmContextFindByPDUSessionID(pduSessionID) | ||
| if !okSmContextFindByPDUSessionID { | ||
| sourceUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) | ||
| // TODO: Check if doing error handling here | ||
| continue | ||
| } | ||
| snssai := smContext.Snssai() | ||
| ueContextCreateData.PduSessionList = append(ueContextCreateData.PduSessionList, models.N2SmInformation{ | ||
| PduSessionId: pduSessionID, | ||
| SNssai: &snssai, | ||
| }) | ||
| } | ||
|
|
||
| ueContextCreateData.SourceToTargetData.NgapIeType = models.AmfCommunicationNgapIeType_HANDOVER_REQUIRED | ||
| ueContextCreateData.SourceToTargetData.NgapData.ContentId = "N2SmInfo" | ||
|
|
||
| ueContextCreateData.N2NotifyUri = "" | ||
| ueContextCreatedData, targetToSourceTransparentContainer, | ||
| problemDetails, err := consumer.GetConsumer().CreateUEContextRequest(amfUe, ueContextCreateData) | ||
|
|
||
| if problemDetails != nil { | ||
| // get UeContextCreateError (HANDOVER FAILURE) from target AMF. | ||
| // Send Handover Preparation Failure to source RAN (described in TS 38.413 8.4.1.3). | ||
| sourceUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]") | ||
| cause = &ngapType.Cause{ | ||
| Present: ngapType.CausePresentRadioNetwork, | ||
| RadioNetwork: &ngapType.CauseRadioNetwork{ | ||
| Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem, | ||
| }, | ||
| } | ||
| ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil) | ||
| return | ||
| } else if err != nil { | ||
| // error occurred in S-AMF. | ||
| sourceUe.Log.Errorf("CreateUEContextRequest Error in source AMF: %s", err.Error()) | ||
| cause = &ngapType.Cause{ | ||
| Present: ngapType.CausePresentRadioNetwork, | ||
| RadioNetwork: &ngapType.CauseRadioNetwork{ | ||
| Value: ngapType.CauseRadioNetworkPresentUnspecified, | ||
| }, | ||
| } | ||
| ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil) | ||
| } else { | ||
| // Get UeContextCreatedData from T-AMF. | ||
| // Send HandoverCommand to S-RAN. | ||
| var pduSessionResourceHandoverList ngapType.PDUSessionResourceHandoverList | ||
| var pduSessionResourceToReleaseList ngapType.PDUSessionResourceToReleaseListHOCmd | ||
|
|
||
| for _, N2SmInfo := range ueContextCreatedData.PduSessionList { | ||
| var item ngapType.PDUSessionResourceHandoverItem | ||
| item.PDUSessionID.Value = int64(N2SmInfo.PduSessionId) | ||
| } | ||
|
|
||
| ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList, | ||
| *targetToSourceTransparentContainer, nil) | ||
| /* | ||
| // describe in 23.502 4.9.1.3.2 step11 | ||
| if pDUSessionResourceAdmittedList != nil { | ||
| targetUe.Log.Infof("Send HandoverRequestAcknowledgeTransfer to SMF") | ||
| for _, item := range pDUSessionResourceAdmittedList.List { /* | ||
| pduSessionID := int32(item.PDUSessionID.Value) | ||
| transfer := item.HandoverRequestAcknowledgeTransfer | ||
| smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) | ||
| if !ok { | ||
| targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) | ||
| // TODO: Check if doing error handling here | ||
| continue | ||
| } | ||
| resp, errResponse, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe, | ||
| smContext, models.N2SmInfoType_HANDOVER_REQ_ACK, transfer) | ||
| if err != nil { | ||
| targetUe.Log.Errorf("Send HandoverRequestAcknowledgeTransfer error: %v", err) | ||
| } | ||
| if problemDetails != nil { | ||
| targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause) | ||
| } | ||
| if resp != nil && resp.BinaryDataN2SmInformation != nil { | ||
| handoverItem := ngapType.PDUSessionResourceHandoverItem{} | ||
| handoverItem.PDUSessionID = item.PDUSessionID | ||
| handoverItem.HandoverCommandTransfer = resp.BinaryDataN2SmInformation | ||
| pduSessionResourceHandoverList.List = append(pduSessionResourceHandoverList.List, handoverItem) | ||
| targetUe.SuccessPduSessionId = append(targetUe.SuccessPduSessionId, pduSessionID) | ||
| } | ||
| if errResponse != nil && errResponse.BinaryDataN2SmInformation != nil { | ||
| releaseItem := ngapType.PDUSessionResourceToReleaseItemHOCmd{} | ||
| releaseItem.PDUSessionID = item.PDUSessionID | ||
| releaseItem.HandoverPreparationUnsuccessfulTransfer = errResponse.BinaryDataN2SmInformation | ||
| pduSessionResourceToReleaseList.List = append(pduSessionResourceToReleaseList.List, releaseItem) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if pDUSessionResourceFailedToSetupListHOAck != nil { | ||
| targetUe.Log.Infof("Send HandoverResourceAllocationUnsuccessfulTransfer to SMF") | ||
| for _, item := range pDUSessionResourceFailedToSetupListHOAck.List { | ||
| pduSessionID := int32(item.PDUSessionID.Value) | ||
| transfer := item.HandoverResourceAllocationUnsuccessfulTransfer | ||
| smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) | ||
| if !ok { | ||
| targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) | ||
| // TODO: Check if doing error handling here | ||
| continue | ||
| } | ||
| _, _, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe, smContext, | ||
| models.N2SmInfoType_HANDOVER_RES_ALLOC_FAIL, transfer) | ||
| if err != nil { | ||
| targetUe.Log.Errorf("Send HandoverResourceAllocationUnsuccessfulTransfer error: %v", err) | ||
| } | ||
| if problemDetails != nil { | ||
| targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| sourceUe := targetUe.SourceUe | ||
| if sourceUe == nil { | ||
| // TODO: Send Namf_Communication_CreateUEContext Response to S-AMF | ||
| ran.Log.Error("handover between different Ue has not been implement yet") | ||
| } else { | ||
| ran.Log.Tracef("Source: RanUeNgapID[%d] AmfUeNgapID[%d]", sourceUe.RanUeNgapId, sourceUe.AmfUeNgapId) | ||
| ran.Log.Tracef("Target: RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId) | ||
| if len(pduSessionResourceHandoverList.List) == 0 { | ||
| targetUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]") | ||
| cause := &ngapType.Cause{ | ||
| Present: ngapType.CausePresentRadioNetwork, | ||
| RadioNetwork: &ngapType.CauseRadioNetwork{ | ||
| Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem, | ||
| }, | ||
| } | ||
| ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil) | ||
| return | ||
| } | ||
| ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList, | ||
| *targetToSourceTransparentContainer, nil) | ||
| } | ||
| } */ | ||
| } else { | ||
| // Handover in same AMF | ||
| sourceUe.HandOverType.Value = handoverType.Value | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After implementation, this TODO line can be removed.