mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 21:21:32 +00:00
krata: restructure packages for cleanliness
This commit is contained in:
29
crates/network/src/nat/key.rs
Normal file
29
crates/network/src/nat/key.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use smoltcp::wire::{EthernetAddress, IpEndpoint};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
|
||||
pub enum NatKeyProtocol {
|
||||
Tcp,
|
||||
Udp,
|
||||
Icmp,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
|
||||
pub struct NatKey {
|
||||
pub protocol: NatKeyProtocol,
|
||||
pub client_mac: EthernetAddress,
|
||||
pub local_mac: EthernetAddress,
|
||||
pub client_ip: IpEndpoint,
|
||||
pub external_ip: IpEndpoint,
|
||||
}
|
||||
|
||||
impl Display for NatKey {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{} -> {} {:?} {} -> {}",
|
||||
self.client_mac, self.local_mac, self.protocol, self.client_ip, self.external_ip
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user