Fix: list agent event per domain only
[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
21#define _GNU_SOURCE
22#include <inttypes.h>
23
24#include <common/hashtable/hashtable.h>
25#include <lttng/lttng.h>
26
27/*
28 * Hash table that contains the agent app created upon registration indexed by
29 * socket.
30 */
31struct lttng_ht *agent_apps_ht_by_sock;
32
33struct agent_ht_key {
34 const char *name;
35 int loglevel;
36};
37
38/*
39 * Registration message payload from an agent application. The PID is used to
40 * find back the corresponding UST app object so both socket can be linked.
41 */
42struct agent_register_msg {
fefd409b
DG
43 /* This maps to a lttng_domain_type. */
44 uint32_t domain;
022d91ba
DG
45 uint32_t pid;
46};
47
48/*
49 * Agent application object created after a successful registration. This
50 * object is linked to its associated UST app by their PID through hash table
51 * lookups.
52 */
53struct agent_app {
54 /*
55 * PID sent during registration of a AGENT application.
56 */
57 pid_t pid;
58
fefd409b
DG
59 /* Domain of the application. */
60 enum lttng_domain_type domain;
61
022d91ba
DG
62 /*
63 * AGENT TCP socket that was created upon registration.
64 */
65 struct lttcomm_sock *sock;
66
67 /* Initialized with the AGENT sock value. */
68 struct lttng_ht_node_ulong node;
69};
70
71/*
72 * Agent event representation.
73 */
74struct agent_event {
75 /* Name of the event. */
76 char name[LTTNG_SYMBOL_NAME_LEN];
77 int loglevel;
78 enum lttng_loglevel_type loglevel_type;
79
80 /*
81 * Tells if the event is enabled or not on the agent.
82 */
83 unsigned int enabled:1;
84
85 /* Hash table node of the agent domain object. */
86 struct lttng_ht_node_str node;
87
88 /* Bytecode filter associated with the event . NULL if none. */
89 struct lttng_filter_bytecode *filter;
90};
91
92/*
93 * Agent object containing events enabled/disabled for it.
94 */
95struct agent {
96 /*
97 * This indicates if that domain is being used meaning if at least one
98 * event has been at some point in time added to it. This is used so when
99 * listing domains for a session, we can tell or not if the agent is
100 * actually enabled.
101 */
102 unsigned int being_used:1;
fefd409b
DG
103
104 /* What domain this agent is. */
105 enum lttng_domain_type domain;
106
022d91ba
DG
107 /* Contains event indexed by name. */
108 struct lttng_ht *events;
fefd409b
DG
109
110 /* Node used for the hash table indexed by domain type. */
111 struct lttng_ht_node_u64 node;
022d91ba
DG
112};
113
114/* Setup agent subsystem. */
115int agent_setup(void);
116
117/* Initialize an already allocated agent domain. */
118int agent_init(struct agent *agt);
fefd409b 119struct agent *agent_create(enum lttng_domain_type domain);
022d91ba 120void agent_destroy(struct agent *agt);
fefd409b 121void agent_add(struct agent *agt, struct lttng_ht *ht);
022d91ba
DG
122
123/* Agent event API. */
124struct agent_event *agent_create_event(const char *name,
125 struct lttng_filter_bytecode *filter);
126void agent_add_event(struct agent_event *event, struct agent *agt);
127
128struct agent_event *agent_find_event(const char *name, int loglevel,
129 struct agent *agt);
130struct agent_event *agent_find_event_by_name(const char *name,
131 struct agent *agt);
132void agent_delete_event(struct agent_event *event, struct agent *agt);
133void agent_destroy_event(struct agent_event *event);
134
135/* Agent app API. */
fefd409b
DG
136struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
137 struct lttcomm_sock *sock);
022d91ba
DG
138void agent_add_app(struct agent_app *app);
139void agent_delete_app(struct agent_app *app);
140struct agent_app *agent_find_app_by_sock(int sock);
141void agent_destroy_app(struct agent_app *app);
142int agent_send_registration_done(struct agent_app *app);
143
144/* Agent action API */
fefd409b
DG
145int agent_enable_event(struct agent_event *event,
146 enum lttng_domain_type domain);
147int agent_disable_event(struct agent_event *event,
148 enum lttng_domain_type domain);
022d91ba 149void agent_update(struct agent *agt, int sock);
f60140a1
DG
150int agent_list_events(struct lttng_event **events,
151 enum lttng_domain_type domain);
022d91ba
DG
152
153#endif /* LTTNG_SESSIOND_AGENT_H */
This page took 0.034325 seconds and 4 git commands to generate.