Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
0002 /*
0003  * linux/can/core.h
0004  *
0005  * Prototypes and definitions for CAN protocol modules using the PF_CAN core
0006  *
0007  * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
0008  *          Urs Thuermann   <urs.thuermann@volkswagen.de>
0009  * Copyright (c) 2002-2017 Volkswagen Group Electronic Research
0010  * All rights reserved.
0011  *
0012  */
0013 
0014 #ifndef _CAN_CORE_H
0015 #define _CAN_CORE_H
0016 
0017 #include <linux/can.h>
0018 #include <linux/skbuff.h>
0019 #include <linux/netdevice.h>
0020 
0021 #define DNAME(dev) ((dev) ? (dev)->name : "any")
0022 
0023 /**
0024  * struct can_proto - CAN protocol structure
0025  * @type:       type argument in socket() syscall, e.g. SOCK_DGRAM.
0026  * @protocol:   protocol number in socket() syscall.
0027  * @ops:        pointer to struct proto_ops for sock->ops.
0028  * @prot:       pointer to struct proto structure.
0029  */
0030 struct can_proto {
0031     int type;
0032     int protocol;
0033     const struct proto_ops *ops;
0034     struct proto *prot;
0035 };
0036 
0037 /* required_size
0038  * macro to find the minimum size of a struct
0039  * that includes a requested member
0040  */
0041 #define CAN_REQUIRED_SIZE(struct_type, member) \
0042     (offsetof(typeof(struct_type), member) + \
0043      sizeof(((typeof(struct_type) *)(NULL))->member))
0044 
0045 /* function prototypes for the CAN networklayer core (af_can.c) */
0046 
0047 extern int  can_proto_register(const struct can_proto *cp);
0048 extern void can_proto_unregister(const struct can_proto *cp);
0049 
0050 int can_rx_register(struct net *net, struct net_device *dev,
0051             canid_t can_id, canid_t mask,
0052             void (*func)(struct sk_buff *, void *),
0053             void *data, char *ident, struct sock *sk);
0054 
0055 extern void can_rx_unregister(struct net *net, struct net_device *dev,
0056                   canid_t can_id, canid_t mask,
0057                   void (*func)(struct sk_buff *, void *),
0058                   void *data);
0059 
0060 extern int can_send(struct sk_buff *skb, int loop);
0061 void can_sock_destruct(struct sock *sk);
0062 
0063 #endif /* !_CAN_CORE_H */