2 * Copyright (C) 2013-2014 Kay Sievers
3 * Copyright (C) 2013-2014 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 * Copyright (C) 2013-2014 Linux Foundation
5 * Copyright (C) 2013-2014 Lennart Poettering
6 * Copyright (C) 2013-2014 Daniel Mack <daniel@zonque.org>
7 * Copyright (C) 2013-2014 David Herrmann <dh.herrmann@gmail.com>
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.
14 * "Everything should be made as simple as possible, but not simpler."
18 #ifndef _KDBUS_UAPI_H_
19 #define _KDBUS_UAPI_H_
21 #include <linux/ioctl.h>
22 #include <linux/types.h>
24 #define KDBUS_IOCTL_MAGIC 0x95
25 #define KDBUS_SRC_ID_KERNEL (0)
26 #define KDBUS_DST_ID_NAME (0)
27 #define KDBUS_MATCH_ID_ANY (~0ULL)
28 #define KDBUS_DST_ID_BROADCAST (~0ULL)
31 * struct kdbus_notify_id_change - name registry change message
32 * @id: New or former owner of the name
33 * @flags: flags field from KDBUS_HELLO_*
35 * Sent from kernel to userspace when the owner or activator of
36 * a well-known name changes.
40 * KDBUS_ITEM_ID_REMOVE
42 struct kdbus_notify_id_change {
48 * struct kdbus_notify_name_change - name registry change message
49 * @old_id: ID and flags of former owner of a name
50 * @new_id: ID and flags of new owner of a name
51 * @name: Well-known name
53 * Sent from kernel to userspace when the owner or activator of
54 * a well-known name changes.
58 * KDBUS_ITEM_NAME_REMOVE
59 * KDBUS_ITEM_NAME_CHANGE
61 struct kdbus_notify_name_change {
62 struct kdbus_notify_id_change old_id;
63 struct kdbus_notify_id_change new_id;
68 * struct kdbus_creds - process credentials
73 * @starttime: Starttime of the process
75 * The starttime of the process PID. This is useful to detect PID overruns
76 * from the client side. i.e. if you use the PID to look something up in
77 * /proc/$PID/ you can afterwards check the starttime field of it, to ensure
78 * you didn't run into a PID overrun.
92 * struct kdbus_audit - audit information
93 * @sessionid: The audit session ID
94 * @loginuid: The audit login uid
105 * struct kdbus_timestamp
106 * @seqnum: Global per-domain message sequence number
107 * @monotonic_ns: Monotonic timestamp, in nanoseconds
108 * @realtime_ns: Realtime timestamp, in nanoseconds
111 * KDBUS_ITEM_TIMESTAMP
113 struct kdbus_timestamp {
120 * struct kdbus_vec - I/O vector for kdbus payload items
121 * @size: The size of the vector
122 * @address: Memory address of data buffer
123 * @offset: Offset in the in-message payload memory,
124 * relative to the message head
127 * KDBUS_ITEM_PAYLOAD_VEC, KDBUS_ITEM_PAYLOAD_OFF
138 * struct kdbus_bloom_parameter - bus-wide bloom parameters
139 * @size: Size of the bit field in bytes (m / 8)
140 * @n_hash: Number of hash functions used (k)
142 struct kdbus_bloom_parameter {
148 * struct kdbus_bloom_filter - bloom filter containing n elements
149 * @generation: Generation of the element set in the filter
150 * @data: Bit field, multiple of 8 bytes
152 struct kdbus_bloom_filter {
158 * struct kdbus_memfd - a kdbus memfd
159 * @size: The memfd's size
160 * @fd: The file descriptor number
161 * @__pad: Padding to ensure proper alignment and size
164 * KDBUS_ITEM_PAYLOAD_MEMFD
173 * struct kdbus_name - a registered well-known name with its flags
174 * @flags: Flags from KDBUS_NAME_*
175 * @name: Well-known name
186 * struct kdbus_policy_access - policy access item
187 * @type: One of KDBUS_POLICY_ACCESS_* types
188 * @access: Access to grant
189 * @id: For KDBUS_POLICY_ACCESS_USER, the uid
190 * For KDBUS_POLICY_ACCESS_GROUP, the gid
192 struct kdbus_policy_access {
193 __u64 type; /* USER, GROUP, WORLD */
194 __u64 access; /* OWN, TALK, SEE */
195 __u64 id; /* uid, gid, 0 */
199 * enum kdbus_item_type - item types to chain data in a list
200 * @_KDBUS_ITEM_NULL: Uninitialized/invalid
201 * @_KDBUS_ITEM_USER_BASE: Start of user items
202 * @KDBUS_ITEM_PAYLOAD_VEC: Vector to data
203 * @KDBUS_ITEM_PAYLOAD_OFF: Data at returned offset to message head
204 * @KDBUS_ITEM_PAYLOAD_MEMFD: Data as sealed memfd
205 * @KDBUS_ITEM_FDS: Attached file descriptors
206 * @KDBUS_ITEM_BLOOM_PARAMETER: Bus-wide bloom parameters, used with
207 * KDBUS_CMD_BUS_MAKE, carries a
208 * struct kdbus_bloom_parameter
209 * @KDBUS_ITEM_BLOOM_FILTER: Bloom filter carried with a message, used to
210 * match against a bloom mask of a connection,
211 * carries a struct kdbus_bloom_filter
212 * @KDBUS_ITEM_BLOOM_MASK: Bloom mask used to match against a message's
214 * @KDBUS_ITEM_DST_NAME: Destination's well-known name
215 * @KDBUS_ITEM_MAKE_NAME: Name of domain, bus, endpoint
216 * @KDBUS_ITEM_ATTACH_FLAGS: Attach-flags, used for updating which metadata
217 * a connection subscribes to
218 * @_KDBUS_ITEM_ATTACH_BASE: Start of metadata attach items
219 * @KDBUS_ITEM_NAME: Well-know name with flags
220 * @KDBUS_ITEM_ID: Connection ID
221 * @KDBUS_ITEM_TIMESTAMP: Timestamp
222 * @KDBUS_ITEM_CREDS: Process credential
223 * @KDBUS_ITEM_AUXGROUPS: Auxiliary process groups
224 * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier
225 * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier
226 * @KDBUS_ITEM_EXE: The path of the executable
227 * @KDBUS_ITEM_CMDLINE: The process command line
228 * @KDBUS_ITEM_CGROUP: The croup membership
229 * @KDBUS_ITEM_CAPS: The process capabilities
230 * @KDBUS_ITEM_SECLABEL: The security label
231 * @KDBUS_ITEM_AUDIT: The audit IDs
232 * @KDBUS_ITEM_CONN_NAME: The connection's human-readable name (debugging)
233 * @_KDBUS_ITEM_POLICY_BASE: Start of policy items
234 * @KDBUS_ITEM_POLICY_ACCESS: Policy access block
235 * @_KDBUS_ITEM_KERNEL_BASE: Start of kernel-generated message items
236 * @KDBUS_ITEM_NAME_ADD: Notify in struct kdbus_notify_name_change
237 * @KDBUS_ITEM_NAME_REMOVE: Notify in struct kdbus_notify_name_change
238 * @KDBUS_ITEM_NAME_CHANGE: Notify in struct kdbus_notify_name_change
239 * @KDBUS_ITEM_ID_ADD: Notify in struct kdbus_notify_id_change
240 * @KDBUS_ITEM_ID_REMOVE: Notify in struct kdbus_notify_id_change
241 * @KDBUS_ITEM_REPLY_TIMEOUT: Timeout has been reached
242 * @KDBUS_ITEM_REPLY_DEAD: Destination died
244 enum kdbus_item_type {
246 _KDBUS_ITEM_USER_BASE,
247 KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE,
248 KDBUS_ITEM_PAYLOAD_OFF,
249 KDBUS_ITEM_PAYLOAD_MEMFD,
251 KDBUS_ITEM_BLOOM_PARAMETER,
252 KDBUS_ITEM_BLOOM_FILTER,
253 KDBUS_ITEM_BLOOM_MASK,
255 KDBUS_ITEM_MAKE_NAME,
256 KDBUS_ITEM_ATTACH_FLAGS,
258 _KDBUS_ITEM_ATTACH_BASE = 0x1000,
259 KDBUS_ITEM_NAME = _KDBUS_ITEM_ATTACH_BASE,
261 KDBUS_ITEM_TIMESTAMP,
263 KDBUS_ITEM_AUXGROUPS,
272 KDBUS_ITEM_CONN_NAME,
274 _KDBUS_ITEM_POLICY_BASE = 0x2000,
275 KDBUS_ITEM_POLICY_ACCESS = _KDBUS_ITEM_POLICY_BASE,
277 _KDBUS_ITEM_KERNEL_BASE = 0x8000,
278 KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE,
279 KDBUS_ITEM_NAME_REMOVE,
280 KDBUS_ITEM_NAME_CHANGE,
282 KDBUS_ITEM_ID_REMOVE,
283 KDBUS_ITEM_REPLY_TIMEOUT,
284 KDBUS_ITEM_REPLY_DEAD,
288 * struct kdbus_item - chain of data blocks
289 * @size: Overall data record size
290 * @type: Kdbus_item type of data
291 * @data: Generic bytes
292 * @data32: Generic 32 bit array
293 * @data64: Generic 64 bit array
294 * @str: Generic string
296 * @vec: KDBUS_ITEM_PAYLOAD_VEC
297 * @creds: KDBUS_ITEM_CREDS
298 * @audit: KDBUS_ITEM_AUDIT
299 * @timestamp: KDBUS_ITEM_TIMESTAMP
300 * @name: KDBUS_ITEM_NAME
301 * @bloom_parameter: KDBUS_ITEM_BLOOM_PARAMETER
302 * @bloom_filter: KDBUS_ITEM_BLOOM_FILTER
303 * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD
304 * @name_change: KDBUS_ITEM_NAME_ADD
305 * KDBUS_ITEM_NAME_REMOVE
306 * KDBUS_ITEM_NAME_CHANGE
307 * @id_change: KDBUS_ITEM_ID_ADD
308 * KDBUS_ITEM_ID_REMOVE
309 * @policy: KDBUS_ITEM_POLICY_ACCESS
321 struct kdbus_vec vec;
322 struct kdbus_creds creds;
323 struct kdbus_audit audit;
324 struct kdbus_timestamp timestamp;
325 struct kdbus_name name;
326 struct kdbus_bloom_parameter bloom_parameter;
327 struct kdbus_bloom_filter bloom_filter;
328 struct kdbus_memfd memfd;
330 struct kdbus_notify_name_change name_change;
331 struct kdbus_notify_id_change id_change;
332 struct kdbus_policy_access policy_access;
337 * enum kdbus_msg_flags - type of message
338 * @KDBUS_MSG_FLAGS_EXPECT_REPLY: Expect a reply message, used for
339 * method calls. The userspace-supplied
340 * cookie identifies the message and the
341 * respective reply carries the cookie
343 * @KDBUS_MSG_FLAGS_SYNC_REPLY: Wait for destination connection to
344 * reply to this message. The
345 * KDBUS_CMD_MSG_SEND ioctl() will block
346 * until the reply is received, and
347 * offset_reply in struct kdbus_msg will
348 * yield the offset in the sender's pool
349 * where the reply can be found.
350 * This flag is only valid if
351 * @KDBUS_MSG_FLAGS_EXPECT_REPLY is set as
353 * @KDBUS_MSG_FLAGS_NO_AUTO_START: Do not start a service, if the addressed
354 * name is not currently active
356 enum kdbus_msg_flags {
357 KDBUS_MSG_FLAGS_EXPECT_REPLY = 1ULL << 0,
358 KDBUS_MSG_FLAGS_SYNC_REPLY = 1ULL << 1,
359 KDBUS_MSG_FLAGS_NO_AUTO_START = 1ULL << 2,
363 * enum kdbus_payload_type - type of payload carried by message
364 * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message
365 * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling "DBusDBus"
367 enum kdbus_payload_type {
368 KDBUS_PAYLOAD_KERNEL,
369 KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL,
373 * struct kdbus_msg - the representation of a kdbus message
374 * @size: Total size of the message
375 * @flags: Message flags (KDBUS_MSG_FLAGS_*)
376 * @priority: Message queue priority value
377 * @dst_id: 64-bit ID of the destination connection
378 * @src_id: 64-bit ID of the source connection
379 * @payload_type: Payload type (KDBUS_PAYLOAD_*)
380 * @cookie: Userspace-supplied cookie, for the connection
381 * to identify its messages
382 * @timeout_ns: The time to wait for a message reply from the peer.
383 * If there is no reply, a kernel-generated message
384 * with an attached KDBUS_ITEM_REPLY_TIMEOUT item
385 * is sent to @src_id.
386 * @cookie_reply: A reply to the requesting message with the same
387 * cookie. The requesting connection can match its
388 * request and the reply with this value
389 * @offset_reply: If KDBUS_MSG_FLAGS_EXPECT_REPLY, this field will
390 * contain the offset in the sender's pool where the
392 * @items: A list of kdbus_items containing the message payload
407 struct kdbus_item items[0];
408 } __attribute__((aligned(8)));
411 * enum kdbus_recv_flags - flags for de-queuing messages
412 * @KDBUS_RECV_PEEK: Return the next queued message without
413 * actually de-queuing it, and without installing
414 * any file descriptors or other resources. It is
415 * usually used to determine the activating
416 * connection of a bus name.
417 * @KDBUS_RECV_DROP: Drop and free the next queued message and all
418 * its resources without actually receiving it.
419 * @KDBUS_RECV_USE_PRIORITY: Only de-queue messages with the specified or
420 * higher priority (lowest values); if not set,
421 * the priority value is ignored.
423 enum kdbus_recv_flags {
424 KDBUS_RECV_PEEK = 1ULL << 0,
425 KDBUS_RECV_DROP = 1ULL << 1,
426 KDBUS_RECV_USE_PRIORITY = 1ULL << 2,
430 * struct kdbus_cmd_recv - struct to de-queue a buffered message
431 * @flags: KDBUS_RECV_* flags
432 * @priority: Minimum priority of the messages to de-queue. Lowest
433 * values have the highest priority.
434 * @offset: Returned offset in the pool where the message is
435 * stored. The user must use KDBUS_CMD_FREE to free
436 * the allocated memory.
438 * This struct is used with the KDBUS_CMD_MSG_RECV ioctl.
440 struct kdbus_cmd_recv {
444 } __attribute__((aligned(8)));
447 * struct kdbus_cmd_cancel - struct to cancel a synchronously pending message
448 * @cookie The cookie of the pending message
449 * @flags Flags for the free command. Currently unused.
451 * This struct is used with the KDBUS_CMD_CANCEL ioctl.
453 struct kdbus_cmd_cancel {
456 } __attribute__((aligned(8)));
459 * struct kdbus_cmd_free - struct to free a slice of memory in the pool
460 * @offset The offset of the memory slice, as returned by other
462 * @flags Flags for the free command. Currently unused.
464 * This struct is used with the KDBUS_CMD_FREE ioctl.
466 struct kdbus_cmd_free {
469 } __attribute__((aligned(8)));
472 * enum kdbus_policy_access_type - permissions of a policy record
473 * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
474 * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid
475 * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid
476 * @KDBUS_POLICY_ACCESS_WORLD: World-accessible
478 enum kdbus_policy_access_type {
479 _KDBUS_POLICY_ACCESS_NULL,
480 KDBUS_POLICY_ACCESS_USER,
481 KDBUS_POLICY_ACCESS_GROUP,
482 KDBUS_POLICY_ACCESS_WORLD,
486 * enum kdbus_policy_access_flags - mode flags
487 * @KDBUS_POLICY_OWN: Allow to own a well-known name
488 * Implies KDBUS_POLICY_TALK and KDBUS_POLICY_SEE
489 * @KDBUS_POLICY_TALK: Allow communication to a well-known name
490 * Implies KDBUS_POLICY_SEE
491 * @KDBUS_POLICY_SEE: Allow to see a well-known name
493 enum kdbus_policy_type {
494 KDBUS_POLICY_SEE = 0,
500 * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
501 * @KDBUS_HELLO_ACCEPT_FD: The connection allows the reception of
502 * any passed file descriptors
503 * @KDBUS_HELLO_ACCEPT_MEMFD: The connection allows the reception of
504 * any passed memfd file descriptors
505 * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers
506 * a well-know name for a process to be started
507 * when traffic arrives
508 * @KDBUS_HELLO_POLICY_HOLDER: Special-purpose connection which registers
509 * policy entries for a name. The provided name
510 * is not activated and not registered with the
511 * name database, it only allows unprivileged
512 * connections to aquire a name, talk or discover
514 * @KDBUS_HELLO_MONITOR: Special-purpose connection to monitor
517 enum kdbus_hello_flags {
518 KDBUS_HELLO_ACCEPT_FD = 1ULL << 0,
519 KDBUS_HELLO_ACCEPT_MEMFD = 1ULL << 1,
520 KDBUS_HELLO_ACTIVATOR = 1ULL << 2,
521 KDBUS_HELLO_POLICY_HOLDER = 1ULL << 3,
522 KDBUS_HELLO_MONITOR = 1ULL << 4,
526 * enum kdbus_attach_flags - flags for metadata attachments
527 * @KDBUS_ATTACH_TIMESTAMP: Timestamp
528 * @KDBUS_ATTACH_CREDS: Credentials
529 * @KDBUS_ATTACH_AUXGROUPS: Auxiliary groups
530 * @KDBUS_ATTACH_NAMES: Well-known names
531 * @KDBUS_ATTACH_COMM: The "comm" process identifier
532 * @KDBUS_ATTACH_EXE: The path of the executable
533 * @KDBUS_ATTACH_CMDLINE: The process command line
534 * @KDBUS_ATTACH_CGROUP: The croup membership
535 * @KDBUS_ATTACH_CAPS: The process capabilities
536 * @KDBUS_ATTACH_SECLABEL: The security label
537 * @KDBUS_ATTACH_AUDIT: The audit IDs
538 * @KDBUS_ATTACH_CONN_NAME: The human-readable connection name
539 * @_KDBUS_ATTACH_ALL: All of the above
541 enum kdbus_attach_flags {
542 KDBUS_ATTACH_TIMESTAMP = 1ULL << 0,
543 KDBUS_ATTACH_CREDS = 1ULL << 1,
544 KDBUS_ATTACH_AUXGROUPS = 1ULL << 2,
545 KDBUS_ATTACH_NAMES = 1ULL << 3,
546 KDBUS_ATTACH_COMM = 1ULL << 4,
547 KDBUS_ATTACH_EXE = 1ULL << 5,
548 KDBUS_ATTACH_CMDLINE = 1ULL << 6,
549 KDBUS_ATTACH_CGROUP = 1ULL << 7,
550 KDBUS_ATTACH_CAPS = 1ULL << 8,
551 KDBUS_ATTACH_SECLABEL = 1ULL << 9,
552 KDBUS_ATTACH_AUDIT = 1ULL << 10,
553 KDBUS_ATTACH_CONN_NAME = 1ULL << 11,
554 _KDBUS_ATTACH_ALL = (1ULL << 12) - 1,
558 * struct kdbus_cmd_hello - struct to say hello to kdbus
559 * @size: The total size of the structure
560 * @features: Feature negotiation bitmask
561 * @conn_flags: Connection flags (KDBUS_HELLO_*).
562 * @attach_flags: Mask of metadata to attach to each message sent
564 * @bus_flags: The flags field copied verbatim from the original
565 * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful
566 * to do negotiation of features of the payload that is
567 * transferred (kernel → userspace)
568 * @id: The ID of this connection (kernel → userspace)
569 * @pool_size: Size of the connection's buffer where the received
570 * messages are placed
571 * @bloom: The bloom properties of the bus, specified
572 * by the bus creator (kernel → userspace)
573 * @id128: Unique 128-bit ID of the bus (kernel → userspace)
574 * @items: A list of items
576 * This struct is used with the KDBUS_CMD_HELLO ioctl.
578 struct kdbus_cmd_hello {
586 struct kdbus_bloom_parameter bloom;
588 struct kdbus_item items[0];
589 } __attribute__((aligned(8)));
592 * enum kdbus_make_flags - Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE
593 * @KDBUS_MAKE_ACCESS_GROUP: Make the device node group-accessible
594 * @KDBUS_MAKE_ACCESS_WORLD: Make the device node world-accessible
596 enum kdbus_make_flags {
597 KDBUS_MAKE_ACCESS_GROUP = 1ULL << 0,
598 KDBUS_MAKE_ACCESS_WORLD = 1ULL << 1,
602 * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
603 * @size: The total size of the struct
604 * @features: Feature negotiation bitmask
605 * @flags: Properties for the bus/ep/domain to create
606 * @items: Items describing details
608 * This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_ENDPOINT_MAKE
609 * and KDBUS_CMD_DOMAIN_MAKE ioctls.
611 struct kdbus_cmd_make {
615 struct kdbus_item items[0];
616 } __attribute__((aligned(8)));
619 * enum kdbus_name_flags - properties of a well-known name
620 * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections
621 * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name
622 * @KDBUS_NAME_QUEUE: Name should be queued if busy
623 * @KDBUS_NAME_IN_QUEUE: Name is queued
624 * @KDBUS_NAME_ACTIVATOR: Name is owned by a activator connection
626 enum kdbus_name_flags {
627 KDBUS_NAME_REPLACE_EXISTING = 1ULL << 0,
628 KDBUS_NAME_ALLOW_REPLACEMENT = 1ULL << 1,
629 KDBUS_NAME_QUEUE = 1ULL << 2,
630 KDBUS_NAME_IN_QUEUE = 1ULL << 3,
631 KDBUS_NAME_ACTIVATOR = 1ULL << 4,
635 * struct kdbus_cmd_name - struct to describe a well-known name
636 * @size: The total size of the struct
637 * @flags: Flags for a name entry (KDBUS_NAME_*)
638 * @owner_id: The current owner of the name
639 * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
640 * @items: Item list, containing the well-known name as
643 * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
645 struct kdbus_cmd_name {
650 struct kdbus_item items[0];
651 } __attribute__((aligned(8)));
654 * enum kdbus_name_list_flags - what to include into the returned list
655 * @KDBUS_NAME_LIST_UNIQUE: All active connections
656 * @KDBUS_NAME_LIST_NAMES: All known well-known names
657 * @KDBUS_NAME_LIST_ACTIVATORS: All activator connections
658 * @KDBUS_NAME_LIST_QUEUED: All queued-up names
660 enum kdbus_name_list_flags {
661 KDBUS_NAME_LIST_UNIQUE = 1ULL << 0,
662 KDBUS_NAME_LIST_NAMES = 1ULL << 1,
663 KDBUS_NAME_LIST_ACTIVATORS = 1ULL << 2,
664 KDBUS_NAME_LIST_QUEUED = 1ULL << 3,
668 * struct kdbus_cmd_name_list - request a list of name entries
669 * @flags: Flags for the query (KDBUS_NAME_LIST_*)
670 * @offset: The returned offset in the caller's pool buffer.
671 * The user must use KDBUS_CMD_FREE to free the
674 * This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
676 struct kdbus_cmd_name_list {
679 } __attribute__((aligned(8)));
682 * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST
683 * @size: The total size of the structure
684 * @names: A list of names
686 * Note that the user is responsible for freeing the allocated memory with
687 * the KDBUS_CMD_FREE ioctl.
689 struct kdbus_name_list {
691 struct kdbus_cmd_name names[0];
695 * struct kdbus_cmd_conn_info - struct used for KDBUS_CMD_CONN_INFO ioctl
696 * @size: The total size of the struct
697 * @flags: KDBUS_ATTACH_* flags
698 * @id: The 64-bit ID of the connection. If set to zero, passing
699 * @name is required. kdbus will look up the name to
700 * determine the ID in this case.
701 * @offset: Returned offset in the caller's pool buffer where the
702 * kdbus_conn_info struct result is stored. The user must
703 * use KDBUS_CMD_FREE to free the allocated memory.
704 * @name: The optional well-known name to look up. Only needed in
707 * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will
708 * tell the user the offset in the connection pool buffer at which to find the
709 * result in a struct kdbus_conn_info.
711 struct kdbus_cmd_conn_info {
716 struct kdbus_item items[0];
717 } __attribute__((aligned(8)));
720 * struct kdbus_conn_info - information returned by KDBUS_CMD_CONN_INFO
721 * @size: The total size of the struct
722 * @id: The connection's 64-bit ID
723 * @flags: The connection's flags
724 * @items: A list of struct kdbus_item
726 * Note that the user is responsible for freeing the allocated memory with
727 * the KDBUS_CMD_FREE ioctl.
729 struct kdbus_conn_info {
733 struct kdbus_item items[0];
737 * struct kdbus_cmd_update - update flags of a connection
738 * @size: The total size of the struct
739 * @items: A list of struct kdbus_item
741 * This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl.
743 struct kdbus_cmd_update {
746 struct kdbus_item items[0];
747 } __attribute__((aligned(8)));
750 * enum kdbus_cmd_match_flags - flags to control the KDBUS_CMD_MATCH_ADD ioctl
751 * @KDBUS_MATCH_REPLACE: If entries with the supplied cookie already
752 * exists, remove them before installing the new
755 enum kdbus_cmd_match_flags {
756 KDBUS_MATCH_REPLACE = 1ULL << 0,
760 * struct kdbus_cmd_match - struct to add or remove matches
761 * @size: The total size of the struct
762 * @cookie: Userspace supplied cookie. When removing, the cookie
763 * identifies the match to remove
764 * @items: A list of items for additional information
766 * This structure is used with the KDBUS_CMD_ADD_MATCH and
767 * KDBUS_CMD_REMOVE_MATCH ioctl.
769 struct kdbus_cmd_match {
773 struct kdbus_item items[0];
774 } __attribute__((aligned(8)));
777 * enum kdbus_ioctl_type - Ioctl API
778 * @KDBUS_CMD_BUS_MAKE: After opening the "control" device node, this
779 * command creates a new bus with the specified
780 * name. The bus is immediately shut down and
781 * cleaned up when the opened "control" device node
783 * @KDBUS_CMD_DOMAIN_MAKE: Similar to KDBUS_CMD_BUS_MAKE, but it creates a
785 * @KDBUS_CMD_ENDPOINT_MAKE: Creates a new named special endpoint to talk to
786 * the bus. Such endpoints usually carry a more
787 * restrictive policy and grant restricted access
788 * to specific applications.
789 * @KDBUS_CMD_HELLO: By opening the bus device node a connection is
790 * created. After a HELLO the opened connection
791 * becomes an active peer on the bus.
792 * @KDBUS_CMD_BYEBYE: Disconnect a connection. If there are no
793 * messages queued up in the connection's pool,
794 * the call succeeds, and the handle is rendered
795 * unusable. Otherwise, -EBUSY is returned without
796 * any further side-effects.
797 * @KDBUS_CMD_MSG_SEND: Send a message and pass data from userspace to
799 * @KDBUS_CMD_MSG_RECV: Receive a message from the kernel which is
800 * placed in the receiver's pool.
801 * @KDBUS_CMD_MSG_CANCEL: Cancel a pending request of a message that
802 * blocks while waiting for a reply. The parameter
803 * denotes the cookie of the message in flight.
804 * @KDBUS_CMD_FREE: Release the allocated memory in the receiver's
806 * @KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with
807 * the connection. Well-known names are used to
808 * address a peer on the bus.
809 * @KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection
811 * @KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered
812 * well-known and unique names.
813 * @KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the
814 * initial creator of the connection. The data was
815 * stored at registration time and does not
816 * necessarily represent the connected process or
817 * the actual state of the process.
818 * @KDBUS_CMD_CONN_UPDATE: Update the properties of a connection. Used to
819 * update the metadata subscription mask and
821 * @KDBUS_CMD_ENDPOINT_UPDATE: Update the properties of a custom enpoint. Used
822 * to update the policy.
823 * @KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should
824 * be delivered to the connection.
825 * @KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages.
827 enum kdbus_ioctl_type {
828 KDBUS_CMD_BUS_MAKE = _IOW(KDBUS_IOCTL_MAGIC, 0x00,
829 struct kdbus_cmd_make),
830 KDBUS_CMD_DOMAIN_MAKE = _IOW(KDBUS_IOCTL_MAGIC, 0x10,
831 struct kdbus_cmd_make),
832 KDBUS_CMD_ENDPOINT_MAKE = _IOW(KDBUS_IOCTL_MAGIC, 0x20,
833 struct kdbus_cmd_make),
835 KDBUS_CMD_HELLO = _IOWR(KDBUS_IOCTL_MAGIC, 0x30,
836 struct kdbus_cmd_hello),
837 KDBUS_CMD_BYEBYE = _IO(KDBUS_IOCTL_MAGIC, 0x31),
839 KDBUS_CMD_MSG_SEND = _IOWR(KDBUS_IOCTL_MAGIC, 0x40,
841 KDBUS_CMD_MSG_RECV = _IOWR(KDBUS_IOCTL_MAGIC, 0x41,
842 struct kdbus_cmd_recv),
843 KDBUS_CMD_MSG_CANCEL = _IOW(KDBUS_IOCTL_MAGIC, 0x42,
844 struct kdbus_cmd_cancel),
845 KDBUS_CMD_FREE = _IOW(KDBUS_IOCTL_MAGIC, 0x43,
846 struct kdbus_cmd_free),
848 KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOCTL_MAGIC, 0x50,
849 struct kdbus_cmd_name),
850 KDBUS_CMD_NAME_RELEASE = _IOW(KDBUS_IOCTL_MAGIC, 0x51,
851 struct kdbus_cmd_name),
852 KDBUS_CMD_NAME_LIST = _IOWR(KDBUS_IOCTL_MAGIC, 0x52,
853 struct kdbus_cmd_name_list),
855 KDBUS_CMD_CONN_INFO = _IOWR(KDBUS_IOCTL_MAGIC, 0x60,
856 struct kdbus_cmd_conn_info),
857 KDBUS_CMD_CONN_UPDATE = _IOW(KDBUS_IOCTL_MAGIC, 0x61,
858 struct kdbus_cmd_update),
860 KDBUS_CMD_ENDPOINT_UPDATE = _IOW(KDBUS_IOCTL_MAGIC, 0x71,
861 struct kdbus_cmd_update),
863 KDBUS_CMD_MATCH_ADD = _IOW(KDBUS_IOCTL_MAGIC, 0x80,
864 struct kdbus_cmd_match),
865 KDBUS_CMD_MATCH_REMOVE = _IOW(KDBUS_IOCTL_MAGIC, 0x81,
866 struct kdbus_cmd_match),
869 #endif /* _KDBUS_UAPI_H_ */