Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
Tenjin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nawasan Wisitsingkhon
Tenjin
Commits
eda2a361
Commit
eda2a361
authored
Aug 07, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cli/feature: run multiple port
parent
3963dd58
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
cli_system.rs
src/cli/cli_system.rs
+21
-9
No files found.
src/cli/cli_system.rs
View file @
eda2a361
use
clap
::{
command
,
Parser
,
Subcommand
};
use
crate
::{
example
::{
Controller10
,
Controller13
},
openflow
::{
ofp10
::
ControllerFrame10
,
ofp13
::
ControllerFrame13
},
};
use
clap
::{
command
,
Parser
,
Subcommand
};
use
std
::
thread
;
#[derive(Parser)]
#[command(author,
version,
about,
long_about
=
None)]
...
...
@@ -18,8 +18,8 @@ enum Commands {
Run
{
#[command(subcommand)]
controller
:
Option
<
Controllers
>
,
#[arg(default_value
_t
=
6633
,
short
=
'p'
,
long
)]
port
:
u16
,
#[arg(default_value
s_t
=
[
6633
,
6653
]
,
short
=
'p'
,
long
,
value_delimiter
=
','
)]
port
:
Vec
<
u16
>
,
#[arg(
default_value
=
"127.0.0.1"
,
short
=
'l'
,
...
...
@@ -47,14 +47,26 @@ pub fn system() {
port
,
listen
,
}
=>
{
let
addr
=
format!
(
"{}:{}"
,
listen
.as_str
(),
port
.to_string
());
match
controller
{
// creat runner function to run inside thread spawn
let
runner
=
match
controller
{
Some
(
controller
)
=>
match
controller
{
Controllers
::
Ctrl13
=>
Controller13
::
new
()
.listener
(
&
addr
),
Controllers
::
Ctrl10
=>
Controller10
::
new
()
.listener
(
&
addr
),
Controllers
::
Ctrl13
=>
|
addr
:
&
str
|
Controller13
::
new
()
.listener
(
addr
),
Controllers
::
Ctrl10
=>
|
addr
:
&
str
|
Controller10
::
new
()
.listener
(
addr
),
},
// Set Default Controller at here
None
=>
Controller13
::
new
()
.listener
(
&
addr
),
None
=>
|
addr
:
&
str
|
Controller13
::
new
()
.listener
(
addr
),
};
// spawn and run threads
let
mut
thread_list
=
Vec
::
new
();
for
p
in
port
.iter
()
{
let
addr
=
format!
(
"{}:{}"
,
listen
,
p
);
let
t
=
thread
::
spawn
(
move
||
{
runner
(
&
addr
);
});
thread_list
.push
(
t
);
}
for
th
in
thread_list
{
let
_
=
th
.join
();
}
}
}
...
...
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