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