Skip to content

Commit

Permalink
fix: use SecurityHeaderTypeIntegrityProtectedAndCiphered as Security …
Browse files Browse the repository at this point in the history
…Header Type in Configuration Update Complete message

Signed-off-by: brianchennn <[email protected]>
  • Loading branch information
brianchennn authored and linouxis9 committed Mar 19, 2024
1 parent 3abe9c0 commit 6e163a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,31 @@ package mm_5gs
import (
"bytes"
"fmt"
"my5G-RANTester/internal/control_test_engine/ue/context"
"my5G-RANTester/internal/control_test_engine/ue/nas/message/nas_control"

"github.com/free5gc/nas"
"github.com/free5gc/nas/nasMessage"
"my5G-RANTester/internal/control_test_engine/ue/context"
)

func ConfigurationUpdateComplete(ue *context.UEContext) (nasPdu []byte) {
func ConfigurationUpdateComplete(ue *context.UEContext) ([]byte, error) {
pdu := getConfigurationUpdateComplete()
pdu, err := nas_control.EncodeNasPduWithSecurity(ue, pdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true, false)
if err != nil {
return nil, fmt.Errorf("error encoding %s IMSI UE NAS Registration Complete Msg", ue.UeSecurity.Supi)
}

return pdu, nil
}

func getConfigurationUpdateComplete() (nasPdu []byte) {
m := nas.NewMessage()
m.GmmMessage = nas.NewGmmMessage()
m.GmmHeader.SetMessageType(nas.MsgTypeConfigurationUpdateComplete)

configurationUpdateComplete := nasMessage.NewConfigurationUpdateComplete(0)
configurationUpdateComplete.SetExtendedProtocolDiscriminator(nasMessage.Epd5GSMobilityManagementMessage)
configurationUpdateComplete.SetSecurityHeaderType(0x00)
configurationUpdateComplete.SetSecurityHeaderType(nas.SecurityHeaderTypeIntegrityProtectedAndCiphered)
configurationUpdateComplete.SetSpareHalfOctet(0x00)
configurationUpdateComplete.SetMessageType(nas.MsgTypeConfigurationUpdateComplete)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func RegistrationComplete(ue *context.UEContext) ([]byte, error) {
pdu := getRegistrationComplete(nil)
pdu, err := nas_control.EncodeNasPduWithSecurity(ue, pdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true, false)
if err != nil {
return nil, fmt.Errorf("Error encoding %s IMSI UE NAS Registration Complete Msg", ue.UeSecurity.Supi)
return nil, fmt.Errorf("error encoding %s IMSI UE NAS Registration Complete Msg", ue.UeSecurity.Supi)
}

return pdu, nil
Expand Down
6 changes: 4 additions & 2 deletions internal/control_test_engine/ue/nas/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ func InitConfigurationUpdateComplete(ue *context.UEContext) {
log.Info("[UE] Initiating Configuration Update Complete")

// trigger Configuration Update Complete.
identityResponse := mm_5gs.ConfigurationUpdateComplete(ue)

identityResponse, err := mm_5gs.ConfigurationUpdateComplete(ue)
if err != nil {
log.Fatal("[UE][NAS] Error sending Configuration Update Complete: ", err)
}
// send to GNB.
sender.SendToGnb(ue, identityResponse)
}
Expand Down

0 comments on commit 6e163a5

Please sign in to comment.