Skip to content

Commit

Permalink
Merge pull request #136 from donald1218/fix/second-ue-release-context
Browse files Browse the repository at this point in the history
fix: second ue release uecontext without authetication
  • Loading branch information
ianchen0119 authored Aug 13, 2024
2 parents 9443d1b + 89266cf commit 6c3f75b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/context/amf_ran.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (ran *AmfRan) NewRanUe(ranUeNgapID int64) (*RanUe, error) {
ranUe.RanUeNgapId = ranUeNgapID
ranUe.Ran = ran
ranUe.Log = ran.Log
ranUe.FindAmfUe = nil
ranUe.UpdateLogFields()

if ranUeNgapID != RanUeNgapIdUnspecified {
Expand Down
5 changes: 3 additions & 2 deletions internal/context/ran_ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type RanUe struct {
LastActTime *time.Time

/* Related Context*/
AmfUe *AmfUe
Ran *AmfRan
AmfUe *AmfUe
Ran *AmfRan
FindAmfUe *AmfUe

/* Routing ID */
RoutingID string
Expand Down
12 changes: 12 additions & 0 deletions internal/gmm/common/user_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ func AttachRanUeToAmfUeAndReleaseOldIfAny(ue *context.AmfUe, ranUe *context.RanU
ue.AttachRanUe(ranUe)
}

func ClearHoldingRanUe(ranUe *context.RanUe) {
if ranUe != nil {
ranUe.DetachAmfUe()
ranUe.Log.Infof("Clear Holding RanUE")
causeGroup := ngapType.CausePresentRadioNetwork
causeValue := ngapType.CauseRadioNetworkPresentReleaseDueToNgranGeneratedReason
ngap_message.SendUEContextReleaseCommand(ranUe, context.UeContextReleaseUeContext, causeGroup, causeValue)
} else {
logger.GmmLog.Warnf("RanUE is nil")
}
}

func PurgeSubscriberData(ue *context.AmfUe, accessType models.AccessType) error {
logger.GmmLog.Debugln("PurgeSubscriberData")

Expand Down
5 changes: 5 additions & 0 deletions internal/nas/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func HandleNAS(ue *amf_context.RanUe, procedureCode int64, nasPdu []byte, initia
ue.AmfUe.NasPduValue = nasPdu
ue.AmfUe.MacFailed = !integrityProtected

if ue.AmfUe.SecurityContextIsValid() && ue.FindAmfUe != nil {
gmm_common.ClearHoldingRanUe(ue.FindAmfUe.RanUe[ue.Ran.AnType])
ue.FindAmfUe = nil
}

if errDispatch := Dispatch(ue.AmfUe, ue.Ran.AnType, procedureCode, msg); errDispatch != nil {
ue.AmfUe.NASLog.Errorf("Handle NAS Error: %v", errDispatch)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ngap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func handleInitialUEMessageMain(ran *context.AmfRan,
// Described in TS 23.502 4.2.2.2.2 step 4 (without UDSF deployment)
ranUe.Log.Infof("find AmfUe [%q:%q]", idType, id)
ranUe.Log.Debugf("AmfUe Attach RanUe [RanUeNgapID: %d]", ranUe.RanUeNgapId)
gmm_common.AttachRanUeToAmfUeAndReleaseOldIfAny(amfUe, ranUe)
ranUe.FindAmfUe = amfUe
} else if regReqType != nasMessage.RegistrationType5GSInitialRegistration {
if regReqType == nasMessage.RegistrationType5GSPeriodicRegistrationUpdating ||
regReqType == nasMessage.RegistrationType5GSMobilityRegistrationUpdating {
Expand Down

0 comments on commit 6c3f75b

Please sign in to comment.