]> rtime.felk.cvut.cz Git - socketcan-devel.git/blob - kernel/2.6/include/socketcan/can/gw.h
Added netlink powered CAN gateway functionality with CAN frame modification features.
[socketcan-devel.git] / kernel / 2.6 / include / socketcan / can / gw.h
1 /*
2  * socketcan/can/gw.h
3  *
4  * Definitions for CAN frame Gateway/Router/Bridge 
5  *
6  * $Id$
7  *
8  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
9  * Copyright (c) 2002-2010 Volkswagen Group Electronic Research
10  * All rights reserved.
11  *
12  * Send feedback to <socketcan-users@lists.berlios.de>
13  *
14  */
15
16 #ifndef CAN_GW_H
17 #define CAN_GW_H
18
19 #include <socketcan/can.h>
20
21 struct rtcanmsg {
22         __u8  can_family;
23         __u8  can_txflags;
24         __u16 pad;
25         __u32 src_ifindex;
26         __u32 dst_ifindex;
27 };
28
29 #define CAN_GW_TXFLAGS_LOOPBACK 0x01
30
31 /* CAN rtnetlink attribute definitions */
32 enum {
33         CGW_UNSPEC,
34         CGW_FILTER,     /* specify struct can_filter on source CAN device */
35         CGW_MOD_AND,    /* CAN frame modification binary AND */
36         CGW_MOD_OR,     /* CAN frame modification binary OR */
37         CGW_MOD_XOR,    /* CAN frame modification binary XOR */
38         CGW_MOD_SET,    /* CAN frame modification set alternate values */
39         __CGW_MAX
40 };
41
42 #define CGW_MAX (__CGW_MAX - 1)
43
44 #define CGW_MOD_FUNCS 4 /* AND OR XOR SET */
45
46 /* CAN frame elements that are affected by curr. 3 CAN frame modifications */
47 #define CGW_MOD_ID      0x01
48 #define CGW_MOD_DLC     0x02
49 #define CGW_MOD_DATA    0x04
50
51 #define CGW_FRAME_MODS 3 /* ID DLC DATA */
52
53 #define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_FRAME_MODS)
54
55 #define CGW_MODATTR_LEN (sizeof(struct can_frame) + 1)
56
57 /*
58  * CAN rtnetlink attribute contents in detail
59  *
60  * CGW_FILTER (length 32 bytes):
61  * Sets a CAN receive filter for the gateway job specified by the
62  * struct can_filter described in include/linux/can.h
63  *
64  * CGW_MOD_XXX (length 17 bytes):
65  * Specifies a modification that's done to a received CAN frame before it is
66  * send out to the destination interface.
67  *
68  * <u8> affected CAN frame elements
69  * <struct can_frame> data used as operator
70  *
71  * Remark: The attribute data is a linear buffer. Beware of sending structs!
72  */
73
74 #endif