diff --git a/internal/context/amf_ue.go b/internal/context/amf_ue.go index 4d91da2e..eb5ff718 100644 --- a/internal/context/amf_ue.go +++ b/internal/context/amf_ue.go @@ -14,7 +14,6 @@ import ( "github.com/free5gc/amf/internal/logger" "github.com/free5gc/amf/pkg/factory" - "github.com/free5gc/nas" "github.com/free5gc/nas/nasMessage" "github.com/free5gc/nas/nasType" "github.com/free5gc/nas/security" @@ -64,10 +63,10 @@ type AmfUe struct { RegistrationType5GS uint8 IdentityTypeUsedForRegistration uint8 RegistrationRequest *nasMessage.RegistrationRequest - SecurityHeader nas.SecurityHeader 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 */ diff --git a/internal/nas/handler.go b/internal/nas/handler.go index 54e6f095..dee9a22b 100644 --- a/internal/nas/handler.go +++ b/internal/nas/handler.go @@ -33,10 +33,7 @@ func HandleNAS(ue *amf_context.RanUe, procedureCode int64, nasPdu []byte, initia ue.AmfUe.NASLog.Errorln(err) return } - ue.AmfUe.SecurityHeader.ProtocolDiscriminator = msg.ProtocolDiscriminator - ue.AmfUe.SecurityHeader.SecurityHeaderType = msg.SecurityHeaderType - ue.AmfUe.SecurityHeader.SequenceNumber = msg.SequenceNumber - ue.AmfUe.SecurityHeader.MessageAuthenticationCode = msg.MessageAuthenticationCode + ue.AmfUe.NasPduValue = nasPdu ue.AmfUe.MacFailed = !integrityProtected if err := Dispatch(ue.AmfUe, ue.Ran.AnType, procedureCode, msg); err != nil { diff --git a/internal/sbi/consumer/communication.go b/internal/sbi/consumer/communication.go index e21af5f2..8f545afb 100644 --- a/internal/sbi/consumer/communication.go +++ b/internal/sbi/consumer/communication.go @@ -1,9 +1,7 @@ package consumer import ( - "bytes" "context" - "encoding/binary" "fmt" amf_context "github.com/free5gc/amf/internal/context" @@ -215,30 +213,13 @@ func UEContextTransferRequest( JsonData: &ueContextTransferReqData, } if transferReason == models.TransferReason_INIT_REG || transferReason == models.TransferReason_MOBI_REG { - var buf bytes.Buffer - if err = binary.Write(&buf, binary.BigEndian, ue.SecurityHeader.ProtocolDiscriminator); err != nil { - logger.ConsumerLog.Error("NAS encode error (SecurityHeader/ProtocolDiscriminator): %w", err) - } - if err = binary.Write(&buf, binary.BigEndian, ue.SecurityHeader.SecurityHeaderType); err != nil { - logger.ConsumerLog.Error("NAS encode error (SecurityHeader/SecurityHeaderType): %w", err) - } - if err = binary.Write(&buf, binary.BigEndian, ue.SecurityHeader.MessageAuthenticationCode); err != nil { - logger.ConsumerLog.Error("NAS encode error (SecurityHeader/MessageAuthenticationCode): %w", err) - } - if err = binary.Write(&buf, binary.BigEndian, ue.SecurityHeader.SequenceNumber); err != nil { - logger.ConsumerLog.Error("NAS encode error (SecurityHeader/SequenceNumber): %w", err) - } - 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}