Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
0002 /*
0003  * j1939.h
0004  *
0005  * Copyright (c) 2010-2011 EIA Electronics
0006  *
0007  * This program is free software; you can redistribute it and/or modify
0008  * it under the terms of the GNU General Public License version 2 as
0009  * published by the Free Software Foundation.
0010  */
0011 
0012 #ifndef _UAPI_CAN_J1939_H_
0013 #define _UAPI_CAN_J1939_H_
0014 
0015 #include <linux/types.h>
0016 #include <linux/socket.h>
0017 #include <linux/can.h>
0018 
0019 #define J1939_MAX_UNICAST_ADDR 0xfd
0020 #define J1939_IDLE_ADDR 0xfe
0021 #define J1939_NO_ADDR 0xff      /* == broadcast or no addr */
0022 #define J1939_NO_NAME 0
0023 #define J1939_PGN_REQUEST 0x0ea00       /* Request PG */
0024 #define J1939_PGN_ADDRESS_CLAIMED 0x0ee00   /* Address Claimed */
0025 #define J1939_PGN_ADDRESS_COMMANDED 0x0fed8 /* Commanded Address */
0026 #define J1939_PGN_PDU1_MAX 0x3ff00
0027 #define J1939_PGN_MAX 0x3ffff
0028 #define J1939_NO_PGN 0x40000
0029 
0030 /* J1939 Parameter Group Number
0031  *
0032  * bit 0-7  : PDU Specific (PS)
0033  * bit 8-15 : PDU Format (PF)
0034  * bit 16   : Data Page (DP)
0035  * bit 17   : Reserved (R)
0036  * bit 19-31    : set to zero
0037  */
0038 typedef __u32 pgn_t;
0039 
0040 /* J1939 Priority
0041  *
0042  * bit 0-2  : Priority (P)
0043  * bit 3-7  : set to zero
0044  */
0045 typedef __u8 priority_t;
0046 
0047 /* J1939 NAME
0048  *
0049  * bit 0-20 : Identity Number
0050  * bit 21-31    : Manufacturer Code
0051  * bit 32-34    : ECU Instance
0052  * bit 35-39    : Function Instance
0053  * bit 40-47    : Function
0054  * bit 48   : Reserved
0055  * bit 49-55    : Vehicle System
0056  * bit 56-59    : Vehicle System Instance
0057  * bit 60-62    : Industry Group
0058  * bit 63   : Arbitrary Address Capable
0059  */
0060 typedef __u64 name_t;
0061 
0062 /* J1939 socket options */
0063 #define SOL_CAN_J1939 (SOL_CAN_BASE + CAN_J1939)
0064 enum {
0065     SO_J1939_FILTER = 1,    /* set filters */
0066     SO_J1939_PROMISC = 2,   /* set/clr promiscuous mode */
0067     SO_J1939_SEND_PRIO = 3,
0068     SO_J1939_ERRQUEUE = 4,
0069 };
0070 
0071 enum {
0072     SCM_J1939_DEST_ADDR = 1,
0073     SCM_J1939_DEST_NAME = 2,
0074     SCM_J1939_PRIO = 3,
0075     SCM_J1939_ERRQUEUE = 4,
0076 };
0077 
0078 enum {
0079     J1939_NLA_PAD,
0080     J1939_NLA_BYTES_ACKED,
0081     J1939_NLA_TOTAL_SIZE,
0082     J1939_NLA_PGN,
0083     J1939_NLA_SRC_NAME,
0084     J1939_NLA_DEST_NAME,
0085     J1939_NLA_SRC_ADDR,
0086     J1939_NLA_DEST_ADDR,
0087 };
0088 
0089 enum {
0090     J1939_EE_INFO_NONE,
0091     J1939_EE_INFO_TX_ABORT,
0092     J1939_EE_INFO_RX_RTS,
0093     J1939_EE_INFO_RX_DPO,
0094     J1939_EE_INFO_RX_ABORT,
0095 };
0096 
0097 struct j1939_filter {
0098     name_t name;
0099     name_t name_mask;
0100     pgn_t pgn;
0101     pgn_t pgn_mask;
0102     __u8 addr;
0103     __u8 addr_mask;
0104 };
0105 
0106 #define J1939_FILTER_MAX 512 /* maximum number of j1939_filter set via setsockopt() */
0107 
0108 #endif /* !_UAPI_CAN_J1939_H_ */