diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-03-05 00:35:09 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-03-05 00:35:09 +0100 |
commit | 7c7955cb5dbd2a403e31906242e20e038dd4206a (patch) | |
tree | afc1e04e02485406dcd8f09ee5b5191b4d613aa2 /src/util.rs | |
parent | 58489789baf2b3a2319333c80433accb6b5aaac0 (diff) |
actually bind to the interfaces
this server is now truly multi-interface
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/util.rs b/src/util.rs index 7fa8f5e..d131753 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,10 +1,8 @@ use crate::error::{Error, Result}; -use std::ffi::c_int; +use std::ffi::{c_char, c_int}; use std::io; -use std::mem; use std::net::Ipv4Addr; -use std::ptr; /// Helper macro to execute a system call that returns an `io::Result`. macro_rules! syscall { @@ -35,14 +33,19 @@ pub fn local_ip(link: &str) -> Result<Ipv4Addr> { } #[allow(clippy::missing_safety_doc)] -pub unsafe fn setsockopt<T>(fd: c_int, opt: c_int, val: c_int, payload: T) -> io::Result<()> { - let payload = ptr::addr_of!(payload).cast(); +pub unsafe fn setsockopt( + fd: c_int, + opt: c_int, + val: c_int, + payload: *const c_char, + optlen: c_int, +) -> io::Result<()> { syscall!(setsockopt( fd, opt, val, - payload, - mem::size_of::<T>() as libc::socklen_t + payload.cast(), + optlen as libc::socklen_t )) .map(|_| ()) } |