@@ -36,6 +36,10 @@ pub type Elf64_Sxword = i64;
36
36
pub type Elf32_Section = u16 ;
37
37
pub type Elf64_Section = u16 ;
38
38
39
+ // linux/can.h
40
+ pub type canid_t = u32 ;
41
+ pub type can_err_mask_t = u32 ;
42
+
39
43
#[ cfg_attr( feature = "extra_traits" , derive( Debug ) ) ]
40
44
pub enum fpos64_t { } // FIXME: fill this out with a struct
41
45
impl :: Copy for fpos64_t { }
@@ -504,6 +508,23 @@ s! {
504
508
pub ee_info: u32 ,
505
509
pub ee_data: u32 ,
506
510
}
511
+
512
+ // linux/can.h
513
+ pub struct __c_anonymous_sockaddr_can_tp {
514
+ pub rx_id: canid_t,
515
+ pub tx_id: canid_t,
516
+ }
517
+
518
+ pub struct __c_anonymous_sockaddr_can_j1939 {
519
+ pub name: u64 ,
520
+ pub pgn: u32 ,
521
+ pub addr: u8 ,
522
+ }
523
+
524
+ pub struct can_filter {
525
+ pub can_id: canid_t,
526
+ pub can_mask: canid_t,
527
+ }
507
528
}
508
529
509
530
s_no_extra_traits ! {
@@ -577,6 +598,26 @@ s_no_extra_traits! {
577
598
}
578
599
}
579
600
601
+ cfg_if ! {
602
+ if #[ cfg( libc_union) ] {
603
+ s_no_extra_traits! {
604
+ // linux/can.h
605
+ #[ allow( missing_debug_implementations) ]
606
+ pub union __c_anonymous_sockaddr_can_can_addr {
607
+ pub tp: __c_anonymous_sockaddr_can_tp,
608
+ pub j1939: __c_anonymous_sockaddr_can_j1939,
609
+ }
610
+
611
+ #[ allow( missing_debug_implementations) ]
612
+ pub struct sockaddr_can {
613
+ pub can_family: :: sa_family_t,
614
+ pub can_ifindex: :: c_int,
615
+ pub can_addr: __c_anonymous_sockaddr_can_can_addr,
616
+ }
617
+ }
618
+ }
619
+ }
620
+
580
621
cfg_if ! {
581
622
if #[ cfg( feature = "extra_traits" ) ] {
582
623
impl PartialEq for sockaddr_nl {
@@ -2567,6 +2608,46 @@ pub const EDOM: ::c_int = 33;
2567
2608
pub const ERANGE : :: c_int = 34 ;
2568
2609
pub const EWOULDBLOCK : :: c_int = EAGAIN ;
2569
2610
2611
+ // linux/can.h
2612
+ pub const CAN_EFF_FLAG : canid_t = 0x80000000 ;
2613
+ pub const CAN_RTR_FLAG : canid_t = 0x40000000 ;
2614
+ pub const CAN_ERR_FLAG : canid_t = 0x20000000 ;
2615
+ pub const CAN_SFF_MASK : canid_t = 0x000007FF ;
2616
+ pub const CAN_EFF_MASK : canid_t = 0x1FFFFFFF ;
2617
+ pub const CAN_ERR_MASK : canid_t = 0x1FFFFFFF ;
2618
+
2619
+ pub const CAN_SFF_ID_BITS : :: c_int = 11 ;
2620
+ pub const CAN_EFF_ID_BITS : :: c_int = 29 ;
2621
+
2622
+ pub const CAN_MAX_DLC : :: c_int = 8 ;
2623
+ pub const CAN_MAX_DLEN : usize = 8 ;
2624
+ pub const CANFD_MAX_DLC : :: c_int = 15 ;
2625
+ pub const CANFD_MAX_DLEN : usize = 64 ;
2626
+
2627
+ pub const CANFD_BRS : :: c_int = 0x01 ;
2628
+ pub const CANFD_ESI : :: c_int = 0x02 ;
2629
+
2630
+ cfg_if ! {
2631
+ if #[ cfg( libc_const_size_of) ] {
2632
+ pub const CAN_MTU : usize = :: mem:: size_of:: <can_frame>( ) ;
2633
+ pub const CANFD_MTU : usize = :: mem:: size_of:: <canfd_frame>( ) ;
2634
+ }
2635
+ }
2636
+
2637
+ pub const CAN_RAW : :: c_int = 1 ;
2638
+ pub const CAN_BCM : :: c_int = 2 ;
2639
+ pub const CAN_TP16 : :: c_int = 3 ;
2640
+ pub const CAN_TP20 : :: c_int = 4 ;
2641
+ pub const CAN_MCNET : :: c_int = 5 ;
2642
+ pub const CAN_ISOTP : :: c_int = 6 ;
2643
+ pub const CAN_J1939 : :: c_int = 7 ;
2644
+ pub const CAN_NPROTO : :: c_int = 8 ;
2645
+
2646
+ pub const SOL_CAN_BASE : :: c_int = 100 ;
2647
+
2648
+ pub const CAN_INV_FILTER : canid_t = 0x20000000 ;
2649
+ pub const CAN_RAW_FILTER_MAX : :: c_int = 512 ;
2650
+
2570
2651
f ! {
2571
2652
pub fn NLA_ALIGN ( len: :: c_int) -> :: c_int {
2572
2653
return ( ( len) + NLA_ALIGNTO - 1 ) & !( NLA_ALIGNTO - 1 )
0 commit comments