From 1ac8c65dd0ed864fe9baec40678a722bebb63def Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Mon, 30 Sep 2024 03:34:56 +0000 Subject: [PATCH] fix: comply new NF structure --- internal/sbi/consumer/udm_service.go | 22 ++++++++++++++-------- internal/sbi/processor/pdu_session.go | 8 ++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/internal/sbi/consumer/udm_service.go b/internal/sbi/consumer/udm_service.go index 629e5e1c..4ffb4032 100644 --- a/internal/sbi/consumer/udm_service.go +++ b/internal/sbi/consumer/udm_service.go @@ -179,6 +179,9 @@ func (s *nudmService) GetSmData(ctx context.Context, supi string, SDMConf := Nudm_SubscriberDataManagement.NewConfiguration() SDMConf.SetBasePath(service.ApiPrefix) client = s.getSubscribeDataManagementClient(service.ApiPrefix) + if client != nil { + break + } } } @@ -209,6 +212,9 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex SDMConf := Nudm_SubscriberDataManagement.NewConfiguration() SDMConf.SetBasePath(service.ApiPrefix) client = s.getSubscribeDataManagementClient(service.ApiPrefix) + if client != nil { + break + } } } @@ -217,7 +223,7 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex } sdmSubscription := models.SdmSubscription{ - NfInstanceId: smf_context.GetSelf().NfInstanceID, + NfInstanceId: s.consumer.Context().NfInstanceID, PlmnId: smPlmnID, } @@ -233,7 +239,7 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex }() if localErr == nil { - smf_context.GetSelf().Ues.SetSubscriptionId(smCtx.Supi, resSubscription.SubscriptionId) + s.consumer.Context().Ues.SetSubscriptionId(smCtx.Supi, resSubscription.SubscriptionId) logger.PduSessLog.Infoln("SDM Subscription Successful UE:", smCtx.Supi, "SubscriptionId:", resSubscription.SubscriptionId) } else if httpResp != nil { @@ -246,19 +252,19 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex return nil, openapi.ReportError("server no response") } - smf_context.GetSelf().Ues.IncrementPduSessionCount(smCtx.Supi) + s.consumer.Context().Ues.IncrementPduSessionCount(smCtx.Supi) return nil, nil } func (s *nudmService) UnSubscribe(smCtx *smf_context.SMContext) ( *models.ProblemDetails, error, ) { - ctx, _, oauthErr := smf_context.GetSelf().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM) + ctx, _, oauthErr := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM) if oauthErr != nil { return nil, fmt.Errorf("Get Token Context Error[%v]", oauthErr) } - if smf_context.GetSelf().Ues.IsLastPduSession(smCtx.Supi) { + if s.consumer.Context().Ues.IsLastPduSession(smCtx.Supi) { var client *Nudm_SubscriberDataManagement.APIClient for _, service := range *s.consumer.Context().UDMProfile.NfServices { if service.ServiceName == models.ServiceName_NUDM_SDM { @@ -272,7 +278,7 @@ func (s *nudmService) UnSubscribe(smCtx *smf_context.SMContext) ( return nil, fmt.Errorf("sdm client failed") } - subscriptionId := smf_context.GetSelf().Ues.GetSubscriptionId(smCtx.Supi) + subscriptionId := s.consumer.Context().Ues.GetSubscriptionId(smCtx.Supi) httpResp, localErr := client.SubscriptionDeletionApi.Unsubscribe(ctx, smCtx.Supi, subscriptionId) defer func() { @@ -295,9 +301,9 @@ func (s *nudmService) UnSubscribe(smCtx *smf_context.SMContext) ( } else { return nil, openapi.ReportError("server no response") } - smf_context.GetSelf().Ues.DeleteUe(smCtx.Supi) + s.consumer.Context().Ues.DeleteUe(smCtx.Supi) } else { - smf_context.GetSelf().Ues.DecrementPduSessionCount(smCtx.Supi) + s.consumer.Context().Ues.DecrementPduSessionCount(smCtx.Supi) } return nil, nil diff --git a/internal/sbi/processor/pdu_session.go b/internal/sbi/processor/pdu_session.go index 550335bb..4e7cdbde 100644 --- a/internal/sbi/processor/pdu_session.go +++ b/internal/sbi/processor/pdu_session.go @@ -121,7 +121,7 @@ func (p *Processor) HandlePDUSessionSMContextCreate( } } - if !smf_context.GetSelf().Ues.UeExists(smContext.Supi) { + if !p.Context().Ues.UeExists(smContext.Supi) { if problemDetails, err := p.Consumer(). Subscribe(ctx, smContext, smPlmnID); problemDetails != nil { smContext.Log.Errorln("SDM Subscription Failed Problem:", problemDetails) @@ -129,7 +129,7 @@ func (p *Processor) HandlePDUSessionSMContextCreate( smContext.Log.Errorln("SDM Subscription Error:", err) } } else { - smf_context.GetSelf().Ues.IncrementPduSessionCount(smContext.Supi) + p.Context().Ues.IncrementPduSessionCount(smContext.Supi) } establishmentRequest := m.PDUSessionEstablishmentRequest @@ -898,7 +898,7 @@ func (p *Processor) HandlePDUSessionSMContextRelease( } } - if smf_context.GetSelf().Ues.UeExists(smContext.Supi) { + if p.Context().Ues.UeExists(smContext.Supi) { problemDetails, err := p.Consumer().UnSubscribe(smContext) if problemDetails != nil { logger.PduSessLog.Errorf("SDM UnSubscription Failed Problem[%+v]", problemDetails) @@ -998,7 +998,7 @@ func (p *Processor) HandlePDUSessionSMContextLocalRelease( } } - if smf_context.GetSelf().Ues.UeExists(smContext.Supi) { + if p.Context().Ues.UeExists(smContext.Supi) { problemDetails, err := p.Consumer().UnSubscribe(smContext) if problemDetails != nil { logger.PduSessLog.Errorf("SDM UnSubscription Failed Problem[%+v]", problemDetails)