-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14388c3
commit 2b865c6
Showing
14 changed files
with
693 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
control: | ||
uri: "http://192.0.2.1:8080" | ||
bind-addr: "192.0.2.1:8080" | ||
ran: | ||
bind-addr: "198.51.100.1:1234" | ||
gnbs: | ||
- "http://192.0.2.2:8080" | ||
pdu-sessions: | ||
- gnb: "http://192.0.2.2:8080" | ||
dnn: "nextmn-lite" | ||
|
||
logger: | ||
level: "debug" | ||
level: "trace" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// 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 app | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/nextmn/json-api/jsonapi" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type Cli struct { | ||
Radio *Radio | ||
PduSessions *PduSessions | ||
} | ||
|
||
func NewCli(radio *Radio, pduSessions *PduSessions) *Cli { | ||
return &Cli{ | ||
Radio: radio, | ||
PduSessions: pduSessions, | ||
} | ||
} | ||
|
||
type CliPeerMsg struct { | ||
Gnb jsonapi.ControlURI `json:"gnb"` | ||
Dnn string `json:"dnn"` | ||
} | ||
|
||
// Allow to peer to a gNB | ||
func (cli *Cli) RadioPeer(c *gin.Context) { | ||
var peer CliPeerMsg | ||
if err := c.BindJSON(&peer); err != nil { | ||
logrus.WithError(err).Error("could not deserialize") | ||
c.JSON(http.StatusBadRequest, jsonapi.MessageWithError{Message: "could not deserialize", Error: err}) | ||
return | ||
} | ||
if err := cli.Radio.InitPeer(c, peer.Gnb); err != nil { | ||
logrus.WithError(err).Error("could not perform radio peer init") | ||
c.JSON(http.StatusInternalServerError, jsonapi.MessageWithError{Message: "could not perform radio peer init", Error: err}) | ||
return | ||
} | ||
|
||
// TODO: handle gnb failure | ||
|
||
c.Status(http.StatusNoContent) | ||
} | ||
|
||
func (cli *Cli) PsEstablish(c *gin.Context) { | ||
var peer CliPeerMsg | ||
if err := c.BindJSON(&peer); err != nil { | ||
logrus.WithError(err).Error("could not deserialize") | ||
c.JSON(http.StatusBadRequest, jsonapi.MessageWithError{Message: "could not deserialize", Error: err}) | ||
return | ||
} | ||
// TODO: first, check if radio link is established | ||
|
||
if err := cli.PduSessions.InitEstablish(c, peer.Gnb, peer.Dnn); err != nil { | ||
logrus.WithError(err).Error("could not perform pdu session establishment") | ||
c.JSON(http.StatusInternalServerError, jsonapi.MessageWithError{Message: "could not perform pdu session establishment", Error: err}) | ||
return | ||
} | ||
|
||
// TODO: handle gnb failure | ||
|
||
c.Status(http.StatusNoContent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.