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