SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.h
CommitLineData
1831ae68
FD
1/*
2 * Copyright (C) 2019 - Jonathan Rajotte-Julien
3 * <jonathan.rajotte-julien@efficios.com>
4 *
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, version 2.1 only,
7 * as published by the Free Software Foundation.
8 *
9 * This library 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 Lesser General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef LTTNG_EVENT_RULE_INTERNAL_H
20#define LTTNG_EVENT_RULE_INTERNAL_H
21
22#include <common/buffer-view.h>
23#include <common/dynamic-buffer.h>
24#include <common/macros.h>
25#include <lttng/event.h>
26#include <lttng/event-rule/event-rule.h>
27#include <lttng/lttng-error.h>
28#include <stdbool.h>
29#include <stdint.h>
30#include <sys/types.h>
31#include <urcu/ref.h>
32
33typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
34typedef bool (*event_rule_validate_cb)(
35 const struct lttng_event_rule *event_rule);
36typedef int (*event_rule_serialize_cb)(
37 const struct lttng_event_rule *event_rule,
38 struct lttng_dynamic_buffer *buf,
39 int *fd_to_send);
40typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
41 const struct lttng_event_rule *b);
42typedef ssize_t (*event_rule_create_from_buffer_cb)(
43 const struct lttng_buffer_view *view,
44 struct lttng_event_rule **event_rule);
45typedef enum lttng_error_code (*event_rule_populate_cb)(
46 struct lttng_event_rule *event_rule, uid_t uid, gid_t gid);
47typedef const char *(*event_rule_get_filter_cb)(
48 const struct lttng_event_rule *event_rule);
49typedef const struct lttng_filter_bytecode *(
50 *event_rule_get_filter_bytecode_cb)(
51 const struct lttng_event_rule *event_rule);
52typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)(
53 struct lttng_event_rule *event_rule);
54typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
55 const struct lttng_event_rule *event_rule);
56
57struct lttng_event_rule {
58 struct urcu_ref ref;
59 enum lttng_event_rule_type type;
60 event_rule_validate_cb validate;
61 event_rule_serialize_cb serialize;
62 event_rule_equal_cb equal;
63 event_rule_destroy_cb destroy;
64 event_rule_populate_cb populate;
65 /* Optional */
66 event_rule_get_filter_cb get_filter;
67 event_rule_get_filter_bytecode_cb get_filter_bytecode;
68 event_rule_generate_exclusions_cb generate_exclusions;
69 event_rule_generate_lttng_event_cb generate_lttng_event;
70};
71
72struct lttng_event_rule_comm {
73 /* enum lttng_event_rule_type */
74 int8_t event_rule_type;
75 char payload[];
76};
77
78LTTNG_HIDDEN
79void lttng_event_rule_init(struct lttng_event_rule *event_rule,
80 enum lttng_event_rule_type type);
81
82LTTNG_HIDDEN
83bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
84
85LTTNG_HIDDEN
86ssize_t lttng_event_rule_create_from_buffer(
87 const struct lttng_buffer_view *buffer,
88 struct lttng_event_rule **event_rule);
89
90LTTNG_HIDDEN
91int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
92 struct lttng_dynamic_buffer *buf,
93 int *fd_to_send);
94
95LTTNG_HIDDEN
96bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
97 const struct lttng_event_rule *b);
98
99LTTNG_HIDDEN
100bool lttng_event_rule_get(struct lttng_event_rule *rule);
101
102LTTNG_HIDDEN
103void lttng_event_rule_put(struct lttng_event_rule *rule);
104
105LTTNG_HIDDEN
106enum lttng_domain_type lttng_event_rule_get_domain_type(
107 const struct lttng_event_rule *rule);
108
109LTTNG_HIDDEN
110enum lttng_error_code lttng_event_rule_populate(
111 struct lttng_event_rule *rule, uid_t uid, gid_t gid);
112
113/* If not present return NULL
114 * Caller DO NOT own the returned object
115 */
116LTTNG_HIDDEN
117const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
118
119/* If not present return NULL
120 * Caller DO NOT own the returned object
121 */
122LTTNG_HIDDEN
123const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode(
124 const struct lttng_event_rule *rule);
125
126/*
127 * If not present return NULL
128 * Caller OWN the returned object
129 * TODO: should this be done another way?
130 */
131LTTNG_HIDDEN
132struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
133 struct lttng_event_rule *rule);
134
135/*
136 * This is compatibility helper, allowing us to generate a sessiond side (not
137 * communication) struct lttng_event object. This facilitate integration with
138 * current code.
139 * Caller OWN the returned object
140 */
141LTTNG_HIDDEN
142struct lttng_event *lttng_event_rule_generate_lttng_event(
143 const struct lttng_event_rule *rule);
144
145/* Quick helper to test if the event rule apply to an agent domain */
146LTTNG_HIDDEN
147bool lttng_event_rule_is_agent(const struct lttng_event_rule *rule);
148
149LTTNG_HIDDEN
150const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
151
152#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.029953 seconds and 5 git commands to generate.