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
caa61fc7
Commit
caa61fc7
authored
May 19, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ether_type to Ether_Frame
parent
48c16b03
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
controller.rs
src/controller.rs
+3
-0
ether_type.rs
src/etherparser/ether_type.rs
+22
-0
ethernet.rs
src/etherparser/ethernet.rs
+2
-0
No files found.
src/controller.rs
View file @
caa61fc7
...
...
@@ -34,6 +34,9 @@ impl<OME: OfpMsgEvent> ControllerFrame<OME> for Controller<OME> {
let
mac_dst
=
pkt
.mac_des
;
let
mac_src
=
pkt
.mac_src
;
// if pkt.
let
out_port
=
self
.mac_to_port
.get
(
&
mac_dst
);
match
out_port
{
Some
(
p
)
=>
{
...
...
src/etherparser/ether_type.rs
View file @
caa61fc7
...
...
@@ -12,4 +12,26 @@ pub enum EtherType {
IEEE802_3
=
0x05dc
,
CFM
=
0x8902
,
NSH
=
0x894f
,
Unparsable
=
0xffff
,
}
impl
EtherType
{
pub
fn
parse
(
ether
:
u16
)
->
EtherType
{
match
ether
{
tp
if
tp
==
EtherType
::
IP
as
u16
=>
EtherType
::
IP
,
tp
if
tp
==
EtherType
::
ARP
as
u16
=>
EtherType
::
ARP
,
tp
if
tp
==
EtherType
::
TEB
as
u16
=>
EtherType
::
TEB
,
tp
if
tp
==
EtherType
::
VLAN
as
u16
=>
EtherType
::
VLAN
,
tp
if
tp
==
EtherType
::
IPV6
as
u16
=>
EtherType
::
IPV6
,
tp
if
tp
==
EtherType
::
SLOW
as
u16
=>
EtherType
::
SLOW
,
tp
if
tp
==
EtherType
::
MPLS
as
u16
=>
EtherType
::
MPLS
,
tp
if
tp
==
EtherType
::
SVLAN
as
u16
=>
EtherType
::
SVLAN
,
tp
if
tp
==
EtherType
::
LLDP
as
u16
=>
EtherType
::
LLDP
,
tp
if
tp
==
EtherType
::
PBB
as
u16
=>
EtherType
::
PBB
,
tp
if
tp
==
EtherType
::
IEEE802_3
as
u16
=>
EtherType
::
IEEE802_3
,
tp
if
tp
==
EtherType
::
CFM
as
u16
=>
EtherType
::
CFM
,
tp
if
tp
==
EtherType
::
NSH
as
u16
=>
EtherType
::
NSH
,
_
=>
EtherType
::
Unparsable
,
}
}
}
src/etherparser/ethernet.rs
View file @
caa61fc7
...
...
@@ -9,6 +9,7 @@ use super::{
};
pub
struct
EthernetFrame
{
pub
ether_type
:
EtherType
,
pub
mac_des
:
u64
,
pub
mac_src
:
u64
,
pub
vlan_pcp
:
u8
,
...
...
@@ -60,6 +61,7 @@ impl EthernetFrame {
_
=>
Network
::
Unparsable
(
typ
,
bytes
.fill_buf
()
.unwrap
()
.to_vec
()),
};
EthernetFrame
{
ether_type
:
EtherType
::
parse
(
typ
),
mac_des
:
mac_to_bytes
(
mac_des
),
mac_src
:
mac_to_bytes
(
mac_src
),
vlan_pcp
,
...
...
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