at commit c03c1a14

1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /*
3 * linux/can/core.h
4 *
5 * Prototypes 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 #include <net/can.h>
21
22 #define DNAME(dev) ((dev) ? (dev)->name : "any")
23
24 /**
25 * struct can_proto - CAN protocol structure
26 * @type: type argument in socket() syscall, e.g. SOCK_DGRAM.
27 * @protocol: protocol number in socket() syscall.
28 * @ops: pointer to struct proto_ops for sock->ops.
29 * @prot: pointer to struct proto structure.
30 */
31 struct can_proto {
32 int type;
33 int protocol;
34 const struct proto_ops *ops;
35 struct proto *prot;
36 };
37
38 /* required_size
39 * macro to find the minimum size of a struct
40 * that includes a requested member
41 */
42 #define CAN_REQUIRED_SIZE(struct_type, member) \
43 (offsetof(typeof(struct_type), member) + \
44 sizeof(((typeof(struct_type) *)(NULL))->member))
45
46 /* function prototypes for the CAN networklayer core (af_can.c) */
47
48 extern int can_proto_register(const struct can_proto *cp);
49 extern void can_proto_unregister(const struct can_proto *cp);
50
51 int can_rx_register(struct net *net, struct net_device *dev,
52 canid_t can_id, canid_t mask,
53 void (*func)(struct sk_buff *, void *),
54 void *data, char *ident, struct sock *sk);
55
56 extern void can_rx_unregister(struct net *net, struct net_device *dev,
57 canid_t can_id, canid_t mask,
58 void (*func)(struct sk_buff *, void *),
59 void *data);
60
61 extern int can_send(struct sk_buff *skb, int loop);
62 void can_set_skb_uid(struct can_skb_ext *csx);
63 void can_sock_destruct(struct sock *sk);
64
65 #endif /* !_CAN_CORE_H */