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> |
7a3dcaf6 JR |
13 | #include <lttng/domain.h> |
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 | ||
21 | struct lttng_payload; | |
22 | struct lttng_payload_view; | |
23 | ||
24 | typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule); | |
25 | typedef bool (*event_rule_validate_cb)( | |
26 | const struct lttng_event_rule *event_rule); | |
27 | typedef int (*event_rule_serialize_cb)( | |
28 | const struct lttng_event_rule *event_rule, | |
29 | struct lttng_payload *payload); | |
30 | typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a, | |
31 | const struct lttng_event_rule *b); | |
32 | typedef ssize_t (*event_rule_create_from_payload_cb)( | |
33 | struct lttng_payload_view *view, | |
34 | struct lttng_event_rule **event_rule); | |
35 | typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)( | |
58daac01 JR |
36 | struct lttng_event_rule *event_rule, |
37 | const struct lttng_credentials *creds); | |
7a3dcaf6 JR |
38 | typedef const char *(*event_rule_get_filter_cb)( |
39 | const struct lttng_event_rule *event_rule); | |
40 | typedef const struct lttng_filter_bytecode *( | |
41 | *event_rule_get_filter_bytecode_cb)( | |
42 | const struct lttng_event_rule *event_rule); | |
43 | typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)( | |
44 | const struct lttng_event_rule *event_rule); | |
959e3c66 JR |
45 | typedef unsigned long (*event_rule_hash_cb)( |
46 | const struct lttng_event_rule *event_rule); | |
7a3dcaf6 JR |
47 | |
48 | struct lttng_event_rule { | |
49 | struct urcu_ref ref; | |
50 | enum lttng_event_rule_type type; | |
51 | event_rule_validate_cb validate; | |
52 | event_rule_serialize_cb serialize; | |
53 | event_rule_equal_cb equal; | |
54 | event_rule_destroy_cb destroy; | |
55 | event_rule_generate_filter_bytecode_cb generate_filter_bytecode; | |
56 | event_rule_get_filter_cb get_filter; | |
57 | event_rule_get_filter_bytecode_cb get_filter_bytecode; | |
58 | event_rule_generate_exclusions_cb generate_exclusions; | |
959e3c66 | 59 | event_rule_hash_cb hash; |
7a3dcaf6 JR |
60 | }; |
61 | ||
62 | struct lttng_event_rule_comm { | |
63 | /* enum lttng_event_rule_type */ | |
64 | int8_t event_rule_type; | |
65 | char payload[]; | |
66 | }; | |
67 | ||
68 | LTTNG_HIDDEN | |
69 | void lttng_event_rule_init(struct lttng_event_rule *event_rule, | |
70 | enum lttng_event_rule_type type); | |
71 | ||
72 | LTTNG_HIDDEN | |
73 | bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule); | |
74 | ||
75 | LTTNG_HIDDEN | |
76 | ssize_t lttng_event_rule_create_from_payload( | |
77 | struct lttng_payload_view *payload, | |
78 | struct lttng_event_rule **event_rule); | |
79 | ||
80 | LTTNG_HIDDEN | |
81 | int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule, | |
82 | struct lttng_payload *payload); | |
83 | ||
84 | LTTNG_HIDDEN | |
85 | bool lttng_event_rule_is_equal(const struct lttng_event_rule *a, | |
86 | const struct lttng_event_rule *b); | |
87 | ||
88 | LTTNG_HIDDEN | |
89 | bool lttng_event_rule_get(struct lttng_event_rule *rule); | |
90 | ||
91 | LTTNG_HIDDEN | |
92 | void lttng_event_rule_put(struct lttng_event_rule *rule); | |
93 | ||
94 | LTTNG_HIDDEN | |
95 | enum lttng_domain_type lttng_event_rule_get_domain_type( | |
96 | const struct lttng_event_rule *rule); | |
97 | ||
98 | LTTNG_HIDDEN | |
99 | enum lttng_error_code lttng_event_rule_generate_filter_bytecode( | |
58daac01 JR |
100 | struct lttng_event_rule *rule, |
101 | const struct lttng_credentials *creds); | |
7a3dcaf6 JR |
102 | |
103 | /* | |
104 | * If not present/implemented returns NULL. | |
105 | * Caller DOES NOT own the returned object. | |
106 | */ | |
107 | LTTNG_HIDDEN | |
108 | const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule); | |
109 | ||
110 | /* | |
111 | * If not present/implemented returns NULL. | |
112 | * Caller DOES NOT own the returned object. | |
113 | */ | |
114 | LTTNG_HIDDEN | |
115 | const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode( | |
116 | const struct lttng_event_rule *rule); | |
117 | ||
118 | /* | |
119 | * If not present/implemented return NULL. | |
120 | * Caller OWNS the returned object. | |
121 | */ | |
122 | LTTNG_HIDDEN | |
123 | struct lttng_event_exclusion *lttng_event_rule_generate_exclusions( | |
124 | const struct lttng_event_rule *rule); | |
125 | ||
126 | LTTNG_HIDDEN | |
127 | const char *lttng_event_rule_type_str(enum lttng_event_rule_type type); | |
128 | ||
959e3c66 JR |
129 | LTTNG_HIDDEN |
130 | unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule); | |
131 | ||
7a3dcaf6 | 132 | #endif /* LTTNG_EVENT_RULE_INTERNAL_H */ |