chiark / gitweb /
bus: set cookie_reply and update kdbus.h
[elogind.git] / src / libsystemd-bus / kdbus.h
index 4896c38dfe30d2e07b67c7f60709109e6fd100c3..8db165c9abd1c1d7508eeddfa9e789c54bac5dc7 100644 (file)
@@ -23,7 +23,7 @@
 #define KDBUS_IOC_MAGIC                        0x95
 #define KDBUS_SRC_ID_KERNEL            (0)
 #define KDBUS_DST_ID_NAME              (0)
-#define KDBUS_MATCH_SRC_ID_ANY         (~0ULL)
+#define KDBUS_MATCH_ID_ANY             (~0ULL)
 #define KDBUS_DST_ID_BROADCAST         (~0ULL)
 
 /**
@@ -205,6 +205,7 @@ struct kdbus_policy {
  * @KDBUS_ITEM_POLICY_NAME:    Policy in struct kdbus_policy
  * @KDBUS_ITEM_POLICY_ACCESS:  Policy in struct kdbus_policy
  * @KDBUS_ITEM_NAME:           Well-know name with flags
+ * @KDBUS_ITEM_ID:             Connection ID
  * @KDBUS_ITEM_TIMESTAMP:      Timestamp
  * @KDBUS_ITEM_CREDS:          Process credential
  * @KDBUS_ITEM_PID_COMM:       Process ID "comm" identifier
@@ -242,6 +243,7 @@ enum kdbus_item_type {
 
        _KDBUS_ITEM_ATTACH_BASE = 0x600,
        KDBUS_ITEM_NAME         = _KDBUS_ITEM_ATTACH_BASE,
+       KDBUS_ITEM_ID,
        KDBUS_ITEM_TIMESTAMP,
        KDBUS_ITEM_CREDS,
        KDBUS_ITEM_PID_COMM,
@@ -312,8 +314,9 @@ struct kdbus_item {
 /**
  * enum kdbus_msg_flags - type of message
  * @KDBUS_MSG_FLAGS_EXPECT_REPLY:      Expect a reply message, used for method
- *                                     calls. The cookie identifies the
- *                                     message and the respective reply
+ *                                     calls. The userspace-supplied cookie identifies
+ *                                     the message and the respective reply
+ *                                     carries the cookie in cookie_reply
  * @KDBUS_MSG_FLAGS_NO_AUTO_START:     Do not start a service, if the addressed
  *                                     name is not currently active
  */
@@ -339,9 +342,11 @@ enum kdbus_payload_type {
  * @dst_id:            64-bit ID of the destination connection
  * @src_id:            64-bit ID of the source connection
  * @payload_type:      Payload type (KDBUS_PAYLOAD_*)
- * @cookie:            Userspace-supplied cookie
- * @cookie_reply:      For kernel-generated messages, this is the cookie
- *                     the message is a reply to
+ * @cookie:            Userspace-supplied cookie to uniquely identify a
+ *                     message, unsually all messages carry this
+ * @cookie_reply:      A reply to the message with the same cookie. The
+ *                     reply itself has its own unique cookie, @cookie_reply
+ *                     connects the reply to the request message.
  * @timeout_ns:                For non-kernel-generated messages, this denotes the
  *                     message timeout in nanoseconds. A message has to be
  *                     received with KDBUS_CMD_MSG_RECV by the destination
@@ -363,10 +368,8 @@ struct kdbus_msg {
        __u64 src_id;
        __u64 payload_type;
        __u64 cookie;
-       union {
-               __u64 cookie_reply;
-               __u64 timeout_ns;
-       };
+       __u64 cookie_reply;
+       __u64 timeout_ns;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
 
@@ -526,8 +529,9 @@ 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_*)
- * @id:                        Privileged users may use this field to (de)register
- *                     names on behalf of other peers.
+ * @owner_id:          The current owner of the name. For requests,
+ *                     privileged users may set this field to
+ *                     (de)register names on behalf of other connections.
  * @conn_flags:                The flags of the owning connection (KDBUS_HELLO_*)
  * @name:              The well-known name
  *
@@ -536,7 +540,7 @@ enum kdbus_name_flags {
 struct kdbus_cmd_name {
        __u64 size;
        __u64 flags;
-       __u64 id;
+       __u64 owner_id;
        __u64 conn_flags;
        char name[0];
 } __attribute__((aligned(8)));
@@ -624,37 +628,13 @@ struct kdbus_conn_info {
        struct kdbus_item items[0];
 };
 
-/**
- * enum kdbus_match_type - type of match record
- * @KDBUS_MATCH_BLOOM:         Matches against KDBUS_MSG_BLOOM
- * @KDBUS_MATCH_SRC_NAME:      Matches a name string
- * @KDBUS_MATCH_NAME_ADD:      Matches a name string
- * @KDBUS_MATCH_NAME_REMOVE:   Matches a name string
- * @KDBUS_MATCH_NAME_CHANGE:   Matches a name string
- * @KDBUS_MATCH_ID_ADD:                Matches an ID
- * @KDBUS_MATCH_ID_REMOVE:     Matches an ID
- */
-enum kdbus_match_type {
-       _KDBUS_MATCH_NULL,
-       KDBUS_MATCH_BLOOM,
-       KDBUS_MATCH_SRC_NAME,
-       KDBUS_MATCH_NAME_ADD,
-       KDBUS_MATCH_NAME_REMOVE,
-       KDBUS_MATCH_NAME_CHANGE,
-       KDBUS_MATCH_ID_ADD,
-       KDBUS_MATCH_ID_REMOVE,
-};
-
 /**
  * struct kdbus_cmd_match - struct to add or remove matches
  * @size:              The total size of the struct
- * @id:                        Privileged users may (de)register matches on behalf
- *                     of other peers. In other cases, set to 0.
+ * @owner_id:          Privileged users may (de)register matches on behalf
+ *                     of other peers
  * @cookie:            Userspace supplied cookie. When removing, the cookie
- *                     identifies the match to remove.
- * @src_id:            The source ID to match against. Use
- *                     KDBUS_MATCH_SRC_ID_ANY or any other value for a unique
- *                     match.
+ *                     identifies the match to remove
  * @items:             A list of items for additional information
  *
  * This structure is used with the KDBUS_CMD_ADD_MATCH and
@@ -662,9 +642,8 @@ enum kdbus_match_type {
  */
 struct kdbus_cmd_match {
        __u64 size;
-       __u64 id;
+       __u64 owner_id;
        __u64 cookie;
-       __u64 src_id;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
 
@@ -788,6 +767,8 @@ enum kdbus_ioctl_type {
  * @EBADFD:            A bus connection is in a corrupted state.
  * @EBADMSG:           Passed data contains a combination of conflicting or
  *                     inconsistent types.
+ * @EBUSY:             The user tried to say BYEBYE to a connection, but the
+ *                     connection had a non-empty message list.
  * @ECONNRESET:                A connection is shut down, no further operations are
  *                     possible.
  * @ECOMM:             A peer does not accept the file descriptors addressed
@@ -814,6 +795,8 @@ enum kdbus_ioctl_type {
  *                     size.
  * @ENOBUFS:           There is no space left for the submitted data to fit
  *                     into the receiver's pool.
+ * @ENOENT:            The name to query information about is currently not on
+ *                     the bus.
  * @ENOMEM:            Out of memory.
  * @ENOSYS:            The requested functionality is not available.
  * @ENOTCONN:          The addressed peer is not an active connection.