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
f2d84128
Commit
f2d84128
authored
Jun 15, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inprove controller frame: message handle; add echo events
parent
ecaef6a6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
8 deletions
+89
-8
controller_frame.rs
src/openflow/ofp10/controller_frame.rs
+21
-8
echo_reply.rs
src/openflow/ofp10/events/echo_reply.rs
+31
-0
echo_request.rs
src/openflow/ofp10/events/echo_request.rs
+31
-0
mod.rs
src/openflow/ofp10/events/mod.rs
+6
-0
No files found.
src/openflow/ofp10/controller_frame.rs
View file @
f2d84128
...
...
@@ -4,7 +4,10 @@ use std::{
net
::
TcpStream
,
};
use
super
::{
tcp_listener_handler
,
MessageMarshal
,
OfpMsgEvent
,
Openflow10
,
OpenflowHeader
};
use
super
::{
events
::{
echo_reply
::
EchoReplyEvent
,
EchoRequestEvent
},
tcp_listener_handler
,
MessageMarshal
,
OfpMsgEvent
,
Openflow10
,
OpenflowHeader
,
};
pub
trait
ControllerFrame10
{
fn
ofp
(
&
self
)
->
ofp10
::
Openflow10
{
...
...
@@ -33,18 +36,15 @@ pub trait ControllerFrame10 {
let
_
=
stream
.read
(
&
mut
payload
);
let
message
=
ofp
.msg_parse
(
message
as
u8
);
match
message
{
Msg
::
Hello
=>
self
.send_msg
(
ofp
.fetures_req
(),
xid
,
stream
),
Msg
::
Error
=>
{
let
error
=
ErrorEvent
::
parse
(
&
payload
);
println!
(
"Error {:?}"
,
error
.error_type
);
()
Msg
::
Hello
=>
self
.hello_handler
(
xid
,
stream
),
Msg
::
Error
=>
self
.error_handler
(
ErrorEvent
::
parse
(
&
payload
)),
Msg
::
EchoRequest
=>
{
self
.echo_request_handler
(
xid
,
EchoRequestEvent
::
new
(
payload
),
stream
)
}
Msg
::
FeaturesRequest
=>
(),
Msg
::
PacketIn
=>
{
self
.packet_in_handler
(
xid
,
PacketInEvent
::
parse
(
&
payload
),
stream
);
}
Msg
::
PacketOut
=>
(),
Msg
::
FlowMod
=>
(),
_
=>
(),
}
}
...
...
@@ -60,4 +60,17 @@ pub trait ControllerFrame10 {
header_bytes
.append
(
&
mut
body_bytes
);
let
_
=
stream
.write_all
(
&
header_bytes
);
}
/**
* for handle message
*/
fn
hello_handler
(
&
self
,
xid
:
u32
,
stream
:
&
mut
TcpStream
)
{
self
.send_msg
(
self
.ofp
()
.fetures_req
(),
xid
,
stream
);
}
fn
error_handler
(
&
self
,
error
:
ErrorEvent
)
{
println!
(
"Error {:?}"
,
error
.error_type
);
}
fn
echo_request_handler
(
&
self
,
xid
:
u32
,
echo
:
EchoRequestEvent
,
stream
:
&
mut
TcpStream
)
{
self
.send_msg
(
EchoReplyEvent
::
new
(
echo
.payload
),
xid
,
stream
);
}
}
src/openflow/ofp10/events/echo_reply.rs
0 → 100644
View file @
f2d84128
use
std
::
io
::
Write
;
use
crate
::
openflow
::
ofp10
::{
self
,
MessageMarshal
};
pub
struct
EchoReplyEvent
{
pub
payload
:
Vec
<
u8
>
,
}
impl
EchoReplyEvent
{
pub
fn
new
(
payload
:
Vec
<
u8
>
)
->
Self
{
Self
{
payload
}
}
}
impl
MessageMarshal
for
EchoReplyEvent
{
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
let
_
=
bytes
.write_all
(
&
self
.payload
);
}
fn
msg_code
(
&
self
)
->
ofp10
::
Msg
{
ofp10
::
Msg
::
EchoReply
}
fn
msg_usize
<
OFP
:
ofp10
::
OfpMsgEvent
>
(
&
self
,
ofp
:
&
OFP
)
->
usize
{
ofp10
::
Msg
::
EchoReply
as
usize
}
fn
size_of
(
&
self
)
->
usize
{
self
.payload
.len
()
}
}
src/openflow/ofp10/events/echo_request.rs
0 → 100644
View file @
f2d84128
use
std
::
io
::
Write
;
use
crate
::
openflow
::
ofp10
::{
self
,
MessageMarshal
,
Msg
};
pub
struct
EchoRequestEvent
{
pub
payload
:
Vec
<
u8
>
,
}
impl
EchoRequestEvent
{
pub
fn
new
(
payload
:
Vec
<
u8
>
)
->
Self
{
Self
{
payload
}
}
}
impl
MessageMarshal
for
EchoRequestEvent
{
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
let
_
=
bytes
.write_all
(
&
self
.payload
);
}
fn
msg_code
(
&
self
)
->
ofp10
::
Msg
{
Msg
::
EchoRequest
}
fn
msg_usize
<
OFP
:
ofp10
::
OfpMsgEvent
>
(
&
self
,
_
:
&
OFP
)
->
usize
{
Msg
::
EchoRequest
as
usize
}
fn
size_of
(
&
self
)
->
usize
{
self
.payload
.len
()
}
}
src/openflow/ofp10/events/mod.rs
View file @
f2d84128
...
...
@@ -21,3 +21,8 @@ pub use features_req::FeaturesReqEvent;
pub
mod
payload
;
pub
use
payload
::
Payload
;
pub
mod
echo_request
;
pub
use
echo_request
::
EchoRequestEvent
;
pub
mod
echo_reply
;
\ No newline at end of file
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