Skip to content

Commit

Permalink
Sending Deregistration request when SIGTERM (#8)
Browse files Browse the repository at this point in the history
* Send Deregistration request when SIGTERM

* Fix config

---------

Co-authored-by: 123 <123>
  • Loading branch information
allen0091 authored Aug 12, 2024
1 parent b0c644c commit c2662c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/nwucp/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions internal/nwucp/handler/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -45,6 +46,7 @@ func Start() {
}()

<-signalChannel
nwucp_handler.SendDeregistration()
Terminate()
time.Sleep(2 * time.Second)
os.Exit(0)
Expand Down

0 comments on commit c2662c7

Please sign in to comment.