From b6b07f73a06caaed42707ba7d0fb626578f96f05 Mon Sep 17 00:00:00 2001 From: RyuichiNamba-fj <73165618+RyuichiNamba-fj@users.noreply.github.com> Date: Sun, 6 Feb 2022 11:29:02 +0900 Subject: [PATCH] Fix: Log information is not updated (#61) * Fix: Log information is not updated - When AttachRanUe()/DetatchRanUe() is executed, it is modified to set the log information. - When Ran information is switched by SwitchToRan(), the log information is also updated. - Changed to put RanUeNgapID in NGAP Handler log as much as possible. * fix log format Co-authored-by: free5GC --- context/amf_ran.go | 2 +- context/amf_ue.go | 24 ++++++++++- context/ran_ue.go | 14 +++++++ gmm/sm.go | 6 +-- ngap/handler.go | 102 +++++++++++++++++++++++---------------------- 5 files changed, 90 insertions(+), 58 deletions(-) diff --git a/context/amf_ran.go b/context/amf_ran.go index 89a70638..6d043c59 100644 --- a/context/amf_ran.go +++ b/context/amf_ran.go @@ -61,7 +61,7 @@ func (ran *AmfRan) NewRanUe(ranUeNgapID int64) (*RanUe, error) { ranUe.AmfUeNgapId = amfUeNgapID ranUe.RanUeNgapId = ranUeNgapID ranUe.Ran = ran - ranUe.Log = ran.Log.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId)) + ranUe.UpdateLogFields() ran.RanUeList = append(ran.RanUeList, &ranUe) self.RanUePool.Store(ranUe.AmfUeNgapId, &ranUe) diff --git a/context/amf_ue.go b/context/amf_ue.go index 2c5d2b0e..d2b132b4 100644 --- a/context/amf_ue.go +++ b/context/amf_ue.go @@ -292,6 +292,7 @@ func (ue *AmfUe) Remove() { func (ue *AmfUe) DetachRanUe(anType models.AccessType) { delete(ue.RanUe, anType) + ue.UpdateLogFields() } func (ue *AmfUe) AttachRanUe(ranUe *RanUe) { @@ -302,8 +303,27 @@ func (ue *AmfUe) AttachRanUe(ranUe *RanUe) { } ue.RanUe[ranUe.Ran.AnType] = ranUe ranUe.AmfUe = ue - ue.NASLog = logger.NasLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId)) - ue.GmmLog = logger.GmmLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId)) + ue.UpdateLogFields() +} + +func (ue *AmfUe) UpdateLogFields() { + nasLog := logger.NasLog + gmmLog := logger.GmmLog + producerLog := logger.ProducerLog + + if ranUe, ok := ue.RanUe[models.AccessType__3_GPP_ACCESS]; ok { + nasLog = nasLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId)) + gmmLog = gmmLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId)) + } + if ue.Supi != "" { + nasLog = nasLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", ue.Supi)) + gmmLog = gmmLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", ue.Supi)) + producerLog = producerLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", ue.Supi)) + } + + ue.NASLog = nasLog + ue.GmmLog = gmmLog + ue.ProducerLog = producerLog } func (ue *AmfUe) GetAnType() models.AccessType { diff --git a/context/ran_ue.go b/context/ran_ue.go index 602990c6..ba59d4df 100644 --- a/context/ran_ue.go +++ b/context/ran_ue.go @@ -124,6 +124,9 @@ func (ranUe *RanUe) SwitchToRan(newRan *AmfRan, ranUeNgapId int64) error { ranUe.Ran = newRan ranUe.RanUeNgapId = ranUeNgapId + // update log information + ranUe.UpdateLogFields() + logger.ContextLog.Infof("RanUe[RanUeNgapID: %d] Switch to new Ran[Name: %s]", ranUe.RanUeNgapId, ranUe.Ran.Name) return nil } @@ -240,3 +243,14 @@ func (ranUe *RanUe) UpdateLocation(userLocationInformation *ngapType.UserLocatio case ngapType.UserLocationInformationPresentNothing: } } + +func (ranUe *RanUe) UpdateLogFields() { + ngapLog := logger.NgapLog + + if ranUe.Ran != nil && ranUe.Ran.Conn != nil { + ngapLog = ngapLog.WithField(logger.FieldRanAddr, ranUe.Ran.Conn.RemoteAddr().String()) + ngapLog = ngapLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId)) + } + + ranUe.Log = ngapLog +} diff --git a/gmm/sm.go b/gmm/sm.go index 9389181e..6df8f3d0 100644 --- a/gmm/sm.go +++ b/gmm/sm.go @@ -1,8 +1,6 @@ package gmm import ( - "fmt" - "github.com/free5gc/amf/consumer" "github.com/free5gc/amf/context" gmm_message "github.com/free5gc/amf/gmm/message" @@ -224,9 +222,7 @@ func SecurityMode(state *fsm.State, event fsm.EventType, args fsm.ArgsType) { amfUe := args[ArgAmfUe].(*context.AmfUe) accessType := args[ArgAccessType].(models.AccessType) // set log information - amfUe.NASLog = amfUe.NASLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", amfUe.Supi)) - amfUe.GmmLog = amfUe.GmmLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", amfUe.Supi)) - amfUe.ProducerLog = logger.ProducerLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", amfUe.Supi)) + amfUe.UpdateLogFields() amfUe.GmmLog.Debugln("EntryEvent at GMM State[SecurityMode]") if amfUe.SecurityContextIsValid() { diff --git a/ngap/handler.go b/ngap/handler.go index 7226a92b..6636885b 100644 --- a/ngap/handler.go +++ b/ngap/handler.go @@ -173,7 +173,6 @@ func HandleUplinkNasTransport(ran *context.AmfRan, message *ngapType.NGAPPDU) { ran.Log.Error("UplinkNasTransport is nil") return } - ran.Log.Info("Handle Uplink Nas Transport") for i := 0; i < len(uplinkNasTransport.ProtocolIEs.List); i++ { ie := uplinkNasTransport.ProtocolIEs.List[i] @@ -410,8 +409,6 @@ func HandleUEContextReleaseComplete(ran *context.AmfRan, message *ngapType.NGAPP return } - ran.Log.Info("Handle UE Context Release Complete") - for _, ie := range uEContextReleaseComplete.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: @@ -459,6 +456,8 @@ func HandleUEContextReleaseComplete(ran *context.AmfRan, message *ngapType.NGAPP return } + ranUe.Log.Info("Handle UE Context Release Complete") + if userLocationInformation != nil { ranUe.UpdateLocation(userLocationInformation) } @@ -556,17 +555,17 @@ func HandleUEContextReleaseComplete(ran *context.AmfRan, message *ngapType.NGAPP delete(amfUe.ReleaseCause, ran.AnType) switch ranUe.ReleaseAction { case context.UeContextN2NormalRelease: - ran.Log.Infof("Release UE[%s] Context : N2 Connection Release", amfUe.Supi) + ranUe.Log.Infof("Release UE[%s] Context : N2 Connection Release", amfUe.Supi) // amfUe.DetachRanUe(ran.AnType) err := ranUe.Remove() if err != nil { ran.Log.Errorln(err.Error()) } case context.UeContextReleaseUeContext: - ran.Log.Infof("Release UE[%s] Context : Release Ue Context", amfUe.Supi) + ranUe.Log.Infof("Release UE[%s] Context : Release Ue Context", amfUe.Supi) gmm_common.RemoveAmfUe(amfUe) case context.UeContextReleaseHandover: - ran.Log.Infof("Release UE[%s] Context : Release for Handover", amfUe.Supi) + ranUe.Log.Infof("Release UE[%s] Context : Release for Handover", amfUe.Supi) // TODO: it's a workaround, need to fix it. targetRanUe := context.AMF_Self().RanUeFindByAmfUeNgapID(ranUe.TargetUe.AmfUeNgapId) @@ -608,8 +607,6 @@ func HandlePDUSessionResourceReleaseResponse(ran *context.AmfRan, message *ngapT return } - ran.Log.Info("Handle PDU Session Resource Release Response") - for _, ie := range pDUSessionResourceReleaseResponse.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: @@ -648,6 +645,8 @@ func HandlePDUSessionResourceReleaseResponse(ran *context.AmfRan, message *ngapT return } + ranUe.Log.Info("Handle PDU Session Resource Release Response") + if userLocationInformation != nil { ranUe.UpdateLocation(userLocationInformation) } @@ -713,7 +712,6 @@ func HandleUERadioCapabilityCheckResponse(ran *context.AmfRan, message *ngapType ran.Log.Error("UERadioCapabilityCheckResponse is nil") return } - ran.Log.Info("Handle UE Radio Capability Check Response") for i := 0; i < len(uERadioCapabilityCheckResponse.ProtocolIEs.List); i++ { ie := uERadioCapabilityCheckResponse.ProtocolIEs.List[i] @@ -751,6 +749,8 @@ func HandleUERadioCapabilityCheckResponse(ran *context.AmfRan, message *ngapType return } + ranUe.Log.Info("Handle UE Radio Capability Check Response") + // TODO: handle iMSVoiceSupportIndicator if criticalityDiagnostics != nil { @@ -784,8 +784,6 @@ func HandleLocationReportingFailureIndication(ran *context.AmfRan, message *ngap return } - ran.Log.Info("Handle Location Reporting Failure Indication") - for i := 0; i < len(locationReportingFailureIndication.ProtocolIEs.List); i++ { ie := locationReportingFailureIndication.ProtocolIEs.List[i] switch ie.Id.Value { @@ -820,6 +818,7 @@ func HandleLocationReportingFailureIndication(ran *context.AmfRan, message *ngap ran.Log.Errorf("No UE Context[RanUeNgapID: %d]", rANUENGAPID.Value) return } + ranUe.Log.Info("Handle Location Reporting Failure Indication") } func HandleInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU) { @@ -1022,8 +1021,6 @@ func HandlePDUSessionResourceSetupResponse(ran *context.AmfRan, message *ngapTyp return } - ran.Log.Info("Handle PDU Session Resource Setup Response") - for _, ie := range pDUSessionResourceSetupResponse.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // ignore @@ -1060,6 +1057,7 @@ func HandlePDUSessionResourceSetupResponse(ran *context.AmfRan, message *ngapTyp } if ranUe != nil { + ranUe.Log.Info("Handle PDU Session Resource Setup Response") ranUe.Log.Tracef("AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) amfUe := ranUe.AmfUe if amfUe == nil { @@ -1150,8 +1148,6 @@ func HandlePDUSessionResourceModifyResponse(ran *context.AmfRan, message *ngapTy return } - ran.Log.Info("Handle PDU Session Resource Modify Response") - for _, ie := range pDUSessionResourceModifyResponse.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // ignore @@ -1191,6 +1187,7 @@ func HandlePDUSessionResourceModifyResponse(ran *context.AmfRan, message *ngapTy } if ranUe != nil { + ranUe.Log.Info("Handle PDU Session Resource Modify Response") ranUe.Log.Tracef("AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) amfUe := ranUe.AmfUe if amfUe == nil { @@ -1323,6 +1320,7 @@ func HandlePDUSessionResourceNotify(ran *context.AmfRan, message *ngapType.NGAPP return } + ranUe.Log.Info("Handle PDU Session Resource Notify") ranUe.Log.Tracef("AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) amfUe := ranUe.AmfUe if amfUe == nil { @@ -1489,8 +1487,6 @@ func HandlePDUSessionResourceModifyIndication(ran *context.AmfRan, message *ngap return } - ran.Log.Info("Handle PDU Session Resource Modify Indication") - for _, ie := range pDUSessionResourceModifyIndication.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // reject @@ -1548,6 +1544,7 @@ func HandlePDUSessionResourceModifyIndication(ran *context.AmfRan, message *ngap return } + ranUe.Log.Info("Handle PDU Session Resource Modify Indication") ran.Log.Tracef("UE Context AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) amfUe := ranUe.AmfUe @@ -1613,8 +1610,6 @@ func HandleInitialContextSetupResponse(ran *context.AmfRan, message *ngapType.NG return } - ran.Log.Info("Handle Initial Context Setup Response") - for _, ie := range initialContextSetupResponse.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: @@ -1662,6 +1657,7 @@ func HandleInitialContextSetupResponse(ran *context.AmfRan, message *ngapType.NG } ran.Log.Tracef("RanUeNgapID[%d] AmfUeNgapID[%d]", ranUe.RanUeNgapId, ranUe.AmfUeNgapId) + ranUe.Log.Info("Handle Initial Context Setup Response") if pDUSessionResourceSetupResponseList != nil { ranUe.Log.Trace("Send PDUSessionResourceSetupResponseTransfer to SMF") @@ -1748,8 +1744,6 @@ func HandleInitialContextSetupFailure(ran *context.AmfRan, message *ngapType.NGA return } - ran.Log.Info("Handle Initial Context Setup Failure") - for _, ie := range initialContextSetupFailure.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: @@ -1795,9 +1789,12 @@ func HandleInitialContextSetupFailure(ran *context.AmfRan, message *ngapType.NGA ran.Log.Errorf("No UE Context[RanUeNgapID: %d]", rANUENGAPID.Value) return } + + ranUe.Log.Info("Handle Initial Context Setup Failure") + amfUe := ranUe.AmfUe if amfUe == nil { - ran.Log.Error("amfUe is nil") + ranUe.Log.Error("amfUe is nil") return } @@ -1851,8 +1848,6 @@ func HandleUEContextReleaseRequest(ran *context.AmfRan, message *ngapType.NGAPPD return } - ran.Log.Info("UE Context Release Request") - for _, ie := range uEContextReleaseRequest.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: @@ -1895,6 +1890,7 @@ func HandleUEContextReleaseRequest(ran *context.AmfRan, message *ngapType.NGAPPD } ran.Log.Tracef("RanUeNgapID[%d] AmfUeNgapID[%d]", ranUe.RanUeNgapId, ranUe.AmfUeNgapId) + ranUe.Log.Info("Handle UE Context Release Request") causeGroup := ngapType.CausePresentRadioNetwork causeValue := ngapType.CauseRadioNetworkPresentUnspecified @@ -1985,8 +1981,6 @@ func HandleUEContextModificationResponse(ran *context.AmfRan, message *ngapType. return } - ran.Log.Info("Handle UE Context Modification Response") - for _, ie := range uEContextModificationResponse.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // ignore @@ -2030,6 +2024,7 @@ func HandleUEContextModificationResponse(ran *context.AmfRan, message *ngapType. if ranUe != nil { ranUe.Log.Tracef("AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) + ranUe.Log.Info("Handle UE Context Modification Response") if rRCState != nil { switch rRCState.Value { @@ -2077,8 +2072,6 @@ func HandleUEContextModificationFailure(ran *context.AmfRan, message *ngapType.N return } - ran.Log.Info("Handle UE Context Modification Failure") - for _, ie := range uEContextModificationFailure.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // ignore @@ -2121,6 +2114,7 @@ func HandleUEContextModificationFailure(ran *context.AmfRan, message *ngapType.N if ranUe != nil { ran.Log.Tracef("AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) + ranUe.Log.Info("Handle UE Context Modification Failure") } if cause != nil { @@ -2158,7 +2152,6 @@ func HandleRRCInactiveTransitionReport(ran *context.AmfRan, message *ngapType.NG ran.Log.Error("RRCInactiveTransitionReport is nil") return } - ran.Log.Info("Handle RRC Inactive Transition Report") for i := 0; i < len(rRCInactiveTransitionReport.ProtocolIEs.List); i++ { ie := rRCInactiveTransitionReport.ProtocolIEs.List[i] @@ -2199,6 +2192,7 @@ func HandleRRCInactiveTransitionReport(ran *context.AmfRan, message *ngapType.NG ran.Log.Warnf("No UE Context[RanUeNgapID: %d]", rANUENGAPID.Value) } else { ran.Log.Tracef("RANUENGAPID[%d] AMFUENGAPID[%d]", ranUe.RanUeNgapId, ranUe.AmfUeNgapId) + ranUe.Log.Info("Handle RRC Inactive Transition Report") if rRCState != nil { switch rRCState.Value { @@ -2237,8 +2231,6 @@ func HandleHandoverNotify(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } - ran.Log.Info("Handle Handover notification") - for i := 0; i < len(HandoverNotify.ProtocolIEs.List); i++ { ie := HandoverNotify.ProtocolIEs.List[i] switch ie.Id.Value { @@ -2280,6 +2272,8 @@ func HandleHandoverNotify(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } + targetUe.Log.Info("Handle Handover notification") + if userLocationInformation != nil { targetUe.UpdateLocation(userLocationInformation) } @@ -2294,7 +2288,7 @@ func HandleHandoverNotify(ran *context.AmfRan, message *ngapType.NGAPPDU) { // Desciibed in (23.502 4.9.1.3.3) [conditional] 6a.Namf_Communication_N2InfoNotify. ran.Log.Error("N2 Handover between AMF has not been implemented yet") } else { - ran.Log.Info("Handle Handover notification Finshed ") + targetUe.Log.Info("Handle Handover notification Finshed ") for _, pduSessionid := range targetUe.SuccessPduSessionId { smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionid) if !ok { @@ -2344,8 +2338,6 @@ func HandlePathSwitchRequest(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } - ran.Log.Info("Handle Path Switch Request") - for _, ie := range pathSwitchRequest.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDRANUENGAPID: // reject @@ -2393,6 +2385,7 @@ func HandlePathSwitchRequest(ran *context.AmfRan, message *ngapType.NGAPPDU) { } ran.Log.Tracef("AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) + ranUe.Log.Info("Handle Path Switch Request") amfUe := ranUe.AmfUe if amfUe == nil { @@ -2537,8 +2530,6 @@ func HandleHandoverRequestAcknowledge(ran *context.AmfRan, message *ngapType.NGA return } - ran.Log.Info("Handle Handover Request Acknowledge") - for _, ie := range handoverRequestAcknowledge.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // ignore @@ -2588,8 +2579,11 @@ func HandleHandoverRequestAcknowledge(ran *context.AmfRan, message *ngapType.NGA return } + targetUe.Log.Info("Handle Handover Request Acknowledge") + if rANUENGAPID != nil { targetUe.RanUeNgapId = rANUENGAPID.Value + targetUe.UpdateLogFields() } ran.Log.Debugf("Target Ue RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId) @@ -2740,6 +2734,8 @@ func HandleHandoverFailure(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } + targetUe.Log.Info("Handle Handover Failure") + sourceUe := targetUe.SourceUe if sourceUe == nil { // TODO: handle N2 Handover between AMF @@ -2758,7 +2754,7 @@ func HandleHandoverFailure(ran *context.AmfRan, message *ngapType.NGAPPDU) { } _, _, _, err := consumer.SendUpdateSmContextN2HandoverCanceled(amfUe, smContext, causeAll) if err != nil { - ran.Log.Errorf("Send UpdateSmContextN2HandoverCanceled Error for PduSessionId[%d]", pduSessionID) + amfUe.ProducerLog.Errorf("Send UpdateSmContextN2HandoverCanceled Error for PduSessionId[%d]", pduSessionID) } return true }) @@ -2799,7 +2795,6 @@ func HandleHandoverRequired(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } - ran.Log.Info("Handle HandoverRequired\n") for i := 0; i < len(HandoverRequired.ProtocolIEs.List); i++ { ie := HandoverRequired.ProtocolIEs.List[i] switch ie.Id.Value { @@ -2887,6 +2882,9 @@ func HandleHandoverRequired(ran *context.AmfRan, message *ngapType.NGAPPDU) { ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, &cause, nil) return } + + sourceUe.Log.Info("Handle HandoverRequired") + amfUe := sourceUe.AmfUe if amfUe == nil { ran.Log.Error("Cannot find amfUE from sourceUE") @@ -2990,7 +2988,6 @@ func HandleHandoverCancel(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } - ran.Log.Info("Handle Handover Cancel") for i := 0; i < len(HandoverCancel.ProtocolIEs.List); i++ { ie := HandoverCancel.ProtocolIEs.List[i] switch ie.Id.Value { @@ -3031,6 +3028,8 @@ func HandleHandoverCancel(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } + sourceUe.Log.Info("Handle Handover Cancel") + if sourceUe.AmfUeNgapId != aMFUENGAPID.Value { ran.Log.Warnf("Conflict AMF_UE_NGAP_ID : %d != %d", sourceUe.AmfUeNgapId, aMFUENGAPID.Value) } @@ -3096,8 +3095,6 @@ func HandleUplinkRanStatusTransfer(ran *context.AmfRan, message *ngapType.NGAPPD return } - ran.Log.Info("Handle Uplink Ran Status Transfer") - for _, ie := range uplinkRanStatusTransfer.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // reject @@ -3127,7 +3124,8 @@ func HandleUplinkRanStatusTransfer(ran *context.AmfRan, message *ngapType.NGAPPD return } - ranUe.Log.Tracef("UE Context AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) + ran.Log.Tracef("UE Context AmfUeNgapID[%d] RanUeNgapID[%d]", ranUe.AmfUeNgapId, ranUe.RanUeNgapId) + ranUe.Log.Info("Handle Uplink Ran Status Transfer") amfUe := ranUe.AmfUe if amfUe == nil { @@ -3162,8 +3160,6 @@ func HandleNasNonDeliveryIndication(ran *context.AmfRan, message *ngapType.NGAPP return } - ran.Log.Info("Handle Nas Non Delivery Indication") - for _, ie := range nASNonDeliveryIndication.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: @@ -3200,6 +3196,7 @@ func HandleNasNonDeliveryIndication(ran *context.AmfRan, message *ngapType.NGAPP } ran.Log.Tracef("RanUeNgapID[%d] AmfUeNgapID[%d]", ranUe.RanUeNgapId, ranUe.AmfUeNgapId) + ranUe.Log.Info("Handle Nas Non Delivery Indication") printAndGetCause(ran, cause) @@ -3398,8 +3395,6 @@ func HandleUplinkUEAssociatedNRPPATransport(ran *context.AmfRan, message *ngapTy return } - ran.Log.Info("Handle Uplink UE Associated NRPPA Transpor") - for _, ie := range uplinkUEAssociatedNRPPaTransport.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // reject @@ -3440,6 +3435,7 @@ func HandleUplinkUEAssociatedNRPPATransport(ran *context.AmfRan, message *ngapTy } ran.Log.Tracef("RanUeNgapId[%d] AmfUeNgapId[%d]", ranUe.RanUeNgapId, ranUe.AmfUeNgapId) + ranUe.Log.Info("Handle Uplink UE Associated NRPPA Transpor") ranUe.RoutingID = hex.EncodeToString(routingID.Value) @@ -3524,7 +3520,6 @@ func HandleLocationReport(ran *context.AmfRan, message *ngapType.NGAPPDU) { return } - ran.Log.Info("Handle Location Report") for _, ie := range locationReport.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFUENGAPID: // reject @@ -3565,6 +3560,7 @@ func HandleLocationReport(ran *context.AmfRan, message *ngapType.NGAPPDU) { ran.Log.Errorf("No UE Context[RanUeNgapID: %d]", rANUENGAPID.Value) return } + ranUe.Log.Info("Handle Location Report") ranUe.UpdateLocation(userLocationInformation) @@ -3618,23 +3614,24 @@ func HandleUERadioCapabilityInfoIndication(ran *context.AmfRan, message *ngapTyp logger.NgapLog.Error("ran is nil") return } + if message == nil { ran.Log.Error("NGAP Message is nil") return } + initiatingMessage := message.InitiatingMessage if initiatingMessage == nil { ran.Log.Error("Initiating Message is nil") return } + uERadioCapabilityInfoIndication := initiatingMessage.Value.UERadioCapabilityInfoIndication if uERadioCapabilityInfoIndication == nil { ran.Log.Error("UERadioCapabilityInfoIndication is nil") return } - ran.Log.Info("Handle UE Radio Capability Info Indication") - for i := 0; i < len(uERadioCapabilityInfoIndication.ProtocolIEs.List); i++ { ie := uERadioCapabilityInfoIndication.ProtocolIEs.List[i] switch ie.Id.Value { @@ -3675,15 +3672,18 @@ func HandleUERadioCapabilityInfoIndication(ran *context.AmfRan, message *ngapTyp return } ran.Log.Tracef("RanUeNgapID[%d] AmfUeNgapID[%d]", ranUe.RanUeNgapId, ranUe.AmfUeNgapId) - amfUe := ranUe.AmfUe + ranUe.Log.Info("Handle UE Radio Capability Info Indication") + amfUe := ranUe.AmfUe if amfUe == nil { ranUe.Log.Errorln("amfUe is nil") return } + if uERadioCapability != nil { amfUe.UeRadioCapability = hex.EncodeToString(uERadioCapability.Value) } + if uERadioCapabilityForPaging != nil { amfUe.UeRadioCapabilityForPaging = &context.UERadioCapabilityForPaging{} if uERadioCapabilityForPaging.UERadioCapabilityForPagingOfNR != nil { @@ -3849,6 +3849,8 @@ func HandleErrorIndication(ran *context.AmfRan, message *ngapType.NGAPPDU) { } } + ran.Log.Infof("Handle Error Indication: RAN_UE_NGAP_ID:%v AMF_UE_NGAP_ID:%v", rANUENGAPID, aMFUENGAPID) + if cause == nil && criticalityDiagnostics == nil { ran.Log.Error("[ErrorIndication] both Cause IE and CriticalityDiagnostics IE are nil, should have at least one") return