Skip to content

Commit

Permalink
Add debug information
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Jan 10, 2025
1 parent e1a0020 commit 0818be4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/radio/radio.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ func (r *Radio) UpdateRoute(ueIp netip.Addr, oldGnb jsonapi.ControlURI, newGnb j
return nil
}

func (r *Radio) GetRoutes() map[netip.Addr]jsonapi.ControlURI {
sessions := make(map[netip.Addr]jsonapi.ControlURI)
r.routingTable.Range(func(key, value any) bool {
sessions[key.(netip.Addr)] = value.(jsonapi.ControlURI)
logrus.WithFields(logrus.Fields{
"key": key.(netip.Addr),
"value": value.(jsonapi.ControlURI),
}).Trace("Creating ps/status response")
return true
})
return sessions
}

func (r *Radio) Write(pkt []byte, srv *net.UDPConn, ue netip.Addr) error {
gnb, ok := r.routingTable.Load(ue)
if !ok {
Expand Down
1 change: 1 addition & 0 deletions internal/session/pdu_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func NewPduSessions(control jsonapi.ControlURI, r *radio.Radio, reqPs []config.P
}

func (p *PduSessions) Register(e *gin.Engine) {
e.GET("/ps", p.Status)
e.POST("/ps/establishment-accept", p.EstablishmentAccept)
e.POST("/ps/handover-command", p.HandoverCommand)
}
Expand Down
19 changes: 19 additions & 0 deletions internal/session/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 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 session

import (
"net/http"

"github.com/gin-gonic/gin"
)

func (p *PduSessions) Status(c *gin.Context) {
sessions := p.radio.GetRoutes()

c.Header("Cache-Control", "no-cache")
c.JSON(http.StatusOK, sessions)
}

0 comments on commit 0818be4

Please sign in to comment.