SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[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>
12#include <lttng/domain.h>
2463b787 13#include <lttng/event.h>
7a3dcaf6
JR
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
21struct lttng_payload;
22struct lttng_payload_view;
23
24typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
25typedef bool (*event_rule_validate_cb)(
26 const struct lttng_event_rule *event_rule);
27typedef int (*event_rule_serialize_cb)(
28 const struct lttng_event_rule *event_rule,
29 struct lttng_payload *payload);
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_payload_cb)(
33 struct lttng_payload_view *view,
34 struct lttng_event_rule **event_rule);
35typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_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);
2463b787 39typedef const struct lttng_bytecode *(
7a3dcaf6
JR
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 const struct lttng_event_rule *event_rule);
2463b787
JR
44typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
45 const struct lttng_event_rule *event_rule);
7a3dcaf6
JR
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_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;
2463b787 58 event_rule_generate_lttng_event_cb generate_lttng_event;
7a3dcaf6
JR
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_payload(
76 struct lttng_payload_view *payload,
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_payload *payload);
82
83LTTNG_HIDDEN
84bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
85 const struct lttng_event_rule *b);
86
87LTTNG_HIDDEN
88bool lttng_event_rule_get(struct lttng_event_rule *rule);
89
90LTTNG_HIDDEN
91void lttng_event_rule_put(struct lttng_event_rule *rule);
92
93LTTNG_HIDDEN
94enum lttng_domain_type lttng_event_rule_get_domain_type(
95 const struct lttng_event_rule *rule);
96
97LTTNG_HIDDEN
98enum 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 */
105LTTNG_HIDDEN
106const 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 */
112LTTNG_HIDDEN
2463b787 113const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
7a3dcaf6
JR
114 const struct lttng_event_rule *rule);
115
116/*
117 * If not present/implemented return NULL.
118 * Caller OWNS the returned object.
119 */
120LTTNG_HIDDEN
121struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
122 const struct lttng_event_rule *rule);
123
124LTTNG_HIDDEN
125const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
126
2463b787
JR
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 */
133LTTNG_HIDDEN
134struct 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 */
138LTTNG_HIDDEN
139bool lttng_event_rule_is_agent(const struct lttng_event_rule *rule);
140
7a3dcaf6 141#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.041373 seconds and 5 git commands to generate.