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
a7725227
Commit
a7725227
authored
May 12, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add OfpMsgEvent to packet_out and at packet_out to ofp v1.0
parent
78cf45a2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
22 deletions
+51
-22
controller_frame.rs
src/openflow/controller_frame.rs
+1
-0
packet_out.rs
src/openflow/events/packet_out.rs
+42
-22
payload.rs
src/openflow/events/payload.rs
+5
-0
ofp_message.rs
src/openflow/ofp_manager/ofp_message.rs
+1
-0
ofp_v1_0.rs
src/openflow/ofp_manager/ofp_v1_0.rs
+2
-0
No files found.
src/openflow/controller_frame.rs
View file @
a7725227
...
@@ -41,6 +41,7 @@ pub trait ControllerFrame<OME: OfpMsgEvent> {
...
@@ -41,6 +41,7 @@ pub trait ControllerFrame<OME: OfpMsgEvent> {
OfpMsg
::
PacketIn
=>
{
OfpMsg
::
PacketIn
=>
{
self
.packet_in_handler
(
xid
,
PacketInEvent
::
parse
(
&
payload
),
stream
);
self
.packet_in_handler
(
xid
,
PacketInEvent
::
parse
(
&
payload
),
stream
);
}
}
OfpMsg
::
PacketOut
=>
(),
OfpMsg
::
FlowMod
=>
todo!
(),
OfpMsg
::
FlowMod
=>
todo!
(),
OfpMsg
::
NotFound
=>
todo!
(),
OfpMsg
::
NotFound
=>
todo!
(),
}
}
...
...
src/openflow/events/packet_out.rs
View file @
a7725227
use
std
::
io
::{
BufRead
,
Cursor
,
Read
};
use
std
::{
io
::{
BufRead
,
Cursor
,
Read
},
mem
::
size_of
,
};
use
byteorder
::{
BigEndian
,
ReadBytesExt
,
WriteBytesExt
};
use
byteorder
::{
BigEndian
,
ReadBytesExt
,
WriteBytesExt
};
use
crate
::
openflow
::{
OfpPort
,
PseudoPort
};
use
crate
::
openflow
::{
ofp_manager
::{
MessageMarshal
,
OfpMsg
,
OfpMsgEvent
},
OfpPort
,
PseudoPort
,
};
use
super
::{
flow_mod
::
SizeCheck
,
FlowAction
,
Payload
};
use
super
::{
flow_mod
::
SizeCheck
,
FlowAction
,
Payload
};
...
@@ -12,6 +18,40 @@ pub struct PacketOutEvent {
...
@@ -12,6 +18,40 @@ pub struct PacketOutEvent {
pub
actions
:
Vec
<
FlowAction
>
,
pub
actions
:
Vec
<
FlowAction
>
,
}
}
impl
MessageMarshal
for
PacketOutEvent
{
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
let
_
=
bytes
.write_i32
::
<
BigEndian
>
(
match
self
.payload
{
Payload
::
Buffered
(
n
,
_
)
=>
n
as
i32
,
Payload
::
NoBuffered
(
_
)
=>
-
1
,
});
match
self
.port_id
{
Some
(
id
)
=>
{
PseudoPort
::
PhysicalPort
(
id
)
.marshal
(
bytes
);
}
None
=>
{
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
OfpPort
::
None
as
u16
);
}
}
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.actions
.size_of_sequence
()
as
u16
);
for
act
in
self
.actions
.move_controller_last
()
{
act
.marshal
(
bytes
);
}
self
.payload
.marshal
(
bytes
);
}
fn
msg_code
(
&
self
)
->
OfpMsg
{
OfpMsg
::
PacketOut
}
fn
msg_usize
<
OFP
:
OfpMsgEvent
>
(
&
self
,
ofp
:
&
OFP
)
->
usize
{
ofp
.msg_usize
(
OfpMsg
::
PacketOut
)
}
fn
size_of
(
&
self
)
->
usize
{
size_of
::
<
(
u32
,
u16
,
u16
)
>
()
+
self
.actions
.size_of_sequence
()
+
self
.payload
.length
()
}
}
impl
PacketOutEvent
{
impl
PacketOutEvent
{
pub
fn
new
(
port_id
:
Option
<
u16
>
,
payload
:
Payload
,
actions
:
Vec
<
FlowAction
>
)
->
Self
{
pub
fn
new
(
port_id
:
Option
<
u16
>
,
payload
:
Payload
,
actions
:
Vec
<
FlowAction
>
)
->
Self
{
Self
{
Self
{
...
@@ -52,24 +92,4 @@ impl PacketOutEvent {
...
@@ -52,24 +92,4 @@ impl PacketOutEvent {
actions
,
actions
,
}
}
}
}
pub
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
let
_
=
bytes
.write_i32
::
<
BigEndian
>
(
match
self
.payload
{
Payload
::
Buffered
(
n
,
_
)
=>
n
as
i32
,
Payload
::
NoBuffered
(
_
)
=>
-
1
,
});
match
self
.port_id
{
Some
(
id
)
=>
{
PseudoPort
::
PhysicalPort
(
id
)
.marshal
(
bytes
);
}
None
=>
{
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
OfpPort
::
None
as
u16
);
}
}
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.actions
.size_of_sequence
()
as
u16
);
for
act
in
self
.actions
.move_controller_last
()
{
act
.marshal
(
bytes
);
}
self
.payload
.marshal
(
bytes
);
}
}
}
src/openflow/events/payload.rs
View file @
a7725227
...
@@ -6,6 +6,11 @@ pub enum Payload {
...
@@ -6,6 +6,11 @@ pub enum Payload {
}
}
impl
Payload
{
impl
Payload
{
pub
fn
length
(
&
self
)
->
usize
{
match
self
{
Payload
::
Buffered
(
_
,
p
)
|
Payload
::
NoBuffered
(
p
)
=>
p
.len
(),
}
}
pub
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
pub
fn
marshal
(
&
self
,
bytes
:
&
mut
Vec
<
u8
>
)
{
match
self
{
match
self
{
Payload
::
Buffered
(
_
,
buf
)
|
Payload
::
NoBuffered
(
buf
)
=>
{
Payload
::
Buffered
(
_
,
buf
)
|
Payload
::
NoBuffered
(
buf
)
=>
{
...
...
src/openflow/ofp_manager/ofp_message.rs
View file @
a7725227
...
@@ -2,6 +2,7 @@ pub enum OfpMsg {
...
@@ -2,6 +2,7 @@ pub enum OfpMsg {
Hello
,
Hello
,
FeaturesReq
,
FeaturesReq
,
PacketIn
,
PacketIn
,
PacketOut
,
FlowMod
,
FlowMod
,
NotFound
NotFound
}
}
src/openflow/ofp_manager/ofp_v1_0.rs
View file @
a7725227
...
@@ -53,6 +53,7 @@ impl OfpMsgEvent for Openflow10 {
...
@@ -53,6 +53,7 @@ impl OfpMsgEvent for Openflow10 {
0
=>
OfpMsg
::
Hello
,
0
=>
OfpMsg
::
Hello
,
5
=>
OfpMsg
::
FeaturesReq
,
5
=>
OfpMsg
::
FeaturesReq
,
8
=>
OfpMsg
::
PacketIn
,
8
=>
OfpMsg
::
PacketIn
,
13
=>
OfpMsg
::
PacketOut
,
14
=>
OfpMsg
::
FlowMod
,
14
=>
OfpMsg
::
FlowMod
,
_
=>
OfpMsg
::
NotFound
,
_
=>
OfpMsg
::
NotFound
,
}
}
...
@@ -63,6 +64,7 @@ impl OfpMsgEvent for Openflow10 {
...
@@ -63,6 +64,7 @@ impl OfpMsgEvent for Openflow10 {
OfpMsg
::
Hello
=>
0
,
OfpMsg
::
Hello
=>
0
,
OfpMsg
::
FeaturesReq
=>
5
,
OfpMsg
::
FeaturesReq
=>
5
,
OfpMsg
::
PacketIn
=>
8
,
OfpMsg
::
PacketIn
=>
8
,
OfpMsg
::
PacketOut
=>
13
,
OfpMsg
::
FlowMod
=>
14
,
OfpMsg
::
FlowMod
=>
14
,
_
=>
1024
,
_
=>
1024
,
}
}
...
...
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