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
53c50a2e
Commit
53c50a2e
authored
Jun 14, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change variable name des to dst
parent
94958e03
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
12 deletions
+11
-12
controller.rs
src/controller.rs
+1
-1
ethernet.rs
src/etherparser/ethernet.rs
+4
-4
ipv4.rs
src/etherparser/packet/ipv4.rs
+3
-3
tcp.rs
src/etherparser/packet/tcp.rs
+3
-4
No files found.
src/controller.rs
View file @
53c50a2e
...
...
@@ -39,7 +39,7 @@ impl ControllerFrame10 for Controller {
let
pkt
=
packetin
.ether_parse
();
self
.mac_to_port
.insert
(
pkt
.mac_src
,
packetin
.in_port
);
let
mac_dst
=
pkt
.mac_d
es
;
let
mac_dst
=
pkt
.mac_d
st
;
let
mac_src
=
pkt
.mac_src
;
if
let
EtherType
::
LLDP
=
pkt
.ether_type
{
...
...
src/etherparser/ethernet.rs
View file @
53c50a2e
...
...
@@ -10,7 +10,7 @@ use super::{
pub
struct
EthernetFrame
{
pub
ether_type
:
EtherType
,
pub
mac_d
es
:
u64
,
pub
mac_d
st
:
u64
,
pub
mac_src
:
u64
,
pub
vlan_pcp
:
u8
,
pub
vlan_dei
:
bool
,
...
...
@@ -21,10 +21,10 @@ pub struct EthernetFrame {
impl
EthernetFrame
{
pub
fn
parse
(
payload
:
&
Vec
<
u8
>
)
->
EthernetFrame
{
let
mut
bytes
=
Cursor
::
new
(
payload
.to_vec
());
let
mut
mac_d
es
=
[
0u8
;
6
];
let
mut
mac_d
st
=
[
0u8
;
6
];
let
mut
mac_src
=
[
0u8
;
6
];
for
i
in
0
..
6
{
mac_d
es
[
i
]
=
bytes
.read_u8
()
.unwrap
();
mac_d
st
[
i
]
=
bytes
.read_u8
()
.unwrap
();
}
for
i
in
0
..
6
{
mac_src
[
i
]
=
bytes
.read_u8
()
.unwrap
();
...
...
@@ -62,7 +62,7 @@ impl EthernetFrame {
};
EthernetFrame
{
ether_type
:
EtherType
::
parse
(
typ
),
mac_d
es
:
mac_to_bytes
(
mac_des
),
mac_d
st
:
mac_to_bytes
(
mac_dst
),
mac_src
:
mac_to_bytes
(
mac_src
),
vlan_pcp
,
vlan_dei
,
...
...
src/etherparser/packet/ipv4.rs
View file @
53c50a2e
...
...
@@ -27,7 +27,7 @@ pub struct IP {
pub
protocol
:
u8
,
pub
checksum
:
u16
,
pub
src
:
u32
,
pub
d
es
:
u32
,
pub
d
st
:
u32
,
pub
options
:
Vec
<
u8
>
,
pub
ptcol
:
EtherData
,
}
...
...
@@ -55,7 +55,7 @@ impl IP {
let
protocol
=
bytes
.read_u8
()
.unwrap
();
let
checksum
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
src
=
bytes
.read_u32
::
<
BigEndian
>
()
.unwrap
();
let
d
es
=
bytes
.read_u32
::
<
BigEndian
>
()
.unwrap
();
let
d
st
=
bytes
.read_u32
::
<
BigEndian
>
()
.unwrap
();
let
option_len
=
(
ihl
*
4
)
as
usize
-
20
;
let
mut
options
=
vec!
[
0u8
;
option_len
];
bytes
.read_exact
(
&
mut
options
)
.unwrap
();
...
...
@@ -98,7 +98,7 @@ impl IP {
ttl
,
checksum
,
src
,
d
es
,
d
st
,
options
,
ptcol
,
})
...
...
src/etherparser/packet/tcp.rs
View file @
53c50a2e
...
...
@@ -5,7 +5,7 @@ use std::io::{BufRead, Cursor};
#[derive(Clone)]
pub
struct
TCP
{
pub
src_port
:
u16
,
pub
d
es
_port
:
u16
,
pub
d
st
_port
:
u16
,
pub
seq
:
u32
,
pub
ack
:
u32
,
pub
offset
:
u8
,
...
...
@@ -25,7 +25,7 @@ impl TCP {
return
None
;
}
let
src_port
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
d
es
_port
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
d
st
_port
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
let
seq
=
bytes
.read_u32
::
<
BigEndian
>
()
.unwrap
();
let
ack
=
bytes
.read_u32
::
<
BigEndian
>
()
.unwrap
();
let
dataoff_reserv_flags
=
bytes
.read_u16
::
<
BigEndian
>
()
.unwrap
();
...
...
@@ -37,7 +37,7 @@ impl TCP {
let
payload
=
bytes
.fill_buf
()
.unwrap
()
.to_vec
();
Some
(
TCP
{
src_port
,
d
es
_port
,
d
st
_port
,
seq
,
ack
,
offset
,
...
...
@@ -50,7 +50,6 @@ impl TCP {
}
}
#[derive(Clone)]
pub
struct
TcpFlags
{
pub
ns
:
bool
,
...
...
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