Skip to content

Commit

Permalink
remove InetAddr from streamer/src/sendmmsg.rs (solana-labs#557)
Browse files Browse the repository at this point in the history
* remove InetAddr from streamer/src/sendmmsg.rs

* add ref links

* use SocketAddr conversion directly
  • Loading branch information
yihau authored Apr 6, 2024
1 parent be09b49 commit 01460ef
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions streamer/src/sendmmsg.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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")]
Expand Down

0 comments on commit 01460ef

Please sign in to comment.