Skip to content

Commit

Permalink
fix: add comments and remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Aug 30, 2024
1 parent 130a12c commit dd578d7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion internal/context/amf_ran.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (ran *AmfRan) NewRanUe(ranUeNgapID int64) (*RanUe, error) {
ranUe.RanUeNgapId = ranUeNgapID
ranUe.Ran = ran
ranUe.Log = ran.Log
ranUe.FindAmfUe = nil
ranUe.HoldingAmfUe = nil
ranUe.UpdateLogFields()

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

/* Related Context*/
AmfUe *AmfUe
Ran *AmfRan
FindAmfUe *AmfUe
AmfUe *AmfUe
Ran *AmfRan
HoldingAmfUe *AmfUe // The AmfUe that is already exist (CM-Idle, Re-Registration)

/* Routing ID */
RoutingID string
Expand Down
20 changes: 10 additions & 10 deletions internal/nas/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func HandleNAS(ranUe *amf_context.RanUe, procedureCode int64, nasPdu []byte, ini
}

if ranUe.AmfUe == nil {
if ranUe.FindAmfUe != nil && !ranUe.FindAmfUe.CmConnect(ranUe.Ran.AnType) {
// models.CmState_IDLE
gmm_common.ClearHoldingRanUe(ranUe.FindAmfUe.RanUe[ranUe.Ran.AnType])
// Only the New created RanUE will have no AmfUe in it

ranUe.AmfUe = ranUe.FindAmfUe
gmm_common.AttachRanUeToAmfUeAndReleaseOldIfAny(ranUe.AmfUe, ranUe)
ranUe.FindAmfUe = nil
if ranUe.HoldingAmfUe != nil && !ranUe.HoldingAmfUe.CmConnect(ranUe.Ran.AnType) {
// If the UE is CM-IDLE, there is no RanUE in AmfUe, so here we attach new RanUe to AmfUe.
gmm_common.AttachRanUeToAmfUeAndReleaseOldIfAny(ranUe.HoldingAmfUe, ranUe)
ranUe.HoldingAmfUe = nil
} else {
// New AmfUe
// Assume we have an existing UE context in CM-CONNECTED state. (RanUe <-> AmfUe)
// We will release it if the new UE context has a valid security context(Authenticated) in line 50.
ranUe.AmfUe = amfSelf.NewAmfUe("")
gmm_common.AttachRanUeToAmfUeAndReleaseOldIfAny(ranUe.AmfUe, ranUe)
}
Expand All @@ -46,9 +46,9 @@ func HandleNAS(ranUe *amf_context.RanUe, procedureCode int64, nasPdu []byte, ini
ranUe.AmfUe.NasPduValue = nasPdu
ranUe.AmfUe.MacFailed = !integrityProtected

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

if errDispatch := Dispatch(ranUe.AmfUe, ranUe.Ran.AnType, procedureCode, msg); errDispatch != nil {
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)
ranUe.FindAmfUe = amfUe
ranUe.HoldingAmfUe = amfUe
} else if regReqType != nasMessage.RegistrationType5GSInitialRegistration {
if regReqType == nasMessage.RegistrationType5GSPeriodicRegistrationUpdating ||
regReqType == nasMessage.RegistrationType5GSMobilityRegistrationUpdating {
Expand Down

0 comments on commit dd578d7

Please sign in to comment.