1 /* SPDX-License-Identifier: GPL-2.0-or-later */
5 * 2004-2005 Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
12 #include <linux/refcount.h>
14 #include <linux/list.h>
15 #include <linux/workqueue.h>
18 #include <uapi/linux/connector.h>
20 #define CN_CBQ_NAMELEN 32
24 unsigned char name[CN_CBQ_NAMELEN];
26 struct list_head queue_list;
27 spinlock_t queue_lock;
32 struct cn_callback_id {
33 unsigned char name[CN_CBQ_NAMELEN];
37 struct cn_callback_entry {
38 struct list_head callback_entry;
40 struct cn_queue_dev *pdev;
42 struct cn_callback_id id;
43 void (*callback) (struct cn_msg *, struct netlink_skb_parms *);
53 void (*input) (struct sk_buff *skb);
55 struct cn_queue_dev *cbdev;
59 * cn_add_callback() - Registers new callback with connector core.
61 * @id: unique connector's user identifier.
62 * It must be registered in connector.h for legal
64 * @name: connector's callback symbolic name.
65 * @callback: connector's callback.
66 * parameters are %cn_msg and the sender's credentials
68 int cn_add_callback(struct cb_id *id, const char *name,
69 void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
71 * cn_del_callback() - Unregisters new callback with connector core.
73 * @id: unique connector's user identifier.
75 void cn_del_callback(struct cb_id *id);
79 * cn_netlink_send_mult - Sends message to the specified groups.
81 * @msg: message header(with attached data).
82 * @len: Number of @msg to be sent.
83 * @portid: destination port.
84 * If non-zero the message will be sent to the given port,
85 * which should be set to the original sender.
86 * @group: destination group.
87 * If @portid and @group is zero, then appropriate group will
88 * be searched through all registered connector users, and
89 * message will be delivered to the group which was created
90 * for user with the same ID as in @msg.
91 * If @group is not zero, then message will be delivered
92 * to the specified group.
93 * @gfp_mask: GFP mask.
95 * It can be safely called from softirq context, but may silently
96 * fail under strong memory pressure.
98 * If there are no listeners for given group %-ESRCH can be returned.
100 int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 group, gfp_t gfp_mask);
103 * cn_netlink_send_mult - Sends message to the specified groups.
105 * @msg: message header(with attached data).
106 * @portid: destination port.
107 * If non-zero the message will be sent to the given port,
108 * which should be set to the original sender.
109 * @group: destination group.
110 * If @portid and @group is zero, then appropriate group will
111 * be searched through all registered connector users, and
112 * message will be delivered to the group which was created
113 * for user with the same ID as in @msg.
114 * If @group is not zero, then message will be delivered
115 * to the specified group.
116 * @gfp_mask: GFP mask.
118 * It can be safely called from softirq context, but may silently
119 * fail under strong memory pressure.
121 * If there are no listeners for given group %-ESRCH can be returned.
123 int cn_netlink_send(struct cn_msg *msg, u32 portid, u32 group, gfp_t gfp_mask);
125 int cn_queue_add_callback(struct cn_queue_dev *dev, const char *name,
127 void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
128 void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
129 void cn_queue_release_callback(struct cn_callback_entry *);
131 struct cn_queue_dev *cn_queue_alloc_dev(const char *name, struct sock *);
132 void cn_queue_free_dev(struct cn_queue_dev *dev);
134 int cn_cb_equal(struct cb_id *, struct cb_id *);
136 #endif /* __CONNECTOR_H */