SoW-2019-0007-2: Dynamic Snapshot: Triggers send partial event payload with notifications
[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/buffer-view.h>
12 #include <common/dynamic-buffer.h>
13 #include <common/macros.h>
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 typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
24 typedef bool (*event_rule_validate_cb)(
25 const struct lttng_event_rule *event_rule);
26 typedef int (*event_rule_serialize_cb)(
27 const struct lttng_event_rule *event_rule,
28 struct lttng_dynamic_buffer *buf,
29 int *fd_to_send);
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_buffer_cb)(
33 const struct lttng_buffer_view *view,
34 struct lttng_event_rule **event_rule);
35 typedef enum lttng_error_code (*event_rule_populate_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 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_populate_cb populate;
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_buffer(
76 const struct lttng_buffer_view *buffer,
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_dynamic_buffer *buf,
82 int *fd_to_send);
83
84 LTTNG_HIDDEN
85 bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
86 const struct lttng_event_rule *b);
87
88 LTTNG_HIDDEN
89 bool lttng_event_rule_get(struct lttng_event_rule *rule);
90
91 LTTNG_HIDDEN
92 void lttng_event_rule_put(struct lttng_event_rule *rule);
93
94 LTTNG_HIDDEN
95 enum lttng_domain_type lttng_event_rule_get_domain_type(
96 const struct lttng_event_rule *rule);
97
98 LTTNG_HIDDEN
99 enum lttng_error_code lttng_event_rule_populate(
100 struct lttng_event_rule *rule, uid_t uid, gid_t gid);
101
102 /*
103 * If not present/implemented returns NULL
104 * Caller DO NOT own the returned object
105 */
106 LTTNG_HIDDEN
107 const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
108
109 /*
110 * If not present/implemented returns NULL
111 * Caller DO NOT own the returned object
112 */
113 LTTNG_HIDDEN
114 const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
115 const struct lttng_event_rule *rule);
116
117 /*
118 * If not present return NULL
119 * Caller OWN the returned object
120 * TODO: should this be done another way?
121 */
122 LTTNG_HIDDEN
123 struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
124 struct lttng_event_rule *rule);
125
126 LTTNG_HIDDEN
127 const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
128
129 /*
130 * This is compatibility helper, allowing us to generate a sessiond side (not
131 * communication) struct lttng_event object. This facilitate integration with
132 * current code.
133 * Caller OWN the returned object
134 */
135 LTTNG_HIDDEN
136 struct lttng_event *lttng_event_rule_generate_lttng_event(
137 const struct lttng_event_rule *rule);
138
139 /* Quick helper to test if the event rule apply to an agent domain */
140 LTTNG_HIDDEN
141 bool lttng_event_rule_is_agent(const struct lttng_event_rule *rule);
142
143 #endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.03314 seconds and 5 git commands to generate.