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