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