Skip to content

Commit

Permalink
Use raw byte as BinaryDataN1Message
Browse files Browse the repository at this point in the history
  • Loading branch information
iamelisahi committed Sep 14, 2023
1 parent 4535acf commit d7aabae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
3 changes: 1 addition & 2 deletions internal/context/amf_ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand Down
5 changes: 1 addition & 4 deletions internal/nas/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 1 addition & 20 deletions internal/sbi/consumer/communication.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package consumer

import (
"bytes"
"context"
"encoding/binary"
"fmt"

amf_context "github.com/free5gc/amf/internal/context"
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit d7aabae

Please sign in to comment.