Skip to content

Commit

Permalink
Expand TCP / UDP binding interface to android.
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIMP committed Mar 14, 2024
1 parent 65e0fb7 commit 5840308
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions commons/zenoh-util/src/std_only/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ pub fn get_ipv6_ipaddrs(interface: Option<&str>) -> Vec<IpAddr> {
.collect()
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn set_bind_to_device(socket: std::os::raw::c_int, iface: Option<&str>) {
if let Some(iface) = iface {
// @TODO: switch to bind_device after tokio porting
Expand All @@ -509,19 +509,19 @@ fn set_bind_to_device(socket: std::os::raw::c_int, iface: Option<&str>) {
}
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn set_bind_to_device_tcp_listener(socket: &TcpListener, iface: Option<&str>) {
use std::os::fd::AsRawFd;
set_bind_to_device(socket.as_raw_fd(), iface);
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn set_bind_to_device_tcp_stream(socket: &TcpStream, iface: Option<&str>) {
use std::os::fd::AsRawFd;
set_bind_to_device(socket.as_raw_fd(), iface);
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn set_bind_to_device_udp_socket(socket: &UdpSocket, iface: Option<&str>) {
use std::os::fd::AsRawFd;
set_bind_to_device(socket.as_raw_fd(), iface);
Expand Down

0 comments on commit 5840308

Please sign in to comment.