Skip to content

Commit a5470ce

Browse files
Andrew BalmosAndrew Balmos
authored andcommitted
Add SocketCan J1939 constants and structs
Signed-off-by: Andrew Balmos <andrew@balmos.org>
1 parent 5d228ea commit a5470ce

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,6 +2917,7 @@ fn test_linux(target: &str) {
29172917
"asm/mman.h",
29182918
"linux/can.h",
29192919
"linux/can/raw.h",
2920+
"linux/can/j1939.h",
29202921
"linux/dccp.h",
29212922
"linux/errqueue.h",
29222923
"linux/falloc.h",

libc-test/semver/linux.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,24 @@ ITIMER_PROF
986986
ITIMER_REAL
987987
ITIMER_VIRTUAL
988988
IUTF8
989+
J1939_IDLE_ADDR
990+
J1939_MAX_UNICAST_ADDR
991+
J1939_NLA_BYTES_ACKED
992+
J1939_NLA_DEST_ADDR
993+
J1939_NLA_DEST_NAME
994+
J1939_NLA_PAD
995+
J1939_NLA_PGN
996+
J1939_NLA_SRC_ADDR
997+
J1939_NLA_SRC_NAME
998+
J1939_NLA_TOTAL_SIZE
999+
J1939_NO_ADDR
1000+
J1939_NO_NAME
1001+
J1939_NO_PGN
1002+
J1939_PGN_ADDRESS_CLAIMED
1003+
J1939_PGN_ADDRESS_COMMANDED
1004+
J1939_PGN_MAX
1005+
J1939_PGN_PDU1_MAX
1006+
J1939_PGN_REQUEST
9891007
KEYCTL_ASSUME_AUTHORITY
9901008
KEYCTL_CHOWN
9911009
KEYCTL_CLEAR
@@ -1945,6 +1963,10 @@ SCHED_RESET_ON_FORK
19451963
SCHED_RR
19461964
SCM_CREDENTIALS
19471965
SCM_RIGHTS
1966+
SCM_J1939_DEST_ADDR
1967+
SCM_J1939_DEST_NAME
1968+
SCM_J1939_ERRQUEUE
1969+
SCM_J1939_PRIO
19481970
SCM_TIMESTAMP
19491971
SCM_TIMESTAMPING
19501972
SECCOMP_FILTER_FLAG_LOG
@@ -2047,6 +2069,7 @@ SOL_ALG
20472069
SOL_ATM
20482070
SOL_BLUETOOTH
20492071
SOL_CAN_BASE
2072+
SOL_CAN_J1939
20502073
SOL_CAN_RAW
20512074
SOL_DCCP
20522075
SOL_DECNET
@@ -2073,6 +2096,10 @@ SO_EE_ORIGIN_NONE
20732096
SO_EE_ORIGIN_TIMESTAMPING
20742097
SO_EE_ORIGIN_TXSTATUS
20752098
SO_MARK
2099+
SO_J1939_ERRQUEUE
2100+
SO_J1939_FILTER
2101+
SO_J1939_PROMISC
2102+
SO_J1939_SEND_PRIO
20762103
SO_ORIGINAL_DST
20772104
SO_PASSCRED
20782105
SO_PASSSEC
@@ -2799,6 +2826,7 @@ ip_mreqn
27992826
ip_mreq_source
28002827
ipc_perm
28012828
itimerspec
2829+
j1939_filter
28022830
key_t
28032831
killpg
28042832
labs
@@ -2852,6 +2880,7 @@ msgqnum_t
28522880
msgrcv
28532881
msgsnd
28542882
msqid_ds
2883+
name_t
28552884
newlocale
28562885
nice
28572886
nl_item
@@ -2870,6 +2899,7 @@ openpty
28702899
packet_mreq
28712900
pause
28722901
personality
2902+
pgn_t
28732903
pipe2
28742904
popen
28752905
posix_fadvise
@@ -2902,6 +2932,7 @@ posix_spawnattr_t
29022932
posix_spawnp
29032933
ppoll
29042934
prctl
2935+
priority_t
29052936
pread64
29062937
preadv
29072938
pthread_attr_getguardsize

src/unix/linux_like/linux/mod.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ pub type Elf64_Section = u16;
3939

4040
// linux/can.h
4141
pub type canid_t = u32;
42+
43+
// linux/can/j1939.h
4244
pub type can_err_mask_t = u32;
45+
pub type pgn_t = u32;
46+
pub type priority_t = u8;
47+
pub type name_t = u64;
4348

4449
pub type iconv_t = *mut ::c_void;
4550

@@ -543,6 +548,16 @@ s! {
543548
pub can_mask: canid_t,
544549
}
545550

551+
// linux/can/j1939.h
552+
pub struct j1939_filter {
553+
pub name: name_t,
554+
pub name_mask: name_t,
555+
pub pgn: pgn_t,
556+
pub pgn_mask: pgn_t,
557+
pub addr: u8,
558+
pub addr_mask: u8,
559+
}
560+
546561
// linux/filter.h
547562
pub struct sock_filter {
548563
pub code: ::__u16,
@@ -3185,6 +3200,47 @@ pub const CAN_RAW_RECV_OWN_MSGS: ::c_int = 4;
31853200
pub const CAN_RAW_FD_FRAMES: ::c_int = 5;
31863201
pub const CAN_RAW_JOIN_FILTERS: ::c_int = 6;
31873202

3203+
// linux/can/j1939.h
3204+
pub const SOL_CAN_J1939: ::c_int = SOL_CAN_BASE + CAN_J1939;
3205+
3206+
pub const J1939_MAX_UNICAST_ADDR: ::c_uchar = 0xfd;
3207+
pub const J1939_IDLE_ADDR: ::c_uchar = 0xfe;
3208+
pub const J1939_NO_ADDR: ::c_uchar = 0;
3209+
pub const J1939_NO_NAME: ::c_ulong = 0;
3210+
pub const J1939_PGN_REQUEST: ::c_uint = 0x0ea00;
3211+
pub const J1939_PGN_ADDRESS_CLAIMED: ::c_uint = 0x0ee00;
3212+
pub const J1939_PGN_ADDRESS_COMMANDED: ::c_uint = 0x0fed8;
3213+
pub const J1939_PGN_PDU1_MAX: ::c_uint = 0x3ff00;
3214+
pub const J1939_PGN_MAX: ::c_uint = 0x3ffff;
3215+
pub const J1939_NO_PGN: ::c_uint = 0x40000;
3216+
3217+
pub const SO_J1939_FILTER: ::c_int = 1;
3218+
pub const SO_J1939_PROMISC: ::c_int = 2;
3219+
pub const SO_J1939_SEND_PRIO: ::c_int = 3;
3220+
pub const SO_J1939_ERRQUEUE: ::c_int = 4;
3221+
3222+
pub const SCM_J1939_DEST_ADDR: ::c_int = 1;
3223+
pub const SCM_J1939_DEST_NAME: ::c_int = 2;
3224+
pub const SCM_J1939_PRIO: ::c_int = 3;
3225+
pub const SCM_J1939_ERRQUEUE: ::c_int = 4;
3226+
3227+
pub const J1939_NLA_PAD: ::c_int = 0;
3228+
pub const J1939_NLA_BYTES_ACKED: ::c_int = 1;
3229+
pub const J1939_NLA_TOTAL_SIZE: ::c_int = 2;
3230+
pub const J1939_NLA_PGN: ::c_int = 3;
3231+
pub const J1939_NLA_SRC_NAME: ::c_int = 4;
3232+
pub const J1939_NLA_DEST_NAME: ::c_int = 5;
3233+
pub const J1939_NLA_SRC_ADDR: ::c_int = 6;
3234+
pub const J1939_NLA_DEST_ADDR: ::c_int = 7;
3235+
3236+
pub const J1939_EE_INFO_NONE: ::c_int = 0;
3237+
pub const J1939_EE_INFO_TX_ABORT: ::c_int = 1;
3238+
pub const J1939_EE_INFO_RX_RTS: ::c_int = 2;
3239+
pub const J1939_EE_INFO_RX_DPO: ::c_int = 3;
3240+
pub const J1939_EE_INFO_RX_ABORT: ::c_int = 4;
3241+
3242+
pub const J1939_FILTER_MAX: ::c_int = 512;
3243+
31883244
f! {
31893245
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
31903246
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)

0 commit comments

Comments
 (0)