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