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
15388f3c
Commit
15388f3c
authored
Apr 17, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prepare for packet_out
parent
ecb47c2e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
main.rs
src/main.rs
+9
-4
controller.rs
src/openflow/controller.rs
+7
-2
No files found.
src/main.rs
View file @
15388f3c
use
tenjin
::
etherparser
::
ethernet
::
EthernetFrame
;
use
tenjin
::
openflow
::{
Controller
,
Msg
,
OfpHeader
};
use
std
::
io
::
Read
;
use
std
::
net
::
TcpListener
;
use
tenjin
::
etherparser
::
ethernet
::
EthernetFrame
;
use
tenjin
::
openflow
::
events
::
packet_in
::
PacketInEvent
;
use
tenjin
::
openflow
::{
Controller
,
Msg
,
OfpHeader
};
extern
crate
byteorder
;
fn
main
()
->
Result
<
(),
std
::
io
::
Error
>
{
let
controller
=
Controller
::
new
(
Controller
::
OFP_1_0
);
let
mut
controller
=
Controller
::
new
(
Controller
::
OFP_1_0
);
let
listener
=
TcpListener
::
bind
((
"127.0.0.1"
,
6633
))
.unwrap
();
let
mut
buf
=
vec!
[
0u8
;
8
];
...
...
@@ -41,7 +42,11 @@ fn main() -> Result<(), std::io::Error> {
println!
(
"Hello event"
);
}
Msg
::
PacketIn
(
b
)
=>
{
controller
.packetIn
(
packet
.xid
,
EthernetFrame
::
parse
(
&
payload
),
&
mut
stream
);
controller
.packetIn
(
packet
.xid
,
PacketInEvent
::
parse
(
&
payload
),
&
mut
stream
,
);
println!
(
"PacketIn event"
);
}
_
=>
{
...
...
src/openflow/controller.rs
View file @
15388f3c
...
...
@@ -4,7 +4,7 @@ use byteorder::{BigEndian, WriteBytesExt};
use
crate
::
etherparser
::
ethernet
::
EthernetFrame
;
use
super
::
OfpHeader
;
use
super
::
{
events
::
packet_in
::
PacketInEvent
,
OfpHeader
}
;
pub
struct
Controller
{
version
:
u8
,
...
...
@@ -33,7 +33,12 @@ impl Controller {
stream
.write_all
(
&
bytes
)
.unwrap
();
}
pub
fn
packetIn
(
&
self
,
xid
:
u32
,
payload
:
EthernetFrame
,
stream
:
&
mut
TcpStream
)
{}
pub
fn
packetIn
(
&
mut
self
,
xid
:
u32
,
packetin
:
PacketInEvent
,
stream
:
&
mut
TcpStream
)
{
let
ether
=
packetin
.payload
;
self
.mac_to_port
.insert
(
ether
.mac_src
,
packetin
.port
);
}
pub
fn
send
(
&
self
,
xid
:
u32
,
message
:
u8
,
payload
:
&
Vec
<
u8
>
,
stream
:
&
mut
TcpStream
)
{
let
length
=
size_of
::
<
OfpHeader
>
()
+
payload
.len
();
...
...
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