diff options
author | Jake McGinty <me@jake.su> | 2018-04-13 22:55:02 -0700 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-04-22 14:08:53 -0700 |
commit | 814a543675ac90bede7b390c6db9ddbb71c8edfa (patch) | |
tree | 7f4ee23c13e3a59cedad927babf650fa8746c13b | |
parent | udp: parse in(6)_pktinfo cmsgs (diff) | |
download | wireguard-rs-814a543675ac90bede7b390c6db9ddbb71c8edfa.tar.xz wireguard-rs-814a543675ac90bede7b390c6db9ddbb71c8edfa.zip |
udp: make IPs easily parsable by std::net
-rw-r--r-- | Cargo.lock | 3 | ||||
-rw-r--r-- | src/udp/mod.rs | 16 |
2 files changed, 11 insertions, 8 deletions
@@ -650,13 +650,12 @@ dependencies = [ [[package]] name = "nix" version = "0.11.0-pre" -source = "git+https://github.com/mcginty/nix?branch=ipv6-pktinfo#e1a23698617ba775b378ea38480f659499000f0f" +source = "git+https://github.com/mcginty/nix?branch=ipv6-pktinfo#aaafeb51f77bbe2846a0f6b3d3144e35eff5d759" 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)", "cfg-if 0.1.2 (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)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/udp/mod.rs b/src/udp/mod.rs index d54b726..bfefb91 100644 --- a/src/udp/mod.rs +++ b/src/udp/mod.rs @@ -144,7 +144,6 @@ impl UdpSocket { return Err(io::ErrorKind::WouldBlock.into()) } - debug!("sending udp to {:?}", target); match io.get_ref().send_to(buf, target) { Ok(n) => Ok(n), Err(e) => { @@ -175,13 +174,18 @@ impl UdpSocket { Ok(msg) => { for cmsg in msg.cmsgs() { match cmsg { - ControlMessage::Ipv4PacketInfo(_) => { - debug!("ipv4 cmsg"); + 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), + info.ipi_ifindex); }, - ControlMessage::Ipv6PacketInfo(_) => { - debug!("ipv6 cmsg"); + ControlMessage::Ipv6PacketInfo(info) => { + trace!("ipv6 cmsg (\n ipi6_addr: {:?},\n ipi6_ifindex: {}\n)", + Ipv6Addr::from(info.ipi6_addr.s6_addr), + info.ipi6_ifindex); }, - _ => debug!("unknown cmsg") + _ => trace!("unknown cmsg") } } if let Some(SockAddr::Inet(addr)) = msg.address { |