4 * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, the following disclaimer and
12 * the referenced file 'COPYING'.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Volkswagen nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * Alternatively, provided that this notice is retained in full, this
21 * software may be distributed under the terms of the GNU General
22 * Public License ("GPL") version 2 as distributed in the 'COPYING'
23 * file from the main directory of the linux kernel source.
25 * The provided data structures and external interfaces from this code
26 * are not restricted to be used by modules with a GPL compatible license.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
41 * Send feedback to <socketcan-users@lists.berlios.de>
49 #include <linux/version.h>
50 #include <linux/skbuff.h>
51 #include <linux/netdevice.h>
52 #include <linux/proc_fs.h>
54 #include <linux/list.h>
59 #include <linux/can/can.h>
61 /* CAN socket protocol family definition */
62 /* to be moved to include/linux/socket.h */
63 #define PF_CAN 29 /* Controller Area Network */
66 /* particular protocols of the protocol family PF_CAN */
67 #define CAN_RAW 1 /* RAW sockets */
68 #define CAN_BCM 2 /* Broadcast Manager */
69 #define CAN_TP16 3 /* VAG Transport Protocol v1.6 */
70 #define CAN_TP20 4 /* VAG Transport Protocol v2.0 */
71 #define CAN_MCNET 5 /* Bosch MCNet */
72 #define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */
73 #define CAN_BAP 7 /* VAG Bedien- und Anzeigeprotokoll */
76 #define SOL_CAN_BASE 100
79 sa_family_t can_family;
82 struct { canid_t rx_id, tx_id; } tp16;
83 struct { canid_t rx_id, tx_id; } tp20;
84 struct { canid_t rx_id, tx_id; } mcnet;
88 typedef canid_t can_err_mask_t;
95 #define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
99 #define CAN_PROC_DIR "net/can" /* /proc/... */
105 struct proto_ops *ops;
106 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
109 struct module *owner;
110 int (*init)(struct sock *sk);
115 void can_proto_register(struct can_proto *cp);
116 void can_proto_unregister(struct can_proto *cp);
117 void can_rx_register(struct net_device *dev, canid_t can_id, canid_t mask,
118 void (*func)(struct sk_buff *, void *), void *data,
120 void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
121 void (*func)(struct sk_buff *, void *), void *data);
122 void can_dev_register(struct net_device *dev,
123 void (*func)(unsigned long msg, void *), void *data);
124 void can_dev_unregister(struct net_device *dev,
125 void (*func)(unsigned long msg, void *), void *data);
126 int can_send(struct sk_buff *skb, int loop);
128 unsigned long timeval2jiffies(struct timeval *tv, int round_up);
130 void can_debug_skb(struct sk_buff *skb);
131 void can_debug_cframe(const char *msg, struct can_frame *cframe, ...);
133 /* af_can rx dispatcher structures */
136 struct hlist_node list;
140 unsigned long matches;
141 void (*func)(struct sk_buff *, void *);
146 struct dev_rcv_lists {
147 struct hlist_node list;
149 struct net_device *dev;
150 struct hlist_head rx_err;
151 struct hlist_head rx_all;
152 struct hlist_head rx_fil;
153 struct hlist_head rx_inv;
154 struct hlist_head rx_sff[0x800];
155 struct hlist_head rx_eff;
159 /* statistic structures */
162 unsigned long jiffies_init;
164 unsigned long rx_frames;
165 unsigned long tx_frames;
166 unsigned long matches;
168 unsigned long total_rx_rate;
169 unsigned long total_tx_rate;
170 unsigned long total_rx_match_ratio;
172 unsigned long current_rx_rate;
173 unsigned long current_tx_rate;
174 unsigned long current_rx_match_ratio;
176 unsigned long max_rx_rate;
177 unsigned long max_tx_rate;
178 unsigned long max_rx_match_ratio;
180 unsigned long rx_frames_delta;
181 unsigned long tx_frames_delta;
182 unsigned long matches_delta;
183 }; /* can be reset e.g. by can_init_stats() */
186 unsigned long stats_reset;
187 unsigned long rcv_entries;
188 unsigned long rcv_entries_max;
189 }; /* persistent statistics */
191 void can_init_proc(void);
192 void can_remove_proc(void);
196 #endif /* AF_CAN_H */