]> rtime.felk.cvut.cz Git - can-utils.git/blob - include/socketcan/can/isotp.h
include: import kernel header files into tree
[can-utils.git] / include / socketcan / can / isotp.h
1 /*
2  * socketcan/can/isotp.h
3  *
4  * Definitions for isotp CAN sockets
5  *
6  * $Id$
7  *
8  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
9  * Copyright (c) 2008 Volkswagen Group Electronic Research
10  * All rights reserved.
11  *
12  * Send feedback to <socketcan-users@lists.berlios.de>
13  *
14  */
15
16 #ifndef CAN_ISOTP_H
17 #define CAN_ISOTP_H
18
19 #include <socketcan/can.h>
20
21 #define SOL_CAN_ISOTP (SOL_CAN_BASE + CAN_ISOTP)
22
23 /* for socket options affecting the socket (not the global system) */
24
25 #define CAN_ISOTP_OPTS          1       /* pass struct can_isotp_options */
26
27 #define CAN_ISOTP_RECV_FC       2       /* pass struct can_isotp_fc_options */
28
29 /* sockopts to force stmin timer values for protocol regression tests */
30
31 #define CAN_ISOTP_TX_STMIN      3       /* pass __u32 value in nano secs    */
32                                         /* use this time instead of value   */
33                                         /* provided in FC from the receiver */
34
35 #define CAN_ISOTP_RX_STMIN      4       /* pass __u32 value in nano secs   */
36                                         /* ignore received CF frames which */
37                                         /* timestamps differ less than val */
38
39 struct can_isotp_options {
40
41         __u32 flags;            /* set flags for isotp behaviour.       */
42                                 /* __u32 value : flags see below        */
43
44         __u32 frame_txtime;     /* frame transmission time (N_As/N_Ar)  */
45                                 /* __u32 value : time in nano secs      */
46
47         __u8  ext_address;      /* set address for extended addressing  */
48                                 /* __u8 value : extended address        */
49
50         __u8  txpad_content;    /* set content of padding byte (tx)     */
51                                 /* __u8 value : content on tx path      */
52
53         __u8  rxpad_content;    /* set content of padding byte (rx)     */
54                                 /* __u8 value : content on rx path      */
55 };
56
57 struct can_isotp_fc_options {
58
59         __u8  bs;               /* blocksize provided in FC frame       */
60                                 /* __u8 value : blocksize. 0 = off      */
61
62         __u8  stmin;            /* separation time provided in FC frame */
63                                 /* __u8 value :                         */
64                                 /* 0x00 - 0x7F : 0 - 127 ms             */
65                                 /* 0x80 - 0xF0 : reserved               */
66                                 /* 0xF1 - 0xF9 : 100 us - 900 us        */
67                                 /* 0xFA - 0xFF : reserved               */
68
69         __u8  wftmax;           /* max. number of wait frame transmiss. */
70                                 /* __u8 value : 0 = omit FC N_PDU WT    */
71 };
72
73
74 /* flags for isotp behaviour */
75
76 #define CAN_ISOTP_LISTEN_MODE   0x001   /* listen only (do not send FC) */
77 #define CAN_ISOTP_EXTEND_ADDR   0x002   /* enable extended addressing */
78 #define CAN_ISOTP_TX_PADDING    0x004   /* enable CAN frame padding tx path */
79 #define CAN_ISOTP_RX_PADDING    0x008   /* enable CAN frame padding rx path */
80 #define CAN_ISOTP_CHK_PAD_LEN   0x010   /* check received CAN frame padding */
81 #define CAN_ISOTP_CHK_PAD_DATA  0x020   /* check received CAN frame padding */
82 #define CAN_ISOTP_HALF_DUPLEX   0x040   /* half duplex error state handling */
83 #define CAN_ISOTP_FORCE_TXSTMIN 0x080   /* ignore stmin from received FC */
84 #define CAN_ISOTP_FORCE_RXSTMIN 0x100   /* ignore CFs depending on rx stmin */
85
86
87 /* default values */
88
89 #define CAN_ISOTP_DEFAULT_FLAGS         0
90 #define CAN_ISOTP_DEFAULT_EXT_ADDRESS   0x00
91 #define CAN_ISOTP_DEFAULT_RXPAD_CONTENT 0x00
92 #define CAN_ISOTP_DEFAULT_TXPAD_CONTENT 0x00
93 #define CAN_ISOTP_DEFAULT_FRAME_TXTIME  0
94 #define CAN_ISOTP_DEFAULT_RECV_BS       0
95 #define CAN_ISOTP_DEFAULT_RECV_STMIN    0x00
96 #define CAN_ISOTP_DEFAULT_RECV_WFTMAX   0
97
98 /*
99  * Remark on CAN_ISOTP_DEFAULT_RECV_* values:
100  *
101  * We can strongly assume, that the Linux Kernel implementation of
102  * CAN_ISOTP is capable to run with BS=0, STmin=0 and WFTmax=0.
103  * But as we like to be able to behave as a commonly available ECU,
104  * these default settings can be changed via sockopts.
105  * For that reason the STmin value is intentionally _not_ checked for
106  * consistency and copied directly into the flow control (FC) frame.
107  *
108  */
109
110 #endif