kdbus: the driver, original and non-working
[platform/kernel/linux-exynos.git] / ipc / kdbus / endpoint.h
1 /*
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>
8  *
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.
13  */
14
15 #ifndef __KDBUS_ENDPOINT_H
16 #define __KDBUS_ENDPOINT_H
17
18 #include <linux/list.h>
19 #include <linux/mutex.h>
20 #include <linux/uidgid.h>
21 #include "node.h"
22 #include "policy.h"
23
24 struct kdbus_bus;
25 struct kdbus_user;
26
27 /**
28  * struct kdbus_ep - endpoint to access a bus
29  * @node:               The kdbus node
30  * @lock:               Endpoint data lock
31  * @bus:                Bus behind this endpoint
32  * @user:               Custom enpoints account against an anonymous user
33  * @policy_db:          Uploaded policy
34  * @conn_list:          Connections of this endpoint
35  *
36  * An endpoint offers access to a bus; the default endpoint node name is "bus".
37  * Additional custom endpoints to the same bus can be created and they can
38  * carry their own policies/filters.
39  */
40 struct kdbus_ep {
41         struct kdbus_node node;
42         struct mutex lock;
43
44         /* static */
45         struct kdbus_bus *bus;
46         struct kdbus_user *user;
47
48         /* protected by own locks */
49         struct kdbus_policy_db policy_db;
50
51         /* protected by ep->lock */
52         struct list_head conn_list;
53 };
54
55 #define kdbus_ep_from_node(_node) \
56         container_of((_node), struct kdbus_ep, node)
57
58 struct kdbus_ep *kdbus_ep_new(struct kdbus_bus *bus, const char *name,
59                               unsigned int access, kuid_t uid, kgid_t gid,
60                               bool policy);
61 struct kdbus_ep *kdbus_ep_ref(struct kdbus_ep *ep);
62 struct kdbus_ep *kdbus_ep_unref(struct kdbus_ep *ep);
63
64 bool kdbus_ep_is_privileged(struct kdbus_ep *ep, struct file *file);
65 bool kdbus_ep_is_owner(struct kdbus_ep *ep, struct file *file);
66
67 struct kdbus_ep *kdbus_cmd_ep_make(struct kdbus_bus *bus, void __user *argp);
68 int kdbus_cmd_ep_update(struct kdbus_ep *ep, void __user *argp);
69
70 #endif