trigger: implement listing of registered trigger
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-commands.h
CommitLineData
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
20struct notification_thread_data;
21struct lttng_trigger;
22
23enum 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,
fbc9f37d 30 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
ab0ee2ca 31 NOTIFICATION_COMMAND_TYPE_QUIT,
f2b3ef9f 32 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
ab0ee2ca
JG
33};
34
ab0ee2ca
JG
35struct notification_thread_command {
36 struct cds_list_head cmd_list_node;
37
38 enum notification_thread_command_type type;
39 union {
40 /* Register/Unregister trigger. */
41 struct lttng_trigger *trigger;
42 /* Add channel. */
8abe313a
JG
43 struct {
44 struct {
45 const char *name;
46 uid_t uid;
47 gid_t gid;
48 } session;
49 struct {
50 const char *name;
51 enum lttng_domain_type domain;
52 uint64_t key;
53 uint64_t capacity;
54 } channel;
55 } add_channel;
ab0ee2ca
JG
56 /* Remove channel. */
57 struct {
58 uint64_t key;
59 enum lttng_domain_type domain;
60 } remove_channel;
731c1b12
JG
61 struct {
62 const char *session_name;
63 uid_t uid;
64 gid_t gid;
65 uint64_t trace_archive_chunk_id;
66 struct lttng_trace_archive_location *location;
67 } session_rotation;
fbc9f37d
JR
68 /* List triggers. */
69 struct {
70 /* Credentials of the requesting user. */
71 uid_t uid;
72 } list_triggers;
f2b3ef9f
JG
73 /* Client communication update. */
74 struct {
75 notification_client_id id;
76 enum client_transmission_status status;
77 } client_communication_update;
78
ab0ee2ca
JG
79 } parameters;
80
fbc9f37d
JR
81 union {
82 struct {
83 struct lttng_triggers *triggers;
84 } list_triggers;
85 } reply;
8ada111f
JG
86 /* lttng_waiter on which to wait for command reply (optional). */
87 struct lttng_waiter reply_waiter;
ab0ee2ca 88 enum lttng_error_code reply_code;
0ab399e0 89 bool is_async;
ab0ee2ca
JG
90};
91
92enum lttng_error_code notification_thread_command_register_trigger(
93 struct notification_thread_handle *handle,
94 struct lttng_trigger *trigger);
95
96enum lttng_error_code notification_thread_command_unregister_trigger(
97 struct notification_thread_handle *handle,
98 struct lttng_trigger *trigger);
99
100enum lttng_error_code notification_thread_command_add_channel(
101 struct notification_thread_handle *handle,
731c1b12 102 char *session_name, uid_t session_uid, gid_t session_gid,
ab0ee2ca
JG
103 char *channel_name, uint64_t key,
104 enum lttng_domain_type domain, uint64_t capacity);
105
106enum lttng_error_code notification_thread_command_remove_channel(
107 struct notification_thread_handle *handle,
108 uint64_t key, enum lttng_domain_type domain);
109
731c1b12
JG
110enum 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);
114
115/* Ownership of location is transferred. */
116enum 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);
121
fbc9f37d
JR
122/*
123 * Return the set of triggers visible to a given client.
124 *
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.
129 *
130 * Moreover, the lifetime of the trigger instances is protected through
131 * reference counting (references are held by the trigger set).
132 *
133 * The caller has the exclusive ownership of the returned trigger set.
134 */
135enum lttng_error_code notification_thread_command_list_triggers(
136 struct notification_thread_handle *handle,
137 uid_t client_uid,
138 struct lttng_triggers **triggers);
139
ab0ee2ca
JG
140void notification_thread_command_quit(
141 struct notification_thread_handle *handle);
142
143#endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.060247 seconds and 4 git commands to generate.