ust-app: implement event notifier support
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.h
CommitLineData
7a3dcaf6
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/macros.h>
58daac01 12#include <common/credentials.h>
993578ff 13#include <common/sessiond-comm/sessiond-comm.h>
7a3dcaf6
JR
14#include <lttng/domain.h>
15#include <lttng/event-rule/event-rule.h>
16#include <lttng/lttng-error.h>
17#include <stdbool.h>
18#include <stdint.h>
19#include <sys/types.h>
20#include <urcu/ref.h>
21
22struct lttng_payload;
23struct lttng_payload_view;
24
993578ff
JR
25enum lttng_event_rule_generate_exclusions_status {
26 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
27 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
28 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
29 LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
30};
31
7a3dcaf6
JR
32typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
33typedef bool (*event_rule_validate_cb)(
34 const struct lttng_event_rule *event_rule);
35typedef int (*event_rule_serialize_cb)(
36 const struct lttng_event_rule *event_rule,
37 struct lttng_payload *payload);
38typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
39 const struct lttng_event_rule *b);
40typedef ssize_t (*event_rule_create_from_payload_cb)(
41 struct lttng_payload_view *view,
42 struct lttng_event_rule **event_rule);
43typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
58daac01
JR
44 struct lttng_event_rule *event_rule,
45 const struct lttng_credentials *creds);
7a3dcaf6
JR
46typedef const char *(*event_rule_get_filter_cb)(
47 const struct lttng_event_rule *event_rule);
48typedef const struct lttng_filter_bytecode *(
49 *event_rule_get_filter_bytecode_cb)(
50 const struct lttng_event_rule *event_rule);
993578ff
JR
51typedef enum lttng_event_rule_generate_exclusions_status (
52 *event_rule_generate_exclusions_cb)(
53 const struct lttng_event_rule *event_rule,
54 struct lttng_event_exclusion **exclusions);
959e3c66
JR
55typedef unsigned long (*event_rule_hash_cb)(
56 const struct lttng_event_rule *event_rule);
7a3dcaf6
JR
57
58struct lttng_event_rule {
59 struct urcu_ref ref;
60 enum lttng_event_rule_type type;
61 event_rule_validate_cb validate;
62 event_rule_serialize_cb serialize;
63 event_rule_equal_cb equal;
64 event_rule_destroy_cb destroy;
65 event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
66 event_rule_get_filter_cb get_filter;
67 event_rule_get_filter_bytecode_cb get_filter_bytecode;
68 event_rule_generate_exclusions_cb generate_exclusions;
959e3c66 69 event_rule_hash_cb hash;
7a3dcaf6
JR
70};
71
72struct lttng_event_rule_comm {
73 /* enum lttng_event_rule_type */
74 int8_t event_rule_type;
75 char payload[];
76};
77
78LTTNG_HIDDEN
79void lttng_event_rule_init(struct lttng_event_rule *event_rule,
80 enum lttng_event_rule_type type);
81
82LTTNG_HIDDEN
83bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
84
85LTTNG_HIDDEN
86ssize_t lttng_event_rule_create_from_payload(
87 struct lttng_payload_view *payload,
88 struct lttng_event_rule **event_rule);
89
90LTTNG_HIDDEN
91int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
92 struct lttng_payload *payload);
93
94LTTNG_HIDDEN
95bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
96 const struct lttng_event_rule *b);
97
98LTTNG_HIDDEN
99bool lttng_event_rule_get(struct lttng_event_rule *rule);
100
101LTTNG_HIDDEN
102void lttng_event_rule_put(struct lttng_event_rule *rule);
103
104LTTNG_HIDDEN
105enum lttng_domain_type lttng_event_rule_get_domain_type(
106 const struct lttng_event_rule *rule);
107
108LTTNG_HIDDEN
109enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
58daac01
JR
110 struct lttng_event_rule *rule,
111 const struct lttng_credentials *creds);
7a3dcaf6
JR
112
113/*
114 * If not present/implemented returns NULL.
115 * Caller DOES NOT own the returned object.
116 */
117LTTNG_HIDDEN
118const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
119
120/*
121 * If not present/implemented returns NULL.
122 * Caller DOES NOT own the returned object.
123 */
124LTTNG_HIDDEN
125const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode(
126 const struct lttng_event_rule *rule);
127
128/*
129 * If not present/implemented return NULL.
130 * Caller OWNS the returned object.
131 */
132LTTNG_HIDDEN
993578ff
JR
133enum lttng_event_rule_generate_exclusions_status
134lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
135 struct lttng_event_exclusion **exclusions);
7a3dcaf6
JR
136
137LTTNG_HIDDEN
138const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
139
959e3c66
JR
140LTTNG_HIDDEN
141unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
142
7a3dcaf6 143#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.027838 seconds and 4 git commands to generate.