Skip to content
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

Handle Deregistration Notification Implementation #214

Merged
merged 7 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion context/amf_ran.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func (ran *AmfRan) SetRanId(ranNodeId *ngapType.GlobalRANNodeID) {
if ranId.GNbId != nil {
ran.GnbId += ranId.GNbId.GNBValue
}
AMF_Self().AmfRanPool.Store(ran.GnbId, ran)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please tell us why this is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map 'amfranpool' was populated with two entries for single NG connection.
This line of code adds one extra entry to amfranpool for the same NG connection.
Therefore, two paging messages are send by AMF.
Furthermore, this extra line of code is found in omec-project/amf repository but not in free5gc/amf repository (https://github.com/free5gc/amf/blob/main/internal/context/amf_ran.go).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please share where is the other entry added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Attaching the screenshot of the function where the other entry is added.

NewAmfRan

The function 'NewAmfRan' is called in 'ngap/dispatcher.go' (https://github.com/omec-project/amf/blob/master/ngap/dispatcher.go#L116).

}

func (ran *AmfRan) ConvertGnbIdToRanId(gnbId string) (ranNodeId *models.GlobalRanNodeId) {
Expand Down
68 changes: 68 additions & 0 deletions httpcallback/api_dereg_notify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-FileCopyrightText: 2022 Infosys Limited
// Copyright 2019 free5GC.org
//
// SPDX-License-Identifier: Apache-2.0
//

package httpcallback

import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/omec-project/amf/logger"
"github.com/omec-project/amf/producer"
"github.com/omec-project/openapi"
"github.com/omec-project/openapi/models"
"github.com/omec-project/util/httpwrapper"
)

func HTTPDeregistrationNotification(c *gin.Context) {
var deregistrationData models.DeregistrationData

requestBody, err := c.GetRawData()
if err != nil {
logger.CallbackLog.Errorf("Get Request Body error: %+v", err)
problemDetail := models.ProblemDetails{
Title: "System failure",
Status: http.StatusInternalServerError,
Detail: err.Error(),
Cause: "SYSTEM_FAILURE",
}
c.JSON(http.StatusInternalServerError, problemDetail)
return
}

err = openapi.Deserialize(&deregistrationData, requestBody, "application/json")
if err != nil {
problemDetail := "[Request Body] " + err.Error()
rsp := models.ProblemDetails{
Title: "Malformed request syntax",
Status: http.StatusBadRequest,
Detail: problemDetail,
}
logger.CallbackLog.Errorln(problemDetail)
c.JSON(http.StatusBadRequest, rsp)
return
}

req := httpwrapper.NewRequest(c.Request, deregistrationData)
if supi, exists := c.Params.Get("supi"); exists {
req.Params["supi"] = supi
}
rsp := producer.HandleDeregistrationNotification(req)

responseBody, err := openapi.Serialize(rsp.Body, "application/json")
if err != nil {
logger.CallbackLog.Errorln(err)
problemDetails := models.ProblemDetails{
Status: http.StatusInternalServerError,
Cause: "SYSTEM_FAILURE",
Detail: err.Error(),
}
c.JSON(http.StatusInternalServerError, problemDetails)
} else {
c.Data(rsp.Status, "application/json", responseBody)
}

}
6 changes: 6 additions & 0 deletions httpcallback/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,10 @@ var routes = Routes{
"/nf-status-notify",
HTTPNfSubscriptionStatusNotify,
},
{
"DeregistrationNotify",
strings.ToUpper("Post"),
":supi/deregistration-notify",
HTTPDeregistrationNotification,
},
}
49 changes: 49 additions & 0 deletions producer/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,52 @@ func NfSubscriptionStatusNotifyProcedure(notificationData models.NotificationDat

return nil
}

func HandleDeregistrationNotification(request *httpwrapper.Request) *httpwrapper.Response {
logger.ProducerLog.Infoln("Handle Deregistration Notification")
deregistrationData := request.Body.(models.DeregistrationData)

switch deregistrationData.DeregReason {
case "SUBSCRIPTION_WITHDRAWN":
amfSelf := context.AMF_Self()
if supi, exists := request.Params["supi"]; exists {
reqUri := request.URL.RequestURI()
if ue, ok := amfSelf.AmfUeFindBySupi(supi); ok {
logger.ProducerLog.Debugln("amf ue found: ", ue.Supi)
sbiMsg := context.SbiMsg{
UeContextId: ue.Supi,
ReqUri: reqUri,
Msg: nil,
Result: make(chan context.SbiResponseMsg, 10),
}
ue.EventChannel.UpdateSbiHandler(HandleOAMPurgeUEContextRequest)
ue.EventChannel.SubmitMessage(sbiMsg)
msg := <-sbiMsg.Result
if msg.ProblemDetails != nil {
return httpwrapper.NewResponse(int(msg.ProblemDetails.(*models.ProblemDetails).Status), nil, msg.ProblemDetails.(*models.ProblemDetails))
} else {
return httpwrapper.NewResponse(http.StatusNoContent, nil, nil)
}
} else {
return httpwrapper.NewResponse(http.StatusNotFound, nil, nil)
}
}

case "":
problemDetails := &models.ProblemDetails{
Status: http.StatusBadRequest,
Cause: "MANDATORY_IE_MISSING", // Defined in TS 29.503 6.2.5.2
Detail: "Missing IE [DeregReason] in DeregistrationData",
}
return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)

default:
problemDetails := &models.ProblemDetails{
Status: http.StatusNotImplemented,
Cause: "NOT_IMPLEMENTED", // Defined in TS 29.503
Detail: "Unsupported [DeregReason] in DeregistrationData",
}
return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)
}
return nil
}