Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
63a3031c
Commit
63a3031c
authored
Feb 13, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gNB CLI improvement
parent
43974a15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
153 additions
and
0 deletions
+153
-0
src/gnb/app/cmd_handler.cpp
src/gnb/app/cmd_handler.cpp
+122
-0
src/gnb/app/cmd_handler.hpp
src/gnb/app/cmd_handler.hpp
+31
-0
No files found.
src/gnb/app/cmd_handler.cpp
0 → 100644
View file @
63a3031c
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include "cmd_handler.hpp"
#include <gnb/app/task.hpp>
#include <gnb/gtp/task.hpp>
#include <gnb/mr/task.hpp>
#include <gnb/ngap/task.hpp>
#include <gnb/rrc/task.hpp>
#include <gnb/sctp/task.hpp>
#include <utils/common.hpp>
#define PAUSE_CONFIRM_TIMEOUT 3000
#define PAUSE_POLLING 10
namespace
nr
::
gnb
{
void
GnbCmdHandler
::
PauseTasks
(
TaskBase
&
base
)
{
base
.
gtpTask
->
requestPause
();
base
.
mrTask
->
requestPause
();
base
.
ngapTask
->
requestPause
();
base
.
rrcTask
->
requestPause
();
base
.
sctpTask
->
requestPause
();
}
void
GnbCmdHandler
::
UnpauseTasks
(
TaskBase
&
base
)
{
base
.
gtpTask
->
requestUnpause
();
base
.
mrTask
->
requestUnpause
();
base
.
ngapTask
->
requestUnpause
();
base
.
rrcTask
->
requestUnpause
();
base
.
sctpTask
->
requestUnpause
();
}
bool
GnbCmdHandler
::
IsAllPaused
(
TaskBase
&
base
)
{
if
(
!
base
.
gtpTask
->
isPauseConfirmed
())
return
false
;
if
(
!
base
.
mrTask
->
isPauseConfirmed
())
return
false
;
if
(
!
base
.
ngapTask
->
isPauseConfirmed
())
return
false
;
if
(
!
base
.
rrcTask
->
isPauseConfirmed
())
return
false
;
if
(
!
base
.
sctpTask
->
isPauseConfirmed
())
return
false
;
return
true
;
}
void
GnbCmdHandler
::
HandleCmd
(
TaskBase
&
base
,
NwGnbCliCommand
&
msg
)
{
PauseTasks
(
base
);
uint64_t
currentTime
=
utils
::
CurrentTimeMillis
();
uint64_t
endTime
=
currentTime
+
PAUSE_CONFIRM_TIMEOUT
;
bool
isPaused
=
false
;
while
(
currentTime
<
endTime
)
{
currentTime
=
utils
::
CurrentTimeMillis
();
if
(
IsAllPaused
(
base
))
{
isPaused
=
true
;
break
;
}
utils
::
Sleep
(
PAUSE_POLLING
);
}
if
(
!
isPaused
)
{
msg
.
sendError
(
"gNB is unable process command due to pausing timeout"
);
}
else
{
HandleCmdImpl
(
base
,
msg
);
}
UnpauseTasks
(
base
);
}
void
GnbCmdHandler
::
HandleCmdImpl
(
TaskBase
&
base
,
NwGnbCliCommand
&
msg
)
{
switch
(
msg
.
cmd
->
present
)
{
case
app
:
:
GnbCliCommand
::
STATUS
:
{
msg
.
sendResult
(
base
.
appTask
->
m_statusInfo
.
toString
());
break
;
}
case
app
:
:
GnbCliCommand
::
INFO
:
{
msg
.
sendResult
(
base
.
config
->
toString
());
break
;
}
case
app
:
:
GnbCliCommand
::
AMF_LIST
:
{
std
::
stringstream
ss
{};
for
(
auto
&
amf
:
base
.
ngapTask
->
m_amfCtx
)
ss
<<
"* amf-id: "
<<
amf
.
first
<<
"
\n
"
;
utils
::
Trim
(
ss
);
msg
.
sendResult
(
ss
.
str
());
break
;
}
case
app
:
:
GnbCliCommand
::
AMF_STATUS
:
{
if
(
base
.
ngapTask
->
m_amfCtx
.
count
(
msg
.
cmd
->
amfId
)
==
0
)
msg
.
sendError
(
"AMF not found with given ID"
);
else
{
auto
amf
=
base
.
ngapTask
->
m_amfCtx
[
msg
.
cmd
->
amfId
];
msg
.
sendResult
(
"state: "
+
std
::
to_string
((
int
)
amf
->
state
));
}
break
;
}
}
}
}
// namespace nr::gnb
\ No newline at end of file
src/gnb/app/cmd_handler.hpp
0 → 100644
View file @
63a3031c
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#pragma once
#include <gnb/nts.hpp>
#include <gnb/types.hpp>
namespace
nr
::
gnb
{
class
GnbCmdHandler
{
private:
static
void
PauseTasks
(
TaskBase
&
base
);
static
void
UnpauseTasks
(
TaskBase
&
base
);
static
bool
IsAllPaused
(
TaskBase
&
base
);
public:
static
void
HandleCmd
(
TaskBase
&
base
,
NwGnbCliCommand
&
msg
);
private:
static
void
HandleCmdImpl
(
TaskBase
&
base
,
NwGnbCliCommand
&
msg
);
};
}
// namespace nr::gnb
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment