summaryrefslogtreecommitdiff
path: root/ipc/kdbus/endpoint.h
blob: bc1b94a70f93a7b026f79431f00c48407ca7e01c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * Copyright (C) 2013-2015 Kay Sievers
 * Copyright (C) 2013-2015 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 * Copyright (C) 2013-2015 Daniel Mack <daniel@zonque.org>
 * Copyright (C) 2013-2015 David Herrmann <dh.herrmann@gmail.com>
 * Copyright (C) 2013-2015 Linux Foundation
 * Copyright (C) 2014-2015 Djalal Harouni <tixxdz@opendz.org>
 *
 * 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
 * Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 */

#ifndef __KDBUS_ENDPOINT_H
#define __KDBUS_ENDPOINT_H

#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/uidgid.h>
#include "node.h"
#include "policy.h"

struct kdbus_bus;
struct kdbus_user;

/**
 * struct kdbus_ep - endpoint to access a bus
 * @node:		The kdbus node
 * @lock:		Endpoint data lock
 * @bus:		Bus behind this endpoint
 * @user:		Custom enpoints account against an anonymous user
 * @policy_db:		Uploaded policy
 * @conn_list:		Connections of this endpoint
 *
 * An endpoint offers access to a bus; the default endpoint node name is "bus".
 * Additional custom endpoints to the same bus can be created and they can
 * carry their own policies/filters.
 */
struct kdbus_ep {
	struct kdbus_node node;
	struct mutex lock;

	/* static */
	struct kdbus_bus *bus;
	struct kdbus_user *user;

	/* protected by own locks */
	struct kdbus_policy_db policy_db;

	/* protected by ep->lock */
	struct list_head conn_list;
};

#define kdbus_ep_from_node(_node) \
	container_of((_node), struct kdbus_ep, node)

struct kdbus_ep *kdbus_ep_new(struct kdbus_bus *bus, const char *name,
			      unsigned int access, kuid_t uid, kgid_t gid,
			      bool policy);
struct kdbus_ep *kdbus_ep_ref(struct kdbus_ep *ep);
struct kdbus_ep *kdbus_ep_unref(struct kdbus_ep *ep);

struct kdbus_ep *kdbus_cmd_ep_make(struct kdbus_bus *bus, void __user *argp);
int kdbus_cmd_ep_update(struct kdbus_ep *ep, void __user *argp);

#endif