Skip to content

Commit

Permalink
Modify DeregistrationNotificationProcedure
Browse files Browse the repository at this point in the history
- Remove the query parameter
- DeregistrationNotifcation and UECM_Deregistration are mutually exclusive
  • Loading branch information
YouShengLiu committed Oct 8, 2023
1 parent 06e5c0a commit 6f4e77e
Showing 1 changed file with 40 additions and 67 deletions.
107 changes: 40 additions & 67 deletions internal/sbi/httpcallback/api_handle_dereg_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func HTTPHandleDeregistrationNotification(c *gin.Context) {
}

ueid := c.Param("ueid")
deregType := c.Query("type")
ue, ok := amf_context.GetSelf().AmfUeFindByUeContextID(ueid)
if !ok {
logger.CallbackLog.Errorf("AmfUe Context[%s] not found", ueid)
Expand All @@ -56,7 +55,7 @@ func HTTPHandleDeregistrationNotification(c *gin.Context) {
return
}

problemDetails, err := DeregistrationNotificationProcedure(ue, deregType, deregData)
problemDetails, err := DeregistrationNotificationProcedure(ue, deregData)
if problemDetails != nil {
ue.GmmLog.Errorf("Deregistration Notification Procedure Failed Problem[%+v]", problemDetails)
} else if err != nil {
Expand All @@ -70,81 +69,55 @@ func HTTPHandleDeregistrationNotification(c *gin.Context) {
// TS 23.502 - 4.2.2.3.3 Network-initiated Deregistration
// The AMF can initiate this procedure for either explicit (e.g. by O&M intervention) or
// implicit (e.g. expiring of Implicit Deregistration timer)
func DeregistrationNotificationProcedure(ue *amf_context.AmfUe, deregType string, deregData models.DeregistrationData) (
func DeregistrationNotificationProcedure(ue *amf_context.AmfUe, deregData models.DeregistrationData) (
problemDetails *models.ProblemDetails, err error,
) {
var doUecmDereg bool = true

if deregType == "implicit" {
// The AMF does not send the Deregistration Request message to the UE for Implicit Deregistration.
switch deregData.DeregReason {
case models.DeregistrationReason_UE_INITIAL_REGISTRATION:
// TS 23.502 - 4.2.2.2.2 General Registration
// Invokes the Nsmf_PDUSession_ReleaseSMContext for the corresponding access type
ue.SmContextList.Range(func(key, value interface{}) bool {
smContext := value.(*amf_context.SmContext)
if smContext.AccessType() == deregData.AccessType {
problemDetails, err = consumer.SendReleaseSmContextRequest(ue, smContext, nil, "", nil)
if problemDetails != nil {
ue.GmmLog.Errorf("Release SmContext Failed Problem[%+v]", problemDetails)
} else if err != nil {
ue.GmmLog.Errorf("Release SmContext Error[%v]", err.Error())
}
}
return true
})
case models.DeregistrationReason_SUBSCRIPTION_WITHDRAWN:
// The notification is triggered by the new AMF executing UECM registration,
// UDM will use the new data to replace the old context.
// Therefore old AMF doesn't need to execute UECM de-registration to clean the old context stored in UDM.
doUecmDereg = false
}
// TS 23.502 - 4.2.2.2.2 General Registration - 14e
// TODO: (R16) If old AMF does not have UE context for another access type (i.e. non-3GPP access),
// the Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe
if ue.SdmSubscriptionId != "" {
problemDetails, err = consumer.SDMUnsubscribe(ue)
if problemDetails != nil {
logger.GmmLog.Errorf("SDM Unubscribe Failed Problem[%+v]", problemDetails)
} else if err != nil {
logger.GmmLog.Errorf("SDM Unubscribe Error[%+v]", err)
}
ue.SdmSubscriptionId = ""
}

if doUecmDereg {
if ue.UeCmRegistered[deregData.AccessType] {
problemDetails, err := consumer.UeCmDeregistration(ue, deregData.AccessType)
// The AMF does not send the Deregistration Request message to the UE for Implicit Deregistration.
switch deregData.DeregReason {
case models.DeregistrationReason_UE_INITIAL_REGISTRATION:
// TS 23.502 - 4.2.2.2.2 General Registration
// Invokes the Nsmf_PDUSession_ReleaseSMContext for the corresponding access type
ue.SmContextList.Range(func(key, value interface{}) bool {
smContext := value.(*amf_context.SmContext)
if smContext.AccessType() == deregData.AccessType {
problemDetails, err = consumer.SendReleaseSmContextRequest(ue, smContext, nil, "", nil)
if problemDetails != nil {
logger.GmmLog.Errorf("UECM Deregistration Failed Problem[%+v]", problemDetails)
ue.GmmLog.Errorf("Release SmContext Failed Problem[%+v]", problemDetails)
} else if err != nil {
logger.GmmLog.Errorf("UECM Deregistration Error[%+v]", err)
ue.GmmLog.Errorf("Release SmContext Error[%v]", err.Error())
}
ue.UeCmRegistered[deregData.AccessType] = false
}
return true
})
}
// TS 23.502 - 4.2.2.2.2 General Registration - 14e
// TODO: (R16) If old AMF does not have UE context for another access type (i.e. non-3GPP access),
// the Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe
if ue.SdmSubscriptionId != "" {
problemDetails, err = consumer.SDMUnsubscribe(ue)
if problemDetails != nil {
logger.GmmLog.Errorf("SDM Unubscribe Failed Problem[%+v]", problemDetails)
} else if err != nil {
logger.GmmLog.Errorf("SDM Unubscribe Error[%+v]", err)
}
ue.SdmSubscriptionId = ""
}

// TS 23.502 - 4.2.2.2.2 General Registration - 20
if ue.PolicyAssociationId != "" {
// TODO: It also needs to check if the PCF ID is tranfered to new AMF
// Currently, old AMF will transfer the PCF ID but new AMF will not utilize the PCF ID
problemDetails, err := consumer.AMPolicyControlDelete(ue)
if problemDetails != nil {
logger.GmmLog.Errorf("Delete AM policy Failed Problem[%+v]", problemDetails)
} else if err != nil {
logger.GmmLog.Errorf("Delete AM policy Error[%+v]", err)
}
// TS 23.502 - 4.2.2.2.2 General Registration - 20 AMF-Initiated Policy Association Termination
if ue.PolicyAssociationId != "" {
// TODO: It also needs to check if the PCF ID is tranfered to new AMF
// Currently, old AMF will transfer the PCF ID but new AMF will not utilize the PCF ID
problemDetails, err := consumer.AMPolicyControlDelete(ue)
if problemDetails != nil {
logger.GmmLog.Errorf("Delete AM policy Failed Problem[%+v]", problemDetails)
} else if err != nil {
logger.GmmLog.Errorf("Delete AM policy Error[%+v]", err)
}

// The old AMF should clean the UE context
// TODO: (R16) Only remove the target access UE context
ue.Remove()
} else if deregType == "explicit" {
// TODO: TS 23.502 - 4.2.2.3.3 Network-initiated Deregistration
// AMF may need to send Deregistration Request message to the UE.
} else {
logger.CallbackLog.Errorf("Deregistration Notification Procedure: unknown deregistration type: %v", deregType)
}

// The old AMF should clean the UE context
// TODO: (R16) Only remove the target access UE context
ue.Remove()

return nil, nil
}

0 comments on commit 6f4e77e

Please sign in to comment.