Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Use nix new api
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Apr 21, 2022
1 parent e8faca7 commit dde05d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions streamer/src/sendmmsg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use {
itertools::izip,
libc::{iovec, mmsghdr, sockaddr_in, sockaddr_in6, sockaddr_storage},
nix::sys::socket::InetAddr,
nix::sys::socket::{SockaddrIn, SockaddrIn6},
std::os::unix::io::AsRawFd,
};
use {
Expand Down Expand Up @@ -74,14 +74,16 @@ fn mmsghdr_for_packet(
hdr.msg_hdr.msg_iovlen = 1;
hdr.msg_hdr.msg_name = addr as *mut _ as *mut _;

match InetAddr::from_std(dest) {
InetAddr::V4(dest) => {
match dest {
SocketAddr::V4(dest) => {
let dest = SockaddrIn::from(dest);
unsafe {
std::ptr::write(addr as *mut _ as *mut _, dest);
}
hdr.msg_hdr.msg_namelen = SIZE_OF_SOCKADDR_IN as u32;
}
InetAddr::V6(dest) => {
SocketAddr::V6(dest) => {
let dest = SockaddrIn6::from(dest);
unsafe {
std::ptr::write(addr as *mut _ as *mut _, dest);
}
Expand Down

0 comments on commit dde05d8

Please sign in to comment.