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
0d4c2ce9
Commit
0d4c2ce9
authored
Jun 22, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mac address struct
parent
f4cf0ec0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
11 deletions
+59
-11
mod.rs
src/etherparser/mod.rs
+3
-5
mac_address.rs
src/etherparser/net/mac_address.rs
+47
-0
mod.rs
src/etherparser/net/mod.rs
+3
-0
match_fields.rs
src/openflow/ofp10/events/flow_mod/match_fields.rs
+6
-6
No files found.
src/etherparser/mod.rs
View file @
0d4c2ce9
pub
mod
ether_type
;
pub
mod
ether_type
;
pub
mod
ethernet
;
pub
mod
ethernet
;
pub
mod
packet
;
pub
mod
packet
;
pub
mod
tools
;
pub
mod
tools
;
pub
mod
net
;
\ No newline at end of file
pub
use
net
::
MacAddr
;
src/etherparser/net/mac_address.rs
0 → 100644
View file @
0d4c2ce9
pub
struct
MacAddr
{
mac
:
[
u8
;
6
],
}
impl
MacAddr
{
pub
fn
new
(
mac
:
[
u8
;
6
])
->
Self
{
Self
{
mac
}
}
}
impl
From
<
MacAddr
>
for
u64
{
fn
from
(
value
:
MacAddr
)
->
Self
{
let
mut
byte
:
u64
=
0
;
for
i
in
0
..
6
{
byte
=
byte
<<
8
;
byte
+=
value
.mac
[
i
]
as
u64
;
}
byte
}
}
impl
From
<
u64
>
for
MacAddr
{
fn
from
(
value
:
u64
)
->
Self
{
let
mut
mac
=
[
0u8
;
6
];
for
i
in
0
..
6
{
mac
[
i
]
=
(
value
>>
(
i
*
8
))
as
u8
;
}
Self
{
mac
}
}
}
impl
From
<&
str
>
for
MacAddr
{
fn
from
(
value
:
&
str
)
->
Self
{
let
mac_vec
=
value
.split
(
":"
)
.map
(|
x
|
match
u8
::
from_str_radix
(
x
,
16
)
{
Ok
(
v
)
=>
v
,
Err
(
_
)
=>
0
,
})
.collect
::
<
Vec
<
u8
>>
();
let
mut
mac
=
[
0u8
;
6
];
for
i
in
0
..
6
{
mac
[
i
]
=
mac_vec
[
i
];
}
Self
{
mac
}
}
}
src/etherparser/net/mod.rs
0 → 100644
View file @
0d4c2ce9
pub
mod
mac_address
;
pub
use
mac_address
::
MacAddr
;
\ No newline at end of file
src/openflow/ofp10/events/flow_mod/match_fields.rs
View file @
0d4c2ce9
...
@@ -132,18 +132,18 @@ pub struct MatchFields {
...
@@ -132,18 +132,18 @@ pub struct MatchFields {
pub
icmpv4_type
:
Option
<
u8
>
,
pub
icmpv4_type
:
Option
<
u8
>
,
pub
icmpv4_code
:
Option
<
u8
>
,
pub
icmpv4_code
:
Option
<
u8
>
,
pub
arp_op
:
Option
<
u16
>
,
pub
arp_op
:
Option
<
u16
>
,
pub
arp_spa
:
Option
<
IPv4
>
,
// ARP source IPv4 address
pub
arp_spa
:
Option
<
IPv4
>
,
// ARP source IPv4 address
pub
arp_tpa
:
Option
<
IPv4
>
,
// ARP target IPv4 address
pub
arp_tpa
:
Option
<
IPv4
>
,
// ARP target IPv4 address
pub
arp_sha
:
Option
<
MacAddr
>
,
// ARP source Mac
pub
arp_sha
:
Option
<
MacAddr
>
,
// ARP source Mac
pub
arp_tha
:
Option
<
MacAddr
>
,
// ARP target Mac
pub
arp_tha
:
Option
<
MacAddr
>
,
// ARP target Mac
pub
ipv6_src
:
Option
<
IPv6
>
,
// IPv6 address
pub
ipv6_src
:
Option
<
IPv6
>
,
// IPv6 address
pub
ipv6_dst
:
Option
<
IPv6
>
,
// IPv6 address
pub
ipv6_dst
:
Option
<
IPv6
>
,
// IPv6 address
pub
ipv6_flabel
:
Option
<
u32
>
,
// IPv6 Flow Lable
pub
ipv6_flabel
:
Option
<
u32
>
,
// IPv6 Flow Lable
pub
icmpv6_type
:
Option
<
u8
>
,
// ICMPv6 type
pub
icmpv6_type
:
Option
<
u8
>
,
// ICMPv6 type
pub
icmpv6_code
:
Option
<
u8
>
,
// ICMPv6 code
pub
icmpv6_code
:
Option
<
u8
>
,
// ICMPv6 code
pub
ipv6_nd_target
:
Option
<
u128
>
,
// Target address for ND
pub
ipv6_nd_target
:
Option
<
u128
>
,
// Target address for ND
pub
ipv6_nd_sll
:
Option
<
MacAddr
>
,
// MAC , source link-layer for ND
pub
ipv6_nd_sll
:
Option
<
MacAddr
>
,
// MAC , source link-layer for ND
pub
ipv6_nd_tll
:
Option
<
MacAddr
>
,
// Mac , Target link-layer for ND
pub
ipv6_nd_tll
:
Option
<
MacAddr
>
,
// Mac , Target link-layer for ND
pub
mpls_label
:
Option
<
u32
>
,
// MPLS label
pub
mpls_label
:
Option
<
u32
>
,
// MPLS label
pub
mpls_tc
:
Option
<
u8
>
,
// MPLS TC
pub
mpls_tc
:
Option
<
u8
>
,
// MPLS TC
pub
mpls_bos
:
Option
<
u8
>
,
// MPLS Bos bit
pub
mpls_bos
:
Option
<
u8
>
,
// MPLS Bos bit
...
...
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