summaryrefslogtreecommitdiff
path: root/src/sys/socket/mod.rs
AgeCommit message (Collapse)Author
2018-01-08Impl LinkAddr(MAC Addr)luozijun
2017-12-20Replace '0 as *_' with ptr::null*()Bryant Mairs
2017-12-20Use backticks around types/functions in docsBryant Mairs
2017-12-20Use |= where appropriateBryant Mairs
2017-12-20Use unwrap_or_else instead of unwrap_or without a closureBryant Mairs
2017-12-20Remove unnecessary parenthesisBryant Mairs
2017-12-20Remove unnecessary referencesBryant Mairs
2017-12-20Migrate sys/socket to libc FFI types and fix `msghdr` definition mismatch.Matthew Gregan
2017-12-10Replace ip(v6)_mreq structs with libc equivalentBryant Mairs
2017-12-10Replace custom ucred struct with newtype wrapper around libc::ucredBryant Mairs
2017-12-10Use libc::lingerBryant Mairs
2017-12-10Add more derives for SignalFd and various enumsBryant Mairs
2017-12-05Remove nix-test subcrateBryant Mairs
This was doing testing for errno constants and a few other types that is no longer necessary now that these types are all tested within the libc project itself.
2017-12-04Stop reexporting `Errno` and its variantsJonas Schievink
cc #664 (unsure if this is everything needed)
2017-12-02Upgrade to Bitflags 1.0Bryant Mairs
The libc_bitflags! macro was replaced with a non-recursive one supporting only public structs. I could not figure out how to make the old macro work with the upgrade, so I reworked part of the bitflags! macro directly to suit our needs, much as the original recursive macro was made. There are no uses of this macro for non-public structs, so this is not a problem for internal code.
2017-10-08Replace most Linux man page links with Open Group man page linksAlan Somers
But leave in place Linux links for non-standard functions. Also, add brief docs for some functions that were lacking them.
2017-09-04Add support for SO_TIMESTAMPWesley Wolfe
2017-08-26Replace more FFI instancesBryant Mairs
2017-08-17Merge #725bors[bot]
725: Match syntax of libc_bitflags! with bitflags! r=asomers Also update a couple of constant declarations while we're at it.
2017-08-16Match libc_bitflags! syntax to upstream bitflags!Bryant Mairs
2017-08-16Replace extra SOCK_ constants with libc versionsBryant Mairs
Fixes #244
2017-08-11Get rid of a lot of transmutesJonas Schievink
Most could be replaced by simple raw pointer casts (or even perfectly safe coercions!). cc #373
2017-08-05Correct access of cmsg ancillary data on first headerWesley Moore
Also updates cmsg types to match structs on non-Linux OSes. The implementation of CmsgInterator did not correctly mirror the way the CMSG_FIRSTHDR and CMSG_NEXTHDR macros work in C. CMSG_FIRSTHDR does not attempt to align access since the pointer is already aligned due to being part of the msghdr struct. CmsgInterator was always aligning access which happened to work on all platforms except OpenBSD where the use of alignment was adding unexpected bytes to the expected size and causing the `cmsg_align(cmsg_len) > self.buf.len()` guard clause to return early.
2017-08-01Document AddressFamily and SockTypeNicolas Dusart
2017-08-01add SockProtocol type for third argument of socket and socketpairNicolas Dusart
2017-08-01Document `MsgFlags` constantsNicolas Dusart
2017-08-01add socket constants already present in libcNicolas Dusart
2017-08-01remove sys::sockets::consts module as it's libc goal to define themNicolas Dusart
2017-07-10Fix sendmsg on macOS when passing a zero entry cmsgs array.Matthew Gregan
2017-07-10Simplify Vec allocation in sendmsg after 077d979a removed alignment hacks.Matthew Gregan
2017-07-04Allow nix to compile on android targetsroblabla
2017-06-18Update bitflags to 0.9equal-l2
2017-02-16Update bitflags to 0.7Simon Sapin
2017-01-11Auto merge of #489 - fiveop:fixcopyinto, r=fiveopHomu
Fix ControlMessage::encode_into when encoding multiple messages copy_bytes updates dst so that it points after the bytes that were just copied into it. encode_into did not advance the buffer in the same way when encoding the data. See #473
2017-01-10Always use libc's socketaddr_storagePhilipp Matthias Schaefer
Since rust-lang/rust#23425 is closed, we no longer need the special case.
2016-12-10Fix ControlMessage::encode_into when encoding multiple messagesPhilipp Matthias Schaefer
copy_bytes updates dst so that it points after the bytes that were just copied into it. encode_into did not advance the buffer in the same way when encoding the data.
2016-11-18Fix Unix domain sockets.Alan Somers
There were multiple errors regarding Unix domain sockets: * UnixAddr::path assumed that gethostbyname and similar functions would include the terminating null as part of len. That is not universally true. In fact, POSIX only guarantees that len will be at least large enough to store the non-null-terminated path. So it could be larger or smaller than nix was assuming. Since abstract sockets' paths are not strings, we can't modify gethostbyname. Instead, I implemented the fix in UnixAddr::path and UnixAddr::new. I clarified the documentation too. * SockAddr::as_ffi_pair contained a Linuxism. * sockaddr_storage_to_addr forgot to adjust sun_len when creating a UnixAddr
2016-08-10Fix nix on FreeBSD amd64Alan Somers
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.
2016-05-01Support sockaddr_nl in sockaddr_storage_to_addr().James Peach
Add support for converting AF_NETLINK sockaddr_nl addresses to Sockaddr::Netlink(). This lets socket::recvmsg() work on netlink sockets.
2016-01-29Convert MSG_ flags to bitflags! type.Philipp Matthias Schaefer
2016-01-28Derive all the thingsAlexander Polakov
as suggested by @kamalmarhubi
2016-01-28Netlink bitsAlexander Polakov
2016-01-28Move errno::Result back to crate rootarcnmx
2016-01-28Errno::result()arcnmx
2015-12-22Fix broken tests on nightlyCarl Lerche
2015-12-22Implement support for getsockopt of peer credentials using the Linux ↵Magnus Hoff
specific SO_PEERCRED
2015-12-04socket(): add protocol argument (breaking change)Alexander Polakov
2015-10-28Fix handling of sockaddr_un lengthsGeoffrey Thomas
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.
2015-10-06Add support for sendmsg(2), recvmsg(2), and cmsg(3)Geoffrey Thomas
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.
2015-09-28Revert "Add support for sendmsg(2), recvmsg(2), and cmsg(4)"Carl Lerche
This reverts commit 046af7d1ba82506f9bc48e62ac0584361025fc02.