1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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 *);
54 struct cn_queue_dev *cbdev;
58 * cn_add_callback() - Registers new callback with connector core.
60 * @id: unique connector's user identifier.
61 * It must be registered in connector.h for legal
63 * @name: connector's callback symbolic name.
64 * @callback: connector's callback.
65 * parameters are %cn_msg and the sender's credentials
67 int cn_add_callback(const struct cb_id *id, const char *name,
68 void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
70 * cn_del_callback() - Unregisters new callback with connector core.
72 * @id: unique connector's user identifier.
74 void cn_del_callback(const struct cb_id *id);
78 * cn_netlink_send_mult - Sends message to the specified groups.
80 * @msg: message header(with attached data).
81 * @len: Number of @msg to be sent.
82 * @portid: destination port.
83 * If non-zero the message will be sent to the given port,
84 * which should be set to the original sender.
85 * @group: destination group.
86 * If @portid and @group is zero, then appropriate group will
87 * be searched through all registered connector users, and
88 * message will be delivered to the group which was created
89 * for user with the same ID as in @msg.
90 * If @group is not zero, then message will be delivered
91 * to the specified group.
92 * @gfp_mask: GFP mask.
93 * @filter: Filter function to be used at netlink layer.
94 * @filter_data:Filter data to be supplied to the filter function
96 * It can be safely called from softirq context, but may silently
97 * fail under strong memory pressure.
99 * If there are no listeners for given group %-ESRCH can be returned.
101 int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid,
102 u32 group, gfp_t gfp_mask,
103 int (*filter)(struct sock *dsk, struct sk_buff *skb,
108 * cn_netlink_send - Sends message to the specified groups.
110 * @msg: message header(with attached data).
111 * @portid: destination port.
112 * If non-zero the message will be sent to the given port,
113 * which should be set to the original sender.
114 * @group: destination group.
115 * If @portid and @group is zero, then appropriate group will
116 * be searched through all registered connector users, and
117 * message will be delivered to the group which was created
118 * for user with the same ID as in @msg.
119 * If @group is not zero, then message will be delivered
120 * to the specified group.
121 * @gfp_mask: GFP mask.
123 * It can be safely called from softirq context, but may silently
124 * fail under strong memory pressure.
126 * If there are no listeners for given group %-ESRCH can be returned.
128 int cn_netlink_send(struct cn_msg *msg, u32 portid, u32 group, gfp_t gfp_mask);
130 int cn_queue_add_callback(struct cn_queue_dev *dev, const char *name,
131 const struct cb_id *id,
132 void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
133 void cn_queue_del_callback(struct cn_queue_dev *dev, const struct cb_id *id);
134 void cn_queue_release_callback(struct cn_callback_entry *);
136 struct cn_queue_dev *cn_queue_alloc_dev(const char *name, struct sock *);
137 void cn_queue_free_dev(struct cn_queue_dev *dev);
139 int cn_cb_equal(const struct cb_id *, const struct cb_id *);
141 #endif /* __CONNECTOR_H */