Skip to content

Commit 4c06589

Browse files
committed
Add linux canxl constants and canxl frame struct
1 parent e06d905 commit 4c06589

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

libc-test/semver/linux.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,19 @@ CAN_RAW_LOOPBACK
237237
CAN_RAW_RECV_OWN_MSGS
238238
CAN_RAW_FD_FRAMES
239239
CAN_RAW_JOIN_FILTERS
240+
CANXL_HDR_SIZE
241+
CANXL_MAX_DLC
242+
CANXL_MAX_DLC_MASK
243+
CANXL_MAX_DLEN
244+
CANXL_MAX_MTU
245+
CANXL_MIN_DLC
246+
CANXL_MIN_DLEN
247+
CANXL_MIN_MTU
248+
CANXL_MTU
249+
CANXL_PRIO_BITS
250+
CANXL_PRIO_MASK
251+
CANXL_SEC
252+
CANXL_XLF
240253
CBAUD
241254
CBAUDEX
242255
CLD_CONTINUED
@@ -3056,6 +3069,7 @@ can_err_mask_t
30563069
can_filter
30573070
can_frame
30583071
canfd_frame
3072+
canxl_frame
30593073
canid_t
30603074
chroot
30613075
clearenv

src/unix/linux_like/linux/align.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ macro_rules! expand_align {
176176
__res1: u8,
177177
pub data: [u8; CANFD_MAX_DLEN],
178178
}
179+
180+
#[repr(align(8))]
181+
#[allow(missing_debug_implementations)]
182+
pub struct canxl_frame {
183+
pub prio: canid_t,
184+
pub flags: u8,
185+
pub sdt: u8,
186+
pub len: u16,
187+
pub af: u32,
188+
pub data: [u8; CANXL_MAX_DLEN],
189+
}
179190
}
180191
};
181192
}

src/unix/linux_like/linux/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,9 +3723,11 @@ pub const CAN_ERR_FLAG: canid_t = 0x20000000;
37233723
pub const CAN_SFF_MASK: canid_t = 0x000007FF;
37243724
pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF;
37253725
pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF;
3726+
pub const CANXL_PRIO_MASK: ::canid_t = CAN_SFF_MASK;
37263727

37273728
pub const CAN_SFF_ID_BITS: ::c_int = 11;
37283729
pub const CAN_EFF_ID_BITS: ::c_int = 29;
3730+
pub const CANXL_PRIO_BITS: ::c_int = CAN_SFF_ID_BITS;
37293731

37303732
pub const CAN_MAX_DLC: ::c_int = 8;
37313733
pub const CAN_MAX_DLEN: usize = 8;
@@ -3735,10 +3737,26 @@ pub const CANFD_MAX_DLEN: usize = 64;
37353737
pub const CANFD_BRS: ::c_int = 0x01;
37363738
pub const CANFD_ESI: ::c_int = 0x02;
37373739

3740+
pub const CANXL_MIN_DLC: ::c_int = 0;
3741+
pub const CANXL_MAX_DLC: ::c_int = 2047;
3742+
pub const CANXL_MAX_DLC_MASK: ::c_int = 0x07FF;
3743+
pub const CANXL_MIN_DLEN: usize = 1;
3744+
pub const CANXL_MAX_DLEN: usize = 2048;
3745+
3746+
pub const CANXL_XLF: ::c_int = 0x80;
3747+
pub const CANXL_SEC: ::c_int = 0x01;
3748+
37383749
cfg_if! {
37393750
if #[cfg(libc_align)] {
37403751
pub const CAN_MTU: usize = ::mem::size_of::<can_frame>();
37413752
pub const CANFD_MTU: usize = ::mem::size_of::<canfd_frame>();
3753+
pub const CANXL_MTU: usize = ::mem::size_of::<canxl_frame>();
3754+
// FIXME: use `core::mem::offset_of!` once that is available
3755+
// https://github.com/rust-lang/rfcs/pull/3308
3756+
// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data);
3757+
pub const CANXL_HDR_SIZE: usize = 12;
3758+
pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64;
3759+
pub const CANXL_MAX_MTU: usize = CANXL_MTU;
37423760
}
37433761
}
37443762

0 commit comments

Comments
 (0)