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
Show 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> {
...
@@ -40,40 +40,29 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
return
;
return
;
}
}
let
out_port
=
self
.mac_to_port
.get
(
&
mac_dst
);
let
out_port
=
match
self
.mac_to_port
.get
(
&
mac_dst
)
{
match
out_port
{
Some
(
p
)
=>
PseudoPort
::
PhysicalPort
(
*
p
),
Some
(
p
)
=>
{
None
=>
PseudoPort
::
Flood
,
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
mut
dst_src_match
=
MatchFields
::
match_all
();
let
actions
=
vec!
[
FlowAction
::
Oputput
(
out_port
.clone
())];
dst_src_match
.mac_dest
=
Some
(
mac_src
);
dst_src_match
.mac_src
=
Some
(
mac_dst
);
let
actions
=
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
*
p
))];
if
let
PseudoPort
::
PhysicalPort
(
_
)
=
out_port
{
self
.add_flow
(
0
,
src_dst_match
,
actions
,
stream
);
let
mut
match_fields
=
MatchFields
::
match_all
();
match_fields
.in_port
=
Some
(
packetin
.port
);
let
actions
=
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
src_port
))];
match_fields
.mac_dest
=
Some
(
mac_dst
);
self
.add_flow
(
0
,
dst_src_match
,
actions
,
stream
);
match_fields
.mac_src
=
Some
(
mac_src
);
if
let
Some
(
buf_id
)
=
packetin
.buf_id
{
let
packet_out
=
self
.ofp
.packet_out
(
self
.add_flow
(
xid
,
1
,
match_fields
,
&
actions
,
Some
(
buf_id
as
u32
),
stream
);
None
,
return
;
packetin
.payload
,
}
else
{
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
*
p
))],
self
.add_flow
(
xid
,
1
,
match_fields
,
&
actions
,
None
,
stream
);
);
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
);
}
}
}
}
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> {
...
@@ -81,10 +70,16 @@ impl<OME: OfpMsgEvent> Controller<OME> {
fn
add_flow
(
fn
add_flow
(
&
self
,
&
self
,
xid
:
u32
,
xid
:
u32
,
priority
:
u16
,
flow
:
MatchFields
,
flow
:
MatchFields
,
actions
:
Vec
<
FlowAction
>
,
actions
:
&
Vec
<
FlowAction
>
,
buffer_id
:
Option
<
u32
>
,
stream
:
&
mut
TcpStream
,
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 {
...
@@ -11,7 +11,7 @@ pub enum PacketInReason {
}
}
pub
struct
PacketInEvent
{
pub
struct
PacketInEvent
{
pub
buf_id
:
Option
<
i
32
>
,
pub
buf_id
:
Option
<
u
32
>
,
pub
total_len
:
u16
,
pub
total_len
:
u16
,
pub
port
:
u16
,
pub
port
:
u16
,
pub
reason
:
PacketInReason
,
pub
reason
:
PacketInReason
,
...
@@ -29,7 +29,7 @@ impl PacketInEvent {
...
@@ -29,7 +29,7 @@ impl PacketInEvent {
let
mut
bytes
=
Cursor
::
new
(
payload
.to_vec
());
let
mut
bytes
=
Cursor
::
new
(
payload
.to_vec
());
let
buf_id
=
match
bytes
.read_i32
::
<
BigEndian
>
()
.unwrap
()
{
let
buf_id
=
match
bytes
.read_i32
::
<
BigEndian
>
()
.unwrap
()
{
-
1
=>
None
,
-
1
=>
None
,
n
=>
Some
(
n
),
n
=>
Some
(
n
as
u32
),
};
};
let
total_len
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
total_len
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
port
=
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