can_eth_gw Gateway Module  0.1
A bidirectional CAN to Ethernet Gateway (Kernel Module)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Getter & Setter
static __u8 ce_gw_get_ip_version (void *payload)
 Reads the first 4 bytes of IP-Header and detects the version. 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...
 

Detailed Description

Function Documentation

struct can_frame * ce_gw_get_header_can ( canid_t  can_id,
__u8  can_dlc,
__u8 *  payload 
)
read

builds a can header in SFF (standart frame format) or EFF (extended frame formate) with the given information

Parameters
can_id_tidentifier (11/29 bits) + error flag (0=data, 1= error) + remote transmission flag (1=rtr frame) + frame format flag (0=SFF, 1=EFF)
can_dlcdata length code
payloaddata (maximum 64 bit in an 8*8 array)
See Also
include/linux/can.h
Return values
canframe if successful
NULLif unsuccessful
Todo:
not tested yet

Definition at line 186 of file ce_gw_main.c.

References ce_gw_alloc_can_frame().

187  {
188  struct can_frame *new_can_frame = ce_gw_alloc_can_frame();
189  if (new_can_frame == NULL) {
190  printk (KERN_ERR "ce_gw_main.c: kmalloc failed in function"
191  "ce_gw_get_header_can \n");
192  return NULL;
193  }
194  new_can_frame->can_id = can_id;
195  new_can_frame->can_dlc = can_dlc;
196  *(u64 *)new_can_frame->data = *(u64 *)payload;
197  return new_can_frame;
198 }

Here is the call graph for this function:

static __u8 ce_gw_get_ip_version ( void *  payload)
static

Reads the first 4 bytes of IP-Header and detects the version.

Parameters
payloadLayer 2 Payload with IP-Header
Return values
4if it is a IPv4 Header
6if it is a IPv6 Header
0else

Definition at line 746 of file ce_gw_main.c.

747 {
748  __u8 version = *(__u8 *)payload & 0xF0;
749  if (version == 0x40) {
750  return 4;
751  } else if (version == 0x60) {
752  return 6;
753  } else {
754  return 0;
755  }
756 }