From 8c8aa22fc73e94dfb53dc24533928bbeaba47cb2 Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Thu, 19 Dec 2024 18:44:16 +0100 Subject: [PATCH] wip --- jsonapi/fteid.go | 20 ++++++++++++++++++ jsonapi/n1n2/handover_command.go | 13 ++++++------ jsonapi/n1n2/handover_confirm.go | 13 +++++++++++- jsonapi/n1n2/handover_notify.go | 13 +++++++++++- jsonapi/n1n2/handover_request.go | 11 ++++++++++ jsonapi/n1n2/handover_request_ack.go | 12 +++++++++++ jsonapi/n1n2/handover_required.go | 13 +++++++----- jsonapi/n1n2/n2_pdu_session_req_msg.go | 5 +---- jsonapi/n1n2/n2_pdu_session_resp_msg.go | 7 ++++--- jsonapi/n1n2/session.go | 23 ++++++++++++++++++++ jsonapi_test/n1n2_test/session_test.go | 28 +++++++++++++++++++++++++ 11 files changed, 138 insertions(+), 20 deletions(-) create mode 100644 jsonapi/fteid.go create mode 100644 jsonapi/n1n2/session.go create mode 100644 jsonapi_test/n1n2_test/session_test.go diff --git a/jsonapi/fteid.go b/jsonapi/fteid.go new file mode 100644 index 0000000..5184c57 --- /dev/null +++ b/jsonapi/fteid.go @@ -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, + } +} diff --git a/jsonapi/n1n2/handover_command.go b/jsonapi/n1n2/handover_command.go index b963d16..016a12b 100644 --- a/jsonapi/n1n2/handover_command.go +++ b/jsonapi/n1n2/handover_command.go @@ -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"` } diff --git a/jsonapi/n1n2/handover_confirm.go b/jsonapi/n1n2/handover_confirm.go index ec9c03a..52c59f3 100644 --- a/jsonapi/n1n2/handover_confirm.go +++ b/jsonapi/n1n2/handover_confirm.go @@ -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"` } diff --git a/jsonapi/n1n2/handover_notify.go b/jsonapi/n1n2/handover_notify.go index b7701ed..a3c3f01 100644 --- a/jsonapi/n1n2/handover_notify.go +++ b/jsonapi/n1n2/handover_notify.go @@ -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"` } diff --git a/jsonapi/n1n2/handover_request.go b/jsonapi/n1n2/handover_request.go index 4fbbd16..76d0402 100644 --- a/jsonapi/n1n2/handover_request.go +++ b/jsonapi/n1n2/handover_request.go @@ -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 } diff --git a/jsonapi/n1n2/handover_request_ack.go b/jsonapi/n1n2/handover_request_ack.go index b3a30f6..13b1e22 100644 --- a/jsonapi/n1n2/handover_request_ack.go +++ b/jsonapi/n1n2/handover_request_ack.go @@ -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 } diff --git a/jsonapi/n1n2/handover_required.go b/jsonapi/n1n2/handover_required.go index 24b456d..69a392d 100644 --- a/jsonapi/n1n2/handover_required.go +++ b/jsonapi/n1n2/handover_required.go @@ -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"` } diff --git a/jsonapi/n1n2/n2_pdu_session_req_msg.go b/jsonapi/n1n2/n2_pdu_session_req_msg.go index eab8118..7426ecc 100644 --- a/jsonapi/n1n2/n2_pdu_session_req_msg.go +++ b/jsonapi/n1n2/n2_pdu_session_req_msg.go @@ -6,8 +6,6 @@ package n1n2 import ( - "net/netip" - "github.com/nextmn/json-api/jsonapi" ) @@ -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"` } diff --git a/jsonapi/n1n2/n2_pdu_session_resp_msg.go b/jsonapi/n1n2/n2_pdu_session_resp_msg.go index 0b8e5d3..d78f43a 100644 --- a/jsonapi/n1n2/n2_pdu_session_resp_msg.go +++ b/jsonapi/n1n2/n2_pdu_session_resp_msg.go @@ -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"` } diff --git a/jsonapi/n1n2/session.go b/jsonapi/n1n2/session.go new file mode 100644 index 0000000..68047b4 --- /dev/null +++ b/jsonapi/n1n2/session.go @@ -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"` +} diff --git a/jsonapi_test/n1n2_test/session_test.go b/jsonapi_test/n1n2_test/session_test.go new file mode 100644 index 0000000..ab6dec9 --- /dev/null +++ b/jsonapi_test/n1n2_test/session_test.go @@ -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") + } + +}