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_TRIGGER_INTERNAL_H | |
9 | #define LTTNG_TRIGGER_INTERNAL_H | |
10 | ||
11 | #include <lttng/trigger/trigger.h> | |
3da864a9 | 12 | #include <common/credentials.h> |
a58c490f | 13 | #include <common/macros.h> |
3da864a9 | 14 | #include <common/optional.h> |
a58c490f JG |
15 | #include <stdint.h> |
16 | #include <stdbool.h> | |
72756a3f | 17 | #include <sys/types.h> |
f01d28b4 | 18 | #include <urcu/ref.h> |
a58c490f | 19 | |
c0a66c84 JG |
20 | struct lttng_payload; |
21 | struct lttng_payload_view; | |
22 | ||
a58c490f | 23 | struct lttng_trigger { |
f01d28b4 JR |
24 | /* Reference counting is only exposed to internal users. */ |
25 | struct urcu_ref ref; | |
26 | ||
a58c490f JG |
27 | struct lttng_condition *condition; |
28 | struct lttng_action *action; | |
64eafdf6 JR |
29 | /* For now only the uid portion of the credentials is used. */ |
30 | struct lttng_credentials creds; | |
a58c490f JG |
31 | }; |
32 | ||
33 | struct lttng_trigger_comm { | |
34 | /* length excludes its own length. */ | |
35 | uint32_t length; | |
64eafdf6 JR |
36 | /* |
37 | * Credentials, only the uid portion is used for now. | |
38 | * Used as an override when desired by the root user. | |
39 | */ | |
40 | uint64_t uid; | |
a58c490f JG |
41 | /* A condition and action object follow. */ |
42 | char payload[]; | |
43 | } LTTNG_PACKED; | |
44 | ||
45 | LTTNG_HIDDEN | |
c0a66c84 | 46 | ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *view, |
a58c490f JG |
47 | struct lttng_trigger **trigger); |
48 | ||
49 | LTTNG_HIDDEN | |
3647288f | 50 | int lttng_trigger_serialize(struct lttng_trigger *trigger, |
c0a66c84 | 51 | struct lttng_payload *payload); |
a58c490f | 52 | |
9b63a4aa JG |
53 | LTTNG_HIDDEN |
54 | const struct lttng_condition *lttng_trigger_get_const_condition( | |
55 | const struct lttng_trigger *trigger); | |
56 | ||
57 | LTTNG_HIDDEN | |
58 | const struct lttng_action *lttng_trigger_get_const_action( | |
59 | const struct lttng_trigger *trigger); | |
60 | ||
a58c490f JG |
61 | LTTNG_HIDDEN |
62 | bool lttng_trigger_validate(struct lttng_trigger *trigger); | |
63 | ||
85c06c44 JR |
64 | LTTNG_HIDDEN |
65 | bool lttng_trigger_is_equal( | |
66 | const struct lttng_trigger *a, const struct lttng_trigger *b); | |
67 | ||
f01d28b4 JR |
68 | LTTNG_HIDDEN |
69 | void lttng_trigger_get(struct lttng_trigger *trigger); | |
70 | ||
71 | LTTNG_HIDDEN | |
72 | void lttng_trigger_put(struct lttng_trigger *trigger); | |
73 | ||
3da864a9 JR |
74 | LTTNG_HIDDEN |
75 | const struct lttng_credentials *lttng_trigger_get_credentials( | |
76 | const struct lttng_trigger *trigger); | |
77 | ||
78 | LTTNG_HIDDEN | |
64eafdf6 | 79 | void lttng_trigger_set_credentials(struct lttng_trigger *trigger, |
3da864a9 JR |
80 | const struct lttng_credentials *creds); |
81 | ||
a58c490f | 82 | #endif /* LTTNG_TRIGGER_INTERNAL_H */ |