From 8ab189cd569cc5c049e48b283ede8d717f984a53 Mon Sep 17 00:00:00 2001 From: Mute Date: Thu, 13 Aug 2026 07:41:49 +0000 Subject: [PATCH] fix compile errors in gatunad - io::last_os_error() -> io::Error::last_os_error() - MacAddr(mac.0) -> MacAddr(mac.octets()) for pnet 0.35 - cast htons() result to c_int for libc::socket protocol arg - mark read as mut in spawn_pump --- gatunad/src/link.rs | 24 ++++++++++++++---------- gatunad/src/session.rs | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gatunad/src/link.rs b/gatunad/src/link.rs index 8ec2bb5..2379aee 100644 --- a/gatunad/src/link.rs +++ b/gatunad/src/link.rs @@ -68,7 +68,7 @@ fn lookup_mac(iface: &str) -> io::Result { for ni in pnet_datalink::interfaces() { if ni.name == iface { if let Some(mac) = ni.mac { - return Ok(MacAddr(mac.0)); + return Ok(MacAddr(mac.octets())); } } } @@ -81,20 +81,24 @@ fn lookup_mac(iface: &str) -> io::Result { impl Link { pub fn open(iface: &str) -> io::Result { unsafe { - let fd = libc::socket(libc::AF_PACKET, libc::SOCK_RAW, htons(libc::ETH_P_ALL as u16)); + let fd = libc::socket( + libc::AF_PACKET, + libc::SOCK_RAW, + htons(libc::ETH_P_ALL as u16) as libc::c_int, + ); if fd < 0 { - return Err(io::last_os_error()); + return Err(io::Error::last_os_error()); } // Non-blocking for AsyncFd. let flags = libc::fcntl(fd, libc::F_GETFL); if flags < 0 { - let e = io::last_os_error(); + let e = io::Error::last_os_error(); libc::close(fd); return Err(e); } if libc::fcntl(fd, libc::F_SETFL, flags | libc::O_NONBLOCK) < 0 { - let e = io::last_os_error(); + let e = io::Error::last_os_error(); libc::close(fd); return Err(e); } @@ -111,7 +115,7 @@ impl Link { }; let ifindex = libc::if_nametoindex(ciface.as_ptr()); if ifindex == 0 { - let e = io::last_os_error(); + let e = io::Error::last_os_error(); libc::close(fd); return Err(e); } @@ -127,7 +131,7 @@ impl Link { std::mem::size_of::() as libc::socklen_t, ); if r < 0 { - let e = io::last_os_error(); + let e = io::Error::last_os_error(); libc::close(fd); return Err(e); } @@ -146,7 +150,7 @@ impl Link { std::mem::size_of::() as libc::socklen_t, ); if r < 0 { - let e = io::last_os_error(); + let e = io::Error::last_os_error(); libc::close(fd); return Err(e); } @@ -191,7 +195,7 @@ impl Link { ) }; if n < 0 { - return Err(io::last_os_error()); + return Err(io::Error::last_os_error()); } // Skip frames we transmitted (AF_PACKET with ETH_P_ALL loops them back). if sll.sll_pkttype == libc::PACKET_OUTGOING { @@ -239,7 +243,7 @@ impl Link { ) }; if r < 0 { - return Err(io::last_os_error()); + return Err(io::Error::last_os_error()); } Ok(()) } diff --git a/gatunad/src/session.rs b/gatunad/src/session.rs index c2d9e22..4a3a5c5 100644 --- a/gatunad/src/session.rs +++ b/gatunad/src/session.rs @@ -48,7 +48,7 @@ pub async fn write_to_session( /// 1480-byte chunks and emits DATA frames. On EOF/error sends CLOSE and /// removes the session from the store. pub fn spawn_pump( - read: OwnedReadHalf, + mut read: OwnedReadHalf, session_id: u32, peer_mac: MacAddr, tx: TxChan,