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
117ebae2
Commit
117ebae2
authored
May 12, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packet_in: change payload -> dont auto parse to ethernet frame and create method to parse payload
parent
8e30497f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
10 deletions
+34
-10
controller.rs
src/controller.rs
+4
-3
mod.rs
src/openflow/events/mod.rs
+7
-2
packet_in.rs
src/openflow/events/packet_in.rs
+13
-5
packet_out.rs
src/openflow/events/packet_out.rs
+6
-0
payload.rs
src/openflow/events/payload.rs
+4
-0
No files found.
src/controller.rs
View file @
117ebae2
...
...
@@ -29,8 +29,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
* Start here for handle packetIn message.
*/
fn
packet_in_handler
(
&
mut
self
,
xid
:
u32
,
packetin
:
PacketInEvent
,
stream
:
&
mut
TcpStream
)
{
let
mac_dst
=
packetin
.payload.mac_des
;
let
mac_src
=
packetin
.payload.mac_src
;
let
pkt
=
packetin
.ether_parse
();
let
mac_dst
=
pkt
.mac_des
;
let
mac_src
=
pkt
.mac_src
;
let
out_port
=
self
.mac_to_port
.get
(
&
mac_dst
);
match
out_port
{
Some
(
p
)
=>
{
...
...
@@ -49,7 +50,7 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
let
actions
=
vec!
[
FlowAction
::
Oputput
(
PseudoPort
::
PhysicalPort
(
src_port
))];
self
.add_flow
(
xid
,
dst_src_match
,
actions
,
stream
);
// let pkt_out =
// let pkt_out =
}
None
=>
todo!
(),
}
...
...
src/openflow/events/mod.rs
View file @
117ebae2
pub
mod
packet_in
;
pub
use
packet_in
::{
PacketInEvent
,
PacketInReason
};
pub
mod
packet_out
;
pub
mod
flow_mod
;
pub
use
flow_mod
::{
FlowAction
,
FlowModEvent
};
...
...
@@ -8,4 +10,7 @@ pub mod hello;
pub
use
hello
::
HelloEvent
;
pub
mod
features_req
;
pub
use
features_req
::
FeaturesReq
;
\ No newline at end of file
pub
use
features_req
::
FeaturesReq
;
pub
mod
payload
;
pub
use
payload
::
Payload
;
\ No newline at end of file
src/openflow/events/packet_in.rs
View file @
117ebae2
use
std
::
io
::{
BufRead
,
Cursor
}
;
use
crate
::
etherparser
::
ethernet
::
EthernetFrame
;
use
super
::
Payload
;
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
use
crate
::
etherparser
::
ethernet
::
EthernetFrame
;
use
std
::
io
::{
BufRead
,
Cursor
};
pub
enum
PacketInReason
{
NoMatch
,
...
...
@@ -16,10 +16,15 @@ pub struct PacketInEvent {
pub
port
:
u16
,
pub
reason
:
PacketInReason
,
pub
table_id
:
u8
,
pub
payload
:
EthernetFrame
,
pub
payload
:
Payload
,
}
impl
PacketInEvent
{
pub
fn
ether_parse
(
&
self
)
->
EthernetFrame
{
match
&
self
.payload
{
Payload
::
Buffered
(
_
,
p
)
|
Payload
::
NoBuffered
(
p
)
=>
EthernetFrame
::
parse
(
&
p
),
}
}
pub
fn
parse
(
payload
:
&
Vec
<
u8
>
)
->
PacketInEvent
{
let
mut
bytes
=
Cursor
::
new
(
payload
.to_vec
());
let
buf_id
=
match
bytes
.read_i32
::
<
BigEndian
>
()
.unwrap
()
{
...
...
@@ -35,7 +40,10 @@ impl PacketInEvent {
};
let
table_id
=
bytes
.read_u8
()
.unwrap
();
let
packet
=
bytes
.fill_buf
()
.unwrap
()
.to_vec
();
let
payload
=
EthernetFrame
::
parse
(
&
packet
);
let
payload
=
match
buf_id
{
Some
(
n
)
=>
Payload
::
Buffered
(
n
as
u32
,
packet
),
None
=>
Payload
::
NoBuffered
(
packet
),
};
PacketInEvent
{
buf_id
,
total_len
,
...
...
src/openflow/events/packet_out.rs
0 → 100644
View file @
117ebae2
use
super
::
Payload
;
pub
struct
PacketOutEvent
{
pub
payload
:
Payload
}
\ No newline at end of file
src/openflow/events/payload.rs
0 → 100644
View file @
117ebae2
pub
enum
Payload
{
Buffered
(
u32
,
Vec
<
u8
>
),
NoBuffered
(
Vec
<
u8
>
),
}
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