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
19be69bc
Commit
19be69bc
authored
May 19, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite packet_in_handler and change packet_in buf to option u32
parent
98928545
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
34 deletions
+29
-34
controller.rs
src/controller.rs
+27
-32
packet_in.rs
src/openflow/events/packet_in.rs
+2
-2
No files found.
src/controller.rs
View file @
19be69bc
...
...
@@ -40,40 +40,29 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
return
;
}
let
out_port
=
self
.mac_to_port
.get
(
&
mac_dst
);
match
out_port
{
Some
(
p
)
=>
{
let
src_port
=
packetin
.port
;
let
mut
src_dst_match
=
MatchFields
::
match_all
();
src_dst_match
.mac_dest
=
Some
(
mac_dst
);
src_dst_match
.mac_src
=
Some
(
mac_src
);
let
out_port
=
match
self
.mac_to_port
.get
(
&
mac_dst
)
{
Some
(
p
)
=>
PseudoPort
::
PhysicalPort
(
*
p
),
None
=>
PseudoPort
::
Flood
,
};
let
mut
dst_src_match
=
MatchFields
::
match_all
();
dst_src_match
.mac_dest
=
Some
(
mac_src
);
dst_src_match
.mac_src
=
Some
(
mac_dst
);
let
actions
=
vec!
[
FlowAction
::
Oputput
(
out_port
.clone
())];
let
actions
=
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
*
p
))];
self
.add_flow
(
0
,
src_dst_match
,
actions
,
stream
);
let
actions
=
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
src_port
))];
self
.add_flow
(
0
,
dst_src_match
,
actions
,
stream
);
let
packet_out
=
self
.ofp
.packet_out
(
None
,
packetin
.payload
,
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
*
p
))],
);
self
.send_msg
(
packet_out
,
xid
,
stream
);
}
None
=>
{
let
packet_out
=
self
.ofp
.packet_out
(
None
,
packetin
.payload
,
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
AllPorts
)],
);
self
.send_msg
(
packet_out
,
xid
,
stream
);
if
let
PseudoPort
::
PhysicalPort
(
_
)
=
out_port
{
let
mut
match_fields
=
MatchFields
::
match_all
();
match_fields
.in_port
=
Some
(
packetin
.port
);
match_fields
.mac_dest
=
Some
(
mac_dst
);
match_fields
.mac_src
=
Some
(
mac_src
);
if
let
Some
(
buf_id
)
=
packetin
.buf_id
{
self
.add_flow
(
xid
,
1
,
match_fields
,
&
actions
,
Some
(
buf_id
as
u32
),
stream
);
return
;
}
else
{
self
.add_flow
(
xid
,
1
,
match_fields
,
&
actions
,
None
,
stream
);
}
}
let
packet_out
=
self
.ofp
.packet_out
(
Some
(
packetin
.port
),
packetin
.payload
,
actions
);
self
.send_msg
(
packet_out
,
xid
,
stream
);
}
}
...
...
@@ -81,10 +70,16 @@ impl<OME: OfpMsgEvent> Controller<OME> {
fn
add_flow
(
&
self
,
xid
:
u32
,
priority
:
u16
,
flow
:
MatchFields
,
actions
:
Vec
<
FlowAction
>
,
actions
:
&
Vec
<
FlowAction
>
,
buffer_id
:
Option
<
u32
>
,
stream
:
&
mut
TcpStream
,
)
{
self
.send_msg
(
FlowModEvent
::
add_flow
(
10
,
flow
,
actions
,
None
),
xid
,
stream
)
self
.send_msg
(
FlowModEvent
::
add_flow
(
10
,
flow
,
actions
.clone
(),
buffer_id
),
xid
,
stream
,
)
}
}
src/openflow/events/packet_in.rs
View file @
19be69bc
...
...
@@ -11,7 +11,7 @@ pub enum PacketInReason {
}
pub
struct
PacketInEvent
{
pub
buf_id
:
Option
<
i
32
>
,
pub
buf_id
:
Option
<
u
32
>
,
pub
total_len
:
u16
,
pub
port
:
u16
,
pub
reason
:
PacketInReason
,
...
...
@@ -29,7 +29,7 @@ impl PacketInEvent {
let
mut
bytes
=
Cursor
::
new
(
payload
.to_vec
());
let
buf_id
=
match
bytes
.read_i32
::
<
BigEndian
>
()
.unwrap
()
{
-
1
=>
None
,
n
=>
Some
(
n
),
n
=>
Some
(
n
as
u32
),
};
let
total_len
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
port
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
...
...
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