Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
language: rust
rust:
- nightly
- 1.0.0
- 1.1.0

os:
- linux
Expand Down Expand Up @@ -37,7 +37,7 @@ deploy:
upload-dir: nix/${TRAVIS_BRANCH}/${TRAVIS_OS_NAME}
acl: public_read
on:
condition: "\"$TRAVIS_RUST_VERSION/$ARCH\" == \"1.0.0/x86_64\""
condition: "\"$TRAVIS_RUST_VERSION/$ARCH\" == \"1.1.0/x86_64\""
repo: carllerche/nix-rust
branch:
- master
4 changes: 4 additions & 0 deletions nix-test/src/const.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ get_int_const(const char* err) {
GET_CONST(MSG_OOB);
GET_CONST(MSG_PEEK);
GET_CONST(MSG_DONTWAIT);
GET_CONST(MSG_EOR);
GET_CONST(MSG_TRUNC);
GET_CONST(MSG_CTRUNC);
GET_CONST(SHUT_RD);
GET_CONST(SHUT_WR);
GET_CONST(SHUT_RDWR);
Expand All @@ -312,6 +315,7 @@ get_int_const(const char* err) {
// GET_CONST(SO_PEEK_OFF);
GET_CONST(SO_PEERCRED);
GET_CONST(SO_SNDBUFFORCE);
GET_CONST(MSG_ERRQUEUE);
#endif

return -1;
Expand Down
21 changes: 19 additions & 2 deletions src/sys/socket/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,23 @@ mod os {
pub const INADDR_NONE: InAddrT = 0xffffffff;
pub const INADDR_BROADCAST: InAddrT = 0xffffffff;

pub type SockMessageFlags = i32;
pub type SockMessageFlags = c_int;
// Flags for send/recv and their relatives
pub const MSG_OOB: SockMessageFlags = 0x1;
pub const MSG_PEEK: SockMessageFlags = 0x2;
pub const MSG_CTRUNC: SockMessageFlags = 0x08;
pub const MSG_TRUNC: SockMessageFlags = 0x20;
pub const MSG_DONTWAIT: SockMessageFlags = 0x40;
pub const MSG_EOR: SockMessageFlags = 0x80;
pub const MSG_ERRQUEUE: SockMessageFlags = 0x2000;

// shutdown flags
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;

// Ancillary message types
pub const SCM_RIGHTS: c_int = 1;
}

// Not all of these constants exist on freebsd
Expand Down Expand Up @@ -197,12 +204,18 @@ mod os {
// Flags for send/recv and their relatives
pub const MSG_OOB: SockMessageFlags = 0x1;
pub const MSG_PEEK: SockMessageFlags = 0x2;
pub const MSG_EOR: SockMessageFlags = 0x8;
pub const MSG_TRUNC: SockMessageFlags = 0x10;
pub const MSG_CTRUNC: SockMessageFlags = 0x20;
pub const MSG_DONTWAIT: SockMessageFlags = 0x80;

// shutdown flags
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;

// Ancillary message types
pub const SCM_RIGHTS: c_int = 1;
}

#[cfg(target_os = "dragonfly")]
Expand Down Expand Up @@ -340,6 +353,9 @@ mod test {
MSG_OOB,
MSG_PEEK,
MSG_DONTWAIT,
MSG_EOR,
MSG_TRUNC,
MSG_CTRUNC,
SHUT_RD,
SHUT_WR,
SHUT_RDWR
Expand Down Expand Up @@ -370,6 +386,7 @@ mod test {
SO_RCVBUFFORCE,
// SO_PEEK_OFF,
SO_PEERCRED,
SO_SNDBUFFORCE);
SO_SNDBUFFORCE,
MSG_ERRQUEUE);
}
}
9 changes: 8 additions & 1 deletion src/sys/socket/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use libc::{c_int, c_void, socklen_t};
// Silence invalid warnings due to rust-lang/rust#16719
#![allow(improper_ctypes)]

use libc::{c_int, c_void, socklen_t, ssize_t};
pub use libc::{socket, listen, bind, accept, connect, setsockopt, sendto, recvfrom, getsockname, getpeername, recv, send};
use super::msghdr;

extern {
pub fn getsockopt(
Expand All @@ -15,4 +19,7 @@ extern {
protocol: c_int,
sv: *mut c_int
) -> c_int;

pub fn sendmsg(sockfd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t;
pub fn recvmsg(sockfd: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t;
}
Loading