From bb8718ead5b4ea3ca7a482fb5e247bb67a153e9f Mon Sep 17 00:00:00 2001 From: ShouheiNishi <96609867+ShouheiNishi@users.noreply.github.com> Date: Sat, 17 Jun 2023 00:10:25 +0900 Subject: [PATCH 01/13] Implement uncomprehended IE handling (#94) * Implement uncomprehended procedure code handling * Implement uncomprehended IE handling * Fix unimplemented IE handling * Update aper and NGAP pkg * Change level of unimplemented log --- go.mod | 4 +- go.sum | 12 +- internal/ngap/dispatcher_generated.go | 58 +- internal/ngap/handler.go | 4 - internal/ngap/handler_generated.go | 2794 +++++++++++++++++++++++-- internal/ngap/ngap_generator.go | 274 +-- 6 files changed, 2864 insertions(+), 282 deletions(-) diff --git a/go.mod b/go.mod index 4e08c0b6..e52fed90 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/antihax/optional v1.0.0 github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/davecgh/go-spew v1.1.1 - github.com/free5gc/aper v1.0.4 + github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 github.com/free5gc/nas v1.1.1 - github.com/free5gc/ngap v1.0.6 + github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f github.com/free5gc/openapi v1.0.6 github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 github.com/gin-contrib/cors v1.3.1 diff --git a/go.sum b/go.sum index e714eba1..5fdbd9b1 100644 --- a/go.sum +++ b/go.sum @@ -66,13 +66,12 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= -github.com/free5gc/aper v1.0.4 h1:Ufbf5lzbXBOhSdUSaIdAhFMOjggsX4p6eWMrpzrrD60= -github.com/free5gc/aper v1.0.4/go.mod h1:3K/m47BIPR2xhBkuHD1unp2LnArVtt3iTI4De0bCqpI= +github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 h1:IV9PXKo6MH62e7nngSqr+cwjuoffkouPMmyX3jHC9Ds= +github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582/go.mod h1:ybHxhYnRqQ9wD4yB9r/3MZdbCYCjtqUyfLpSnJpwWd4= github.com/free5gc/nas v1.1.1 h1:xUsqOOrb3kH38TQCzwZY7WN6WJkIerjERNjORDtnCbo= github.com/free5gc/nas v1.1.1/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU= -github.com/free5gc/ngap v1.0.6 h1:f9sKqHMNrFZVo9Kp8hAyrCXSoI8l746N5O+DFn7vKHA= -github.com/free5gc/ngap v1.0.6/go.mod h1:TG1kwwU/EyIlJ3bxY591rdxpD5ZeYnLZTzoWjcfvrBM= -github.com/free5gc/openapi v1.0.4/go.mod h1:KRCnnp0GeK0Bl4gnrX79cQAidKXNENf8VRdG0y9R0Fc= +github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f h1:wgXjoknZ7JJoZ72J15g/f2/0DgdCpfcTg189lnhUPuY= +github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f/go.mod h1:lKA1sLTYM3CGEBhZVxkGGJIkai5+Bvy2yHIMhb7Vx/k= github.com/free5gc/openapi v1.0.6 h1:ytRjU/YZRI8UhKKyfajXSyGB6s1YDFkJ1weeAGJ8LXw= github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 h1:FG8KlJ46Epscj3F9XBAKuDGJD9kSKJdstCL9fttjUjE= @@ -340,7 +339,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= @@ -391,7 +389,6 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -412,7 +409,6 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= diff --git a/internal/ngap/dispatcher_generated.go b/internal/ngap/dispatcher_generated.go index 17918a17..90e40ce3 100644 --- a/internal/ngap/dispatcher_generated.go +++ b/internal/ngap/dispatcher_generated.go @@ -3,6 +3,7 @@ package ngap import ( "github.com/free5gc/amf/internal/context" + ngap_message "github.com/free5gc/amf/internal/ngap/message" "github.com/free5gc/ngap/ngapType" ) @@ -120,7 +121,24 @@ func dispatchMain(ran *context.AmfRan, message *ngapType.NGAPPDU) { case ngapType.ProcedureCodeWriteReplaceWarning: handlerWriteReplaceWarningRequest(ran, initiatingMessage) default: - ran.Log.Warnf("Not implemented(choice:%d, procedureCode:%d)", message.Present, initiatingMessage.ProcedureCode.Value) + cause := ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{}, + } + switch initiatingMessage.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended procedure code of InitiatingMessage (criticality: reject, procedureCode:0x%02x)", initiatingMessage.ProcedureCode.Value) + cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorReject + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended procedure code of InitiatingMessage (criticality: ignore, procedureCode:0x%02x)", initiatingMessage.ProcedureCode.Value) + return + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended procedure code of InitiatingMessage (criticality: notify, procedureCode:0x%02x)", initiatingMessage.ProcedureCode.Value) + cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorIgnoreAndNotify + } + triggeringMessage := ngapType.TriggeringMessagePresentInitiatingMessage + criticalityDiagnostics := buildCriticalityDiagnostics(&initiatingMessage.ProcedureCode.Value, &triggeringMessage, &initiatingMessage.Criticality.Value, nil) + ngap_message.SendErrorIndication(ran, nil, nil, &cause, &criticalityDiagnostics) } case ngapType.NGAPPDUPresentSuccessfulOutcome: successfulOutcome := message.SuccessfulOutcome @@ -166,7 +184,24 @@ func dispatchMain(ran *context.AmfRan, message *ngapType.NGAPPDU) { case ngapType.ProcedureCodeWriteReplaceWarning: handlerWriteReplaceWarningResponse(ran, successfulOutcome) default: - ran.Log.Warnf("Not implemented(choice:%d, procedureCode:%d)", message.Present, successfulOutcome.ProcedureCode.Value) + cause := ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{}, + } + switch successfulOutcome.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended procedure code of SuccessfulOutcome (criticality: reject, procedureCode:0x%02x)", successfulOutcome.ProcedureCode.Value) + cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorReject + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended procedure code of SuccessfulOutcome (criticality: ignore, procedureCode:0x%02x)", successfulOutcome.ProcedureCode.Value) + return + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended procedure code of SuccessfulOutcome (criticality: notify, procedureCode:0x%02x)", successfulOutcome.ProcedureCode.Value) + cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorIgnoreAndNotify + } + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + criticalityDiagnostics := buildCriticalityDiagnostics(&successfulOutcome.ProcedureCode.Value, &triggeringMessage, &successfulOutcome.Criticality.Value, nil) + ngap_message.SendErrorIndication(ran, nil, nil, &cause, &criticalityDiagnostics) } case ngapType.NGAPPDUPresentUnsuccessfulOutcome: unsuccessfulOutcome := message.UnsuccessfulOutcome @@ -192,7 +227,24 @@ func dispatchMain(ran *context.AmfRan, message *ngapType.NGAPPDU) { case ngapType.ProcedureCodeUEContextModification: handlerUEContextModificationFailure(ran, unsuccessfulOutcome) default: - ran.Log.Warnf("Not implemented(choice:%d, procedureCode:%d)", message.Present, unsuccessfulOutcome.ProcedureCode.Value) + cause := ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{}, + } + switch unsuccessfulOutcome.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended procedure code of UnsuccessfulOutcome (criticality: reject, procedureCode:0x%02x)", unsuccessfulOutcome.ProcedureCode.Value) + cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorReject + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended procedure code of UnsuccessfulOutcome (criticality: ignore, procedureCode:0x%02x)", unsuccessfulOutcome.ProcedureCode.Value) + return + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended procedure code of UnsuccessfulOutcome (criticality: notify, procedureCode:0x%02x)", unsuccessfulOutcome.ProcedureCode.Value) + cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorIgnoreAndNotify + } + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + criticalityDiagnostics := buildCriticalityDiagnostics(&unsuccessfulOutcome.ProcedureCode.Value, &triggeringMessage, &unsuccessfulOutcome.Criticality.Value, nil) + ngap_message.SendErrorIndication(ran, nil, nil, &cause, &criticalityDiagnostics) } } } diff --git a/internal/ngap/handler.go b/internal/ngap/handler.go index f8ccd9fb..82db74c5 100644 --- a/internal/ngap/handler.go +++ b/internal/ngap/handler.go @@ -390,7 +390,6 @@ func handlePDUSessionResourceReleaseResponseMain(ran *context.AmfRan, func handleUERadioCapabilityCheckResponseMain(ran *context.AmfRan, ranUe *context.RanUe, - iMSVoiceSupportIndicator *ngapType.IMSVoiceSupportIndicator, criticalityDiagnostics *ngapType.CriticalityDiagnostics, ) { // TODO: handle iMSVoiceSupportIndicator @@ -417,7 +416,6 @@ func handleInitialUEMessageMain(ran *context.AmfRan, rRCEstablishmentCause *ngapType.RRCEstablishmentCause, fiveGSTMSI *ngapType.FiveGSTMSI, uEContextRequest *ngapType.UEContextRequest, - allowedNSSAI *ngapType.AllowedNSSAI, ) { ranUe := ran.RanUeFindByRanUeNgapID(rANUENGAPID.Value) if ranUe != nil { @@ -1685,7 +1683,6 @@ func handleHandoverCancelMain(ran *context.AmfRan, func handleUplinkRANStatusTransferMain(ran *context.AmfRan, ranUe *context.RanUe, - rANStatusTransferTransparentContainer *ngapType.RANStatusTransferTransparentContainer, ) { amfUe := ranUe.AmfUe if amfUe == nil { @@ -1801,7 +1798,6 @@ func handleUplinkRANConfigurationTransferMain(ran *context.AmfRan, func handleUplinkUEAssociatedNRPPaTransportMain(ran *context.AmfRan, ranUe *context.RanUe, routingID *ngapType.RoutingID, - nRPPaPDU *ngapType.NRPPaPDU, ) { ranUe.RoutingID = hex.EncodeToString(routingID.Value) diff --git a/internal/ngap/handler_generated.go b/internal/ngap/handler_generated.go index 9fc50556..29b0e8f4 100644 --- a/internal/ngap/handler_generated.go +++ b/internal/ngap/handler_generated.go @@ -20,6 +20,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false aMFConfigurationUpdate := initiatingMessage.Value.AMFConfigurationUpdate if aMFConfigurationUpdate == nil { @@ -40,6 +41,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFName = ie.Value.AMFName @@ -53,6 +55,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } servedGUAMIList = ie.Value.ServedGUAMIList @@ -66,6 +69,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } relativeAMFCapacity = ie.Value.RelativeAMFCapacity @@ -79,6 +83,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pLMNSupportList = ie.Value.PLMNSupportList @@ -92,6 +97,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFTNLAssociationToAddList = ie.Value.AMFTNLAssociationToAddList @@ -105,6 +111,7 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFTNLAssociationToRemoveList = ie.Value.AMFTNLAssociationToRemoveList @@ -118,10 +125,27 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFTNLAssociationToUpdateList = ie.Value.AMFTNLAssociationToUpdateList ran.Log.Trace("Decode IE AMF-TNLAssociationToUpdateList") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -136,6 +160,9 @@ func handlerAMFConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -166,8 +193,14 @@ func handleAMFConfigurationUpdateMain(ran *context.AmfRan, aMFName *ngapType.AMF } func handlerAMFConfigurationUpdateAcknowledge(ran *context.AmfRan, successfulOutcome *ngapType.SuccessfulOutcome) { + var aMFTNLAssociationSetupList *ngapType.AMFTNLAssociationSetupList + var aMFTNLAssociationFailedToSetupList *ngapType.TNLAssociationList var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + aMFConfigurationUpdateAcknowledge := successfulOutcome.Value.AMFConfigurationUpdateAcknowledge if aMFConfigurationUpdateAcknowledge == nil { ran.Log.Error("AMFConfigurationUpdateAcknowledge is nil") @@ -179,17 +212,65 @@ func handlerAMFConfigurationUpdateAcknowledge(ran *context.AmfRan, successfulOut for _, ie := range aMFConfigurationUpdateAcknowledge.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDAMFTNLAssociationSetupList: // optional, ignore - ran.Log.Info("Not comprehended IE AMF-TNLAssociationSetupList") + if aMFTNLAssociationSetupList != nil { + ran.Log.Error("Duplicate IE AMF-TNLAssociationSetupList") + abort = true + break + } + aMFTNLAssociationSetupList = ie.Value.AMFTNLAssociationSetupList + ran.Log.Trace("Decode IE AMF-TNLAssociationSetupList") case ngapType.ProtocolIEIDAMFTNLAssociationFailedToSetupList: // optional, ignore - ran.Log.Info("Not comprehended IE TNLAssociationList") + if aMFTNLAssociationFailedToSetupList != nil { + ran.Log.Error("Duplicate IE TNLAssociationList") + abort = true + break + } + aMFTNLAssociationFailedToSetupList = ie.Value.AMFTNLAssociationFailedToSetupList + ran.Log.Trace("Decode IE TNLAssociationList") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeAMFConfigurationUpdate + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + + if aMFTNLAssociationSetupList != nil { + ran.Log.Warn("IE AMF-TNLAssociationSetupList is not implemented") + } + if aMFTNLAssociationFailedToSetupList != nil { + ran.Log.Warn("IE TNLAssociationList is not implemented") } // func handleAMFConfigurationUpdateAcknowledgeMain(ran *context.AmfRan, @@ -199,8 +280,13 @@ func handlerAMFConfigurationUpdateAcknowledge(ran *context.AmfRan, successfulOut func handlerAMFConfigurationUpdateFailure(ran *context.AmfRan, unsuccessfulOutcome *ngapType.UnsuccessfulOutcome) { var cause *ngapType.Cause + var timeToWait *ngapType.TimeToWait var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + aMFConfigurationUpdateFailure := unsuccessfulOutcome.Value.AMFConfigurationUpdateFailure if aMFConfigurationUpdateFailure == nil { ran.Log.Error("AMFConfigurationUpdateFailure is nil") @@ -214,25 +300,64 @@ func handlerAMFConfigurationUpdateFailure(ran *context.AmfRan, unsuccessfulOutco case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDTimeToWait: // optional, ignore - ran.Log.Info("Not comprehended IE TimeToWait") + if timeToWait != nil { + ran.Log.Error("Duplicate IE TimeToWait") + abort = true + break + } + timeToWait = ie.Value.TimeToWait + ran.Log.Trace("Decode IE TimeToWait") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeAMFConfigurationUpdate + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if cause == nil { ran.Log.Warn("Missing IE Cause") } + if timeToWait != nil { + ran.Log.Warn("IE TimeToWait is not implemented") + } // func handleAMFConfigurationUpdateFailureMain(ran *context.AmfRan, // cause *ngapType.Cause, @@ -245,6 +370,7 @@ func handlerAMFStatusIndication(ran *context.AmfRan, initiatingMessage *ngapType var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false aMFStatusIndication := initiatingMessage.Value.AMFStatusIndication if aMFStatusIndication == nil { @@ -265,10 +391,27 @@ func handlerAMFStatusIndication(ran *context.AmfRan, initiatingMessage *ngapType Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } unavailableGUAMIList = ie.Value.UnavailableGUAMIList ran.Log.Trace("Decode IE UnavailableGUAMIList") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -276,6 +419,7 @@ func handlerAMFStatusIndication(ran *context.AmfRan, initiatingMessage *ngapType ran.Log.Error("Missing IE UnavailableGUAMIList") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDUnavailableGUAMIList, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -289,6 +433,9 @@ func handlerAMFStatusIndication(ran *context.AmfRan, initiatingMessage *ngapType } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -326,6 +473,7 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false cellTrafficTrace := initiatingMessage.Value.CellTrafficTrace if cellTrafficTrace == nil { @@ -346,6 +494,7 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -359,6 +508,7 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -372,6 +522,7 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nGRANTraceID = ie.Value.NGRANTraceID @@ -385,6 +536,7 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nGRANCGI = ie.Value.NGRANCGI @@ -398,10 +550,27 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } traceCollectionEntityIPAddress = ie.Value.TraceCollectionEntityIPAddress ran.Log.Trace("Decode IE TransportLayerAddress") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -409,11 +578,13 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -427,6 +598,9 @@ func handlerCellTrafficTrace(ran *context.AmfRan, initiatingMessage *ngapType.In } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -478,6 +652,7 @@ func handlerDeactivateTrace(ran *context.AmfRan, initiatingMessage *ngapType.Ini var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false deactivateTrace := initiatingMessage.Value.DeactivateTrace if deactivateTrace == nil { @@ -498,6 +673,7 @@ func handlerDeactivateTrace(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -511,6 +687,7 @@ func handlerDeactivateTrace(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -524,10 +701,27 @@ func handlerDeactivateTrace(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nGRANTraceID = ie.Value.NGRANTraceID ran.Log.Trace("Decode IE NGRANTraceID") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -535,11 +729,13 @@ func handlerDeactivateTrace(ran *context.AmfRan, initiatingMessage *ngapType.Ini ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -553,6 +749,9 @@ func handlerDeactivateTrace(ran *context.AmfRan, initiatingMessage *ngapType.Ini } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -617,6 +816,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false downlinkNASTransport := initiatingMessage.Value.DownlinkNASTransport if downlinkNASTransport == nil { @@ -637,6 +837,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -650,6 +851,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -663,6 +865,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } oldAMF = ie.Value.OldAMF @@ -676,6 +879,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANPagingPriority = ie.Value.RANPagingPriority @@ -689,6 +893,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -702,6 +907,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } mobilityRestrictionList = ie.Value.MobilityRestrictionList @@ -715,6 +921,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } indexToRFSP = ie.Value.IndexToRFSP @@ -728,6 +935,7 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEAggregateMaximumBitRate = ie.Value.UEAggregateMaximumBitRate @@ -741,10 +949,27 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } allowedNSSAI = ie.Value.AllowedNSSAI ran.Log.Trace("Decode IE AllowedNSSAI") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -752,16 +977,19 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nASPDU == nil { ran.Log.Error("Missing IE NAS-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNASPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -775,6 +1003,9 @@ func handlerDownlinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapTyp } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -839,6 +1070,7 @@ func handlerDownlinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatin var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false downlinkNonUEAssociatedNRPPaTransport := initiatingMessage.Value.DownlinkNonUEAssociatedNRPPaTransport if downlinkNonUEAssociatedNRPPaTransport == nil { @@ -859,6 +1091,7 @@ func handlerDownlinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatin Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } routingID = ie.Value.RoutingID @@ -872,10 +1105,27 @@ func handlerDownlinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatin Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nRPPaPDU = ie.Value.NRPPaPDU ran.Log.Trace("Decode IE NRPPa-PDU") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -883,11 +1133,13 @@ func handlerDownlinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatin ran.Log.Error("Missing IE RoutingID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRoutingID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nRPPaPDU == nil { ran.Log.Error("Missing IE NRPPa-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNRPPaPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -901,6 +1153,9 @@ func handlerDownlinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatin } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -940,6 +1195,7 @@ func handlerDownlinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMess var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false downlinkRANConfigurationTransfer := initiatingMessage.Value.DownlinkRANConfigurationTransfer if downlinkRANConfigurationTransfer == nil { @@ -960,6 +1216,7 @@ func handlerDownlinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } sONConfigurationTransferDL = ie.Value.SONConfigurationTransferDL @@ -973,10 +1230,27 @@ func handlerDownlinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } eNDCSONConfigurationTransferDL = ie.Value.ENDCSONConfigurationTransferDL ran.Log.Trace("Decode IE EN-DCSONConfigurationTransfer") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -991,6 +1265,9 @@ func handlerDownlinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMess } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -1022,6 +1299,7 @@ func handlerDownlinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ng var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false downlinkRANStatusTransfer := initiatingMessage.Value.DownlinkRANStatusTransfer if downlinkRANStatusTransfer == nil { @@ -1042,6 +1320,7 @@ func handlerDownlinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ng Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -1055,6 +1334,7 @@ func handlerDownlinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ng Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -1068,10 +1348,27 @@ func handlerDownlinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ng Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANStatusTransferTransparentContainer = ie.Value.RANStatusTransferTransparentContainer ran.Log.Trace("Decode IE RANStatusTransfer-TransparentContainer") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -1079,16 +1376,19 @@ func handlerDownlinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ng ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANStatusTransferTransparentContainer == nil { ran.Log.Error("Missing IE RANStatusTransfer-TransparentContainer") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANStatusTransferTransparentContainer, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -1102,6 +1402,9 @@ func handlerDownlinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ng } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -1162,6 +1465,7 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false downlinkUEAssociatedNRPPaTransport := initiatingMessage.Value.DownlinkUEAssociatedNRPPaTransport if downlinkUEAssociatedNRPPaTransport == nil { @@ -1182,6 +1486,7 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -1195,6 +1500,7 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -1208,6 +1514,7 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } routingID = ie.Value.RoutingID @@ -1221,10 +1528,27 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nRPPaPDU = ie.Value.NRPPaPDU ran.Log.Trace("Decode IE NRPPa-PDU") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -1232,21 +1556,25 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if routingID == nil { ran.Log.Error("Missing IE RoutingID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRoutingID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nRPPaPDU == nil { ran.Log.Error("Missing IE NRPPa-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNRPPaPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -1260,6 +1588,9 @@ func handlerDownlinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMe } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -1323,6 +1654,10 @@ func handlerErrorIndication(ran *context.AmfRan, initiatingMessage *ngapType.Ini var cause *ngapType.Cause var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + errorIndication := initiatingMessage.Value.ErrorIndication if errorIndication == nil { ran.Log.Error("ErrorIndication is nil") @@ -1336,32 +1671,64 @@ func handlerErrorIndication(ran *context.AmfRan, initiatingMessage *ngapType.Ini case ngapType.ProtocolIEIDAMFUENGAPID: // optional, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // optional, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDCause: // optional, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeErrorIndication + triggeringMessage := ngapType.TriggeringMessagePresentInitiatingMessage + procedureCriticality := ngapType.CriticalityPresentIgnore + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } // func handleErrorIndicationMain(ran *context.AmfRan, @@ -1379,6 +1746,7 @@ func handlerHandoverCancel(ran *context.AmfRan, initiatingMessage *ngapType.Init var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false handoverCancel := initiatingMessage.Value.HandoverCancel if handoverCancel == nil { @@ -1399,6 +1767,7 @@ func handlerHandoverCancel(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -1412,6 +1781,7 @@ func handlerHandoverCancel(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -1425,10 +1795,27 @@ func handlerHandoverCancel(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -1436,11 +1823,13 @@ func handlerHandoverCancel(ran *context.AmfRan, initiatingMessage *ngapType.Init ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -1454,6 +1843,9 @@ func handlerHandoverCancel(ran *context.AmfRan, initiatingMessage *ngapType.Init } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -1495,6 +1887,10 @@ func handlerHandoverCancelAcknowledge(ran *context.AmfRan, successfulOutcome *ng var rANUENGAPID *ngapType.RANUENGAPID var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + handoverCancelAcknowledge := successfulOutcome.Value.HandoverCancelAcknowledge if handoverCancelAcknowledge == nil { ran.Log.Error("HandoverCancelAcknowledge is nil") @@ -1508,25 +1904,56 @@ func handlerHandoverCancelAcknowledge(ran *context.AmfRan, successfulOutcome *ng case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeHandoverCancel + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -1573,6 +2000,10 @@ func handlerHandoverCommand(ran *context.AmfRan, successfulOutcome *ngapType.Suc var targetToSourceTransparentContainer *ngapType.TargetToSourceTransparentContainer var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + handoverCommand := successfulOutcome.Value.HandoverCommand if handoverCommand == nil { ran.Log.Error("HandoverCommand is nil") @@ -1586,60 +2017,96 @@ func handlerHandoverCommand(ran *context.AmfRan, successfulOutcome *ngapType.Suc case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, reject if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, reject if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDHandoverType: // mandatory, reject if handoverType != nil { ran.Log.Error("Duplicate IE HandoverType") - return + abort = true + break } handoverType = ie.Value.HandoverType ran.Log.Trace("Decode IE HandoverType") case ngapType.ProtocolIEIDNASSecurityParametersFromNGRAN: // conditional, reject if nASSecurityParametersFromNGRAN != nil { ran.Log.Error("Duplicate IE NASSecurityParametersFromNGRAN") - return + abort = true + break } nASSecurityParametersFromNGRAN = ie.Value.NASSecurityParametersFromNGRAN ran.Log.Trace("Decode IE NASSecurityParametersFromNGRAN") case ngapType.ProtocolIEIDPDUSessionResourceHandoverList: // optional, ignore if pDUSessionResourceHandoverList != nil { ran.Log.Error("Duplicate IE PDUSessionResourceHandoverList") - return + abort = true + break } pDUSessionResourceHandoverList = ie.Value.PDUSessionResourceHandoverList ran.Log.Trace("Decode IE PDUSessionResourceHandoverList") case ngapType.ProtocolIEIDPDUSessionResourceToReleaseListHOCmd: // optional, ignore if pDUSessionResourceToReleaseListHOCmd != nil { ran.Log.Error("Duplicate IE PDUSessionResourceToReleaseListHOCmd") - return + abort = true + break } pDUSessionResourceToReleaseListHOCmd = ie.Value.PDUSessionResourceToReleaseListHOCmd ran.Log.Trace("Decode IE PDUSessionResourceToReleaseListHOCmd") case ngapType.ProtocolIEIDTargetToSourceTransparentContainer: // mandatory, reject if targetToSourceTransparentContainer != nil { ran.Log.Error("Duplicate IE TargetToSource-TransparentContainer") - return + abort = true + break } targetToSourceTransparentContainer = ie.Value.TargetToSourceTransparentContainer ran.Log.Trace("Decode IE TargetToSource-TransparentContainer") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeHandoverPreparation + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -1694,6 +2161,10 @@ func handlerHandoverFailure(ran *context.AmfRan, unsuccessfulOutcome *ngapType.U var cause *ngapType.Cause var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + handoverFailure := unsuccessfulOutcome.Value.HandoverFailure if handoverFailure == nil { ran.Log.Error("HandoverFailure is nil") @@ -1707,25 +2178,56 @@ func handlerHandoverFailure(ran *context.AmfRan, unsuccessfulOutcome *ngapType.U case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeHandoverResourceAllocation + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -1765,6 +2267,7 @@ func handlerHandoverNotify(ran *context.AmfRan, initiatingMessage *ngapType.Init var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false handoverNotify := initiatingMessage.Value.HandoverNotify if handoverNotify == nil { @@ -1785,6 +2288,7 @@ func handlerHandoverNotify(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -1798,6 +2302,7 @@ func handlerHandoverNotify(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -1811,10 +2316,27 @@ func handlerHandoverNotify(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -1822,11 +2344,13 @@ func handlerHandoverNotify(ran *context.AmfRan, initiatingMessage *ngapType.Init ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -1840,6 +2364,9 @@ func handlerHandoverNotify(ran *context.AmfRan, initiatingMessage *ngapType.Init } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -1882,6 +2409,10 @@ func handlerHandoverPreparationFailure(ran *context.AmfRan, unsuccessfulOutcome var cause *ngapType.Cause var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + handoverPreparationFailure := unsuccessfulOutcome.Value.HandoverPreparationFailure if handoverPreparationFailure == nil { ran.Log.Error("HandoverPreparationFailure is nil") @@ -1895,32 +2426,64 @@ func handlerHandoverPreparationFailure(ran *context.AmfRan, unsuccessfulOutcome case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeHandoverPreparation + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -1984,6 +2547,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false handoverRequest := initiatingMessage.Value.HandoverRequest if handoverRequest == nil { @@ -2004,6 +2568,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -2017,6 +2582,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } handoverType = ie.Value.HandoverType @@ -2030,6 +2596,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause @@ -2043,6 +2610,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEAggregateMaximumBitRate = ie.Value.UEAggregateMaximumBitRate @@ -2056,6 +2624,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } coreNetworkAssistanceInformation = ie.Value.CoreNetworkAssistanceInformation @@ -2069,6 +2638,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uESecurityCapabilities = ie.Value.UESecurityCapabilities @@ -2082,6 +2652,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } securityContext = ie.Value.SecurityContext @@ -2095,6 +2666,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } newSecurityContextInd = ie.Value.NewSecurityContextInd @@ -2108,6 +2680,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASC = ie.Value.NASC @@ -2121,6 +2694,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceSetupListHOReq = ie.Value.PDUSessionResourceSetupListHOReq @@ -2134,6 +2708,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } allowedNSSAI = ie.Value.AllowedNSSAI @@ -2147,6 +2722,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } traceActivation = ie.Value.TraceActivation @@ -2160,6 +2736,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } maskedIMEISV = ie.Value.MaskedIMEISV @@ -2173,6 +2750,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } sourceToTargetTransparentContainer = ie.Value.SourceToTargetTransparentContainer @@ -2186,6 +2764,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } mobilityRestrictionList = ie.Value.MobilityRestrictionList @@ -2199,6 +2778,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } locationReportingRequestType = ie.Value.LocationReportingRequestType @@ -2212,6 +2792,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rRCInactiveTransitionReportRequest = ie.Value.RRCInactiveTransitionReportRequest @@ -2225,6 +2806,7 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } gUAMI = ie.Value.GUAMI @@ -2238,10 +2820,27 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } redirectionVoiceFallback = ie.Value.RedirectionVoiceFallback ran.Log.Trace("Decode IE RedirectionVoiceFallback") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -2249,46 +2848,55 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if handoverType == nil { ran.Log.Error("Missing IE HandoverType") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDHandoverType, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if uEAggregateMaximumBitRate == nil { ran.Log.Error("Missing IE UEAggregateMaximumBitRate") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDUEAggregateMaximumBitRate, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if uESecurityCapabilities == nil { ran.Log.Error("Missing IE UESecurityCapabilities") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDUESecurityCapabilities, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if securityContext == nil { ran.Log.Error("Missing IE SecurityContext") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSecurityContext, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceSetupListHOReq == nil { ran.Log.Error("Missing IE PDUSessionResourceSetupListHOReq") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceSetupListHOReq, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if allowedNSSAI == nil { ran.Log.Error("Missing IE AllowedNSSAI") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAllowedNSSAI, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if sourceToTargetTransparentContainer == nil { ran.Log.Error("Missing IE SourceToTarget-TransparentContainer") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSourceToTargetTransparentContainer, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if gUAMI == nil { ran.Log.Error("Missing IE GUAMI") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDGUAMI, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -2302,6 +2910,9 @@ func handlerHandoverRequest(ran *context.AmfRan, initiatingMessage *ngapType.Ini } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -2405,6 +3016,10 @@ func handlerHandoverRequestAcknowledge(ran *context.AmfRan, successfulOutcome *n var targetToSourceTransparentContainer *ngapType.TargetToSourceTransparentContainer var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + handoverRequestAcknowledge := successfulOutcome.Value.HandoverRequestAcknowledge if handoverRequestAcknowledge == nil { ran.Log.Error("HandoverRequestAcknowledge is nil") @@ -2418,50 +3033,84 @@ func handlerHandoverRequestAcknowledge(ran *context.AmfRan, successfulOutcome *n case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceAdmittedList: // mandatory, ignore if pDUSessionResourceAdmittedList != nil { ran.Log.Error("Duplicate IE PDUSessionResourceAdmittedList") - return + abort = true + break } pDUSessionResourceAdmittedList = ie.Value.PDUSessionResourceAdmittedList ran.Log.Trace("Decode IE PDUSessionResourceAdmittedList") case ngapType.ProtocolIEIDPDUSessionResourceFailedToSetupListHOAck: // optional, ignore if pDUSessionResourceFailedToSetupListHOAck != nil { ran.Log.Error("Duplicate IE PDUSessionResourceFailedToSetupListHOAck") - return + abort = true + break } pDUSessionResourceFailedToSetupListHOAck = ie.Value.PDUSessionResourceFailedToSetupListHOAck ran.Log.Trace("Decode IE PDUSessionResourceFailedToSetupListHOAck") case ngapType.ProtocolIEIDTargetToSourceTransparentContainer: // mandatory, reject if targetToSourceTransparentContainer != nil { ran.Log.Error("Duplicate IE TargetToSource-TransparentContainer") - return + abort = true + break } targetToSourceTransparentContainer = ie.Value.TargetToSourceTransparentContainer ran.Log.Trace("Decode IE TargetToSource-TransparentContainer") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } - if aMFUENGAPID == nil { - ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeHandoverResourceAllocation + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + + if aMFUENGAPID == nil { + ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") } if rANUENGAPID == nil { ran.Log.Warn("Missing IE RAN-UE-NGAP-ID") @@ -2507,11 +3156,13 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In var handoverType *ngapType.HandoverType var cause *ngapType.Cause var targetID *ngapType.TargetID + var directForwardingPathAvailability *ngapType.DirectForwardingPathAvailability var pDUSessionResourceListHORqd *ngapType.PDUSessionResourceListHORqd var sourceToTargetTransparentContainer *ngapType.SourceToTargetTransparentContainer var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false handoverRequired := initiatingMessage.Value.HandoverRequired if handoverRequired == nil { @@ -2532,6 +3183,7 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -2545,6 +3197,7 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -2558,6 +3211,7 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } handoverType = ie.Value.HandoverType @@ -2571,6 +3225,7 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause @@ -2584,12 +3239,25 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } targetID = ie.Value.TargetID ran.Log.Trace("Decode IE TargetID") case ngapType.ProtocolIEIDDirectForwardingPathAvailability: // optional, ignore - ran.Log.Info("Not comprehended IE DirectForwardingPathAvailability") + if directForwardingPathAvailability != nil { + ran.Log.Error("Duplicate IE DirectForwardingPathAvailability") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + directForwardingPathAvailability = ie.Value.DirectForwardingPathAvailability + ran.Log.Trace("Decode IE DirectForwardingPathAvailability") case ngapType.ProtocolIEIDPDUSessionResourceListHORqd: // mandatory, reject if pDUSessionResourceListHORqd != nil { ran.Log.Error("Duplicate IE PDUSessionResourceListHORqd") @@ -2599,6 +3267,7 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceListHORqd = ie.Value.PDUSessionResourceListHORqd @@ -2612,10 +3281,27 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } sourceToTargetTransparentContainer = ie.Value.SourceToTargetTransparentContainer ran.Log.Trace("Decode IE SourceToTarget-TransparentContainer") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -2623,31 +3309,37 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if handoverType == nil { ran.Log.Error("Missing IE HandoverType") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDHandoverType, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if targetID == nil { ran.Log.Error("Missing IE TargetID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDTargetID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceListHORqd == nil { ran.Log.Error("Missing IE PDUSessionResourceListHORqd") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceListHORqd, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if sourceToTargetTransparentContainer == nil { ran.Log.Error("Missing IE SourceToTarget-TransparentContainer") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSourceToTargetTransparentContainer, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -2673,6 +3365,9 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In } else { ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) } + } + + if abort { return } @@ -2695,6 +3390,9 @@ func handlerHandoverRequired(ran *context.AmfRan, initiatingMessage *ngapType.In ran.Log.Error("Missing IE TargetID") return } + if directForwardingPathAvailability != nil { + ran.Log.Warn("IE DirectForwardingPathAvailability is not implemented") + } if pDUSessionResourceListHORqd == nil { ran.Log.Error("Missing IE PDUSessionResourceListHORqd") return @@ -2736,6 +3434,10 @@ func handlerInitialContextSetupFailure(ran *context.AmfRan, unsuccessfulOutcome var cause *ngapType.Cause var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + initialContextSetupFailure := unsuccessfulOutcome.Value.InitialContextSetupFailure if initialContextSetupFailure == nil { ran.Log.Error("InitialContextSetupFailure is nil") @@ -2749,41 +3451,74 @@ func handlerInitialContextSetupFailure(ran *context.AmfRan, unsuccessfulOutcome case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceFailedToSetupListCxtFail: // optional, ignore if pDUSessionResourceFailedToSetupListCxtFail != nil { ran.Log.Error("Duplicate IE PDUSessionResourceFailedToSetupListCxtFail") - return + abort = true + break } pDUSessionResourceFailedToSetupListCxtFail = ie.Value.PDUSessionResourceFailedToSetupListCxtFail ran.Log.Trace("Decode IE PDUSessionResourceFailedToSetupListCxtFail") case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeInitialContextSetup + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if aMFUENGAPID == nil { ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") } @@ -2843,6 +3578,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false initialContextSetupRequest := initiatingMessage.Value.InitialContextSetupRequest if initialContextSetupRequest == nil { @@ -2863,6 +3599,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -2876,6 +3613,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -2889,6 +3627,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } oldAMF = ie.Value.OldAMF @@ -2902,6 +3641,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEAggregateMaximumBitRate = ie.Value.UEAggregateMaximumBitRate @@ -2915,6 +3655,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } coreNetworkAssistanceInformation = ie.Value.CoreNetworkAssistanceInformation @@ -2928,6 +3669,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } gUAMI = ie.Value.GUAMI @@ -2941,6 +3683,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceSetupListCxtReq = ie.Value.PDUSessionResourceSetupListCxtReq @@ -2954,6 +3697,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } allowedNSSAI = ie.Value.AllowedNSSAI @@ -2967,6 +3711,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uESecurityCapabilities = ie.Value.UESecurityCapabilities @@ -2980,6 +3725,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } securityKey = ie.Value.SecurityKey @@ -2993,6 +3739,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } traceActivation = ie.Value.TraceActivation @@ -3006,6 +3753,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } mobilityRestrictionList = ie.Value.MobilityRestrictionList @@ -3019,6 +3767,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uERadioCapability = ie.Value.UERadioCapability @@ -3032,6 +3781,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } indexToRFSP = ie.Value.IndexToRFSP @@ -3045,6 +3795,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } maskedIMEISV = ie.Value.MaskedIMEISV @@ -3058,6 +3809,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -3071,6 +3823,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } emergencyFallbackIndicator = ie.Value.EmergencyFallbackIndicator @@ -3084,6 +3837,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rRCInactiveTransitionReportRequest = ie.Value.RRCInactiveTransitionReportRequest @@ -3097,6 +3851,7 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uERadioCapabilityForPaging = ie.Value.UERadioCapabilityForPaging @@ -3110,10 +3865,27 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } redirectionVoiceFallback = ie.Value.RedirectionVoiceFallback ran.Log.Trace("Decode IE RedirectionVoiceFallback") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -3121,31 +3893,37 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if gUAMI == nil { ran.Log.Error("Missing IE GUAMI") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDGUAMI, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if allowedNSSAI == nil { ran.Log.Error("Missing IE AllowedNSSAI") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAllowedNSSAI, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if uESecurityCapabilities == nil { ran.Log.Error("Missing IE UESecurityCapabilities") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDUESecurityCapabilities, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if securityKey == nil { ran.Log.Error("Missing IE SecurityKey") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSecurityKey, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -3159,6 +3937,9 @@ func handlerInitialContextSetupRequest(ran *context.AmfRan, initiatingMessage *n } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -3247,6 +4028,10 @@ func handlerInitialContextSetupResponse(ran *context.AmfRan, successfulOutcome * var pDUSessionResourceFailedToSetupListCxtRes *ngapType.PDUSessionResourceFailedToSetupListCxtRes var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + initialContextSetupResponse := successfulOutcome.Value.InitialContextSetupResponse if initialContextSetupResponse == nil { ran.Log.Error("InitialContextSetupResponse is nil") @@ -3260,41 +4045,74 @@ func handlerInitialContextSetupResponse(ran *context.AmfRan, successfulOutcome * case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceSetupListCxtRes: // optional, ignore if pDUSessionResourceSetupListCxtRes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceSetupListCxtRes") - return + abort = true + break } pDUSessionResourceSetupListCxtRes = ie.Value.PDUSessionResourceSetupListCxtRes ran.Log.Trace("Decode IE PDUSessionResourceSetupListCxtRes") case ngapType.ProtocolIEIDPDUSessionResourceFailedToSetupListCxtRes: // optional, ignore if pDUSessionResourceFailedToSetupListCxtRes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceFailedToSetupListCxtRes") - return + abort = true + break } pDUSessionResourceFailedToSetupListCxtRes = ie.Value.PDUSessionResourceFailedToSetupListCxtRes ran.Log.Trace("Decode IE PDUSessionResourceFailedToSetupListCxtRes") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeInitialContextSetup + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if aMFUENGAPID == nil { ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") } @@ -3333,11 +4151,13 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini var userLocationInformation *ngapType.UserLocationInformation var rRCEstablishmentCause *ngapType.RRCEstablishmentCause var fiveGSTMSI *ngapType.FiveGSTMSI + var aMFSetID *ngapType.AMFSetID var uEContextRequest *ngapType.UEContextRequest var allowedNSSAI *ngapType.AllowedNSSAI var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false initialUEMessage := initiatingMessage.Value.InitialUEMessage if initialUEMessage == nil { @@ -3358,6 +4178,7 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -3371,6 +4192,7 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -3384,6 +4206,7 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation @@ -3397,6 +4220,7 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rRCEstablishmentCause = ie.Value.RRCEstablishmentCause @@ -3410,12 +4234,25 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } fiveGSTMSI = ie.Value.FiveGSTMSI ran.Log.Trace("Decode IE FiveG-S-TMSI") case ngapType.ProtocolIEIDAMFSetID: // optional, ignore - ran.Log.Info("Not comprehended IE AMFSetID") + if aMFSetID != nil { + ran.Log.Error("Duplicate IE AMFSetID") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + aMFSetID = ie.Value.AMFSetID + ran.Log.Trace("Decode IE AMFSetID") case ngapType.ProtocolIEIDUEContextRequest: // optional, ignore if uEContextRequest != nil { ran.Log.Error("Duplicate IE UEContextRequest") @@ -3425,6 +4262,7 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEContextRequest = ie.Value.UEContextRequest @@ -3438,10 +4276,27 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } allowedNSSAI = ie.Value.AllowedNSSAI ran.Log.Trace("Decode IE AllowedNSSAI") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -3449,16 +4304,19 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nASPDU == nil { ran.Log.Error("Missing IE NAS-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNASPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if userLocationInformation == nil { ran.Log.Error("Missing IE UserLocationInformation") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDUserLocationInformation, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -3472,6 +4330,9 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -3490,6 +4351,12 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini if rRCEstablishmentCause == nil { ran.Log.Warn("Missing IE RRCEstablishmentCause") } + if aMFSetID != nil { + ran.Log.Warn("IE AMFSetID is not implemented") + } + if allowedNSSAI != nil { + ran.Log.Warn("IE AllowedNSSAI is not implemented") + } // func handleInitialUEMessageMain(ran *context.AmfRan, // message *ngapType.NGAPPDU, @@ -3498,9 +4365,8 @@ func handlerInitialUEMessage(ran *context.AmfRan, message *ngapType.NGAPPDU, ini // userLocationInformation *ngapType.UserLocationInformation, // rRCEstablishmentCause *ngapType.RRCEstablishmentCause, // fiveGSTMSI *ngapType.FiveGSTMSI, - // uEContextRequest *ngapType.UEContextRequest, - // allowedNSSAI *ngapType.AllowedNSSAI) { - handleInitialUEMessageMain(ran, message, rANUENGAPID, nASPDU, userLocationInformation, rRCEstablishmentCause /* may be nil */, fiveGSTMSI /* may be nil */, uEContextRequest /* may be nil */, allowedNSSAI /* may be nil */) + // uEContextRequest *ngapType.UEContextRequest) { + handleInitialUEMessageMain(ran, message, rANUENGAPID, nASPDU, userLocationInformation, rRCEstablishmentCause /* may be nil */, fiveGSTMSI /* may be nil */, uEContextRequest /* may be nil */) } func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMessage) { @@ -3512,6 +4378,7 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false locationReport := initiatingMessage.Value.LocationReport if locationReport == nil { @@ -3532,6 +4399,7 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -3545,6 +4413,7 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -3558,6 +4427,7 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation @@ -3571,6 +4441,7 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEPresenceInAreaOfInterestList = ie.Value.UEPresenceInAreaOfInterestList @@ -3584,10 +4455,27 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } locationReportingRequestType = ie.Value.LocationReportingRequestType ran.Log.Trace("Decode IE LocationReportingRequestType") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -3595,11 +4483,13 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -3613,6 +4503,9 @@ func handlerLocationReport(ran *context.AmfRan, initiatingMessage *ngapType.Init } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -3661,6 +4554,7 @@ func handlerLocationReportingControl(ran *context.AmfRan, initiatingMessage *nga var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false locationReportingControl := initiatingMessage.Value.LocationReportingControl if locationReportingControl == nil { @@ -3681,6 +4575,7 @@ func handlerLocationReportingControl(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -3694,6 +4589,7 @@ func handlerLocationReportingControl(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -3707,10 +4603,27 @@ func handlerLocationReportingControl(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } locationReportingRequestType = ie.Value.LocationReportingRequestType ran.Log.Trace("Decode IE LocationReportingRequestType") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -3718,11 +4631,13 @@ func handlerLocationReportingControl(ran *context.AmfRan, initiatingMessage *nga ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -3736,6 +4651,9 @@ func handlerLocationReportingControl(ran *context.AmfRan, initiatingMessage *nga } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -3794,6 +4712,7 @@ func handlerLocationReportingFailureIndication(ran *context.AmfRan, initiatingMe var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false locationReportingFailureIndication := initiatingMessage.Value.LocationReportingFailureIndication if locationReportingFailureIndication == nil { @@ -3814,6 +4733,7 @@ func handlerLocationReportingFailureIndication(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -3827,6 +4747,7 @@ func handlerLocationReportingFailureIndication(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -3840,10 +4761,27 @@ func handlerLocationReportingFailureIndication(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -3851,11 +4789,13 @@ func handlerLocationReportingFailureIndication(ran *context.AmfRan, initiatingMe ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -3869,6 +4809,9 @@ func handlerLocationReportingFailureIndication(ran *context.AmfRan, initiatingMe } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -3913,6 +4856,7 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false nASNonDeliveryIndication := initiatingMessage.Value.NASNonDeliveryIndication if nASNonDeliveryIndication == nil { @@ -3933,6 +4877,7 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -3946,6 +4891,7 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -3959,6 +4905,7 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -3972,10 +4919,27 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -3983,11 +4947,13 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -4001,6 +4967,9 @@ func handlerNASNonDeliveryIndication(ran *context.AmfRan, initiatingMessage *nga } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -4047,6 +5016,7 @@ func handlerNGReset(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingM var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false nGReset := initiatingMessage.Value.NGReset if nGReset == nil { @@ -4067,6 +5037,7 @@ func handlerNGReset(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingM Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause @@ -4080,10 +5051,27 @@ func handlerNGReset(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingM Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } resetType = ie.Value.ResetType ran.Log.Trace("Decode IE ResetType") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -4091,6 +5079,7 @@ func handlerNGReset(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingM ran.Log.Error("Missing IE ResetType") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDResetType, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -4104,6 +5093,9 @@ func handlerNGReset(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingM } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -4125,6 +5117,10 @@ func handlerNGResetAcknowledge(ran *context.AmfRan, successfulOutcome *ngapType. var uEAssociatedLogicalNGConnectionList *ngapType.UEAssociatedLogicalNGConnectionList var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + nGResetAcknowledge := successfulOutcome.Value.NGResetAcknowledge if nGResetAcknowledge == nil { ran.Log.Error("NGResetAcknowledge is nil") @@ -4138,18 +5134,48 @@ func handlerNGResetAcknowledge(ran *context.AmfRan, successfulOutcome *ngapType. case ngapType.ProtocolIEIDUEAssociatedLogicalNGConnectionList: // optional, ignore if uEAssociatedLogicalNGConnectionList != nil { ran.Log.Error("Duplicate IE UE-associatedLogicalNG-connectionList") - return + abort = true + break } uEAssociatedLogicalNGConnectionList = ie.Value.UEAssociatedLogicalNGConnectionList ran.Log.Trace("Decode IE UE-associatedLogicalNG-connectionList") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeNGReset + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } // func handleNGResetAcknowledgeMain(ran *context.AmfRan, @@ -4163,6 +5189,10 @@ func handlerNGSetupFailure(ran *context.AmfRan, unsuccessfulOutcome *ngapType.Un var timeToWait *ngapType.TimeToWait var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + nGSetupFailure := unsuccessfulOutcome.Value.NGSetupFailure if nGSetupFailure == nil { ran.Log.Error("NGSetupFailure is nil") @@ -4176,25 +5206,56 @@ func handlerNGSetupFailure(ran *context.AmfRan, unsuccessfulOutcome *ngapType.Un case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDTimeToWait: // optional, ignore if timeToWait != nil { ran.Log.Error("Duplicate IE TimeToWait") - return + abort = true + break } timeToWait = ie.Value.TimeToWait ran.Log.Trace("Decode IE TimeToWait") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeNGSetup + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if cause == nil { @@ -4217,9 +5278,11 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init var rANNodeName *ngapType.RANNodeName var supportedTAList *ngapType.SupportedTAList var defaultPagingDRX *ngapType.PagingDRX + var uERetentionInformation *ngapType.UERetentionInformation var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false nGSetupRequest := initiatingMessage.Value.NGSetupRequest if nGSetupRequest == nil { @@ -4240,6 +5303,7 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } globalRANNodeID = ie.Value.GlobalRANNodeID @@ -4253,6 +5317,7 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANNodeName = ie.Value.RANNodeName @@ -4266,6 +5331,7 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } supportedTAList = ie.Value.SupportedTAList @@ -4279,12 +5345,41 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } defaultPagingDRX = ie.Value.DefaultPagingDRX ran.Log.Trace("Decode IE PagingDRX") case ngapType.ProtocolIEIDUERetentionInformation: // optional, ignore - ran.Log.Info("Not comprehended IE UERetentionInformation") + if uERetentionInformation != nil { + ran.Log.Error("Duplicate IE UERetentionInformation") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + uERetentionInformation = ie.Value.UERetentionInformation + ran.Log.Trace("Decode IE UERetentionInformation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -4292,11 +5387,13 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init ran.Log.Error("Missing IE GlobalRANNodeID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDGlobalRANNodeID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if supportedTAList == nil { ran.Log.Error("Missing IE SupportedTAList") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSupportedTAList, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -4318,6 +5415,9 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init } } rawSendNGSetupFailure(ran, *syntaxCause, nil, &criticalityDiagnostics) + } + + if abort { return } @@ -4332,6 +5432,9 @@ func handlerNGSetupRequest(ran *context.AmfRan, initiatingMessage *ngapType.Init if defaultPagingDRX == nil { ran.Log.Warn("Missing IE PagingDRX") } + if uERetentionInformation != nil { + ran.Log.Warn("IE UERetentionInformation is not implemented") + } // func handleNGSetupRequestMain(ran *context.AmfRan, // globalRANNodeID *ngapType.GlobalRANNodeID, @@ -4349,6 +5452,10 @@ func handlerNGSetupResponse(ran *context.AmfRan, successfulOutcome *ngapType.Suc var criticalityDiagnostics *ngapType.CriticalityDiagnostics var uERetentionInformation *ngapType.UERetentionInformation + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + nGSetupResponse := successfulOutcome.Value.NGSetupResponse if nGSetupResponse == nil { ran.Log.Error("NGSetupResponse is nil") @@ -4362,48 +5469,82 @@ func handlerNGSetupResponse(ran *context.AmfRan, successfulOutcome *ngapType.Suc case ngapType.ProtocolIEIDAMFName: // mandatory, reject if aMFName != nil { ran.Log.Error("Duplicate IE AMFName") - return + abort = true + break } aMFName = ie.Value.AMFName ran.Log.Trace("Decode IE AMFName") case ngapType.ProtocolIEIDServedGUAMIList: // mandatory, reject if servedGUAMIList != nil { ran.Log.Error("Duplicate IE ServedGUAMIList") - return + abort = true + break } servedGUAMIList = ie.Value.ServedGUAMIList ran.Log.Trace("Decode IE ServedGUAMIList") case ngapType.ProtocolIEIDRelativeAMFCapacity: // mandatory, ignore if relativeAMFCapacity != nil { ran.Log.Error("Duplicate IE RelativeAMFCapacity") - return + abort = true + break } relativeAMFCapacity = ie.Value.RelativeAMFCapacity ran.Log.Trace("Decode IE RelativeAMFCapacity") case ngapType.ProtocolIEIDPLMNSupportList: // mandatory, reject if pLMNSupportList != nil { ran.Log.Error("Duplicate IE PLMNSupportList") - return + abort = true + break } pLMNSupportList = ie.Value.PLMNSupportList ran.Log.Trace("Decode IE PLMNSupportList") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") case ngapType.ProtocolIEIDUERetentionInformation: // optional, ignore if uERetentionInformation != nil { ran.Log.Error("Duplicate IE UERetentionInformation") - return + abort = true + break } uERetentionInformation = ie.Value.UERetentionInformation ran.Log.Trace("Decode IE UERetentionInformation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeNGSetup + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if aMFName == nil { ran.Log.Error("Missing IE AMFName") return @@ -4441,6 +5582,7 @@ func handlerOverloadStart(ran *context.AmfRan, initiatingMessage *ngapType.Initi var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false overloadStart := initiatingMessage.Value.OverloadStart if overloadStart == nil { @@ -4461,6 +5603,7 @@ func handlerOverloadStart(ran *context.AmfRan, initiatingMessage *ngapType.Initi Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFOverloadResponse = ie.Value.AMFOverloadResponse @@ -4474,6 +5617,7 @@ func handlerOverloadStart(ran *context.AmfRan, initiatingMessage *ngapType.Initi Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFTrafficLoadReductionIndication = ie.Value.AMFTrafficLoadReductionIndication @@ -4487,10 +5631,27 @@ func handlerOverloadStart(ran *context.AmfRan, initiatingMessage *ngapType.Initi Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } overloadStartNSSAIList = ie.Value.OverloadStartNSSAIList ran.Log.Trace("Decode IE OverloadStartNSSAIList") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -4505,6 +5666,9 @@ func handlerOverloadStart(ran *context.AmfRan, initiatingMessage *ngapType.Initi } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -4534,6 +5698,7 @@ func handlerOverloadStop(ran *context.AmfRan, initiatingMessage *ngapType.Initia var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false overloadStop := initiatingMessage.Value.OverloadStop if overloadStop == nil { @@ -4545,6 +5710,22 @@ func handlerOverloadStop(ran *context.AmfRan, initiatingMessage *ngapType.Initia for _, ie := range overloadStop.ProtocolIEs.List { switch ie.Id.Value { + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -4559,6 +5740,9 @@ func handlerOverloadStop(ran *context.AmfRan, initiatingMessage *ngapType.Initia } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -4588,6 +5772,10 @@ func handlerPDUSessionResourceModifyConfirm(ran *context.AmfRan, successfulOutco var pDUSessionResourceFailedToModifyListModCfm *ngapType.PDUSessionResourceFailedToModifyListModCfm var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pDUSessionResourceModifyConfirm := successfulOutcome.Value.PDUSessionResourceModifyConfirm if pDUSessionResourceModifyConfirm == nil { ran.Log.Error("PDUSessionResourceModifyConfirm is nil") @@ -4601,41 +5789,74 @@ func handlerPDUSessionResourceModifyConfirm(ran *context.AmfRan, successfulOutco case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceModifyListModCfm: // optional, ignore if pDUSessionResourceModifyListModCfm != nil { ran.Log.Error("Duplicate IE PDUSessionResourceModifyListModCfm") - return + abort = true + break } pDUSessionResourceModifyListModCfm = ie.Value.PDUSessionResourceModifyListModCfm ran.Log.Trace("Decode IE PDUSessionResourceModifyListModCfm") case ngapType.ProtocolIEIDPDUSessionResourceFailedToModifyListModCfm: // optional, ignore if pDUSessionResourceFailedToModifyListModCfm != nil { ran.Log.Error("Duplicate IE PDUSessionResourceFailedToModifyListModCfm") - return + abort = true + break } pDUSessionResourceFailedToModifyListModCfm = ie.Value.PDUSessionResourceFailedToModifyListModCfm ran.Log.Trace("Decode IE PDUSessionResourceFailedToModifyListModCfm") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePDUSessionResourceModifyIndication + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if aMFUENGAPID == nil { ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") } @@ -4679,6 +5900,7 @@ func handlerPDUSessionResourceModifyIndication(ran *context.AmfRan, initiatingMe var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pDUSessionResourceModifyIndication := initiatingMessage.Value.PDUSessionResourceModifyIndication if pDUSessionResourceModifyIndication == nil { @@ -4699,6 +5921,7 @@ func handlerPDUSessionResourceModifyIndication(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -4712,6 +5935,7 @@ func handlerPDUSessionResourceModifyIndication(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -4725,10 +5949,27 @@ func handlerPDUSessionResourceModifyIndication(ran *context.AmfRan, initiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceModifyListModInd = ie.Value.PDUSessionResourceModifyListModInd ran.Log.Trace("Decode IE PDUSessionResourceModifyListModInd") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -4736,16 +5977,19 @@ func handlerPDUSessionResourceModifyIndication(ran *context.AmfRan, initiatingMe ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceModifyListModInd == nil { ran.Log.Error("Missing IE PDUSessionResourceModifyListModInd") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceModifyListModInd, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -4759,6 +6003,9 @@ func handlerPDUSessionResourceModifyIndication(ran *context.AmfRan, initiatingMe } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -4804,6 +6051,7 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pDUSessionResourceModifyRequest := initiatingMessage.Value.PDUSessionResourceModifyRequest if pDUSessionResourceModifyRequest == nil { @@ -4824,6 +6072,7 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -4837,6 +6086,7 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -4850,6 +6100,7 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANPagingPriority = ie.Value.RANPagingPriority @@ -4863,10 +6114,27 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceModifyListModReq = ie.Value.PDUSessionResourceModifyListModReq ran.Log.Trace("Decode IE PDUSessionResourceModifyListModReq") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -4874,16 +6142,19 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceModifyListModReq == nil { ran.Log.Error("Missing IE PDUSessionResourceModifyListModReq") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceModifyListModReq, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -4897,6 +6168,9 @@ func handlerPDUSessionResourceModifyRequest(ran *context.AmfRan, initiatingMessa } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -4958,6 +6232,10 @@ func handlerPDUSessionResourceModifyResponse(ran *context.AmfRan, successfulOutc var userLocationInformation *ngapType.UserLocationInformation var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pDUSessionResourceModifyResponse := successfulOutcome.Value.PDUSessionResourceModifyResponse if pDUSessionResourceModifyResponse == nil { ran.Log.Error("PDUSessionResourceModifyResponse is nil") @@ -4971,46 +6249,80 @@ func handlerPDUSessionResourceModifyResponse(ran *context.AmfRan, successfulOutc case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceModifyListModRes: // optional, ignore if pDUSessionResourceModifyListModRes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceModifyListModRes") - return + abort = true + break } pDUSessionResourceModifyListModRes = ie.Value.PDUSessionResourceModifyListModRes ran.Log.Trace("Decode IE PDUSessionResourceModifyListModRes") case ngapType.ProtocolIEIDPDUSessionResourceFailedToModifyListModRes: // optional, ignore if pDUSessionResourceFailedToModifyListModRes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceFailedToModifyListModRes") - return + abort = true + break } pDUSessionResourceFailedToModifyListModRes = ie.Value.PDUSessionResourceFailedToModifyListModRes ran.Log.Trace("Decode IE PDUSessionResourceFailedToModifyListModRes") case ngapType.ProtocolIEIDUserLocationInformation: // optional, ignore if userLocationInformation != nil { ran.Log.Error("Duplicate IE UserLocationInformation") - return + abort = true + break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePDUSessionResourceModify + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -5055,6 +6367,7 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pDUSessionResourceNotify := initiatingMessage.Value.PDUSessionResourceNotify if pDUSessionResourceNotify == nil { @@ -5075,6 +6388,7 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -5088,6 +6402,7 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -5101,6 +6416,7 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceNotifyList = ie.Value.PDUSessionResourceNotifyList @@ -5114,6 +6430,7 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceReleasedListNot = ie.Value.PDUSessionResourceReleasedListNot @@ -5127,10 +6444,27 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -5138,11 +6472,13 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -5156,6 +6492,9 @@ func handlerPDUSessionResourceNotify(ran *context.AmfRan, initiatingMessage *nga } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -5200,6 +6539,7 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pDUSessionResourceReleaseCommand := initiatingMessage.Value.PDUSessionResourceReleaseCommand if pDUSessionResourceReleaseCommand == nil { @@ -5220,6 +6560,7 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -5233,6 +6574,7 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -5246,6 +6588,7 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANPagingPriority = ie.Value.RANPagingPriority @@ -5259,6 +6602,7 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -5272,10 +6616,27 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceToReleaseListRelCmd = ie.Value.PDUSessionResourceToReleaseListRelCmd ran.Log.Trace("Decode IE PDUSessionResourceToReleaseListRelCmd") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -5283,16 +6644,19 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceToReleaseListRelCmd == nil { ran.Log.Error("Missing IE PDUSessionResourceToReleaseListRelCmd") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceToReleaseListRelCmd, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -5306,6 +6670,9 @@ func handlerPDUSessionResourceReleaseCommand(ran *context.AmfRan, initiatingMess } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -5367,6 +6734,10 @@ func handlerPDUSessionResourceReleaseResponse(ran *context.AmfRan, successfulOut var userLocationInformation *ngapType.UserLocationInformation var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pDUSessionResourceReleaseResponse := successfulOutcome.Value.PDUSessionResourceReleaseResponse if pDUSessionResourceReleaseResponse == nil { ran.Log.Error("PDUSessionResourceReleaseResponse is nil") @@ -5380,41 +6751,74 @@ func handlerPDUSessionResourceReleaseResponse(ran *context.AmfRan, successfulOut case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceReleasedListRelRes: // mandatory, ignore if pDUSessionResourceReleasedListRelRes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceReleasedListRelRes") - return + abort = true + break } pDUSessionResourceReleasedListRelRes = ie.Value.PDUSessionResourceReleasedListRelRes ran.Log.Trace("Decode IE PDUSessionResourceReleasedListRelRes") case ngapType.ProtocolIEIDUserLocationInformation: // optional, ignore if userLocationInformation != nil { ran.Log.Error("Duplicate IE UserLocationInformation") - return + abort = true + break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePDUSessionResourceRelease + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if aMFUENGAPID == nil { ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") } @@ -5460,6 +6864,7 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pDUSessionResourceSetupRequest := initiatingMessage.Value.PDUSessionResourceSetupRequest if pDUSessionResourceSetupRequest == nil { @@ -5480,6 +6885,7 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -5493,6 +6899,7 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -5506,6 +6913,7 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANPagingPriority = ie.Value.RANPagingPriority @@ -5519,6 +6927,7 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -5532,6 +6941,7 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceSetupListSUReq = ie.Value.PDUSessionResourceSetupListSUReq @@ -5545,10 +6955,27 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEAggregateMaximumBitRate = ie.Value.UEAggregateMaximumBitRate ran.Log.Trace("Decode IE UEAggregateMaximumBitRate") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -5556,16 +6983,19 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceSetupListSUReq == nil { ran.Log.Error("Missing IE PDUSessionResourceSetupListSUReq") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceSetupListSUReq, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -5579,6 +7009,9 @@ func handlerPDUSessionResourceSetupRequest(ran *context.AmfRan, initiatingMessag } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -5641,6 +7074,10 @@ func handlerPDUSessionResourceSetupResponse(ran *context.AmfRan, successfulOutco var pDUSessionResourceFailedToSetupListSURes *ngapType.PDUSessionResourceFailedToSetupListSURes var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pDUSessionResourceSetupResponse := successfulOutcome.Value.PDUSessionResourceSetupResponse if pDUSessionResourceSetupResponse == nil { ran.Log.Error("PDUSessionResourceSetupResponse is nil") @@ -5654,41 +7091,74 @@ func handlerPDUSessionResourceSetupResponse(ran *context.AmfRan, successfulOutco case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceSetupListSURes: // optional, ignore if pDUSessionResourceSetupListSURes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceSetupListSURes") - return + abort = true + break } pDUSessionResourceSetupListSURes = ie.Value.PDUSessionResourceSetupListSURes ran.Log.Trace("Decode IE PDUSessionResourceSetupListSURes") case ngapType.ProtocolIEIDPDUSessionResourceFailedToSetupListSURes: // optional, ignore if pDUSessionResourceFailedToSetupListSURes != nil { ran.Log.Error("Duplicate IE PDUSessionResourceFailedToSetupListSURes") - return + abort = true + break } pDUSessionResourceFailedToSetupListSURes = ie.Value.PDUSessionResourceFailedToSetupListSURes ran.Log.Trace("Decode IE PDUSessionResourceFailedToSetupListSURes") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePDUSessionResourceSetup + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if aMFUENGAPID == nil { ran.Log.Warn("Missing IE AMF-UE-NGAP-ID") } @@ -5729,6 +7199,7 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pWSCancelRequest := initiatingMessage.Value.PWSCancelRequest if pWSCancelRequest == nil { @@ -5749,6 +7220,7 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } messageIdentifier = ie.Value.MessageIdentifier @@ -5762,6 +7234,7 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } serialNumber = ie.Value.SerialNumber @@ -5775,6 +7248,7 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } warningAreaList = ie.Value.WarningAreaList @@ -5788,10 +7262,27 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cancelAllWarningMessages = ie.Value.CancelAllWarningMessages ran.Log.Trace("Decode IE CancelAllWarningMessages") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -5799,11 +7290,13 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In ran.Log.Error("Missing IE MessageIdentifier") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDMessageIdentifier, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if serialNumber == nil { ran.Log.Error("Missing IE SerialNumber") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSerialNumber, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -5817,6 +7310,9 @@ func handlerPWSCancelRequest(ran *context.AmfRan, initiatingMessage *ngapType.In } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -5858,6 +7354,10 @@ func handlerPWSCancelResponse(ran *context.AmfRan, successfulOutcome *ngapType.S var broadcastCancelledAreaList *ngapType.BroadcastCancelledAreaList var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pWSCancelResponse := successfulOutcome.Value.PWSCancelResponse if pWSCancelResponse == nil { ran.Log.Error("PWSCancelResponse is nil") @@ -5871,34 +7371,66 @@ func handlerPWSCancelResponse(ran *context.AmfRan, successfulOutcome *ngapType.S case ngapType.ProtocolIEIDMessageIdentifier: // mandatory, reject if messageIdentifier != nil { ran.Log.Error("Duplicate IE MessageIdentifier") - return + abort = true + break } messageIdentifier = ie.Value.MessageIdentifier ran.Log.Trace("Decode IE MessageIdentifier") case ngapType.ProtocolIEIDSerialNumber: // mandatory, reject if serialNumber != nil { ran.Log.Error("Duplicate IE SerialNumber") - return + abort = true + break } serialNumber = ie.Value.SerialNumber ran.Log.Trace("Decode IE SerialNumber") case ngapType.ProtocolIEIDBroadcastCancelledAreaList: // optional, ignore if broadcastCancelledAreaList != nil { ran.Log.Error("Duplicate IE BroadcastCancelledAreaList") - return + abort = true + break } broadcastCancelledAreaList = ie.Value.BroadcastCancelledAreaList ran.Log.Trace("Decode IE BroadcastCancelledAreaList") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } } } + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePWSCancel + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics + } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return + } + if messageIdentifier == nil { ran.Log.Error("Missing IE MessageIdentifier") return @@ -5926,6 +7458,7 @@ func handlerPWSFailureIndication(ran *context.AmfRan, initiatingMessage *ngapTyp var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pWSFailureIndication := initiatingMessage.Value.PWSFailureIndication if pWSFailureIndication == nil { @@ -5946,6 +7479,7 @@ func handlerPWSFailureIndication(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pWSFailedCellIDList = ie.Value.PWSFailedCellIDList @@ -5959,10 +7493,27 @@ func handlerPWSFailureIndication(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } globalRANNodeID = ie.Value.GlobalRANNodeID ran.Log.Trace("Decode IE GlobalRANNodeID") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -5970,11 +7521,13 @@ func handlerPWSFailureIndication(ran *context.AmfRan, initiatingMessage *ngapTyp ran.Log.Error("Missing IE PWSFailedCellIDList") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPWSFailedCellIDList, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if globalRANNodeID == nil { ran.Log.Error("Missing IE GlobalRANNodeID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDGlobalRANNodeID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -5988,6 +7541,9 @@ func handlerPWSFailureIndication(ran *context.AmfRan, initiatingMessage *ngapTyp } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -6029,6 +7585,7 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pWSRestartIndication := initiatingMessage.Value.PWSRestartIndication if pWSRestartIndication == nil { @@ -6049,6 +7606,7 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cellIDListForRestart = ie.Value.CellIDListForRestart @@ -6062,6 +7620,7 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } globalRANNodeID = ie.Value.GlobalRANNodeID @@ -6075,6 +7634,7 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } tAIListForRestart = ie.Value.TAIListForRestart @@ -6088,10 +7648,27 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } emergencyAreaIDListForRestart = ie.Value.EmergencyAreaIDListForRestart ran.Log.Trace("Decode IE EmergencyAreaIDListForRestart") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -6099,16 +7676,19 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp ran.Log.Error("Missing IE CellIDListForRestart") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDCellIDListForRestart, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if globalRANNodeID == nil { ran.Log.Error("Missing IE GlobalRANNodeID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDGlobalRANNodeID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if tAIListForRestart == nil { ran.Log.Error("Missing IE TAIListForRestart") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDTAIListForRestart, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -6122,6 +7702,9 @@ func handlerPWSRestartIndication(ran *context.AmfRan, initiatingMessage *ngapTyp } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -6172,6 +7755,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false paging := initiatingMessage.Value.Paging if paging == nil { @@ -6192,6 +7776,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEPagingIdentity = ie.Value.UEPagingIdentity @@ -6205,6 +7790,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pagingDRX = ie.Value.PagingDRX @@ -6218,6 +7804,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } tAIListForPaging = ie.Value.TAIListForPaging @@ -6231,6 +7818,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pagingPriority = ie.Value.PagingPriority @@ -6244,6 +7832,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uERadioCapabilityForPaging = ie.Value.UERadioCapabilityForPaging @@ -6257,6 +7846,7 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pagingOrigin = ie.Value.PagingOrigin @@ -6270,10 +7860,27 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } assistanceDataForPaging = ie.Value.AssistanceDataForPaging ran.Log.Trace("Decode IE AssistanceDataForPaging") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -6288,6 +7895,9 @@ func handlerPaging(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMe } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -6334,6 +7944,7 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false pathSwitchRequest := initiatingMessage.Value.PathSwitchRequest if pathSwitchRequest == nil { @@ -6354,6 +7965,7 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -6367,6 +7979,7 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } sourceAMFUENGAPID = ie.Value.SourceAMFUENGAPID @@ -6380,6 +7993,7 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation @@ -6393,6 +8007,7 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uESecurityCapabilities = ie.Value.UESecurityCapabilities @@ -6406,6 +8021,7 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceToBeSwitchedDLList = ie.Value.PDUSessionResourceToBeSwitchedDLList @@ -6419,10 +8035,27 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceFailedToSetupListPSReq = ie.Value.PDUSessionResourceFailedToSetupListPSReq ran.Log.Trace("Decode IE PDUSessionResourceFailedToSetupListPSReq") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -6430,16 +8063,19 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if sourceAMFUENGAPID == nil { ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSourceAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if pDUSessionResourceToBeSwitchedDLList == nil { ran.Log.Error("Missing IE PDUSessionResourceToBeSwitchedDLList") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDPDUSessionResourceToBeSwitchedDLList, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -6453,6 +8089,9 @@ func handlerPathSwitchRequest(ran *context.AmfRan, initiatingMessage *ngapType.I } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -6499,6 +8138,10 @@ func handlerPathSwitchRequestAcknowledge(ran *context.AmfRan, successfulOutcome var criticalityDiagnostics *ngapType.CriticalityDiagnostics var redirectionVoiceFallback *ngapType.RedirectionVoiceFallback + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pathSwitchRequestAcknowledge := successfulOutcome.Value.PathSwitchRequestAcknowledge if pathSwitchRequestAcknowledge == nil { ran.Log.Error("PathSwitchRequestAcknowledge is nil") @@ -6512,88 +8155,128 @@ func handlerPathSwitchRequestAcknowledge(ran *context.AmfRan, successfulOutcome case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDUESecurityCapabilities: // optional, reject if uESecurityCapabilities != nil { ran.Log.Error("Duplicate IE UESecurityCapabilities") - return + abort = true + break } uESecurityCapabilities = ie.Value.UESecurityCapabilities ran.Log.Trace("Decode IE UESecurityCapabilities") case ngapType.ProtocolIEIDSecurityContext: // mandatory, reject if securityContext != nil { ran.Log.Error("Duplicate IE SecurityContext") - return + abort = true + break } securityContext = ie.Value.SecurityContext ran.Log.Trace("Decode IE SecurityContext") case ngapType.ProtocolIEIDNewSecurityContextInd: // optional, reject if newSecurityContextInd != nil { ran.Log.Error("Duplicate IE NewSecurityContextInd") - return + abort = true + break } newSecurityContextInd = ie.Value.NewSecurityContextInd ran.Log.Trace("Decode IE NewSecurityContextInd") case ngapType.ProtocolIEIDPDUSessionResourceSwitchedList: // mandatory, ignore if pDUSessionResourceSwitchedList != nil { ran.Log.Error("Duplicate IE PDUSessionResourceSwitchedList") - return + abort = true + break } pDUSessionResourceSwitchedList = ie.Value.PDUSessionResourceSwitchedList ran.Log.Trace("Decode IE PDUSessionResourceSwitchedList") case ngapType.ProtocolIEIDPDUSessionResourceReleasedListPSAck: // optional, ignore if pDUSessionResourceReleasedListPSAck != nil { ran.Log.Error("Duplicate IE PDUSessionResourceReleasedListPSAck") - return + abort = true + break } pDUSessionResourceReleasedListPSAck = ie.Value.PDUSessionResourceReleasedListPSAck ran.Log.Trace("Decode IE PDUSessionResourceReleasedListPSAck") case ngapType.ProtocolIEIDAllowedNSSAI: // mandatory, reject if allowedNSSAI != nil { ran.Log.Error("Duplicate IE AllowedNSSAI") - return + abort = true + break } allowedNSSAI = ie.Value.AllowedNSSAI ran.Log.Trace("Decode IE AllowedNSSAI") case ngapType.ProtocolIEIDCoreNetworkAssistanceInformation: // optional, ignore if coreNetworkAssistanceInformation != nil { ran.Log.Error("Duplicate IE CoreNetworkAssistanceInformationForInactive") - return + abort = true + break } coreNetworkAssistanceInformation = ie.Value.CoreNetworkAssistanceInformation ran.Log.Trace("Decode IE CoreNetworkAssistanceInformationForInactive") case ngapType.ProtocolIEIDRRCInactiveTransitionReportRequest: // optional, ignore if rRCInactiveTransitionReportRequest != nil { ran.Log.Error("Duplicate IE RRCInactiveTransitionReportRequest") - return + abort = true + break } rRCInactiveTransitionReportRequest = ie.Value.RRCInactiveTransitionReportRequest ran.Log.Trace("Decode IE RRCInactiveTransitionReportRequest") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") case ngapType.ProtocolIEIDRedirectionVoiceFallback: // optional, ignore if redirectionVoiceFallback != nil { ran.Log.Error("Duplicate IE RedirectionVoiceFallback") - return + abort = true + break } redirectionVoiceFallback = ie.Value.RedirectionVoiceFallback ran.Log.Trace("Decode IE RedirectionVoiceFallback") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePathSwitchRequest + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -6656,6 +8339,10 @@ func handlerPathSwitchRequestFailure(ran *context.AmfRan, unsuccessfulOutcome *n var pDUSessionResourceReleasedListPSFail *ngapType.PDUSessionResourceReleasedListPSFail var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + pathSwitchRequestFailure := unsuccessfulOutcome.Value.PathSwitchRequestFailure if pathSwitchRequestFailure == nil { ran.Log.Error("PathSwitchRequestFailure is nil") @@ -6669,32 +8356,64 @@ func handlerPathSwitchRequestFailure(ran *context.AmfRan, unsuccessfulOutcome *n case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDPDUSessionResourceReleasedListPSFail: // mandatory, ignore if pDUSessionResourceReleasedListPSFail != nil { ran.Log.Error("Duplicate IE PDUSessionResourceReleasedListPSFail") - return + abort = true + break } pDUSessionResourceReleasedListPSFail = ie.Value.PDUSessionResourceReleasedListPSFail ran.Log.Trace("Decode IE PDUSessionResourceReleasedListPSFail") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodePathSwitchRequest + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -6736,10 +8455,14 @@ func handlePathSwitchRequestFailureMain(ran *context.AmfRan, ranUe *context.RanU } func handlerRANConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMessage) { + var rANNodeName *ngapType.RANNodeName var supportedTAList *ngapType.SupportedTAList + var defaultPagingDRX *ngapType.PagingDRX + var globalRANNodeID *ngapType.GlobalRANNodeID var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false rANConfigurationUpdate := initiatingMessage.Value.RANConfigurationUpdate if rANConfigurationUpdate == nil { @@ -6752,7 +8475,19 @@ func handlerRANConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT for _, ie := range rANConfigurationUpdate.ProtocolIEs.List { switch ie.Id.Value { case ngapType.ProtocolIEIDRANNodeName: // optional, ignore - ran.Log.Info("Not comprehended IE RANNodeName") + if rANNodeName != nil { + ran.Log.Error("Duplicate IE RANNodeName") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + rANNodeName = ie.Value.RANNodeName + ran.Log.Trace("Decode IE RANNodeName") case ngapType.ProtocolIEIDSupportedTAList: // optional, reject if supportedTAList != nil { ran.Log.Error("Duplicate IE SupportedTAList") @@ -6762,14 +8497,55 @@ func handlerRANConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } supportedTAList = ie.Value.SupportedTAList ran.Log.Trace("Decode IE SupportedTAList") case ngapType.ProtocolIEIDDefaultPagingDRX: // optional, ignore - ran.Log.Info("Not comprehended IE PagingDRX") + if defaultPagingDRX != nil { + ran.Log.Error("Duplicate IE PagingDRX") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + defaultPagingDRX = ie.Value.DefaultPagingDRX + ran.Log.Trace("Decode IE PagingDRX") case ngapType.ProtocolIEIDGlobalRANNodeID: // optional, ignore - ran.Log.Info("Not comprehended IE GlobalRANNodeID") + if globalRANNodeID != nil { + ran.Log.Error("Duplicate IE GlobalRANNodeID") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + globalRANNodeID = ie.Value.GlobalRANNodeID + ran.Log.Trace("Decode IE GlobalRANNodeID") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -6792,9 +8568,22 @@ func handlerRANConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT } } rawSendRANConfigurationUpdateFailure(ran, *syntaxCause, nil, &criticalityDiagnostics) + } + + if abort { return } + if rANNodeName != nil { + ran.Log.Warn("IE RANNodeName is not implemented") + } + if defaultPagingDRX != nil { + ran.Log.Warn("IE PagingDRX is not implemented") + } + if globalRANNodeID != nil { + ran.Log.Warn("IE GlobalRANNodeID is not implemented") + } + // func handleRANConfigurationUpdateMain(ran *context.AmfRan, // supportedTAList *ngapType.SupportedTAList) { handleRANConfigurationUpdateMain(ran, supportedTAList /* may be nil */) @@ -6803,6 +8592,10 @@ func handlerRANConfigurationUpdate(ran *context.AmfRan, initiatingMessage *ngapT func handlerRANConfigurationUpdateAcknowledge(ran *context.AmfRan, successfulOutcome *ngapType.SuccessfulOutcome) { var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + rANConfigurationUpdateAcknowledge := successfulOutcome.Value.RANConfigurationUpdateAcknowledge if rANConfigurationUpdateAcknowledge == nil { ran.Log.Error("RANConfigurationUpdateAcknowledge is nil") @@ -6816,11 +8609,40 @@ func handlerRANConfigurationUpdateAcknowledge(ran *context.AmfRan, successfulOut case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeRANConfigurationUpdate + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } // func handleRANConfigurationUpdateAcknowledgeMain(ran *context.AmfRan, @@ -6837,6 +8659,10 @@ func handlerRANConfigurationUpdateFailure(ran *context.AmfRan, unsuccessfulOutco var timeToWait *ngapType.TimeToWait var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + rANConfigurationUpdateFailure := unsuccessfulOutcome.Value.RANConfigurationUpdateFailure if rANConfigurationUpdateFailure == nil { ran.Log.Error("RANConfigurationUpdateFailure is nil") @@ -6850,25 +8676,56 @@ func handlerRANConfigurationUpdateFailure(ran *context.AmfRan, unsuccessfulOutco case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDTimeToWait: // optional, ignore if timeToWait != nil { ran.Log.Error("Duplicate IE TimeToWait") - return + abort = true + break } timeToWait = ie.Value.TimeToWait ran.Log.Trace("Decode IE TimeToWait") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeRANConfigurationUpdate + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if cause == nil { @@ -6894,6 +8751,7 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false rRCInactiveTransitionReport := initiatingMessage.Value.RRCInactiveTransitionReport if rRCInactiveTransitionReport == nil { @@ -6914,6 +8772,7 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -6927,6 +8786,7 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -6940,6 +8800,7 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rRCState = ie.Value.RRCState @@ -6953,10 +8814,27 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -6964,11 +8842,13 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -6982,6 +8862,9 @@ func handlerRRCInactiveTransitionReport(ran *context.AmfRan, initiatingMessage * } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -7030,6 +8913,7 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false rerouteNASRequest := initiatingMessage.Value.RerouteNASRequest if rerouteNASRequest == nil { @@ -7050,6 +8934,7 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -7063,6 +8948,7 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -7076,6 +8962,7 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFSetID = ie.Value.AMFSetID @@ -7089,10 +8976,27 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } allowedNSSAI = ie.Value.AllowedNSSAI ran.Log.Trace("Decode IE AllowedNSSAI") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -7100,11 +9004,13 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if aMFSetID == nil { ran.Log.Error("Missing IE AMFSetID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFSetID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -7118,6 +9024,9 @@ func handlerRerouteNASRequest(ran *context.AmfRan, initiatingMessage *ngapType.I } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -7177,6 +9086,7 @@ func handlerSecondaryRATDataUsageReport(ran *context.AmfRan, initiatingMessage * var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false secondaryRATDataUsageReport := initiatingMessage.Value.SecondaryRATDataUsageReport if secondaryRATDataUsageReport == nil { @@ -7197,6 +9107,7 @@ func handlerSecondaryRATDataUsageReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -7210,6 +9121,7 @@ func handlerSecondaryRATDataUsageReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -7223,6 +9135,7 @@ func handlerSecondaryRATDataUsageReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceSecondaryRATUsageList = ie.Value.PDUSessionResourceSecondaryRATUsageList @@ -7236,10 +9149,27 @@ func handlerSecondaryRATDataUsageReport(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } handoverFlag = ie.Value.HandoverFlag ran.Log.Trace("Decode IE HandoverFlag") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -7254,6 +9184,9 @@ func handlerSecondaryRATDataUsageReport(ran *context.AmfRan, initiatingMessage * } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -7314,6 +9247,7 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false traceFailureIndication := initiatingMessage.Value.TraceFailureIndication if traceFailureIndication == nil { @@ -7334,6 +9268,7 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -7347,6 +9282,7 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -7360,6 +9296,7 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nGRANTraceID = ie.Value.NGRANTraceID @@ -7373,10 +9310,27 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -7384,11 +9338,13 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -7402,6 +9358,9 @@ func handlerTraceFailureIndication(ran *context.AmfRan, initiatingMessage *ngapT } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -7464,6 +9423,7 @@ func handlerTraceStart(ran *context.AmfRan, initiatingMessage *ngapType.Initiati var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false traceStart := initiatingMessage.Value.TraceStart if traceStart == nil { @@ -7484,6 +9444,7 @@ func handlerTraceStart(ran *context.AmfRan, initiatingMessage *ngapType.Initiati Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -7497,6 +9458,7 @@ func handlerTraceStart(ran *context.AmfRan, initiatingMessage *ngapType.Initiati Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -7510,10 +9472,27 @@ func handlerTraceStart(ran *context.AmfRan, initiatingMessage *ngapType.Initiati Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } traceActivation = ie.Value.TraceActivation ran.Log.Trace("Decode IE TraceActivation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -7521,11 +9500,13 @@ func handlerTraceStart(ran *context.AmfRan, initiatingMessage *ngapType.Initiati ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -7539,6 +9520,9 @@ func handlerTraceStart(ran *context.AmfRan, initiatingMessage *ngapType.Initiati } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -7596,6 +9580,10 @@ func handlerUEContextModificationFailure(ran *context.AmfRan, unsuccessfulOutcom var cause *ngapType.Cause var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + uEContextModificationFailure := unsuccessfulOutcome.Value.UEContextModificationFailure if uEContextModificationFailure == nil { ran.Log.Error("UEContextModificationFailure is nil") @@ -7609,32 +9597,64 @@ func handlerUEContextModificationFailure(ran *context.AmfRan, unsuccessfulOutcom case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDCause: // mandatory, ignore if cause != nil { ran.Log.Error("Duplicate IE Cause") - return + abort = true + break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeUEContextModification + triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -7686,6 +9706,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uEContextModificationRequest := initiatingMessage.Value.UEContextModificationRequest if uEContextModificationRequest == nil { @@ -7706,6 +9727,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -7719,6 +9741,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -7732,6 +9755,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANPagingPriority = ie.Value.RANPagingPriority @@ -7745,6 +9769,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } securityKey = ie.Value.SecurityKey @@ -7758,6 +9783,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } indexToRFSP = ie.Value.IndexToRFSP @@ -7771,6 +9797,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uEAggregateMaximumBitRate = ie.Value.UEAggregateMaximumBitRate @@ -7784,6 +9811,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uESecurityCapabilities = ie.Value.UESecurityCapabilities @@ -7797,6 +9825,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } coreNetworkAssistanceInformation = ie.Value.CoreNetworkAssistanceInformation @@ -7810,6 +9839,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } emergencyFallbackIndicator = ie.Value.EmergencyFallbackIndicator @@ -7823,6 +9853,7 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } newAMFUENGAPID = ie.Value.NewAMFUENGAPID @@ -7836,10 +9867,27 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rRCInactiveTransitionReportRequest = ie.Value.RRCInactiveTransitionReportRequest ran.Log.Trace("Decode IE RRCInactiveTransitionReportRequest") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -7847,11 +9895,13 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -7865,6 +9915,9 @@ func handlerUEContextModificationRequest(ran *context.AmfRan, initiatingMessage } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -7928,6 +9981,10 @@ func handlerUEContextModificationResponse(ran *context.AmfRan, successfulOutcome var userLocationInformation *ngapType.UserLocationInformation var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + uEContextModificationResponse := successfulOutcome.Value.UEContextModificationResponse if uEContextModificationResponse == nil { ran.Log.Error("UEContextModificationResponse is nil") @@ -7941,39 +9998,72 @@ func handlerUEContextModificationResponse(ran *context.AmfRan, successfulOutcome case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDRRCState: // optional, ignore if rRCState != nil { ran.Log.Error("Duplicate IE RRCState") - return + abort = true + break } rRCState = ie.Value.RRCState ran.Log.Trace("Decode IE RRCState") case ngapType.ProtocolIEIDUserLocationInformation: // optional, ignore if userLocationInformation != nil { ran.Log.Error("Duplicate IE UserLocationInformation") - return + abort = true + break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeUEContextModification + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -8014,6 +10104,7 @@ func handlerUEContextReleaseCommand(ran *context.AmfRan, initiatingMessage *ngap var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uEContextReleaseCommand := initiatingMessage.Value.UEContextReleaseCommand if uEContextReleaseCommand == nil { @@ -8034,6 +10125,7 @@ func handlerUEContextReleaseCommand(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uENGAPIDs = ie.Value.UENGAPIDs @@ -8047,10 +10139,27 @@ func handlerUEContextReleaseCommand(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8058,6 +10167,7 @@ func handlerUEContextReleaseCommand(ran *context.AmfRan, initiatingMessage *ngap ran.Log.Error("Missing IE UE-NGAP-IDs") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDUENGAPIDs, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -8071,6 +10181,9 @@ func handlerUEContextReleaseCommand(ran *context.AmfRan, initiatingMessage *ngap } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -8111,6 +10224,10 @@ func handlerUEContextReleaseComplete(ran *context.AmfRan, successfulOutcome *nga var pDUSessionResourceListCxtRelCpl *ngapType.PDUSessionResourceListCxtRelCpl var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + uEContextReleaseComplete := successfulOutcome.Value.UEContextReleaseComplete if uEContextReleaseComplete == nil { ran.Log.Error("UEContextReleaseComplete is nil") @@ -8124,46 +10241,80 @@ func handlerUEContextReleaseComplete(ran *context.AmfRan, successfulOutcome *nga case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDUserLocationInformation: // optional, ignore if userLocationInformation != nil { ran.Log.Error("Duplicate IE UserLocationInformation") - return + abort = true + break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") case ngapType.ProtocolIEIDInfoOnRecommendedCellsAndRANNodesForPaging: // optional, ignore if infoOnRecommendedCellsAndRANNodesForPaging != nil { ran.Log.Error("Duplicate IE InfoOnRecommendedCellsAndRANNodesForPaging") - return + abort = true + break } infoOnRecommendedCellsAndRANNodesForPaging = ie.Value.InfoOnRecommendedCellsAndRANNodesForPaging ran.Log.Trace("Decode IE InfoOnRecommendedCellsAndRANNodesForPaging") case ngapType.ProtocolIEIDPDUSessionResourceListCxtRelCpl: // optional, reject if pDUSessionResourceListCxtRelCpl != nil { ran.Log.Error("Duplicate IE PDUSessionResourceListCxtRelCpl") - return + abort = true + break } pDUSessionResourceListCxtRelCpl = ie.Value.PDUSessionResourceListCxtRelCpl ran.Log.Trace("Decode IE PDUSessionResourceListCxtRelCpl") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeUEContextRelease + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -8207,6 +10358,7 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uEContextReleaseRequest := initiatingMessage.Value.UEContextReleaseRequest if uEContextReleaseRequest == nil { @@ -8227,6 +10379,7 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -8240,6 +10393,7 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -8253,6 +10407,7 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } pDUSessionResourceListCxtRelReq = ie.Value.PDUSessionResourceListCxtRelReq @@ -8266,10 +10421,27 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } cause = ie.Value.Cause ran.Log.Trace("Decode IE Cause") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8277,11 +10449,13 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -8295,6 +10469,9 @@ func handlerUEContextReleaseRequest(ran *context.AmfRan, initiatingMessage *ngap } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -8339,6 +10516,7 @@ func handlerUERadioCapabilityCheckRequest(ran *context.AmfRan, initiatingMessage var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uERadioCapabilityCheckRequest := initiatingMessage.Value.UERadioCapabilityCheckRequest if uERadioCapabilityCheckRequest == nil { @@ -8359,6 +10537,7 @@ func handlerUERadioCapabilityCheckRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -8372,6 +10551,7 @@ func handlerUERadioCapabilityCheckRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -8385,10 +10565,27 @@ func handlerUERadioCapabilityCheckRequest(ran *context.AmfRan, initiatingMessage Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uERadioCapability = ie.Value.UERadioCapability ran.Log.Trace("Decode IE UERadioCapability") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8396,11 +10593,13 @@ func handlerUERadioCapabilityCheckRequest(ran *context.AmfRan, initiatingMessage ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -8414,6 +10613,9 @@ func handlerUERadioCapabilityCheckRequest(ran *context.AmfRan, initiatingMessage } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -8468,6 +10670,10 @@ func handlerUERadioCapabilityCheckResponse(ran *context.AmfRan, successfulOutcom var iMSVoiceSupportIndicator *ngapType.IMSVoiceSupportIndicator var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + uERadioCapabilityCheckResponse := successfulOutcome.Value.UERadioCapabilityCheckResponse if uERadioCapabilityCheckResponse == nil { ran.Log.Error("UERadioCapabilityCheckResponse is nil") @@ -8481,32 +10687,64 @@ func handlerUERadioCapabilityCheckResponse(ran *context.AmfRan, successfulOutcom case ngapType.ProtocolIEIDAMFUENGAPID: // mandatory, ignore if aMFUENGAPID != nil { ran.Log.Error("Duplicate IE AMF-UE-NGAP-ID") - return + abort = true + break } aMFUENGAPID = ie.Value.AMFUENGAPID ran.Log.Trace("Decode IE AMF-UE-NGAP-ID") case ngapType.ProtocolIEIDRANUENGAPID: // mandatory, ignore if rANUENGAPID != nil { ran.Log.Error("Duplicate IE RAN-UE-NGAP-ID") - return + abort = true + break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") case ngapType.ProtocolIEIDIMSVoiceSupportIndicator: // mandatory, reject if iMSVoiceSupportIndicator != nil { ran.Log.Error("Duplicate IE IMSVoiceSupportIndicator") - return + abort = true + break } iMSVoiceSupportIndicator = ie.Value.IMSVoiceSupportIndicator ran.Log.Trace("Decode IE IMSVoiceSupportIndicator") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeUERadioCapabilityCheck + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if aMFUENGAPID == nil { @@ -8519,6 +10757,9 @@ func handlerUERadioCapabilityCheckResponse(ran *context.AmfRan, successfulOutcom ran.Log.Error("Missing IE IMSVoiceSupportIndicator") return } + if iMSVoiceSupportIndicator != nil { + ran.Log.Warn("IE IMSVoiceSupportIndicator is not implemented") + } // AMF: mandatory, ignore // RAN: mandatory, ignore @@ -8539,9 +10780,8 @@ func handlerUERadioCapabilityCheckResponse(ran *context.AmfRan, successfulOutcom // func handleUERadioCapabilityCheckResponseMain(ran *context.AmfRan, // ranUe *context.RanUe, - // iMSVoiceSupportIndicator *ngapType.IMSVoiceSupportIndicator, // criticalityDiagnostics *ngapType.CriticalityDiagnostics) { - handleUERadioCapabilityCheckResponseMain(ran, ranUe /* may be nil */, iMSVoiceSupportIndicator, criticalityDiagnostics /* may be nil */) + handleUERadioCapabilityCheckResponseMain(ran, ranUe /* may be nil */, criticalityDiagnostics /* may be nil */) } func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMessage) { @@ -8552,6 +10792,7 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uERadioCapabilityInfoIndication := initiatingMessage.Value.UERadioCapabilityInfoIndication if uERadioCapabilityInfoIndication == nil { @@ -8572,6 +10813,7 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -8585,6 +10827,7 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -8598,6 +10841,7 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uERadioCapability = ie.Value.UERadioCapability @@ -8611,10 +10855,27 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } uERadioCapabilityForPaging = ie.Value.UERadioCapabilityForPaging ran.Log.Trace("Decode IE UERadioCapabilityForPaging") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8622,11 +10883,13 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -8640,6 +10903,9 @@ func handlerUERadioCapabilityInfoIndication(ran *context.AmfRan, initiatingMessa } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -8683,6 +10949,7 @@ func handlerUETNLABindingReleaseRequest(ran *context.AmfRan, initiatingMessage * var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uETNLABindingReleaseRequest := initiatingMessage.Value.UETNLABindingReleaseRequest if uETNLABindingReleaseRequest == nil { @@ -8703,6 +10970,7 @@ func handlerUETNLABindingReleaseRequest(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -8716,10 +10984,27 @@ func handlerUETNLABindingReleaseRequest(ran *context.AmfRan, initiatingMessage * Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID ran.Log.Trace("Decode IE RAN-UE-NGAP-ID") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8727,11 +11012,13 @@ func handlerUETNLABindingReleaseRequest(ran *context.AmfRan, initiatingMessage * ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -8745,6 +11032,9 @@ func handlerUETNLABindingReleaseRequest(ran *context.AmfRan, initiatingMessage * } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -8800,6 +11090,7 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uplinkNASTransport := initiatingMessage.Value.UplinkNASTransport if uplinkNASTransport == nil { @@ -8820,6 +11111,7 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -8833,6 +11125,7 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -8846,6 +11139,7 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nASPDU = ie.Value.NASPDU @@ -8859,10 +11153,27 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } userLocationInformation = ie.Value.UserLocationInformation ran.Log.Trace("Decode IE UserLocationInformation") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8870,16 +11181,19 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nASPDU == nil { ran.Log.Error("Missing IE NAS-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNASPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -8893,6 +11207,9 @@ func handlerUplinkNASTransport(ran *context.AmfRan, initiatingMessage *ngapType. } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -8940,6 +11257,7 @@ func handlerUplinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingM var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uplinkNonUEAssociatedNRPPaTransport := initiatingMessage.Value.UplinkNonUEAssociatedNRPPaTransport if uplinkNonUEAssociatedNRPPaTransport == nil { @@ -8960,6 +11278,7 @@ func handlerUplinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingM Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } routingID = ie.Value.RoutingID @@ -8973,10 +11292,27 @@ func handlerUplinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingM Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nRPPaPDU = ie.Value.NRPPaPDU ran.Log.Trace("Decode IE NRPPa-PDU") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -8984,11 +11320,13 @@ func handlerUplinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingM ran.Log.Error("Missing IE RoutingID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRoutingID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nRPPaPDU == nil { ran.Log.Error("Missing IE NRPPa-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNRPPaPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -9002,6 +11340,9 @@ func handlerUplinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingM } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -9022,9 +11363,11 @@ func handlerUplinkNonUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingM func handlerUplinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMessage) { var sONConfigurationTransferUL *ngapType.SONConfigurationTransfer + var eNDCSONConfigurationTransferUL *ngapType.ENDCSONConfigurationTransfer var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uplinkRANConfigurationTransfer := initiatingMessage.Value.UplinkRANConfigurationTransfer if uplinkRANConfigurationTransfer == nil { @@ -9045,12 +11388,41 @@ func handlerUplinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMessag Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } sONConfigurationTransferUL = ie.Value.SONConfigurationTransferUL ran.Log.Trace("Decode IE SONConfigurationTransfer") case ngapType.ProtocolIEIDENDCSONConfigurationTransferUL: // optional, ignore - ran.Log.Info("Not comprehended IE EN-DCSONConfigurationTransfer") + if eNDCSONConfigurationTransferUL != nil { + ran.Log.Error("Duplicate IE EN-DCSONConfigurationTransfer") + syntaxCause = &ngapType.Cause{ + Present: ngapType.CausePresentProtocol, + Protocol: &ngapType.CauseProtocol{ + Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, + }, + } + abort = true + break + } + eNDCSONConfigurationTransferUL = ie.Value.ENDCSONConfigurationTransferUL + ran.Log.Trace("Decode IE EN-DCSONConfigurationTransfer") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -9065,9 +11437,16 @@ func handlerUplinkRANConfigurationTransfer(ran *context.AmfRan, initiatingMessag } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } + if eNDCSONConfigurationTransferUL != nil { + ran.Log.Warn("IE EN-DCSONConfigurationTransfer is not implemented") + } + // func handleUplinkRANConfigurationTransferMain(ran *context.AmfRan, // sONConfigurationTransferUL *ngapType.SONConfigurationTransfer) { handleUplinkRANConfigurationTransferMain(ran, sONConfigurationTransferUL /* may be nil */) @@ -9080,6 +11459,7 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uplinkRANStatusTransfer := initiatingMessage.Value.UplinkRANStatusTransfer if uplinkRANStatusTransfer == nil { @@ -9100,6 +11480,7 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -9113,6 +11494,7 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -9126,10 +11508,27 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANStatusTransferTransparentContainer = ie.Value.RANStatusTransferTransparentContainer ran.Log.Trace("Decode IE RANStatusTransfer-TransparentContainer") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -9137,16 +11536,19 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANStatusTransferTransparentContainer == nil { ran.Log.Error("Missing IE RANStatusTransfer-TransparentContainer") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANStatusTransferTransparentContainer, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -9160,6 +11562,9 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -9175,6 +11580,9 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap ran.Log.Error("Missing IE RANStatusTransfer-TransparentContainer") return } + if rANStatusTransferTransparentContainer != nil { + ran.Log.Warn("IE RANStatusTransfer-TransparentContainer is not implemented") + } // AMF: mandatory, reject // RAN: mandatory, reject @@ -9192,9 +11600,8 @@ func handlerUplinkRANStatusTransfer(ran *context.AmfRan, initiatingMessage *ngap ranUe.Log.Infof("Handle UplinkRANStatusTransfer (RAN UE NGAP ID: %d)", ranUe.RanUeNgapId) // func handleUplinkRANStatusTransferMain(ran *context.AmfRan, - // ranUe *context.RanUe, - // rANStatusTransferTransparentContainer *ngapType.RANStatusTransferTransparentContainer) { - handleUplinkRANStatusTransferMain(ran, ranUe, rANStatusTransferTransparentContainer) + // ranUe *context.RanUe) { + handleUplinkRANStatusTransferMain(ran, ranUe) } func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMessage) { @@ -9205,6 +11612,7 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false uplinkUEAssociatedNRPPaTransport := initiatingMessage.Value.UplinkUEAssociatedNRPPaTransport if uplinkUEAssociatedNRPPaTransport == nil { @@ -9225,6 +11633,7 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } aMFUENGAPID = ie.Value.AMFUENGAPID @@ -9238,6 +11647,7 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } rANUENGAPID = ie.Value.RANUENGAPID @@ -9251,6 +11661,7 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } routingID = ie.Value.RoutingID @@ -9264,10 +11675,27 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } nRPPaPDU = ie.Value.NRPPaPDU ran.Log.Trace("Decode IE NRPPa-PDU") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -9275,21 +11703,25 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess ran.Log.Error("Missing IE AMF-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDAMFUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if rANUENGAPID == nil { ran.Log.Error("Missing IE RAN-UE-NGAP-ID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRANUENGAPID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if routingID == nil { ran.Log.Error("Missing IE RoutingID") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRoutingID, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if nRPPaPDU == nil { ran.Log.Error("Missing IE NRPPa-PDU") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNRPPaPDU, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -9303,6 +11735,9 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, aMFUENGAPID, rANUENGAPID, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -9322,6 +11757,9 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess ran.Log.Error("Missing IE NRPPa-PDU") return } + if nRPPaPDU != nil { + ran.Log.Warn("IE NRPPa-PDU is not implemented") + } // AMF: mandatory, reject // RAN: mandatory, reject @@ -9340,9 +11778,8 @@ func handlerUplinkUEAssociatedNRPPaTransport(ran *context.AmfRan, initiatingMess // func handleUplinkUEAssociatedNRPPaTransportMain(ran *context.AmfRan, // ranUe *context.RanUe, - // routingID *ngapType.RoutingID, - // nRPPaPDU *ngapType.NRPPaPDU) { - handleUplinkUEAssociatedNRPPaTransportMain(ran, ranUe, routingID, nRPPaPDU) + // routingID *ngapType.RoutingID) { + handleUplinkUEAssociatedNRPPaTransportMain(ran, ranUe, routingID) } func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *ngapType.InitiatingMessage) { @@ -9360,6 +11797,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n var syntaxCause *ngapType.Cause var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false writeReplaceWarningRequest := initiatingMessage.Value.WriteReplaceWarningRequest if writeReplaceWarningRequest == nil { @@ -9380,6 +11818,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } messageIdentifier = ie.Value.MessageIdentifier @@ -9393,6 +11832,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } serialNumber = ie.Value.SerialNumber @@ -9406,6 +11846,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } warningAreaList = ie.Value.WarningAreaList @@ -9419,6 +11860,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } repetitionPeriod = ie.Value.RepetitionPeriod @@ -9432,6 +11874,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } numberOfBroadcastsRequested = ie.Value.NumberOfBroadcastsRequested @@ -9445,6 +11888,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } warningType = ie.Value.WarningType @@ -9458,6 +11902,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } warningSecurityInfo = ie.Value.WarningSecurityInfo @@ -9471,6 +11916,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } dataCodingScheme = ie.Value.DataCodingScheme @@ -9484,6 +11930,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } warningMessageContents = ie.Value.WarningMessageContents @@ -9497,6 +11944,7 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } concurrentWarningMessageInd = ie.Value.ConcurrentWarningMessageInd @@ -9510,10 +11958,27 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n Value: ngapType.CauseProtocolPresentAbstractSyntaxErrorFalselyConstructedMessage, }, } + abort = true break } warningAreaCoordinates = ie.Value.WarningAreaCoordinates ran.Log.Trace("Decode IE WarningAreaCoordinates") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + } + if ie.Criticality.Value != ngapType.CriticalityPresentIgnore { + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + if ie.Criticality.Value == ngapType.CriticalityPresentReject { + abort = true + } + } } } @@ -9521,21 +11986,25 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n ran.Log.Error("Missing IE MessageIdentifier") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDMessageIdentifier, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if serialNumber == nil { ran.Log.Error("Missing IE SerialNumber") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDSerialNumber, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if repetitionPeriod == nil { ran.Log.Error("Missing IE RepetitionPeriod") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDRepetitionPeriod, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if numberOfBroadcastsRequested == nil { ran.Log.Error("Missing IE NumberOfBroadcastsRequested") item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, ngapType.ProtocolIEIDNumberOfBroadcastsRequested, ngapType.TypeOfErrorPresentMissing) iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + abort = true } if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { @@ -9549,6 +12018,9 @@ func handlerWriteReplaceWarningRequest(ran *context.AmfRan, initiatingMessage *n } criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { return } @@ -9605,6 +12077,10 @@ func handlerWriteReplaceWarningResponse(ran *context.AmfRan, successfulOutcome * var broadcastCompletedAreaList *ngapType.BroadcastCompletedAreaList var criticalityDiagnostics *ngapType.CriticalityDiagnostics + var syntaxCause *ngapType.Cause + var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList + abort := false + writeReplaceWarningResponse := successfulOutcome.Value.WriteReplaceWarningResponse if writeReplaceWarningResponse == nil { ran.Log.Error("WriteReplaceWarningResponse is nil") @@ -9618,32 +12094,64 @@ func handlerWriteReplaceWarningResponse(ran *context.AmfRan, successfulOutcome * case ngapType.ProtocolIEIDMessageIdentifier: // mandatory, reject if messageIdentifier != nil { ran.Log.Error("Duplicate IE MessageIdentifier") - return + abort = true + break } messageIdentifier = ie.Value.MessageIdentifier ran.Log.Trace("Decode IE MessageIdentifier") case ngapType.ProtocolIEIDSerialNumber: // mandatory, reject if serialNumber != nil { ran.Log.Error("Duplicate IE SerialNumber") - return + abort = true + break } serialNumber = ie.Value.SerialNumber ran.Log.Trace("Decode IE SerialNumber") case ngapType.ProtocolIEIDBroadcastCompletedAreaList: // optional, ignore if broadcastCompletedAreaList != nil { ran.Log.Error("Duplicate IE BroadcastCompletedAreaList") - return + abort = true + break } broadcastCompletedAreaList = ie.Value.BroadcastCompletedAreaList ran.Log.Trace("Decode IE BroadcastCompletedAreaList") case ngapType.ProtocolIEIDCriticalityDiagnostics: // optional, ignore if criticalityDiagnostics != nil { ran.Log.Error("Duplicate IE CriticalityDiagnostics") - return + abort = true + break } criticalityDiagnostics = ie.Value.CriticalityDiagnostics ran.Log.Trace("Decode IE CriticalityDiagnostics") + default: + switch ie.Criticality.Value { + case ngapType.CriticalityPresentReject: + ran.Log.Errorf("Not comprehended IE ID 0x%04x (criticality: reject)", ie.Id.Value) + case ngapType.CriticalityPresentIgnore: + ran.Log.Infof("Not comprehended IE ID 0x%04x (criticality: ignore)", ie.Id.Value) + case ngapType.CriticalityPresentNotify: + ran.Log.Warnf("Not comprehended IE ID 0x%04x (criticality: notify)", ie.Id.Value) + item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood) + iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item) + } + } + } + + if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 { + ran.Log.Trace("Has IE error") + procedureCode := ngapType.ProcedureCodeWriteReplaceWarning + triggeringMessage := ngapType.TriggeringMessagePresentSuccessfulOutcome + procedureCriticality := ngapType.CriticalityPresentReject + var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList + if len(iesCriticalityDiagnostics.List) > 0 { + pIesCriticalityDiagnostics = &iesCriticalityDiagnostics } + criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics) + ngap_message.SendErrorIndication(ran, nil, nil, syntaxCause, &criticalityDiagnostics) + } + + if abort { + return } if messageIdentifier == nil { diff --git a/internal/ngap/ngap_generator.go b/internal/ngap/ngap_generator.go index 41b43fbc..1d67a056 100644 --- a/internal/ngap/ngap_generator.go +++ b/internal/ngap/ngap_generator.go @@ -28,14 +28,14 @@ const ( // NGAP IE definition type IEInfo struct { - Criticality aper.Enumerated - Type string - Presence aper.Enumerated - GoID string - GoField string - GoVar string - GoType string - Comprehended bool + Criticality aper.Enumerated + Type string + Presence aper.Enumerated + GoID string + GoField string + GoVar string + GoType string + Unimplemented bool } // NGAP message definition @@ -154,7 +154,6 @@ func readASN1() { ie.GoField = "Value." + convGoName(ieId[3:]) ie.GoVar = convGoLocalName(ieId[3:]) ie.GoType = "ngapType." + convGoName(ieType) - ie.Comprehended = true // fmt.Printf("%+v\n", *ie) } } @@ -234,23 +233,23 @@ func readASN1() { } func fixIEs() { - // Uncomprehended (not implemented) IEs - MsgTable["AMFConfigurationUpdateAcknowledge"].IEs["id-AMF-TNLAssociationSetupList"].Comprehended = false - MsgTable["AMFConfigurationUpdateAcknowledge"].IEs["id-AMF-TNLAssociationFailedToSetupList"].Comprehended = false - MsgTable["AMFConfigurationUpdateFailure"].IEs["id-TimeToWait"].Comprehended = false - MsgTable["HandoverRequired"].IEs["id-DirectForwardingPathAvailability"].Comprehended = false - MsgTable["InitialUEMessage"].IEs["id-AMFSetID"].Comprehended = false - // MsgTable["InitialUEMessage"].IEs["id-AllowedNSSAI"].Comprehended = false - MsgTable["NGSetupRequest"].IEs["id-UERetentionInformation"].Comprehended = false - MsgTable["RANConfigurationUpdate"].IEs["id-RANNodeName"].Comprehended = false - MsgTable["RANConfigurationUpdate"].IEs["id-DefaultPagingDRX"].Comprehended = false - MsgTable["RANConfigurationUpdate"].IEs["id-GlobalRANNodeID"].Comprehended = false - // MsgTable["UERadioCapabilityCheckResponse"].IEs["id-AMF-UE-NGAP-ID"].Comprehended = false - // MsgTable["UERadioCapabilityCheckResponse"].IEs["id-RAN-UE-NGAP-ID"].Comprehended = false - // MsgTable["UERadioCapabilityCheckResponse"].IEs["id-IMSVoiceSupportIndicator"].Comprehended = false - MsgTable["UplinkRANConfigurationTransfer"].IEs["id-ENDC-SONConfigurationTransferUL"].Comprehended = false - // MsgTable["UplinkRANStatusTransfer"].IEs["id-RANStatusTransfer-TransparentContainer"].Comprehended = false - // MsgTable["UplinkUEAssociatedNRPPaTransport"].IEs["id-NRPPa-PDU"].Comprehended = false + // Not implemented IEs + MsgTable["AMFConfigurationUpdateAcknowledge"].IEs["id-AMF-TNLAssociationSetupList"].Unimplemented = true + MsgTable["AMFConfigurationUpdateAcknowledge"].IEs["id-AMF-TNLAssociationFailedToSetupList"].Unimplemented = true + MsgTable["AMFConfigurationUpdateFailure"].IEs["id-TimeToWait"].Unimplemented = true + MsgTable["HandoverRequired"].IEs["id-DirectForwardingPathAvailability"].Unimplemented = true + MsgTable["InitialUEMessage"].IEs["id-AMFSetID"].Unimplemented = true + MsgTable["InitialUEMessage"].IEs["id-AllowedNSSAI"].Unimplemented = true + MsgTable["NGSetupRequest"].IEs["id-UERetentionInformation"].Unimplemented = true + MsgTable["RANConfigurationUpdate"].IEs["id-RANNodeName"].Unimplemented = true + MsgTable["RANConfigurationUpdate"].IEs["id-DefaultPagingDRX"].Unimplemented = true + MsgTable["RANConfigurationUpdate"].IEs["id-GlobalRANNodeID"].Unimplemented = true + // MsgTable["UERadioCapabilityCheckResponse"].IEs["id-AMF-UE-NGAP-ID"].Unimplemented = true + // MsgTable["UERadioCapabilityCheckResponse"].IEs["id-RAN-UE-NGAP-ID"].Unimplemented = true + MsgTable["UERadioCapabilityCheckResponse"].IEs["id-IMSVoiceSupportIndicator"].Unimplemented = true + MsgTable["UplinkRANConfigurationTransfer"].IEs["id-ENDC-SONConfigurationTransferUL"].Unimplemented = true + MsgTable["UplinkRANStatusTransfer"].IEs["id-RANStatusTransfer-TransparentContainer"].Unimplemented = true + MsgTable["UplinkUEAssociatedNRPPaTransport"].IEs["id-NRPPa-PDU"].Unimplemented = true } // generate NGAP handler file @@ -304,15 +303,12 @@ func generateHandler() { for _, ieName := range mInfo.IEorder { ieInfo := mInfo.IEs[ieName] // fmt.Fprintf(fOut, "// %s\n", ieName) - if ieInfo.Comprehended { - fmt.Fprintf(fOut, "var %s *%s\n", ieInfo.GoVar, ieInfo.GoType) - } + fmt.Fprintf(fOut, "var %s *%s\n", ieInfo.GoVar, ieInfo.GoType) } fmt.Fprintln(fOut, "") - if isRequest { - fmt.Fprintln(fOut, "var syntaxCause *ngapType.Cause") - fmt.Fprintln(fOut, "var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList") - } + fmt.Fprintln(fOut, "var syntaxCause *ngapType.Cause") + fmt.Fprintln(fOut, "var iesCriticalityDiagnostics ngapType.CriticalityDiagnosticsIEList") + fmt.Fprintln(fOut, "abort := false") // generate extract IEs code fmt.Fprintln(fOut, "") @@ -329,14 +325,13 @@ func generateHandler() { for _, ieName := range mInfo.IEorder { ieInfo := mInfo.IEs[ieName] fmt.Fprintf(fOut, "case %s: // %s, %s\n", ieInfo.GoID, presence2Str(ieInfo.Presence), criticality2Str(ieInfo.Criticality)) - if ieInfo.Comprehended { - // supported IE - - // duplicate check code - fmt.Fprintf(fOut, "if %s !=nil {\n", ieInfo.GoVar) - fmt.Fprintf(fOut, "ran.Log.Error(\"Duplicate IE %s\")\n", ieInfo.Type) - if isRequest { - fmt.Fprint(fOut, ` + // supported IE + + // duplicate check code + fmt.Fprintf(fOut, "if %s !=nil {\n", ieInfo.GoVar) + fmt.Fprintf(fOut, "ran.Log.Error(\"Duplicate IE %s\")\n", ieInfo.Type) + if isRequest { + fmt.Fprint(fOut, ` syntaxCause = &ngapType.Cause{ Present: ngapType.CausePresentProtocol, Protocol: &ngapType.CauseProtocol{ @@ -344,31 +339,35 @@ syntaxCause = &ngapType.Cause{ }, } `[1:]) - fmt.Fprintf(fOut, "break\n") - } else { - fmt.Fprintln(fOut, "return") - } - fmt.Fprintf(fOut, "}\n") - - fmt.Fprintf(fOut, "%s = ie.%s\n", ieInfo.GoVar, ieInfo.GoField) - fmt.Fprintf(fOut, "ran.Log.Trace(\"Decode IE %s\")\n", ieInfo.Type) - } else { - // not supported IE - switch ieInfo.Criticality { - case ngapType.CriticalityPresentReject: - fmt.Fprintf(fOut, "ran.Log.Error(\"Not comprehended IE %s\")\n", ieInfo.Type) - if isRequest { - fmt.Fprintf(fOut, "item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, %s, ngapType.TypeOfErrorPresentNotUnderstood)\n", ieInfo.GoID) - fmt.Fprintln(fOut, "iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item)") - } else { - fmt.Fprintln(fOut, "return") - } - case ngapType.CriticalityPresentIgnore: - fmt.Fprintf(fOut, "ran.Log.Info(\"Not comprehended IE %s\")\n", ieInfo.Type) - case ngapType.CriticalityPresentNotify: - panic("not yet") - } } + fmt.Fprintln(fOut, "abort = true") + fmt.Fprintln(fOut, "break") + fmt.Fprintf(fOut, "}\n") + + fmt.Fprintf(fOut, "%s = ie.%s\n", ieInfo.GoVar, ieInfo.GoField) + fmt.Fprintf(fOut, "ran.Log.Trace(\"Decode IE %s\")\n", ieInfo.Type) + } + fmt.Fprintln(fOut, "default:") + fmt.Fprintln(fOut, "switch ie.Criticality.Value {") + fmt.Fprintln(fOut, "case ngapType.CriticalityPresentReject:") + fmt.Fprintln(fOut, "ran.Log.Errorf(\"Not comprehended IE ID 0x%04x (criticality: reject)\", ie.Id.Value)") + fmt.Fprintln(fOut, "case ngapType.CriticalityPresentIgnore:") + fmt.Fprintln(fOut, "ran.Log.Infof(\"Not comprehended IE ID 0x%04x (criticality: ignore)\", ie.Id.Value)") + fmt.Fprintln(fOut, "case ngapType.CriticalityPresentNotify:") + fmt.Fprintln(fOut, "ran.Log.Warnf(\"Not comprehended IE ID 0x%04x (criticality: notify)\", ie.Id.Value)") + if !isRequest { + fmt.Fprintln(fOut, "item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood)") + fmt.Fprintln(fOut, "iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item)") + } + fmt.Fprintln(fOut, "}") + if isRequest { + fmt.Fprintln(fOut, "if ie.Criticality.Value != ngapType.CriticalityPresentIgnore {") + fmt.Fprintln(fOut, "item := buildCriticalityDiagnosticsIEItem(ie.Criticality.Value, ie.Id.Value, ngapType.TypeOfErrorPresentNotUnderstood)") + fmt.Fprintln(fOut, "iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item)") + fmt.Fprintln(fOut, "if ie.Criticality.Value == ngapType.CriticalityPresentReject {") + fmt.Fprintln(fOut, "abort = true") + fmt.Fprintln(fOut, "}") + fmt.Fprintln(fOut, "}") } fmt.Fprintln(fOut, "}") fmt.Fprintln(fOut, "}") @@ -383,65 +382,68 @@ syntaxCause = &ngapType.Cause{ fmt.Fprintf(fOut, "ran.Log.Error(\"Missing IE %s\")\n", ieInfo.Type) fmt.Fprintf(fOut, "item := buildCriticalityDiagnosticsIEItem(ngapType.CriticalityPresentReject, %s, ngapType.TypeOfErrorPresentMissing)\n", ieInfo.GoID) fmt.Fprintln(fOut, "iesCriticalityDiagnostics.List = append(iesCriticalityDiagnostics.List, item)") + fmt.Fprintln(fOut, "abort = true") fmt.Fprintln(fOut, "}") } } + } - // Generate Error Indication - fmt.Fprintln(fOut, "") - fmt.Fprintln(fOut, "if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 {") - fmt.Fprintln(fOut, "ran.Log.Trace(\"Has IE error\")") - genErrorIndicationCommon(fOut, mInfo) - fmt.Fprintln(fOut, "var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList") - fmt.Fprintln(fOut, "if len(iesCriticalityDiagnostics.List) > 0 {") - fmt.Fprintln(fOut, "pIesCriticalityDiagnostics = &iesCriticalityDiagnostics") + // Generate Error Indication + fmt.Fprintln(fOut, "") + fmt.Fprintln(fOut, "if syntaxCause != nil || len(iesCriticalityDiagnostics.List) > 0 {") + fmt.Fprintln(fOut, "ran.Log.Trace(\"Has IE error\")") + genErrorIndicationCommon(fOut, mInfo) + fmt.Fprintln(fOut, "var pIesCriticalityDiagnostics *ngapType.CriticalityDiagnosticsIEList") + fmt.Fprintln(fOut, "if len(iesCriticalityDiagnostics.List) > 0 {") + fmt.Fprintln(fOut, "pIesCriticalityDiagnostics = &iesCriticalityDiagnostics") + fmt.Fprintln(fOut, "}") + fmt.Fprintln(fOut, "criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics)") + // Must report error by other message than ErrorIndication by these messages + switch msgName { + // AMF to RAN message + // case "AMFConfigurationUpdate": + // fmt.Fprintf(fOut, "ngap_message.SendAMFConfigurationUpdateFailure(ran, syntaxCause, &criticalityDiagnostics)\n") + + case "HandoverRequired": + fmt.Fprintf(fOut, "if %s != nil && %s != nil {\n", amfIdIeVar, ranIdIeVar) + avoidNilSyntaxCause(fOut) + fmt.Fprintf(fOut, "rawSendHandoverPreparationFailure(ran, *%s, *%s, *syntaxCause, &criticalityDiagnostics)\n", amfIdIeVar, ranIdIeVar) + fmt.Fprintln(fOut, "} else {") + fmt.Fprintf(fOut, "ngap_message.SendErrorIndication(ran, %s, %s, syntaxCause, &criticalityDiagnostics)\n", amfIdIeVar, ranIdIeVar) fmt.Fprintln(fOut, "}") - fmt.Fprintln(fOut, "criticalityDiagnostics := buildCriticalityDiagnostics(&procedureCode, &triggeringMessage, &procedureCriticality, pIesCriticalityDiagnostics)") - // Must report error by other message than ErrorIndication by these messages - switch msgName { - // AMF to RAN message - // case "AMFConfigurationUpdate": - // fmt.Fprintf(fOut, "ngap_message.SendAMFConfigurationUpdateFailure(ran, syntaxCause, &criticalityDiagnostics)\n") - - case "HandoverRequired": - fmt.Fprintf(fOut, "if %s != nil && %s != nil {\n", amfIdIeVar, ranIdIeVar) - avoidNilSyntaxCause(fOut) - fmt.Fprintf(fOut, "rawSendHandoverPreparationFailure(ran, *%s, *%s, *syntaxCause, &criticalityDiagnostics)\n", amfIdIeVar, ranIdIeVar) - fmt.Fprintln(fOut, "} else {") - fmt.Fprintf(fOut, "ngap_message.SendErrorIndication(ran, %s, %s, syntaxCause, &criticalityDiagnostics)\n", amfIdIeVar, ranIdIeVar) - fmt.Fprintln(fOut, "}") - // AMF to RAN message - // case "HandoverRequest": - // fmt.Fprintf(fOut, "ngap_message.SendHandoverFailure(ran, syntaxCause, &criticalityDiagnostics)\n") + // AMF to RAN message + // case "HandoverRequest": + // fmt.Fprintf(fOut, "ngap_message.SendHandoverFailure(ran, syntaxCause, &criticalityDiagnostics)\n") - // AMF to RAN message - // case "InitialContextSetupRequest": - // fmt.Fprintf(fOut, "ngap_message.SendInitialContextSetupFailure(ran, syntaxCause, &criticalityDiagnostics)\n") + // AMF to RAN message + // case "InitialContextSetupRequest": + // fmt.Fprintf(fOut, "ngap_message.SendInitialContextSetupFailure(ran, syntaxCause, &criticalityDiagnostics)\n") - case "NGSetupRequest": - avoidNilSyntaxCause(fOut) - fmt.Fprintf(fOut, "rawSendNGSetupFailure(ran, *syntaxCause, nil, &criticalityDiagnostics)\n") + case "NGSetupRequest": + avoidNilSyntaxCause(fOut) + fmt.Fprintf(fOut, "rawSendNGSetupFailure(ran, *syntaxCause, nil, &criticalityDiagnostics)\n") - // Cannot fill mandatory IEs - // case "PathSwitchRequest": - // fmt.Fprintf(fOut, "ngap_message.SendPathSwitchRequestFailure(ran, syntaxCause, &criticalityDiagnostics)\n") + // Cannot fill mandatory IEs + // case "PathSwitchRequest": + // fmt.Fprintf(fOut, "ngap_message.SendPathSwitchRequestFailure(ran, syntaxCause, &criticalityDiagnostics)\n") - case "RANConfigurationUpdate": - avoidNilSyntaxCause(fOut) - fmt.Fprintf(fOut, "rawSendRANConfigurationUpdateFailure(ran, *syntaxCause, nil, &criticalityDiagnostics)\n") + case "RANConfigurationUpdate": + avoidNilSyntaxCause(fOut) + fmt.Fprintf(fOut, "rawSendRANConfigurationUpdateFailure(ran, *syntaxCause, nil, &criticalityDiagnostics)\n") - // AMF to RAN message - // case "UEContextModificationRequest": - // fmt.Fprintf(fOut, "ngap_message.SendUEContextModificationFailure(ran, syntaxCause, &criticalityDiagnostics)\n") + // AMF to RAN message + // case "UEContextModificationRequest": + // fmt.Fprintf(fOut, "ngap_message.SendUEContextModificationFailure(ran, syntaxCause, &criticalityDiagnostics)\n") - default: - fmt.Fprintf(fOut, "ngap_message.SendErrorIndication(ran, %s, %s, syntaxCause, &criticalityDiagnostics)\n", amfIdIeVar, ranIdIeVar) - } - fmt.Fprintln(fOut, "return") - fmt.Fprintln(fOut, "}") - // } + default: + fmt.Fprintf(fOut, "ngap_message.SendErrorIndication(ran, %s, %s, syntaxCause, &criticalityDiagnostics)\n", amfIdIeVar, ranIdIeVar) } + fmt.Fprintln(fOut, "}") + fmt.Fprintln(fOut, "") + fmt.Fprintln(fOut, "if abort {") + fmt.Fprintln(fOut, "return") + fmt.Fprintln(fOut, "}") // To avoid Coverity's false positive, generate this check for Request messages too fmt.Fprintln(fOut, "") @@ -457,6 +459,11 @@ syntaxCause = &ngapType.Cause{ } fmt.Fprintln(fOut, "}") } + if ieInfo.Unimplemented { + fmt.Fprintf(fOut, "if %s != nil {\n", ieInfo.GoVar) + fmt.Fprintf(fOut, "ran.Log.Warn(\"IE %s is not implemented\")\n", ieInfo.Type) + fmt.Fprintln(fOut, "}") + } } // generate UE ID handling codes @@ -507,7 +514,7 @@ syntaxCause = &ngapType.Cause{ } for _, ieName := range mInfo.IEorder { ieInfo := mInfo.IEs[ieName] - if ieInfo.Comprehended && (!hasRanUe || (ieName != "id-AMF-UE-NGAP-ID" && ieName != "id-RAN-UE-NGAP-ID") || (msgName == "HandoverRequestAcknowledge" && ieName == "id-RAN-UE-NGAP-ID")) { + if !ieInfo.Unimplemented && (!hasRanUe || (ieName != "id-AMF-UE-NGAP-ID" && ieName != "id-RAN-UE-NGAP-ID") || (msgName == "HandoverRequestAcknowledge" && ieName == "id-RAN-UE-NGAP-ID")) { mayNil := "" if !(ieInfo.Presence == ngapType.PresencePresentMandatory && ieInfo.Criticality == ngapType.CriticalityPresentReject) { mayNil = " /* may be nil */" @@ -576,6 +583,7 @@ func generateDispatcher() { "ngap", []string{ "\"github.com/free5gc/amf/internal/context\"", + "ngap_message \"github.com/free5gc/amf/internal/ngap/message\"", "\"github.com/free5gc/ngap/ngapType\"", }) @@ -589,12 +597,13 @@ func generateDispatcher() { "UnsuccessfulOutcome", } { fmt.Fprintf(fOut, "case ngapType.NGAPPDUPresent%s:\n", present) - fmt.Fprintf(fOut, "%s := message.%s\n", convGoLocalName(present), present) - fmt.Fprintf(fOut, "if %s == nil {\n", convGoLocalName(present)) + presentVar := convGoLocalName(present) + fmt.Fprintf(fOut, "%s := message.%s\n", presentVar, present) + fmt.Fprintf(fOut, "if %s == nil {\n", presentVar) fmt.Fprintf(fOut, "ran.Log.Errorln(\"%s is nil\")\n", present) fmt.Fprintln(fOut, "return") fmt.Fprintln(fOut, "}") - fmt.Fprintf(fOut, "switch %s.ProcedureCode.Value {\n", convGoLocalName(present)) + fmt.Fprintf(fOut, "switch %s.ProcedureCode.Value {\n", presentVar) for _, msgName := range msgNames { mInfo := MsgTable[msgName] if mInfo.GoField == present { @@ -603,11 +612,28 @@ func generateDispatcher() { if msgName == "InitialUEMessage" { messageAppend = ", message" } - fmt.Fprintf(fOut, "handler%s(ran%s, %s)\n", msgName, messageAppend, convGoLocalName(present)) + fmt.Fprintf(fOut, "handler%s(ran%s, %s)\n", msgName, messageAppend, presentVar) } } fmt.Fprintln(fOut, "default:") - fmt.Fprintf(fOut, "ran.Log.Warnf(\"Not implemented(choice:%%d, procedureCode:%%d)\", message.Present, %s.ProcedureCode.Value)\n", convGoLocalName(present)) + fmt.Fprintln(fOut, "cause := ngapType.Cause{") + fmt.Fprintln(fOut, "Present: ngapType.CausePresentProtocol,") + fmt.Fprintln(fOut, "Protocol: &ngapType.CauseProtocol{},") + fmt.Fprintln(fOut, "}") + fmt.Fprintf(fOut, "switch %s.Criticality.Value {\n", presentVar) + fmt.Fprintln(fOut, "case ngapType.CriticalityPresentReject:") + fmt.Fprintf(fOut, "ran.Log.Errorf(\"Not comprehended procedure code of %s (criticality: reject, procedureCode:0x%%02x)\", %s.ProcedureCode.Value)\n", present, presentVar) + fmt.Fprintln(fOut, "cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorReject") + fmt.Fprintln(fOut, "case ngapType.CriticalityPresentIgnore:") + fmt.Fprintf(fOut, "ran.Log.Infof(\"Not comprehended procedure code of %s (criticality: ignore, procedureCode:0x%%02x)\", %s.ProcedureCode.Value)\n", present, presentVar) + fmt.Fprintln(fOut, "return") + fmt.Fprintln(fOut, "case ngapType.CriticalityPresentNotify:") + fmt.Fprintf(fOut, "ran.Log.Warnf(\"Not comprehended procedure code of %s (criticality: notify, procedureCode:0x%%02x)\", %s.ProcedureCode.Value)\n", present, presentVar) + fmt.Fprintln(fOut, "cause.Protocol.Value = ngapType.CauseProtocolPresentAbstractSyntaxErrorIgnoreAndNotify") + fmt.Fprintln(fOut, "}") + genTriggeringMessage(fOut, present) + fmt.Fprintf(fOut, "criticalityDiagnostics := buildCriticalityDiagnostics(&%s.ProcedureCode.Value, &triggeringMessage, &%s.Criticality.Value, nil)\n", presentVar, presentVar) + fmt.Fprintln(fOut, "ngap_message.SendErrorIndication(ran, nil, nil, &cause, &criticalityDiagnostics)") fmt.Fprintln(fOut, "}") } fmt.Fprintln(fOut, "}") @@ -764,11 +790,7 @@ func (o *outputFile) Close() { func genErrorIndicationCommon(f io.Writer, mInfo *MsgInfo) { fmt.Fprintf(f, "procedureCode := ngapType.ProcedureCode%s\n", mInfo.ProcCode) - if mInfo.GoField == "UnsuccessfulOutcome" { - fmt.Fprintf(f, "triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome\n") - } else { - fmt.Fprintf(f, "triggeringMessage := ngapType.TriggeringMessagePresent%s\n", mInfo.GoField) - } + genTriggeringMessage(f, mInfo.GoField) switch mInfo.Criticality { case ngapType.CriticalityPresentReject: fmt.Fprintln(f, "procedureCriticality := ngapType.CriticalityPresentReject") @@ -779,6 +801,14 @@ func genErrorIndicationCommon(f io.Writer, mInfo *MsgInfo) { } } +func genTriggeringMessage(f io.Writer, present string) { + if present == "UnsuccessfulOutcome" { + fmt.Fprintf(f, "triggeringMessage := ngapType.TriggeringMessagePresentUnsuccessfullOutcome\n") + } else { + fmt.Fprintf(f, "triggeringMessage := ngapType.TriggeringMessagePresent%s\n", present) + } +} + func str2Presence(presence string) aper.Enumerated { switch presence { case "optional": From fa32537d370bff6b20c89ceeadeef6f1825b3dc2 Mon Sep 17 00:00:00 2001 From: ShouheiNishi <96609867+ShouheiNishi@users.noreply.github.com> Date: Fri, 21 Jul 2023 01:17:37 +0900 Subject: [PATCH 02/13] fix nil check in handlePDUSessionResourceNotifyMain (#99) --- internal/ngap/handler.go | 199 +++++++++++++++++++-------------------- 1 file changed, 98 insertions(+), 101 deletions(-) diff --git a/internal/ngap/handler.go b/internal/ngap/handler.go index 82db74c5..f0888f3e 100644 --- a/internal/ngap/handler.go +++ b/internal/ngap/handler.go @@ -758,118 +758,115 @@ func handlePDUSessionResourceNotifyMain(ran *context.AmfRan, if pDUSessionResourceNotifyList != nil { ranUe.Log.Infof("Send PDUSessionResourceNotifyTransfer to SMF") - - if pDUSessionResourceNotifyList != nil { - for _, item := range pDUSessionResourceNotifyList.List { - pduSessionID := int32(item.PDUSessionID.Value) - transfer := item.PDUSessionResourceNotifyTransfer - smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) - if !ok { - ranUe.Log.Errorf("SmContext[PDU Session ID:%d] not found", pduSessionID) - continue - } - response, errResponse, problemDetail, err := consumer.SendUpdateSmContextN2Info(amfUe, smContext, - models.N2SmInfoType_PDU_RES_NTY, transfer) - if err != nil { - ranUe.Log.Errorf("SendUpdateSmContextN2Info[PDUSessionResourceNotifyTransfer] Error: %+v", err) - } - - if response != nil { - responseData := response.JsonData - n2Info := response.BinaryDataN1SmMessage - n1Msg := response.BinaryDataN2SmInformation - if n2Info != nil { - switch responseData.N2SmInfoType { - case models.N2SmInfoType_PDU_RES_MOD_REQ: - ranUe.Log.Debugln("AMF Transfer NGAP PDU Resource Modify Req from SMF") - var nasPdu []byte - if n1Msg != nil { - pduSessionId := uint8(pduSessionID) - nasPdu, err = gmm_message.BuildDLNASTransport(amfUe, ran.AnType, nasMessage.PayloadContainerTypeN1SMInfo, - n1Msg, pduSessionId, nil, nil, 0) - if err != nil { - ranUe.Log.Warnf("GMM Message build DL NAS Transport filaed: %v", err) - } + for _, item := range pDUSessionResourceNotifyList.List { + pduSessionID := int32(item.PDUSessionID.Value) + transfer := item.PDUSessionResourceNotifyTransfer + smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) + if !ok { + ranUe.Log.Errorf("SmContext[PDU Session ID:%d] not found", pduSessionID) + continue + } + response, errResponse, problemDetail, err := consumer.SendUpdateSmContextN2Info(amfUe, smContext, + models.N2SmInfoType_PDU_RES_NTY, transfer) + if err != nil { + ranUe.Log.Errorf("SendUpdateSmContextN2Info[PDUSessionResourceNotifyTransfer] Error: %+v", err) + } + + if response != nil { + responseData := response.JsonData + n2Info := response.BinaryDataN1SmMessage + n1Msg := response.BinaryDataN2SmInformation + if n2Info != nil { + switch responseData.N2SmInfoType { + case models.N2SmInfoType_PDU_RES_MOD_REQ: + ranUe.Log.Debugln("AMF Transfer NGAP PDU Resource Modify Req from SMF") + var nasPdu []byte + if n1Msg != nil { + pduSessionId := uint8(pduSessionID) + nasPdu, err = gmm_message.BuildDLNASTransport(amfUe, ran.AnType, nasMessage.PayloadContainerTypeN1SMInfo, + n1Msg, pduSessionId, nil, nil, 0) + if err != nil { + ranUe.Log.Warnf("GMM Message build DL NAS Transport filaed: %v", err) } - list := ngapType.PDUSessionResourceModifyListModReq{} - ngap_message.AppendPDUSessionResourceModifyListModReq(&list, pduSessionID, nasPdu, n2Info) - ngap_message.SendPDUSessionResourceModifyRequest(ranUe, list) } + list := ngapType.PDUSessionResourceModifyListModReq{} + ngap_message.AppendPDUSessionResourceModifyListModReq(&list, pduSessionID, nasPdu, n2Info) + ngap_message.SendPDUSessionResourceModifyRequest(ranUe, list) } - } else if errResponse != nil { - errJSON := errResponse.JsonData - n1Msg := errResponse.BinaryDataN2SmInformation - ranUe.Log.Warnf("PDU Session Modification is rejected by SMF[pduSessionId:%d], Error[%s]\n", - pduSessionID, errJSON.Error.Cause) - if n1Msg != nil { - gmm_message.SendDLNASTransport( - ranUe, nasMessage.PayloadContainerTypeN1SMInfo, errResponse.BinaryDataN1SmMessage, pduSessionID, 0, nil, 0) - } - // TODO: handle n2 info transfer - } else if err != nil { - return - } else { - // TODO: error handling - ranUe.Log.Errorf("Failed to Update smContext[pduSessionID: %d], Error[%v]", pduSessionID, problemDetail) - return } + } else if errResponse != nil { + errJSON := errResponse.JsonData + n1Msg := errResponse.BinaryDataN2SmInformation + ranUe.Log.Warnf("PDU Session Modification is rejected by SMF[pduSessionId:%d], Error[%s]\n", + pduSessionID, errJSON.Error.Cause) + if n1Msg != nil { + gmm_message.SendDLNASTransport( + ranUe, nasMessage.PayloadContainerTypeN1SMInfo, errResponse.BinaryDataN1SmMessage, pduSessionID, 0, nil, 0) + } + // TODO: handle n2 info transfer + } else if err != nil { + return + } else { + // TODO: error handling + ranUe.Log.Errorf("Failed to Update smContext[pduSessionID: %d], Error[%v]", pduSessionID, problemDetail) + return } } + } - if pDUSessionResourceReleasedListNot != nil { - ranUe.Log.Infof("Send PDUSessionResourceNotifyReleasedTransfer to SMF") - for _, item := range pDUSessionResourceReleasedListNot.List { - pduSessionID := int32(item.PDUSessionID.Value) - transfer := item.PDUSessionResourceNotifyReleasedTransfer - smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) - if !ok { - ranUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) - // TODO: Check if doing error handling here - continue - } - response, errResponse, problemDetail, err := consumer.SendUpdateSmContextN2Info(amfUe, smContext, - models.N2SmInfoType_PDU_RES_NTY_REL, transfer) - if err != nil { - ranUe.Log.Errorf("SendUpdateSmContextN2Info[PDUSessionResourceNotifyReleasedTransfer] Error: %+v", err) - } - if response != nil { - responseData := response.JsonData - n2Info := response.BinaryDataN1SmMessage - n1Msg := response.BinaryDataN2SmInformation - if n2Info != nil { - switch responseData.N2SmInfoType { - case models.N2SmInfoType_PDU_RES_REL_CMD: - ranUe.Log.Debugln("AMF Transfer NGAP PDU Session Resource Rel Co from SMF") - var nasPdu []byte - if n1Msg != nil { - nasPdu, err = gmm_message.BuildDLNASTransport( - amfUe, ran.AnType, nasMessage.PayloadContainerTypeN1SMInfo, n1Msg, - uint8(pduSessionID), nil, nil, 0) - if err != nil { - ranUe.Log.Warnf("GMM Message build DL NAS Transport filaed: %v", err) - } + if pDUSessionResourceReleasedListNot != nil { + ranUe.Log.Infof("Send PDUSessionResourceNotifyReleasedTransfer to SMF") + for _, item := range pDUSessionResourceReleasedListNot.List { + pduSessionID := int32(item.PDUSessionID.Value) + transfer := item.PDUSessionResourceNotifyReleasedTransfer + smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) + if !ok { + ranUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) + // TODO: Check if doing error handling here + continue + } + response, errResponse, problemDetail, err := consumer.SendUpdateSmContextN2Info(amfUe, smContext, + models.N2SmInfoType_PDU_RES_NTY_REL, transfer) + if err != nil { + ranUe.Log.Errorf("SendUpdateSmContextN2Info[PDUSessionResourceNotifyReleasedTransfer] Error: %+v", err) + } + if response != nil { + responseData := response.JsonData + n2Info := response.BinaryDataN1SmMessage + n1Msg := response.BinaryDataN2SmInformation + if n2Info != nil { + switch responseData.N2SmInfoType { + case models.N2SmInfoType_PDU_RES_REL_CMD: + ranUe.Log.Debugln("AMF Transfer NGAP PDU Session Resource Rel Co from SMF") + var nasPdu []byte + if n1Msg != nil { + nasPdu, err = gmm_message.BuildDLNASTransport( + amfUe, ran.AnType, nasMessage.PayloadContainerTypeN1SMInfo, n1Msg, + uint8(pduSessionID), nil, nil, 0) + if err != nil { + ranUe.Log.Warnf("GMM Message build DL NAS Transport filaed: %v", err) } - list := ngapType.PDUSessionResourceToReleaseListRelCmd{} - ngap_message.AppendPDUSessionResourceToReleaseListRelCmd(&list, pduSessionID, n2Info) - ngap_message.SendPDUSessionResourceReleaseCommand(ranUe, nasPdu, list) } + list := ngapType.PDUSessionResourceToReleaseListRelCmd{} + ngap_message.AppendPDUSessionResourceToReleaseListRelCmd(&list, pduSessionID, n2Info) + ngap_message.SendPDUSessionResourceReleaseCommand(ranUe, nasPdu, list) } - } else if errResponse != nil { - errJSON := errResponse.JsonData - n1Msg := errResponse.BinaryDataN2SmInformation - ranUe.Log.Warnf("PDU Session Release is rejected by SMF[pduSessionID:%d], Error[%s]\n", - pduSessionID, errJSON.Error.Cause) - if n1Msg != nil { - gmm_message.SendDLNASTransport( - ranUe, nasMessage.PayloadContainerTypeN1SMInfo, errResponse.BinaryDataN1SmMessage, pduSessionID, 0, nil, 0) - } - } else if err != nil { - return - } else { - // TODO: error handling - ranUe.Log.Errorf("Failed to Update smContext[pduSessionID: %d], Error[%v]", pduSessionID, problemDetail) - return } + } else if errResponse != nil { + errJSON := errResponse.JsonData + n1Msg := errResponse.BinaryDataN2SmInformation + ranUe.Log.Warnf("PDU Session Release is rejected by SMF[pduSessionID:%d], Error[%s]\n", + pduSessionID, errJSON.Error.Cause) + if n1Msg != nil { + gmm_message.SendDLNASTransport( + ranUe, nasMessage.PayloadContainerTypeN1SMInfo, errResponse.BinaryDataN1SmMessage, pduSessionID, 0, nil, 0) + } + } else if err != nil { + return + } else { + // TODO: error handling + ranUe.Log.Errorf("Failed to Update smContext[pduSessionID: %d], Error[%v]", pduSessionID, problemDetail) + return } } } From 694b964f90e77091899c40991acd752dbc52615d Mon Sep 17 00:00:00 2001 From: danielh1204 <80144195+danielh1204@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:32:23 +0800 Subject: [PATCH 03/13] changed all sd to lowercase (#101) * change all sd to lowercase * gofumpt-ed --- pkg/factory/factory.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/factory/factory.go b/pkg/factory/factory.go index 52f3c0ae..2a5c59cf 100644 --- a/pkg/factory/factory.go +++ b/pkg/factory/factory.go @@ -7,6 +7,7 @@ package factory import ( "fmt" "io/ioutil" + "strings" "github.com/asaskevich/govalidator" "gopkg.in/yaml.v2" @@ -32,6 +33,15 @@ func InitConfigFactory(f string, cfg *Config) error { } } + // change sd to lowercase + PlmnSupportList := cfg.Configuration.PlmnSupportList + for i := range PlmnSupportList { + SNssaiList := PlmnSupportList[i].SNssaiList + for j := range SNssaiList { + SNssaiList[j].Sd = strings.ToLower(SNssaiList[j].Sd) + } + } + return nil } From c72eaa8e1d0058f5b108e2077ff2ddc59412bd4e Mon Sep 17 00:00:00 2001 From: tim-ywliu <68043973+tim-ywliu@users.noreply.github.com> Date: Mon, 7 Aug 2023 01:14:34 +0800 Subject: [PATCH 04/13] Revert "changed all sd to lowercase (#101)" (#103) This reverts commit 694b964f90e77091899c40991acd752dbc52615d. --- pkg/factory/factory.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkg/factory/factory.go b/pkg/factory/factory.go index 2a5c59cf..52f3c0ae 100644 --- a/pkg/factory/factory.go +++ b/pkg/factory/factory.go @@ -7,7 +7,6 @@ package factory import ( "fmt" "io/ioutil" - "strings" "github.com/asaskevich/govalidator" "gopkg.in/yaml.v2" @@ -33,15 +32,6 @@ func InitConfigFactory(f string, cfg *Config) error { } } - // change sd to lowercase - PlmnSupportList := cfg.Configuration.PlmnSupportList - for i := range PlmnSupportList { - SNssaiList := PlmnSupportList[i].SNssaiList - for j := range SNssaiList { - SNssaiList[j].Sd = strings.ToLower(SNssaiList[j].Sd) - } - } - return nil } From e2114465264caf14237edd2bdd761c43882b4f10 Mon Sep 17 00:00:00 2001 From: danielh1204 <80144195+danielh1204@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:21:26 +0800 Subject: [PATCH 05/13] compare snssai with SnssaiEqualFold (#102) * change all sd to lowercase * gofumpt-ed * compare Snssai with SnssaiEqualfold --- go.mod | 2 +- go.sum | 3 ++- internal/context/amf_ue.go | 8 ++++---- internal/context/context.go | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index e52fed90..3afb9aaa 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 github.com/free5gc/nas v1.1.1 github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f - github.com/free5gc/openapi v1.0.6 + github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 github.com/gin-contrib/cors v1.3.1 github.com/gin-gonic/gin v1.9.0 diff --git a/go.sum b/go.sum index 5fdbd9b1..511e6587 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,9 @@ github.com/free5gc/nas v1.1.1 h1:xUsqOOrb3kH38TQCzwZY7WN6WJkIerjERNjORDtnCbo= github.com/free5gc/nas v1.1.1/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU= github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f h1:wgXjoknZ7JJoZ72J15g/f2/0DgdCpfcTg189lnhUPuY= github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f/go.mod h1:lKA1sLTYM3CGEBhZVxkGGJIkai5+Bvy2yHIMhb7Vx/k= -github.com/free5gc/openapi v1.0.6 h1:ytRjU/YZRI8UhKKyfajXSyGB6s1YDFkJ1weeAGJ8LXw= github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= +github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 h1:BSIvKCYu7646sE8J9R1L8v2R435otUik3wOFN33csfs= +github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 h1:FG8KlJ46Epscj3F9XBAKuDGJD9kSKJdstCL9fttjUjE= github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2/go.mod h1:fgV0hXf5arxAWs8D9LfrrfNByZ1IDCWYlgBzncy5GtE= github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA= diff --git a/internal/context/amf_ue.go b/internal/context/amf_ue.go index 4191b60b..79472041 100644 --- a/internal/context/amf_ue.go +++ b/internal/context/amf_ue.go @@ -6,7 +6,6 @@ import ( "encoding/hex" "errors" "fmt" - "reflect" "regexp" "sync" "time" @@ -18,6 +17,7 @@ import ( "github.com/free5gc/nas/nasMessage" "github.com/free5gc/nas/nasType" "github.com/free5gc/nas/security" + "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" "github.com/free5gc/util/fsm" "github.com/free5gc/util/idgenerator" @@ -371,7 +371,7 @@ func (ue *AmfUe) GetCmInfo() (cmInfos []models.CmInfo) { func (ue *AmfUe) InAllowedNssai(targetSNssai models.Snssai, anType models.AccessType) bool { for _, allowedSnssai := range ue.AllowedNssai[anType] { - if reflect.DeepEqual(*allowedSnssai.AllowedSnssai, targetSNssai) { + if openapi.SnssaiEqualFold(*allowedSnssai.AllowedSnssai, targetSNssai) { return true } } @@ -380,7 +380,7 @@ func (ue *AmfUe) InAllowedNssai(targetSNssai models.Snssai, anType models.Access func (ue *AmfUe) InSubscribedNssai(targetSNssai models.Snssai) bool { for _, sNssai := range ue.SubscribedNssai { - if reflect.DeepEqual(*sNssai.SubscribedSnssai, targetSNssai) { + if openapi.SnssaiEqualFold(*sNssai.SubscribedSnssai, targetSNssai) { return true } } @@ -389,7 +389,7 @@ func (ue *AmfUe) InSubscribedNssai(targetSNssai models.Snssai) bool { func (ue *AmfUe) GetNsiInformationFromSnssai(anType models.AccessType, snssai models.Snssai) *models.NsiInformation { for _, allowedSnssai := range ue.AllowedNssai[anType] { - if reflect.DeepEqual(*allowedSnssai.AllowedSnssai, snssai) { + if openapi.SnssaiEqualFold(*allowedSnssai.AllowedSnssai, snssai) { // TODO: select NsiInformation based on operator policy if len(allowedSnssai.NsiInformationList) != 0 { return &allowedSnssai.NsiInformationList[0] diff --git a/internal/context/context.go b/internal/context/context.go index 1e251cc9..764e6b60 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -15,6 +15,7 @@ import ( "github.com/free5gc/amf/internal/logger" "github.com/free5gc/amf/pkg/factory" "github.com/free5gc/nas/security" + "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" "github.com/free5gc/util/idgenerator" ) @@ -413,7 +414,7 @@ func (context *AMFContext) InSupportDnnList(targetDnn string) bool { func (context *AMFContext) InPlmnSupportList(snssai models.Snssai) bool { for _, plmnSupportItem := range context.PlmnSupportList { for _, supportSnssai := range plmnSupportItem.SNssaiList { - if reflect.DeepEqual(supportSnssai, snssai) { + if openapi.SnssaiEqualFold(supportSnssai, snssai) { return true } } From 27dda179a9695a291a3ac2aa31ee814692e08839 Mon Sep 17 00:00:00 2001 From: Sheng <51371214+YouShengLiu@users.noreply.github.com> Date: Wed, 9 Aug 2023 00:07:26 +0800 Subject: [PATCH 06/13] Add IE, universal time, in the configuration update command message: (#98) * Add IE, universal time, in the configuration update command message: * Add TimeZone field in the AMFContext. * Fix bug: the format of time zone is wrong * Modify BuildConfigurationUpdateCommand * Update go module --- go.mod | 2 +- go.sum | 4 ++-- internal/context/amf_ue.go | 2 +- internal/context/context.go | 25 ++++++++++++++++++++++--- internal/gmm/message/build.go | 17 +++++++++++------ 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 3afb9aaa..32e69cd0 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/davecgh/go-spew v1.1.1 github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 - github.com/free5gc/nas v1.1.1 + github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 diff --git a/go.sum b/go.sum index 511e6587..c3fb6dc5 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 h1:IV9PXKo6MH62e7nngSqr+cwjuoffkouPMmyX3jHC9Ds= github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582/go.mod h1:ybHxhYnRqQ9wD4yB9r/3MZdbCYCjtqUyfLpSnJpwWd4= -github.com/free5gc/nas v1.1.1 h1:xUsqOOrb3kH38TQCzwZY7WN6WJkIerjERNjORDtnCbo= -github.com/free5gc/nas v1.1.1/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU= +github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e h1:M2vWqCRQKa8hgJzbJkPrswFEe8lJoRTD/CmMwbJoW+Q= +github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU= github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f h1:wgXjoknZ7JJoZ72J15g/f2/0DgdCpfcTg189lnhUPuY= github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f/go.mod h1:lKA1sLTYM3CGEBhZVxkGGJIkai5+Bvy2yHIMhb7Vx/k= github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= diff --git a/internal/context/amf_ue.go b/internal/context/amf_ue.go index 79472041..132e1ba2 100644 --- a/internal/context/amf_ue.go +++ b/internal/context/amf_ue.go @@ -90,7 +90,7 @@ type AmfUe struct { Tai models.Tai LocationChanged bool LastVisitedRegisteredTai models.Tai - TimeZone string + TimeZone string // "[+-]HH:MM[+][1-2]", Refer to TS 29.571 - 5.2.2 Simple Data Types /* context about udm */ UdmId string NudmUECMUri string diff --git a/internal/context/context.go b/internal/context/context.go index 764e6b60..c5fcf703 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -69,9 +69,10 @@ type AMFContext struct { NetworkName factory.NetworkName NgapIpList []string // NGAP Server IP NgapPort int - T3502Value int // unit is second - T3512Value int // unit is second - Non3gppDeregTimerValue int // unit is second + T3502Value int // unit is second + T3512Value int // unit is second + Non3gppDeregTimerValue int // unit is second + TimeZone string // "[+-]HH:MM[+][1-2]", Refer to TS 29.571 - 5.2.2 Simple Data Types // read-only fields T3513Cfg factory.TimerValue T3522Cfg factory.TimerValue @@ -129,6 +130,7 @@ func InitAmfContext(context *AMFContext) { context.SecurityAlgorithm.CipheringOrder = getEncAlgOrder(security.CipheringOrder) } context.NetworkName = configuration.NetworkName + context.TimeZone = getTimeZone(time.Now()) context.T3502Value = configuration.T3502Value context.T3512Value = configuration.T3512Value context.Non3gppDeregTimerValue = configuration.Non3gppDeregTimerValue @@ -141,6 +143,23 @@ func InitAmfContext(context *AMFContext) { context.Locality = configuration.Locality } +func getTimeZone(now time.Time) string { + timezone := "" + _, offset := now.Zone() + if offset < 0 { + timezone += "-" + offset = 0 - offset + } else { + timezone += "+" + } + timezone += fmt.Sprintf("%02d:%02d", offset/3600, (offset%3600)/60) + if now.IsDST() { + timezone += "+1" + } + + return timezone +} + func getIntAlgOrder(integrityOrder []string) (intOrder []uint8) { for _, intAlg := range integrityOrder { switch intAlg { diff --git a/internal/gmm/message/build.go b/internal/gmm/message/build.go index 6fef850c..3f252115 100644 --- a/internal/gmm/message/build.go +++ b/internal/gmm/message/build.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/hex" "fmt" + "time" "github.com/mitchellh/mapstructure" @@ -765,7 +766,6 @@ func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType } } - // TODO: UniversalTimeAndLocalTimeZone if anType == models.AccessType__3_GPP_ACCESS && ue.AmPolicyAssociation != nil && ue.AmPolicyAssociation.ServAreaRes != nil { configurationUpdateCommand.ServiceAreaList = nasType. @@ -789,16 +789,21 @@ func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType configurationUpdateCommand.ShortNameForNetwork.SetIei(nasMessage.ConfigurationUpdateCommandShortNameForNetworkType) } - if ue.TimeZone != "" { - localTimeZone := nasConvert.LocalTimeZoneToNas(ue.TimeZone) + now := time.Now() + universalTimeAndLocalTimeZone := nasConvert.EncodeUniversalTimeAndLocalTimeZoneToNas(now) + universalTimeAndLocalTimeZone.SetIei(nasMessage.ConfigurationUpdateCommandUniversalTimeAndLocalTimeZoneType) + configurationUpdateCommand.UniversalTimeAndLocalTimeZone = &universalTimeAndLocalTimeZone + + if ue.TimeZone != amfSelf.TimeZone { + ue.TimeZone = amfSelf.TimeZone + + localTimeZone := nasConvert.EncodeLocalTimeZoneToNas(ue.TimeZone) localTimeZone.SetIei(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType) configurationUpdateCommand.LocalTimeZone = nasType. NewLocalTimeZone(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType) configurationUpdateCommand.LocalTimeZone = &localTimeZone - } - if ue.TimeZone != "" { - daylightSavingTime := nasConvert.DaylightSavingTimeToNas(ue.TimeZone) + daylightSavingTime := nasConvert.EncodeDaylightSavingTimeToNas(ue.TimeZone) daylightSavingTime.SetIei(nasMessage.ConfigurationUpdateCommandNetworkDaylightSavingTimeType) configurationUpdateCommand.NetworkDaylightSavingTime = nasType. NewNetworkDaylightSavingTime(nasMessage.ConfigurationUpdateCommandNetworkDaylightSavingTimeType) From 1fbd166320426fe4dab717609266eaeef86e2c20 Mon Sep 17 00:00:00 2001 From: ShouheiNishi <96609867+ShouheiNishi@users.noreply.github.com> Date: Wed, 9 Aug 2023 01:08:42 +0900 Subject: [PATCH 07/13] All build functions use nas_security.Encode() (#100) --- internal/gmm/message/build.go | 90 ++++++++++++++++++++++++----------- internal/gmm/message/send.go | 49 ++++++++++++++++--- 2 files changed, 105 insertions(+), 34 deletions(-) diff --git a/internal/gmm/message/build.go b/internal/gmm/message/build.go index 3f252115..a7450f6e 100644 --- a/internal/gmm/message/build.go +++ b/internal/gmm/message/build.go @@ -111,7 +111,7 @@ func BuildIdentityRequest(ue *context.AmfUe, accessType models.AccessType, typeO return nas_security.Encode(ue, m, accessType) } -func BuildAuthenticationRequest(ue *context.AmfUe) ([]byte, error) { +func BuildAuthenticationRequest(ue *context.AmfUe, accessType models.AccessType) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeAuthenticationRequest) @@ -166,7 +166,11 @@ func BuildAuthenticationRequest(ue *context.AmfUe) ([]byte, error) { m.GmmMessage.AuthenticationRequest = authenticationRequest - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } func BuildServiceAccept(ue *context.AmfUe, accessType models.AccessType, pDUSessionStatus *[16]bool, @@ -210,7 +214,7 @@ func BuildServiceAccept(ue *context.AmfUe, accessType models.AccessType, pDUSess return nas_security.Encode(ue, m, accessType) } -func BuildAuthenticationReject(ue *context.AmfUe, eapMsg string) ([]byte, error) { +func BuildAuthenticationReject(ue *context.AmfUe, accessType models.AccessType, eapMsg string) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeAuthenticationReject) @@ -233,10 +237,15 @@ func BuildAuthenticationReject(ue *context.AmfUe, eapMsg string) ([]byte, error) m.GmmMessage.AuthenticationReject = authenticationReject - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } -func BuildAuthenticationResult(ue *context.AmfUe, eapSuccess bool, eapMsg string) ([]byte, error) { +func BuildAuthenticationResult(ue *context.AmfUe, accessType models.AccessType, eapSuccess bool, eapMsg string, +) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeAuthenticationResult) @@ -262,11 +271,16 @@ func BuildAuthenticationResult(ue *context.AmfUe, eapSuccess bool, eapMsg string m.GmmMessage.AuthenticationResult = authenticationResult - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } // T3346 Timer and EAP are not Supported -func BuildServiceReject(pDUSessionStatus *[16]bool, cause uint8) ([]byte, error) { +func BuildServiceReject(ue *context.AmfUe, accessType models.AccessType, pDUSessionStatus *[16]bool, cause uint8, +) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeServiceReject) @@ -285,11 +299,16 @@ func BuildServiceReject(pDUSessionStatus *[16]bool, cause uint8) ([]byte, error) m.GmmMessage.ServiceReject = serviceReject - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } // T3346 timer are not supported -func BuildRegistrationReject(ue *context.AmfUe, cause5GMM uint8, eapMessage string) ([]byte, error) { +func BuildRegistrationReject(ue *context.AmfUe, accessType models.AccessType, cause5GMM uint8, eapMessage string, +) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeRegistrationReject) @@ -324,7 +343,11 @@ func BuildRegistrationReject(ue *context.AmfUe, cause5GMM uint8, eapMessage stri m.GmmMessage.RegistrationReject = registrationReject - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } // TS 24.501 8.2.25 @@ -434,23 +457,24 @@ func BuildDeregistrationRequest(ue *context.RanUe, accessType uint8, reRegistrat } m.GmmMessage.DeregistrationRequestUETerminatedDeregistration = deregistrationRequest - if ue != nil && ue.AmfUe != nil { - m.SecurityHeader = nas.SecurityHeader{ - ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, - SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, - } - var anType models.AccessType - if accessType == 0x01 { - anType = models.AccessType__3_GPP_ACCESS - } else if accessType == 0x02 { - anType = models.AccessType_NON_3_GPP_ACCESS - } + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + var anType models.AccessType + if accessType == 0x01 { + anType = models.AccessType__3_GPP_ACCESS + } else if accessType == 0x02 { + anType = models.AccessType_NON_3_GPP_ACCESS + } + if ue != nil { return nas_security.Encode(ue.AmfUe, m, anType) + } else { + return nas_security.Encode(nil, m, anType) } - return m.PlainNasEncode() } -func BuildDeregistrationAccept() ([]byte, error) { +func BuildDeregistrationAccept(ue *context.AmfUe, accessType models.AccessType) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeDeregistrationAcceptUEOriginatingDeregistration) @@ -463,7 +487,11 @@ func BuildDeregistrationAccept() ([]byte, error) { m.GmmMessage.DeregistrationAcceptUEOriginatingDeregistration = deregistrationAccept - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } func BuildRegistrationAccept( @@ -678,7 +706,7 @@ func includeConfiguredNssaiCheck(ue *context.AmfUe) bool { return false } -func BuildStatus5GMM(cause uint8) ([]byte, error) { +func BuildStatus5GMM(ue *context.AmfUe, accessType models.AccessType, cause uint8) ([]byte, error) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeStatus5GMM) @@ -691,7 +719,11 @@ func BuildStatus5GMM(cause uint8) ([]byte, error) { m.GmmMessage.Status5GMM = status5GMM - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, accessType) } func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType, @@ -824,5 +856,9 @@ func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType m.GmmMessage.ConfigurationUpdateCommand = configurationUpdateCommand - return m.PlainNasEncode() + m.SecurityHeader = nas.SecurityHeader{ + ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, + SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, + } + return nas_security.Encode(ue, m, anType) } diff --git a/internal/gmm/message/send.go b/internal/gmm/message/send.go index a42e44d1..4df330ad 100644 --- a/internal/gmm/message/send.go +++ b/internal/gmm/message/send.go @@ -114,6 +114,11 @@ func SendAuthenticationRequest(ue *context.RanUe) { return } amfUe := ue.AmfUe + if ue.Ran == nil { + logger.GmmLog.Error("SendAuthenticationRequest: Ran is nil") + return + } + ran := ue.Ran amfUe.GmmLog.Infof("Send Authentication Request") if amfUe.AuthenticationCtx == nil { @@ -121,7 +126,7 @@ func SendAuthenticationRequest(ue *context.RanUe) { return } - nasMsg, err := BuildAuthenticationRequest(amfUe) + nasMsg, err := BuildAuthenticationRequest(amfUe, ran.AnType) if err != nil { amfUe.GmmLog.Error(err.Error()) return @@ -206,9 +211,14 @@ func SendAuthenticationReject(ue *context.RanUe, eapMsg string) { return } amfUe := ue.AmfUe + if ue.Ran == nil { + logger.GmmLog.Error("SendAuthenticationReject: Ran is nil") + return + } + ran := ue.Ran amfUe.GmmLog.Info("Send Authentication Reject") - nasMsg, err := BuildAuthenticationReject(amfUe, eapMsg) + nasMsg, err := BuildAuthenticationReject(amfUe, ran.AnType, eapMsg) if err != nil { amfUe.GmmLog.Error(err.Error()) return @@ -226,9 +236,14 @@ func SendAuthenticationResult(ue *context.RanUe, eapSuccess bool, eapMsg string) return } amfUe := ue.AmfUe + if ue.Ran == nil { + logger.GmmLog.Error("SendAuthenticationResult: Ran is nil") + return + } + ran := ue.Ran amfUe.GmmLog.Info("Send Authentication Result") - nasMsg, err := BuildAuthenticationResult(amfUe, eapSuccess, eapMsg) + nasMsg, err := BuildAuthenticationResult(amfUe, ran.AnType, eapSuccess, eapMsg) if err != nil { amfUe.GmmLog.Error(err.Error()) return @@ -241,13 +256,18 @@ func SendServiceReject(ue *context.RanUe, pDUSessionStatus *[16]bool, cause uint logger.GmmLog.Error("SendServiceReject: RanUe is nil") return } + if ue.Ran == nil { + logger.GmmLog.Error("SendServiceReject: Ran is nil") + return + } + ran := ue.Ran if ue.AmfUe == nil { ue.Log.Info("Send Service Reject") } else { ue.AmfUe.GmmLog.Info("Send Service Reject") } - nasMsg, err := BuildServiceReject(pDUSessionStatus, cause) + nasMsg, err := BuildServiceReject(ue.AmfUe, ran.AnType, pDUSessionStatus, cause) if err != nil { if ue.AmfUe == nil { ue.Log.Error(err.Error()) @@ -266,13 +286,18 @@ func SendRegistrationReject(ue *context.RanUe, cause5GMM uint8, eapMessage strin logger.GmmLog.Error("SendRegistrationReject: RanUe is nil") return } + if ue.Ran == nil { + logger.GmmLog.Error("SendRegistrationReject: Ran is nil") + return + } + ran := ue.Ran if ue.AmfUe == nil { ue.Log.Info("Send Registration Reject") } else { ue.AmfUe.GmmLog.Info("Send Registration Reject") } - nasMsg, err := BuildRegistrationReject(ue.AmfUe, cause5GMM, eapMessage) + nasMsg, err := BuildRegistrationReject(ue.AmfUe, ran.AnType, cause5GMM, eapMessage) if err != nil { if ue.AmfUe == nil { ue.Log.Error(err.Error()) @@ -376,9 +401,14 @@ func SendDeregistrationAccept(ue *context.RanUe) { return } amfUe := ue.AmfUe + if ue.Ran == nil { + logger.GmmLog.Error("SendDeregistrationAccept: Ran is nil") + return + } + ran := ue.Ran amfUe.GmmLog.Info("Send Deregistration Accept") - nasMsg, err := BuildDeregistrationAccept() + nasMsg, err := BuildDeregistrationAccept(ue.AmfUe, ran.AnType) if err != nil { amfUe.GmmLog.Error(err.Error()) return @@ -449,9 +479,14 @@ func SendStatus5GMM(ue *context.RanUe, cause uint8) { return } amfUe := ue.AmfUe + if ue.Ran == nil { + logger.GmmLog.Error("SendStatus5GMM: Ran is nil") + return + } + ran := ue.Ran amfUe.GmmLog.Info("Send Status 5GMM") - nasMsg, err := BuildStatus5GMM(cause) + nasMsg, err := BuildStatus5GMM(ue.AmfUe, ran.AnType, cause) if err != nil { amfUe.GmmLog.Error(err.Error()) return From 641292a725e8e071871ce2296785a18846cbfa0b Mon Sep 17 00:00:00 2001 From: BrianChen <46628572+brianchennn@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:15:08 +0800 Subject: [PATCH 08/13] fix ueContextTransferResponse nil pointer dereference (#104) --- internal/sbi/producer/ue_context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/sbi/producer/ue_context.go b/internal/sbi/producer/ue_context.go index bf648a85..09fc9da3 100644 --- a/internal/sbi/producer/ue_context.go +++ b/internal/sbi/producer/ue_context.go @@ -242,7 +242,7 @@ func UEContextTransferProcedure(ueContextID string, ueContextTransferRequest mod ue.Lock.Lock() defer ue.Lock.Unlock() - var ueContextTransferResponse *models.UeContextTransferResponse + ueContextTransferResponse := new(models.UeContextTransferResponse) ueContextTransferResponse.JsonData = new(models.UeContextTransferRspData) ueContextTransferRspData := ueContextTransferResponse.JsonData From 80b4f277cce150e69f519e866deaee80f1454da5 Mon Sep 17 00:00:00 2001 From: Tim Liu Date: Wed, 23 Aug 2023 15:36:09 +0000 Subject: [PATCH 09/13] update util pkg --- go.mod | 2 +- go.sum | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 32e69cd0..78290431 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 - github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 + github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef github.com/gin-contrib/cors v1.3.1 github.com/gin-gonic/gin v1.9.0 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index c3fb6dc5..13c2b893 100644 --- a/go.sum +++ b/go.sum @@ -75,31 +75,26 @@ github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f/go.mod h1:lKA1sLTYM github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 h1:BSIvKCYu7646sE8J9R1L8v2R435otUik3wOFN33csfs= github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= -github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2 h1:FG8KlJ46Epscj3F9XBAKuDGJD9kSKJdstCL9fttjUjE= -github.com/free5gc/util v1.0.5-0.20230306071612-a52909216bd2/go.mod h1:fgV0hXf5arxAWs8D9LfrrfNByZ1IDCWYlgBzncy5GtE= +github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef h1:ne0EMnst7wbLoaY2Uvn/2Kvp/KkXKMQJcaIJQKFe+a4= +github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef/go.mod h1:l2Jrml4vojDomW5jdDJhIS60KdbrE9uPYhyAq/7OnF4= github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA= github.com/gin-contrib/cors v1.3.1/go.mod h1:jjEJ4268OPZUcU7k9Pm653S7lXUGcqMADzFA61xsmDk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= -github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU= github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -170,7 +165,6 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -190,11 +184,9 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -279,7 +271,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -341,7 +332,6 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= @@ -376,7 +366,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -401,7 +390,6 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -412,7 +400,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= @@ -554,7 +541,6 @@ gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWd 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.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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= From 7de97a69e972c3d3626b6bb0294a7942dfb4305b Mon Sep 17 00:00:00 2001 From: Sheng <51371214+YouShengLiu@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:37:34 +0800 Subject: [PATCH 10/13] Bugfix/sync issue (#108) * Add IE, universal time, in the configuration update command message: * Add TimeZone field in the AMFContext. * Fix bug: the format of time zone is wrong * Modify BuildConfigurationUpdateCommand * Update go module * Fix bug: There is a synchronization issue between step 5 and step 11 during the procedure of UE Requested PDU Session Establishment. --- internal/gmm/handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index e2131286..2191ee0a 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -265,6 +265,9 @@ func CreatePDUSession(ulNasTransport *nasMessage.ULNASTransport, gmm_message.SendDLNASTransport(ue.RanUe[anType], nasMessage.PayloadContainerTypeN1SMInfo, smMessage, pduSessionID, cause, nil, 0) } else { + ue.Lock.Lock() + defer ue.Lock.Unlock() + _, smContextRef, errResponse, problemDetail, err := consumer.SendCreateSmContextRequest( ue, newSmContext, nil, smMessage) if err != nil { From e4d31e8a09179414a31a18d3851f74c818f8f902 Mon Sep 17 00:00:00 2001 From: Sheng <51371214+YouShengLiu@users.noreply.github.com> Date: Tue, 12 Sep 2023 15:16:08 +0800 Subject: [PATCH 11/13] Feature/cfg update cmd (#105) * Add IE, universal time, in the configuration update command message: * Add TimeZone field in the AMFContext. * Fix bug: the format of time zone is wrong * Modify BuildConfigurationUpdateCommand * Update go module * Modify the BuildConfigurationUpdateCommand and SendConfigurationUpdateCommand functions: * Enhance the generality of the BuildConfigurationUpdateCommand function. * Decouple the BuildConfigurationUpdateCommand from the SendConfigurationUpdateCommand, enabling finer customization of the Configuration Update Command message. * Add T3555 timer for retransmission of CONFIGURATION UPDATE COMMAND message. * Leave two TODOs in AmPolicyControlUpdateNotifyUpdateProcedure function. * Modify coding style * Stop T3555 timer in HandleConfigurationUpdateComplete function * Modify BuildConfigurationUpdateCommand * Reduce the number of parameters. * AmPolicyControlUpdateNotifyUpdateProcedure keeps its original functionality with the configurationUpdateCommandFlags. * Modify BuildConfigurationUpdateCommand * Show some warning message while the required argument is nothing. * Check the Configuration Update Command message if is valid. * Modify SendConfigurationUpdateCommand * Add ConfigurationUpdateCommandFlags parameter to control how to build the Configuration Update Command message. * Determine whether to start the T3555 timer or not in the SendConfigurationUpdateCommand. * Modify SendConfigurationUpdateCommand * Add the missing return. * Modify BuildConfigurationUpdateCommand and SendConfigurationUpdateCommand * Fix bug: the original getTimeZone function was wrong * Aggregate the same function into nasConvert.GetTimeZone * Update go module * Modify BuildConfigurationUpdateCommand * Remove the parameter NetworkSlicingIndication * Modify AmfUe structure * Replace ConfigurationUpdateMessage by ConfigurationUpdateCommandFlags * Modify HandleServiceRequest --- go.mod | 2 +- go.sum | 4 +- internal/context/amf_ue.go | 79 +++++++--- internal/context/context.go | 22 +-- internal/gmm/common/timer.go | 4 + internal/gmm/handler.go | 17 ++- internal/gmm/message/build.go | 243 +++++++++++++++++++----------- internal/gmm/message/send.go | 27 +++- internal/sbi/producer/callback.go | 24 ++- pkg/factory/config.go | 5 + 10 files changed, 280 insertions(+), 147 deletions(-) diff --git a/go.mod b/go.mod index 78290431..374e7a6f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/davecgh/go-spew v1.1.1 github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 - github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e + github.com/free5gc/nas v1.1.2-0.20230828074825-175b09665828 github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef diff --git a/go.sum b/go.sum index 13c2b893..4de6abbf 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 h1:IV9PXKo6MH62e7nngSqr+cwjuoffkouPMmyX3jHC9Ds= github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582/go.mod h1:ybHxhYnRqQ9wD4yB9r/3MZdbCYCjtqUyfLpSnJpwWd4= -github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e h1:M2vWqCRQKa8hgJzbJkPrswFEe8lJoRTD/CmMwbJoW+Q= -github.com/free5gc/nas v1.1.2-0.20230731044306-324a5cc4c35e/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU= +github.com/free5gc/nas v1.1.2-0.20230828074825-175b09665828 h1:/gIlzF8hacxWa6hsx+HQlw9F8yEorTvZvS1VR5Iwpjc= +github.com/free5gc/nas v1.1.2-0.20230828074825-175b09665828/go.mod h1:fjWwpyp7/wOyL72HTkjvIe9YTCfGyZosjITsI5sXyuU= github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f h1:wgXjoknZ7JJoZ72J15g/f2/0DgdCpfcTg189lnhUPuY= github.com/free5gc/ngap v1.0.7-0.20230614061954-9c128114ab1f/go.mod h1:lKA1sLTYM3CGEBhZVxkGGJIkai5+Bvy2yHIMhb7Vx/k= github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= diff --git a/internal/context/amf_ue.go b/internal/context/amf_ue.go index 132e1ba2..a387ffae 100644 --- a/internal/context/amf_ue.go +++ b/internal/context/amf_ue.go @@ -71,20 +71,19 @@ type AmfUe struct { /* Used for AMF relocation */ TargetAmfProfile *models.NfProfile TargetAmfUri string - /* Ue Identity*/ - PlmnId models.PlmnId - Suci string - Supi string - UnauthenticatedSupi bool - Gpsi string - Pei string - Tmsi int32 // 5G-Tmsi - Guti string - GroupID string - EBI int32 - /* Ue Identity*/ + /* Ue Identity */ + PlmnId models.PlmnId + Suci string + Supi string + UnauthenticatedSupi bool + Gpsi string + Pei string + Tmsi int32 // 5G-Tmsi + Guti string + GroupID string + EBI int32 EventSubscriptionsInfo map[string]*AmfUeEventSubscription - /* User Location*/ + /* User Location */ RatType models.RatType Location models.UserLocation Tai models.Tai @@ -122,8 +121,7 @@ type AmfUe struct { AmPolicyUri string AmPolicyAssociation *models.PolicyAssociation RequestTriggerLocationChange bool // true if AmPolicyAssociation.Trigger contains RequestTrigger_LOC_CH - ConfigurationUpdateMessage []byte - /* UeContextForHandover*/ + /* UeContextForHandover */ HandoverNotifyUri string /* N1N2Message */ N1N2MessageIDGenerator *idgenerator.IDGenerator @@ -133,13 +131,14 @@ type AmfUe struct { N1N2MessageSubscription sync.Map /* Pdu Sesseion context */ SmContextList sync.Map // map[int32]*SmContext, pdu session id as key - /* Related Context*/ + /* Related Context */ RanUe map[models.AccessType]*RanUe /* other */ - onGoing map[models.AccessType]*OnGoing - UeRadioCapability string // OCTET string - Capability5GMM nasType.Capability5GMM - ConfigurationUpdateIndication nasType.ConfigurationUpdateIndication + onGoing map[models.AccessType]*OnGoing + UeRadioCapability string // OCTET string + Capability5GMM nasType.Capability5GMM + ConfigurationUpdateIndication nasType.ConfigurationUpdateIndication + ConfigurationUpdateCommandFlags *ConfigurationUpdateCommandFlags /* context related to Paging */ UeRadioCapabilityForPaging *UERadioCapabilityForPaging InfoOnRecommendedCellsAndRanNodesForPaging *InfoOnRecommendedCellsAndRanNodesForPaging @@ -183,6 +182,8 @@ type AmfUe struct { T3522 *Timer /* T3570 (for identity request) */ T3570 *Timer + /* T3555 (for configuration update command) */ + T3555 *Timer /* Ue Context Release Cause */ ReleaseCause map[models.AccessType]*CauseAll /* T3502 (Assigned by AMF, and used by UE to initialize registration procedure) */ @@ -245,6 +246,22 @@ type NGRANCGI struct { EUTRACGI *models.Ecgi } +// TS 24.501 8.2.19 +type ConfigurationUpdateCommandFlags struct { + NeedGUTI bool + NeedNITZ bool + NeedTaiList bool + NeedRejectNSSAI bool + NeedAllowedNSSAI bool + NeedSmsIndication bool + NeedMicoIndication bool + NeedLadnInformation bool + NeedServiceAreaList bool + NeedConfiguredNSSAI bool + NeedNetworkSlicingIndication bool + NeedOperatordefinedAccessCategoryDefinitions bool +} + func (ue *AmfUe) init() { ue.servingAMF = GetSelf() ue.State = make(map[models.AccessType]*fsm.State) @@ -290,6 +307,8 @@ func (ue *AmfUe) Remove() { ue.StopT3560() ue.StopT3550() ue.StopT3522() + ue.StopT3570() + ue.StopT3555() for _, ranUe := range ue.RanUe { if err := ranUe.Remove(); err != nil { @@ -889,3 +908,23 @@ func (ue *AmfUe) StopT3522() { ue.T3522.Stop() ue.T3522 = nil // clear the timer } + +func (ue *AmfUe) StopT3570() { + if ue.T3570 == nil { + return + } + + ue.GmmLog.Infof("Stop T3570 timer") + ue.T3570.Stop() + ue.T3570 = nil // clear the timer +} + +func (ue *AmfUe) StopT3555() { + if ue.T3555 == nil { + return + } + + ue.GmmLog.Infof("Stop T3555 timer") + ue.T3555.Stop() + ue.T3555 = nil // clear the timer +} diff --git a/internal/context/context.go b/internal/context/context.go index c5fcf703..bc37af80 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -14,6 +14,7 @@ import ( "github.com/free5gc/amf/internal/logger" "github.com/free5gc/amf/pkg/factory" + "github.com/free5gc/nas/nasConvert" "github.com/free5gc/nas/security" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" @@ -80,6 +81,7 @@ type AMFContext struct { T3560Cfg factory.TimerValue T3565Cfg factory.TimerValue T3570Cfg factory.TimerValue + T3555Cfg factory.TimerValue Locality string } @@ -130,7 +132,7 @@ func InitAmfContext(context *AMFContext) { context.SecurityAlgorithm.CipheringOrder = getEncAlgOrder(security.CipheringOrder) } context.NetworkName = configuration.NetworkName - context.TimeZone = getTimeZone(time.Now()) + context.TimeZone = nasConvert.GetTimeZone(time.Now()) context.T3502Value = configuration.T3502Value context.T3512Value = configuration.T3512Value context.Non3gppDeregTimerValue = configuration.Non3gppDeregTimerValue @@ -140,26 +142,10 @@ func InitAmfContext(context *AMFContext) { context.T3560Cfg = configuration.T3560 context.T3565Cfg = configuration.T3565 context.T3570Cfg = configuration.T3570 + context.T3555Cfg = configuration.T3555 context.Locality = configuration.Locality } -func getTimeZone(now time.Time) string { - timezone := "" - _, offset := now.Zone() - if offset < 0 { - timezone += "-" - offset = 0 - offset - } else { - timezone += "+" - } - timezone += fmt.Sprintf("%02d:%02d", offset/3600, (offset%3600)/60) - if now.IsDST() { - timezone += "+1" - } - - return timezone -} - func getIntAlgOrder(integrityOrder []string) (intOrder []uint8) { for _, intAlg := range integrityOrder { switch intAlg { diff --git a/internal/gmm/common/timer.go b/internal/gmm/common/timer.go index 63200b74..c49ef64f 100644 --- a/internal/gmm/common/timer.go +++ b/internal/gmm/common/timer.go @@ -35,4 +35,8 @@ func StopAll5GSMMTimers(ue *context.AmfUe) { ue.T3570.Stop() ue.T3570 = nil // clear the timer } + if ue.T3555 != nil { + ue.T3555.Stop() + ue.T3555 = nil // clear the timer + } } diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index 2191ee0a..9cbf2489 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -1582,7 +1582,8 @@ func HandleConfigurationUpdateComplete(ue *context.AmfUe, return fmt.Errorf("NAS message integrity check failed") } - // TODO: Stop timer T3555 in TS 24.501 Figure 5.4.4.1.1 in handler + // Stop timer T3555 in TS 24.501 Figure 5.4.4.1.1 in handler + ue.StopT3555() // TODO: Send acknowledgment by Nudm_SMD_Info_Service to UDM in handler // import "github.com/free5gc/openapi/Nudm_SubscriberDataManagement" client.Info @@ -1849,16 +1850,14 @@ func HandleServiceRequest(ue *context.AmfUe, anType models.AccessType, } // downlink signaling - if ue.ConfigurationUpdateMessage != nil { + if ue.ConfigurationUpdateCommandFlags != nil { err := gmm_message.SendServiceAccept(ue, anType, cxtList, pduStatusResult, reactivationResult, errPduSessionId, errCause) if err != nil { return err } - mobilityRestrictionList := ngap_message.BuildIEMobilityRestrictionList(ue) - ngap_message.SendDownlinkNasTransport(ue.RanUe[models.AccessType__3_GPP_ACCESS], - ue.ConfigurationUpdateMessage, &mobilityRestrictionList) - ue.ConfigurationUpdateMessage = nil + gmm_message.SendConfigurationUpdateCommand(ue, anType, ue.ConfigurationUpdateCommandFlags) + ue.ConfigurationUpdateCommandFlags = nil } case nasMessage.ServiceTypeData: if anType == models.AccessType__3_GPP_ACCESS { @@ -2162,6 +2161,12 @@ func HandleRegistrationComplete(ue *context.AmfUe, accessType models.AccessType, }) } + // Send NITZ information to UE + configurationUpdateCommandFlags := &context.ConfigurationUpdateCommandFlags{ + NeedNITZ: true, + } + gmm_message.SendConfigurationUpdateCommand(ue, accessType, configurationUpdateCommandFlags) + // if registrationComplete.SORTransparentContainer != nil { // TODO: if at regsitration procedure 14b, udm provide amf Steering of Roaming info & request an ack, // AMF provides the UE's ack with Nudm_SDM_Info (SOR not supportted in this stage) diff --git a/internal/gmm/message/build.go b/internal/gmm/message/build.go index a7450f6e..f9f93a8e 100644 --- a/internal/gmm/message/build.go +++ b/internal/gmm/message/build.go @@ -726,9 +726,11 @@ func BuildStatus5GMM(ue *context.AmfUe, accessType models.AccessType, cause uint return nas_security.Encode(ue, m, accessType) } +// Fllowed by TS 24.501 - 5.4.4 Generic UE configuration update procedure - 5.4.4.1 General func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType, - networkSlicingIndication *nasType.NetworkSlicingIndication, -) ([]byte, error) { + flags *context.ConfigurationUpdateCommandFlags, +) ([]byte, error, bool) { + needTimer := false m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeConfigurationUpdateCommand) @@ -739,119 +741,183 @@ func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType configurationUpdateCommand.SpareHalfOctetAndSecurityHeaderType.SetSpareHalfOctet(0) configurationUpdateCommand.SetMessageType(nas.MsgTypeConfigurationUpdateCommand) - if ue.ConfigurationUpdateIndication.Octet != 0 { - configurationUpdateCommand.ConfigurationUpdateIndication = nasType. - NewConfigurationUpdateIndication(nasMessage.ConfigurationUpdateCommandConfigurationUpdateIndicationType) - configurationUpdateCommand.ConfigurationUpdateIndication = &ue.ConfigurationUpdateIndication - } - - if networkSlicingIndication != nil { + if flags.NeedNetworkSlicingIndication { configurationUpdateCommand.NetworkSlicingIndication = nasType. NewNetworkSlicingIndication(nasMessage.ConfigurationUpdateCommandNetworkSlicingIndicationType) - configurationUpdateCommand.NetworkSlicingIndication = networkSlicingIndication + configurationUpdateCommand.NetworkSlicingIndication.SetNSSCI(0x01) } - if ue.Guti != "" { - gutiNas, err := nasConvert.GutiToNasWithError(ue.Guti) - if err != nil { - return nil, fmt.Errorf("encode GUTI failed: %w", err) + if flags.NeedGUTI { + if ue.Guti != "" { + gutiNas, err := nasConvert.GutiToNasWithError(ue.Guti) + if err != nil { + return nil, fmt.Errorf("encode GUTI failed: %w", err), needTimer + } + configurationUpdateCommand.GUTI5G = &gutiNas + configurationUpdateCommand.GUTI5G.SetIei(nasMessage.ConfigurationUpdateCommandGUTI5GType) + } else { + logger.GmmLog.Warnf("Require 5G-GUTI, but got nothing.") } - configurationUpdateCommand.GUTI5G = &gutiNas - configurationUpdateCommand.GUTI5G.SetIei(nasMessage.ConfigurationUpdateCommandGUTI5GType) } - if len(ue.RegistrationArea[anType]) > 0 { - configurationUpdateCommand.TAIList = nasType.NewTAIList(nasMessage.ConfigurationUpdateCommandTAIListType) - taiListNas := nasConvert.TaiListToNas(ue.RegistrationArea[anType]) - configurationUpdateCommand.TAIList.SetLen(uint8(len(taiListNas))) - configurationUpdateCommand.TAIList.SetPartialTrackingAreaIdentityList(taiListNas) - } + if flags.NeedAllowedNSSAI { + if len(ue.AllowedNssai[anType]) > 0 { + configurationUpdateCommand.AllowedNSSAI = nasType. + NewAllowedNSSAI(nasMessage.ConfigurationUpdateCommandAllowedNSSAIType) - if len(ue.AllowedNssai[anType]) > 0 { - configurationUpdateCommand.AllowedNSSAI = nasType. - NewAllowedNSSAI(nasMessage.ConfigurationUpdateCommandAllowedNSSAIType) - var buf []uint8 - for _, allowedSnssai := range ue.AllowedNssai[anType] { - buf = append(buf, nasConvert.SnssaiToNas(*allowedSnssai.AllowedSnssai)...) + var buf []uint8 + for _, allowedSnssai := range ue.AllowedNssai[anType] { + buf = append(buf, nasConvert.SnssaiToNas(*allowedSnssai.AllowedSnssai)...) + } + configurationUpdateCommand.AllowedNSSAI.SetLen(uint8(len(buf))) + configurationUpdateCommand.AllowedNSSAI.SetSNSSAIValue(buf) + } else { + logger.GmmLog.Warnf("Require Allowed NSSAI, but got nothing.") } - configurationUpdateCommand.AllowedNSSAI.SetLen(uint8(len(buf))) - configurationUpdateCommand.AllowedNSSAI.SetSNSSAIValue(buf) } - if len(ue.ConfiguredNssai) > 0 { - configurationUpdateCommand.ConfiguredNSSAI = nasType. - NewConfiguredNSSAI(nasMessage.ConfigurationUpdateCommandConfiguredNSSAIType) - var buf []uint8 - for _, snssai := range ue.ConfiguredNssai { - buf = append(buf, nasConvert.SnssaiToNas(*snssai.ConfiguredSnssai)...) + if flags.NeedConfiguredNSSAI { + if len(ue.ConfiguredNssai) > 0 { + configurationUpdateCommand.ConfiguredNSSAI = nasType. + NewConfiguredNSSAI(nasMessage.ConfigurationUpdateCommandConfiguredNSSAIType) + + var buf []uint8 + for _, snssai := range ue.ConfiguredNssai { + buf = append(buf, nasConvert.SnssaiToNas(*snssai.ConfiguredSnssai)...) + } + configurationUpdateCommand.ConfiguredNSSAI.SetLen(uint8(len(buf))) + configurationUpdateCommand.ConfiguredNSSAI.SetSNSSAIValue(buf) + } else { + logger.GmmLog.Warnf("Require Configured NSSAI, but got nothing.") } - configurationUpdateCommand.ConfiguredNSSAI.SetLen(uint8(len(buf))) - configurationUpdateCommand.ConfiguredNSSAI.SetSNSSAIValue(buf) } - if ue.NetworkSliceInfo != nil { - if len(ue.NetworkSliceInfo.RejectedNssaiInPlmn) != 0 || len(ue.NetworkSliceInfo.RejectedNssaiInTa) != 0 { + if flags.NeedRejectNSSAI { + if ue.NetworkSliceInfo != nil && + (len(ue.NetworkSliceInfo.RejectedNssaiInPlmn) != 0 || len(ue.NetworkSliceInfo.RejectedNssaiInTa) != 0) { rejectedNssaiNas := nasConvert.RejectedNssaiToNas( ue.NetworkSliceInfo.RejectedNssaiInPlmn, ue.NetworkSliceInfo.RejectedNssaiInTa) configurationUpdateCommand.RejectedNSSAI = &rejectedNssaiNas configurationUpdateCommand.RejectedNSSAI.SetIei(nasMessage.ConfigurationUpdateCommandRejectedNSSAIType) + } else { + logger.GmmLog.Warnf("Require Rejected NSSAI, but got nothing.") } } - if anType == models.AccessType__3_GPP_ACCESS && ue.AmPolicyAssociation != nil && - ue.AmPolicyAssociation.ServAreaRes != nil { - configurationUpdateCommand.ServiceAreaList = nasType. - NewServiceAreaList(nasMessage.ConfigurationUpdateCommandServiceAreaListType) - partialServiceAreaList := nasConvert. - PartialServiceAreaListToNas(ue.PlmnId, *ue.AmPolicyAssociation.ServAreaRes) - configurationUpdateCommand.ServiceAreaList.SetLen(uint8(len(partialServiceAreaList))) - configurationUpdateCommand.ServiceAreaList.SetPartialServiceAreaList(partialServiceAreaList) + if flags.NeedTaiList && anType == models.AccessType__3_GPP_ACCESS { + if len(ue.RegistrationArea[anType]) > 0 { + configurationUpdateCommand.TAIList = nasType.NewTAIList(nasMessage.ConfigurationUpdateCommandTAIListType) + taiListNas := nasConvert.TaiListToNas(ue.RegistrationArea[anType]) + configurationUpdateCommand.TAIList.SetLen(uint8(len(taiListNas))) + configurationUpdateCommand.TAIList.SetPartialTrackingAreaIdentityList(taiListNas) + } else { + logger.GmmLog.Warnf("Require TAI List, but got nothing.") + } } - amfSelf := context.GetSelf() - if amfSelf.NetworkName.Full != "" { - fullNetworkName := nasConvert.FullNetworkNameToNas(amfSelf.NetworkName.Full) - configurationUpdateCommand.FullNameForNetwork = &fullNetworkName - configurationUpdateCommand.FullNameForNetwork.SetIei(nasMessage.ConfigurationUpdateCommandFullNameForNetworkType) + if flags.NeedServiceAreaList && anType == models.AccessType__3_GPP_ACCESS { + if ue.AmPolicyAssociation != nil && ue.AmPolicyAssociation.ServAreaRes != nil { + configurationUpdateCommand.ServiceAreaList = nasType. + NewServiceAreaList(nasMessage.ConfigurationUpdateCommandServiceAreaListType) + partialServiceAreaList := nasConvert. + PartialServiceAreaListToNas(ue.PlmnId, *ue.AmPolicyAssociation.ServAreaRes) + configurationUpdateCommand.ServiceAreaList.SetLen(uint8(len(partialServiceAreaList))) + configurationUpdateCommand.ServiceAreaList.SetPartialServiceAreaList(partialServiceAreaList) + } else { + logger.GmmLog.Warnf("Require Service Area List, but got nothing.") + } } - if amfSelf.NetworkName.Short != "" { - shortNetworkName := nasConvert.ShortNetworkNameToNas(amfSelf.NetworkName.Short) - configurationUpdateCommand.ShortNameForNetwork = &shortNetworkName - configurationUpdateCommand.ShortNameForNetwork.SetIei(nasMessage.ConfigurationUpdateCommandShortNameForNetworkType) + if flags.NeedLadnInformation && anType == models.AccessType__3_GPP_ACCESS { + if len(ue.LadnInfo) > 0 { + configurationUpdateCommand.LADNInformation = nasType. + NewLADNInformation(nasMessage.ConfigurationUpdateCommandLADNInformationType) + var buf []uint8 + for _, ladn := range ue.LadnInfo { + ladnNas := nasConvert.LadnToNas(ladn.Dnn, ladn.TaiList) + buf = append(buf, ladnNas...) + } + configurationUpdateCommand.LADNInformation.SetLen(uint16(len(buf))) + configurationUpdateCommand.LADNInformation.SetLADND(buf) + } else { + logger.GmmLog.Warnf("Require LADN Information, but got nothing.") + } } - now := time.Now() - universalTimeAndLocalTimeZone := nasConvert.EncodeUniversalTimeAndLocalTimeZoneToNas(now) - universalTimeAndLocalTimeZone.SetIei(nasMessage.ConfigurationUpdateCommandUniversalTimeAndLocalTimeZoneType) - configurationUpdateCommand.UniversalTimeAndLocalTimeZone = &universalTimeAndLocalTimeZone - - if ue.TimeZone != amfSelf.TimeZone { - ue.TimeZone = amfSelf.TimeZone - - localTimeZone := nasConvert.EncodeLocalTimeZoneToNas(ue.TimeZone) - localTimeZone.SetIei(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType) - configurationUpdateCommand.LocalTimeZone = nasType. - NewLocalTimeZone(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType) - configurationUpdateCommand.LocalTimeZone = &localTimeZone + amfSelf := context.GetSelf() - daylightSavingTime := nasConvert.EncodeDaylightSavingTimeToNas(ue.TimeZone) - daylightSavingTime.SetIei(nasMessage.ConfigurationUpdateCommandNetworkDaylightSavingTimeType) - configurationUpdateCommand.NetworkDaylightSavingTime = nasType. - NewNetworkDaylightSavingTime(nasMessage.ConfigurationUpdateCommandNetworkDaylightSavingTimeType) - configurationUpdateCommand.NetworkDaylightSavingTime = &daylightSavingTime + if flags.NeedNITZ { + // Full network name + if amfSelf.NetworkName.Full != "" { + fullNetworkName := nasConvert.FullNetworkNameToNas(amfSelf.NetworkName.Full) + configurationUpdateCommand.FullNameForNetwork = &fullNetworkName + configurationUpdateCommand.FullNameForNetwork.SetIei(nasMessage.ConfigurationUpdateCommandFullNameForNetworkType) + } else { + logger.GmmLog.Warnf("Require Full Network Name, but got nothing.") + } + // Short network name + if amfSelf.NetworkName.Short != "" { + shortNetworkName := nasConvert.ShortNetworkNameToNas(amfSelf.NetworkName.Short) + configurationUpdateCommand.ShortNameForNetwork = &shortNetworkName + configurationUpdateCommand.ShortNameForNetwork.SetIei(nasMessage.ConfigurationUpdateCommandShortNameForNetworkType) + } else { + logger.GmmLog.Warnf("Require Short Network Name, but got nothing.") + } + // Universal Time and Local Time Zone + now := time.Now() + universalTimeAndLocalTimeZone := nasConvert.EncodeUniversalTimeAndLocalTimeZoneToNas(now) + universalTimeAndLocalTimeZone.SetIei(nasMessage.ConfigurationUpdateCommandUniversalTimeAndLocalTimeZoneType) + configurationUpdateCommand.UniversalTimeAndLocalTimeZone = &universalTimeAndLocalTimeZone + + if ue.TimeZone != amfSelf.TimeZone { + ue.TimeZone = amfSelf.TimeZone + // Local Time Zone + localTimeZone := nasConvert.EncodeLocalTimeZoneToNas(ue.TimeZone) + localTimeZone.SetIei(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType) + configurationUpdateCommand.LocalTimeZone = nasType. + NewLocalTimeZone(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType) + configurationUpdateCommand.LocalTimeZone = &localTimeZone + // Daylight Saving Time + daylightSavingTime := nasConvert.EncodeDaylightSavingTimeToNas(ue.TimeZone) + daylightSavingTime.SetIei(nasMessage.ConfigurationUpdateCommandNetworkDaylightSavingTimeType) + configurationUpdateCommand.NetworkDaylightSavingTime = nasType. + NewNetworkDaylightSavingTime(nasMessage.ConfigurationUpdateCommandNetworkDaylightSavingTimeType) + configurationUpdateCommand.NetworkDaylightSavingTime = &daylightSavingTime + } } - if len(ue.LadnInfo) > 0 { - configurationUpdateCommand.LADNInformation = nasType. - NewLADNInformation(nasMessage.ConfigurationUpdateCommandLADNInformationType) - var buf []uint8 - for _, ladn := range ue.LadnInfo { - ladnNas := nasConvert.LadnToNas(ladn.Dnn, ladn.TaiList) - buf = append(buf, ladnNas...) - } - configurationUpdateCommand.LADNInformation.SetLen(uint16(len(buf))) - configurationUpdateCommand.LADNInformation.SetLADND(buf) + configurationUpdateCommand.ConfigurationUpdateIndication = nasType. + NewConfigurationUpdateIndication(nasMessage.ConfigurationUpdateCommandConfigurationUpdateIndicationType) + if configurationUpdateCommand.GUTI5G != nil || + configurationUpdateCommand.TAIList != nil || + configurationUpdateCommand.AllowedNSSAI != nil || + configurationUpdateCommand.LADNInformation != nil || + configurationUpdateCommand.ServiceAreaList != nil || + configurationUpdateCommand.MICOIndication != nil || + configurationUpdateCommand.ConfiguredNSSAI != nil || + configurationUpdateCommand.RejectedNSSAI != nil || + configurationUpdateCommand.NetworkSlicingIndication != nil || + configurationUpdateCommand.OperatordefinedAccessCategoryDefinitions != nil || + configurationUpdateCommand.SMSIndication != nil { + // TS 24.501 - 5.4.4.2 Generic UE configuration update procedure initiated by the network + // Acknowledgement shall be requested for all parameters except when only NITZ is included + configurationUpdateCommand.ConfigurationUpdateIndication.SetACK(uint8(1)) + needTimer = true + } + if configurationUpdateCommand.MICOIndication != nil { + // Allowed NSSAI and Configured NSSAI are optional to request to perform the registration procedure + configurationUpdateCommand.ConfigurationUpdateIndication.SetRED(uint8(1)) + } + + // Check if the Configuration Update Command is vaild + if configurationUpdateCommand.ConfigurationUpdateIndication.GetACK() == uint8(0) && + configurationUpdateCommand.ConfigurationUpdateIndication.GetRED() == uint8(0) && + (configurationUpdateCommand.FullNameForNetwork == nil && + configurationUpdateCommand.ShortNameForNetwork == nil && + configurationUpdateCommand.UniversalTimeAndLocalTimeZone == nil && + configurationUpdateCommand.LocalTimeZone == nil && + configurationUpdateCommand.NetworkDaylightSavingTime == nil) { + return nil, fmt.Errorf("Configuration Update Command is invaild"), false } m.GmmMessage.ConfigurationUpdateCommand = configurationUpdateCommand @@ -860,5 +926,10 @@ func BuildConfigurationUpdateCommand(ue *context.AmfUe, anType models.AccessType ProtocolDiscriminator: nasMessage.Epd5GSMobilityManagementMessage, SecurityHeaderType: nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, } - return nas_security.Encode(ue, m, anType) + + b, err := nas_security.Encode(ue, m, anType) + if err != nil { + return nil, fmt.Errorf("BuildConfigurationUpdateCommand() err: %v", err), false + } + return b, err, needTimer } diff --git a/internal/gmm/message/send.go b/internal/gmm/message/send.go index 4df330ad..9297716e 100644 --- a/internal/gmm/message/send.go +++ b/internal/gmm/message/send.go @@ -9,7 +9,6 @@ import ( ngap_message "github.com/free5gc/amf/internal/ngap/message" "github.com/free5gc/amf/internal/sbi/producer/callback" "github.com/free5gc/nas/nasMessage" - "github.com/free5gc/nas/nasType" "github.com/free5gc/ngap/ngapType" "github.com/free5gc/openapi/models" ) @@ -179,8 +178,9 @@ func SendServiceAccept(amfUe *context.AmfUe, anType models.AccessType, return nil } -func SendConfigurationUpdateCommand(amfUe *context.AmfUe, accessType models.AccessType, - networkSlicingIndication *nasType.NetworkSlicingIndication, +func SendConfigurationUpdateCommand(amfUe *context.AmfUe, + accessType models.AccessType, + flags *context.ConfigurationUpdateCommandFlags, ) { if amfUe == nil { logger.GmmLog.Error("SendConfigurationUpdateCommand: AmfUe is nil") @@ -190,15 +190,30 @@ func SendConfigurationUpdateCommand(amfUe *context.AmfUe, accessType models.Acce logger.GmmLog.Error("SendConfigurationUpdateCommand: RanUe is nil") return } - amfUe.GmmLog.Info("Configuration Update Command") - nasMsg, err := BuildConfigurationUpdateCommand(amfUe, accessType, networkSlicingIndication) + nasMsg, err, startT3555 := BuildConfigurationUpdateCommand(amfUe, accessType, flags) if err != nil { - amfUe.GmmLog.Error(err.Error()) + amfUe.GmmLog.Errorf("BuildConfigurationUpdateCommand Error: %+v", err) return } + amfUe.GmmLog.Info("Send Configuration Update Command") + mobilityRestrictionList := ngap_message.BuildIEMobilityRestrictionList(amfUe) ngap_message.SendDownlinkNasTransport(amfUe.RanUe[accessType], nasMsg, &mobilityRestrictionList) + + if startT3555 && context.GetSelf().T3555Cfg.Enable { + cfg := context.GetSelf().T3555Cfg + amfUe.GmmLog.Infof("Start T3555 timer") + amfUe.T3555 = context.NewTimer(cfg.ExpireTime, cfg.MaxRetryTimes, func(expireTimes int32) { + amfUe.GmmLog.Warnf("T3555 expires, retransmit Configuration Update Command (retry: %d)", + expireTimes) + ngap_message.SendDownlinkNasTransport(amfUe.RanUe[accessType], nasMsg, &mobilityRestrictionList) + }, func() { + amfUe.GmmLog.Warnf("T3555 Expires %d times, abort configuration update procedure", + cfg.MaxRetryTimes) + }, + ) + } } func SendAuthenticationReject(ue *context.RanUe, eapMsg string) { diff --git a/internal/sbi/producer/callback.go b/internal/sbi/producer/callback.go index 08d01f33..3c2f1e84 100644 --- a/internal/sbi/producer/callback.go +++ b/internal/sbi/producer/callback.go @@ -153,18 +153,26 @@ func AmPolicyControlUpdateNotifyUpdateProcedure(polAssoID string, } }() + configurationUpdateCommandFlags := &context.ConfigurationUpdateCommandFlags{ + NeedGUTI: true, + NeedAllowedNSSAI: true, + NeedConfiguredNSSAI: true, + NeedRejectNSSAI: true, + NeedTaiList: true, + NeedNITZ: true, + NeedLadnInformation: true, + } + // UE is CM-Connected State if ue.CmConnect(models.AccessType__3_GPP_ACCESS) { - gmm_message.SendConfigurationUpdateCommand(ue, models.AccessType__3_GPP_ACCESS, nil) - // UE is CM-IDLE => paging + gmm_message.SendConfigurationUpdateCommand(ue, + models.AccessType__3_GPP_ACCESS, + configurationUpdateCommandFlags, + ) } else { - message, err := gmm_message.BuildConfigurationUpdateCommand(ue, models.AccessType__3_GPP_ACCESS, nil) - if err != nil { - logger.GmmLog.Errorf("Build Configuration Update Command Failed : %s", err.Error()) - return - } + // UE is CM-IDLE => paging + ue.ConfigurationUpdateCommandFlags = configurationUpdateCommandFlags - ue.ConfigurationUpdateMessage = message ue.SetOnGoing(models.AccessType__3_GPP_ACCESS, &context.OnGoing{ Procedure: context.OnGoingProcedurePaging, }) diff --git a/pkg/factory/config.go b/pkg/factory/config.go index 62ad3f0a..51239e10 100644 --- a/pkg/factory/config.go +++ b/pkg/factory/config.go @@ -88,6 +88,7 @@ type Configuration struct { T3560 TimerValue `yaml:"t3560" valid:"required"` T3565 TimerValue `yaml:"t3565" valid:"required"` T3570 TimerValue `yaml:"t3570" valid:"required"` + T3555 TimerValue `yaml:"t3555" valid:"required"` Locality string `yaml:"locality,omitempty" valid:"type(string),optional"` SCTP *Sctp `yaml:"sctp,omitempty" valid:"optional"` DefaultUECtxReq bool `yaml:"defaultUECtxReq,omitempty" valid:"type(bool),optional"` @@ -267,6 +268,10 @@ func (c *Configuration) validate() (bool, error) { return false, err } + if _, err := c.T3555.validate(); err != nil { + return false, err + } + if c.SCTP != nil { if _, err := c.SCTP.validate(); err != nil { return false, err From d00d96f7f48885dfe81cda115d8af4ca8c77070c Mon Sep 17 00:00:00 2001 From: iamelisahi <135607537+iamelisahi@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:39:04 +0800 Subject: [PATCH 12/13] Feature/integrity check (#109) * Modify UEContextTransferProcedure: * check integrity of the registration request included in ueContextTransferRequest * Modify buildUEContextModel: * copy security context to new amf * Modify code to satisfy the coding style * Modify old amf integrity check parameter: * ulCount * Modify UEContextTransferProcedure: * handle INTEGRITY_CHECK_FAIL Modify IdentityVerification Modify HandleRegistrationRequest: * assign value to ue.PlmnId in case "nasMessage.MobileIdentity5GSType5gGuti" * Modify old amf integrity check parameter * Modify FuzzNASSecurity: * since the MACs vary when the integrity check algorithms differ, the identical comparison should only be applied to nas.message.GmmMessage * Modify buildUEContextModel: * change input parameter from integrityProtected to models.TransferReason * Modify ue_context.go handler.go * add TODO and delete comments * Use raw byte as BinaryDataN1Message * Remove unused code and fix lint error * remove unused code --- internal/context/amf_ue.go | 3 + internal/gmm/handler.go | 11 +- internal/nas/handler.go | 1 + internal/nas/nas_security/fuzz_test.go | 2 +- internal/nas/nas_security/security.go | 9 +- internal/sbi/consumer/communication.go | 8 +- internal/sbi/producer/ue_context.go | 191 +++++++++++++++++-------- 7 files changed, 153 insertions(+), 72 deletions(-) mode change 100644 => 100755 internal/nas/nas_security/fuzz_test.go diff --git a/internal/context/amf_ue.go b/internal/context/amf_ue.go index a387ffae..f293ddfc 100644 --- a/internal/context/amf_ue.go +++ b/internal/context/amf_ue.go @@ -66,6 +66,7 @@ type AmfUe struct { ServingAmfChanged bool DeregistrationTargetAccessType uint8 // only used when deregistration procedure is initialized by the network RegistrationAcceptForNon3GPPAccess []byte + NasPduValue []byte RetransmissionOfInitialNASMsg bool RequestIdentityType uint8 /* Used for AMF relocation */ @@ -735,6 +736,8 @@ func (ue *AmfUe) CopyDataFromUeContextModel(ueContext models.UeContext) { ue.NH = nh } ue.NCC = uint8(seafData.Ncc) + } else { + ue.SecurityContextAvailable = false } if ueContext.PcfId != "" { diff --git a/internal/gmm/handler.go b/internal/gmm/handler.go index 9cbf2489..6be75112 100644 --- a/internal/gmm/handler.go +++ b/internal/gmm/handler.go @@ -482,6 +482,7 @@ func HandleRegistrationRequest(ue *context.AmfUe, anType models.AccessType, proc return fmt.Errorf("decode GUTI failed: %w", err) } guamiFromUeGuti = guamiFromUeGutiTmp + ue.PlmnId = *guamiFromUeGuti.PlmnId ue.GmmLog.Infof("MobileIdentity5GS: GUTI[%s]", guti) // TODO: support multiple ServedGuami @@ -564,7 +565,6 @@ func HandleRegistrationRequest(ue *context.AmfUe, anType models.AccessType, proc // if failed, give up to retrieve the old context and start a new authentication procedure. ue.ServingAmfChanged = false context.GetSelf().AllocateGutiToUe(ue) // refresh 5G-GUTI - ue.SecurityContextAvailable = false // need to start authentication procedure later } } return nil @@ -594,14 +594,23 @@ func contextTransferFromOldAmf(ue *context.AmfUe, anType models.AccessType, oldA ueContextTransferRspData, problemDetails, err := consumer.UEContextTransferRequest(ue, anType, transferReason) if problemDetails != nil { if problemDetails.Cause == "INTEGRITY_CHECK_FAIL" || problemDetails.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("UE Context Transfer Request Failed Problem[%+v]", problemDetails) } else if err != nil { return fmt.Errorf("UE Context Transfer Request Error[%+v]", err) + } else { + ue.SecurityContextAvailable = true + ue.MacFailed = false } ue.CopyDataFromUeContextModel(*ueContextTransferRspData.UeContext) + if ue.SecurityContextAvailable { + ue.DerivateAlgKey() + } return nil } diff --git a/internal/nas/handler.go b/internal/nas/handler.go index 69e82f48..dee9a22b 100644 --- a/internal/nas/handler.go +++ b/internal/nas/handler.go @@ -33,6 +33,7 @@ func HandleNAS(ue *amf_context.RanUe, procedureCode int64, nasPdu []byte, initia ue.AmfUe.NASLog.Errorln(err) return } + ue.AmfUe.NasPduValue = nasPdu ue.AmfUe.MacFailed = !integrityProtected if err := Dispatch(ue.AmfUe, ue.Ran.AnType, procedureCode, msg); err != nil { diff --git a/internal/nas/nas_security/fuzz_test.go b/internal/nas/nas_security/fuzz_test.go old mode 100644 new mode 100755 index 4daf188f..e9098785 --- a/internal/nas/nas_security/fuzz_test.go +++ b/internal/nas/nas_security/fuzz_test.go @@ -50,7 +50,7 @@ func FuzzNASSecurity(f *testing.F) { if !integrityProtected2 { panic("integrityProtected mismatch") } - if !reflect.DeepEqual(msg0, msg2) { + if !reflect.DeepEqual(msg0.GmmMessage, msg2.GmmMessage) { panic("msg mismatch") } } diff --git a/internal/nas/nas_security/security.go b/internal/nas/nas_security/security.go index 22d89634..d5ebe30d 100644 --- a/internal/nas/nas_security/security.go +++ b/internal/nas/nas_security/security.go @@ -1,6 +1,7 @@ package nas_security import ( + "encoding/binary" "encoding/hex" "fmt" "reflect" @@ -123,6 +124,7 @@ func Decode(ue *context.AmfUe, accessType models.AccessType, payload []byte, ulCountNew := ue.ULCount msg = new(nas.Message) + msg.ProtocolDiscriminator = payload[0] msg.SecurityHeaderType = nas.GetSecurityHeaderType(payload) & 0x0f ue.NASLog.Traceln("securityHeaderType is ", msg.SecurityHeaderType) if msg.SecurityHeaderType != nas.SecurityHeaderTypePlainNas { // Security protected NAS message @@ -139,8 +141,9 @@ func Decode(ue *context.AmfUe, accessType models.AccessType, payload []byte, ue.NASLog.Traceln("securityHeader is ", securityHeader) sequenceNumber := payload[6] ue.NASLog.Traceln("sequenceNumber", sequenceNumber) - + msg.SequenceNumber = sequenceNumber receivedMac32 := securityHeader[2:] + msg.MessageAuthenticationCode = binary.BigEndian.Uint32(receivedMac32) // remove security Header except for sequece Number payload = payload[6:] @@ -278,7 +281,7 @@ func Decode(ue *context.AmfUe, accessType models.AccessType, payload []byte, mobileIdentityContents := msg.IdentityResponse.MobileIdentity.GetMobileIdentityContents() if len(mobileIdentityContents) >= 1 && nasConvert.GetTypeOfIdentity(mobileIdentityContents[0]) == nasMessage.MobileIdentity5GSTypeSuci { - // Identity is SUSI + // Identity is SUCI if ue.SecurityContextAvailable { if msg.SecurityHeaderType != nas.SecurityHeaderTypeIntegrityProtectedAndCiphered { return nil, false, errWrongSecurityHeader() @@ -288,7 +291,7 @@ func Decode(ue *context.AmfUe, accessType models.AccessType, payload []byte, } } } else { - // Identity is not SUSI + // Identity is not SUCI if !ue.SecurityContextAvailable { return nil, false, errNoSecurityContext() } diff --git a/internal/sbi/consumer/communication.go b/internal/sbi/consumer/communication.go index 59a6a6f8..8f545afb 100644 --- a/internal/sbi/consumer/communication.go +++ b/internal/sbi/consumer/communication.go @@ -1,7 +1,6 @@ package consumer import ( - "bytes" "context" "fmt" @@ -214,18 +213,13 @@ func UEContextTransferRequest( JsonData: &ueContextTransferReqData, } if transferReason == models.TransferReason_INIT_REG || transferReason == models.TransferReason_MOBI_REG { - var buf bytes.Buffer - err = ue.RegistrationRequest.EncodeRegistrationRequest(&buf) - if err != nil { - return nil, nil, fmt.Errorf("re-encoding registration request message is failed: %w", err) - } ueContextTransferReqData.RegRequest = &models.N1MessageContainer{ N1MessageClass: models.N1MessageClass__5_GMM, N1MessageContent: &models.RefToBinaryData{ ContentId: "n1Msg", }, } - req.BinaryDataN1Message = buf.Bytes() + req.BinaryDataN1Message = ue.NasPduValue } // guti format is defined at TS 29.518 Table 6.1.3.2.2-1 5g-guti-[0-9]{5,6}[0-9a-fA-F]{14} diff --git a/internal/sbi/producer/ue_context.go b/internal/sbi/producer/ue_context.go index 09fc9da3..b0b1638c 100644 --- a/internal/sbi/producer/ue_context.go +++ b/internal/sbi/producer/ue_context.go @@ -1,13 +1,17 @@ package producer import ( + "encoding/base64" + "encoding/hex" "net/http" "strings" "github.com/free5gc/amf/internal/context" gmm_common "github.com/free5gc/amf/internal/gmm/common" "github.com/free5gc/amf/internal/logger" + "github.com/free5gc/amf/internal/nas/nas_security" "github.com/free5gc/amf/internal/sbi/consumer" + "github.com/free5gc/nas/security" "github.com/free5gc/openapi/models" "github.com/free5gc/util/httpwrapper" ) @@ -191,6 +195,20 @@ func ReleaseUEContextProcedure(ueContextID string, ueContextRelease models.UeCon return nil } +func HandleMobiRegUe(ue *context.AmfUe, ueContextTransferRspData *models.UeContextTransferRspData, + ueContextTransferResponse *models.UeContextTransferResponse, +) { + ueContextTransferRspData.UeRadioCapability = &models.N2InfoContent{ + NgapMessageType: 0, + NgapIeType: models.NgapIeType_UE_RADIO_CAPABILITY, + NgapData: &models.RefToBinaryData{ + ContentId: "n2Info", + }, + } + b := []byte(ue.UeRadioCapability) + copy(ueContextTransferResponse.BinaryDataN2Information, b) +} + // TS 29.518 5.2.2.2.1 func HandleUEContextTransferRequest(request *httpwrapper.Request) *httpwrapper.Response { logger.CommLog.Info("Handle UE Context Transfer Request") @@ -256,70 +274,52 @@ func UEContextTransferProcedure(ueContextID string, ueContextTransferRequest mod switch UeContextTransferReqData.Reason { case models.TransferReason_INIT_REG: - // TODO: check integrity of the registration request included in ueContextTransferRequest + _, integrityProtected, err := nas_security.Decode(ue, UeContextTransferReqData.AccessType, + ueContextTransferRequest.BinaryDataN1Message, true) + if err != nil { + problemDetails := &models.ProblemDetails{ + Status: http.StatusForbidden, + Cause: "INTEGRITY_CHECK_FAIL", + } + ue.NASLog.Errorln(err) + return nil, problemDetails + } + if integrityProtected { + ueContextTransferRspData.UeContext = buildUEContextModel(ue, UeContextTransferReqData.Reason) + } else { + problemDetails := &models.ProblemDetails{ + Status: http.StatusForbidden, + Cause: "INTEGRITY_CHECK_FAIL", + } + return nil, problemDetails + } // TODO: handle condition of TS 29.518 5.2.2.2.1.1 step 2a case b - ueContextTransferRspData.UeContext = buildUEContextModel(ue) case models.TransferReason_MOBI_REG: - // TODO: check integrity of the registration request included in ueContextTransferRequest - ueContextTransferRspData.UeContext = buildUEContextModel(ue) - - sessionContextList := &ueContextTransferRspData.UeContext.SessionContextList - ue.SmContextList.Range(func(key, value interface{}) bool { - smContext := value.(*context.SmContext) - snssai := smContext.Snssai() - pduSessionContext := models.PduSessionContext{ - PduSessionId: smContext.PduSessionID(), - SmContextRef: smContext.SmContextRef(), - SNssai: &snssai, - Dnn: smContext.Dnn(), - AccessType: smContext.AccessType(), - HsmfId: smContext.HSmfID(), - VsmfId: smContext.VSmfID(), - NsInstance: smContext.NsInstance(), + _, integrityProtected, err := nas_security.Decode(ue, UeContextTransferReqData.AccessType, + ueContextTransferRequest.BinaryDataN1Message, false) + if err != nil { + problemDetails := &models.ProblemDetails{ + Status: http.StatusForbidden, + Cause: "INTEGRITY_CHECK_FAIL", } - *sessionContextList = append(*sessionContextList, pduSessionContext) - return true - }) - - ueContextTransferRspData.UeRadioCapability = &models.N2InfoContent{ - NgapMessageType: 0, - NgapIeType: models.NgapIeType_UE_RADIO_CAPABILITY, - NgapData: &models.RefToBinaryData{ - ContentId: "n2Info", - }, + ue.NASLog.Errorln(err) + return nil, problemDetails } - b := []byte(ue.UeRadioCapability) - copy(ueContextTransferResponse.BinaryDataN2Information, b) - case models.TransferReason_MOBI_REG_UE_VALIDATED: - ueContextTransferRspData.UeContext = buildUEContextModel(ue) - - sessionContextList := &ueContextTransferRspData.UeContext.SessionContextList - ue.SmContextList.Range(func(key, value interface{}) bool { - smContext := value.(*context.SmContext) - snssai := smContext.Snssai() - pduSessionContext := models.PduSessionContext{ - PduSessionId: smContext.PduSessionID(), - SmContextRef: smContext.SmContextRef(), - SNssai: &snssai, - Dnn: smContext.Dnn(), - AccessType: smContext.AccessType(), - HsmfId: smContext.HSmfID(), - VsmfId: smContext.VSmfID(), - NsInstance: smContext.NsInstance(), + if integrityProtected { + ueContextTransferRspData.UeContext = buildUEContextModel(ue, UeContextTransferReqData.Reason) + } else { + problemDetails := &models.ProblemDetails{ + Status: http.StatusForbidden, + Cause: "INTEGRITY_CHECK_FAIL", } - *sessionContextList = append(*sessionContextList, pduSessionContext) - return true - }) - - ueContextTransferRspData.UeRadioCapability = &models.N2InfoContent{ - NgapMessageType: 0, - NgapIeType: models.NgapIeType_UE_RADIO_CAPABILITY, - NgapData: &models.RefToBinaryData{ - ContentId: "n2Info", - }, + return nil, problemDetails } - b := []byte(ue.UeRadioCapability) - copy(ueContextTransferResponse.BinaryDataN2Information, b) + HandleMobiRegUe(ue, ueContextTransferRspData, ueContextTransferResponse) + + case models.TransferReason_MOBI_REG_UE_VALIDATED: + ueContextTransferRspData.UeContext = buildUEContextModel(ue, UeContextTransferReqData.Reason) + HandleMobiRegUe(ue, ueContextTransferRspData, ueContextTransferResponse) + default: logger.ProducerLog.Warnf("Invalid Transfer Reason: %+v", UeContextTransferReqData.Reason) problemDetails := &models.ProblemDetails{ @@ -336,11 +336,82 @@ func UEContextTransferProcedure(ueContextID string, ueContextTransferRequest mod return ueContextTransferResponse, nil } -func buildUEContextModel(ue *context.AmfUe) *models.UeContext { +func buildUEContextModel(ue *context.AmfUe, Reason models.TransferReason) *models.UeContext { ueContext := new(models.UeContext) ueContext.Supi = ue.Supi ueContext.SupiUnauthInd = ue.UnauthenticatedSupi - + if Reason == models.TransferReason_INIT_REG || Reason == models.TransferReason_MOBI_REG { + var mmContext models.MmContext + mmContext.AccessType = models.AccessType__3_GPP_ACCESS + NasSecurityMode := new(models.NasSecurityMode) + switch ue.IntegrityAlg { + case security.AlgIntegrity128NIA0: + NasSecurityMode.IntegrityAlgorithm = models.IntegrityAlgorithm_NIA0 + case security.AlgIntegrity128NIA1: + NasSecurityMode.IntegrityAlgorithm = models.IntegrityAlgorithm_NIA1 + case security.AlgIntegrity128NIA2: + NasSecurityMode.IntegrityAlgorithm = models.IntegrityAlgorithm_NIA2 + case security.AlgIntegrity128NIA3: + NasSecurityMode.IntegrityAlgorithm = models.IntegrityAlgorithm_NIA3 + } + switch ue.CipheringAlg { + case security.AlgCiphering128NEA0: + NasSecurityMode.CipheringAlgorithm = models.CipheringAlgorithm_NEA0 + case security.AlgCiphering128NEA1: + NasSecurityMode.CipheringAlgorithm = models.CipheringAlgorithm_NEA1 + case security.AlgCiphering128NEA2: + NasSecurityMode.CipheringAlgorithm = models.CipheringAlgorithm_NEA2 + case security.AlgCiphering128NEA3: + NasSecurityMode.CipheringAlgorithm = models.CipheringAlgorithm_NEA3 + } + NgKsi := new(models.NgKsi) + NgKsi.Ksi = ue.NgKsi.Ksi + NgKsi.Tsc = ue.NgKsi.Tsc + KeyAmf := new(models.KeyAmf) + KeyAmf.KeyType = models.KeyAmfType_KAMF + KeyAmf.KeyVal = ue.Kamf + SeafData := new(models.SeafData) + SeafData.NgKsi = NgKsi + SeafData.KeyAmf = KeyAmf + if ue.NH != nil { + SeafData.Nh = hex.EncodeToString(ue.NH) + } + SeafData.Ncc = int32(ue.NCC) + SeafData.KeyAmfChangeInd = false + SeafData.KeyAmfHDerivationInd = false + ueContext.SeafData = SeafData + mmContext.NasSecurityMode = NasSecurityMode + if ue.UESecurityCapability.Buffer != nil { + mmContext.UeSecurityCapability = base64.StdEncoding.EncodeToString(ue.UESecurityCapability.Buffer) + } + mmContext.NasDownlinkCount = int32(ue.DLCount.Get()) + mmContext.NasUplinkCount = int32(ue.ULCount.Get()) + if ue.AllowedNssai[models.AccessType__3_GPP_ACCESS] != nil { + for _, allowedSnssai := range ue.AllowedNssai[models.AccessType__3_GPP_ACCESS] { + mmContext.AllowedNssai = append(mmContext.AllowedNssai, *(allowedSnssai.AllowedSnssai)) + } + } + ueContext.MmContextList = append(ueContext.MmContextList, mmContext) + } + if Reason == models.TransferReason_MOBI_REG_UE_VALIDATED || Reason == models.TransferReason_MOBI_REG { + sessionContextList := &ueContext.SessionContextList + ue.SmContextList.Range(func(key, value interface{}) bool { + smContext := value.(*context.SmContext) + snssai := smContext.Snssai() + pduSessionContext := models.PduSessionContext{ + PduSessionId: smContext.PduSessionID(), + SmContextRef: smContext.SmContextRef(), + SNssai: &snssai, + Dnn: smContext.Dnn(), + AccessType: smContext.AccessType(), + HsmfId: smContext.HSmfID(), + VsmfId: smContext.VSmfID(), + NsInstance: smContext.NsInstance(), + } + *sessionContextList = append(*sessionContextList, pduSessionContext) + return true + }) + } if ue.Gpsi != "" { ueContext.GpsiList = append(ueContext.GpsiList, ue.Gpsi) } From f915d42ebdc3c09f5b8c9db94523d0d4f82d9593 Mon Sep 17 00:00:00 2001 From: Tim Liu Date: Sun, 1 Oct 2023 09:30:41 +0000 Subject: [PATCH 13/13] remove go 1.17 in workflows --- .github/workflows/go.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d3de7616..87ba0914 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.17', '1.18' ] + go: [ '1.18' ] name: Go ${{ matrix.go }} sample steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4af7bb19..1169dd43 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.17', '1.18' ] + go: [ '1.18' ] steps: - name: Set up Go uses: actions/setup-go@v3