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> | |
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 | ||
22 | struct lttng_payload; | |
23 | struct lttng_payload_view; | |
24 | ||
993578ff JR |
25 | enum 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 |
32 | typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule); |
33 | typedef bool (*event_rule_validate_cb)( | |
34 | const struct lttng_event_rule *event_rule); | |
35 | typedef int (*event_rule_serialize_cb)( | |
36 | const struct lttng_event_rule *event_rule, | |
37 | struct lttng_payload *payload); | |
38 | typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a, | |
39 | const struct lttng_event_rule *b); | |
40 | typedef ssize_t (*event_rule_create_from_payload_cb)( | |
41 | struct lttng_payload_view *view, | |
42 | struct lttng_event_rule **event_rule); | |
43 | typedef 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 |
46 | typedef const char *(*event_rule_get_filter_cb)( |
47 | const struct lttng_event_rule *event_rule); | |
48 | typedef const struct lttng_filter_bytecode *( | |
49 | *event_rule_get_filter_bytecode_cb)( | |
50 | const struct lttng_event_rule *event_rule); | |
993578ff JR |
51 | typedef 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 |
55 | typedef unsigned long (*event_rule_hash_cb)( |
56 | const struct lttng_event_rule *event_rule); | |
7a3dcaf6 JR |
57 | |
58 | struct 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 | ||
72 | struct lttng_event_rule_comm { | |
73 | /* enum lttng_event_rule_type */ | |
74 | int8_t event_rule_type; | |
75 | char payload[]; | |
76 | }; | |
77 | ||
78 | LTTNG_HIDDEN | |
79 | void lttng_event_rule_init(struct lttng_event_rule *event_rule, | |
80 | enum lttng_event_rule_type type); | |
81 | ||
82 | LTTNG_HIDDEN | |
83 | bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule); | |
84 | ||
85 | LTTNG_HIDDEN | |
86 | ssize_t lttng_event_rule_create_from_payload( | |
87 | struct lttng_payload_view *payload, | |
88 | struct lttng_event_rule **event_rule); | |
89 | ||
90 | LTTNG_HIDDEN | |
91 | int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule, | |
92 | struct lttng_payload *payload); | |
93 | ||
94 | LTTNG_HIDDEN | |
95 | bool lttng_event_rule_is_equal(const struct lttng_event_rule *a, | |
96 | const struct lttng_event_rule *b); | |
97 | ||
98 | LTTNG_HIDDEN | |
99 | bool lttng_event_rule_get(struct lttng_event_rule *rule); | |
100 | ||
101 | LTTNG_HIDDEN | |
102 | void lttng_event_rule_put(struct lttng_event_rule *rule); | |
103 | ||
104 | LTTNG_HIDDEN | |
105 | enum lttng_domain_type lttng_event_rule_get_domain_type( | |
106 | const struct lttng_event_rule *rule); | |
107 | ||
108 | LTTNG_HIDDEN | |
109 | enum 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 | */ | |
117 | LTTNG_HIDDEN | |
118 | const 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 | */ | |
124 | LTTNG_HIDDEN | |
125 | const 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 | */ | |
132 | LTTNG_HIDDEN | |
993578ff JR |
133 | enum lttng_event_rule_generate_exclusions_status |
134 | lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule, | |
135 | struct lttng_event_exclusion **exclusions); | |
7a3dcaf6 JR |
136 | |
137 | LTTNG_HIDDEN | |
138 | const char *lttng_event_rule_type_str(enum lttng_event_rule_type type); | |
139 | ||
959e3c66 JR |
140 | LTTNG_HIDDEN |
141 | unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule); | |
142 | ||
7a3dcaf6 | 143 | #endif /* LTTNG_EVENT_RULE_INTERNAL_H */ |