2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #ifndef NOTIFICATION_THREAD_COMMANDS_H
9 #define NOTIFICATION_THREAD_COMMANDS_H
11 #include <lttng/domain.h>
12 #include <lttng/lttng-error.h>
13 #include <urcu/rculfhash.h>
14 #include "notification-thread.h"
15 #include "notification-thread-internal.h"
16 #include "notification-thread-events.h"
17 #include <common/waiter.h>
20 struct notification_thread_data
;
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
,
28 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING
,
29 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED
,
30 NOTIFICATION_COMMAND_TYPE_ADD_APPLICATION
,
31 NOTIFICATION_COMMAND_TYPE_REMOVE_APPLICATION
,
32 NOTIFICATION_COMMAND_TYPE_GET_TOKENS
,
33 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS
,
34 NOTIFICATION_COMMAND_TYPE_QUIT
,
35 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE
,
38 struct notification_thread_command
{
39 struct cds_list_head cmd_list_node
;
41 enum notification_thread_command_type type
;
43 /* Register/Unregister trigger. */
44 struct lttng_trigger
*trigger
;
54 enum lttng_domain_type domain
;
62 enum lttng_domain_type domain
;
65 const char *session_name
;
68 uint64_t trace_archive_chunk_id
;
69 struct lttng_trace_archive_location
*location
;
71 /* Add/Remove application */
73 int read_side_trigger_event_application_pipe
;
81 /* Client communication update. */
83 notification_client_id id
;
84 enum client_transmission_status status
;
85 } client_communication_update
;
91 struct lttng_triggers
*triggers
;
94 struct lttng_triggers
*triggers
;
98 /* lttng_waiter on which to wait for command reply (optional). */
99 struct lttng_waiter reply_waiter
;
100 enum lttng_error_code reply_code
;
104 enum lttng_error_code
notification_thread_command_register_trigger(
105 struct notification_thread_handle
*handle
,
106 struct lttng_trigger
*trigger
);
108 enum lttng_error_code
notification_thread_command_unregister_trigger(
109 struct notification_thread_handle
*handle
,
110 struct lttng_trigger
*trigger
);
112 enum lttng_error_code
notification_thread_command_add_channel(
113 struct notification_thread_handle
*handle
,
114 char *session_name
, uid_t session_uid
, gid_t session_gid
,
115 char *channel_name
, uint64_t key
,
116 enum lttng_domain_type domain
, uint64_t capacity
);
118 enum lttng_error_code
notification_thread_command_remove_channel(
119 struct notification_thread_handle
*handle
,
120 uint64_t key
, enum lttng_domain_type domain
);
122 enum lttng_error_code
notification_thread_command_session_rotation_ongoing(
123 struct notification_thread_handle
*handle
,
124 const char *session_name
, uid_t session_uid
, gid_t session_gid
,
125 uint64_t trace_archive_chunk_id
);
127 /* Ownership of location is transferred. */
128 enum lttng_error_code
notification_thread_command_session_rotation_completed(
129 struct notification_thread_handle
*handle
,
130 const char *session_name
, uid_t session_uid
, gid_t session_gid
,
131 uint64_t trace_archive_chunk_id
,
132 struct lttng_trace_archive_location
*location
);
134 enum lttng_error_code
notification_thread_command_add_application(
135 struct notification_thread_handle
*handle
,
136 struct lttng_pipe
*trigger_event_application_pipe
);
138 enum lttng_error_code
notification_thread_command_remove_application(
139 struct notification_thread_handle
*handle
,
140 struct lttng_pipe
*trigger_event_application_pipe
);
142 /* Must hold the notification_trigger_tokens_ht_lock to protect against
143 * insertion removal of triggers TODO: is it the case even with refcounting? */
144 /* todo find a better way....*/
145 enum lttng_error_code
notification_thread_command_get_tokens(
146 struct notification_thread_handle
*handle
,
147 struct lttng_triggers
**triggers
);
149 /* TODO: for now we borrow with no refcount the trigger. THIS IS DANGEROUS */
150 enum lttng_error_code
notification_thread_command_list_triggers(
151 struct notification_thread_handle
*handle
,
154 struct lttng_triggers
**triggers
);
156 void notification_thread_command_quit(
157 struct notification_thread_handle
*handle
);
159 #endif /* NOTIFICATION_THREAD_COMMANDS_H */