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
94958e03
Commit
94958e03
authored
Jun 14, 2024
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add get_ip and arp to network
parent
e17a2926
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
0 deletions
+26
-0
ethernet.rs
src/etherparser/ethernet.rs
+16
-0
arp.rs
src/etherparser/packet/arp.rs
+2
-0
icmp.rs
src/etherparser/packet/icmp.rs
+1
-0
ipv4.rs
src/etherparser/packet/ipv4.rs
+3
-0
tcp.rs
src/etherparser/packet/tcp.rs
+3
-0
udp.rs
src/etherparser/packet/udp.rs
+1
-0
No files found.
src/etherparser/ethernet.rs
View file @
94958e03
...
...
@@ -77,3 +77,19 @@ pub enum Network {
ARP
(
ARP
),
Unparsable
(
u16
,
Vec
<
u8
>
),
}
impl
Network
{
pub
fn
get_ip
(
&
self
)
->
Option
<
IP
>
{
match
self
{
Network
::
IP
(
ip
)
=>
Some
(
ip
.clone
()),
_
=>
None
,
}
}
pub
fn
get_arp
(
&
self
)
->
Option
<
ARP
>
{
if
let
Network
::
ARP
(
arp
)
=
self
{
Some
(
arp
.clone
())
}
else
{
None
}
}
}
src/etherparser/packet/arp.rs
View file @
94958e03
...
...
@@ -2,12 +2,14 @@ use std::io::Cursor;
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
#[derive(Clone)]
pub
enum
ArpOperation
{
Query
=
0x0001
,
Reply
=
0x0002
,
Unparse
,
}
#[derive(Clone)]
pub
struct
ARP
{
pub
hardware_type
:
u16
,
pub
protocol_type
:
u16
,
...
...
src/etherparser/packet/icmp.rs
View file @
94958e03
...
...
@@ -2,6 +2,7 @@ use std::io::{BufRead, Cursor};
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
#[derive(Clone)]
pub
struct
ICMP
{
pub
typ
:
u8
,
pub
code
:
u8
,
...
...
src/etherparser/packet/ipv4.rs
View file @
94958e03
...
...
@@ -2,6 +2,7 @@ use super::{tcp::TCP, udp::UDP, ICMP};
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
use
std
::
io
::{
BufRead
,
Cursor
,
Read
};
#[derive(Clone)]
pub
struct
Flags
{
pub
dont_flagment
:
bool
,
pub
more_fragments
:
bool
,
...
...
@@ -13,6 +14,7 @@ pub enum IpProtocol {
UDP
=
0x11
,
}
#[derive(Clone)]
pub
struct
IP
{
pub
version
:
u8
,
pub
ihl
:
u8
,
...
...
@@ -103,6 +105,7 @@ impl IP {
}
}
#[derive(Clone)]
pub
enum
EtherData
{
ICMP
(
ICMP
),
TCP
(
TCP
),
...
...
src/etherparser/packet/tcp.rs
View file @
94958e03
...
...
@@ -2,6 +2,7 @@ use crate::etherparser::tools::bits::bit_bool;
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
use
std
::
io
::{
BufRead
,
Cursor
};
#[derive(Clone)]
pub
struct
TCP
{
pub
src_port
:
u16
,
pub
des_port
:
u16
,
...
...
@@ -49,6 +50,8 @@ impl TCP {
}
}
#[derive(Clone)]
pub
struct
TcpFlags
{
pub
ns
:
bool
,
pub
cwr
:
bool
,
...
...
src/etherparser/packet/udp.rs
View file @
94958e03
...
...
@@ -2,6 +2,7 @@ use std::io::{BufRead, Cursor};
use
byteorder
::{
BigEndian
,
ReadBytesExt
};
#[derive(Clone)]
pub
struct
UDP
{
pub
src_port
:
u16
,
pub
des_port
:
u16
,
...
...
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