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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
7 deletions
+32
-7
controller.rs
src/controller.rs
+3
-2
mod.rs
src/openflow/events/mod.rs
+6
-0
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> {
...
@@ -29,8 +29,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
* Start here for handle packetIn message.
* Start here for handle packetIn message.
*/
*/
fn
packet_in_handler
(
&
mut
self
,
xid
:
u32
,
packetin
:
PacketInEvent
,
stream
:
&
mut
TcpStream
)
{
fn
packet_in_handler
(
&
mut
self
,
xid
:
u32
,
packetin
:
PacketInEvent
,
stream
:
&
mut
TcpStream
)
{
let
mac_dst
=
packetin
.payload.mac_des
;
let
pkt
=
packetin
.ether_parse
();
let
mac_src
=
packetin
.payload.mac_src
;
let
mac_dst
=
pkt
.mac_des
;
let
mac_src
=
pkt
.mac_src
;
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
{
Some
(
p
)
=>
{
Some
(
p
)
=>
{
...
...
src/openflow/events/mod.rs
View file @
117ebae2
pub
mod
packet_in
;
pub
mod
packet_in
;
pub
use
packet_in
::{
PacketInEvent
,
PacketInReason
};
pub
use
packet_in
::{
PacketInEvent
,
PacketInReason
};
pub
mod
packet_out
;
pub
mod
flow_mod
;
pub
mod
flow_mod
;
pub
use
flow_mod
::{
FlowAction
,
FlowModEvent
};
pub
use
flow_mod
::{
FlowAction
,
FlowModEvent
};
...
@@ -9,3 +11,6 @@ pub use hello::HelloEvent;
...
@@ -9,3 +11,6 @@ pub use hello::HelloEvent;
pub
mod
features_req
;
pub
mod
features_req
;
pub
use
features_req
::
FeaturesReq
;
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
byteorder
::{
BigEndian
,
ReadBytesExt
};
use
std
::
io
::{
BufRead
,
Cursor
};
use
crate
::
etherparser
::
ethernet
::
EthernetFrame
;
pub
enum
PacketInReason
{
pub
enum
PacketInReason
{
NoMatch
,
NoMatch
,
...
@@ -16,10 +16,15 @@ pub struct PacketInEvent {
...
@@ -16,10 +16,15 @@ pub struct PacketInEvent {
pub
port
:
u16
,
pub
port
:
u16
,
pub
reason
:
PacketInReason
,
pub
reason
:
PacketInReason
,
pub
table_id
:
u8
,
pub
table_id
:
u8
,
pub
payload
:
EthernetFrame
,
pub
payload
:
Payload
,
}
}
impl
PacketInEvent
{
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
{
pub
fn
parse
(
payload
:
&
Vec
<
u8
>
)
->
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
()
{
...
@@ -35,7 +40,10 @@ impl PacketInEvent {
...
@@ -35,7 +40,10 @@ impl PacketInEvent {
};
};
let
table_id
=
bytes
.read_u8
()
.unwrap
();
let
table_id
=
bytes
.read_u8
()
.unwrap
();
let
packet
=
bytes
.fill_buf
()
.unwrap
()
.to_vec
();
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
{
PacketInEvent
{
buf_id
,
buf_id
,
total_len
,
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