cloudflare / cfnts

Cloudflare's implementation of the NTS protocol written in Rust
https://blog.cloudflare.com/announcing-cfnts/
BSD 2-Clause "Simplified" License
176 stars 19 forks source link

BSD portability #35

Open wbl opened 4 years ago

wbl commented 4 years ago

in_pktinfo doesn't exist on BSD, instead one can get a sockaddr_dl out of recvmsg instead via IP_RECVIF, and likewise for the the other information we need from the packet.

dch commented 4 years ago

specifically:

   Compiling cfnts v2019.6.0 (/repos/cfnts)
error[E0432]: unresolved import `libc::in_pktinfo`
  --> src/ntp/server/server.rs:24:25
   |
24 | use libc::{in6_pktinfo, in_pktinfo};
   |                         ^^^^^^^^^^
   |                         |
   |                         no `in_pktinfo` in the root
   |                         help: a similar name exists in the module: `in6_pktinfo`

error[E0425]: cannot find value `Ipv4PacketInfo` in module `sockopt`
   --> src/ntp/server/server.rs:112:37
    |
112 |         setsockopt(sockfd, sockopt::Ipv4PacketInfo, &true)
    |                                     ^^^^^^^^^^^^^^ not found in `sockopt`

error[E0599]: no variant or associated item named `Ipv4PacketInfo` found for type `nix::sys::socket::ControlMessage<'_>` in the current scope
   --> src/ntp/server/server.rs:147:33
    |
147 |                 ControlMessage::Ipv4PacketInfo(_inf) => {
    |                                 ^^^^^^^^^^^^^^
    |                                 |
    |                                 variant or associated item not found in `nix::sys::socket::ControlMessage<'_>`
    |                                 help: there is a variant with a similar name: `Ipv6PacketInfo`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0425, E0432, E0599.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `cfnts`.