Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Dec 23, 2024
1 parent a64418a commit 8c8aa22
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 20 deletions.
20 changes: 20 additions & 0 deletions jsonapi/fteid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package jsonapi

import "net/netip"

type Fteid struct {
Addr netip.Addr `json:"addr"`
Teid uint32 `json:"teid"`
}

func NewFteid(addr netip.Addr, teid uint32) *Fteid {
return &Fteid{
Addr: addr,
Teid: teid,
}
}
13 changes: 7 additions & 6 deletions jsonapi/n1n2/handover_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
package n1n2

import (
"net/netip"

"github.com/nextmn/json-api/jsonapi"
)

// Handovercommand is sent by the CP to the source gNB to start the execution of handover, and forwarded to the UE
// HandoverCommand is sent by the CP to the source gNB to start the execution of handover, and forwarded to the UE
type HandoverCommand struct {
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`
Sessions []netip.Addr `json:"sessions"`
GNBSource jsonapi.ControlURI `json:"gnb-source"`
GNBTarget jsonapi.ControlURI `json:"gnb-target"`
SourceGnb jsonapi.ControlURI `json:"source-gnb"`

// Handover Command
Sessions []Session `json:"sessions"` // contains new ForwardDownlinkFteid
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
}
13 changes: 12 additions & 1 deletion jsonapi/n1n2/handover_confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverConfirm is send by the target UE to the target gNB after the UE is synchronized to the new cell
type HandoverConfirm struct {
Command HandoverCommand `json:"handover-command"`
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`

// Handover Confirm
Sessions []Session `json:"sessions"`
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
}
13 changes: 12 additions & 1 deletion jsonapi/n1n2/handover_notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverNotify is send by the target gNB to the CP after handover have been confirmed by the UE
type HandoverNotify struct {
Command HandoverCommand `json:"handover-command"`
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`
TargetGnb jsonapi.ControlURI `json:"target-gnb"`

// Handover Notify
Sessions []Session `json:"sessions"`
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
}
11 changes: 11 additions & 0 deletions jsonapi/n1n2/handover_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverRequest is send by the CP to the target gNB during the handover preparation phase
type HandoverRequest struct {
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"ue-ctrl"`
TargetgNB jsonapi.ControlURI `json:"ue-ctrl"`

// Handover Request
Sessions []Session `json:"sessions"` // contains new UL FTeid
}
12 changes: 12 additions & 0 deletions jsonapi/n1n2/handover_request_ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverRequestAck is send by the target gNB to the CP in response to an HandoverRequest
type HandoverRequestAck struct {
// Header
Cp jsonapi.ControlURI `json:"cp"`
TargetgNB jsonapi.ControlURI `json:"target-gnb"`

// Handover Request Ack
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Sessions []Session `json:"sessions"` // contains new DL FTeid
}
13 changes: 8 additions & 5 deletions jsonapi/n1n2/handover_required.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
package n1n2

import (
"net/netip"

"github.com/nextmn/json-api/jsonapi"
)

// HandoverRequired is send by the source gNB to the CP to start the handover preparation phase
type HandoverRequired struct {
Ue jsonapi.ControlURI `json:"ue"`
PduSessions []netip.Addr `json:"pdu-sessions"` // list of all pdu sessions of the UE to be moved
TargetgNB jsonapi.ControlURI `json:"target-gnb"`
// Header
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
Cp jsonapi.ControlURI `json:"cp"`

// Handover Required content
Ue jsonapi.ControlURI `json:"ue"`
Sessions []Session `json:"sessions"` // list of all pdu sessions of the UE to be moved
TargetgNB jsonapi.ControlURI `json:"target-gnb"`
}
5 changes: 1 addition & 4 deletions jsonapi/n1n2/n2_pdu_session_req_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package n1n2

import (
"net/netip"

"github.com/nextmn/json-api/jsonapi"
)

Expand All @@ -17,6 +15,5 @@ type N2PduSessionReqMsg struct {
UeInfo PduSessionEstabAcceptMsg `json:"ue-info"` // information to forward to the UE

// Uplink FTEID: the gNB will establish an Uplink GTP Tunnel using the following
Upf netip.Addr `json:"upf"`
UplinkTeid uint32 `json:"uplink-teid"`
UplinkFteid jsonapi.Fteid `json:"uplink-fteid"`
}
7 changes: 4 additions & 3 deletions jsonapi/n1n2/n2_pdu_session_resp_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

package n1n2

import "net/netip"
import (
"github.com/nextmn/json-api/jsonapi"
)

// N2PduSessionRespMsg is sent to the CP by the gNB as a response of N2PduSessionReqMsg.
type N2PduSessionRespMsg struct {
UeInfo PduSessionEstabAcceptMsg `json:"ue-info"` // used to identify the PDU Session

// Downlink FTEID: the CP will use this to configure a downlink GTP Tunnel in Upf-i
DownlinkTeid uint32 `json:"downlink-teid"`
Gnb netip.Addr `json:"gnb"`
DownlinkFteid jsonapi.Fteid `json:"downlink-fteid"`
}
23 changes: 23 additions & 0 deletions jsonapi/n1n2/session.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"net/netip"

"github.com/nextmn/json-api/jsonapi"
)

type Session struct {
Addr netip.Addr `json:"ue-addr"`
Dnn string `json:"dnn"`
UplinkFteid *jsonapi.Fteid `json:"uplink-fteid,omitempty"`
DownlinkFteid *jsonapi.Fteid `json:"downlink-fteid,omitempty"`

// when ForwardDownlinkFteid is not empty,
// PDUs received on DownlinkFteid must be forwarded to it
ForwardDownlinkFteid *jsonapi.Fteid `json:"forward-fteid,omitempty"`
}
28 changes: 28 additions & 0 deletions jsonapi_test/n1n2_test/session_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2_test

import (
"encoding/json"
"testing"

"github.com/nextmn/json-api/jsonapi/n1n2"
)

func TestSession(t *testing.T) {
s := &n1n2.Session{}
if err := json.Unmarshal([]byte("{\"ue-addr\": \"127.0.0.1\", \"uplink-fteid\": {\"addr\": \"127.0.0.2\", \"teid\": 80}}"), s); err != nil {
t.Errorf("Session with only uplink FTeid could not be unmarshaled")
}

if s.DownlinkFteid != nil {
t.Errorf("Downlink Fteid was not defined but is not nil")
}
if s.UplinkFteid == nil {
t.Errorf("Uplink Fteid was defined but is nil")
}

}

0 comments on commit 8c8aa22

Please sign in to comment.