Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
af_can.c File Reference
#include <linux/module.h>
#include <linux/stddef.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include <linux/uaccess.h>
#include <linux/net.h>
#include <linux/netdevice.h>
#include <linux/socket.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <linux/skbuff.h>
#include <linux/can.h>
#include <linux/can/core.h>
#include <linux/ratelimit.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include "af_can.h"

Go to the source code of this file.

Macros

#define CAN_EFF_RTR_FLAGS   (CAN_EFF_FLAG | CAN_RTR_FLAG)
 

Functions

 MODULE_DESCRIPTION ("Controller Area Network PF_CAN core")
 
 MODULE_LICENSE ("Dual BSD/GPL")
 
 MODULE_AUTHOR ("Urs Thuermann <[email protected]>, ""Oliver Hartkopp <[email protected]>")
 
 MODULE_ALIAS_NETPROTO (PF_CAN)
 
 module_param (stats_timer, int, S_IRUGO)
 
 MODULE_PARM_DESC (stats_timer,"enable timer for statistics (default:on)")
 
int can_ioctl (struct socket *sock, unsigned int cmd, unsigned long arg)
 
 EXPORT_SYMBOL (can_ioctl)
 
int can_send (struct sk_buff *skb, int loop)
 
 EXPORT_SYMBOL (can_send)
 
int can_rx_register (struct net_device *dev, canid_t can_id, canid_t mask, void(*func)(struct sk_buff *, void *), void *data, char *ident)
 
 EXPORT_SYMBOL (can_rx_register)
 
void can_rx_unregister (struct net_device *dev, canid_t can_id, canid_t mask, void(*func)(struct sk_buff *, void *), void *data)
 
 EXPORT_SYMBOL (can_rx_unregister)
 
int can_proto_register (const struct can_proto *cp)
 
 EXPORT_SYMBOL (can_proto_register)
 
void can_proto_unregister (const struct can_proto *cp)
 
 EXPORT_SYMBOL (can_proto_unregister)
 
 module_init (can_init)
 
 module_exit (can_exit)
 

Variables

struct dev_rcv_lists can_rx_alldev_list
 
struct timer_list can_stattimer
 
struct s_stats can_stats
 
struct s_pstats can_pstats
 

Macro Definition Documentation

#define CAN_EFF_RTR_FLAGS   (CAN_EFF_FLAG | CAN_RTR_FLAG)

Function Documentation

int can_ioctl ( struct socket sock,
unsigned int  cmd,
unsigned long  arg 
)

Definition at line 98 of file af_can.c.

int can_proto_register ( const struct can_proto cp)

can_proto_register - register CAN transport protocol : pointer to CAN protocol structure

Return: 0 on success -EINVAL invalid (out of range) protocol number -EBUSY protocol already in use -ENOBUF if proto_register() fails

Definition at line 748 of file af_can.c.

void can_proto_unregister ( const struct can_proto cp)

can_proto_unregister - unregister CAN transport protocol : pointer to CAN protocol structure

Definition at line 785 of file af_can.c.

int can_rx_register ( struct net_device dev,
canid_t  can_id,
canid_t  mask,
void(*)(struct sk_buff *, void *)  func,
void data,
char ident 
)

can_rx_register - subscribe CAN frames from a specific interface : pointer to netdevice (NULL => subcribe from 'all' CAN devices list) : CAN identifier (see description) : CAN mask (see description) : callback function on filter match : returned parameter for callback function : string for calling module indentification

Description: Invokes the callback function with the received sk_buff and the given parameter 'data' on a matching receive filter. A filter matches, when

    <received_can_id> & mask == can_id & mask

The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can filter for error message frames (CAN_ERR_FLAG bit set in mask).

The provided pointer to the sk_buff is guaranteed to be valid as long as the callback function is running. The callback function must not free the given sk_buff while processing it's task. When the given sk_buff is needed after the end of the callback function it must be cloned inside the callback function with skb_clone().

Return: 0 on success -ENOMEM on missing cache mem to create subscription entry -ENODEV unknown device

Definition at line 445 of file af_can.c.

void can_rx_unregister ( struct net_device dev,
canid_t  can_id,
canid_t  mask,
void(*)(struct sk_buff *, void *)  func,
void data 
)

can_rx_unregister - unsubscribe CAN frames from a specific interface : pointer to netdevice (NULL => unsubcribe from 'all' CAN devices list) : CAN identifier : CAN mask : callback function on filter match : returned parameter for callback function

Description: Removes subscription entry depending on given (subscription) values.

Definition at line 514 of file af_can.c.

int can_send ( struct sk_buff skb,
int  loop 
)

can_send - transmit a CAN frame (optional with local loopback) : pointer to socket buffer with CAN frame in data section : loopback for listeners on local CAN sockets (recommended default!)

Due to the loopback this routine must not be called from hardirq context.

Return: 0 on success -ENETDOWN when the selected interface is down -ENOBUFS on full driver queue (see net_xmit_errno()) -ENOMEM when local loopback failed at calling skb_clone() -EPERM when trying to send on a non-CAN interface -EMSGSIZE CAN frame size is bigger than CAN interface MTU -EINVAL when the skb->data does not contain a valid CAN frame

Definition at line 227 of file af_can.c.

EXPORT_SYMBOL ( can_ioctl  )
EXPORT_SYMBOL ( can_send  )
EXPORT_SYMBOL ( can_rx_register  )
EXPORT_SYMBOL ( can_rx_unregister  )
EXPORT_SYMBOL ( can_proto_register  )
EXPORT_SYMBOL ( can_proto_unregister  )
MODULE_ALIAS_NETPROTO ( PF_CAN  )
MODULE_AUTHOR ( "Urs Thuermann <[email protected] ,
""Oliver Hartkopp< oliver.hartkopp @volkswagen.de >"   
)
MODULE_DESCRIPTION ( "Controller Area Network PF_CAN core )
module_exit ( can_exit  )
module_init ( can_init  )
MODULE_LICENSE ( "Dual BSD/GPL"  )
module_param ( stats_timer  ,
int  ,
S_IRUGO   
)
MODULE_PARM_DESC ( stats_timer  ,
"enable timer for statistics (default:on)"   
)

Variable Documentation

struct s_pstats can_pstats

Definition at line 92 of file af_can.c.

struct dev_rcv_lists can_rx_alldev_list

Definition at line 81 of file af_can.c.

struct s_stats can_stats

Definition at line 91 of file af_can.c.

struct timer_list can_stattimer

Definition at line 90 of file af_can.c.