MI: implement all objects related to trigger machine interface
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.h
CommitLineData
7a3dcaf6
JR
1/*
2 * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8#ifndef LTTNG_EVENT_RULE_INTERNAL_H
9#define LTTNG_EVENT_RULE_INTERNAL_H
10
11#include <common/macros.h>
58daac01 12#include <common/credentials.h>
993578ff 13#include <common/sessiond-comm/sessiond-comm.h>
7a3dcaf6 14#include <lttng/domain.h>
44760c20 15#include <lttng/event.h>
7a3dcaf6
JR
16#include <lttng/event-rule/event-rule.h>
17#include <lttng/lttng-error.h>
18#include <stdbool.h>
19#include <stdint.h>
20#include <sys/types.h>
21#include <urcu/ref.h>
22
23struct lttng_payload;
24struct lttng_payload_view;
6a751b95 25struct mi_writer;
7a3dcaf6 26
993578ff
JR
27enum lttng_event_rule_generate_exclusions_status {
28 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
29 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
30 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
31 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
32};
33
7a3dcaf6
JR
34typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
35typedef bool (*event_rule_validate_cb)(
36 const struct lttng_event_rule *event_rule);
37typedef int (*event_rule_serialize_cb)(
38 const struct lttng_event_rule *event_rule,
39 struct lttng_payload *payload);
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_payload_cb)(
43 struct lttng_payload_view *view,
44 struct lttng_event_rule **event_rule);
45typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
58daac01
JR
46 struct lttng_event_rule *event_rule,
47 const struct lttng_credentials *creds);
7a3dcaf6
JR
48typedef const char *(*event_rule_get_filter_cb)(
49 const struct lttng_event_rule *event_rule);
2b00d462 50typedef const struct lttng_bytecode *(
7a3dcaf6
JR
51 *event_rule_get_filter_bytecode_cb)(
52 const struct lttng_event_rule *event_rule);
993578ff
JR
53typedef enum lttng_event_rule_generate_exclusions_status (
54 *event_rule_generate_exclusions_cb)(
55 const struct lttng_event_rule *event_rule,
56 struct lttng_event_exclusion **exclusions);
959e3c66
JR
57typedef unsigned long (*event_rule_hash_cb)(
58 const struct lttng_event_rule *event_rule);
44760c20
JR
59typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
60 const struct lttng_event_rule *event_rule);
6a751b95
JR
61typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
62 const struct lttng_event_rule *event_rule,
63 struct mi_writer *writer);
7a3dcaf6
JR
64
65struct lttng_event_rule {
66 struct urcu_ref ref;
67 enum lttng_event_rule_type type;
68 event_rule_validate_cb validate;
69 event_rule_serialize_cb serialize;
70 event_rule_equal_cb equal;
71 event_rule_destroy_cb destroy;
72 event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
73 event_rule_get_filter_cb get_filter;
74 event_rule_get_filter_bytecode_cb get_filter_bytecode;
75 event_rule_generate_exclusions_cb generate_exclusions;
959e3c66 76 event_rule_hash_cb hash;
44760c20 77 event_rule_generate_lttng_event_cb generate_lttng_event;
6a751b95 78 event_rule_mi_serialize_cb mi_serialize;
7a3dcaf6
JR
79};
80
81struct lttng_event_rule_comm {
82 /* enum lttng_event_rule_type */
83 int8_t event_rule_type;
84 char payload[];
85};
86
87LTTNG_HIDDEN
88void lttng_event_rule_init(struct lttng_event_rule *event_rule,
89 enum lttng_event_rule_type type);
90
91LTTNG_HIDDEN
92bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
93
94LTTNG_HIDDEN
95ssize_t lttng_event_rule_create_from_payload(
96 struct lttng_payload_view *payload,
97 struct lttng_event_rule **event_rule);
98
99LTTNG_HIDDEN
100int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
101 struct lttng_payload *payload);
102
103LTTNG_HIDDEN
104bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
105 const struct lttng_event_rule *b);
106
107LTTNG_HIDDEN
108bool lttng_event_rule_get(struct lttng_event_rule *rule);
109
110LTTNG_HIDDEN
111void lttng_event_rule_put(struct lttng_event_rule *rule);
112
113LTTNG_HIDDEN
114enum lttng_domain_type lttng_event_rule_get_domain_type(
115 const struct lttng_event_rule *rule);
116
117LTTNG_HIDDEN
118enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
58daac01
JR
119 struct lttng_event_rule *rule,
120 const struct lttng_credentials *creds);
7a3dcaf6
JR
121
122/*
123 * If not present/implemented returns NULL.
124 * Caller DOES NOT own the returned object.
125 */
126LTTNG_HIDDEN
127const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
128
129/*
130 * If not present/implemented returns NULL.
131 * Caller DOES NOT own the returned object.
132 */
133LTTNG_HIDDEN
2b00d462 134const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
7a3dcaf6
JR
135 const struct lttng_event_rule *rule);
136
137/*
138 * If not present/implemented return NULL.
139 * Caller OWNS the returned object.
140 */
141LTTNG_HIDDEN
993578ff
JR
142enum lttng_event_rule_generate_exclusions_status
143lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
144 struct lttng_event_exclusion **exclusions);
7a3dcaf6
JR
145
146LTTNG_HIDDEN
147const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
148
959e3c66
JR
149LTTNG_HIDDEN
150unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
151
44760c20
JR
152/*
153 * This is a compatibility helper allowing us to generate a sessiond-side (not
154 * communication) `struct lttng_event` object from an event rule.
155 *
156 * This effectively bridges older parts of the code using those structures and
157 * new event-rule based code.
158 *
159 * The caller owns the returned object.
160 */
161LTTNG_HIDDEN
162struct lttng_event *lttng_event_rule_generate_lttng_event(
163 const struct lttng_event_rule *rule);
164
165/* Test if an event rule targets an agent domain. */
166LTTNG_HIDDEN
167bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
168
6a751b95
JR
169LTTNG_HIDDEN
170enum lttng_error_code lttng_event_rule_mi_serialize(
171 const struct lttng_event_rule *rule, struct mi_writer *writer);
172
7a3dcaf6 173#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.031591 seconds and 4 git commands to generate.