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
,
37 struct notification_thread_command
{
38 struct cds_list_head cmd_list_node
;
40 enum notification_thread_command_type type
;
42 /* Register/Unregister trigger. */
43 struct lttng_trigger
*trigger
;
53 enum lttng_domain_type domain
;
61 enum lttng_domain_type domain
;
64 const char *session_name
;
67 uint64_t trace_archive_chunk_id
;
68 struct lttng_trace_archive_location
*location
;
70 /* Add/Remove application */
72 int read_side_trigger_event_application_pipe
;
85 struct lttng_triggers
*triggers
;
88 struct lttng_triggers
*triggers
;
92 /* lttng_waiter on which to wait for command reply (optional). */
93 struct lttng_waiter reply_waiter
;
94 enum lttng_error_code reply_code
;
98 enum lttng_error_code
notification_thread_command_register_trigger(
99 struct notification_thread_handle
*handle
,
100 struct lttng_trigger
*trigger
);
102 enum lttng_error_code
notification_thread_command_unregister_trigger(
103 struct notification_thread_handle
*handle
,
104 struct lttng_trigger
*trigger
);
106 enum lttng_error_code
notification_thread_command_add_channel(
107 struct notification_thread_handle
*handle
,
108 char *session_name
, uid_t session_uid
, gid_t session_gid
,
109 char *channel_name
, uint64_t key
,
110 enum lttng_domain_type domain
, uint64_t capacity
);
112 enum lttng_error_code
notification_thread_command_remove_channel(
113 struct notification_thread_handle
*handle
,
114 uint64_t key
, enum lttng_domain_type domain
);
116 enum lttng_error_code
notification_thread_command_session_rotation_ongoing(
117 struct notification_thread_handle
*handle
,
118 const char *session_name
, uid_t session_uid
, gid_t session_gid
,
119 uint64_t trace_archive_chunk_id
);
121 /* Ownership of location is transferred. */
122 enum lttng_error_code
notification_thread_command_session_rotation_completed(
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
,
126 struct lttng_trace_archive_location
*location
);
128 enum lttng_error_code
notification_thread_command_add_application(
129 struct notification_thread_handle
*handle
,
130 struct lttng_pipe
*trigger_event_application_pipe
);
132 enum lttng_error_code
notification_thread_command_remove_application(
133 struct notification_thread_handle
*handle
,
134 struct lttng_pipe
*trigger_event_application_pipe
);
136 /* Must hold the notification_trigger_tokens_ht_lock to protect against
137 * insertion removal of triggers TODO: is it the case even with refcounting? */
138 /* todo find a better way....*/
139 enum lttng_error_code
notification_thread_command_get_tokens(
140 struct notification_thread_handle
*handle
,
141 struct lttng_triggers
**triggers
);
143 /* TODO: for now we borrow with no refcount the trigger. THIS IS DANGEROUS */
144 enum lttng_error_code
notification_thread_command_list_triggers(
145 struct notification_thread_handle
*handle
,
148 struct lttng_triggers
**triggers
);
150 void notification_thread_command_quit(
151 struct notification_thread_handle
*handle
);
153 #endif /* NOTIFICATION_THREAD_COMMANDS_H */