forked from gregkh/kdbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection.h
111 lines (105 loc) · 3.68 KB
/
connection.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* 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_CONNECTION_H
#define __KDBUS_CONNECTION_H
#include "defaults.h"
#include "util.h"
#include "metadata.h"
#include "pool.h"
/**
* struct kdbus_conn - connection to a bus
* @kref: Reference count
* @disconnected: Invalidated data
* @name: Human-readable connection name, used for debugging
* @ep: The endpoint this connection belongs to
* @id: Connection ID
* @flags: KDBUS_HELLO_* flags
* @attach_flags: KDBUS_ATTACH_* flags
* @lock: Connection data lock
* @msg_list: Queue of messages
* @msg_prio_queue: Tree of messages, sorted by priority
* @msg_prio_highest: Cached entry for highest priority (lowest value) node
* @hentry: Entry in ID <-> connection map
* @monitor_entry: The connection is a monitor
* @names_list: List of well-known names
* @names_queue_list: Well-known names this connection waits for
* @reply_list: List of connections this connection expects
* a reply from.
* @reply_count: Number of requests this connection has issued, and
* waits for replies from the peer
* @names: Number of owned well-known names
* @work: Support for poll()
* @timer: Message reply timeout handling
* @match_db: Subscription filter to broadcast messages
* @meta: Active connection creator's metadata/credentials,
* either from the handle of from HELLO
* @owner_meta: The connection's metadata/credentials supplied by
* HELLO
* @msg_count: Number of queued messages
* @pool: The user's buffer to receive messages
* @user: Owner of the connection;
*/
struct kdbus_conn {
struct kref kref;
bool disconnected;
const char *name;
struct kdbus_ep *ep;
u64 id;
u64 flags;
u64 attach_flags;
struct mutex lock;
struct list_head msg_list;
struct rb_root msg_prio_queue;
struct rb_node *msg_prio_highest;
struct hlist_node hentry;
struct list_head monitor_entry;
struct list_head names_list;
struct list_head names_queue_list;
struct list_head reply_list;
atomic_t reply_count;
size_t names;
struct work_struct work;
struct timer_list timer;
struct kdbus_match_db *match_db;
struct kdbus_meta *meta;
struct kdbus_meta *owner_meta;
unsigned int msg_count;
struct kdbus_pool *pool;
struct kdbus_ns_user *user;
void *security;
};
struct kdbus_kmsg;
struct kdbus_conn_queue;
struct kdbus_name_registry;
int kdbus_conn_new(struct kdbus_ep *ep,
struct kdbus_cmd_hello *hello,
struct kdbus_meta *meta,
struct kdbus_conn **conn);
struct kdbus_conn *kdbus_conn_ref(struct kdbus_conn *conn);
struct kdbus_conn *kdbus_conn_unref(struct kdbus_conn *conn);
int kdbus_conn_disconnect(struct kdbus_conn *conn, bool ensure_msg_list_empty);
bool kdbus_conn_active(struct kdbus_conn *conn);
int kdbus_conn_recv_msg_user(struct kdbus_conn *conn,
struct kdbus_cmd_recv __user *recv);
int kdbus_cmd_conn_info(struct kdbus_conn *conn,
void __user *buf);
int kdbus_conn_kmsg_send(struct kdbus_ep *ep,
struct kdbus_conn *conn_src,
struct kdbus_kmsg *kmsg);
void kdbus_conn_kmsg_list_free(struct list_head *kmsg_list);
int kdbus_conn_kmsg_list_send(struct kdbus_ep *ep,
struct list_head *kmsg_list);
int kdbus_conn_move_messages(struct kdbus_conn *conn_dst,
struct kdbus_conn *conn_src,
u64 name_id);
bool kdbus_conn_has_name(struct kdbus_conn *conn, const char *name);
#endif