main
shellrow 3 years ago
parent 8d78aa85ff
commit eb16ba8c99
  1. 3
      src/gateway/mod.rs
  2. 35
      src/interface/types.rs

@ -10,11 +10,14 @@ use crate::interface::{self, MacAddr, Interface};
/// Structure of default Gateway information /// Structure of default Gateway information
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Gateway { pub struct Gateway {
/// MAC address of Gateway
pub mac_addr: MacAddr, pub mac_addr: MacAddr,
/// IP address of Gateway
pub ip_addr: IpAddr, pub ip_addr: IpAddr,
} }
impl Gateway { impl Gateway {
/// Construct a new Gateway instance
pub fn new() -> Gateway { pub fn new() -> Gateway {
Gateway { Gateway {
mac_addr: MacAddr::zero(), mac_addr: MacAddr::zero(),

@ -3,37 +3,66 @@ use std::convert::TryFrom;
/// Type of Network Interface /// Type of Network Interface
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum InterfaceType { pub enum InterfaceType {
/// Unknown interface type
Unknown, Unknown,
/// The network interface using an Ethernet connection
Ethernet, Ethernet,
/// The network interface using a Token-Ring connection
TokenRing, TokenRing,
/// The network interface using a Fiber Distributed Data Interface (FDDI) connection
Fddi, Fddi,
/// The network interface using a basic rate interface Integrated Services Digital Network (ISDN) connection
BasicIsdn, BasicIsdn,
/// The network interface using a primary rate interface Integrated Services Digital Network (ISDN) connection
PrimaryIsdn, PrimaryIsdn,
/// The network interface using a Point-To-Point protocol (PPP) connection
Ppp, Ppp,
/// The loopback interface (often used for testing)
Loopback, Loopback,
/// The network interface using an Ethernet 3 megabit/second connection
Ethernet3Megabit, Ethernet3Megabit,
/// The network interface using a Serial Line Internet Protocol (SLIP) connection
Slip, Slip,
/// The network interface using asynchronous transfer mode (ATM) for data transmission
Atm, Atm,
/// The network interface using a modem
GenericModem, GenericModem,
/// The network interface using a Fast Ethernet connection over twisted pair and provides a data rate of 100 megabits per second (100BASE-T)
FastEthernetT, FastEthernetT,
/// The network interface using a connection configured for ISDN and the X.25 protocol.
Isdn, Isdn,
/// The network interface using a Fast Ethernet connection over optical fiber and provides a data rate of 100 megabits per second (100Base-FX)
FastEthernetFx, FastEthernetFx,
/// The network interface using a wireless LAN connection (IEEE 802.11)
Wireless80211, Wireless80211,
/// The network interface using an Asymmetric Digital Subscriber Line (ADSL)
AsymmetricDsl, AsymmetricDsl,
/// The network interface using a Rate Adaptive Digital Subscriber Line (RADSL)
RateAdaptDsl, RateAdaptDsl,
/// The network interface using a Symmetric Digital Subscriber Line (SDSL)
SymmetricDsl, SymmetricDsl,
/// The network interface using a Very High Data Rate Digital Subscriber Line (VDSL)
VeryHighSpeedDsl, VeryHighSpeedDsl,
/// The network interface using the Internet Protocol (IP) in combination with asynchronous transfer mode (ATM) for data transmission
IPOverAtm, IPOverAtm,
/// The network interface using a gigabit Ethernet connection and provides a data rate of 1,000 megabits per second (1 gigabit per second)
GigabitEthernet, GigabitEthernet,
/// The network interface using a tunnel connection
Tunnel, Tunnel,
/// The network interface using a Multirate Digital Subscriber Line
MultiRateSymmetricDsl, MultiRateSymmetricDsl,
/// The network interface using a High Performance Serial Bus
HighPerformanceSerialBus, HighPerformanceSerialBus,
/// The network interface using a mobile broadband interface for WiMax devices
Wman, Wman,
/// The network interface using a mobile broadband interface for GSM-based devices
Wwanpp, Wwanpp,
/// The network interface using a mobile broadband interface for CDMA-based devices
Wwanpp2, Wwanpp2,
} }
impl InterfaceType { impl InterfaceType {
/// Returns OS-specific value of InterfaceType
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub fn value(&self) -> u32 { pub fn value(&self) -> u32 {
match *self { match *self {
@ -67,7 +96,7 @@ impl InterfaceType {
InterfaceType::Wwanpp2 => 244, InterfaceType::Wwanpp2 => 244,
} }
} }
/// Returns OS-specific value of InterfaceType
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
pub fn value(&self) -> u32 { pub fn value(&self) -> u32 {
match *self { match *self {
@ -84,7 +113,7 @@ impl InterfaceType {
_ => u32::MAX, _ => u32::MAX,
} }
} }
/// Returns OS-specific value of InterfaceType
#[cfg(any(target_os = "macos", target_os = "openbsd", target_os = "freebsd", target_os = "netbsd", target_os = "ios"))] #[cfg(any(target_os = "macos", target_os = "openbsd", target_os = "freebsd", target_os = "netbsd", target_os = "ios"))]
pub fn value(&self) -> u32 { pub fn value(&self) -> u32 {
// TODO // TODO
@ -92,7 +121,7 @@ impl InterfaceType {
_ => 0, _ => 0,
} }
} }
/// Returns name of InterfaceType
pub fn name(&self) -> String { pub fn name(&self) -> String {
match *self { match *self {
InterfaceType::Unknown => String::from("Unknown"), InterfaceType::Unknown => String::from("Unknown"),

Loading…
Cancel
Save