lttng-enable-event.1.txt: fix SDT acronym, add missing "are supported"
[lttng-tools.git] / src / bin / lttng-sessiond / agent.h
CommitLineData
022d91ba
DG
1/*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
bdf64013 3 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
022d91ba
DG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef LTTNG_SESSIOND_AGENT_H
20#define LTTNG_SESSIOND_AGENT_H
21
022d91ba
DG
22#include <inttypes.h>
23
24#include <common/hashtable/hashtable.h>
25#include <lttng/lttng.h>
26
9474416f 27/* Agent protocol version that is verified during the agent registration. */
a0ba721c 28#define AGENT_MAJOR_VERSION 2
9474416f
DG
29#define AGENT_MINOR_VERSION 0
30
022d91ba
DG
31/*
32 * Hash table that contains the agent app created upon registration indexed by
7c1d2758 33 * socket. Global to the session daemon.
022d91ba 34 */
7c1d2758 35extern struct lttng_ht *agent_apps_ht_by_sock;
022d91ba
DG
36
37struct agent_ht_key {
38 const char *name;
2106efa0 39 int loglevel_value;
a9319624 40 enum lttng_loglevel_type loglevel_type;
6b10b3b0 41 char *filter_expression;
022d91ba
DG
42};
43
44/*
45 * Registration message payload from an agent application. The PID is used to
46 * find back the corresponding UST app object so both socket can be linked.
47 */
48struct agent_register_msg {
fefd409b
DG
49 /* This maps to a lttng_domain_type. */
50 uint32_t domain;
022d91ba 51 uint32_t pid;
9474416f
DG
52 uint32_t major_version;
53 uint32_t minor_version;
022d91ba
DG
54};
55
56/*
57 * Agent application object created after a successful registration. This
58 * object is linked to its associated UST app by their PID through hash table
59 * lookups.
60 */
61struct agent_app {
62 /*
d53e2992 63 * PID sent during registration of an agent application.
022d91ba
DG
64 */
65 pid_t pid;
66
fefd409b
DG
67 /* Domain of the application. */
68 enum lttng_domain_type domain;
69
022d91ba
DG
70 /*
71 * AGENT TCP socket that was created upon registration.
72 */
73 struct lttcomm_sock *sock;
74
75 /* Initialized with the AGENT sock value. */
76 struct lttng_ht_node_ulong node;
77};
78
79/*
80 * Agent event representation.
81 */
82struct agent_event {
83 /* Name of the event. */
84 char name[LTTNG_SYMBOL_NAME_LEN];
2106efa0 85 int loglevel_value;
022d91ba
DG
86 enum lttng_loglevel_type loglevel_type;
87
88 /*
89 * Tells if the event is enabled or not on the agent.
90 */
91 unsigned int enabled:1;
92
93 /* Hash table node of the agent domain object. */
94 struct lttng_ht_node_str node;
95
51755dc8 96 /* Filter associated with the event. NULL if none. */
022d91ba 97 struct lttng_filter_bytecode *filter;
51755dc8
JG
98 char *filter_expression;
99 struct lttng_event_exclusion *exclusion;
022d91ba
DG
100};
101
102/*
103 * Agent object containing events enabled/disabled for it.
104 */
105struct agent {
106 /*
107 * This indicates if that domain is being used meaning if at least one
108 * event has been at some point in time added to it. This is used so when
109 * listing domains for a session, we can tell or not if the agent is
110 * actually enabled.
111 */
112 unsigned int being_used:1;
fefd409b
DG
113
114 /* What domain this agent is. */
115 enum lttng_domain_type domain;
116
022d91ba
DG
117 /* Contains event indexed by name. */
118 struct lttng_ht *events;
fefd409b 119
bdf64013
JG
120 /* Application context list (struct agent_app_ctx). */
121 struct cds_list_head app_ctx_list;
122
fefd409b
DG
123 /* Node used for the hash table indexed by domain type. */
124 struct lttng_ht_node_u64 node;
022d91ba
DG
125};
126
6a4e4039
JG
127/* Allocate agent apps hash table */
128int agent_app_ht_alloc(void);
129/* Clean-up agent apps hash table */
130void agent_app_ht_clean(void);
022d91ba
DG
131
132/* Initialize an already allocated agent domain. */
133int agent_init(struct agent *agt);
fefd409b 134struct agent *agent_create(enum lttng_domain_type domain);
022d91ba 135void agent_destroy(struct agent *agt);
fefd409b 136void agent_add(struct agent *agt, struct lttng_ht *ht);
022d91ba
DG
137
138/* Agent event API. */
a9319624
PP
139struct agent_event *agent_create_event(const char *name,
140 enum lttng_loglevel_type loglevel_type, int loglevel_value,
51755dc8
JG
141 struct lttng_filter_bytecode *filter,
142 char *filter_expression);
022d91ba
DG
143void agent_add_event(struct agent_event *event, struct agent *agt);
144
a9319624
PP
145struct agent_event *agent_find_event(const char *name,
146 enum lttng_loglevel_type loglevel_type, int loglevel_value,
6b10b3b0 147 char *filter_expression, struct agent *agt);
e261a6cc
PP
148void agent_find_events_by_name(const char *name, struct agent *agt,
149 struct lttng_ht_iter* iter);
150void agent_event_next_duplicate(const char *name,
151 struct agent *agt, struct lttng_ht_iter* iter);
022d91ba
DG
152void agent_delete_event(struct agent_event *event, struct agent *agt);
153void agent_destroy_event(struct agent_event *event);
154
bdf64013
JG
155/* Agent context API.*/
156int agent_enable_context(struct lttng_event_context *ctx,
157 enum lttng_domain_type domain);
158int agent_add_context(struct lttng_event_context *ctx, struct agent *agt);
159
022d91ba 160/* Agent app API. */
fefd409b
DG
161struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
162 struct lttcomm_sock *sock);
022d91ba
DG
163void agent_add_app(struct agent_app *app);
164void agent_delete_app(struct agent_app *app);
165struct agent_app *agent_find_app_by_sock(int sock);
166void agent_destroy_app(struct agent_app *app);
6a4e4039 167void agent_destroy_app_by_sock(int sock);
022d91ba
DG
168int agent_send_registration_done(struct agent_app *app);
169
170/* Agent action API */
fefd409b
DG
171int agent_enable_event(struct agent_event *event,
172 enum lttng_domain_type domain);
173int agent_disable_event(struct agent_event *event,
174 enum lttng_domain_type domain);
022d91ba 175void agent_update(struct agent *agt, int sock);
f60140a1
DG
176int agent_list_events(struct lttng_event **events,
177 enum lttng_domain_type domain);
022d91ba
DG
178
179#endif /* LTTNG_SESSIOND_AGENT_H */
This page took 0.043904 seconds and 4 git commands to generate.