Commit | Line | Data |
---|---|---|
a58c490f | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
a58c490f | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
a58c490f | 5 | * |
a58c490f JG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_ACTION_INTERNAL_H | |
9 | #define LTTNG_ACTION_INTERNAL_H | |
10 | ||
11 | #include <lttng/action/action.h> | |
12 | #include <common/macros.h> | |
13 | #include <common/buffer-view.h> | |
3647288f | 14 | #include <common/dynamic-buffer.h> |
9e620ea7 JG |
15 | #include <common/payload-view.h> |
16 | #include <common/payload.h> | |
a58c490f | 17 | #include <stdbool.h> |
72756a3f | 18 | #include <sys/types.h> |
c852ce4e | 19 | #include <urcu/ref.h> |
a58c490f JG |
20 | |
21 | typedef bool (*action_validate_cb)(struct lttng_action *action); | |
22 | typedef void (*action_destroy_cb)(struct lttng_action *action); | |
3647288f | 23 | typedef int (*action_serialize_cb)(struct lttng_action *action, |
c0a66c84 | 24 | struct lttng_payload *payload); |
3dd04a6a JR |
25 | typedef bool (*action_equal_cb)(const struct lttng_action *a, |
26 | const struct lttng_action *b); | |
c0a66c84 JG |
27 | typedef ssize_t (*action_create_from_payload_cb)( |
28 | struct lttng_payload_view *view, | |
869a3c2d | 29 | struct lttng_action **action); |
a58c490f JG |
30 | |
31 | struct lttng_action { | |
c852ce4e | 32 | struct urcu_ref ref; |
a58c490f JG |
33 | enum lttng_action_type type; |
34 | action_validate_cb validate; | |
35 | action_serialize_cb serialize; | |
3dd04a6a | 36 | action_equal_cb equal; |
a58c490f JG |
37 | action_destroy_cb destroy; |
38 | }; | |
39 | ||
40 | struct lttng_action_comm { | |
41 | /* enum lttng_action_type */ | |
42 | int8_t action_type; | |
43 | } LTTNG_PACKED; | |
44 | ||
6acb3f46 SM |
45 | LTTNG_HIDDEN |
46 | void lttng_action_init(struct lttng_action *action, | |
47 | enum lttng_action_type type, | |
48 | action_validate_cb validate, | |
49 | action_serialize_cb serialize, | |
3dd04a6a | 50 | action_equal_cb equal, |
6acb3f46 SM |
51 | action_destroy_cb destroy); |
52 | ||
a58c490f JG |
53 | LTTNG_HIDDEN |
54 | bool lttng_action_validate(struct lttng_action *action); | |
55 | ||
56 | LTTNG_HIDDEN | |
3647288f | 57 | int lttng_action_serialize(struct lttng_action *action, |
c0a66c84 | 58 | struct lttng_payload *buf); |
a58c490f JG |
59 | |
60 | LTTNG_HIDDEN | |
c0a66c84 | 61 | ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view, |
a58c490f JG |
62 | struct lttng_action **action); |
63 | ||
9b63a4aa JG |
64 | LTTNG_HIDDEN |
65 | enum lttng_action_type lttng_action_get_type_const( | |
66 | const struct lttng_action *action); | |
67 | ||
3dd04a6a JR |
68 | LTTNG_HIDDEN |
69 | bool lttng_action_is_equal(const struct lttng_action *a, | |
70 | const struct lttng_action *b); | |
71 | ||
c852ce4e JG |
72 | LTTNG_HIDDEN |
73 | void lttng_action_get(struct lttng_action *action); | |
74 | ||
75 | LTTNG_HIDDEN | |
76 | void lttng_action_put(struct lttng_action *action); | |
77 | ||
10615eee JR |
78 | LTTNG_HIDDEN |
79 | const char* lttng_action_type_string(enum lttng_action_type action_type); | |
80 | ||
a58c490f | 81 | #endif /* LTTNG_ACTION_INTERNAL_H */ |