Hide lttng_event_copy symbol
[lttng-tools.git] / src / bin / lttng-sessiond / agent.h
1 /*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
3 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
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
22 #include <inttypes.h>
23
24 #include <common/hashtable/hashtable.h>
25 #include <lttng/lttng.h>
26
27 /* Agent protocol version that is verified during the agent registration. */
28 #define AGENT_MAJOR_VERSION 2
29 #define AGENT_MINOR_VERSION 0
30
31 /*
32 * Hash table that contains the agent app created upon registration indexed by
33 * socket. Global to the session daemon.
34 */
35 extern struct lttng_ht *agent_apps_ht_by_sock;
36
37 struct agent_ht_key {
38 const char *name;
39 int loglevel_value;
40 enum lttng_loglevel_type loglevel_type;
41 char *filter_expression;
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 */
48 struct agent_register_msg {
49 /* This maps to a lttng_domain_type. */
50 uint32_t domain;
51 uint32_t pid;
52 uint32_t major_version;
53 uint32_t minor_version;
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 */
61 struct agent_app {
62 /*
63 * PID sent during registration of an agent application.
64 */
65 pid_t pid;
66
67 /* Domain of the application. */
68 enum lttng_domain_type domain;
69
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 */
82 struct agent_event {
83 /* Name of the event. */
84 char name[LTTNG_SYMBOL_NAME_LEN];
85 int loglevel_value;
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
96 /* Filter associated with the event. NULL if none. */
97 struct lttng_filter_bytecode *filter;
98 char *filter_expression;
99 struct lttng_event_exclusion *exclusion;
100 };
101
102 /*
103 * Agent object containing events enabled/disabled for it.
104 */
105 struct 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;
113
114 /* What domain this agent is. */
115 enum lttng_domain_type domain;
116
117 /* Contains event indexed by name. */
118 struct lttng_ht *events;
119
120 /* Application context list (struct agent_app_ctx). */
121 struct cds_list_head app_ctx_list;
122
123 /* Node used for the hash table indexed by domain type. */
124 struct lttng_ht_node_u64 node;
125 };
126
127 /* Allocate agent apps hash table */
128 int agent_app_ht_alloc(void);
129 /* Clean-up agent apps hash table */
130 void agent_app_ht_clean(void);
131
132 /* Initialize an already allocated agent domain. */
133 int agent_init(struct agent *agt);
134 struct agent *agent_create(enum lttng_domain_type domain);
135 void agent_destroy(struct agent *agt);
136 void agent_add(struct agent *agt, struct lttng_ht *ht);
137
138 /* Agent event API. */
139 struct agent_event *agent_create_event(const char *name,
140 enum lttng_loglevel_type loglevel_type, int loglevel_value,
141 struct lttng_filter_bytecode *filter,
142 char *filter_expression);
143 void agent_add_event(struct agent_event *event, struct agent *agt);
144
145 struct agent_event *agent_find_event(const char *name,
146 enum lttng_loglevel_type loglevel_type, int loglevel_value,
147 char *filter_expression, struct agent *agt);
148 void agent_find_events_by_name(const char *name, struct agent *agt,
149 struct lttng_ht_iter* iter);
150 void agent_event_next_duplicate(const char *name,
151 struct agent *agt, struct lttng_ht_iter* iter);
152 void agent_delete_event(struct agent_event *event, struct agent *agt);
153 void agent_destroy_event(struct agent_event *event);
154
155 /* Agent context API.*/
156 int agent_enable_context(struct lttng_event_context *ctx,
157 enum lttng_domain_type domain);
158 int agent_add_context(struct lttng_event_context *ctx, struct agent *agt);
159
160 /* Agent app API. */
161 struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
162 struct lttcomm_sock *sock);
163 void agent_add_app(struct agent_app *app);
164 void agent_delete_app(struct agent_app *app);
165 struct agent_app *agent_find_app_by_sock(int sock);
166 void agent_destroy_app(struct agent_app *app);
167 void agent_destroy_app_by_sock(int sock);
168 int agent_send_registration_done(struct agent_app *app);
169
170 /* Agent action API */
171 int agent_enable_event(struct agent_event *event,
172 enum lttng_domain_type domain);
173 int agent_disable_event(struct agent_event *event,
174 enum lttng_domain_type domain);
175 void agent_update(struct agent *agt, int sock);
176 int agent_list_events(struct lttng_event **events,
177 enum lttng_domain_type domain);
178
179 #endif /* LTTNG_SESSIOND_AGENT_H */
This page took 0.03485 seconds and 4 git commands to generate.