aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake McGinty <me@jake.su>2018-04-25 01:30:00 -0700
committerJake McGinty <me@jake.su>2018-04-25 01:30:00 -0700
commit3a2be07f72d02751d04285e7a92ec047c0f96412 (patch)
treedf2946089dd97bf701f3a899562d1943b105be8c
parenttests: first stab at the script working with userspace and kernel (diff)
downloadwireguard-rs-3a2be07f72d02751d04285e7a92ec047c0f96412.tar.xz
wireguard-rs-3a2be07f72d02751d04285e7a92ec047c0f96412.zip
udp: use latest nix draft, which uses latest libc
-rw-r--r--Cargo.lock61
-rw-r--r--Cargo.toml2
-rw-r--r--src/interface/config.rs2
-rw-r--r--src/interface/peer_server.rs2
-rw-r--r--src/peer.rs8
-rw-r--r--src/udp/frame.rs2
-rw-r--r--src/udp/mod.rs41
7 files changed, 58 insertions, 60 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 3604c85..0ba6e60 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -29,7 +29,7 @@ dependencies = [
[[package]]
name = "atty"
-version = "0.2.8"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -153,7 +153,7 @@ version = "2.31.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -179,7 +179,7 @@ name = "criterion"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion-plot 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion-stats 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -189,9 +189,9 @@ dependencies = [
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools-num 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -303,7 +303,7 @@ name = "derive_deref"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -430,8 +430,8 @@ dependencies = [
"pest_derive 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -504,7 +504,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.40"
-source = "git+https://github.com/rust-lang/libc#69769fbf3bbb9944def0b6b8da56b2cb2a83f2b5"
+source = "git+https://github.com/rust-lang/libc#297fc414c3225631e879ff87006ce4a53146bf1f"
[[package]]
name = "libc"
@@ -650,7 +650,7 @@ dependencies = [
[[package]]
name = "nix"
version = "0.11.0-pre"
-source = "git+https://github.com/mcginty/nix?branch=ipv6-pktinfo#9494ba35f96ce347ad5c9033cc57410eed7cec56"
+source = "git+https://github.com/mcginty/nix?branch=ipv6-pktinfo#d5c3de15edc8147e81413defb42cae375e72f744"
dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -762,7 +762,7 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -780,10 +780,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
-version = "0.5.1"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -936,16 +936,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
-version = "1.0.41"
+version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
-version = "1.0.41"
+version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive_internals 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -955,19 +955,18 @@ name = "serde_derive_internals"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_json"
-version = "1.0.15"
+version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1074,8 +1073,8 @@ name = "syn"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1476,7 +1475,7 @@ dependencies = [
"futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.40 (git+https://github.com/rust-lang/libc)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.11.0-pre (git+https://github.com/mcginty/nix?branch=ipv6-pktinfo)",
@@ -1521,7 +1520,7 @@ dependencies = [
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum arrayref 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0fd1479b7c29641adbd35ff3b5c293922d696a92f25c8c975da3e0acbc87258f"
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
-"checksum atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4"
+"checksum atty 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6609a866dd1a1b2d0ee1362195bf3e4f6438abb2d80120b83b1e1f4fb6476dd0"
"checksum backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe525f66f42d207968308ee86bc2dd60aa5fab535b22e616323a173d097d8e"
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
"checksum base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30e93c03064e7590d0466209155251b90c22e37fab1daf2771582598b5827557"
@@ -1607,10 +1606,10 @@ dependencies = [
"checksum pnet_macros 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d228096fd739d4e3e60dee9e1e4f07d9ae0f3f309c876834192538748e561e4"
"checksum pnet_macros_support 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f92b7141318df140dfb8c3f7a1a5a331edb31b1791633cc5c8f03fcd9a7f6ac4"
"checksum pnet_packet 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef99f3cfa2c0ed07e9ad6d9f788592d863361a8dd3102989d79b0f6a787ba434"
-"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"
+"checksum proc-macro2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b16749538926f394755373f0dfec0852d79b3bd512a5906ceaeb72ee64a4eaa0"
"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
-"checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a"
+"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
"checksum rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed02d09394c94ffbdfdc755ad62a132e94c3224a8354e78a1200ced34df12edf"
@@ -1629,10 +1628,10 @@ dependencies = [
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-"checksum serde 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "5f751e9d57bd42502e4362b2d84f916ed9578e9a1a46852dcdeb6f91f6de7c14"
-"checksum serde_derive 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "81ec46cb12594da6750ad5a913f8175798c371d6c5ffd07f082ac4fea32789c3"
+"checksum serde 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)" = "0c855d888276f20d140223bd06515e5bf1647fd6d02593cb5792466d9a8ec2d0"
+"checksum serde_derive 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)" = "aa113e5fc4b008a626ba2bbd41330b56c9987d667f79f7b243e5a2d03d91ed1c"
"checksum serde_derive_internals 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d30c4596450fd7bbda79ef15559683f9a79ac0193ea819db90000d7e1cae794"
-"checksum serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7bf1cbb1387028a13739cb018ee0d9b3db534f22ca3c84a5904f7eadfde14e75"
+"checksum serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6c4e049dc657a99e394bd85c22acbf97356feeec6dbf44150f2dcf79fb3118"
"checksum simplelog 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce595117de34b75e057b41e99079e43e9fcc4e5ec9c7ba5f2fea55321f0c624e"
"checksum slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d807fd58c4181bbabed77cb3b891ba9748241a552bcc5be698faaebefc54f46e"
"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d"
diff --git a/Cargo.toml b/Cargo.toml
index c070568..2946d1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,7 +38,7 @@ derive_deref = "^1.0"
failure = "^0.1"
futures = "^0.1"
lazy_static = "^1"
-libc = "^0.2"
+libc = { git = "https://github.com/rust-lang/libc" }
log = "^0.4"
hex = "^0.3"
notify = "4.0.0"
diff --git a/src/interface/config.rs b/src/interface/config.rs
index 488b5bb..d8a7a9d 100644
--- a/src/interface/config.rs
+++ b/src/interface/config.rs
@@ -258,7 +258,7 @@ impl ConfigurationService {
} else {
info.allowed_ips.extend_from_slice(&peer.info.allowed_ips);
}
- info.endpoint = info.endpoint.or(peer.info.endpoint);
+ info.endpoint = info.endpoint.or(peer.info.endpoint.clone());
info.keepalive = info.keepalive.or(peer.info.keepalive);
info.psk = info.psk.or(peer.info.psk);
state.router.add_allowed_ips(&info.allowed_ips, &peer_ref);
diff --git a/src/interface/peer_server.rs b/src/interface/peer_server.rs
index 4de6eec..b541caa 100644
--- a/src/interface/peer_server.rs
+++ b/src/interface/peer_server.rs
@@ -146,7 +146,7 @@ impl PeerServer {
.ok_or_else(|| err_msg("unknown peer pubkey"))?.clone();
let index = Self::unused_index(&mut state);
- let (response, dead_index) = peer_ref.borrow_mut().complete_incoming_handshake(addr, index, handshake)?;
+ let (response, dead_index) = peer_ref.borrow_mut().complete_incoming_handshake(addr.clone(), index, handshake)?;
if let Some(index) = dead_index {
let _ = state.index_map.remove(&index);
}
diff --git a/src/peer.rs b/src/peer.rs
index 4899893..7115a6f 100644
--- a/src/peer.rs
+++ b/src/peer.rs
@@ -221,7 +221,7 @@ impl Peer {
pub fn initiate_new_session(&mut self, private_key: &[u8], index: u32) -> Result<(Endpoint, Vec<u8>, Option<u32>), Error> {
let noise = noise::build_initiator(private_key, &self.info.pub_key, &self.info.psk)?;
let mut session = Session::new(noise, index);
- let endpoint = self.info.endpoint.ok_or_else(|| err_msg("no known peer endpoint"))?;
+ let endpoint = self.info.endpoint.as_ref().ok_or_else(|| err_msg("no known peer endpoint"))?;
let mut packet = vec![0; 148];
let tai64n = Tai64n::now();
@@ -242,7 +242,7 @@ impl Peer {
None
};
- Ok((endpoint, packet, dead_index))
+ Ok((endpoint.clone(), packet, dead_index))
}
pub fn process_incoming_handshake(private_key: &[u8], packet: &Initiation) -> Result<IncompleteIncomingHandshake, Error> {
@@ -378,7 +378,7 @@ impl Peer {
pub fn handle_outgoing_transport(&mut self, packet: &[u8]) -> Result<(Endpoint, Vec<u8>), Error> {
let session = self.sessions.current.as_mut().ok_or_else(|| err_msg("no current noise session"))?;
- let endpoint = self.info.endpoint.ok_or_else(|| err_msg("no known peer endpoint"))?;
+ let endpoint = self.info.endpoint.as_ref().ok_or_else(|| err_msg("no known peer endpoint"))?;
let padding = PADDING_MULTIPLE - (packet.len() % PADDING_MULTIPLE);
let padded_len = packet.len() + padding;
let mut out_packet = vec![0u8; padded_len + TRANSPORT_OVERHEAD];
@@ -395,7 +395,7 @@ impl Peer {
self.tx_bytes += len as u64;
session.last_sent = Timestamp::now();
out_packet.truncate(TRANSPORT_HEADER_SIZE + len);
- Ok((endpoint, out_packet))
+ Ok((endpoint.clone(), out_packet))
}
pub fn to_config_string(&self) -> String {
diff --git a/src/udp/frame.rs b/src/udp/frame.rs
index b0f1dd4..09418bb 100644
--- a/src/udp/frame.rs
+++ b/src/udp/frame.rs
@@ -141,7 +141,7 @@ pub type PeerServerMessage = (Endpoint, Vec<u8>);
pub struct VecUdpCodec;
impl VecUdpCodec {
fn decode(&mut self, src: &Endpoint, buf: &[u8]) -> io::Result<PeerServerMessage> {
- Ok((*src, buf.to_vec()))
+ Ok((src.clone(), buf.to_vec()))
}
fn encode(&mut self, msg: PeerServerMessage, buf: &mut Vec<u8>) -> Endpoint {
diff --git a/src/udp/mod.rs b/src/udp/mod.rs
index 55fae54..7de1fb1 100644
--- a/src/udp/mod.rs
+++ b/src/udp/mod.rs
@@ -5,13 +5,11 @@ use std::net::{self, SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr}
use std::os::unix::io::{AsRawFd, RawFd};
use futures::{Async, Future, Poll};
-use libc;
+use libc::{self, in_pktinfo, in6_pktinfo, in_addr, in6_addr};
use mio;
use nix::{self, errno::Errno};
use nix::sys::{uio::IoVec,
socket::{
- in6_pktinfo,
- in_pktinfo,
CmsgSpace,
ControlMessage,
InetAddr,
@@ -42,12 +40,22 @@ pub struct UdpSocket {
// but this is for simplicity because nix only offers a to_std() that returns
// `SocketAddr` from its `SockAddr`, so it makes the code cleaner with little
// performance impact.
-#[derive(Clone, Copy, Debug)]
+#[derive(Clone)]
pub enum Endpoint {
V4(SocketAddr, Option<in_pktinfo>),
V6(SocketAddr, Option<in6_pktinfo>)
}
+impl fmt::Debug for Endpoint {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match *self {
+ Endpoint::V4(addr, pktinfo) => write!(f, "Endpoint::V4({}, ...)", addr),
+ Endpoint::V6(addr, pktinfo) => write!(f, "Endpoint::V6({}, ...)", addr),
+
+ }
+ }
+}
+
impl Endpoint {
fn addr(&self) -> SocketAddr {
match *self {
@@ -84,7 +92,7 @@ impl From<SocketAddr> for Endpoint {
}
}
-#[derive(Clone, Copy, Debug)]
+#[derive(Clone)]
pub enum PktInfo {
V4(in_pktinfo),
V6(in6_pktinfo),
@@ -169,18 +177,9 @@ impl UdpSocket {
}
let cmsgs = match *target {
- Endpoint::V4(addr, Some(ref pktinfo)) => {
- trace!("sending cmsg: {:?}", pktinfo);
- vec![ControlMessage::Ipv4PacketInfo(pktinfo)]
- },
- Endpoint::V6(addr, Some(ref pktinfo)) => {
- trace!("sending cmsg: {:?}", pktinfo);
- vec![ControlMessage::Ipv6PacketInfo(pktinfo)]
- },
- _ => {
- trace!("not sending any pktinfo");
- vec![]
- }
+ Endpoint::V4(addr, Some(ref pktinfo)) => vec![ControlMessage::Ipv4PacketInfo(pktinfo)],
+ Endpoint::V6(addr, Some(ref pktinfo)) => vec![ControlMessage::Ipv6PacketInfo(pktinfo)],
+ _ => vec![]
};
let res = sendmsg(io.get_ref().as_raw_fd(),
@@ -234,11 +233,11 @@ impl UdpSocket {
match msg.cmsgs().next() {
Some(ControlMessage::Ipv4PacketInfo(info)) => {
trace!("ipv4 cmsg (\n ipi_addr: {:?},\n ipi_spec_dst: {:?},\n ipi_ifindex: {}\n)",
- Ipv4Addr::from(info.ipi_addr),
- Ipv4Addr::from(info.ipi_spec_dst),
+ Ipv4Addr::from(info.ipi_addr.s_addr),
+ Ipv4Addr::from(info.ipi_spec_dst.s_addr),
info.ipi_ifindex);
let endpoint = Endpoint::V4(addr.to_std(), Some(in_pktinfo {
- ipi_addr : [0u8; 4],
+ ipi_addr : in_addr { s_addr: 0 },
ipi_spec_dst: info.ipi_addr,
ipi_ifindex : info.ipi_ifindex,
}));
@@ -246,7 +245,7 @@ impl UdpSocket {
},
Some(ControlMessage::Ipv6PacketInfo(info)) => {
trace!("ipv6 cmsg (\n ipi6_addr: {:?},\n ipi6_ifindex: {}\n)",
- Ipv6Addr::from(info.ipi6_addr),
+ Ipv6Addr::from(info.ipi6_addr.s6_addr),
info.ipi6_ifindex);
let endpoint = Endpoint::V6(addr.to_std(), Some(*info));
Ok((msg.bytes, endpoint))