-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/implicit deregistration (#107)
* Add IE, universal time, in the configuration update command message: * Add TimeZone field in the AMFContext. * Fix bug: the format of time zone is wrong * Modify BuildConfigurationUpdateCommand * Update go module * Complete the HTTPAmfHandleDeregistrationNotification * It is a callback function for handling the Deregistration Notify from UDM. * Modify RegistrationStatusUpdateProcedure: * if amfue has completed UeCmRegisteration, RemoveAmfUe should be done in AmfHandleDeregistrationNotification. * Modify RegistrationStatusUpdateProcedure: * currently only consider the 3GPP access type * Modify HTTPAmfHandleDeregistrationNotification: * Use API to replace the duplicate code. * Add BackupAmfInfo to the AmfUe structure for UeCmDeregistration. * Expose the function "PurgeSubscriberData" from "gmm/common" package for purging the subscriber data with the specified access type. * Modify HTTPAmfHandleDeregistrationNotification * (R15) Old AMF always execute Nudm_SDM to unsubscribes with UDM. (don't consider access type) * Old AMF will determine whether to execute Nudm_UECM de-registration with UDM based on the dereg cause. * Modify HTTPAmfHandleDeregistrationNotification * Old AMF will delete the AM policy with PCF * Modify UeCmRegistration * Modify DeregCallbackUri to differentiate the access type. * Modify the file name for consistency. * Modify HTTPHandleDeregistrationNotification * Modify the structure of the handler function. * Add query parameter to differential the deregistration type is implicit or explicit. * Modify DeregistrationNotificationProcedure - Remove the query parameter - DeregistrationNotifcation and UECM_Deregistration are mutually exclusive * Leave TODO comment about policy association termination. --------- Co-authored-by: iamelisahi <[email protected]>
- Loading branch information
1 parent
ce9ce4e
commit aebc9fc
Showing
7 changed files
with
174 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
126 changes: 126 additions & 0 deletions
126
internal/sbi/httpcallback/api_handle_dereg_notification.go
This file contains 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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package httpcallback | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
|
||
amf_context "github.com/free5gc/amf/internal/context" | ||
"github.com/free5gc/amf/internal/logger" | ||
"github.com/free5gc/amf/internal/sbi/consumer" | ||
"github.com/free5gc/openapi" | ||
"github.com/free5gc/openapi/models" | ||
) | ||
|
||
func HTTPHandleDeregistrationNotification(c *gin.Context) { | ||
// TS 23.502 - 4.2.2.2.2 - step 14d | ||
logger.CallbackLog.Infoln("Handle Deregistration Notification") | ||
|
||
var deregData models.DeregistrationData | ||
|
||
requestBody, err := c.GetRawData() | ||
if err != nil { | ||
logger.CallbackLog.Errorf("Get Request Body error: %+v", err) | ||
problemDetails := models.ProblemDetails{ | ||
Title: "System failure", | ||
Status: http.StatusInternalServerError, | ||
Detail: err.Error(), | ||
Cause: "SYSTEM_FAILURE", | ||
} | ||
c.JSON(http.StatusInternalServerError, problemDetails) | ||
return | ||
} | ||
|
||
err = openapi.Deserialize(&deregData, requestBody, "application/json") | ||
if err != nil { | ||
problemDetails := models.ProblemDetails{ | ||
Title: "Malformed request syntax", | ||
Status: http.StatusBadRequest, | ||
Detail: "[Request Body] " + err.Error(), | ||
} | ||
logger.CallbackLog.Errorln(problemDetails.Detail) | ||
c.JSON(http.StatusBadRequest, problemDetails) | ||
return | ||
} | ||
|
||
ueid := c.Param("ueid") | ||
ue, ok := amf_context.GetSelf().AmfUeFindByUeContextID(ueid) | ||
if !ok { | ||
logger.CallbackLog.Errorf("AmfUe Context[%s] not found", ueid) | ||
problemDetails := models.ProblemDetails{ | ||
Status: http.StatusNotFound, | ||
Cause: "CONTEXT_NOT_FOUND", | ||
} | ||
c.JSON(http.StatusNotFound, problemDetails) | ||
return | ||
} | ||
|
||
problemDetails, err := DeregistrationNotificationProcedure(ue, deregData) | ||
if problemDetails != nil { | ||
ue.GmmLog.Errorf("Deregistration Notification Procedure Failed Problem[%+v]", problemDetails) | ||
} else if err != nil { | ||
ue.GmmLog.Errorf("Deregistration Notification Procedure Error[%v]", err.Error()) | ||
} | ||
// TS 23.503 - 5.3.2.3.2 UDM initiated NF Deregistration | ||
// The AMF acknowledges the Nudm_UECM_DeRegistrationNotification to the UDM. | ||
c.JSON(http.StatusNoContent, nil) | ||
} | ||
|
||
// 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, deregData models.DeregistrationData) ( | ||
problemDetails *models.ProblemDetails, err error, | ||
) { | ||
// 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 | ||
}) | ||
} | ||
// 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 AMF-Initiated Policy Association Termination | ||
// For UE_INITIAL_REGISTRATION and SUBSCRIPTION_WITHDRAW, do AMF-Initiated Policy Association Termination directly. | ||
if ue.PolicyAssociationId != "" { | ||
// TODO: For REGISTRATION_AREA_CHANGE, old AMF performs an AMF-initiated Policy Association Termination | ||
// procedure if the old AMF has established an AM Policy Association and a UE Policy Association with the PCF(s) | ||
// and the old AMF did not transfer the PCF ID(s) to the new AMF. (Ref: TS 23.502 - 4.2.2.2.2) | ||
// 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() | ||
|
||
return nil, nil | ||
} |
This file contains 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 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