Skip to content

Commit b7cb456

Browse files
Merge #1912
1912: Added CANbus socket family protocol constants. r=asomers a=fpagliughi Added CANbus socket family protocol values for `CanRaw` and `CanBcm` Co-authored-by: fpagliughi <[email protected]>
2 parents 53531b4 + 4871c1a commit b7cb456

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
99
([#1867](https://github.com/nix-rust/nix/pull/1867))
1010
- Added `nix::ucontext` module on `aarch64-unknown-linux-gnu`.
1111
(#[1662](https://github.com/nix-rust/nix/pull/1662))
12+
- Added `CanRaw` to `SockProtocol` and `CanBcm` as a separate `SocProtocol` constant.
13+
([#1912](https://github.com/nix-rust/nix/pull/1912))
1214

1315
### Changed
1416

src/sys/socket/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,21 @@ pub enum SockProtocol {
218218
#[cfg(any(target_os = "android", target_os = "linux"))]
219219
#[cfg_attr(docsrs, doc(cfg(all())))]
220220
EthAll = libc::ETH_P_ALL.to_be(),
221+
/// The Controller Area Network raw socket protocol
222+
/// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan))
223+
#[cfg(target_os = "linux")]
224+
#[cfg_attr(docsrs, doc(cfg(all())))]
225+
CanRaw = libc::CAN_RAW,
221226
}
222227

228+
impl SockProtocol {
229+
/// The Controller Area Network broadcast manager protocol
230+
/// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan))
231+
#[cfg(target_os = "linux")]
232+
#[cfg_attr(docsrs, doc(cfg(all())))]
233+
#[allow(non_upper_case_globals)]
234+
pub const CanBcm: SockProtocol = SockProtocol::NetlinkUserSock; // Matches libc::CAN_BCM
235+
}
223236
#[cfg(any(target_os = "linux"))]
224237
libc_bitflags! {
225238
/// Configuration flags for `SO_TIMESTAMPING` interface

0 commit comments

Comments
 (0)