Merge tag 'tty-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[linux-2.6-microblaze.git] / include / linux / can / core.h
1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /*
3  * linux/can/core.h
4  *
5  * Protoypes and definitions for CAN protocol modules using the PF_CAN core
6  *
7  * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
8  *          Urs Thuermann   <urs.thuermann@volkswagen.de>
9  * Copyright (c) 2002-2017 Volkswagen Group Electronic Research
10  * All rights reserved.
11  *
12  */
13
14 #ifndef _CAN_CORE_H
15 #define _CAN_CORE_H
16
17 #include <linux/can.h>
18 #include <linux/skbuff.h>
19 #include <linux/netdevice.h>
20
21 #define CAN_VERSION "20170425"
22
23 /* increment this number each time you change some user-space interface */
24 #define CAN_ABI_VERSION "9"
25
26 #define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION
27
28 #define DNAME(dev) ((dev) ? (dev)->name : "any")
29
30 /**
31  * struct can_proto - CAN protocol structure
32  * @type:       type argument in socket() syscall, e.g. SOCK_DGRAM.
33  * @protocol:   protocol number in socket() syscall.
34  * @ops:        pointer to struct proto_ops for sock->ops.
35  * @prot:       pointer to struct proto structure.
36  */
37 struct can_proto {
38         int type;
39         int protocol;
40         const struct proto_ops *ops;
41         struct proto *prot;
42 };
43
44 /* required_size
45  * macro to find the minimum size of a struct
46  * that includes a requested member
47  */
48 #define CAN_REQUIRED_SIZE(struct_type, member) \
49         (offsetof(typeof(struct_type), member) + \
50          sizeof(((typeof(struct_type) *)(NULL))->member))
51
52 /* function prototypes for the CAN networklayer core (af_can.c) */
53
54 extern int  can_proto_register(const struct can_proto *cp);
55 extern void can_proto_unregister(const struct can_proto *cp);
56
57 int can_rx_register(struct net *net, struct net_device *dev,
58                     canid_t can_id, canid_t mask,
59                     void (*func)(struct sk_buff *, void *),
60                     void *data, char *ident, struct sock *sk);
61
62 extern void can_rx_unregister(struct net *net, struct net_device *dev,
63                               canid_t can_id, canid_t mask,
64                               void (*func)(struct sk_buff *, void *),
65                               void *data);
66
67 extern int can_send(struct sk_buff *skb, int loop);
68 void can_sock_destruct(struct sock *sk);
69
70 #endif /* !_CAN_CORE_H */