diff --git a/internal/nwucp/handler/handler.go b/internal/nwucp/handler/handler.go index 4fe45a8..ece5b2b 100644 --- a/internal/nwucp/handler/handler.go +++ b/internal/nwucp/handler/handler.go @@ -26,6 +26,7 @@ func HandleRegistrationAccept(n3ueSelf *context.N3UE, nasMsg *nas.Message) { naslog.Tracef("Get Registration Accept") n3ueSelf.RanUeContext.DLCount.AddOne() + n3ueSelf.GUTI = nasMsg.GmmMessage.RegistrationAccept.GUTI5G // send NAS Registration Complete Msg pdu := nasPacket.GetRegistrationComplete(nil) diff --git a/internal/nwucp/handler/send.go b/internal/nwucp/handler/send.go index 09f2eba..09064e4 100644 --- a/internal/nwucp/handler/send.go +++ b/internal/nwucp/handler/send.go @@ -7,9 +7,11 @@ import ( "github.com/free5gc/n3iwue/internal/packet/nasPacket" "github.com/free5gc/n3iwue/internal/packet/ngapPacket" "github.com/free5gc/n3iwue/internal/security" + context "github.com/free5gc/n3iwue/pkg/context" "github.com/free5gc/n3iwue/pkg/factory" "github.com/free5gc/nas" "github.com/free5gc/nas/nasMessage" + "github.com/free5gc/nas/nasType" "github.com/free5gc/openapi/models" ) @@ -60,3 +62,14 @@ func SendPduSessionEstablishmentRequest(ue *security.RanUeContext, naslog.Tracef("send nas complete") return nil } + +func SendDeregistration() { + n3ueContext := context.N3UESelf() + mobileIdentity5GS := nasType.MobileIdentity5GS{ + Len: n3ueContext.GUTI.Len, + Buffer: n3ueContext.GUTI.Octet[:], + } + deregistrationRequest := nasPacket.GetDeregistrationRequest(0x02, 0x01, 0x00, mobileIdentity5GS) + + SendNasMsg(n3ueContext.RanUeContext, n3ueContext.N3IWFRanUe.TCPConnection, deregistrationRequest) +} diff --git a/pkg/context/context.go b/pkg/context/context.go index b9cba2d..f0569be 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -47,6 +47,7 @@ type N3UE struct { CreatedIface []*netlink.Link CurrentState chan uint8 Kn3iwf []uint8 + GUTI *nasType.GUTI5G // Temporary data , used to create GreTunnel TemporaryXfrmiName string diff --git a/pkg/service/init.go b/pkg/service/init.go index f76cce0..bad5509 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -12,6 +12,7 @@ import ( "github.com/vishvananda/netlink" "github.com/free5gc/n3iwue/internal/logger" + nwucp_handler "github.com/free5gc/n3iwue/internal/nwucp/handler" "github.com/free5gc/n3iwue/internal/util" context "github.com/free5gc/n3iwue/pkg/context" "github.com/free5gc/n3iwue/pkg/factory" @@ -45,6 +46,7 @@ func Start() { }() <-signalChannel + nwucp_handler.SendDeregistration() Terminate() time.Sleep(2 * time.Second) os.Exit(0)