diff --git a/go.mod b/go.mod index 6f8022f..258a765 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/free5gc/amf go 1.21 require ( - github.com/antihax/optional v1.0.0 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 github.com/davecgh/go-spew v1.1.1 github.com/free5gc/aper v1.0.5 @@ -43,6 +42,7 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect + github.com/h2non/gock v1.2.0 // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect @@ -73,11 +73,10 @@ require ( golang.org/x/text v0.14.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect - gopkg.in/h2non/gock.v1 v1.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/free5gc/openapi => github.com/yccodr/openapi v1.0.9-0.20240730144000-d94a13fcf6b4 +replace github.com/free5gc/openapi => github.com/free5gc/openapi v1.0.9-0.20240815044523-d494170a5c3a replace github.com/free5gc/nas => github.com/free5gc/nas v1.1.4-0.20240801045646-998afcbf3811 diff --git a/go.sum b/go.sum index c6393ea..ec72887 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 h1:+JkXLHME8vLJafGhOH4aoV2Iu8bR55nU6iKMVfYVLjY= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1/go.mod h1:nuudZmJhzWtx2212z+pkuy7B6nkBqa+xwNXZHL1j8cg= -github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/bytedance/sonic v1.11.5 h1:G00FYjjqll5iQ1PYXynbg/hyzqBqavH8Mo9/oTopd9k= @@ -65,6 +63,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= +github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE= +github.com/h2non/gock v1.2.0/go.mod h1:tNhoxHYW2W42cYkYb1WqzdbYIieALC99kpYr7rH/BQk= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -136,8 +136,6 @@ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65E github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk= github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= -github.com/yccodr/openapi v1.0.9-0.20240730144000-d94a13fcf6b4 h1:iNXXo/g3V7nqQBlXp4duj91El+HluMVlKxWhzftKPgQ= -github.com/yccodr/openapi v1.0.9-0.20240730144000-d94a13fcf6b4/go.mod h1:oy68rqnHakRLUCuEOXcis7/PWGBuil+UaXMeTBeYY8Y= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.49.0 h1:RtcvQ4iw3w9NBB5yRwgA4sSa82rfId7n4atVpvKx3bY= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.49.0/go.mod h1:f/PbKbRd4cdUICWell6DmzvVJ7QrmBgFrRHjXmAXbK4= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= @@ -173,8 +171,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= -gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/context/amf_ue.go b/internal/context/amf_ue.go index 210d9d4..bd86dcd 100644 --- a/internal/context/amf_ue.go +++ b/internal/context/amf_ue.go @@ -657,7 +657,7 @@ func (ue *AmfUe) RemoveAmPolicyAssociation() { ue.PolicyAssociationId = "" } -func (ue *AmfUe) CopyDataFromUeContextModel(ueContext models.UeContext) { +func (ue *AmfUe) CopyDataFromUeContextModel(ueContext *models.UeContext) { if ueContext.Supi != "" { ue.Supi = ueContext.Supi ue.UnauthenticatedSupi = ueContext.SupiUnauthInd @@ -683,9 +683,9 @@ func (ue *AmfUe) CopyDataFromUeContextModel(ueContext models.UeContext) { if ue.AccessAndMobilitySubscriptionData == nil { ue.AccessAndMobilitySubscriptionData = new(models.AccessAndMobilitySubscriptionData) } - if ue.AccessAndMobilitySubscriptionData.SubscribedUeAmbr == nil { - ue.AccessAndMobilitySubscriptionData.SubscribedUeAmbr = new(models.AmbrRm) - } + // if ue.AccessAndMobilitySubscriptionData.SubscribedUeAmbr == nil { + // ue.AccessAndMobilitySubscriptionData.SubscribedUeAmbr = new(models.AmbrRm) + // } subAmbr := ue.AccessAndMobilitySubscriptionData.SubscribedUeAmbr subAmbr.Uplink = ueContext.SubUeAmbr.Uplink @@ -755,34 +755,40 @@ func (ue *AmfUe) CopyDataFromUeContextModel(ueContext models.UeContext) { for _, trigger := range ueContext.AmPolicyReqTriggerList { switch trigger { case models.PolicyReqTrigger_LOCATION_CHANGE: - ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, models.PcfAmPolicyControlRequestTrigger_LOC_CH) + ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, + models.PcfAmPolicyControlRequestTrigger_LOC_CH) case models.PolicyReqTrigger_PRA_CHANGE: - ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, models.PcfAmPolicyControlRequestTrigger_PRA_CH) + ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, + models.PcfAmPolicyControlRequestTrigger_PRA_CH) case models.PolicyReqTrigger_ALLOWED_NSSAI_CHANGE: - ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, models.PcfAmPolicyControlRequestTrigger_ALLOWED_NSSAI_CH) + ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, + models.PcfAmPolicyControlRequestTrigger_ALLOWED_NSSAI_CH) case models.PolicyReqTrigger_NWDAF_DATA_CHANGE: - ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, models.PcfAmPolicyControlRequestTrigger_NWDAF_DATA_CH) + ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, + models.PcfAmPolicyControlRequestTrigger_NWDAF_DATA_CH) case models.PolicyReqTrigger_SMF_SELECT_CHANGE: - ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, models.PcfAmPolicyControlRequestTrigger_SMF_SELECT_CH) + ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, + models.PcfAmPolicyControlRequestTrigger_SMF_SELECT_CH) case models.PolicyReqTrigger_ACCESS_TYPE_CHANGE: - ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, models.PcfAmPolicyControlRequestTrigger_ACCESS_TYPE_CH) + ue.AmPolicyAssociation.Triggers = append(ue.AmPolicyAssociation.Triggers, + models.PcfAmPolicyControlRequestTrigger_ACCESS_TYPE_CH) } } } if len(ueContext.SessionContextList) > 0 { - for _, pduSessionContext := range ueContext.SessionContextList { + for index := range ueContext.SessionContextList { smContext := SmContext{ - pduSessionID: pduSessionContext.PduSessionId, - smContextRef: pduSessionContext.SmContextRef, - snssai: *pduSessionContext.SNssai, - dnn: pduSessionContext.Dnn, - accessType: pduSessionContext.AccessType, - hSmfID: pduSessionContext.HsmfId, - vSmfID: pduSessionContext.VsmfId, - nsInstance: pduSessionContext.NsInstance, + pduSessionID: ueContext.SessionContextList[index].PduSessionId, + smContextRef: ueContext.SessionContextList[index].SmContextRef, + snssai: *ueContext.SessionContextList[index].SNssai, + dnn: ueContext.SessionContextList[index].Dnn, + accessType: ueContext.SessionContextList[index].AccessType, + hSmfID: ueContext.SessionContextList[index].HsmfId, + vSmfID: ueContext.SessionContextList[index].VsmfId, + nsInstance: ueContext.SessionContextList[index].NsInstance, } - ue.StoreSmContext(pduSessionContext.PduSessionId, &smContext) + ue.StoreSmContext(ueContext.SessionContextList[index].PduSessionId, &smContext) } } diff --git a/internal/context/context.go b/internal/context/context.go index a6ff81f..cdd342b 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -101,7 +101,7 @@ type AMFContextEventSubscription struct { IsGroupUe bool UeSupiList []string Expiry *time.Time - EventSubscription models.ExtAmfEventSubscription + EventSubscription models.AmfEventSubscription } type SecurityAlgorithm struct { @@ -241,7 +241,9 @@ func (context *AMFContext) AllocateRegistrationArea(ue *AmfUe, anType models.Acc } } -func (context *AMFContext) NewAMFStatusSubscription(subscriptionData models.AmfCommunicationSubscriptionData) (subscriptionID string) { +func (context *AMFContext) NewAMFStatusSubscription(subscriptionData models.AmfCommunicationSubscriptionData) ( + subscriptionID string, +) { id, err := amfStatusSubscriptionIDGenerator.Allocate() if err != nil { logger.CtxLog.Errorf("Allocate subscriptionID error: %+v", err) @@ -254,7 +256,9 @@ func (context *AMFContext) NewAMFStatusSubscription(subscriptionData models.AmfC } // Return Value: (subscriptionData *models.SubScriptionData, ok bool) -func (context *AMFContext) FindAMFStatusSubscription(subscriptionID string) (*models.AmfCommunicationSubscriptionData, bool) { +func (context *AMFContext) FindAMFStatusSubscription(subscriptionID string) ( + *models.AmfCommunicationSubscriptionData, bool, +) { if value, ok := context.AMFStatusSubscriptions.Load(subscriptionID); ok { subscriptionData := value.(models.AmfCommunicationSubscriptionData) return &subscriptionData, ok diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index 0433f2c..a4362c5 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -131,7 +131,7 @@ func transport5GSMMessage(ue *context.AmfUe, anType models.AccessType, } ue.GmmLog.Warningf("Duplicated PDU session ID[%d]", pduSessionID) smContext.SetDuplicatedPduSessionID(true) - response, _, _, err := consumer.GetConsumer().SendUpdateSmContextRequest(smContext, updateData, nil, nil) + response, _, _, err := consumer.GetConsumer().SendUpdateSmContextRequest(smContext, &updateData, nil, nil) if err != nil { ue.GmmLog.Errorf("Failed to update smContext, local release SmContext[%d]", pduSessionID) ue.SmContextList.Delete(pduSessionID) @@ -314,7 +314,7 @@ func forward5GSMMessageToSMF( } response, errResponse, problemDetail, err := consumer.GetConsumer().SendUpdateSmContextRequest(smContext, - smContextUpdateData, smMessage, nil) + &smContextUpdateData, smMessage, nil) if err != nil { // TODO: error handling @@ -574,7 +574,7 @@ func contextTransferFromOldAmf(ue *context.AmfUe, anType models.AccessType, oldA Guami: &oldAmfGuami, } if err := consumer.GetConsumer().SearchAmfCommunicationInstance(ue, amfSelf.NrfUri, models.NrfNfManagementNfType_AMF, - models.NrfNfManagementNfType_AMF, searchOpt); err != nil { + models.NrfNfManagementNfType_AMF, &searchOpt); err != nil { return err } @@ -604,7 +604,7 @@ func contextTransferFromOldAmf(ue *context.AmfUe, anType models.AccessType, oldA ue.MacFailed = false } - ue.CopyDataFromUeContextModel(*ueContextTransferRspData.UeContext) + ue.CopyDataFromUeContextModel(ueContextTransferRspData.UeContext) if ue.SecurityContextAvailable { ue.DerivateAlgKey() } @@ -697,17 +697,17 @@ func HandleInitialRegistration(ue *context.AmfUe, anType models.AccessType) erro // } for { resp, err := consumer.GetConsumer().SendSearchNFInstances( - amfSelf.NrfUri, models.NrfNfManagementNfType_PCF, models.NrfNfManagementNfType_AMF, param) + amfSelf.NrfUri, models.NrfNfManagementNfType_PCF, models.NrfNfManagementNfType_AMF, ¶m) if err != nil { ue.GmmLog.Error("AMF can not select an PCF by NRF") } else { // select the first PCF, TODO: select base on other info var pcfUri string - for _, nfProfile := range resp.NfInstances { - pcfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NPCF_AM_POLICY_CONTROL, + for index := range resp.NfInstances { + pcfUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NPCF_AM_POLICY_CONTROL, models.NfServiceStatus_REGISTERED) if pcfUri != "" { - ue.PcfId = nfProfile.NfInstanceId + ue.PcfId = resp.NfInstances[index].NfInstanceId break } } @@ -1001,16 +1001,18 @@ func communicateWithUDM(ue *context.AmfUe, accessType models.AccessType) error { Supi: &ue.Supi, } resp, err := consumer.GetConsumer().SendSearchNFInstances( - amfSelf.NrfUri, models.NrfNfManagementNfType_UDM, models.NrfNfManagementNfType_AMF, param) + amfSelf.NrfUri, models.NrfNfManagementNfType_UDM, models.NrfNfManagementNfType_AMF, ¶m) if err != nil { return errors.Errorf("AMF can not select an UDM by NRF: SendSearchNFInstances failed") } var uecmUri, sdmUri string - for _, nfProfile := range resp.NfInstances { - ue.UdmId = nfProfile.NfInstanceId - uecmUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NUDM_UECM, models.NfServiceStatus_REGISTERED) - sdmUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NUDM_SDM, models.NfServiceStatus_REGISTERED) + for index := range resp.NfInstances { + ue.UdmId = resp.NfInstances[index].NfInstanceId + uecmUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NUDM_UECM, + models.NfServiceStatus_REGISTERED) + sdmUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NUDM_SDM, + models.NfServiceStatus_REGISTERED) if uecmUri != "" && sdmUri != "" { break } @@ -1070,7 +1072,7 @@ func getSubscribedNssai(ue *context.AmfUe) { } for { err := consumer.GetConsumer().SearchUdmSdmInstance( - ue, amfSelf.NrfUri, models.NrfNfManagementNfType_UDM, models.NrfNfManagementNfType_AMF, param) + ue, amfSelf.NrfUri, models.NrfNfManagementNfType_UDM, models.NrfNfManagementNfType_AMF, ¶m) if err != nil { ue.GmmLog.Errorf("AMF can not select an Nudm_SDM Instance by NRF[Error: %+v]", err) time.Sleep(2 * time.Second) @@ -1135,7 +1137,7 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { for { reqparam := Nnrf_NFDiscovery.SearchNFInstancesRequest{} errSearchNssf := consumer.GetConsumer().SearchNssfNSSelectionInstance( - ue, amfSelf.NrfUri, models.NrfNfManagementNfType_NSSF, models.NrfNfManagementNfType_AMF, reqparam) + ue, amfSelf.NrfUri, models.NrfNfManagementNfType_NSSF, models.NrfNfManagementNfType_AMF, &reqparam) if errSearchNssf != nil { ue.GmmLog.Errorf("AMF can not select an NSSF Instance by NRF[Error: %+v]", errSearchNssf) time.Sleep(2 * time.Second) @@ -1198,7 +1200,7 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { sendReroute := true err = consumer.GetConsumer().SearchAmfCommunicationInstance(ue, amfSelf.NrfUri, - models.NrfNfManagementNfType_AMF, models.NrfNfManagementNfType_AMF, searchTargetAmfQueryParam) + models.NrfNfManagementNfType_AMF, models.NrfNfManagementNfType_AMF, &searchTargetAmfQueryParam) if err == nil { // Condition (A) Step 7: initial AMF find Target AMF via NRF -> // Send Namf_Communication_N1MessageNotify to Target AMF @@ -1643,7 +1645,7 @@ func AuthenticationProcedure(ue *context.AmfUe, accessType models.AccessType) (b // TODO: consider ausf group id, Routing ID part of SUCI param := Nnrf_NFDiscovery.SearchNFInstancesRequest{} resp, err := consumer.GetConsumer().SendSearchNFInstances( - amfSelf.NrfUri, models.NrfNfManagementNfType_AUSF, models.NrfNfManagementNfType_AMF, param) + amfSelf.NrfUri, models.NrfNfManagementNfType_AUSF, models.NrfNfManagementNfType_AMF, ¶m) if err != nil { ue.GmmLog.Error("AMF can not select an AUSF by NRF") gmm_message.SendRegistrationReject(ue.RanUe[accessType], nasMessage.Cause5GMMCongestion, "") @@ -1652,9 +1654,10 @@ func AuthenticationProcedure(ue *context.AmfUe, accessType models.AccessType) (b // select the first AUSF, TODO: select base on other info var ausfUri string - for _, nfProfile := range resp.NfInstances { - ue.AusfId = nfProfile.NfInstanceId - ausfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NAUSF_AUTH, models.NfServiceStatus_REGISTERED) + for index := range resp.NfInstances { + ue.AusfId = resp.NfInstances[index].NfInstanceId + ausfUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NAUSF_AUTH, + models.NfServiceStatus_REGISTERED) if ausfUri != "" { break } diff --git a/internal/sbi/api_httpcallback.go b/internal/sbi/api_httpcallback.go index 8dc526c..495bab0 100644 --- a/internal/sbi/api_httpcallback.go +++ b/internal/sbi/api_httpcallback.go @@ -14,7 +14,6 @@ import ( func (s *Server) getHttpCallBackRoutes() []Route { return []Route{ { - Method: http.MethodGet, Pattern: "/", APIFunc: func(c *gin.Context) { diff --git a/internal/sbi/consumer/amf_service.go b/internal/sbi/consumer/amf_service.go index f99b7ad..5fab487 100644 --- a/internal/sbi/consumer/amf_service.go +++ b/internal/sbi/consumer/amf_service.go @@ -8,7 +8,6 @@ import ( "github.com/free5gc/amf/internal/logger" "github.com/free5gc/nas/nasMessage" "github.com/free5gc/openapi" - // "github.com/free5gc/openapi/Namf_Communication" Namf_Communication "github.com/free5gc/openapi/amf/Communication" "github.com/free5gc/openapi/models" @@ -220,7 +219,6 @@ func (s *namfService) ReleaseUEContextRequest(ue *amf_context.AmfUe, ngapCause m _, err = client.IndividualUeContextDocumentApi.ReleaseUEContext( ctx, &ueCtxReleaseReq) - if err != nil { if apiErr, ok := err.(openapi.GenericOpenAPIError); ok { problemDetails = apiErr.Model().(*models.ProblemDetails) diff --git a/internal/sbi/consumer/nrf_service.go b/internal/sbi/consumer/nrf_service.go index b4875ba..9f5e4b3 100644 --- a/internal/sbi/consumer/nrf_service.go +++ b/internal/sbi/consumer/nrf_service.go @@ -73,7 +73,7 @@ func (s *nnrfService) getNFDiscClient(uri string) *Nnrf_NFDiscovery.APIClient { } func (s *nnrfService) SendSearchNFInstances(nrfUri string, targetNfType, requestNfType models.NrfNfManagementNfType, - param Nnrf_NFDiscovery.SearchNFInstancesRequest, + param *Nnrf_NFDiscovery.SearchNFInstancesRequest, ) (*models.SearchResult, error) { // Set client and set url client := s.getNFDiscClient(nrfUri) @@ -85,17 +85,20 @@ func (s *nnrfService) SendSearchNFInstances(nrfUri string, targetNfType, request if err != nil { return nil, err } - res, err := client.NFInstancesStoreApi.SearchNFInstances(ctx, ¶m) - result := res.SearchResult + res, err := client.NFInstancesStoreApi.SearchNFInstances(ctx, param) + var result *models.SearchResult + if res != nil { + result = &res.SearchResult + } if err != nil { logger.ConsumerLog.Errorf("SearchNFInstances failed: %+v", err) } - return &result, err + return result, err } func (s *nnrfService) SearchUdmSdmInstance( ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NrfNfManagementNfType, - param Nnrf_NFDiscovery.SearchNFInstancesRequest, + param *Nnrf_NFDiscovery.SearchNFInstancesRequest, ) error { resp, localErr := s.SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param) if localErr != nil { @@ -104,9 +107,10 @@ func (s *nnrfService) SearchUdmSdmInstance( // select the first UDM_SDM, TODO: select base on other info var sdmUri string - for _, nfProfile := range resp.NfInstances { - ue.UdmId = nfProfile.NfInstanceId - sdmUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NUDM_SDM, models.NfServiceStatus_REGISTERED) + for index := range resp.NfInstances { + ue.UdmId = resp.NfInstances[index].NfInstanceId + sdmUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NUDM_SDM, + models.NfServiceStatus_REGISTERED) if sdmUri != "" { break } @@ -122,7 +126,7 @@ func (s *nnrfService) SearchUdmSdmInstance( func (s *nnrfService) SearchNssfNSSelectionInstance( ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NrfNfManagementNfType, - param Nnrf_NFDiscovery.SearchNFInstancesRequest, + param *Nnrf_NFDiscovery.SearchNFInstancesRequest, ) error { resp, localErr := s.SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param) if localErr != nil { @@ -131,9 +135,10 @@ func (s *nnrfService) SearchNssfNSSelectionInstance( // select the first NSSF, TODO: select base on other info var nssfUri string - for _, nfProfile := range resp.NfInstances { - ue.NssfId = nfProfile.NfInstanceId - nssfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NNSSF_NSSELECTION, models.NfServiceStatus_REGISTERED) + for index := range resp.NfInstances { + ue.NssfId = resp.NfInstances[index].NfInstanceId + nssfUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NNSSF_NSSELECTION, + models.NfServiceStatus_REGISTERED) if nssfUri != "" { break } @@ -146,7 +151,7 @@ func (s *nnrfService) SearchNssfNSSelectionInstance( } func (s *nnrfService) SearchAmfCommunicationInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, - requestNfType models.NrfNfManagementNfType, param Nnrf_NFDiscovery.SearchNFInstancesRequest, + requestNfType models.NrfNfManagementNfType, param *Nnrf_NFDiscovery.SearchNFInstancesRequest, ) (err error) { resp, localErr := s.SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param) if localErr != nil { @@ -156,12 +161,13 @@ func (s *nnrfService) SearchAmfCommunicationInstance(ue *amf_context.AmfUe, nrfU // select the first AMF, TODO: select base on other info var amfUri string - for _, nfProfile := range resp.NfInstances { - if nfProfile.NfInstanceId == amf_context.GetSelf().NfId { + for index := range resp.NfInstances { + if resp.NfInstances[index].NfInstanceId == amf_context.GetSelf().NfId { continue } - ue.TargetAmfProfile = &nfProfile - amfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NAMF_COMM, models.NfServiceStatus_REGISTERED) + ue.TargetAmfProfile = &resp.NfInstances[index] + amfUri = util.SearchNFServiceUri(&resp.NfInstances[index], models.ServiceName_NAMF_COMM, + models.NfServiceStatus_REGISTERED) if amfUri != "" { break } @@ -173,7 +179,9 @@ func (s *nnrfService) SearchAmfCommunicationInstance(ue *amf_context.AmfUe, nrfU return } -func (s *nnrfService) BuildNFInstance(context *amf_context.AMFContext) (profile models.NrfNfManagementNfProfile, err error) { +func (s *nnrfService) BuildNFInstance(context *amf_context.AMFContext) ( + profile models.NrfNfManagementNfProfile, err error, +) { profile.NfInstanceId = context.NfId profile.NfType = models.NrfNfManagementNfType_AMF profile.NfStatus = models.NrfNfManagementNfStatus_REGISTERED @@ -232,7 +240,7 @@ func (s *nnrfService) BuildNFInstance(context *amf_context.AMFContext) (profile return profile, err } -func (s *nnrfService) SendRegisterNFInstance(nrfUri, nfInstanceId string, profile models.NrfNfManagementNfProfile) ( +func (s *nnrfService) SendRegisterNFInstance(nrfUri, nfInstanceId string, profile *models.NrfNfManagementNfProfile) ( resouceNrfUri string, retrieveNfInstanceId string, err error, ) { // Set client and set url @@ -245,7 +253,7 @@ func (s *nnrfService) SendRegisterNFInstance(nrfUri, nfInstanceId string, profil var nf models.NrfNfManagementNfProfile registerNFInstanceRequest := &Nnrf_NFManagement.RegisterNFInstanceRequest{ NfInstanceID: &nfInstanceId, - NrfNfManagementNfProfile: &profile, + NrfNfManagementNfProfile: profile, } for { res, err = client.NFInstanceIDDocumentApi.RegisterNFInstance(context.TODO(), registerNFInstanceRequest) @@ -306,7 +314,6 @@ func (s *nnrfService) SendDeregisterNFInstance() (problemDetails *models.Problem } _, err = client.NFInstanceIDDocumentApi.DeregisterNFInstance(ctx, request) - if err != nil { if apiErr, ok := err.(openapi.GenericOpenAPIError); ok { // API error diff --git a/internal/sbi/consumer/nssf_service.go b/internal/sbi/consumer/nssf_service.go index 2c45758..57e3508 100644 --- a/internal/sbi/consumer/nssf_service.go +++ b/internal/sbi/consumer/nssf_service.go @@ -48,7 +48,8 @@ func (s *nssfService) NSSelectionGetForRegistration(ue *amf_context.AmfUe, reque } amfSelf := amf_context.GetSelf() - ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NNSSF_NSSELECTION, models.NrfNfManagementNfType_NSSF) + ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NNSSF_NSSELECTION, + models.NrfNfManagementNfType_NSSF) if err != nil { return nil, err } @@ -118,7 +119,8 @@ func (s *nssfService) NSSelectionGetForPduSession(ue *amf_context.AmfUe, snssai Tai: &ue.Tai, // TS 29.531 R15.3 6.1.3.2.3.1 } - ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NNSSF_NSSELECTION, models.NrfNfManagementNfType_NSSF) + ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NNSSF_NSSELECTION, + models.NrfNfManagementNfType_NSSF) if err != nil { return nil, nil, err } diff --git a/internal/sbi/consumer/pcf_service.go b/internal/sbi/consumer/pcf_service.go index 263836d..98b513c 100644 --- a/internal/sbi/consumer/pcf_service.go +++ b/internal/sbi/consumer/pcf_service.go @@ -50,7 +50,8 @@ func (s *npcfService) AMPolicyControlCreate( return nil, openapi.ReportError("pcf not found") } amfSelf := amf_context.GetSelf() - ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NPCF_AM_POLICY_CONTROL, models.NrfNfManagementNfType_PCF) + ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NPCF_AM_POLICY_CONTROL, + models.NrfNfManagementNfType_PCF) if err != nil { return nil, err } @@ -75,7 +76,8 @@ func (s *npcfService) AMPolicyControlCreate( policyAssociationRequest.Rfsp = ue.AccessAndMobilitySubscriptionData.RfspIndex } - res, localErr := client.AMPolicyAssociationsCollectionApi.CreateIndividualAMPolicyAssociation(ctx, &policyAssociationreq) + res, localErr := client.AMPolicyAssociationsCollectionApi. + CreateIndividualAMPolicyAssociation(ctx, &policyAssociationreq) if localErr == nil { locationHeader := res.Location logger.ConsumerLog.Debugf("location header: %+v", locationHeader) @@ -118,7 +120,8 @@ func (s *npcfService) AMPolicyControlUpdate( return nil, openapi.ReportError("pcf not found") } - ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NPCF_AM_POLICY_CONTROL, models.NrfNfManagementNfType_PCF) + ctx, _, err := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NPCF_AM_POLICY_CONTROL, + models.NrfNfManagementNfType_PCF) if err != nil { return nil, err } @@ -128,8 +131,8 @@ func (s *npcfService) AMPolicyControlUpdate( policyUpdatereq.SetPolAssoId(ue.PolicyAssociationId) policyUpdatereq.SetPcfAmPolicyControlPolicyAssociationUpdateRequest(updateRequest) - res, localErr := client.IndividualAMPolicyAssociationDocumentApi.ReportObservedEventTriggersForIndividualAMPolicyAssociation( - ctx, &policyUpdatereq) + res, localErr := client.IndividualAMPolicyAssociationDocumentApi. + ReportObservedEventTriggersForIndividualAMPolicyAssociation(ctx, &policyUpdatereq) if localErr == nil { if res.PcfAmPolicyControlPolicyUpdate.ServAreaRes != nil { ue.AmPolicyAssociation.ServAreaRes = res.PcfAmPolicyControlPolicyUpdate.ServAreaRes @@ -162,7 +165,8 @@ func (s *npcfService) AMPolicyControlDelete(ue *amf_context.AmfUe) (problemDetai return nil, openapi.ReportError("pcf not found") } - ctx, _, ctxerr := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NPCF_AM_POLICY_CONTROL, models.NrfNfManagementNfType_PCF) + ctx, _, ctxerr := amf_context.GetSelf().GetTokenCtx(models.ServiceName_NPCF_AM_POLICY_CONTROL, + models.NrfNfManagementNfType_PCF) if ctxerr != nil { return nil, ctxerr } diff --git a/internal/sbi/consumer/smf_service.go b/internal/sbi/consumer/smf_service.go index 124773a..41b7c59 100644 --- a/internal/sbi/consumer/smf_service.go +++ b/internal/sbi/consumer/smf_service.go @@ -72,7 +72,7 @@ func (s *nsmfService) SelectSmf( for { searchReq := Nnrf_NFDiscovery.SearchNFInstancesRequest{} if err := s.consumer.SearchNssfNSSelectionInstance(ue, nrfUri, models.NrfNfManagementNfType_NSSF, - models.NrfNfManagementNfType_AMF, searchReq); err != nil { + models.NrfNfManagementNfType_AMF, &searchReq); err != nil { ue.GmmLog.Errorf("AMF can not select an NSSF Instance by NRF[Error: %+v]", err) time.Sleep(2 * time.Second) } else { @@ -123,7 +123,8 @@ func (s *nsmfService) SelectSmf( ue.GmmLog.Debugf("Search SMF from NRF[%s]", nrfUri) - result, err := s.consumer.SendSearchNFInstances(nrfUri, models.NrfNfManagementNfType_SMF, models.NrfNfManagementNfType_AMF, param) + result, err := s.consumer.SendSearchNFInstances(nrfUri, models.NrfNfManagementNfType_SMF, + models.NrfNfManagementNfType_AMF, ¶m) if err != nil { return nil, nasMessage.Cause5GMMPayloadWasNotForwarded, err } @@ -134,8 +135,9 @@ func (s *nsmfService) SelectSmf( } // select the first SMF, TODO: select base on other info - for _, nfProfile := range result.NfInstances { - smfUri = util.SearchNFServiceUri(nfProfile, models.ServiceName_NSMF_PDUSESSION, models.NfServiceStatus_REGISTERED) + for index := range result.NfInstances { + smfUri = util.SearchNFServiceUri(&result.NfInstances[index], models.ServiceName_NSMF_PDUSESSION, + models.NfServiceStatus_REGISTERED) if smfUri != "" { break } @@ -147,7 +149,7 @@ func (s *nsmfService) SelectSmf( func (s *nsmfService) SendCreateSmContextRequest(ue *amf_context.AmfUe, smContext *amf_context.SmContext, requestType *models.RequestType, nasPdu []byte) ( - response *models.PostSmContextsResponse201, smContextRef string, errorResponse *models.PostSmContextsResponse400, + response *models.PostSmContextsResponse201, smContextRef string, errorResponse *models.PostSmContextsError, problemDetail *models.ProblemDetails, err1 error, ) { smContextCreateData := s.buildCreateSmContextRequest(ue, smContext, nil) @@ -249,7 +251,7 @@ func (s *nsmfService) SendUpdateSmContextActivateUpCnxState( updateData.PresenceInLadn = models.PresenceState_IN_AREA } } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, nil) } func (s *nsmfService) SendUpdateSmContextDeactivateUpCnxState(ue *amf_context.AmfUe, @@ -268,7 +270,7 @@ func (s *nsmfService) SendUpdateSmContextDeactivateUpCnxState(ue *amf_context.Am if cause.Var5GmmCause != nil { updateData.Var5gMmCauseValue = *cause.Var5GmmCause } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, nil) } func (s *nsmfService) SendUpdateSmContextChangeAccessType(ue *amf_context.AmfUe, @@ -277,7 +279,7 @@ func (s *nsmfService) SendUpdateSmContextChangeAccessType(ue *amf_context.AmfUe, ) { updateData := models.SmfPduSessionSmContextUpdateData{} updateData.AnTypeCanBeChanged = anTypeCanBeChanged - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, nil) } func (s *nsmfService) SendUpdateSmContextN2Info( @@ -289,7 +291,7 @@ func (s *nsmfService) SendUpdateSmContextN2Info( updateData.N2SmInfo = new(models.RefToBinaryData) updateData.N2SmInfo.ContentId = n2sminfocon updateData.UeLocation = &ue.Location - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, n2SmInfo) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, n2SmInfo) } func (s *nsmfService) SendUpdateSmContextXnHandover( @@ -311,7 +313,7 @@ func (s *nsmfService) SendUpdateSmContextXnHandover( updateData.PresenceInLadn = models.PresenceState_OUT_OF_AREA } } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, n2SmInfo) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, n2SmInfo) } func (s *nsmfService) SendUpdateSmContextXnHandoverFailed( @@ -325,7 +327,7 @@ func (s *nsmfService) SendUpdateSmContextXnHandoverFailed( updateData.N2SmInfo.ContentId = n2sminfocon } updateData.FailedToBeSwitched = true - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, n2SmInfo) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, n2SmInfo) } func (s *nsmfService) SendUpdateSmContextN2HandoverPreparing( @@ -347,7 +349,7 @@ func (s *nsmfService) SendUpdateSmContextN2HandoverPreparing( if amfid != "" { updateData.TargetServingNfId = amfid } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, n2SmInfo) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, n2SmInfo) } func (s *nsmfService) SendUpdateSmContextN2HandoverPrepared( @@ -361,7 +363,7 @@ func (s *nsmfService) SendUpdateSmContextN2HandoverPrepared( updateData.N2SmInfo.ContentId = n2sminfocon } updateData.HoState = models.HoState_PREPARED - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, n2SmInfo) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, n2SmInfo) } func (s *nsmfService) SendUpdateSmContextN2HandoverComplete( @@ -382,7 +384,7 @@ func (s *nsmfService) SendUpdateSmContextN2HandoverComplete( updateData.PresenceInLadn = models.PresenceState_OUT_OF_AREA } } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, nil) } func (s *nsmfService) SendUpdateSmContextN2HandoverCanceled(ue *amf_context.AmfUe, @@ -401,7 +403,7 @@ func (s *nsmfService) SendUpdateSmContextN2HandoverCanceled(ue *amf_context.AmfU if cause.Var5GmmCause != nil { updateData.Var5gMmCauseValue = *cause.Var5GmmCause } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, nil) } func (s *nsmfService) SendUpdateSmContextHandoverBetweenAccessType( @@ -414,7 +416,7 @@ func (s *nsmfService) SendUpdateSmContextHandoverBetweenAccessType( updateData.N1SmMsg = new(models.RefToBinaryData) updateData.N1SmMsg.ContentId = "N1Msg" } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, n1SmMsg, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, n1SmMsg, nil) } func (s *nsmfService) SendUpdateSmContextHandoverBetweenAMF( @@ -436,11 +438,11 @@ func (s *nsmfService) SendUpdateSmContextHandoverBetweenAMF( } } } - return s.consumer.SendUpdateSmContextRequest(smContext, updateData, nil, nil) + return s.consumer.SendUpdateSmContextRequest(smContext, &updateData, nil, nil) } func (s *nsmfService) SendUpdateSmContextRequest(smContext *amf_context.SmContext, - updateData models.SmfPduSessionSmContextUpdateData, n1Msg []byte, n2Info []byte) ( + updateData *models.SmfPduSessionSmContextUpdateData, n1Msg []byte, n2Info []byte) ( response *models.UpdateSmContextResponse200, errorResponse *models.UpdateSmContextResponse400, problemDetail *models.ProblemDetails, err1 error, ) { @@ -453,7 +455,7 @@ func (s *nsmfService) SendUpdateSmContextRequest(smContext *amf_context.SmContex updateSmContextRequest := Nsmf_PDUSession.UpdateSmContextRequest{ SmContextRef: &smCtxRef, UpdateSmContextRequest: &models.UpdateSmContextRequest{ - JsonData: &updateData, + JsonData: updateData, BinaryDataN1SmMessage: n1Msg, BinaryDataN2SmInformation: n2Info, }, diff --git a/internal/sbi/processor/callback.go b/internal/sbi/processor/callback.go index f09c2e0..cef6f57 100644 --- a/internal/sbi/processor/callback.go +++ b/internal/sbi/processor/callback.go @@ -91,7 +91,9 @@ func (p *Processor) SmContextStatusNotifyProcedure(supi string, pduSessionID int return nil } -func (p *Processor) HandleAmPolicyControlUpdateNotifyUpdate(c *gin.Context, policyUpdate models.PcfAmPolicyControlPolicyUpdate) { +func (p *Processor) HandleAmPolicyControlUpdateNotifyUpdate(c *gin.Context, + policyUpdate models.PcfAmPolicyControlPolicyUpdate, +) { logger.ProducerLog.Infoln("Handle AM Policy Control Update Notify [Policy update notification]") polAssoID := c.Param("polAssoId") @@ -299,7 +301,7 @@ func (p *Processor) N1MessageNotifyProcedure(n1MessageNotify models.N1MessageNot amfUe.Lock.Lock() defer amfUe.Lock.Unlock() - amfUe.CopyDataFromUeContextModel(*ueContext) + amfUe.CopyDataFromUeContextModel(ueContext) ranUe := ran.RanUeFindByRanUeNgapID(int64(registrationCtxtContainer.AnN2ApId)) diff --git a/internal/sbi/processor/event_exposure.go b/internal/sbi/processor/event_exposure.go index 8cde3be..bb3cea2 100644 --- a/internal/sbi/processor/event_exposure.go +++ b/internal/sbi/processor/event_exposure.go @@ -62,7 +62,26 @@ func (p *Processor) CreateAMFEventSubscriptionProcedure(createEventSubscription // store subscription in context ueEventSubscription := context.AmfUeEventSubscription{} - ueEventSubscription.EventSubscription = &contextEventSubscription.EventSubscription + extCtxEventSub := models.ExtAmfEventSubscription{ + EventList: contextEventSubscription.EventSubscription.EventList, + EventNotifyUri: contextEventSubscription.EventSubscription.EventNotifyUri, + NotifyCorrelationId: contextEventSubscription.EventSubscription.NotifyCorrelationId, + NfId: contextEventSubscription.EventSubscription.NfId, + SubsChangeNotifyUri: contextEventSubscription.EventSubscription.SubsChangeNotifyUri, + SubsChangeNotifyCorrelationId: contextEventSubscription.EventSubscription.SubsChangeNotifyCorrelationId, + Supi: contextEventSubscription.EventSubscription.Supi, + GroupId: contextEventSubscription.EventSubscription.GroupId, + ExcludeSupiList: contextEventSubscription.EventSubscription.ExcludeSupiList, + ExcludeGpsiList: contextEventSubscription.EventSubscription.ExcludeGpsiList, + IncludeSupiList: contextEventSubscription.EventSubscription.IncludeSupiList, + IncludeGpsiList: contextEventSubscription.EventSubscription.IncludeGpsiList, + Gpsi: contextEventSubscription.EventSubscription.Gpsi, + Pei: contextEventSubscription.EventSubscription.Pei, + AnyUE: contextEventSubscription.EventSubscription.AnyUE, + Options: contextEventSubscription.EventSubscription.Options, + SourceNfType: contextEventSubscription.EventSubscription.SourceNfType, + } + ueEventSubscription.EventSubscription = &extCtxEventSub ueEventSubscription.Timestamp = time.Now().UTC() if subscription.Options != nil && subscription.Options.Trigger == models.AmfEventTrigger_CONTINUOUS { @@ -78,7 +97,7 @@ func (p *Processor) CreateAMFEventSubscriptionProcedure(createEventSubscription return nil, problemDetails } - for _, events := range *subscription.EventList { + for _, events := range subscription.EventList { immediateFlags = append(immediateFlags, events.ImmediateFlag) if events.ImmediateFlag { isImmediate = true @@ -150,7 +169,7 @@ func (p *Processor) CreateAMFEventSubscriptionProcedure(createEventSubscription } for i, flag := range immediateFlags { if flag { - report, ok := p.newAmfEventReport(ue, (*subscription.EventList)[i].Type, newSubscriptionID) + report, ok := p.newAmfEventReport(ue, subscription.EventList[i].Type, newSubscriptionID) if ok { reportlist = append(reportlist, report) } @@ -174,7 +193,7 @@ func (p *Processor) CreateAMFEventSubscriptionProcedure(createEventSubscription if ue.GroupID == subscription.GroupId { for i, flag := range immediateFlags { if flag { - report, ok := p.newAmfEventReport(ue, (*subscription.EventList)[i].Type, newSubscriptionID) + report, ok := p.newAmfEventReport(ue, subscription.EventList[i].Type, newSubscriptionID) if ok { reportlist = append(reportlist, report) } @@ -197,7 +216,7 @@ func (p *Processor) CreateAMFEventSubscriptionProcedure(createEventSubscription } for i, flag := range immediateFlags { if flag { - report, ok := p.newAmfEventReport(ue, (*subscription.EventList)[i].Type, newSubscriptionID) + report, ok := p.newAmfEventReport(ue, subscription.EventList[i].Type, newSubscriptionID) if ok { reportlist = append(reportlist, report) } @@ -293,9 +312,9 @@ func (p *Processor) ModifyAMFEventSubscriptionProcedure( return nil, problemDetails } - if modifySubscriptionRequest.OptionItem != nil { - contextSubscription.Expiry = modifySubscriptionRequest.OptionItem.Value - } else if modifySubscriptionRequest.SubscriptionItemInner != nil { + if len(modifySubscriptionRequest.OptionItem) != 0 { + contextSubscription.Expiry = modifySubscriptionRequest.OptionItem[0].Value + } else if len(modifySubscriptionRequest.SubscriptionItem) != 0 { subscription := &contextSubscription.EventSubscription if !contextSubscription.IsAnyUe && !contextSubscription.IsGroupUe { if _, okAmfUeFindBySupi := amfSelf.AmfUeFindBySupi(subscription.Supi); !okAmfUeFindBySupi { @@ -306,8 +325,8 @@ func (p *Processor) ModifyAMFEventSubscriptionProcedure( return nil, problemDetails } } - op := modifySubscriptionRequest.SubscriptionItemInner.Op - index, err := strconv.Atoi(modifySubscriptionRequest.SubscriptionItemInner.Path[11:]) + op := modifySubscriptionRequest.SubscriptionItem[0].Op + index, err := strconv.Atoi(modifySubscriptionRequest.SubscriptionItem[0].Path[11:]) if err != nil { problemDetails := &models.ProblemDetails{ Status: http.StatusInternalServerError, @@ -315,27 +334,27 @@ func (p *Processor) ModifyAMFEventSubscriptionProcedure( } return nil, problemDetails } - lists := (*subscription.EventList) - eventlistLen := len(*subscription.EventList) + lists := (subscription.EventList) + eventlistLen := len(subscription.EventList) switch op { case "replace": - event := *modifySubscriptionRequest.SubscriptionItemInner.Value + event := *modifySubscriptionRequest.SubscriptionItem[0].Value if index < eventlistLen { - (*subscription.EventList)[index] = event + (subscription.EventList)[index] = event } case "remove": if index < eventlistLen { eventlist := []models.AmfEvent{} eventlist = append(eventlist, lists[:index]...) eventlist = append(eventlist, lists[index+1:]...) - *subscription.EventList = eventlist + subscription.EventList = eventlist } case "add": - event := *modifySubscriptionRequest.SubscriptionItemInner.Value + event := *modifySubscriptionRequest.SubscriptionItem[0].Value eventlist := []models.AmfEvent{} eventlist = append(eventlist, lists...) eventlist = append(eventlist, event) - *subscription.EventList = eventlist + subscription.EventList = eventlist } } diff --git a/internal/sbi/processor/n1n2message.go b/internal/sbi/processor/n1n2message.go index ff51ab2..92d5ea0 100644 --- a/internal/sbi/processor/n1n2message.go +++ b/internal/sbi/processor/n1n2message.go @@ -257,7 +257,8 @@ func (p *Processor) N1N2MessageTransferProcedure(ueContextID string, reqUri stri // UE is CM-IDLE // 409: transfer a N2 PDU Session Resource Release Command to a 5G-AN and if the UE is in CM-IDLE - if n2Info != nil && requestData.N2InfoContainer.SmInfo.N2InfoContent.NgapIeType == models.AmfCommunicationNgapIeType_PDU_RES_REL_CMD { + if n2Info != nil && + requestData.N2InfoContainer.SmInfo.N2InfoContent.NgapIeType == models.AmfCommunicationNgapIeType_PDU_RES_REL_CMD { transferErr = new(models.N1N2MessageTransferError) transferErr.Error = &models.ProblemDetails{ Status: http.StatusConflict, diff --git a/internal/sbi/processor/subscription.go b/internal/sbi/processor/subscription.go index 1d26a99..0b598e1 100644 --- a/internal/sbi/processor/subscription.go +++ b/internal/sbi/processor/subscription.go @@ -12,7 +12,9 @@ import ( ) // TS 29.518 5.2.2.5.1 -func (p *Processor) HandleAMFStatusChangeSubscribeRequest(c *gin.Context, subscriptionDataReq models.AmfCommunicationSubscriptionData) { +func (p *Processor) HandleAMFStatusChangeSubscribeRequest(c *gin.Context, + subscriptionDataReq models.AmfCommunicationSubscriptionData, +) { logger.CommLog.Info("Handle AMF Status Change Subscribe Request") subscriptionDataRsp, locationHeader, problemDetails := p.AMFStatusChangeSubscribeProcedure(subscriptionDataReq) @@ -26,7 +28,8 @@ func (p *Processor) HandleAMFStatusChangeSubscribeRequest(c *gin.Context, subscr } func (p *Processor) AMFStatusChangeSubscribeProcedure(subscriptionDataReq models.AmfCommunicationSubscriptionData) ( - subscriptionDataRsp models.AmfCommunicationSubscriptionData, locationHeader string, problemDetails *models.ProblemDetails, + subscriptionDataRsp models.AmfCommunicationSubscriptionData, locationHeader string, + problemDetails *models.ProblemDetails, ) { amfSelf := context.GetSelf() diff --git a/internal/sbi/routes.go b/internal/sbi/routes.go index 795e43b..82767aa 100644 --- a/internal/sbi/routes.go +++ b/internal/sbi/routes.go @@ -3,7 +3,7 @@ package sbi import "github.com/gin-gonic/gin" type Route struct { - Name string + Name string Method string Pattern string APIFunc gin.HandlerFunc diff --git a/internal/sbi/server.go b/internal/sbi/server.go index 76e928f..56578b9 100644 --- a/internal/sbi/server.go +++ b/internal/sbi/server.go @@ -142,7 +142,7 @@ func (s *Server) Run(traceCtx context.Context, wg *sync.WaitGroup) error { } else { profile = profileTmp } - _, nfId, err_reg := s.Consumer().SendRegisterNFInstance(s.Context().NrfUri, s.Context().NfId, profile) + _, nfId, err_reg := s.Consumer().SendRegisterNFInstance(s.Context().NrfUri, s.Context().NfId, &profile) if err_reg != nil { logger.InitLog.Warnf("Send Register NF Instance failed: %+v", err_reg) } else { diff --git a/internal/util/search_nf_service.go b/internal/util/search_nf_service.go index b50045b..ef762a3 100644 --- a/internal/util/search_nf_service.go +++ b/internal/util/search_nf_service.go @@ -6,7 +6,7 @@ import ( "github.com/free5gc/openapi/models" ) -func SearchNFServiceUri(nfProfile models.NrfNfDiscoveryNfProfile, serviceName models.ServiceName, +func SearchNFServiceUri(nfProfile *models.NrfNfDiscoveryNfProfile, serviceName models.ServiceName, nfServiceStatus models.NfServiceStatus, ) (nfUri string) { if nfProfile.NfServices != nil {