From 9529486288a4cc27bb78e257aacd3c41bc5c6b17 Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Thu, 25 Apr 2024 04:28:12 +0000 Subject: [PATCH] fix: fix linter error --- internal/gmm/handler.go | 44 ++++++++++++++++------------ internal/ngap/handler.go | 10 +++---- internal/sbi/consumer/nrf_service.go | 6 ++-- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index 214027f..adf4fdc 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -260,7 +260,8 @@ func CreatePDUSession(ulNasTransport *nasMessage.ULNASTransport, } } - if newSmContext, cause, err := service.GetApp().Consumer().SelectSmf(ue, anType, pduSessionID, snssai, dnn); err != nil { + if newSmContext, cause, err := service.GetApp().Consumer().SelectSmf( + ue, anType, pduSessionID, snssai, dnn); err != nil { ue.GmmLog.Errorf("Select SMF failed: %+v", err) gmm_message.SendDLNASTransport(ue.RanUe[anType], nasMessage.PayloadContainerTypeN1SMInfo, smMessage, pduSessionID, cause, nil, 0) @@ -591,15 +592,16 @@ func contextTransferFromOldAmf(ue *context.AmfUe, anType models.AccessType, oldA case nasMessage.RegistrationType5GSPeriodicRegistrationUpdating: transferReason = models.TransferReason_MOBI_REG } - ueContextTransferRspData, problemDetails, err := service.GetApp().Consumer().UEContextTransferRequest(ue, anType, transferReason) - if problemDetails != nil { - if problemDetails.Cause == "INTEGRITY_CHECK_FAIL" || problemDetails.Cause == "CONTEXT_NOT_FOUND" { + + ueContextTransferRspData, pd, err := service.GetApp().Consumer().UEContextTransferRequest(ue, anType, transferReason) + if pd != nil { + if pd.Cause == "INTEGRITY_CHECK_FAIL" || pd.Cause == "CONTEXT_NOT_FOUND" { // TODO 9a. After successful authentication in new AMF, which is triggered by the integrity check failure // in old AMF at step 5, the new AMF invokes step 4 above again and indicates that the UE is validated //(i.e. through the reason parameter as specified in clause 5.2.2.2.2). - return fmt.Errorf("Can not retrieve UE Context from old AMF[Cause: %s]", problemDetails.Cause) + return fmt.Errorf("Can not retrieve UE Context from old AMF[Cause: %s]", pd.Cause) } - return fmt.Errorf("UE Context Transfer Request Failed Problem[%+v]", problemDetails) + return fmt.Errorf("UE Context Transfer Request Failed Problem[%+v]", pd) } else if err != nil { return fmt.Errorf("UE Context Transfer Request Error[%+v]", err) } else { @@ -701,7 +703,8 @@ func HandleInitialRegistration(ue *context.AmfUe, anType models.AccessType) erro // } for { - resp, err := service.GetApp().Consumer().SendSearchNFInstances(amfSelf.NrfUri, models.NfType_PCF, models.NfType_AMF, ¶m) + resp, err := service.GetApp().Consumer().SendSearchNFInstances( + amfSelf.NrfUri, models.NfType_PCF, models.NfType_AMF, ¶m) if err != nil { ue.GmmLog.Error("AMF can not select an PCF by NRF") } else { @@ -1006,7 +1009,8 @@ func communicateWithUDM(ue *context.AmfUe, accessType models.AccessType) error { param := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{ Supi: optional.NewString(ue.Supi), } - resp, err := service.GetApp().Consumer().SendSearchNFInstances(amfSelf.NrfUri, models.NfType_UDM, models.NfType_AMF, ¶m) + resp, err := service.GetApp().Consumer().SendSearchNFInstances( + amfSelf.NrfUri, models.NfType_UDM, models.NfType_AMF, ¶m) if err != nil { return errors.Errorf("AMF can not select an UDM by NRF: SendSearchNFInstances failed") } @@ -1075,7 +1079,8 @@ func getSubscribedNssai(ue *context.AmfUe) { Supi: optional.NewString(ue.Supi), } for { - err := service.GetApp().Consumer().SearchUdmSdmInstance(ue, amfSelf.NrfUri, models.NfType_UDM, models.NfType_AMF, ¶m) + err := service.GetApp().Consumer().SearchUdmSdmInstance( + ue, amfSelf.NrfUri, models.NfType_UDM, models.NfType_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) @@ -1138,7 +1143,8 @@ func handleRequestedNssai(ue *context.AmfUe, anType models.AccessType) error { if needSliceSelection { if ue.NssfUri == "" { for { - err := service.GetApp().Consumer().SearchNssfNSSelectionInstance(ue, amfSelf.NrfUri, models.NfType_NSSF, models.NfType_AMF, nil) + err := service.GetApp().Consumer().SearchNssfNSSelectionInstance( + ue, amfSelf.NrfUri, models.NfType_NSSF, models.NfType_AMF, nil) if err != nil { ue.GmmLog.Errorf("AMF can not select an NSSF Instance by NRF[Error: %+v]", err) time.Sleep(2 * time.Second) @@ -1647,7 +1653,8 @@ func AuthenticationProcedure(ue *context.AmfUe, accessType models.AccessType) (b // TODO: consider ausf group id, Routing ID part of SUCI param := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{} - resp, err := service.GetApp().Consumer().SendSearchNFInstances(amfSelf.NrfUri, models.NfType_AUSF, models.NfType_AMF, ¶m) + resp, err := service.GetApp().Consumer().SendSearchNFInstances( + amfSelf.NrfUri, models.NfType_AUSF, models.NfType_AMF, ¶m) if err != nil { ue.GmmLog.Error("AMF can not select an AUSF by NRF") gmm_message.SendRegistrationReject(ue.RanUe[accessType], nasMessage.Cause5GMMCongestion, "") @@ -1983,7 +1990,8 @@ func HandleAuthenticationResponse(ue *context.AmfUe, accessType models.AccessTyp } } - response, problemDetails, err := service.GetApp().Consumer().SendAuth5gAkaConfirmRequest(ue, hex.EncodeToString(resStar[:])) + response, problemDetails, err := service.GetApp().Consumer().SendAuth5gAkaConfirmRequest( + ue, hex.EncodeToString(resStar[:])) if err != nil { return err } else if problemDetails != nil { @@ -2017,11 +2025,11 @@ func HandleAuthenticationResponse(ue *context.AmfUe, accessType models.AccessTyp } } case models.AuthType_EAP_AKA_PRIME: - response, problemDetails, err := service.GetApp().Consumer().SendEapAuthConfirmRequest(ue, *authenticationResponse.EAPMessage) + response, pd, err := service.GetApp().Consumer().SendEapAuthConfirmRequest(ue, *authenticationResponse.EAPMessage) if err != nil { return err - } else if problemDetails != nil { - ue.GmmLog.Debugf("EapAuthConfirm Error[Problem Detail: %+v]", problemDetails) + } else if pd != nil { + ue.GmmLog.Debugf("EapAuthConfirm Error[Problem Detail: %+v]", pd) return nil } @@ -2152,11 +2160,11 @@ func HandleAuthenticationFailure(ue *context.AmfUe, anType models.AccessType, Rand: av5gAka.Rand, } - response, problemDetails, err := service.GetApp().Consumer().SendUEAuthenticationAuthenticateRequest(ue, resynchronizationInfo) + response, pd, err := service.GetApp().Consumer().SendUEAuthenticationAuthenticateRequest(ue, resynchronizationInfo) if err != nil { return err - } else if problemDetails != nil { - ue.GmmLog.Errorf("Nausf_UEAU Authenticate Request Error[Problem Detail: %+v]", problemDetails) + } else if pd != nil { + ue.GmmLog.Errorf("Nausf_UEAU Authenticate Request Error[Problem Detail: %+v]", pd) return nil } ue.AuthenticationCtx = response diff --git a/internal/ngap/handler.go b/internal/ngap/handler.go index 53a8e5d..87b21f7 100644 --- a/internal/ngap/handler.go +++ b/internal/ngap/handler.go @@ -1093,10 +1093,10 @@ func handleUEContextReleaseRequestMain(ran *context.AmfRan, // TODO: Check if doing error handling here continue } - response, _, _, err := service.GetApp().Consumer().SendUpdateSmContextDeactivateUpCnxState(amfUe, smContext, causeAll) + rsp, _, _, err := service.GetApp().Consumer().SendUpdateSmContextDeactivateUpCnxState(amfUe, smContext, causeAll) if err != nil { ranUe.Log.Errorf("Send Update SmContextDeactivate UpCnxState Error[%s]", err.Error()) - } else if response == nil { + } else if rsp == nil { ranUe.Log.Errorln("Send Update SmContextDeactivate UpCnxState Error") } } @@ -1406,7 +1406,7 @@ func handleHandoverRequestAcknowledgeMain(ran *context.AmfRan, // TODO: Check if doing error handling here continue } - response, errResponse, problemDetails, err := service.GetApp().Consumer().SendUpdateSmContextN2HandoverPrepared(amfUe, + resp, errResponse, problemDetails, err := service.GetApp().Consumer().SendUpdateSmContextN2HandoverPrepared(amfUe, smContext, models.N2SmInfoType_HANDOVER_REQ_ACK, transfer) if err != nil { targetUe.Log.Errorf("Send HandoverRequestAcknowledgeTransfer error: %v", err) @@ -1414,10 +1414,10 @@ func handleHandoverRequestAcknowledgeMain(ran *context.AmfRan, if problemDetails != nil { targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause) } - if response != nil && response.BinaryDataN2SmInformation != nil { + if resp != nil && resp.BinaryDataN2SmInformation != nil { handoverItem := ngapType.PDUSessionResourceHandoverItem{} handoverItem.PDUSessionID = item.PDUSessionID - handoverItem.HandoverCommandTransfer = response.BinaryDataN2SmInformation + handoverItem.HandoverCommandTransfer = resp.BinaryDataN2SmInformation pduSessionResourceHandoverList.List = append(pduSessionResourceHandoverList.List, handoverItem) targetUe.SuccessPduSessionId = append(targetUe.SuccessPduSessionId, pduSessionID) } diff --git a/internal/sbi/consumer/nrf_service.go b/internal/sbi/consumer/nrf_service.go index 1bf4e8b..230ac26 100644 --- a/internal/sbi/consumer/nrf_service.go +++ b/internal/sbi/consumer/nrf_service.go @@ -103,7 +103,8 @@ func (s *nnrfService) SendSearchNFInstances(nrfUri string, targetNfType, request return &result, err } -func (s *nnrfService) SearchUdmSdmInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NfType, +func (s *nnrfService) SearchUdmSdmInstance( + ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts, ) error { resp, localErr := s.SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param) @@ -129,7 +130,8 @@ func (s *nnrfService) SearchUdmSdmInstance(ue *amf_context.AmfUe, nrfUri string, return nil } -func (s *nnrfService) SearchNssfNSSelectionInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NfType, +func (s *nnrfService) SearchNssfNSSelectionInstance( + ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts, ) error { resp, localErr := s.SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param)