From 2b7f92a43a7b30e2e2b8f9023e75f1a5d971992a Mon Sep 17 00:00:00 2001 From: James Peach Date: Sun, 1 May 2016 17:56:48 -0700 Subject: [PATCH] Support sockaddr_nl in sockaddr_storage_to_addr(). Add support for converting AF_NETLINK sockaddr_nl addresses to Sockaddr::Netlink(). This lets socket::recvmsg() work on netlink sockets. --- src/sys/socket/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index c96a5c8da8..0846eaf52a 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -630,6 +630,11 @@ pub unsafe fn sockaddr_storage_to_addr( consts::AF_UNIX => { Ok(SockAddr::Unix(UnixAddr(*(addr as *const _ as *const sockaddr_un), len))) } + #[cfg(any(target_os = "linux", target_os = "android"))] + consts::AF_NETLINK => { + use libc::sockaddr_nl; + Ok(SockAddr::Netlink(NetlinkAddr(*(addr as *const _ as *const sockaddr_nl)))) + } af => panic!("unexpected address family {}", af), } }