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:
parent
be09b497cb
commit
01460ef5cc
|
@ -1,8 +1,5 @@
|
||||||
//! The `sendmmsg` module provides sendmmsg() API implementation
|
//! The `sendmmsg` module provides sendmmsg() API implementation
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
use nix::sys::socket::InetAddr;
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use {
|
use {
|
||||||
itertools::izip,
|
itertools::izip,
|
||||||
|
@ -76,21 +73,26 @@ fn mmsghdr_for_packet(
|
||||||
hdr.msg_hdr.msg_iovlen = 1;
|
hdr.msg_hdr.msg_iovlen = 1;
|
||||||
hdr.msg_hdr.msg_name = addr as *mut _ as *mut _;
|
hdr.msg_hdr.msg_name = addr as *mut _ as *mut _;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
match dest {
|
||||||
match InetAddr::from_std(dest) {
|
SocketAddr::V4(socket_addr_v4) => {
|
||||||
InetAddr::V4(dest) => {
|
|
||||||
unsafe {
|
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;
|
hdr.msg_hdr.msg_namelen = SIZE_OF_SOCKADDR_IN as u32;
|
||||||
}
|
}
|
||||||
InetAddr::V6(dest) => {
|
SocketAddr::V6(socket_addr_v6) => {
|
||||||
unsafe {
|
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;
|
hdr.msg_hdr.msg_namelen = SIZE_OF_SOCKADDR_IN6 as u32;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|
Loading…
Reference in New Issue