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

Already on GitHub? Sign in to your account

Mac OS X support #6

Open
astavonin opened this Issue Apr 17, 2012 · 6 comments

Comments

Projects
None yet
2 participants
Contributor

astavonin commented Apr 17, 2012

Current version is totally nonoperable on Mac OS X.

Mac OS X structures:

struct sockaddr {
__uint8_t sa_len; /* total length /
sa_family_t sa_family; /
[XSI] address family /
char sa_data[14]; /
[XSI] addr value (actually larger) */
};

struct sockaddr_in {
__uint8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};

struct sockaddr_in6 {
__uint8_t sin6_len; /* length of this struct(sa_family_t)/
sa_family_t sin6_family; /
AF_INET6 (sa_family_t) /
in_port_t sin6_port; /
Transport layer port # (in_port_t)_/
_uint32_t sin6_flowinfo; / IP6 flow information /
struct in6_addr sin6_addr; /
IP6 address _/
_uint32_t sin6_scope_id; / scope zone index */
};

Contributor

astavonin commented Apr 17, 2012

Basically, I tried to fix the issue, but the total refactoring of the library have to be making for that..

Owner

jdm commented Apr 17, 2012

Can you be more specific? I develop on OS X, and the tests pass for me. Do you have examples of what is not working?

Contributor

astavonin commented Apr 17, 2012

You export from the library sockaddr_in and etc structures which are wrong in case of Mac OS X. It is impossible to use it directly or in case of mixed C/C++ and Rus source code.

Contributor

astavonin commented Apr 17, 2012

By directly I mean without using of getaddrinfo

Owner

jdm commented Apr 17, 2012

Do you have an example piece of code to reproduce this problem?

Contributor

astavonin commented Apr 19, 2012

#[test]
fn test_socket_bind() {
    let fd = c::socket(AF_INET, SOCK_STREAM, 0 as libc::c_int);
    let addr = {
        sin_family: AF_INET as i16,
        sin_addr: {s_addr: htonl( 0u32 )},
        sin_port: htons( 8088u16 ),
        sin_zero: (0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8)};
    let res = c::bind(fd, ptr::addr_of(addr) as *sockaddr_storage, sys::size_of::<sockaddr4_in>() as socklen_t);
    assert res != -1 as libc::c_int;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment