Refactor JUL to agent namespace
[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 {
43 uint32_t pid;
44};
45
46/*
47 * Agent application object created after a successful registration. This
48 * object is linked to its associated UST app by their PID through hash table
49 * lookups.
50 */
51struct agent_app {
52 /*
53 * PID sent during registration of a AGENT application.
54 */
55 pid_t pid;
56
57 /*
58 * AGENT TCP socket that was created upon registration.
59 */
60 struct lttcomm_sock *sock;
61
62 /* Initialized with the AGENT sock value. */
63 struct lttng_ht_node_ulong node;
64};
65
66/*
67 * Agent event representation.
68 */
69struct agent_event {
70 /* Name of the event. */
71 char name[LTTNG_SYMBOL_NAME_LEN];
72 int loglevel;
73 enum lttng_loglevel_type loglevel_type;
74
75 /*
76 * Tells if the event is enabled or not on the agent.
77 */
78 unsigned int enabled:1;
79
80 /* Hash table node of the agent domain object. */
81 struct lttng_ht_node_str node;
82
83 /* Bytecode filter associated with the event . NULL if none. */
84 struct lttng_filter_bytecode *filter;
85};
86
87/*
88 * Agent object containing events enabled/disabled for it.
89 */
90struct agent {
91 /*
92 * This indicates if that domain is being used meaning if at least one
93 * event has been at some point in time added to it. This is used so when
94 * listing domains for a session, we can tell or not if the agent is
95 * actually enabled.
96 */
97 unsigned int being_used:1;
98 /* Contains event indexed by name. */
99 struct lttng_ht *events;
100};
101
102/* Setup agent subsystem. */
103int agent_setup(void);
104
105/* Initialize an already allocated agent domain. */
106int agent_init(struct agent *agt);
107void agent_destroy(struct agent *agt);
108
109/* Agent event API. */
110struct agent_event *agent_create_event(const char *name,
111 struct lttng_filter_bytecode *filter);
112void agent_add_event(struct agent_event *event, struct agent *agt);
113
114struct agent_event *agent_find_event(const char *name, int loglevel,
115 struct agent *agt);
116struct agent_event *agent_find_event_by_name(const char *name,
117 struct agent *agt);
118void agent_delete_event(struct agent_event *event, struct agent *agt);
119void agent_destroy_event(struct agent_event *event);
120
121/* Agent app API. */
122struct agent_app *agent_create_app(pid_t pid, struct lttcomm_sock *sock);
123void agent_add_app(struct agent_app *app);
124void agent_delete_app(struct agent_app *app);
125struct agent_app *agent_find_app_by_sock(int sock);
126void agent_destroy_app(struct agent_app *app);
127int agent_send_registration_done(struct agent_app *app);
128
129/* Agent action API */
130int agent_enable_event(struct agent_event *event);
131int agent_disable_event(struct agent_event *event);
132void agent_update(struct agent *agt, int sock);
133int agent_list_events(struct lttng_event **events);
134
135#endif /* LTTNG_SESSIOND_AGENT_H */
This page took 0.027924 seconds and 4 git commands to generate.