1 Star 1 Fork 1

刘昭/amf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
subscriber_data_management.go 5.64 KB
一键复制 编辑 原始数据 按行查看 历史
刘昭 提交于 2022-01-25 19:22 . 1.0.1
package consumer
import (
"context"
"github.com/antihax/optional"
amf_context "gitee.com/liu-zhao234568/amf/context"
"github.com/free5gc/openapi"
"github.com/free5gc/openapi/Nudm_SubscriberDataManagement"
"github.com/free5gc/openapi/models"
)
func PutUpuAck(ue *amf_context.AmfUe, upuMacIue string) error {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
ackInfo := models.AcknowledgeInfo{
UpuMacIue: upuMacIue,
}
upuOpt := Nudm_SubscriberDataManagement.PutUpuAckParamOpts{
AcknowledgeInfo: optional.NewInterface(ackInfo),
}
_, err := client.ProvidingAcknowledgementOfUEParametersUpdateApi.PutUpuAck(context.Background(), ue.Supi, &upuOpt)
return err
}
func SDMGetAmData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
getAmDataParamOpt := Nudm_SubscriberDataManagement.GetAmDataParamOpts{
PlmnId: optional.NewInterface(ue.PlmnId.Mcc + ue.PlmnId.Mnc),
}
data, httpResp, localErr := client.AccessAndMobilitySubscriptionDataRetrievalApi.GetAmData(
context.Background(), ue.Supi, &getAmDataParamOpt)
if localErr == nil {
ue.AccessAndMobilitySubscriptionData = &data
ue.Gpsi = data.Gpsis[0] // TODO: select GPSI
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = openapi.ReportError("server no response")
}
return
}
func SDMGetSmfSelectData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
paramOpt := Nudm_SubscriberDataManagement.GetSmfSelectDataParamOpts{
PlmnId: optional.NewInterface(ue.PlmnId.Mcc + ue.PlmnId.Mnc),
}
data, httpResp, localErr :=
client.SMFSelectionSubscriptionDataRetrievalApi.GetSmfSelectData(context.Background(), ue.Supi, &paramOpt)
if localErr == nil {
ue.SmfSelectionData = &data
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = openapi.ReportError("server no response")
}
return
}
func SDMGetUeContextInSmfData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
data, httpResp, localErr :=
client.UEContextInSMFDataRetrievalApi.GetUeContextInSmfData(context.Background(), ue.Supi, nil)
if localErr == nil {
ue.UeContextInSmfData = &data
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = openapi.ReportError("server no response")
}
return
}
func SDMSubscribe(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
amfSelf := amf_context.AMF_Self()
sdmSubscription := models.SdmSubscription{
NfInstanceId: amfSelf.NfId,
PlmnId: &ue.PlmnId,
}
_, httpResp, localErr := client.SubscriptionCreationApi.Subscribe(context.Background(), ue.Supi, sdmSubscription)
if localErr == nil {
return
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = openapi.ReportError("server no response")
}
return
}
func SDMGetSliceSelectionSubscriptionData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, err error) {
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
configuration.SetBasePath(ue.NudmSDMUri)
client := Nudm_SubscriberDataManagement.NewAPIClient(configuration)
paramOpt := Nudm_SubscriberDataManagement.GetNssaiParamOpts{
PlmnId: optional.NewInterface(ue.PlmnId.Mcc + ue.PlmnId.Mnc),
}
nssai, httpResp, localErr :=
client.SliceSelectionSubscriptionDataRetrievalApi.GetNssai(context.Background(), ue.Supi, &paramOpt)
if localErr == nil {
for _, defaultSnssai := range nssai.DefaultSingleNssais {
subscribedSnssai := models.SubscribedSnssai{
SubscribedSnssai: &models.Snssai{
Sst: defaultSnssai.Sst,
Sd: defaultSnssai.Sd,
},
DefaultIndication: true,
}
ue.SubscribedNssai = append(ue.SubscribedNssai, subscribedSnssai)
}
for _, snssai := range nssai.SingleNssais {
subscribedSnssai := models.SubscribedSnssai{
SubscribedSnssai: &models.Snssai{
Sst: snssai.Sst,
Sd: snssai.Sd,
},
DefaultIndication: false,
}
ue.SubscribedNssai = append(ue.SubscribedNssai, subscribedSnssai)
}
} else if httpResp != nil {
if httpResp.Status != localErr.Error() {
err = localErr
return
}
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
} else {
err = openapi.ReportError("server no response")
}
return problemDetails, err
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liu-zhao234568/amf.git
git@gitee.com:liu-zhao234568/amf.git
liu-zhao234568
amf
amf
v1.1.0

搜索帮助