chiark / gitweb /
sd-bus: sync kdbus.h (ABI break)
[elogind.git] / src / libsystemd / sd-bus / kdbus.h
index 7379b3d442bc7d37e93bd09c34ba83e3fec29681..1ea4329ea2642bbd572c5937624f389028ed169b 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 2013-2014 Linux Foundation
  * Copyright (C) 2013-2014 Lennart Poettering
  * Copyright (C) 2013-2014 Daniel Mack <daniel@zonque.org>
+ * Copyright (C) 2013-2014 David Herrmann <dh.herrmann@gmail.com>
  *
  * kdbus is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the
 #ifndef _KDBUS_UAPI_H_
 #define _KDBUS_UAPI_H_
 
-#ifndef __KERNEL__
-#include <sys/ioctl.h>
-#include <sys/types.h>
+#include <linux/ioctl.h>
 #include <linux/types.h>
-#endif
 
 #define KDBUS_IOCTL_MAGIC              0x95
 #define KDBUS_SRC_ID_KERNEL            (0)
@@ -48,8 +46,8 @@ struct kdbus_notify_id_change {
 
 /**
  * struct kdbus_notify_name_change - name registry change message
- * @old:               ID and flags of former owner of a name
- * @new:               ID and flags of new owner of a name
+ * @old_id:            ID and flags of former owner of a name
+ * @new_id:            ID and flags of new owner of a name
  * @name:              Well-known name
  *
  * Sent from kernel to userspace when the owner or activator of
@@ -61,8 +59,8 @@ struct kdbus_notify_id_change {
  *   KDBUS_ITEM_NAME_CHANGE
  */
 struct kdbus_notify_name_change {
-       struct kdbus_notify_id_change old;
-       struct kdbus_notify_id_change new;
+       struct kdbus_notify_id_change old_id;
+       struct kdbus_notify_id_change new_id;
        char name[0];
 };
 
@@ -121,7 +119,7 @@ struct kdbus_timestamp {
 /**
  * struct kdbus_vec - I/O vector for kdbus payload items
  * @size:              The size of the vector
- * @address:           Memory address for memory addresses
+ * @address:           Memory address of data buffer
  * @offset:            Offset in the in-message payload memory,
  *                     relative to the message head
  *
@@ -160,7 +158,7 @@ struct kdbus_bloom_filter {
  * struct kdbus_memfd - a kdbus memfd
  * @size:              The memfd's size
  * @fd:                        The file descriptor number
- * @__pad:             Padding to ensure proper alignement and size
+ * @__pad:             Padding to ensure proper alignment and size
  *
  * Attached to:
  *   KDBUS_ITEM_PAYLOAD_MEMFD
@@ -215,7 +213,6 @@ struct kdbus_policy_access {
  *                             bloom filter
  * @KDBUS_ITEM_DST_NAME:       Destination's well-known name
  * @KDBUS_ITEM_MAKE_NAME:      Name of domain, bus, endpoint
- * @KDBUS_ITEM_MEMFD_NAME:     The human readable name of a memfd (debugging)
  * @KDBUS_ITEM_ATTACH_FLAGS:   Attach-flags, used for updating which metadata
  *                             a connection subscribes to
  * @_KDBUS_ITEM_ATTACH_BASE:   Start of metadata attach items
@@ -256,7 +253,6 @@ enum kdbus_item_type {
        KDBUS_ITEM_BLOOM_MASK,
        KDBUS_ITEM_DST_NAME,
        KDBUS_ITEM_MAKE_NAME,
-       KDBUS_ITEM_MEMFD_NAME,
        KDBUS_ITEM_ATTACH_FLAGS,
 
        _KDBUS_ITEM_ATTACH_BASE = 0x1000,
@@ -447,6 +443,31 @@ struct kdbus_cmd_recv {
        __u64 offset;
 } __attribute__((aligned(8)));
 
+/**
+ * struct kdbus_cmd_cancel - struct to cancel a synchronously pending message
+ * @cookie             The cookie of the pending message
+ * @flags              Flags for the free command. Currently unused.
+ *
+ * This struct is used with the KDBUS_CMD_CANCEL ioctl.
+ */
+struct kdbus_cmd_cancel {
+       __u64 cookie;
+       __u64 flags;
+} __attribute__((aligned(8)));
+
+/**
+ * struct kdbus_cmd_free - struct to free a slice of memory in the pool
+ * @offset             The offset of the memory slice, as returned by other
+ *                     ioctls
+ * @flags              Flags for the free command. Currently unused.
+ *
+ * This struct is used with the KDBUS_CMD_FREE ioctl.
+ */
+struct kdbus_cmd_free {
+       __u64 offset;
+       __u64 flags;
+} __attribute__((aligned(8)));
+
 /**
  * enum kdbus_policy_access_type - permissions of a policy record
  * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
@@ -477,8 +498,10 @@ enum kdbus_policy_type {
 
 /**
  * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
- * @KDBUS_HELLO_ACCEPT_FD:     The connection allows the receiving of
+ * @KDBUS_HELLO_ACCEPT_FD:     The connection allows the reception of
  *                             any passed file descriptors
+ * @KDBUS_HELLO_ACCEPT_MEMFD:  The connection allows the reception of
+ *                             any passed memfd file descriptors
  * @KDBUS_HELLO_ACTIVATOR:     Special-purpose connection which registers
  *                             a well-know name for a process to be started
  *                             when traffic arrives
@@ -493,9 +516,10 @@ enum kdbus_policy_type {
  */
 enum kdbus_hello_flags {
        KDBUS_HELLO_ACCEPT_FD           =  1ULL <<  0,
-       KDBUS_HELLO_ACTIVATOR           =  1ULL <<  1,
-       KDBUS_HELLO_POLICY_HOLDER       =  1ULL <<  2,
-       KDBUS_HELLO_MONITOR             =  1ULL <<  3,
+       KDBUS_HELLO_ACCEPT_MEMFD        =  1ULL <<  1,
+       KDBUS_HELLO_ACTIVATOR           =  1ULL <<  2,
+       KDBUS_HELLO_POLICY_HOLDER       =  1ULL <<  3,
+       KDBUS_HELLO_MONITOR             =  1ULL <<  4,
 };
 
 /**
@@ -533,8 +557,8 @@ enum kdbus_attach_flags {
 /**
  * struct kdbus_cmd_hello - struct to say hello to kdbus
  * @size:              The total size of the structure
- * @conn_flags:                Connection flags (KDBUS_HELLO_*). The kernel will
- *                     return its capabilities in that field.
+ * @features:          Feature negotiation bitmask
+ * @conn_flags:                Connection flags (KDBUS_HELLO_*).
  * @attach_flags:      Mask of metadata to attach to each message sent
  *                     (KDBUS_ATTACH_*)
  * @bus_flags:         The flags field copied verbatim from the original
@@ -553,6 +577,7 @@ enum kdbus_attach_flags {
  */
 struct kdbus_cmd_hello {
        __u64 size;
+       __u64 features;
        __u64 conn_flags;
        __u64 attach_flags;
        __u64 bus_flags;
@@ -576,14 +601,16 @@ enum kdbus_make_flags {
 /**
  * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
  * @size:              The total size of the struct
+ * @features:          Feature negotiation bitmask
  * @flags:             Properties for the bus/ep/domain to create
  * @items:             Items describing details
  *
- * This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_EP_MAKE and
- * KDBUS_CMD_DOMAIN_MAKE ioctls.
+ * This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_ENDPOINT_MAKE
+ * and KDBUS_CMD_DOMAIN_MAKE ioctls.
  */
 struct kdbus_cmd_make {
        __u64 size;
+       __u64 features;
        __u64 flags;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
@@ -608,9 +635,10 @@ enum kdbus_name_flags {
  * struct kdbus_cmd_name - struct to describe a well-known name
  * @size:              The total size of the struct
  * @flags:             Flags for a name entry (KDBUS_NAME_*)
- * @owner_id:          The current owner of the name.
+ * @owner_id:          The current owner of the name
  * @conn_flags:                The flags of the owning connection (KDBUS_HELLO_*)
- * @name:              The well-known name
+ * @items:             Item list, containing the well-known name as
+ *                     KDBUS_ITEM_NAME
  *
  * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
  */
@@ -619,7 +647,7 @@ struct kdbus_cmd_name {
        __u64 flags;
        __u64 owner_id;
        __u64 conn_flags;
-       char name[0];
+       struct kdbus_item items[0];
 } __attribute__((aligned(8)));
 
 /**
@@ -685,7 +713,7 @@ struct kdbus_cmd_conn_info {
        __u64 flags;
        __u64 id;
        __u64 offset;
-       char name[0];
+       struct kdbus_item items[0];
 } __attribute__((aligned(8)));
 
 /**
@@ -714,9 +742,20 @@ struct kdbus_conn_info {
  */
 struct kdbus_cmd_update {
        __u64 size;
+       __u64 flags;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
 
+/**
+ * enum kdbus_cmd_match_flags - flags to control the KDBUS_CMD_MATCH_ADD ioctl
+ * @KDBUS_MATCH_REPLACE:       If entries with the supplied cookie already
+ *                             exists, remove them before installing the new
+ *                             matches.
+ */
+enum kdbus_cmd_match_flags {
+       KDBUS_MATCH_REPLACE     = 1ULL <<  0,
+};
+
 /**
  * struct kdbus_cmd_match - struct to add or remove matches
  * @size:              The total size of the struct
@@ -730,6 +769,7 @@ struct kdbus_cmd_update {
 struct kdbus_cmd_match {
        __u64 size;
        __u64 cookie;
+       __u64 flags;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
 
@@ -742,7 +782,7 @@ struct kdbus_cmd_match {
  *                             is closed.
  * @KDBUS_CMD_DOMAIN_MAKE:     Similar to KDBUS_CMD_BUS_MAKE, but it creates a
  *                             new kdbus domain.
- * @KDBUS_CMD_EP_MAKE:         Creates a new named special endpoint to talk to
+ * @KDBUS_CMD_ENDPOINT_MAKE:   Creates a new named special endpoint to talk to
  *                             the bus. Such endpoints usually carry a more
  *                             restrictive policy and grant restricted access
  *                             to specific applications.
@@ -778,7 +818,7 @@ struct kdbus_cmd_match {
  * @KDBUS_CMD_CONN_UPDATE:     Update the properties of a connection. Used to
  *                             update the metadata subscription mask and
  *                             policy.
- * @KDBUS_CMD_EP_UPDATE:       Update the properties of a custom enpoint. Used
+ * @KDBUS_CMD_ENDPOINT_UPDATE: Update the properties of a custom enpoint. Used
  *                             to update the policy.
  * @KDBUS_CMD_MATCH_ADD:       Install a match which broadcast messages should
  *                             be delivered to the connection.
@@ -789,7 +829,7 @@ enum kdbus_ioctl_type {
                                             struct kdbus_cmd_make),
        KDBUS_CMD_DOMAIN_MAKE =         _IOW(KDBUS_IOCTL_MAGIC, 0x10,
                                             struct kdbus_cmd_make),
-       KDBUS_CMD_EP_MAKE =             _IOW(KDBUS_IOCTL_MAGIC, 0x20,
+       KDBUS_CMD_ENDPOINT_MAKE =       _IOW(KDBUS_IOCTL_MAGIC, 0x20,
                                             struct kdbus_cmd_make),
 
        KDBUS_CMD_HELLO =               _IOWR(KDBUS_IOCTL_MAGIC, 0x30,
@@ -800,22 +840,24 @@ enum kdbus_ioctl_type {
                                              struct kdbus_msg),
        KDBUS_CMD_MSG_RECV =            _IOWR(KDBUS_IOCTL_MAGIC, 0x41,
                                              struct kdbus_cmd_recv),
-       KDBUS_CMD_MSG_CANCEL =          _IOW(KDBUS_IOCTL_MAGIC, 0x42, __u64 *),
-       KDBUS_CMD_FREE =                _IOW(KDBUS_IOCTL_MAGIC, 0x43, __u64 *),
+       KDBUS_CMD_MSG_CANCEL =          _IOW(KDBUS_IOCTL_MAGIC, 0x42,
+                                            struct kdbus_cmd_cancel),
+       KDBUS_CMD_FREE =                _IOW(KDBUS_IOCTL_MAGIC, 0x43,
+                                            struct kdbus_cmd_free),
 
        KDBUS_CMD_NAME_ACQUIRE =        _IOWR(KDBUS_IOCTL_MAGIC, 0x50,
                                              struct kdbus_cmd_name),
        KDBUS_CMD_NAME_RELEASE =        _IOW(KDBUS_IOCTL_MAGIC, 0x51,
                                             struct kdbus_cmd_name),
        KDBUS_CMD_NAME_LIST =           _IOWR(KDBUS_IOCTL_MAGIC, 0x52,
-                                            struct kdbus_cmd_name_list),
+                                             struct kdbus_cmd_name_list),
 
        KDBUS_CMD_CONN_INFO =           _IOWR(KDBUS_IOCTL_MAGIC, 0x60,
                                              struct kdbus_cmd_conn_info),
        KDBUS_CMD_CONN_UPDATE =         _IOW(KDBUS_IOCTL_MAGIC, 0x61,
                                             struct kdbus_cmd_update),
 
-       KDBUS_CMD_EP_UPDATE =           _IOW(KDBUS_IOCTL_MAGIC, 0x71,
+       KDBUS_CMD_ENDPOINT_UPDATE =     _IOW(KDBUS_IOCTL_MAGIC, 0x71,
                                             struct kdbus_cmd_update),
 
        KDBUS_CMD_MATCH_ADD =           _IOW(KDBUS_IOCTL_MAGIC, 0x80,