Skip to content

Commit a36ba0a

Browse files
committed
Add n1n2 api for Handover; close #23
1 parent 391cb79 commit a36ba0a

12 files changed

+211
-7
lines changed

jsonapi/control_uri.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type ControlURI struct {
1616
}
1717

1818
func (u *ControlURI) UnmarshalText(text []byte) error {
19+
if len(text) == 0 {
20+
return fmt.Errorf("Control URI should not be empty.")
21+
}
1922
if text[len(text)-1] == '/' {
2023
return fmt.Errorf("Control URI should not contains trailing slash.")
2124
}

jsonapi/fteid.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package jsonapi
7+
8+
import "net/netip"
9+
10+
type Fteid struct {
11+
Addr netip.Addr `json:"addr"`
12+
Teid uint32 `json:"teid"`
13+
}
14+
15+
func NewFteid(addr netip.Addr, teid uint32) *Fteid {
16+
return &Fteid{
17+
Addr: addr,
18+
Teid: teid,
19+
}
20+
}

jsonapi/n1n2/handover_command.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
12+
// HandoverCommand is sent by the CP to the source gNB to start the execution of handover, and forwarded to the UE
13+
type HandoverCommand struct {
14+
// Header
15+
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
16+
Cp jsonapi.ControlURI `json:"cp"`
17+
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
18+
19+
// Handover Command
20+
Sessions []Session `json:"sessions"` // contains new ForwardDownlinkFteid
21+
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
22+
}

jsonapi/n1n2/handover_confirm.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
12+
// HandoverConfirm is send by the target UE to the target gNB after the UE is synchronized to the new cell
13+
type HandoverConfirm struct {
14+
// Header
15+
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
16+
Cp jsonapi.ControlURI `json:"cp"`
17+
18+
// Handover Confirm
19+
Sessions []Session `json:"sessions"`
20+
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
21+
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
22+
}

jsonapi/n1n2/handover_notify.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
12+
// HandoverNotify is send by the target gNB to the CP after handover have been confirmed by the UE
13+
type HandoverNotify struct {
14+
// Header
15+
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
16+
Cp jsonapi.ControlURI `json:"cp"`
17+
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
18+
19+
// Handover Notify
20+
Sessions []Session `json:"sessions"`
21+
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
22+
}

jsonapi/n1n2/handover_request.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
12+
// HandoverRequest is send by the CP to the target gNB during the handover preparation phase
13+
type HandoverRequest struct {
14+
// Header
15+
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
16+
Cp jsonapi.ControlURI `json:"cp"`
17+
TargetgNB jsonapi.ControlURI `json:"target-gnb"`
18+
19+
// Handover Request
20+
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
21+
Sessions []Session `json:"sessions"` // contains new UL FTeid
22+
}

jsonapi/n1n2/handover_request_ack.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
12+
// HandoverRequestAck is send by the target gNB to the CP in response to an HandoverRequest
13+
type HandoverRequestAck struct {
14+
// Header
15+
Cp jsonapi.ControlURI `json:"cp"`
16+
TargetgNB jsonapi.ControlURI `json:"target-gnb"`
17+
18+
// Handover Request Ack
19+
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
20+
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
21+
Sessions []Session `json:"sessions"` // contains new DL FTeid
22+
}

jsonapi/n1n2/handover_required.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
12+
// HandoverRequired is send by the source gNB to the CP to start the handover preparation phase
13+
type HandoverRequired struct {
14+
// Header
15+
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
16+
Cp jsonapi.ControlURI `json:"cp"`
17+
18+
// Handover Required content
19+
Ue jsonapi.ControlURI `json:"ue"`
20+
Sessions []Session `json:"sessions"` // list of all pdu sessions of the UE to be moved
21+
TargetgNB jsonapi.ControlURI `json:"target-gnb"`
22+
}

jsonapi/n1n2/n2_pdu_session_req_msg.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
package n1n2
77

88
import (
9-
"net/netip"
10-
119
"github.com/nextmn/json-api/jsonapi"
1210
)
1311

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

1917
// Uplink FTEID: the gNB will establish an Uplink GTP Tunnel using the following
20-
Upf netip.Addr `json:"upf"`
21-
UplinkTeid uint32 `json:"uplink-teid"`
18+
UplinkFteid jsonapi.Fteid `json:"uplink-fteid"`
2219
}

jsonapi/n1n2/n2_pdu_session_resp_msg.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55

66
package n1n2
77

8-
import "net/netip"
8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
911

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

1416
// Downlink FTEID: the CP will use this to configure a downlink GTP Tunnel in Upf-i
15-
DownlinkTeid uint32 `json:"downlink-teid"`
16-
Gnb netip.Addr `json:"gnb"`
17+
DownlinkFteid jsonapi.Fteid `json:"downlink-fteid"`
1718
}

jsonapi/n1n2/session.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2
7+
8+
import (
9+
"net/netip"
10+
11+
"github.com/nextmn/json-api/jsonapi"
12+
)
13+
14+
type Session struct {
15+
Addr netip.Addr `json:"ue-addr"`
16+
Dnn string `json:"dnn"`
17+
UplinkFteid *jsonapi.Fteid `json:"uplink-fteid,omitempty"`
18+
DownlinkFteid *jsonapi.Fteid `json:"downlink-fteid,omitempty"`
19+
20+
// when ForwardDownlinkFteid is not empty,
21+
// PDUs received on DownlinkFteid must be forwarded to it
22+
ForwardDownlinkFteid *jsonapi.Fteid `json:"forward-fteid,omitempty"`
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package n1n2_test
7+
8+
import (
9+
"encoding/json"
10+
"testing"
11+
12+
"github.com/nextmn/json-api/jsonapi/n1n2"
13+
)
14+
15+
func TestSession(t *testing.T) {
16+
s := &n1n2.Session{}
17+
if err := json.Unmarshal([]byte("{\"ue-addr\": \"127.0.0.1\", \"uplink-fteid\": {\"addr\": \"127.0.0.2\", \"teid\": 80}}"), s); err != nil {
18+
t.Errorf("Session with only uplink FTeid could not be unmarshaled")
19+
}
20+
21+
if s.DownlinkFteid != nil {
22+
t.Errorf("Downlink Fteid was not defined but is not nil")
23+
}
24+
if s.UplinkFteid == nil {
25+
t.Errorf("Uplink Fteid was defined but is nil")
26+
}
27+
28+
}

0 commit comments

Comments
 (0)