2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_ACTION_INTERNAL_H
9 #define LTTNG_ACTION_INTERNAL_H
11 #include <lttng/action/action.h>
12 #include <common/macros.h>
13 #include <common/buffer-view.h>
14 #include <common/dynamic-buffer.h>
15 #include <common/payload-view.h>
16 #include <common/payload.h>
18 #include <sys/types.h>
21 struct lttng_firing_policy
;
23 typedef bool (*action_validate_cb
)(struct lttng_action
*action
);
24 typedef void (*action_destroy_cb
)(struct lttng_action
*action
);
25 typedef int (*action_serialize_cb
)(struct lttng_action
*action
,
26 struct lttng_payload
*payload
);
27 typedef bool (*action_equal_cb
)(const struct lttng_action
*a
,
28 const struct lttng_action
*b
);
29 typedef ssize_t (*action_create_from_payload_cb
)(
30 struct lttng_payload_view
*view
,
31 struct lttng_action
**action
);
32 typedef const struct lttng_firing_policy
*(*action_get_firing_policy_cb
)(
33 const struct lttng_action
*action
);
37 enum lttng_action_type type
;
38 action_validate_cb validate
;
39 action_serialize_cb serialize
;
40 action_equal_cb equal
;
41 action_destroy_cb destroy
;
42 action_get_firing_policy_cb get_firing_policy
;
44 /* Internal use only. */
46 /* The number of time the actions was enqueued for execution. */
47 uint64_t execution_request_counter
;
49 * The number of time the action was actually executed.
50 * Action firing policy can impact on this number.
52 uint64_t execution_counter
;
54 * The number of time the action execution failed.
56 uint64_t execution_failure_counter
;
59 struct lttng_action_comm
{
60 /* enum lttng_action_type */
65 void lttng_action_init(struct lttng_action
*action
,
66 enum lttng_action_type type
,
67 action_validate_cb validate
,
68 action_serialize_cb serialize
,
69 action_equal_cb equal
,
70 action_destroy_cb destroy
,
71 action_get_firing_policy_cb get_firing_policy
);
74 bool lttng_action_validate(struct lttng_action
*action
);
77 int lttng_action_serialize(struct lttng_action
*action
,
78 struct lttng_payload
*buf
);
81 ssize_t
lttng_action_create_from_payload(struct lttng_payload_view
*view
,
82 struct lttng_action
**action
);
85 bool lttng_action_is_equal(const struct lttng_action
*a
,
86 const struct lttng_action
*b
);
89 void lttng_action_get(struct lttng_action
*action
);
92 void lttng_action_put(struct lttng_action
*action
);
95 const char* lttng_action_type_string(enum lttng_action_type action_type
);
98 void lttng_action_increase_execution_request_count(struct lttng_action
*action
);
101 void lttng_action_increase_execution_count(struct lttng_action
*action
);
104 void lttng_action_increase_execution_failure_count(struct lttng_action
*action
);
107 bool lttng_action_should_execute(const struct lttng_action
*action
);
109 #endif /* LTTNG_ACTION_INTERNAL_H */