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
23a5117b
Commit
23a5117b
authored
Mar 31, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Options parser improvement
parent
a3248cc4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
24 deletions
+43
-24
src/app/cli_cmd.cpp
src/app/cli_cmd.cpp
+11
-10
src/cli.cpp
src/cli.cpp
+1
-1
src/gnb.cpp
src/gnb.cpp
+9
-3
src/ue.cpp
src/ue.cpp
+3
-3
src/utils/options.cpp
src/utils/options.cpp
+15
-4
src/utils/options.hpp
src/utils/options.hpp
+4
-3
No files found.
src/app/cli_cmd.cpp
View file @
23a5117b
...
...
@@ -120,22 +120,22 @@ static std::optional<opt::OptionsResult> ParseCliCommandCommon(OrderedMap<std::s
static
opt
::
OptionsDescription
DefaultDesc
(
const
std
::
string
&
subCommand
,
const
CmdEntry
&
entry
)
{
return
{{},
{},
entry
.
descriptionText
,
{},
subCommand
,
{
entry
.
usageText
},
entry
.
helpIfEmpty
,
true
};
return
{{},
{},
entry
.
descriptionText
,
{},
subCommand
,
{
entry
.
usageText
},
{},
entry
.
helpIfEmpty
,
true
};
}
static
opt
::
OptionsDescription
DescForPsEstablish
(
const
std
::
string
&
subCommand
,
const
CmdEntry
&
entry
)
{
std
::
string
usage1
=
"<session-type> [options]"
;
std
::
string
usage2
=
"IPv4 --sst 1 --sd 1 --dnn internet"
;
std
::
string
usage3
=
"IPv4 --emergency"
;
std
::
string
example1
=
"IPv4 --sst 1 --sd 1 --dnn internet"
;
std
::
string
example2
=
"IPv4 --emergency"
;
auto
res
=
opt
::
OptionsDescription
{
{},
{},
entry
.
descriptionText
,
{},
subCommand
,
{
usage1
,
usage2
,
usage3
},
entry
.
helpIfEmpty
,
true
};
{},
{},
entry
.
descriptionText
,
{},
subCommand
,
{
entry
.
usageText
},
{
example1
,
example2
},
entry
.
helpIfEmpty
,
true
};
res
.
items
.
emplace_back
(
std
::
nullopt
,
"sst"
,
"SST value of the PDU session
(Optional)
"
,
"value"
);
res
.
items
.
emplace_back
(
std
::
nullopt
,
"sd"
,
"SD value of the PDU session
(Optional)
"
,
"value"
);
res
.
items
.
emplace_back
(
'n'
,
"dnn"
,
"DNN/APN value of the PDU session
(Optional)
"
,
"apn"
);
res
.
items
.
emplace_back
(
'e'
,
"emergency"
,
"Request as an emergency session
(Optional)
"
,
std
::
nullopt
);
res
.
items
.
emplace_back
(
std
::
nullopt
,
"sst"
,
"SST value of the PDU session"
,
"value"
);
res
.
items
.
emplace_back
(
std
::
nullopt
,
"sd"
,
"SD value of the PDU session"
,
"value"
);
res
.
items
.
emplace_back
(
'n'
,
"dnn"
,
"DNN/APN value of the PDU session"
,
"apn"
);
res
.
items
.
emplace_back
(
'e'
,
"emergency"
,
"Request as an emergency session"
,
std
::
nullopt
);
return
res
;
}
...
...
@@ -158,7 +158,8 @@ static OrderedMap<std::string, CmdEntry> g_ueCmdEntries = {
{
"timers"
,
{
"Dump current status of the timers in the UE"
,
""
,
DefaultDesc
,
false
}},
{
"deregister"
,
{
"Perform a de-registration by the UE"
,
"<normal|disable-5g|switch-off|remove-sim>"
,
DefaultDesc
,
true
}},
{
"ps-establish"
,
{
"Trigger a PDU session establishment procedure"
,
""
,
DescForPsEstablish
,
true
}},
{
"ps-establish"
,
{
"Trigger a PDU session establishment procedure"
,
"<session-type> [options]"
,
DescForPsEstablish
,
true
}},
{
"ps-release"
,
{
"Trigger a PDU session release procedure"
,
"<pdu-session-id>..."
,
DefaultDesc
,
true
}},
{
"ps-release-all"
,
{
"Trigger PDU session release procedures for all active sessions"
,
""
,
DefaultDesc
,
false
}},
};
...
...
src/cli.cpp
View file @
23a5117b
...
...
@@ -134,7 +134,7 @@ static void ReadOptions(int argc, char **argv)
{
opt
::
OptionsDescription
desc
{
"UERANSIM"
,
cons
::
Tag
,
"Command Line Interface"
,
cons
::
Owner
,
"nr-cli"
,
{
"<node-name> [option...]"
,
"--dump"
},
true
,
false
};
{},
true
,
false
};
opt
::
OptionItem
itemDump
=
{
'd'
,
"dump"
,
"List all UE and gNBs in the environment"
,
std
::
nullopt
};
opt
::
OptionItem
itemExec
=
{
'e'
,
"exec"
,
"Execute the given command directly without an interactive shell"
,
...
...
src/gnb.cpp
View file @
23a5117b
...
...
@@ -78,9 +78,15 @@ static nr::gnb::GnbConfig *ReadConfigYaml()
static
void
ReadOptions
(
int
argc
,
char
**
argv
)
{
opt
::
OptionsDescription
desc
{
cons
::
Project
,
cons
::
Tag
,
"5G-SA gNB implementation"
,
cons
::
Owner
,
"nr-gnb"
,
{
"-c <config-file> [option...]"
},
true
,
false
};
opt
::
OptionsDescription
desc
{
cons
::
Project
,
cons
::
Tag
,
"5G-SA gNB implementation"
,
cons
::
Owner
,
"nr-gnb"
,
{
"-c <config-file> [option...]"
},
{},
true
,
false
};
opt
::
OptionItem
itemConfigFile
=
{
'c'
,
"config"
,
"Use specified configuration file for gNB"
,
"config-file"
};
opt
::
OptionItem
itemDisableCmd
=
{
'l'
,
"disable-cmd"
,
"Disable command line functionality for this instance"
,
...
...
src/ue.cpp
View file @
23a5117b
...
...
@@ -220,9 +220,9 @@ static nr::ue::UeConfig *ReadConfigYaml()
static
void
ReadOptions
(
int
argc
,
char
**
argv
)
{
opt
::
OptionsDescription
desc
{
cons
::
Project
,
cons
::
Tag
,
"5G-SA UE implementation"
,
cons
::
Owner
,
"nr-ue"
,
{
"-c <config-file> [option...]"
},
true
,
false
};
opt
::
OptionsDescription
desc
{
cons
::
Project
,
cons
::
Tag
,
"5G-SA UE implementation"
,
cons
::
Owner
,
"nr-ue"
,
{
"-c <config-file> [option...]"
},
{
},
true
,
false
};
opt
::
OptionItem
itemConfigFile
=
{
'c'
,
"config"
,
"Use specified configuration file for UE"
,
"config-file"
};
opt
::
OptionItem
itemImsi
=
{
'i'
,
"imsi"
,
"Use specified IMSI number instead of provided one"
,
"imsi"
};
...
...
src/utils/options.cpp
View file @
23a5117b
...
...
@@ -264,10 +264,21 @@ void opt::OptionsResult::showHelp() const
ostream
<<
std
::
endl
;
ostream
<<
"Usage:"
<<
std
::
endl
;
for
(
auto
&
usage
:
m_description
.
usages
)
ostream
<<
" "
<<
m_description
.
programName
<<
" "
<<
usage
<<
std
::
endl
;
ostream
<<
std
::
endl
;
if
(
!
m_description
.
usages
.
empty
())
{
ostream
<<
"Usage:"
<<
std
::
endl
;
for
(
auto
&
usage
:
m_description
.
usages
)
ostream
<<
" "
<<
m_description
.
programName
<<
" "
<<
usage
<<
std
::
endl
;
ostream
<<
std
::
endl
;
}
if
(
!
m_description
.
examples
.
empty
())
{
ostream
<<
(
m_description
.
examples
.
size
()
>
1
?
"Examples:"
:
"Example:"
)
<<
std
::
endl
;
for
(
auto
&
example
:
m_description
.
examples
)
ostream
<<
" "
<<
m_description
.
programName
<<
" "
<<
example
<<
std
::
endl
;
ostream
<<
std
::
endl
;
}
std
::
vector
<
OptionItem
>
items
=
m_description
.
items
;
if
(
!
m_description
.
hideDefaultOptionsInUsage
)
...
...
src/utils/options.hpp
View file @
23a5117b
...
...
@@ -72,15 +72,16 @@ struct OptionsDescription
std
::
string
programName
{};
std
::
vector
<
OptionItem
>
items
{};
std
::
vector
<
std
::
string
>
usages
{};
std
::
vector
<
std
::
string
>
examples
{};
bool
helpIfEmpty
{};
bool
hideDefaultOptionsInUsage
{};
OptionsDescription
(
std
::
string
projectName
,
std
::
string
version
,
std
::
string
appDescription
,
std
::
string
copyright
,
std
::
string
programName
,
std
::
vector
<
std
::
string
>
usages
,
bool
helpIfEmpty
,
bool
hideDefaultOptionsInUsage
)
std
::
string
programName
,
std
::
vector
<
std
::
string
>
usages
,
std
::
vector
<
std
::
string
>
examples
,
bool
h
elpIfEmpty
,
bool
h
ideDefaultOptionsInUsage
)
:
projectName
(
std
::
move
(
projectName
)),
version
(
std
::
move
(
version
)),
appDescription
(
std
::
move
(
appDescription
)),
copyright
(
std
::
move
(
copyright
)),
programName
(
std
::
move
(
programName
)),
usages
(
std
::
move
(
usages
)),
helpIfEmpty
(
helpIfEmpty
),
hideDefaultOptionsInUsage
(
hideDefaultOptionsInUsage
)
examples
(
std
::
move
(
examples
)),
helpIfEmpty
(
helpIfEmpty
),
hideDefaultOptionsInUsage
(
hideDefaultOptionsInUsage
)
{
}
};
...
...
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