From 4871c1ae1f19353b57303e4b2ff164337a3dc1fd Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Sun, 4 Dec 2022 19:55:40 -0500 Subject: [PATCH] Added CANbus socket family protocol constants. --- CHANGELOG.md | 2 ++ src/sys/socket/mod.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3597db8fd9..8ff4176c87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). ([#1867](https://github.com/nix-rust/nix/pull/1867)) - Added `nix::ucontext` module on `aarch64-unknown-linux-gnu`. (#[1662](https://github.com/nix-rust/nix/pull/1662)) +- Added `CanRaw` to `SockProtocol` and `CanBcm` as a separate `SocProtocol` constant. + ([#1912](https://github.com/nix-rust/nix/pull/1912)) ### Changed diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index a67a5ab34a..bcc28ae619 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -218,8 +218,21 @@ pub enum SockProtocol { #[cfg(any(target_os = "android", target_os = "linux"))] #[cfg_attr(docsrs, doc(cfg(all())))] EthAll = libc::ETH_P_ALL.to_be(), + /// The Controller Area Network raw socket protocol + /// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan)) + #[cfg(target_os = "linux")] + #[cfg_attr(docsrs, doc(cfg(all())))] + CanRaw = libc::CAN_RAW, } +impl SockProtocol { + /// The Controller Area Network broadcast manager protocol + /// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan)) + #[cfg(target_os = "linux")] + #[cfg_attr(docsrs, doc(cfg(all())))] + #[allow(non_upper_case_globals)] + pub const CanBcm: SockProtocol = SockProtocol::NetlinkUserSock; // Matches libc::CAN_BCM +} #[cfg(any(target_os = "linux"))] libc_bitflags! { /// Configuration flags for `SO_TIMESTAMPING` interface