summaryrefslogtreecommitdiff
path: root/names.h
blob: 6e01cd1b693043d99f4d45a6acbf29c15653cf92 (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
68
69
70
71
72
73
74
75
76
/*
 * Copyright (C) 2013 Kay Sievers
 * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
 * Copyright (C) 2013 Linux Foundation
 *
 * 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_NAMES_H
#define __KDBUS_NAMES_H

#include <linux/hashtable.h>

/**
 * struct kdbus_name_registry - names registered for a bus
 * @entries_hash:	Map of entries
 * @lock:		Registry data lock
 * @name_seq_last:	Last used sequence number to assign to a name entry
 */
struct kdbus_name_registry {
	DECLARE_HASHTABLE(entries_hash, 8);
	struct mutex lock;
	u64 name_seq_last;
};

/**
 * struct kdbus_name_entry - well-know name entry
 * @name:		The well-known name
 * @name_id:		Sequence number of name entry to be able to uniquely
 *			identify a name over its registration lifetime
 * @flags:		KDBUS_NAME_* flags
 * @queue_list:		List of queued waiters for the well-known name
 * @conn_entry:		Entry in connection
 * @hentry:		Entry in registry map
 * @conn:		Connection owning the name
 * @activator:		Connection of the activator queuing incoming messages
 */
struct kdbus_name_entry {
	char *name;
	u64 name_id;
	u64 flags;
	struct list_head queue_list;
	struct list_head conn_entry;
	struct hlist_node hentry;
	struct kdbus_conn *conn;
	struct kdbus_conn *activator;
};

int kdbus_name_registry_new(struct kdbus_name_registry **reg);
void kdbus_name_registry_free(struct kdbus_name_registry *reg);

int kdbus_name_acquire(struct kdbus_name_registry *reg,
		       struct kdbus_conn *conn,
		       const char *name, u64 *flags,
		       struct kdbus_name_entry **entry);
int kdbus_cmd_name_acquire(struct kdbus_name_registry *reg,
			   struct kdbus_conn *conn,
			   struct kdbus_cmd_name *cmd);
int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
			   struct kdbus_conn *conn,
			   const struct kdbus_cmd_name *cmd);
int kdbus_cmd_name_list(struct kdbus_name_registry *reg,
			struct kdbus_conn *conn,
			struct kdbus_cmd_name_list *cmd);

struct kdbus_name_entry *kdbus_name_lookup(struct kdbus_name_registry *reg,
					   const char *name);
void kdbus_name_remove_by_conn(struct kdbus_name_registry *reg,
			       struct kdbus_conn *conn);

bool kdbus_name_is_valid(const char *p, bool allow_wildcard);
#endif