diff options
author | Jake McGinty <me@jake.su> | 2018-04-13 20:23:53 -0700 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-04-22 14:08:41 -0700 |
commit | 930f4effb5abc7cb27b178657f2ec99b29da9e34 (patch) | |
tree | 23c22810350ccd28fc105361b59e0516dd3ab9fb /src/udp/frame.rs | |
parent | udp: remove the unused Connected/Unconnected UDP enum (diff) | |
download | wireguard-rs-930f4effb5abc7cb27b178657f2ec99b29da9e34.tar.xz wireguard-rs-930f4effb5abc7cb27b178657f2ec99b29da9e34.zip |
udp: dual-stack single socket -> dual socket
Diffstat (limited to 'src/udp/frame.rs')
-rw-r--r-- | src/udp/frame.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/udp/frame.rs b/src/udp/frame.rs index 860d421..f04b004 100644 --- a/src/udp/frame.rs +++ b/src/udp/frame.rs @@ -168,13 +168,15 @@ impl VecUdpCodec { pub struct UdpChannel { pub ingress : stream::SplitStream<UdpFramed>, pub egress : mpsc::Sender<PeerServerMessage>, - pub fd : RawFd, + pub fd4 : RawFd, + pub fd6 : RawFd, handle : Handle, } impl From<UdpFramed> for UdpChannel { fn from(framed: UdpFramed) -> Self { - let fd = framed.socket.as_raw_fd(); + let fd4 = framed.socket.as_raw_fd_v4(); + let fd6 = framed.socket.as_raw_fd_v6(); let handle = framed.socket.handle.clone(); let (udp_sink, ingress) = framed.split(); let (egress, egress_rx) = mpsc::channel(1024); @@ -189,7 +191,7 @@ impl From<UdpFramed> for UdpChannel { handle.spawn(udp_writethrough); - UdpChannel { egress, ingress, fd, handle } + UdpChannel { egress, ingress, fd4, fd6, handle } } } @@ -200,7 +202,9 @@ impl UdpChannel { #[cfg(target_os = "linux")] pub fn set_mark(&self, mark: u32) -> Result<(), Error> { - Ok(setsockopt(self.fd, sockopt::Mark, &mark)?) + setsockopt(self.fd4, sockopt::Mark, &mark)?; + setsockopt(self.fd6, sockopt::Mark, &mark)?; + Ok(()) } #[cfg(not(target_os = "linux"))] |