|
fn addr2raw( |
|
addr: &std::net::SocketAddr, |
|
) -> (*const libc::sockaddr, libc::socklen_t) { |
|
match *addr { |
|
std::net::SocketAddr::V4(ref a) => { |
|
let b: *const std::net::SocketAddrV4 = a; |
|
( |
|
b as *const _, |
|
std::mem::size_of_val(a) as libc::socklen_t, |
|
) |
|
} |
|
std::net::SocketAddr::V6(ref a) => { |
|
let b: *const std::net::SocketAddrV6 = a; |
|
( |
|
b as *const _, |
|
std::mem::size_of_val(a) as libc::socklen_t, |
|
) |
|
} |
|
} |
|
} |
This code assumes that the layout of std::net::SocketAddrV{4,6} matches libc::sockaddr, but std makes no such promise. See rust-lang/rust#78802 for more details.
Example fixes: tokio-rs/mio#1388, rust-lang/socket2#120.
rio/src/io_uring/uring.rs
Lines 733 to 752 in 319f7fb
This code assumes that the layout of
std::net::SocketAddrV{4,6}matcheslibc::sockaddr, but std makes no such promise. See rust-lang/rust#78802 for more details.Example fixes: tokio-rs/mio#1388, rust-lang/socket2#120.