Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/Verify Windows/OSX support #1

Closed
keeperofdakeys opened this issue Mar 24, 2016 · 11 comments
Closed

Add/Verify Windows/OSX support #1

keeperofdakeys opened this issue Mar 24, 2016 · 11 comments

Comments

@keeperofdakeys
Copy link
Owner

The init function is private, and seems to initialise data for Windows (src/libstd/sys/windows/net.rs). This, and more, may be required for full Window support.

OSX support is unknown.

@keeperofdakeys
Copy link
Owner Author

The net2-rs crate creates (then drops) a UDP socket on a high port, so Rust initialises the Windows socket library. I should probably do something similar.

From what I can see, OSX should just work if unix does (besides res_init not being thread-safe in OSX).

@NfNitLoop
Copy link

OSX support is unknown.

It doesn't seem to work on my OSX laptop. Building gives these errors (and many more along the same lines):

> cargo build
   Compiling dns-lookup v0.4.0
error[E0531]: cannot find unit struct/variant or constant `AF_AX25` in module `c`
   --> /Users/codycasterline/.cargo/registry/src/github.com-1ecc6299db9ec823/dns-lookup-0.4.0/src/types.rs:162:10
    |
162 |       c::AF_AX25 => AddrFamily::Ax25,
    |          ^^^^^^^ not found in `c`

error[E0531]: cannot find unit struct/variant or constant `AF_NETROM` in module `c`
   --> /Users/codycasterline/.cargo/registry/src/github.com-1ecc6299db9ec823/dns-lookup-0.4.0/src/types.rs:165:10
    |
165 |       c::AF_NETROM => AddrFamily::Netrom,
    |          ^^^^^^^^^ did you mean `AF_NATM`?

error[E0531]: cannot find unit struct/variant or constant `AF_BRIDGE` in module `c`
   --> /Users/codycasterline/.cargo/registry/src/github.com-1ecc6299db9ec823/dns-lookup-0.4.0/src/types.rs:166:10
    |
166 |       c::AF_BRIDGE => AddrFamily::Bridge,
    |          ^^^^^^^^^ not found in `c`

@keeperofdakeys
Copy link
Owner Author

keeperofdakeys commented Sep 12, 2017

Interesting, I didn't realise the libc bindings were so variable. I'll remove the uncommon ones and rely on Other for those then.

Edit: And somehow it took me this long to realise that ai_protocol is not Protocol Family, but another kind of Protocol.

@keeperofdakeys
Copy link
Owner Author

I've pushed a fix for this, give it a go.

@keeperofdakeys
Copy link
Owner Author

@NfNitLoop Could you give this another try on OSX? A cargo test should be enough.

@NfNitLoop
Copy link

Many fewer errors now:

> cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading libc v0.2.31
   Compiling libc v0.2.31
   Compiling dns-lookup v1.0.0 (file:///Users/codycasterline/src/dns-lookup)
error[E0531]: cannot find unit struct/variant or constant `AF_PACKET` in module `c`
  --> src/types.rs:97:10
   |
97 |       c::AF_PACKET => AddrFamily::Packet,
   |          ^^^^^^^^^ not found in `c`

error[E0425]: cannot find value `AF_PACKET` in module `c`
   --> src/types.rs:112:32
    |
112 |       AddrFamily::Packet => c::AF_PACKET,
    |                                ^^^^^^^^^ not found in `c`

error[E0063]: missing field `sin6_len` in initializer of `libc::sockaddr_in6`
   --> src/addr.rs:139:14
    |
139 |       inner: c::sockaddr_in6 {
    |              ^^^^^^^^^^^^^^^ missing `sin6_len`

error: aborting due to 3 previous errors

error: Could not compile `dns-lookup`.

@NfNitLoop
Copy link

that was on this version, btw:

commit d3c5ff65294564c16ef4a91d8c4da7c59644ab59 (HEAD -> master, origin/master, origin/HEAD)
Author: Josh Driver <keeperofdakeys@gmail.com>
Date:   Thu Sep 21 21:21:36 2017 +0930

    Version bump + doc updates

@keeperofdakeys
Copy link
Owner Author

keeperofdakeys commented Sep 21, 2017

Thanks for that I appreciate the help. While I'm heading in the right direction, it's obvious that I should get access get access to test systems for OSX and windows.

@DominoTree
Copy link

Commenting out lines 79, 99, and 114 of types.rs takes care of AF_PACKET not existing in OS X, and adding a sin6_len field to MySocketAddrV6.new() in addr.rs adds an additional value that's required in libc on OS X.

These changes allow the library to build on OS X, haven't done much testing yet but I'll try to get some in tomorrow.

@keeperofdakeys
Copy link
Owner Author

I just pushed a new version that does away with the enums in types.rs, it was proving to be too hard to be portable in its current form. I'll re-implement something similar, but more lightweight in the near future.

@keeperofdakeys
Copy link
Owner Author

This is now building on all platforms, and travis/appveyor are now tracking OSX and Windows support going forward.

keeperofdakeys pushed a commit that referenced this issue Apr 26, 2023
Move from winapi to windows-sys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants