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

UDM: Add correct handling of Unsubscribe. #4

Merged
merged 1 commit into from
Apr 29, 2021
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
57 changes: 45 additions & 12 deletions producer/subscriber_data_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ func getAmDataProcedure(supi string, plmnID string, supportedFeatures string) (
}()

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.SetAMSubsriptionData(&accessAndMobilitySubscriptionDataResp)
return &accessAndMobilitySubscriptionDataResp, nil
} else {
Expand Down Expand Up @@ -248,7 +251,10 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res1.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.SetAMSubsriptionData(&amData)
subscriptionDataSets.AmData = &amData
} else {
Expand Down Expand Up @@ -285,7 +291,10 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res2.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.SetSmfSelectionSubsData(&smfSelData)
subscriptionDataSets.SmfSelData = &smfSelData
} else {
Expand Down Expand Up @@ -321,7 +330,10 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res3.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.TraceData = &traceData
udmUe.TraceDataResponse.TraceData = &traceData
subscriptionDataSets.TraceData = &traceData
Expand Down Expand Up @@ -357,7 +369,10 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res4.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
smData, _, _, _ := udm_context.UDM_Self().ManageSmData(sessionManagementSubscriptionData, "", "")
udmUe.SetSMSubsData(smData)
subscriptionDataSets.SmData = sessionManagementSubscriptionData
Expand Down Expand Up @@ -416,7 +431,10 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
ueContextInSmfDataResp.PgwInfo = pgwInfoArray

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.UeCtxtInSmfData = &ueContextInSmfDataResp
} else {
var problemDetails models.ProblemDetails
Expand Down Expand Up @@ -575,7 +593,10 @@ func getSmDataProcedure(supi string, plmnID string, Dnn string, Snssai string, s
}()

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
smData, snssaikey, AllDnnConfigsbyDnn, AllDnns := udm_context.UDM_Self().ManageSmData(
sessionManagementSubscriptionDataResp, Snssai, Dnn)
udmUe.SetSMSubsData(smData)
Expand Down Expand Up @@ -677,7 +698,10 @@ func getNssaiProcedure(supi string, plmnID string, supportedFeatures string) (
nssaiResp = *accessAndMobilitySubscriptionDataResp.Nssai

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.Nssai = &nssaiResp
return udmUe.Nssai, nil
} else {
Expand Down Expand Up @@ -753,7 +777,10 @@ func getSmfSelectDataProcedure(supi string, plmnID string, supportedFeatures str
}()

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.SetSmfSelectionSubsData(&smfSelectionSubscriptionDataResp)
return udmUe.SmfSelSubsData, nil
} else {
Expand Down Expand Up @@ -990,7 +1017,7 @@ func unsubscribeProcedure(supi string, subscriptionID string) *models.ProblemDet
return util.ProblemDetailsSystemFailure(err.Error())
}

res, err := clientAPI.SDMSubscriptionDocumentApi.RemovesdmSubscriptions(context.Background(), "====", subscriptionID)
res, err := clientAPI.SDMSubscriptionDocumentApi.RemovesdmSubscriptions(context.Background(), supi, subscriptionID)
if err != nil {
if res == nil {
logger.SdmLog.Warnln(err)
Expand Down Expand Up @@ -1228,7 +1255,10 @@ func getTraceDataProcedure(supi string, plmnID string) (
}()

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.TraceData = &traceDataRes
udmUe.TraceDataResponse.TraceData = &traceDataRes

Expand Down Expand Up @@ -1327,7 +1357,10 @@ func getUeContextInSmfDataProcedure(supi string, supportedFeatures string) (
ueContextInSmfData.PgwInfo = pgwInfoArray

if res.StatusCode == http.StatusOK {
udmUe := udm_context.UDM_Self().NewUdmUe(supi)
udmUe, ok := udm_context.UDM_Self().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.UDM_Self().NewUdmUe(supi)
}
udmUe.UeCtxtInSmfData = &ueContextInSmfData
return udmUe.UeCtxtInSmfData, nil
} else {
Expand Down
6 changes: 6 additions & 0 deletions producer/ue_context_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ func UpdateAmf3gppAccessProcedure(request models.Amf3GppAccessRegistrationModifi

return problemDetails
}

if request.PurgeFlag {
udmUe, _ := udm_context.UDM_Self().UdmUeFindBySupi(ueID)
udmUe.Amf3GppAccessRegistration = nil
}

defer func() {
if rspCloseErr := resp.Body.Close(); rspCloseErr != nil {
logger.UecmLog.Errorf("AmfContext3gpp response body cannot close: %+v", rspCloseErr)
Expand Down
2 changes: 1 addition & 1 deletion subscriberdatamanagement/api_subscription_deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// Unsubscribe - unsubscribe from notifications
func HTTPUnsubscribe(c *gin.Context) {
req := http_wrapper.NewRequest(c.Request, nil)
req.Params["ueId"] = c.Params.ByName("ueId")
req.Params["supi"] = c.Params.ByName("supi")
req.Params["subscriptionId"] = c.Params.ByName("subscriptionId")

rsp := producer.HandleUnsubscribeRequest(req)
Expand Down