1#![cfg(feature = "agave-unstable-api")]
2
3#[cfg(target_os = "linux")]
4pub mod device;
5#[cfg(target_os = "linux")]
6pub mod gre;
7#[cfg(target_os = "linux")]
8pub(crate) mod lpm;
9#[cfg(target_os = "linux")]
10pub mod netlink;
11#[cfg(target_os = "linux")]
12pub mod packet;
13#[cfg(target_os = "linux")]
14mod program;
15#[cfg(target_os = "linux")]
16pub mod route;
17#[cfg(target_os = "linux")]
18pub mod route_monitor;
19#[cfg(target_os = "linux")]
20pub mod socket;
21#[cfg(target_os = "linux")]
22pub mod tx_loop;
23#[cfg(target_os = "linux")]
24pub mod umem;
25
26pub mod ecn_codepoint;
27
28pub mod transmitter;
29
30#[cfg(target_os = "linux")]
31pub use program::load_xdp_program;
32use std::{io, net::Ipv4Addr};
33
34#[cfg(target_os = "linux")]
38pub fn interface_ipv4(interface: &str) -> Result<Ipv4Addr, io::Error> {
39 if let Some(ip) = crate::transmitter::master_ip_if_bonded(interface) {
40 Ok(ip)
41 } else {
42 crate::device::NetworkDevice::new(interface)?.ipv4_addr()
43 }
44}
45
46#[cfg(not(target_os = "linux"))]
47pub fn interface_ipv4(_interface: &str) -> Result<Ipv4Addr, io::Error> {
48 unimplemented!()
49}
50
51#[cfg(target_os = "linux")]
53pub fn default_device_ipv4() -> Result<Ipv4Addr, io::Error> {
54 crate::device::NetworkDevice::new_from_default_route()?.ipv4_addr()
55}
56
57#[cfg(not(target_os = "linux"))]
58pub fn default_device_ipv4() -> Result<Ipv4Addr, io::Error> {
59 unimplemented!()
60}