Rename C++ header files to .hpp
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.hpp
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.hpp>
12 #include <common/credentials.hpp>
13 #include <common/sessiond-comm/sessiond-comm.hpp>
14 #include <lttng/domain.h>
15 #include <lttng/event.h>
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
23 struct lttng_payload;
24 struct lttng_payload_view;
25 struct mi_writer;
26
27 enum 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
34 typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
35 typedef bool (*event_rule_validate_cb)(
36 const struct lttng_event_rule *event_rule);
37 typedef int (*event_rule_serialize_cb)(
38 const struct lttng_event_rule *event_rule,
39 struct lttng_payload *payload);
40 typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
41 const struct lttng_event_rule *b);
42 typedef ssize_t (*event_rule_create_from_payload_cb)(
43 struct lttng_payload_view *view,
44 struct lttng_event_rule **event_rule);
45 typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
46 struct lttng_event_rule *event_rule,
47 const struct lttng_credentials *creds);
48 typedef const char *(*event_rule_get_filter_cb)(
49 const struct lttng_event_rule *event_rule);
50 typedef const struct lttng_bytecode *(
51 *event_rule_get_filter_bytecode_cb)(
52 const struct lttng_event_rule *event_rule);
53 typedef 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);
57 typedef unsigned long (*event_rule_hash_cb)(
58 const struct lttng_event_rule *event_rule);
59 typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
60 const struct lttng_event_rule *event_rule);
61 typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
62 const struct lttng_event_rule *event_rule,
63 struct mi_writer *writer);
64
65 struct 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;
76 event_rule_hash_cb hash;
77 event_rule_generate_lttng_event_cb generate_lttng_event;
78 event_rule_mi_serialize_cb mi_serialize;
79 };
80
81 struct lttng_event_rule_comm {
82 /* enum lttng_event_rule_type */
83 int8_t event_rule_type;
84 char payload[];
85 };
86
87 void lttng_event_rule_init(struct lttng_event_rule *event_rule,
88 enum lttng_event_rule_type type);
89
90 bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
91
92 ssize_t lttng_event_rule_create_from_payload(
93 struct lttng_payload_view *payload,
94 struct lttng_event_rule **event_rule);
95
96 int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
97 struct lttng_payload *payload);
98
99 bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
100 const struct lttng_event_rule *b);
101
102 bool lttng_event_rule_get(struct lttng_event_rule *rule);
103
104 void lttng_event_rule_put(struct lttng_event_rule *rule);
105
106 enum lttng_domain_type lttng_event_rule_get_domain_type(
107 const struct lttng_event_rule *rule);
108
109 enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
110 struct lttng_event_rule *rule,
111 const struct lttng_credentials *creds);
112
113 /*
114 * If not present/implemented returns NULL.
115 * Caller DOES NOT own the returned object.
116 */
117 const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
118
119 /*
120 * If not present/implemented returns NULL.
121 * Caller DOES NOT own the returned object.
122 */
123 const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
124 const struct lttng_event_rule *rule);
125
126 /*
127 * If not present/implemented return NULL.
128 * Caller OWNS the returned object.
129 */
130 enum lttng_event_rule_generate_exclusions_status
131 lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
132 struct lttng_event_exclusion **exclusions);
133
134 const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
135
136 unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
137
138 /*
139 * This is a compatibility helper allowing us to generate a sessiond-side (not
140 * communication) `struct lttng_event` object from an event rule.
141 *
142 * This effectively bridges older parts of the code using those structures and
143 * new event-rule based code.
144 *
145 * The caller owns the returned object.
146 */
147 struct lttng_event *lttng_event_rule_generate_lttng_event(
148 const struct lttng_event_rule *rule);
149
150 /* Test if an event rule targets an agent domain. */
151 bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
152
153 enum lttng_error_code lttng_event_rule_mi_serialize(
154 const struct lttng_event_rule *rule, struct mi_writer *writer);
155
156 #endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.034149 seconds and 5 git commands to generate.