1 /* SPDX-License-Identifier: GPL-2.0-only WITH 1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 /* 2 /* 3 * j1939.h 3 * j1939.h 4 * 4 * 5 * Copyright (c) 2010-2011 EIA Electronics 5 * Copyright (c) 2010-2011 EIA Electronics 6 * 6 * 7 * This program is free software; you can redi 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Publi 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation. 10 */ 10 */ 11 11 12 #ifndef _UAPI_CAN_J1939_H_ 12 #ifndef _UAPI_CAN_J1939_H_ 13 #define _UAPI_CAN_J1939_H_ 13 #define _UAPI_CAN_J1939_H_ 14 14 15 #include <linux/types.h> 15 #include <linux/types.h> 16 #include <linux/socket.h> 16 #include <linux/socket.h> 17 #include <linux/can.h> 17 #include <linux/can.h> 18 18 19 #define J1939_MAX_UNICAST_ADDR 0xfd 19 #define J1939_MAX_UNICAST_ADDR 0xfd 20 #define J1939_IDLE_ADDR 0xfe 20 #define J1939_IDLE_ADDR 0xfe 21 #define J1939_NO_ADDR 0xff /* == 21 #define J1939_NO_ADDR 0xff /* == broadcast or no addr */ 22 #define J1939_NO_NAME 0 22 #define J1939_NO_NAME 0 23 #define J1939_PGN_REQUEST 0x0ea00 23 #define J1939_PGN_REQUEST 0x0ea00 /* Request PG */ 24 #define J1939_PGN_ADDRESS_CLAIMED 0x0ee00 24 #define J1939_PGN_ADDRESS_CLAIMED 0x0ee00 /* Address Claimed */ 25 #define J1939_PGN_ADDRESS_COMMANDED 0x0fed8 25 #define J1939_PGN_ADDRESS_COMMANDED 0x0fed8 /* Commanded Address */ 26 #define J1939_PGN_PDU1_MAX 0x3ff00 26 #define J1939_PGN_PDU1_MAX 0x3ff00 27 #define J1939_PGN_MAX 0x3ffff 27 #define J1939_PGN_MAX 0x3ffff 28 #define J1939_NO_PGN 0x40000 28 #define J1939_NO_PGN 0x40000 29 29 30 /* J1939 Parameter Group Number 30 /* J1939 Parameter Group Number 31 * 31 * 32 * bit 0-7 : PDU Specific (PS) 32 * bit 0-7 : PDU Specific (PS) 33 * bit 8-15 : PDU Format (PF) 33 * bit 8-15 : PDU Format (PF) 34 * bit 16 : Data Page (DP) 34 * bit 16 : Data Page (DP) 35 * bit 17 : Reserved (R) 35 * bit 17 : Reserved (R) 36 * bit 19-31 : set to zero 36 * bit 19-31 : set to zero 37 */ 37 */ 38 typedef __u32 pgn_t; 38 typedef __u32 pgn_t; 39 39 40 /* J1939 Priority 40 /* J1939 Priority 41 * 41 * 42 * bit 0-2 : Priority (P) 42 * bit 0-2 : Priority (P) 43 * bit 3-7 : set to zero 43 * bit 3-7 : set to zero 44 */ 44 */ 45 typedef __u8 priority_t; 45 typedef __u8 priority_t; 46 46 47 /* J1939 NAME 47 /* J1939 NAME 48 * 48 * 49 * bit 0-20 : Identity Number 49 * bit 0-20 : Identity Number 50 * bit 21-31 : Manufacturer Code 50 * bit 21-31 : Manufacturer Code 51 * bit 32-34 : ECU Instance 51 * bit 32-34 : ECU Instance 52 * bit 35-39 : Function Instance 52 * bit 35-39 : Function Instance 53 * bit 40-47 : Function 53 * bit 40-47 : Function 54 * bit 48 : Reserved 54 * bit 48 : Reserved 55 * bit 49-55 : Vehicle System 55 * bit 49-55 : Vehicle System 56 * bit 56-59 : Vehicle System Instance 56 * bit 56-59 : Vehicle System Instance 57 * bit 60-62 : Industry Group 57 * bit 60-62 : Industry Group 58 * bit 63 : Arbitrary Address Capable 58 * bit 63 : Arbitrary Address Capable 59 */ 59 */ 60 typedef __u64 name_t; 60 typedef __u64 name_t; 61 61 62 /* J1939 socket options */ 62 /* J1939 socket options */ 63 #define SOL_CAN_J1939 (SOL_CAN_BASE + CAN_J193 63 #define SOL_CAN_J1939 (SOL_CAN_BASE + CAN_J1939) 64 enum { 64 enum { 65 SO_J1939_FILTER = 1, /* set filters 65 SO_J1939_FILTER = 1, /* set filters */ 66 SO_J1939_PROMISC = 2, /* set/clr pro 66 SO_J1939_PROMISC = 2, /* set/clr promiscuous mode */ 67 SO_J1939_SEND_PRIO = 3, 67 SO_J1939_SEND_PRIO = 3, 68 SO_J1939_ERRQUEUE = 4, 68 SO_J1939_ERRQUEUE = 4, 69 }; 69 }; 70 70 71 enum { 71 enum { 72 SCM_J1939_DEST_ADDR = 1, 72 SCM_J1939_DEST_ADDR = 1, 73 SCM_J1939_DEST_NAME = 2, 73 SCM_J1939_DEST_NAME = 2, 74 SCM_J1939_PRIO = 3, 74 SCM_J1939_PRIO = 3, 75 SCM_J1939_ERRQUEUE = 4, 75 SCM_J1939_ERRQUEUE = 4, 76 }; 76 }; 77 77 78 enum { 78 enum { 79 J1939_NLA_PAD, 79 J1939_NLA_PAD, 80 J1939_NLA_BYTES_ACKED, 80 J1939_NLA_BYTES_ACKED, 81 J1939_NLA_TOTAL_SIZE, 81 J1939_NLA_TOTAL_SIZE, 82 J1939_NLA_PGN, 82 J1939_NLA_PGN, 83 J1939_NLA_SRC_NAME, 83 J1939_NLA_SRC_NAME, 84 J1939_NLA_DEST_NAME, 84 J1939_NLA_DEST_NAME, 85 J1939_NLA_SRC_ADDR, 85 J1939_NLA_SRC_ADDR, 86 J1939_NLA_DEST_ADDR, 86 J1939_NLA_DEST_ADDR, 87 }; 87 }; 88 88 89 enum { 89 enum { 90 J1939_EE_INFO_NONE, 90 J1939_EE_INFO_NONE, 91 J1939_EE_INFO_TX_ABORT, 91 J1939_EE_INFO_TX_ABORT, 92 J1939_EE_INFO_RX_RTS, 92 J1939_EE_INFO_RX_RTS, 93 J1939_EE_INFO_RX_DPO, 93 J1939_EE_INFO_RX_DPO, 94 J1939_EE_INFO_RX_ABORT, 94 J1939_EE_INFO_RX_ABORT, 95 }; 95 }; 96 96 97 struct j1939_filter { 97 struct j1939_filter { 98 name_t name; 98 name_t name; 99 name_t name_mask; 99 name_t name_mask; 100 pgn_t pgn; 100 pgn_t pgn; 101 pgn_t pgn_mask; 101 pgn_t pgn_mask; 102 __u8 addr; 102 __u8 addr; 103 __u8 addr_mask; 103 __u8 addr_mask; 104 }; 104 }; 105 105 106 #define J1939_FILTER_MAX 512 /* maximum number 106 #define J1939_FILTER_MAX 512 /* maximum number of j1939_filter set via setsockopt() */ 107 107 108 #endif /* !_UAPI_CAN_J1939_H_ */ 108 #endif /* !_UAPI_CAN_J1939_H_ */ 109 109
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.