SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.h
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>
12 #include <lttng/domain.h>
13 #include <lttng/event.h>
14 #include <lttng/event-rule/event-rule.h>
15 #include <lttng/lttng-error.h>
16 #include <stdbool.h>
17 #include <stdint.h>
18 #include <sys/types.h>
19 #include <urcu/ref.h>
20
21 struct lttng_payload;
22 struct lttng_payload_view;
23
24 typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
25 typedef bool (*event_rule_validate_cb)(
26 const struct lttng_event_rule *event_rule);
27 typedef int (*event_rule_serialize_cb)(
28 const struct lttng_event_rule *event_rule,
29 struct lttng_payload *payload);
30 typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
31 const struct lttng_event_rule *b);
32 typedef ssize_t (*event_rule_create_from_payload_cb)(
33 struct lttng_payload_view *view,
34 struct lttng_event_rule **event_rule);
35 typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
36 struct lttng_event_rule *event_rule, uid_t uid, gid_t gid);
37 typedef const char *(*event_rule_get_filter_cb)(
38 const struct lttng_event_rule *event_rule);
39 typedef const struct lttng_bytecode *(
40 *event_rule_get_filter_bytecode_cb)(
41 const struct lttng_event_rule *event_rule);
42 typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)(
43 const struct lttng_event_rule *event_rule);
44 typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
45 const struct lttng_event_rule *event_rule);
46
47 struct lttng_event_rule {
48 struct urcu_ref ref;
49 enum lttng_event_rule_type type;
50 event_rule_validate_cb validate;
51 event_rule_serialize_cb serialize;
52 event_rule_equal_cb equal;
53 event_rule_destroy_cb destroy;
54 event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
55 event_rule_get_filter_cb get_filter;
56 event_rule_get_filter_bytecode_cb get_filter_bytecode;
57 event_rule_generate_exclusions_cb generate_exclusions;
58 event_rule_generate_lttng_event_cb generate_lttng_event;
59 };
60
61 struct lttng_event_rule_comm {
62 /* enum lttng_event_rule_type */
63 int8_t event_rule_type;
64 char payload[];
65 };
66
67 LTTNG_HIDDEN
68 void lttng_event_rule_init(struct lttng_event_rule *event_rule,
69 enum lttng_event_rule_type type);
70
71 LTTNG_HIDDEN
72 bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
73
74 LTTNG_HIDDEN
75 ssize_t lttng_event_rule_create_from_payload(
76 struct lttng_payload_view *payload,
77 struct lttng_event_rule **event_rule);
78
79 LTTNG_HIDDEN
80 int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
81 struct lttng_payload *payload);
82
83 LTTNG_HIDDEN
84 bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
85 const struct lttng_event_rule *b);
86
87 LTTNG_HIDDEN
88 bool lttng_event_rule_get(struct lttng_event_rule *rule);
89
90 LTTNG_HIDDEN
91 void lttng_event_rule_put(struct lttng_event_rule *rule);
92
93 LTTNG_HIDDEN
94 enum lttng_domain_type lttng_event_rule_get_domain_type(
95 const struct lttng_event_rule *rule);
96
97 LTTNG_HIDDEN
98 enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
99 struct lttng_event_rule *rule, uid_t uid, gid_t gid);
100
101 /*
102 * If not present/implemented returns NULL.
103 * Caller DOES NOT own the returned object.
104 */
105 LTTNG_HIDDEN
106 const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
107
108 /*
109 * If not present/implemented returns NULL.
110 * Caller DOES NOT own the returned object.
111 */
112 LTTNG_HIDDEN
113 const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
114 const struct lttng_event_rule *rule);
115
116 /*
117 * If not present/implemented return NULL.
118 * Caller OWNS the returned object.
119 */
120 LTTNG_HIDDEN
121 struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
122 const struct lttng_event_rule *rule);
123
124 LTTNG_HIDDEN
125 const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
126
127 /*
128 * This is compatibility helper, allowing us to generate a sessiond side (not
129 * communication) struct lttng_event object. This facilitate integration with
130 * current code.
131 * Caller OWN the returned object
132 */
133 LTTNG_HIDDEN
134 struct lttng_event *lttng_event_rule_generate_lttng_event(
135 const struct lttng_event_rule *rule);
136
137 /* Quick helper to test if the event rule apply to an agent domain */
138 LTTNG_HIDDEN
139 bool lttng_event_rule_is_agent(const struct lttng_event_rule *rule);
140
141 #endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.046352 seconds and 5 git commands to generate.