Skip to content

Commit

Permalink
fix: fix linter error
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Apr 25, 2024
1 parent bc8b9c7 commit 9529486
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
44 changes: 26 additions & 18 deletions internal/gmm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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, &param)
resp, err := service.GetApp().Consumer().SendSearchNFInstances(
amfSelf.NrfUri, models.NfType_PCF, models.NfType_AMF, &param)
if err != nil {
ue.GmmLog.Error("AMF can not select an PCF by NRF")
} else {
Expand Down Expand Up @@ -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, &param)
resp, err := service.GetApp().Consumer().SendSearchNFInstances(
amfSelf.NrfUri, models.NfType_UDM, models.NfType_AMF, &param)
if err != nil {
return errors.Errorf("AMF can not select an UDM by NRF: SendSearchNFInstances failed")
}
Expand Down Expand Up @@ -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, &param)
err := service.GetApp().Consumer().SearchUdmSdmInstance(
ue, amfSelf.NrfUri, models.NfType_UDM, models.NfType_AMF, &param)
if err != nil {
ue.GmmLog.Errorf("AMF can not select an Nudm_SDM Instance by NRF[Error: %+v]", err)
time.Sleep(2 * time.Second)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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, &param)
resp, err := service.GetApp().Consumer().SendSearchNFInstances(
amfSelf.NrfUri, models.NfType_AUSF, models.NfType_AMF, &param)
if err != nil {
ue.GmmLog.Error("AMF can not select an AUSF by NRF")
gmm_message.SendRegistrationReject(ue.RanUe[accessType], nasMessage.Cause5GMMCongestion, "")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions internal/ngap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -1406,18 +1406,18 @@ 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)
}
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)
}
Expand Down
6 changes: 4 additions & 2 deletions internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9529486

Please sign in to comment.