can_eth_gw Gateway Module
0.1
A bidirectional CAN to Ethernet Gateway (Kernel Module)
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Enumerations
Enumerator
Macros
Groups
Pages
ce_gw_main.h
Go to the documentation of this file.
1
11
/*****************************************************************************
12
* (C) Copyright 2013 Fabian Raab, Stefan Smarzly
13
*
14
* This file is part of CAN-Eth-GW.
15
*
16
* CAN-Eth-GW is free software: you can redistribute it and/or modify
17
* it under the terms of the GNU General Public License as published by
18
* the Free Software Foundation, either version 3 of the License, or
19
* (at your option) any later version.
20
*
21
* CAN-Eth-GW is distributed in the hope that it will be useful,
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
* GNU General Public License for more details.
25
*
26
* You should have received a copy of the GNU General Public License
27
* along with CAN-Eth-GW. If not, see <http://www.gnu.org/licenses/>.
28
*****************************************************************************/
29
30
#ifndef __CE_GW_MAIN_H__
31
#define __CE_GW_MAIN_H__
32
33
#include <linux/module.h>
34
#include <linux/kernel.h>
35
#include <linux/list.h>
36
#include <linux/types.h>
/* ce_gw_job */
37
#include <linux/skbuff.h>
/* sk_buff for receive */
38
#include "
ce_gw_dev.h
"
39
#include "
ce_gw_netlink.h
"
40
#include <uapi/linux/can.h>
/* since kernel 3.7 in uapi/linux/ */
41
#include <uapi/linux/if_arp.h>
/* Net_device types */
42
#include <linux/can/core.h>
/* for can_rx_register and can_send */
43
#include <linux/can/error.h>
44
#include <linux/slab.h>
/* for using kmalloc/kfree */
45
#include <linux/if_ether.h>
46
#include <linux/netdevice.h>
47
49
#define CE_GW_F_CAN_FD 0x00000001
50
55
enum
ce_gw_type
{
56
CE_GW_TYPE_NONE
,
57
CE_GW_TYPE_ETH
,
59
CE_GW_TYPE_NET
,
61
CE_GW_TYPE_TCP
,
62
CE_GW_TYPE_UDP
,
63
__CE_GW_TYPE_MAX
,
64
};
65
#define CE_GW_TYPE_MAX (__CE_GW_TYPE_MAX - 1)
72
struct ce_gw_job {
73
struct
hlist_node list;
74
struct
rcu_head rcu;
75
struct
hlist_node list_dev;
76
u32
id
;
77
enum
ce_gw_type
type
;
78
u32
flags
;
79
u32
handled_frames
;
80
u32
dropped_frames
;
82
union
{
83
struct
net_device *
dev
;
84
} src;
85
union
{
86
struct
net_device *dev;
87
} dst;
88
union
{
89
struct
can_filter can_rcv_filter;
90
/* TODO: Add ethernet receive filter (eth_rcv_filter) */
91
};
92
};
93
99
struct
hlist_head *
ce_gw_get_job_list
(
void
);
100
108
extern
struct
can_frame *
ce_gw_alloc_can_frame
(
void
);
109
117
extern
void
ce_gw_free_can_frame
(
struct
can_frame *memory);
118
126
extern
struct
canfd_frame *
ce_gw_alloc_canfd_frame
(
void
);
127
135
extern
void
ce_gw_free_canfd_frame
(
struct
canfd_frame *memory);
136
152
extern
struct
can_frame *
ce_gw_get_header_can
(canid_t can_id, __u8 can_dlc,
153
__u8 *payload);
154
170
extern
struct
canfd_frame *
ce_gw_get_header_canfd
(canid_t
id
, __u8 len,
171
__u8 flags, __u8 res0, __u8 res1, __u8 *data);
172
188
extern
struct
sk_buff *
ce_gw_can_to_eth
(
unsigned
char
*dest,
189
unsigned
char
*source, __be16 type,
struct
sk_buff *can_buffer,
190
struct
net_device *net);
191
207
extern
struct
sk_buff *
ce_gw_canfd_to_eth
(
unsigned
char
*dest,
unsigned
char
*source,
208
__be16 type,
struct
sk_buff *canfd_skb,
209
struct
net_device *net);
210
223
extern
struct
sk_buff *
ce_gw_eth_to_can
(canid_t
id
,
struct
sk_buff *eth_buff,
struct
224
net_device *net);
225
242
extern
struct
sk_buff *
ce_gw_eth_to_canfd
(canid_t
id
, __u8 flags, __u8 res0,
243
__u8 res1,
struct
sk_buff *eth_skb,
244
struct
net_device *net);
245
259
extern
void
ce_gw_can_rcv
(
struct
sk_buff *can_skb,
void
*data);
260
271
extern
void
ce_gw_eth_rcv
(
struct
sk_buff *eth_skb,
void
*data);
272
280
extern
int
ce_gw_create_route
(
int
src_ifindex,
int
dst_ifindex,
281
enum
ce_gw_type
rt_type, u32 flags);
282
290
extern
int
ce_gw_remove_route
(u32
id
);
291
292
#endif
293
ce_gw_main.h
Generated on Mon Jul 22 2013 11:59:51 for can_eth_gw Gateway Module by
1.8.3.1