kdbus.h revision 86312ab8de59c1066d6d2b456f3a9106ce3e0991
/*
* Copyright (C) 2013 Kay Sievers
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Copyright (C) 2013 Linux Foundation
* Copyright (C) 2013 Lennart Poettering
* Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
*
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*/
#ifndef _KDBUS_H_
#define _KDBUS_H_
#ifndef __KERNEL__
#endif
#define KDBUS_IOC_MAGIC 0x95
/* Message sent from kernel to userspace, when the owner or starter of
* a well-known name changes */
struct kdbus_manager_msg_name_change {
char name[0];
};
struct kdbus_manager_msg_id_change {
};
struct kdbus_creds {
/* The starttime of the process PID. This is useful to detect
PID overruns from the client side. i.e. if you use the PID to
look something up in /proc/$PID/ you can afterwards check the
starttime field of it to ensure you didn't run into a PID
ovretun. */
};
struct kdbus_audit {
};
struct kdbus_timestamp {
};
#define KDBUS_SRC_ID_KERNEL (0)
#define KDBUS_DST_ID_WELL_KNOWN_NAME (0)
#define KDBUS_MATCH_SRC_ID_ANY (~0ULL)
#define KDBUS_DST_ID_BROADCAST (~0ULL)
/* Message Item Types */
enum {
/* Filled in by userspace */
KDBUS_MSG_PAYLOAD_VEC, /* .data_vec, reference to memory area */
KDBUS_MSG_PAYLOAD_MEMFD, /* file descriptor of a special data file */
KDBUS_MSG_FDS, /* .data_fds of file descriptors */
KDBUS_MSG_BLOOM, /* for broadcasts, carries bloom filter blob in .data */
KDBUS_MSG_DST_NAME, /* destination's well-known name, in .str */
KDBUS_MSG_PRIORITY, /* queue priority for message */
/* Filled in by kernelspace */
KDBUS_MSG_TIMESTAMP, /* .timestamp */
KDBUS_MSG_SRC_CREDS, /* .creds */
KDBUS_MSG_SRC_PID_COMM, /* optional, in .str */
KDBUS_MSG_SRC_TID_COMM, /* optional, in .str */
KDBUS_MSG_SRC_EXE, /* optional, in .str */
KDBUS_MSG_SRC_CMDLINE, /* optional, in .str (a chain of NUL str) */
KDBUS_MSG_SRC_CGROUP, /* optional, in .str */
KDBUS_MSG_SRC_CAPS, /* caps data blob, in .data */
KDBUS_MSG_SRC_SECLABEL, /* NUL terminated string, in .str */
KDBUS_MSG_SRC_AUDIT, /* .audit */
/* Special messages from kernel, consisting of one and only one of these data blocks */
KDBUS_MSG_NAME_REMOVE, /* .name_change */
KDBUS_MSG_NAME_CHANGE, /* .name_change */
KDBUS_MSG_ID_ADD, /* .id_change */
KDBUS_MSG_ID_REMOVE, /* .id_change */
KDBUS_MSG_REPLY_TIMEOUT, /* empty, but .reply_cookie in .kdbus_msg is filled in */
KDBUS_MSG_REPLY_DEAD, /* dito */
};
struct kdbus_vec {
};
struct kdbus_memfd {
int fd;
};
/**
* struct kdbus_item - chain of data blocks
*
* size: overall data record size
* type: kdbus_item type of data
*/
struct kdbus_item {
union {
/* inline data */
char str[0];
/* connection */
/* data vector */
/* process credentials and properties*/
struct kdbus_creds creds;
struct kdbus_audit audit;
struct kdbus_timestamp timestamp;
/* specific fields */
struct kdbus_memfd memfd;
int fds[0];
struct kdbus_manager_msg_id_change id_change;
};
};
enum {
KDBUS_MSG_FLAGS_EXPECT_REPLY = 1 << 0,
};
enum {
};
/**
* struct kdbus_msg
*
* set by userspace:
* dst_id: destination id
* flags: KDBUS_MSG_FLAGS_*
* items: data records
*
* set by kernel:
* src_id: who sent the message
*/
struct kdbus_msg {
union {
};
struct kdbus_item items[0];
};
enum {
};
enum {
};
enum {
KDBUS_POLICY_OWN = 1 << 0,
};
struct kdbus_policy {
union {
char name[0];
struct {
} access;
};
};
struct kdbus_cmd_policy {
* more KDBUS_POLICY_ACCESS each. */
};
/* Flags for struct kdbus_cmd_hello */
enum {
KDBUS_HELLO_STARTER = 1 << 0,
/* The following have an effect on directed messages only --
* not for broadcasts */
};
/* Items to append to struct kdbus_cmd_hello */
enum {
KDBUS_HELLO_POOL, /* kdbus_vec, userspace supplied pool to
* place received messages */
};
struct kdbus_cmd_hello {
/* userspace → kernel, kernel → userspace */
* capabilities and more, kernel
* returns its capabilites and
* more. Kernel might refuse client's
* capabilities by returning an error
* from KDBUS_HELLO */
/* kernel → userspace */
* from original KDBUS_CMD_BUS_MAKE
* ioctl. It's intended to be useful
* to do negotiation of features of
* the payload that is transfreted. */
* bus owner */
struct kdbus_item items[0];
};
/* Flags for kdbus_cmd_{bus,ep,ns}_make */
enum {
KDBUS_MAKE_ACCESS_GROUP = 1 << 0,
};
/* Items to append to kdbus_cmd_{bus,ep,ns}_make */
enum {
KDBUS_MAKE_CGROUP, /* the cgroup hierarchy ID for which to attach
* cgroup membership paths * to messages. */
KDBUS_MAKE_CRED, /* allow translator services which connect
* to the bus on behalf of somebody else,
* allow specifiying the credentials of the
* client to connect on behalf on. Needs
* privileges */
};
struct kdbus_cmd_bus_make {
* When creating a bus feature
* kernel negotiation. */
* When a bus is created this value is
* copied verbatim into the bus
* structure and returned from
* KDBUS_CMD_HELLO, later */
struct kdbus_item items[0];
};
struct kdbus_cmd_ep_make {
* When creating an entry point
* feature kernel negotiation done the
* same way as for
* KDBUS_CMD_BUS_MAKE. Unused for
* now. */
struct kdbus_item items[0];
};
struct kdbus_cmd_ns_make {
* When creating an entry point
* feature kernel negotiation done the
* same way as for
* KDBUS_CMD_BUS_MAKE. Unused for
* now. */
struct kdbus_item items[0];
};
enum {
/* userspace → kernel */
KDBUS_NAME_REPLACE_EXISTING = 1 << 0,
/* kernel → userspace */
};
struct kdbus_cmd_name {
char name[0];
};
struct kdbus_cmd_names {
struct kdbus_cmd_name names[0];
};
enum {
KDBUS_NAME_INFO_ITEM_NAME, /* userspace → kernel */
KDBUS_NAME_INFO_ITEM_SECLABEL, /* kernel → userspace */
KDBUS_NAME_INFO_ITEM_AUDIT, /* kernel → userspace */
};
struct kdbus_cmd_name_info {
struct kdbus_creds creds;
};
enum {
KDBUS_MATCH_BLOOM, /* Matches a mask blob against KDBUS_MSG_BLOOM */
KDBUS_MATCH_SRC_NAME, /* Matches a name string against KDBUS_MSG_SRC_NAMES */
KDBUS_MATCH_NAME_ADD, /* Matches a name string against KDBUS_MSG_NAME_ADD */
KDBUS_MATCH_NAME_REMOVE, /* Matches a name string against KDBUS_MSG_NAME_REMOVE */
KDBUS_MATCH_NAME_CHANGE, /* Matches a name string against KDBUS_MSG_NAME_CHANGE */
KDBUS_MATCH_ID_ADD, /* Matches an ID against KDBUS_MSG_ID_ADD */
KDBUS_MATCH_ID_REMOVE, /* Matches an ID against KDBUS_MSG_ID_REMOVE */
};
struct kdbus_cmd_match {
__u64 cookie; /* userspace supplied cookie; when removing; kernel deletes everything with same cookie */
struct kdbus_item items[0];
};
struct kdbus_cmd_monitor {
};
/* FD states:
* control nodes: unset
* bus owner (via KDBUS_CMD_BUS_MAKE)
* ns owner (via KDBUS_CMD_NS_MAKE)
*
* ep nodes: unset
* connected (via KDBUS_CMD_HELLO)
* starter (via KDBUS_CMD_HELLO with KDBUS_CMD_HELLO_STARTER)
* ep owner (via KDBUS_CMD_EP_MAKE)
*/
enum kdbus_cmd {
/* kdbus control node commands: require unset state */
/* kdbus ep node commands: require unset state */
/* kdbus ep node commands: require connected state */
/* kdbus ep node commands: require ep owner state */
/* kdbus memfd commands: */
};
#endif