remove InetAddr from streamer/src/sendmmsg.rs (#557)

* remove InetAddr from streamer/src/sendmmsg.rs

* add ref links

* use SocketAddr conversion directly
This commit is contained in:
Yihau Chen 2024-04-07 00:35:31 +08:00 committed by GitHub
parent be09b497cb
commit 01460ef5cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 10 deletions

View File

@ -1,8 +1,5 @@
//! The `sendmmsg` module provides sendmmsg() API implementation
#[cfg(target_os = "linux")]
#[allow(deprecated)]
use nix::sys::socket::InetAddr;
#[cfg(target_os = "linux")]
use {
itertools::izip,
@ -76,21 +73,26 @@ fn mmsghdr_for_packet(
hdr.msg_hdr.msg_iovlen = 1;
hdr.msg_hdr.msg_name = addr as *mut _ as *mut _;
#[allow(deprecated)]
match InetAddr::from_std(dest) {
InetAddr::V4(dest) => {
match dest {
SocketAddr::V4(socket_addr_v4) => {
unsafe {
std::ptr::write(addr as *mut _ as *mut _, dest);
std::ptr::write(
addr as *mut _ as *mut _,
*nix::sys::socket::SockaddrIn::from(*socket_addr_v4).as_ref(),
);
}
hdr.msg_hdr.msg_namelen = SIZE_OF_SOCKADDR_IN as u32;
}
InetAddr::V6(dest) => {
SocketAddr::V6(socket_addr_v6) => {
unsafe {
std::ptr::write(addr as *mut _ as *mut _, dest);
std::ptr::write(
addr as *mut _ as *mut _,
*nix::sys::socket::SockaddrIn6::from(*socket_addr_v6).as_ref(),
);
}
hdr.msg_hdr.msg_namelen = SIZE_OF_SOCKADDR_IN6 as u32;
}
};
}
}
#[cfg(target_os = "linux")]