Commit | Line | Data |
---|---|---|
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 | ||
20 | struct lttng_payload; | |
21 | struct lttng_payload_view; | |
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_payload *payload); | |
29 | typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a, | |
30 | const struct lttng_event_rule *b); | |
31 | typedef ssize_t (*event_rule_create_from_payload_cb)( | |
32 | struct lttng_payload_view *view, | |
33 | struct lttng_event_rule **event_rule); | |
34 | typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)( | |
35 | struct lttng_event_rule *event_rule, uid_t uid, gid_t gid); | |
36 | typedef const char *(*event_rule_get_filter_cb)( | |
37 | const struct lttng_event_rule *event_rule); | |
38 | typedef const struct lttng_filter_bytecode *( | |
39 | *event_rule_get_filter_bytecode_cb)( | |
40 | const struct lttng_event_rule *event_rule); | |
41 | typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)( | |
42 | const struct lttng_event_rule *event_rule); | |
43 | ||
44 | struct 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 | ||
57 | struct lttng_event_rule_comm { | |
58 | /* enum lttng_event_rule_type */ | |
59 | int8_t event_rule_type; | |
60 | char payload[]; | |
61 | }; | |
62 | ||
63 | LTTNG_HIDDEN | |
64 | void lttng_event_rule_init(struct lttng_event_rule *event_rule, | |
65 | enum lttng_event_rule_type type); | |
66 | ||
67 | LTTNG_HIDDEN | |
68 | bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule); | |
69 | ||
70 | LTTNG_HIDDEN | |
71 | ssize_t lttng_event_rule_create_from_payload( | |
72 | struct lttng_payload_view *payload, | |
73 | struct lttng_event_rule **event_rule); | |
74 | ||
75 | LTTNG_HIDDEN | |
76 | int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule, | |
77 | struct lttng_payload *payload); | |
78 | ||
79 | LTTNG_HIDDEN | |
80 | bool lttng_event_rule_is_equal(const struct lttng_event_rule *a, | |
81 | const struct lttng_event_rule *b); | |
82 | ||
83 | LTTNG_HIDDEN | |
84 | bool lttng_event_rule_get(struct lttng_event_rule *rule); | |
85 | ||
86 | LTTNG_HIDDEN | |
87 | void lttng_event_rule_put(struct lttng_event_rule *rule); | |
88 | ||
89 | LTTNG_HIDDEN | |
90 | enum lttng_domain_type lttng_event_rule_get_domain_type( | |
91 | const struct lttng_event_rule *rule); | |
92 | ||
93 | LTTNG_HIDDEN | |
94 | enum 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 | */ | |
101 | LTTNG_HIDDEN | |
102 | const 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 | */ | |
108 | LTTNG_HIDDEN | |
109 | const 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 | */ | |
116 | LTTNG_HIDDEN | |
117 | struct lttng_event_exclusion *lttng_event_rule_generate_exclusions( | |
118 | const struct lttng_event_rule *rule); | |
119 | ||
120 | LTTNG_HIDDEN | |
121 | const char *lttng_event_rule_type_str(enum lttng_event_rule_type type); | |
122 | ||
123 | #endif /* LTTNG_EVENT_RULE_INTERNAL_H */ |