7aca4a02ba62098be6d6fe271bc151920ddc82e3
[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 <common/credentials.h>
13 #include <lttng/domain.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,
37 const struct lttng_credentials *creds);
38 typedef const char *(*event_rule_get_filter_cb)(
39 const struct lttng_event_rule *event_rule);
40 typedef const struct lttng_filter_bytecode *(
41 *event_rule_get_filter_bytecode_cb)(
42 const struct lttng_event_rule *event_rule);
43 typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)(
44 const struct lttng_event_rule *event_rule);
45
46 struct lttng_event_rule {
47 struct urcu_ref ref;
48 enum lttng_event_rule_type type;
49 event_rule_validate_cb validate;
50 event_rule_serialize_cb serialize;
51 event_rule_equal_cb equal;
52 event_rule_destroy_cb destroy;
53 event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
54 event_rule_get_filter_cb get_filter;
55 event_rule_get_filter_bytecode_cb get_filter_bytecode;
56 event_rule_generate_exclusions_cb generate_exclusions;
57 };
58
59 struct lttng_event_rule_comm {
60 /* enum lttng_event_rule_type */
61 int8_t event_rule_type;
62 char payload[];
63 };
64
65 LTTNG_HIDDEN
66 void lttng_event_rule_init(struct lttng_event_rule *event_rule,
67 enum lttng_event_rule_type type);
68
69 LTTNG_HIDDEN
70 bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
71
72 LTTNG_HIDDEN
73 ssize_t lttng_event_rule_create_from_payload(
74 struct lttng_payload_view *payload,
75 struct lttng_event_rule **event_rule);
76
77 LTTNG_HIDDEN
78 int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
79 struct lttng_payload *payload);
80
81 LTTNG_HIDDEN
82 bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
83 const struct lttng_event_rule *b);
84
85 LTTNG_HIDDEN
86 bool lttng_event_rule_get(struct lttng_event_rule *rule);
87
88 LTTNG_HIDDEN
89 void lttng_event_rule_put(struct lttng_event_rule *rule);
90
91 LTTNG_HIDDEN
92 enum lttng_domain_type lttng_event_rule_get_domain_type(
93 const struct lttng_event_rule *rule);
94
95 LTTNG_HIDDEN
96 enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
97 struct lttng_event_rule *rule,
98 const struct lttng_credentials *creds);
99
100 /*
101 * If not present/implemented returns NULL.
102 * Caller DOES NOT own the returned object.
103 */
104 LTTNG_HIDDEN
105 const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
106
107 /*
108 * If not present/implemented returns NULL.
109 * Caller DOES NOT own the returned object.
110 */
111 LTTNG_HIDDEN
112 const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode(
113 const struct lttng_event_rule *rule);
114
115 /*
116 * If not present/implemented return NULL.
117 * Caller OWNS the returned object.
118 */
119 LTTNG_HIDDEN
120 struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
121 const struct lttng_event_rule *rule);
122
123 LTTNG_HIDDEN
124 const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
125
126 #endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.043099 seconds and 3 git commands to generate.