42 lines
1,014 B
Rust
42 lines
1,014 B
Rust
#[derive(Debug, PartialEq)]
|
|
pub enum PacketInfo {
|
|
// <https://www.geeksforgeeks.org/computer-networks/what-is-ipv4/>
|
|
V4 {
|
|
src_ip: Ipv4,
|
|
src_port: Port,
|
|
dst_ip: Ipv4,
|
|
dst_port: Port,
|
|
protocol: Protocol,
|
|
dns: bool,
|
|
},
|
|
// <https://www.geeksforgeeks.org/computer-networks/internet-protocol-version-6-ipv6-header/>
|
|
V6 {
|
|
src_ip: Ipv6,
|
|
src_port: Port,
|
|
dst_ip: Ipv6,
|
|
dst_port: Port,
|
|
protocol: Protocol,
|
|
dns: bool,
|
|
},
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum Protocol {
|
|
TCP,
|
|
UDP,
|
|
Unsupported(u8),
|
|
}
|
|
pub type SourceV4Ip = Ipv4;
|
|
pub type SourceV6Ip = Ipv6;
|
|
#[derive(PartialEq, Debug)]
|
|
pub enum IpVersion {
|
|
V4,
|
|
V6,
|
|
}
|
|
pub type Ipv4 = [u8; 4];
|
|
pub type Ipv6 = [u16; 8];
|
|
pub type Port = u16;
|
|
|
|
pub type GenericError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
|
pub type SniffedPacket = Result<PacketInfo, Box<dyn std::error::Error + Send + Sync + 'static>>;
|
|
pub type Packet = [u8];
|