bin: compile lttng as C++
[lttng-tools.git] / include / lttng / event-rule / event-rule-internal.h
index 9fb115caf670bd5b924c112be6369ec003361911..98d1f449d2e9000d6d781a6802275d8e74af45e7 100644 (file)
@@ -9,7 +9,10 @@
 #define LTTNG_EVENT_RULE_INTERNAL_H
 
 #include <common/macros.h>
+#include <common/credentials.h>
+#include <common/sessiond-comm/sessiond-comm.h>
 #include <lttng/domain.h>
+#include <lttng/event.h>
 #include <lttng/event-rule/event-rule.h>
 #include <lttng/lttng-error.h>
 #include <stdbool.h>
 #include <sys/types.h>
 #include <urcu/ref.h>
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 struct lttng_payload;
 struct lttng_payload_view;
+struct mi_writer;
+
+enum lttng_event_rule_generate_exclusions_status {
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
+};
 
 typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
 typedef bool (*event_rule_validate_cb)(
@@ -32,14 +47,24 @@ typedef ssize_t (*event_rule_create_from_payload_cb)(
                struct lttng_payload_view *view,
                struct lttng_event_rule **event_rule);
 typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
-               struct lttng_event_rule *event_rule, uid_t uid, gid_t gid);
+               struct lttng_event_rule *event_rule,
+               const struct lttng_credentials *creds);
 typedef const char *(*event_rule_get_filter_cb)(
                const struct lttng_event_rule *event_rule);
-typedef const struct lttng_filter_bytecode *(
+typedef const struct lttng_bytecode *(
                *event_rule_get_filter_bytecode_cb)(
                const struct lttng_event_rule *event_rule);
-typedef struct lttng_event_exclusion *(*event_rule_generate_exclusions_cb)(
+typedef enum lttng_event_rule_generate_exclusions_status (
+               *event_rule_generate_exclusions_cb)(
+               const struct lttng_event_rule *event_rule,
+               struct lttng_event_exclusion **exclusions);
+typedef unsigned long (*event_rule_hash_cb)(
+               const struct lttng_event_rule *event_rule);
+typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
                const struct lttng_event_rule *event_rule);
+typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
+               const struct lttng_event_rule *event_rule,
+               struct mi_writer *writer);
 
 struct lttng_event_rule {
        struct urcu_ref ref;
@@ -52,6 +77,9 @@ struct lttng_event_rule {
        event_rule_get_filter_cb get_filter;
        event_rule_get_filter_bytecode_cb get_filter_bytecode;
        event_rule_generate_exclusions_cb generate_exclusions;
+       event_rule_hash_cb hash;
+       event_rule_generate_lttng_event_cb generate_lttng_event;
+       event_rule_mi_serialize_cb mi_serialize;
 };
 
 struct lttng_event_rule_comm {
@@ -60,64 +88,77 @@ struct lttng_event_rule_comm {
        char payload[];
 };
 
-LTTNG_HIDDEN
 void lttng_event_rule_init(struct lttng_event_rule *event_rule,
                enum lttng_event_rule_type type);
 
-LTTNG_HIDDEN
 bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
 
-LTTNG_HIDDEN
 ssize_t lttng_event_rule_create_from_payload(
                struct lttng_payload_view *payload,
                struct lttng_event_rule **event_rule);
 
-LTTNG_HIDDEN
 int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
                struct lttng_payload *payload);
 
-LTTNG_HIDDEN
 bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
                const struct lttng_event_rule *b);
 
-LTTNG_HIDDEN
 bool lttng_event_rule_get(struct lttng_event_rule *rule);
 
-LTTNG_HIDDEN
 void lttng_event_rule_put(struct lttng_event_rule *rule);
 
-LTTNG_HIDDEN
 enum lttng_domain_type lttng_event_rule_get_domain_type(
                const struct lttng_event_rule *rule);
 
-LTTNG_HIDDEN
 enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
-               struct lttng_event_rule *rule, uid_t uid, gid_t gid);
+               struct lttng_event_rule *rule,
+               const struct lttng_credentials *creds);
 
 /*
  * If not present/implemented returns NULL.
  * Caller DOES NOT own the returned object.
  */
-LTTNG_HIDDEN
 const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
 
 /*
  * If not present/implemented returns NULL.
  * Caller DOES NOT own the returned object.
  */
-LTTNG_HIDDEN
-const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode(
+const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
                const struct lttng_event_rule *rule);
 
 /*
  * If not present/implemented return NULL.
  * Caller OWNS the returned object.
  */
-LTTNG_HIDDEN
-struct lttng_event_exclusion *lttng_event_rule_generate_exclusions(
-               const struct lttng_event_rule *rule);
+enum lttng_event_rule_generate_exclusions_status
+lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
+               struct lttng_event_exclusion **exclusions);
 
-LTTNG_HIDDEN
 const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
 
+unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
+
+/*
+ * This is a compatibility helper allowing us to generate a sessiond-side (not
+ * communication) `struct lttng_event` object from an event rule.
+ *
+ * This effectively bridges older parts of the code using those structures and
+ * new event-rule based code.
+ *
+ * The caller owns the returned object.
+ */
+struct lttng_event *lttng_event_rule_generate_lttng_event(
+               const struct lttng_event_rule *rule);
+
+/* Test if an event rule targets an agent domain. */
+bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
+
+enum lttng_error_code lttng_event_rule_mi_serialize(
+               const struct lttng_event_rule *rule, struct mi_writer *writer);
+
+#if defined(__cplusplus)
+}
+#endif
+
 #endif /* LTTNG_EVENT_RULE_INTERNAL_H */
This page took 0.025418 seconds and 4 git commands to generate.