can_eth_gw Gateway Module
0.1
A bidirectional CAN to Ethernet Gateway (Kernel Module)
|
Control Area Network - Ethernet - Gateway - Device. More...
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/types.h>
#include <linux/skbuff.h>
#include "ce_gw_dev.h"
#include "ce_gw_netlink.h"
#include <uapi/linux/can.h>
#include <uapi/linux/if_arp.h>
#include <linux/can/core.h>
#include <linux/can/error.h>
#include <linux/slab.h>
#include <linux/if_ether.h>
#include <linux/netdevice.h>
#include <linux/crc32.h>
#include "ce_gw_main.h"
#include <net/ip.h>
#include <asm-generic/errno-base.h>
#include <asm-generic/errno.h>
#include <linux/can/dev.h>
Go to the source code of this file.
static struct kmem_cache *ce_gw_job_cache | __read_mostly |
static int | job_count = 1 |
MODULE_DESCRIPTION ("Control Area Network - Ethernet - Gateway") | |
MODULE_LICENSE ("GPL") | |
MODULE_AUTHOR ("Fabian Raab <fabian.raab@tum.de>, ""Stefan Smarzly <stefan.smarzly@in.tum.de>") | |
MODULE_ALIAS ("can_eth_gateway") | |
HLIST_HEAD (ce_gw_job_list) | |
static void | list_jobs () |
Some helper tools for testing. More... | |
static void | test_send_can_to_eth (struct net_device *ethdev) |
Keep these files only during development. More... | |
static void | test_get_vcan_netdev (void) |
Keep these files only during development. More... | |
static void | test_hash_list (void) |
Keep these files only during development. More... | |
struct hlist_head * | ce_gw_get_job_list (void) |
getter for HLIST_HEAD(ce_gw_job_list) More... | |
struct can_frame * | ce_gw_alloc_can_frame (void) |
allocates memory for the can frame More... | |
void | ce_gw_free_can_frame (struct can_frame *memory) |
frees memory allocated for can_frame More... | |
struct canfd_frame * | ce_gw_alloc_canfd_frame (void) |
allocates memory for a canfd frame More... | |
void | ce_gw_free_canfd_frame (struct canfd_frame *memory) |
frees memory allocated for can_frame More... | |
struct can_frame * | ce_gw_get_header_can (canid_t can_id, __u8 can_dlc, __u8 *payload) |
builds a can header in SFF (standart frame format) or EFF (extended frame formate) with the given information More... | |
struct canfd_frame * | ce_gw_get_header_canfd (canid_t id, __u8 len, __u8 flags, __u8 res0, __u8 res1, __u8 *data) |
void | ce_gw_can2net (struct sk_buff *eth_skb, struct sk_buff *can_skb, struct net_device *eth_dev, struct net_device *can_dev, unsigned char *mac_dst, unsigned char *mac_src) |
for CE_GW_TYPE_NET: copy CAN-Frame into ethernet payload More... | |
struct sk_buff * | ce_gw_can2net_alloc (struct sk_buff *can_skb, struct net_device *eth_dev, struct net_device *can_dev, unsigned char *mac_dst, unsigned char *mac_src) |
for CE_GW_TYPE_NET: copy CAN-Frame into ethernet payload and allocate More... | |
struct sk_buff * | ce_gw_net2can_alloc (struct sk_buff *eth_skb, struct net_device *can_dev) |
for CE_GW_TYPE_NET: Copy the can-frame from eth_skb to a new can skb. More... | |
void | ce_gw_canfd2net (struct sk_buff *eth_skb, struct sk_buff *can_skb, struct net_device *eth_dev, struct net_device *can_dev, unsigned char *mac_dst, unsigned char *mac_src) |
for CE_GW_TYPE_NET: copy CAN-Frame into ethernet payload More... | |
struct sk_buff * | ce_gw_canfd2net_alloc (struct sk_buff *can_skb, struct net_device *eth_dev, struct net_device *can_dev, unsigned char *mac_dst, unsigned char *mac_src) |
for CE_GW_TYPE_NET: copy canfd-Frame into ethernet payload and allocate More... | |
struct sk_buff * | ce_gw_net2canfd_alloc (struct sk_buff *eth_skb, struct net_device *can_dev, struct net_device *eth_dev) |
for CE_GW_TYPE_NET: Copy the canfd-frame from eth_skb to a new can skb. More... | |
struct sk_buff * | ce_gw_can_to_eth (unsigned char *dest, unsigned char *source, __be16 type, struct sk_buff *can_buffer, struct net_device *dev) |
converts sk buffer including can frame into sk buffer including ethernet_frame More... | |
struct sk_buff * | ce_gw_canfd_to_eth (unsigned char *dest, unsigned char *source, __be16 type, struct sk_buff *canfd_skb, struct net_device *dev) |
converts sk buffer including canfd frame into sk buffer including ethernet frame More... | |
struct sk_buff * | ce_gw_eth_to_can (canid_t id, struct sk_buff *eth_buff, struct net_device *dev) |
converst sk_buffer including an ethernet frame to sk_buffer including a can_frame More... | |
struct sk_buff * | ce_gw_eth_to_canfd (canid_t id, __u8 flags, __u8 res0, __u8 res1, struct sk_buff *eth_skb, struct net_device *dev) |
converst sk buffer including an ethernet frame to sk buffer including a canfd frame More... | |
static __u8 | ce_gw_get_ip_version (void *payload) |
Reads the first 4 bytes of IP-Header and detects the version. More... | |
void | ce_gw_can_rcv (struct sk_buff *can_skb, void *data) |
The gateway function for incoming CAN frames Receive CAN frame –> process –> send to ETH dev (skbuffer, struct receiver->data) More... | |
void | ce_gw_eth_rcv (struct sk_buff *eth_skb, void *data) |
The gateway function for incoming ETH frames Receive skb from ETH dev –> process –> send to CAN bus. More... | |
static int | ce_gw_register_can_src (struct ce_gw_job *gwj) |
static void | ce_gw_unregister_can_src (struct ce_gw_job *gwj) |
static int | ce_gw_register_eth_src (struct ce_gw_job *gwj) |
static void | ce_gw_unregister_eth_src (struct ce_gw_job *gwj) |
int | ce_gw_create_route (int src_ifindex, int dst_ifindex, enum ce_gw_type rt_type, u32 flags) |
int | ce_gw_remove_route (u32 id) |
static int __init | ce_gw_init_module (void) |
Will be automatic called at module init. More... | |
static void __exit | ce_gw_cleanup (void) |
Will be automatically called on module remove. More... | |
module_init (ce_gw_init_module) | |
module_exit (ce_gw_cleanup) | |
Control Area Network - Ethernet - Gateway - Device.
Definition in file ce_gw_main.c.
int ce_gw_create_route | ( | int | src_ifindex, |
int | dst_ifindex, | ||
enum ce_gw_type | rt_type, | ||
u32 | flags | ||
) |
Definition at line 916 of file ce_gw_main.c.
References ce_gw_job::can_rcv_filter, ce_gw_has_min_mtu(), ce_gw_is_registered_dev(), ce_gw_register_can_src(), ce_gw_register_eth_src(), ce_gw_job::dev, ce_gw_job::dropped_frames, ce_gw_job::dst, ce_gw_job::flags, ce_gw_job::handled_frames, ce_gw_job::id, job_count, ce_gw_job::list, ce_gw_job::src, and ce_gw_job::type.
Referenced by ce_gw_netlink_add().
|
read |
Definition at line 201 of file ce_gw_main.c.
References ce_gw_alloc_canfd_frame().
|
read |
getter for HLIST_HEAD(ce_gw_job_list)
Definition at line 157 of file ce_gw_main.c.
Referenced by ce_gw_netlink_list().
|
inlinestatic |
Definition at line 888 of file ce_gw_main.c.
References ce_gw_job::can_rcv_filter, ce_gw_can_rcv(), ce_gw_job::dev, and ce_gw_job::src.
Referenced by ce_gw_create_route().
|
inlinestatic |
Definition at line 903 of file ce_gw_main.c.
References ce_gw_dev_job_src_add().
Referenced by ce_gw_create_route().
int ce_gw_remove_route | ( | u32 | id | ) |
Definition at line 982 of file ce_gw_main.c.
References ce_gw_job::can_rcv_filter, ce_gw_unregister_can_src(), ce_gw_unregister_eth_src(), ce_gw_job::dev, ce_gw_job::dst, ce_gw_job::id, ce_gw_job::list, and ce_gw_job::src.
Referenced by ce_gw_cleanup(), ce_gw_dev_unregister(), and ce_gw_netlink_del().
|
inlinestatic |
Definition at line 895 of file ce_gw_main.c.
References ce_gw_job::can_rcv_filter, ce_gw_can_rcv(), ce_gw_job::dev, and ce_gw_job::src.
Referenced by ce_gw_remove_route().
|
inlinestatic |
Definition at line 910 of file ce_gw_main.c.
References ce_gw_dev_job_remove().
Referenced by ce_gw_remove_route().
HLIST_HEAD | ( | ce_gw_job_list | ) |
|
static |
Some helper tools for testing.
Definition at line 1069 of file ce_gw_main.c.
References ce_gw_job::dev, ce_gw_job::dst, ce_gw_job::id, and ce_gw_job::src.
Referenced by ce_gw_init_module().
MODULE_ALIAS | ( | "can_eth_gateway" | ) |
MODULE_AUTHOR | ( | "Fabian Raab <fabian.raab@tum.de> | , |
""Stefan Smarzly< stefan.smarzly @in.tum.de >" | |||
) |
MODULE_DESCRIPTION | ( | "Control Area Network - Ethernet - Gateway" | ) |
Diagramm witch shows the relation and Packet transmission between the components of this kernel module (ce_gw) and others of the OS.
This is an UML Klass Diagramm witch shows the main routing Management lists.
module_exit | ( | ce_gw_cleanup | ) |
module_init | ( | ce_gw_init_module | ) |
MODULE_LICENSE | ( | "GPL" | ) |
|
static |
|
static |
Keep these files only during development.
Definition at line 1120 of file ce_gw_main.c.
References ce_gw_job::dropped_frames, and ce_gw_job::list.
|
static |
Keep these files only during development.
Definition at line 1087 of file ce_gw_main.c.
|
static |
Definition at line 148 of file ce_gw_main.c.
|
static |
Definition at line 149 of file ce_gw_main.c.
Referenced by ce_gw_create_route().