Age | Commit message (Collapse) | Author |
|
|
|
Fixes #421.
|
|
On Linux, the cmsg_len field of struct cmsghdr has type size_t, but it
has size socklen_t on POSIX-compliant operating systems. So on
POSIX-compliant 64-bit operating systems, struct cmsghdr has padding
gaps that aren't present on Linux. Most of the issues fixed by this
commit related to those gaps.
src/sys/socket/ffi.rs
Fix the type of the cmsg_data field so the struct layout will be
correct.
src/sys/socket/mod.rs
In CmsgIterator.next, only return a single file descriptor.
sendmsg(2) can only stuff a single file descriptor into each
cmsg.
In cmsg_align, fix the rounding calculation, and eliminate a
division instruction.
Add a missing cmsg_align call in ControlMessage.len
In ControlMessage.encode_into, add any necessary padding bytes
between the cmsghdr and the data.
In sendmsg, fix some len<->capacity confusion.
|
|
Rules for generic types were located above rules for specific types, so the
rules for specific types never got matched. This caused the
sys::socket::sockopt::test::can_get_listen_on_tcp_socket test to fail on
FreeBSD. The solution is to put all of the generic rules at the bottom.
|
|
Add SO_ORIGINAL_DST
In Linux, the SO_ORIGINAL_DST socket option can be used to get the original destination, which can be needed if the connection is translated by a NAT, i.e. iptables. In C, this information can be obtained by ``getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &remote, &remote_len)`` and returns a ``sockaddr_in`` struct. I've added a binding for this option.
Thanks!
|
|
|
|
Add support for converting AF_NETLINK sockaddr_nl addresses to
Sockaddr::Netlink(). This lets socket::recvmsg() work on netlink
sockets.
|
|
|
|
Fixes #329
|
|
|
|
|
|
|
|
|
|
no matter what the architecture is.
|
|
Only known on linux, nacl, freebsd
|
|
|
|
|
|
|
|
|
|
as suggested by @kamalmarhubi
|
|
as pointed out by @kamalmarhubi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
specific SO_PEERCRED
|
|
|
|
|
|
|
|
The returned length of AF_UNIX sockaddrs is significant, and generally
does not match the length of the entire structure. For filesystem
sockets, this is ignorable because the path is also NUL-terminated, but
for unbound sockets (e.g., a socketpair) or abstract-namespace
sockets (a Linux extension where the address is an arbitrary
bytestring), we need to keep track of the length.
Fixes #177. Also add a UnixAddr::new_abstract function and some better
handling of abstract-namespace socket addresses to fix #169.
|
|
The best specification for control message layout appears to be
[RFC 2292, section 4](https://tools.ietf.org/html/rfc2292#section-4),
despite this not being a wire protocol. These definitions have also been
checked against glibc 2.19 <bits/socket.h> and Linux 4.0
<linux/socket.h>, and tested on Debian 8.1 and FreeBSD 10.2 x86_64.
The API differs a bit from the cmsg(3) API for type-safety reasons (and
also because the cmsg(3) API is terrible). See test/sys/test_socket.rs
for an example.
Only supports SCM_RIGHTS at the moment.
Fixes #88.
|
|
This reverts commit 046af7d1ba82506f9bc48e62ac0584361025fc02.
|
|
The best specification for control message layout appears to be
[RFC 2292, section 4](https://tools.ietf.org/html/rfc2292#section-4),
despite this not being a wire protocol. These definitions have also been
checked against glibc 2.19 <bits/socket.h> and Linux 4.0
<linux/socket.h>, and tested on Debian 8.1 and FreeBSD 10.2 x86_64.
The API differs a bit from the cmsg(4) API for type-safety reasons (and
also because the cmsg(4) API is terrible). See test/sys/test_socket.rs
for an example.
Only supports SCM_RIGHTS at the moment.
Fixes #88.
|
|
|
|
|
|
|
|
|
|
|
|
* Split SockOpt trait into GetSockOpt and SetSockOpt.
* Add support for TCP_KEEPALIVE & TCP_KEEPIDLE
|
|
Some of the tests are currently unrunnable, but the basic library is at least
buildable.
|
|
|
|
|
|
|
|
As described in #117, the `AsExtStr` trait is defined to return a raw `*const
libc::c_char`. Its impl for `OsStr` simply borrowed the byte slice from its
`OsStr` argument and cast it to a `*const libc::c_char`, which does not
construct a proper null-terminated C string.
Given this, the `AsExtStr` is not necessary and is removed. `NixPath` is
updated to yield `CStr`.
Fixes #117, #120
Thanks to @dead10ck
|
|
|
|
|