Commit b0041b32 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

change some cli and update readme

parent bcdb310e
...@@ -8,6 +8,7 @@ edition = "2021" ...@@ -8,6 +8,7 @@ edition = "2021"
readme = "README.md" readme = "README.md"
repository = "https://github.com/Arikato111/Tenjin" repository = "https://github.com/Arikato111/Tenjin"
categories = ["command-line-utilities"] categories = ["command-line-utilities"]
keywords = ["sdn", "cli", "openflow"]
[lib] [lib]
name = "tenjin" name = "tenjin"
......
...@@ -6,7 +6,37 @@ Software-defined networking with Rust. ...@@ -6,7 +6,37 @@ Software-defined networking with Rust.
To understand The software-defined networking well, I trying to create a simple SDN with Rust language to support Openflow 1.0 first and 1.3 later. To understand The software-defined networking well, I trying to create a simple SDN with Rust language to support Openflow 1.0 first and 1.3 later.
## Get started ## Run with command line
#### Run Controller by default (Controller13 with OpenFlow 1.3)
```bash
tenjin run
```
#### Run Controller10 with Openflow 1.0
```bash
tenjin run ctrl10
```
#### Run with specific port
```bash
tenjin run --port 6653
```
#### Show details of `run` command
```bash
tenjin run --help
```
## Run only Controller
You need to clone source code to your workspace and modify the code.
this code below is the example for run only Controller.
If you would like to modify Controller's code, it waiting for you at ./src/example/
### Openflow 1.3 ### Openflow 1.3
...@@ -16,10 +46,9 @@ To understand The software-defined networking well, I trying to create a simple ...@@ -16,10 +46,9 @@ To understand The software-defined networking well, I trying to create a simple
use tenjin::{example, openflow::ofp13::ControllerFrame13}; use tenjin::{example, openflow::ofp13::ControllerFrame13};
extern crate byteorder; extern crate byteorder;
fn main() -> Result<(), std::io::Error> { fn main() {
let controller = example::Controller13::new(); let controller = example::Controller13::new();
controller.listener("127.0.0.1:6633"); controller.listener("127.0.0.1:6633");
Ok(())
} }
``` ```
...@@ -43,10 +72,9 @@ import Controller10 into main func. ...@@ -43,10 +72,9 @@ import Controller10 into main func.
use tenjin::{example, openflow::ofp10::ControllerFrame10}; use tenjin::{example, openflow::ofp10::ControllerFrame10};
extern crate byteorder; extern crate byteorder;
fn main() -> Result<(), std::io::Error> { fn main() {
let controller = example::Controller10::new(); let controller = example::Controller10::new();
controller.listener("127.0.0.1:6633"); controller.listener("127.0.0.1:6633");
Ok(())
} }
``` ```
......
...@@ -22,11 +22,12 @@ enum Commands { ...@@ -22,11 +22,12 @@ enum Commands {
port: u16, port: u16,
#[arg( #[arg(
default_value = "127.0.0.1", default_value = "127.0.0.1",
short = 'a', short = 'l',
long = "address", long = "listen",
value_name = "ADDRESS",
help = "ip address" help = "ip address"
)] )]
address: String, listen: String,
}, },
} }
...@@ -44,9 +45,9 @@ pub fn system() { ...@@ -44,9 +45,9 @@ pub fn system() {
Commands::Run { Commands::Run {
controller, controller,
port, port,
address, listen,
} => { } => {
let addr = format!("{}:{}", address.as_str(), port.to_string()); let addr = format!("{}:{}", listen.as_str(), port.to_string());
match controller { match controller {
Some(controller) => match controller { Some(controller) => match controller {
Controllers::Ctrl13 => Controller13::new().listener(&addr), Controllers::Ctrl13 => Controller13::new().listener(&addr),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment