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_LIST_TRIGGERS
,
31 NOTIFICATION_COMMAND_TYPE_QUIT
,
32 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE
,
35 struct notification_thread_command
{
36 struct cds_list_head cmd_list_node
;
38 enum notification_thread_command_type type
;
40 /* Register/Unregister trigger. */
41 struct lttng_trigger
*trigger
;
51 enum lttng_domain_type domain
;
59 enum lttng_domain_type domain
;
62 const char *session_name
;
65 uint64_t trace_archive_chunk_id
;
66 struct lttng_trace_archive_location
*location
;
70 /* Credentials of the requesting user. */
73 /* Client communication update. */
75 notification_client_id id
;
76 enum client_transmission_status status
;
77 } client_communication_update
;
83 struct lttng_triggers
*triggers
;
86 /* lttng_waiter on which to wait for command reply (optional). */
87 struct lttng_waiter reply_waiter
;
88 enum lttng_error_code reply_code
;
92 enum lttng_error_code
notification_thread_command_register_trigger(
93 struct notification_thread_handle
*handle
,
94 struct lttng_trigger
*trigger
);
96 enum lttng_error_code
notification_thread_command_unregister_trigger(
97 struct notification_thread_handle
*handle
,
98 struct lttng_trigger
*trigger
);
100 enum lttng_error_code
notification_thread_command_add_channel(
101 struct notification_thread_handle
*handle
,
102 char *session_name
, uid_t session_uid
, gid_t session_gid
,
103 char *channel_name
, uint64_t key
,
104 enum lttng_domain_type domain
, uint64_t capacity
);
106 enum lttng_error_code
notification_thread_command_remove_channel(
107 struct notification_thread_handle
*handle
,
108 uint64_t key
, enum lttng_domain_type domain
);
110 enum lttng_error_code
notification_thread_command_session_rotation_ongoing(
111 struct notification_thread_handle
*handle
,
112 const char *session_name
, uid_t session_uid
, gid_t session_gid
,
113 uint64_t trace_archive_chunk_id
);
115 /* Ownership of location is transferred. */
116 enum lttng_error_code
notification_thread_command_session_rotation_completed(
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
,
120 struct lttng_trace_archive_location
*location
);
123 * Return the set of triggers visible to a given client.
125 * The trigger objects contained in the set are the actual trigger instances
126 * used by the notification subsystem (i.e. not a copy). Given that the command
127 * is only used to serialize the triggers, this is fine: the properties that
128 * are serialized are immutable over the lifetime of the triggers.
130 * Moreover, the lifetime of the trigger instances is protected through
131 * reference counting (references are held by the trigger set).
133 * The caller has the exclusive ownership of the returned trigger set.
135 enum lttng_error_code
notification_thread_command_list_triggers(
136 struct notification_thread_handle
*handle
,
138 struct lttng_triggers
**triggers
);
140 void notification_thread_command_quit(
141 struct notification_thread_handle
*handle
);
143 #endif /* NOTIFICATION_THREAD_COMMANDS_H */