summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-11-29 14:37:51 +0000
committerGitHub <noreply@github.com>2022-11-29 14:37:51 +0000
commited8319c01a3fff74df24bc9c920d742a0f94874e (patch)
treed53a26de98d2e8590342d12e2d3c1ad181f32e0d /src/sys
parentf263f453a351a1fa3eeffe7d115a9e85ac76541e (diff)
parentd08d4e2f15042ba09aab9fe0e66ab2bdff81cb16 (diff)
downloadnix-ed8319c01a3fff74df24bc9c920d742a0f94874e.zip
Merge #1867
1867: Add routing socket type on macOS r=asomers a=pinkisemils This is a small change to add the routing socket type to the list of socket types one can open with `nix`. I've added a smoke test to see that a socket of such type can actually be opened, but I'm not sure if such a test belongs in the codebase here. Co-authored-by: Emils <emils@mullvad.net>
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/socket/addr.rs5
-rw-r--r--src/sys/socket/mod.rs12
2 files changed, 17 insertions, 0 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 8b23b10c..55a7b2ff 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -80,6 +80,9 @@ pub enum AddressFamily {
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg_attr(docsrs, doc(cfg(all())))]
Netlink = libc::AF_NETLINK,
+ /// Kernel interface for interacting with the routing table
+ #[cfg(not(any(target_os = "redox", target_os = "linux", target_os = "android")))]
+ Route = libc::PF_ROUTE,
/// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html))
#[cfg(any(
target_os = "android",
@@ -421,6 +424,8 @@ impl AddressFamily {
libc::AF_NETLINK => Some(AddressFamily::Netlink),
#[cfg(any(target_os = "macos", target_os = "macos"))]
libc::AF_SYSTEM => Some(AddressFamily::System),
+ #[cfg(not(any(target_os = "redox", target_os = "linux", target_os = "android")))]
+ libc::PF_ROUTE => Some(AddressFamily::Route),
#[cfg(any(target_os = "android", target_os = "linux"))]
libc::AF_PACKET => Some(AddressFamily::Packet),
#[cfg(any(
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 2d7159a6..154403c5 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -2484,4 +2484,16 @@ mod tests {
fn can_use_cmsg_space() {
let _ = cmsg_space!(u8);
}
+
+ #[cfg(not(any(target_os = "redox", target_os = "linux", target_os = "android")))]
+ #[test]
+ fn can_open_routing_socket() {
+ let _ = super::socket(
+ super::AddressFamily::Route,
+ super::SockType::Raw,
+ super::SockFlag::empty(),
+ None,
+ )
+ .expect("Failed to open routing socket");
+ }
}