SoW-2019-0007-2: Dynamic Snapshot: Triggers send partial event payload with notifications
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.h
CommitLineData
5024c2ac
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/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
23typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
24typedef bool (*event_rule_validate_cb)(
25 const struct lttng_event_rule *event_rule);
26typedef int (*event_rule_serialize_cb)(
27 const struct lttng_event_rule *event_rule,
28 struct lttng_dynamic_buffer *buf,
29 int *fd_to_send);
30typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
31 const struct lttng_event_rule *b);
32typedef ssize_t (*event_rule_create_from_buffer_cb)(
33 const struct lttng_buffer_view *view,
34 struct lttng_event_rule **event_rule);
35typedef enum lttng_error_code (*event_rule_populate_cb)(
36 struct lttng_event_rule *event_rule, uid_t uid, gid_t gid);
37typedef const char *(*event_rule_get_filter_cb)(
38 const struct lttng_event_rule *event_rule);
39typedef const struct lttng_bytecode *(
40 *event_rule_get_filter_bytecode_cb)(
41 const struct lttng_event_rule *event_rule);
42typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)(
43 struct lttng_event_rule *event_rule);
44typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
45 const struct lttng_event_rule *event_rule);
46
47struct 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
61struct lttng_event_rule_comm {
62 /* enum lttng_event_rule_type */
63 int8_t event_rule_type;
64 char payload[];
65};
66
67LTTNG_HIDDEN
68void lttng_event_rule_init(struct lttng_event_rule *event_rule,
69 enum lttng_event_rule_type type);
70
71LTTNG_HIDDEN
72bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
73
74LTTNG_HIDDEN
75ssize_t lttng_event_rule_create_from_buffer(
76 const struct lttng_buffer_view *buffer,
77 struct lttng_event_rule **event_rule);
78
79LTTNG_HIDDEN
80int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
81 struct lttng_dynamic_buffer *buf,
82 int *fd_to_send);
83
84LTTNG_HIDDEN
85bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
86 const struct lttng_event_rule *b);
87
88LTTNG_HIDDEN
89bool lttng_event_rule_get(struct lttng_event_rule *rule);
90
91LTTNG_HIDDEN
92void lttng_event_rule_put(struct lttng_event_rule *rule);
93
94LTTNG_HIDDEN
95enum lttng_domain_type lttng_event_rule_get_domain_type(
96 const struct lttng_event_rule *rule);
97
98LTTNG_HIDDEN
99enum 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 */
106LTTNG_HIDDEN
107const 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 */
113LTTNG_HIDDEN
114const 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 */
122LTTNG_HIDDEN
123struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
124 struct lttng_event_rule *rule);
125
126LTTNG_HIDDEN
127const 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 */
135LTTNG_HIDDEN
136struct 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 */
140LTTNG_HIDDEN
141bool lttng_event_rule_is_agent(const struct lttng_event_rule *rule);
142
143#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.028718 seconds and 5 git commands to generate.