2019-07-23 16:17:55 +03:00
|
|
|
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
|
2007-11-17 02:52:17 +03:00
|
|
|
/*
|
|
|
|
* linux/can/core.h
|
|
|
|
*
|
2020-09-16 01:34:53 +03:00
|
|
|
* Prototypes and definitions for CAN protocol modules using the PF_CAN core
|
2007-11-17 02:52:17 +03:00
|
|
|
*
|
|
|
|
* Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
|
|
|
|
* Urs Thuermann <urs.thuermann@volkswagen.de>
|
2017-04-25 09:19:41 +03:00
|
|
|
* Copyright (c) 2002-2017 Volkswagen Group Electronic Research
|
2007-11-17 02:52:17 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-05-15 22:31:56 +04:00
|
|
|
#ifndef _CAN_CORE_H
|
|
|
|
#define _CAN_CORE_H
|
2007-11-17 02:52:17 +03:00
|
|
|
|
|
|
|
#include <linux/can.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
|
|
|
|
#define DNAME(dev) ((dev) ? (dev)->name : "any")
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct can_proto - CAN protocol structure
|
|
|
|
* @type: type argument in socket() syscall, e.g. SOCK_DGRAM.
|
|
|
|
* @protocol: protocol number in socket() syscall.
|
|
|
|
* @ops: pointer to struct proto_ops for sock->ops.
|
|
|
|
* @prot: pointer to struct proto structure.
|
|
|
|
*/
|
|
|
|
struct can_proto {
|
2011-03-22 11:27:25 +03:00
|
|
|
int type;
|
|
|
|
int protocol;
|
|
|
|
const struct proto_ops *ops;
|
|
|
|
struct proto *prot;
|
2007-11-17 02:52:17 +03:00
|
|
|
};
|
|
|
|
|
2018-10-08 12:48:33 +03:00
|
|
|
/* required_size
|
|
|
|
* macro to find the minimum size of a struct
|
|
|
|
* that includes a requested member
|
|
|
|
*/
|
|
|
|
#define CAN_REQUIRED_SIZE(struct_type, member) \
|
|
|
|
(offsetof(typeof(struct_type), member) + \
|
|
|
|
sizeof(((typeof(struct_type) *)(NULL))->member))
|
|
|
|
|
2007-11-17 02:52:17 +03:00
|
|
|
/* function prototypes for the CAN networklayer core (af_can.c) */
|
|
|
|
|
2011-05-03 22:40:57 +04:00
|
|
|
extern int can_proto_register(const struct can_proto *cp);
|
|
|
|
extern void can_proto_unregister(const struct can_proto *cp);
|
2007-11-17 02:52:17 +03:00
|
|
|
|
2017-02-21 14:19:47 +03:00
|
|
|
int can_rx_register(struct net *net, struct net_device *dev,
|
|
|
|
canid_t can_id, canid_t mask,
|
2017-01-27 19:11:44 +03:00
|
|
|
void (*func)(struct sk_buff *, void *),
|
|
|
|
void *data, char *ident, struct sock *sk);
|
2007-11-17 02:52:17 +03:00
|
|
|
|
2017-02-21 14:19:47 +03:00
|
|
|
extern void can_rx_unregister(struct net *net, struct net_device *dev,
|
|
|
|
canid_t can_id, canid_t mask,
|
2007-11-17 02:52:17 +03:00
|
|
|
void (*func)(struct sk_buff *, void *),
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
extern int can_send(struct sk_buff *skb, int loop);
|
2019-11-07 13:55:42 +03:00
|
|
|
void can_sock_destruct(struct sock *sk);
|
2007-11-17 02:52:17 +03:00
|
|
|
|
2014-05-15 22:31:56 +04:00
|
|
|
#endif /* !_CAN_CORE_H */
|