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
98928545
Commit
98928545
authored
May 19, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change flow_mod apply_to_packet to buffer_id
parent
caa61fc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
controller.rs
src/controller.rs
+5
-2
flow_mod_handler.rs
src/openflow/events/flow_mod/flow_mod_handler.rs
+10
-5
No files found.
src/controller.rs
View file @
98928545
#
!
[
allow
(
unused
)]
#
!
[
allow
(
unused
)]
#
!
[
allow
(
unused_variables
)]
#
!
[
allow
(
unused_variables
)]
use
crate
::
etherparser
::
ether_type
::
EtherType
;
use
crate
::
openflow
::
events
::
flow_mod
::{
FlowModCommand
,
MatchFields
};
use
crate
::
openflow
::
events
::
flow_mod
::{
FlowModCommand
,
MatchFields
};
/**
/**
* Here is Controller you can modify and write the process or more you need.
* Here is Controller you can modify and write the process or more you need.
...
@@ -35,7 +36,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
...
@@ -35,7 +36,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
let
mac_dst
=
pkt
.mac_des
;
let
mac_dst
=
pkt
.mac_des
;
let
mac_src
=
pkt
.mac_src
;
let
mac_src
=
pkt
.mac_src
;
// if pkt.
if
let
EtherType
::
LLDP
=
pkt
.ether_type
{
return
;
}
let
out_port
=
self
.mac_to_port
.get
(
&
mac_dst
);
let
out_port
=
self
.mac_to_port
.get
(
&
mac_dst
);
match
out_port
{
match
out_port
{
...
@@ -82,6 +85,6 @@ impl<OME: OfpMsgEvent> Controller<OME> {
...
@@ -82,6 +85,6 @@ impl<OME: OfpMsgEvent> Controller<OME> {
actions
:
Vec
<
FlowAction
>
,
actions
:
Vec
<
FlowAction
>
,
stream
:
&
mut
TcpStream
,
stream
:
&
mut
TcpStream
,
)
{
)
{
self
.send_msg
(
FlowModEvent
::
add_flow
(
10
,
flow
,
actions
),
xid
,
stream
)
self
.send_msg
(
FlowModEvent
::
add_flow
(
10
,
flow
,
actions
,
None
),
xid
,
stream
)
}
}
}
}
src/openflow/events/flow_mod/flow_mod_handler.rs
View file @
98928545
...
@@ -37,13 +37,18 @@ pub struct FlowModEvent {
...
@@ -37,13 +37,18 @@ pub struct FlowModEvent {
idle_timeout
:
Timeout
,
idle_timeout
:
Timeout
,
hard_timeout
:
Timeout
,
hard_timeout
:
Timeout
,
notify_when_removed
:
bool
,
notify_when_removed
:
bool
,
apply_to_packet
:
Option
<
u32
>
,
buffer_id
:
Option
<
u32
>
,
out_port
:
Option
<
PseudoPort
>
,
out_port
:
Option
<
PseudoPort
>
,
check_overlap
:
bool
,
check_overlap
:
bool
,
}
}
impl
FlowModEvent
{
impl
FlowModEvent
{
pub
fn
add_flow
(
priority
:
u16
,
match_fileds
:
MatchFields
,
actions
:
Vec
<
FlowAction
>
)
->
Self
{
pub
fn
add_flow
(
priority
:
u16
,
match_fileds
:
MatchFields
,
actions
:
Vec
<
FlowAction
>
,
buffer_id
:
Option
<
u32
>
,
)
->
Self
{
Self
{
Self
{
command
:
FlowModCommand
::
Add
,
command
:
FlowModCommand
::
Add
,
match_fields
:
match_fileds
,
match_fields
:
match_fileds
,
...
@@ -53,7 +58,7 @@ impl FlowModEvent {
...
@@ -53,7 +58,7 @@ impl FlowModEvent {
idle_timeout
:
Timeout
::
Permanent
,
idle_timeout
:
Timeout
::
Permanent
,
hard_timeout
:
Timeout
::
Permanent
,
hard_timeout
:
Timeout
::
Permanent
,
notify_when_removed
:
false
,
notify_when_removed
:
false
,
apply_to_packet
:
None
,
buffer_id
,
out_port
:
None
,
out_port
:
None
,
check_overlap
:
false
,
check_overlap
:
false
,
}
}
...
@@ -80,7 +85,7 @@ impl FlowModEvent {
...
@@ -80,7 +85,7 @@ impl FlowModEvent {
idle_timeout
,
idle_timeout
,
hard_timeout
,
hard_timeout
,
notify_when_removed
:
flags
&
1
!=
0
,
notify_when_removed
:
flags
&
1
!=
0
,
apply_to_packet
:
{
buffer_id
:
{
match
buffer_id
{
match
buffer_id
{
-
1
=>
None
,
-
1
=>
None
,
n
=>
Some
(
n
as
u32
),
n
=>
Some
(
n
as
u32
),
...
@@ -109,7 +114,7 @@ impl MessageMarshal for FlowModEvent {
...
@@ -109,7 +114,7 @@ impl MessageMarshal for FlowModEvent {
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.idle_timeout
.to_int
());
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.idle_timeout
.to_int
());
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.hard_timeout
.to_int
());
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.hard_timeout
.to_int
());
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.priority
);
let
_
=
bytes
.write_u16
::
<
BigEndian
>
(
self
.priority
);
let
_
=
bytes
.write_i32
::
<
BigEndian
>
(
match
self
.
apply_to_packet
{
let
_
=
bytes
.write_i32
::
<
BigEndian
>
(
match
self
.
buffer_id
{
None
=>
-
1
,
None
=>
-
1
,
Some
(
buf_id
)
=>
buf_id
as
i32
,
Some
(
buf_id
)
=>
buf_id
as
i32
,
});
});
...
...
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