2 * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_EVENT_RULE_INTERNAL_H
9 #define LTTNG_EVENT_RULE_INTERNAL_H
11 #include <common/macros.h>
12 #include <common/credentials.h>
13 #include <common/sessiond-comm/sessiond-comm.h>
14 #include <lttng/domain.h>
15 #include <lttng/event-rule/event-rule.h>
16 #include <lttng/lttng-error.h>
19 #include <sys/types.h>
23 struct lttng_payload_view
;
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
,
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
)(
44 struct lttng_event_rule
*event_rule
,
45 const struct lttng_credentials
*creds
);
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
);
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
);
55 typedef unsigned long (*event_rule_hash_cb
)(
56 const struct lttng_event_rule
*event_rule
);
58 struct lttng_event_rule
{
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
;
69 event_rule_hash_cb hash
;
72 struct lttng_event_rule_comm
{
73 /* enum lttng_event_rule_type */
74 int8_t event_rule_type
;
79 void lttng_event_rule_init(struct lttng_event_rule
*event_rule
,
80 enum lttng_event_rule_type type
);
83 bool lttng_event_rule_validate(const struct lttng_event_rule
*event_rule
);
86 ssize_t
lttng_event_rule_create_from_payload(
87 struct lttng_payload_view
*payload
,
88 struct lttng_event_rule
**event_rule
);
91 int lttng_event_rule_serialize(const struct lttng_event_rule
*event_rule
,
92 struct lttng_payload
*payload
);
95 bool lttng_event_rule_is_equal(const struct lttng_event_rule
*a
,
96 const struct lttng_event_rule
*b
);
99 bool lttng_event_rule_get(struct lttng_event_rule
*rule
);
102 void lttng_event_rule_put(struct lttng_event_rule
*rule
);
105 enum lttng_domain_type
lttng_event_rule_get_domain_type(
106 const struct lttng_event_rule
*rule
);
109 enum lttng_error_code
lttng_event_rule_generate_filter_bytecode(
110 struct lttng_event_rule
*rule
,
111 const struct lttng_credentials
*creds
);
114 * If not present/implemented returns NULL.
115 * Caller DOES NOT own the returned object.
118 const char *lttng_event_rule_get_filter(const struct lttng_event_rule
*rule
);
121 * If not present/implemented returns NULL.
122 * Caller DOES NOT own the returned object.
125 const struct lttng_filter_bytecode
*lttng_event_rule_get_filter_bytecode(
126 const struct lttng_event_rule
*rule
);
129 * If not present/implemented return NULL.
130 * Caller OWNS the returned object.
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
);
138 const char *lttng_event_rule_type_str(enum lttng_event_rule_type type
);
141 unsigned long lttng_event_rule_hash(const struct lttng_event_rule
*rule
);
143 #endif /* LTTNG_EVENT_RULE_INTERNAL_H */