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

source code of linux/include/linux/can/core.h