]> rtime.felk.cvut.cz Git - socketcan-devel.git/blob - kernel/2.6/can/af_can.h
fix version code.
[socketcan-devel.git] / kernel / 2.6 / can / af_can.h
1 /*
2  * af_can.h
3  *
4  * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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.
19  *
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.
24  *
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.
27  *
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
39  * DAMAGE.
40  *
41  * Send feedback to <llcf@volkswagen.de>
42  *
43  */
44
45 #ifndef AF_CAN_H
46 #define AF_CAN_H
47
48 #ifdef __KERNEL__
49 #include "version.h"
50 RCSID("$Id: af_can.h,v 2.0 2006/04/13 10:37:19 ethuerm Exp $");
51 #endif
52
53 #ifdef __KERNEL__
54 #include <linux/version.h>
55 #include <linux/skbuff.h>
56 #include <linux/netdevice.h>
57 #include <linux/proc_fs.h>
58 #include <linux/if.h>
59 #else
60 #include <net/if.h>
61 #endif
62
63 #include "can.h"
64
65 #define PF_CAN       30
66 #define AF_CAN       PF_CAN
67
68 #define CAN_TP16     1
69 #define CAN_TP20     2
70 #define CAN_RAW      3
71 #define CAN_BCM      4
72 #define CAN_MCNET    5
73 #define CAN_ISOTP    6
74 #define CAN_BAP      7
75 #define CAN_MAX      8
76
77 #define SOL_CAN_BASE 100
78
79 struct sockaddr_can {
80     sa_family_t   can_family;
81     int           can_ifindex;
82     union {
83         struct { canid_t rx_id, tx_id; } tp16;
84         struct { canid_t rx_id, tx_id; } tp20;
85         struct { canid_t rx_id, tx_id; } mcnet;
86     } can_addr;
87 };
88
89 struct can_filter {
90     canid_t can_id;
91     canid_t can_mask;
92 };
93
94 #define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
95
96 #ifdef __KERNEL__
97
98 #define CAN_PROC_DIR "sys/net/can" /* /proc/... */
99
100 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
101 struct can_proto {
102     struct proto_ops *ops;
103     struct proto     *prot;
104 };
105 #else
106 struct can_proto {
107     struct proto_ops *ops;
108     struct module    *owner;
109     size_t           obj_size;
110 };
111 #endif
112
113 void can_proto_register(int proto, struct can_proto *cp);
114 void can_proto_unregister(int proto);
115 void can_rx_register(struct net_device *dev, canid_t can_id, canid_t mask,
116         void (*func)(struct sk_buff *, void *), void *data, char *ident);
117 void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
118         void (*func)(struct sk_buff *, void *), void *data);
119 void can_dev_register(struct net_device *dev,
120         void (*func)(unsigned long msg, void *), void *data);
121 void can_dev_unregister(struct net_device *dev,
122         void (*func)(unsigned long msg, void *), void *data);
123 int  can_send(struct sk_buff *skb);
124
125 unsigned long timeval2jiffies(struct timeval *tv, int round_up);
126
127 void can_debug_skb(struct sk_buff *skb);
128 void can_debug_cframe(const char *msg, struct can_frame *cframe, ...);
129
130 /* af_can rx dispatcher structures */
131
132 struct rcv_list {
133     struct rcv_list *next;
134     canid_t can_id;
135     canid_t mask;
136     unsigned long matches;
137     void (*func)(struct sk_buff *, void *);
138     void *data;
139     char *ident;
140 };
141
142 struct rcv_dev_list {
143     struct rcv_dev_list *next;
144     struct net_device *dev;
145     struct rcv_list *rx_all;
146     struct rcv_list *rx_fil;
147     struct rcv_list *rx_inv;
148     struct rcv_list *rx_sff[0x800];
149     struct rcv_list *rx_eff;
150     int entries;
151 };
152
153 /* statistic structures */
154
155 struct s_stats {
156     unsigned long jiffies_init;
157
158     unsigned long rx_frames;
159     unsigned long tx_frames;
160     unsigned long matches;
161
162     unsigned long total_rx_rate;
163     unsigned long total_tx_rate;
164     unsigned long total_rx_match_ratio;
165
166     unsigned long current_rx_rate;
167     unsigned long current_tx_rate;
168     unsigned long current_rx_match_ratio;
169
170     unsigned long max_rx_rate;
171     unsigned long max_tx_rate;
172     unsigned long max_rx_match_ratio;
173
174     unsigned long rx_frames_delta;
175     unsigned long tx_frames_delta;
176     unsigned long matches_delta;
177 }; /* can be reset e.g. by can_init_stats() */
178
179 struct s_pstats {
180     unsigned long stats_reset;
181     unsigned long rcv_entries;
182     unsigned long rcv_entries_max;
183 }; /* persistent statistics */
184
185 void can_init_proc(void);
186 void can_remove_proc(void);
187
188 #endif
189
190 #endif /* AF_CAN_H */