Skip to content

Commit 3029c9b

Browse files
committed
Add n1n2, and refactor
1 parent 9c4fb6c commit 3029c9b

30 files changed

+271
-65
lines changed

jsonapi/control_uri.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2024 Louis Royer and the NextMN-json-api contributors. All rights reserved.
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package jsonapi
67

78
import (

jsonapi/message.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2024 Louis Royer and the NextMN-json-api contributors. All rights reserved.
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package jsonapi
67

78
type Message struct {

jsonapi/message_with_error.go

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
1-
// Copyright 2024 Louis Royer and the NextMN-json-api contributors. All rights reserved.
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package jsonapi
67

8+
import (
9+
"encoding/json"
10+
"fmt"
11+
)
12+
713
type MessageWithError struct {
8-
Message string
9-
Error error
14+
Message string `json:"message"`
15+
Error error `json:"error"`
16+
}
17+
18+
func (u *MessageWithError) UnmarshalJSON(data []byte) error {
19+
a := make(map[string]string)
20+
err := json.Unmarshal(data, a)
21+
if err != nil {
22+
return err
23+
}
24+
msg, ok := a["message"]
25+
if !ok {
26+
return fmt.Errorf("Missing key `message` while unmarshaling MessageWithError")
27+
}
28+
u.Message = msg
29+
e, ok := a["error"]
30+
if !ok {
31+
return fmt.Errorf("Missing key `error` while unmarshaling MessageWithError")
32+
}
33+
u.Error = fmt.Errorf(e)
34+
return nil
35+
}
36+
37+
func (u MessageWithError) MarshalJSON() ([]byte, error) {
38+
return json.Marshal(map[string]string{
39+
"message": u.Message,
40+
"error": u.Error.Error(),
41+
})
1042
}

jsonapi/n1n2/RadioPeerMsg.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
// RadioPeerMsg is used to discover UEs/gNBs "radio" peers.
15+
type RadioPeerMsg struct {
16+
Control jsonapi.ControlURI `json:"control"`
17+
Data netip.AddrPort `json:"data"`
18+
}

jsonapi/n1n2/doc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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 allow to simulate N1/N2 interface using a REST API.
7+
package n1n2
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+
"net/netip"
10+
11+
"github.com/nextmn/json-api/jsonapi"
12+
)
13+
14+
// N2PduSessionReqMsg is sent by the CP to the gNB to establish a PDU Session.
15+
type N2PduSessionReqMsg struct {
16+
Cp jsonapi.ControlURI `json:"cp"`
17+
UeInfo PduSessionEstabAcceptMsg `json:"ue-info"` // information to forward to the UE
18+
19+
// 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"`
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 "net/netip"
9+
10+
// N2PduSessionRespMsg is sent to the CP by the gNB as a response of N2PduSessionReqMsg.
11+
type N2PduSessionRespMsg struct {
12+
UeInfo PduSessionEstabAcceptMsg `json:"ue-info"` // used to identify the PDU Session
13+
14+
// 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+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 "net/netip"
9+
10+
// PduSessionEstabAcceptMsg is sent to the UE by the gNB
11+
// when the PDU Session establishment is accepted.
12+
type PduSessionEstabAcceptMsg struct {
13+
Header PduSessionEstabReqMsg `json:"header"` // copy of the PDU Session Establishment Request Message
14+
Addr netip.Addr `json:"address"` // IP Address attributed to the UE for this PDU Session
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 "github.com/nextmn/json-api/jsonapi"
9+
10+
// PduSessionEstabReqMessage is sent by the UE to the gNB (then forwarded by the gNB to the CP)
11+
// to start the PDU Session Establishment Procedure.
12+
type PduSessionEstabReqMsg struct {
13+
Ue jsonapi.ControlURI `json:"ue"`
14+
Gnb jsonapi.ControlURI `json:"gnb"`
15+
Dnn string `json:"dnn"`
16+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright 2024 Louis Royer and the NextMN-json-api contributors. All rights reserved.
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5-
package jsonapi
5+
6+
package n4tosrv6
67

78
type Action struct {
89
SRH SRH `json:"srh"`

0 commit comments

Comments
 (0)