2 * Copyright (C) 2013-2015 Kay Sievers
3 * Copyright (C) 2013-2015 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 * Copyright (C) 2013-2015 Daniel Mack <daniel@zonque.org>
5 * Copyright (C) 2013-2015 David Herrmann <dh.herrmann@gmail.com>
6 * Copyright (C) 2013-2015 Linux Foundation
7 * Copyright (C) 2014-2015 Djalal Harouni <tixxdz@opendz.org>
9 * kdbus is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU Lesser General Public License as published by the
11 * Free Software Foundation; either version 2.1 of the License, or (at
12 * your option) any later version.
18 #include <linux/hashtable.h>
19 #include <linux/list.h>
20 #include <linux/mutex.h>
21 #include <linux/rwsem.h>
22 #include <linux/spinlock.h>
23 #include <uapi/linux/kdbus.h>
36 * struct kdbus_bus - bus in a domain
38 * @id: ID of this bus in the domain
39 * @bus_flags: Simple pass-through flags from userspace to userspace
40 * @attach_flags_owner: KDBUS_ATTACH_* flags of bus creator that other
41 * connections can see or query
42 * @id128: Unique random 128 bit ID of this bus
43 * @bloom: Bloom parameters
44 * @domain: Domain of this bus
45 * @creator: Creator of the bus
46 * @creator_meta: Meta information about the bus creator
47 * @last_message_id: Last used message id
48 * @policy_db: Policy database for this bus
49 * @name_registry: Name registry of this bus
50 * @conn_rwlock: Read/Write lock for all lists of child connections
51 * @conn_hash: Map of connection IDs
52 * @monitors_list: Connections that monitor this bus
53 * @notify_list: List of pending kernel-generated messages
54 * @notify_lock: Notification list lock
55 * @notify_flush_lock: Notification flushing lock
58 struct kdbus_node node;
63 u64 attach_flags_owner;
65 struct kdbus_bloom_parameter bloom;
66 struct kdbus_domain *domain;
67 struct kdbus_user *creator;
68 struct kdbus_meta_proc *creator_meta;
70 /* protected by own locks */
71 atomic64_t last_message_id;
72 struct kdbus_policy_db policy_db;
73 struct kdbus_name_registry *name_registry;
75 /* protected by conn_rwlock */
76 struct rw_semaphore conn_rwlock;
77 DECLARE_HASHTABLE(conn_hash, 8);
78 struct list_head monitors_list;
80 /* protected by notify_lock */
81 struct list_head notify_list;
82 spinlock_t notify_lock;
83 struct mutex notify_flush_lock;
86 struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus);
87 struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus);
89 struct kdbus_conn *kdbus_bus_find_conn_by_id(struct kdbus_bus *bus, u64 id);
90 void kdbus_bus_broadcast(struct kdbus_bus *bus,
91 struct kdbus_conn *conn_src,
92 struct kdbus_staging *staging);
93 void kdbus_bus_eavesdrop(struct kdbus_bus *bus,
94 struct kdbus_conn *conn_src,
95 struct kdbus_staging *staging);
97 struct kdbus_bus *kdbus_cmd_bus_make(struct kdbus_domain *domain,
99 int kdbus_cmd_bus_creator_info(struct kdbus_conn *conn, void __user *argp);