Commit | Line | Data |
---|---|---|
ab0ee2ca | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
ab0ee2ca | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: GPL-2.0-only |
ab0ee2ca | 5 | * |
ab0ee2ca JG |
6 | */ |
7 | ||
8 | #ifndef NOTIFICATION_THREAD_COMMANDS_H | |
9 | #define NOTIFICATION_THREAD_COMMANDS_H | |
10 | ||
c9e313bc | 11 | #include "notification-thread-events.hpp" |
28f23191 JG |
12 | #include "notification-thread-internal.hpp" |
13 | #include "notification-thread.hpp" | |
14 | ||
c9e313bc | 15 | #include <common/waiter.hpp> |
28f23191 JG |
16 | |
17 | #include <lttng/domain.h> | |
18 | #include <lttng/lttng-error.h> | |
19 | ||
0ab399e0 | 20 | #include <stdbool.h> |
28f23191 | 21 | #include <urcu/rculfhash.h> |
ab0ee2ca JG |
22 | |
23 | struct notification_thread_data; | |
24 | struct lttng_trigger; | |
25 | ||
26 | enum notification_thread_command_type { | |
27 | NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER, | |
28 | NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER, | |
29 | NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL, | |
30 | NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL, | |
139a8d25 JG |
31 | NOTIFICATION_COMMAND_TYPE_ADD_SESSION, |
32 | NOTIFICATION_COMMAND_TYPE_REMOVE_SESSION, | |
731c1b12 JG |
33 | NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING, |
34 | NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED, | |
d02d7404 JR |
35 | NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE, |
36 | NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE, | |
fbc9f37d | 37 | NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS, |
ab0ee2ca | 38 | NOTIFICATION_COMMAND_TYPE_QUIT, |
f2b3ef9f | 39 | NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE, |
8790759c | 40 | NOTIFICATION_COMMAND_TYPE_GET_TRIGGER, |
ab0ee2ca JG |
41 | }; |
42 | ||
ab0ee2ca JG |
43 | struct notification_thread_command { |
44 | struct cds_list_head cmd_list_node; | |
45 | ||
46 | enum notification_thread_command_type type; | |
47 | union { | |
ac16173e JG |
48 | /* Register trigger. */ |
49 | struct { | |
50 | struct lttng_trigger *trigger; | |
0efb2ad7 | 51 | bool is_trigger_anonymous; |
ac16173e JG |
52 | } register_trigger; |
53 | /* Unregister trigger. */ | |
54 | struct { | |
55 | const struct lttng_trigger *trigger; | |
56 | } unregister_trigger; | |
139a8d25 JG |
57 | /* Add session. */ |
58 | struct { | |
59 | uint64_t session_id; | |
60 | const char *session_name; | |
61 | uid_t session_uid; | |
62 | gid_t session_gid; | |
63 | } add_session; | |
64 | /* Remove session. */ | |
65 | struct { | |
66 | uint64_t session_id; | |
67 | } remove_session; | |
ab0ee2ca | 68 | /* Add channel. */ |
8abe313a JG |
69 | struct { |
70 | struct { | |
139a8d25 | 71 | uint64_t id; |
8abe313a JG |
72 | } session; |
73 | struct { | |
74 | const char *name; | |
75 | enum lttng_domain_type domain; | |
76 | uint64_t key; | |
77 | uint64_t capacity; | |
78 | } channel; | |
79 | } add_channel; | |
ab0ee2ca JG |
80 | /* Remove channel. */ |
81 | struct { | |
82 | uint64_t key; | |
83 | enum lttng_domain_type domain; | |
84 | } remove_channel; | |
731c1b12 | 85 | struct { |
139a8d25 | 86 | uint64_t session_id; |
731c1b12 | 87 | uint64_t trace_archive_chunk_id; |
d3740619 | 88 | /* Weak reference. */ |
731c1b12 JG |
89 | struct lttng_trace_archive_location *location; |
90 | } session_rotation; | |
d02d7404 JR |
91 | /* Add/Remove tracer event source fd. */ |
92 | struct { | |
93 | int tracer_event_source_fd; | |
94 | enum lttng_domain_type domain; | |
95 | } tracer_event_source; | |
fbc9f37d JR |
96 | /* List triggers. */ |
97 | struct { | |
98 | /* Credentials of the requesting user. */ | |
99 | uid_t uid; | |
100 | } list_triggers; | |
f2b3ef9f JG |
101 | /* Client communication update. */ |
102 | struct { | |
103 | notification_client_id id; | |
104 | enum client_transmission_status status; | |
105 | } client_communication_update; | |
106 | ||
8790759c FD |
107 | struct { |
108 | const struct lttng_trigger *trigger; | |
109 | } get_trigger; | |
110 | ||
ab0ee2ca JG |
111 | } parameters; |
112 | ||
fbc9f37d JR |
113 | union { |
114 | struct { | |
115 | struct lttng_triggers *triggers; | |
116 | } list_triggers; | |
8790759c FD |
117 | struct { |
118 | struct lttng_trigger *trigger; | |
119 | } get_trigger; | |
fbc9f37d | 120 | } reply; |
8ada111f JG |
121 | /* lttng_waiter on which to wait for command reply (optional). */ |
122 | struct lttng_waiter reply_waiter; | |
ab0ee2ca | 123 | enum lttng_error_code reply_code; |
0ab399e0 | 124 | bool is_async; |
ab0ee2ca JG |
125 | }; |
126 | ||
28f23191 JG |
127 | enum lttng_error_code |
128 | notification_thread_command_register_trigger(struct notification_thread_handle *handle, | |
129 | struct lttng_trigger *trigger, | |
130 | bool is_anonymous_trigger); | |
131 | ||
132 | enum lttng_error_code | |
133 | notification_thread_command_unregister_trigger(struct notification_thread_handle *handle, | |
134 | const struct lttng_trigger *trigger); | |
135 | ||
136 | enum lttng_error_code | |
137 | notification_thread_command_add_session(struct notification_thread_handle *handle, | |
138 | uint64_t session_id, | |
139 | const char *session_name, | |
140 | uid_t session_uid, | |
141 | gid_t session_gid); | |
142 | ||
143 | enum lttng_error_code | |
144 | notification_thread_command_remove_session(struct notification_thread_handle *handle, | |
145 | uint64_t session_id); | |
146 | ||
147 | enum lttng_error_code | |
148 | notification_thread_command_add_channel(struct notification_thread_handle *handle, | |
149 | uint64_t session_id, | |
150 | char *channel_name, | |
151 | uint64_t key, | |
152 | enum lttng_domain_type domain, | |
153 | uint64_t capacity); | |
ab0ee2ca JG |
154 | |
155 | enum lttng_error_code notification_thread_command_remove_channel( | |
28f23191 | 156 | struct notification_thread_handle *handle, uint64_t key, enum lttng_domain_type domain); |
ab0ee2ca | 157 | |
28f23191 JG |
158 | enum lttng_error_code |
159 | notification_thread_command_session_rotation_ongoing(struct notification_thread_handle *handle, | |
160 | uint64_t session_id, | |
161 | uint64_t trace_archive_chunk_id); | |
731c1b12 JG |
162 | |
163 | /* Ownership of location is transferred. */ | |
164 | enum lttng_error_code notification_thread_command_session_rotation_completed( | |
28f23191 JG |
165 | struct notification_thread_handle *handle, |
166 | uint64_t session_id, | |
167 | uint64_t trace_archive_chunk_id, | |
168 | struct lttng_trace_archive_location *location); | |
731c1b12 | 169 | |
fbc9f37d JR |
170 | /* |
171 | * Return the set of triggers visible to a given client. | |
172 | * | |
173 | * The trigger objects contained in the set are the actual trigger instances | |
174 | * used by the notification subsystem (i.e. not a copy). Given that the command | |
175 | * is only used to serialize the triggers, this is fine: the properties that | |
176 | * are serialized are immutable over the lifetime of the triggers. | |
177 | * | |
178 | * Moreover, the lifetime of the trigger instances is protected through | |
179 | * reference counting (references are held by the trigger set). | |
180 | * | |
181 | * The caller has the exclusive ownership of the returned trigger set. | |
182 | */ | |
28f23191 JG |
183 | enum lttng_error_code |
184 | notification_thread_command_list_triggers(struct notification_thread_handle *handle, | |
185 | uid_t client_uid, | |
186 | struct lttng_triggers **triggers); | |
fbc9f37d | 187 | |
d02d7404 JR |
188 | /* |
189 | * The ownership of trigger_event_application_pipe is _not_ transferred to | |
190 | * the notification thread. | |
191 | */ | |
28f23191 JG |
192 | enum lttng_error_code |
193 | notification_thread_command_add_tracer_event_source(struct notification_thread_handle *handle, | |
194 | int tracer_event_source_fd, | |
195 | enum lttng_domain_type domain); | |
196 | ||
197 | enum lttng_error_code | |
198 | notification_thread_command_remove_tracer_event_source(struct notification_thread_handle *handle, | |
199 | int tracer_event_source_fd); | |
200 | ||
201 | void notification_thread_command_quit(struct notification_thread_handle *handle); | |
202 | ||
203 | enum lttng_error_code | |
204 | notification_thread_command_get_trigger(struct notification_thread_handle *handle, | |
205 | const struct lttng_trigger *trigger, | |
206 | struct lttng_trigger **real_trigger); | |
8790759c | 207 | |
ab0ee2ca | 208 | #endif /* NOTIFICATION_THREAD_COMMANDS_H */ |