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; | |
242388e4 | 29 | char *name; |
64eafdf6 JR |
30 | /* For now only the uid portion of the credentials is used. */ |
31 | struct lttng_credentials creds; | |
e6887944 JR |
32 | /* |
33 | * Internal use only. | |
34 | * The unique token passed to the tracer to identify an event-rule | |
35 | * notification. | |
36 | */ | |
37 | LTTNG_OPTIONAL(uint64_t) tracer_token; | |
a58c490f JG |
38 | }; |
39 | ||
40 | struct lttng_trigger_comm { | |
64eafdf6 JR |
41 | /* |
42 | * Credentials, only the uid portion is used for now. | |
43 | * Used as an override when desired by the root user. | |
44 | */ | |
45 | uint64_t uid; | |
242388e4 JR |
46 | /* |
47 | * Length of the variable length payload (name, condition, and | |
48 | * an action). | |
49 | */ | |
50 | uint32_t length; | |
51 | /* Includes '\0' terminator. */ | |
52 | uint32_t name_length; | |
53 | /* A null-terminated name, a condition, and an action follow. */ | |
a58c490f JG |
54 | char payload[]; |
55 | } LTTNG_PACKED; | |
56 | ||
57 | LTTNG_HIDDEN | |
c0a66c84 | 58 | ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *view, |
a58c490f JG |
59 | struct lttng_trigger **trigger); |
60 | ||
61 | LTTNG_HIDDEN | |
3647288f | 62 | int lttng_trigger_serialize(struct lttng_trigger *trigger, |
c0a66c84 | 63 | struct lttng_payload *payload); |
a58c490f | 64 | |
9b63a4aa JG |
65 | LTTNG_HIDDEN |
66 | const struct lttng_condition *lttng_trigger_get_const_condition( | |
67 | const struct lttng_trigger *trigger); | |
68 | ||
69 | LTTNG_HIDDEN | |
70 | const struct lttng_action *lttng_trigger_get_const_action( | |
71 | const struct lttng_trigger *trigger); | |
72 | ||
a58c490f JG |
73 | LTTNG_HIDDEN |
74 | bool lttng_trigger_validate(struct lttng_trigger *trigger); | |
75 | ||
242388e4 JR |
76 | LTTNG_HIDDEN |
77 | int lttng_trigger_assign_name( | |
78 | struct lttng_trigger *dst, const struct lttng_trigger *src); | |
79 | ||
e6887944 JR |
80 | LTTNG_HIDDEN |
81 | void lttng_trigger_set_tracer_token( | |
82 | struct lttng_trigger *trigger, uint64_t token); | |
83 | ||
84 | LTTNG_HIDDEN | |
85 | uint64_t lttng_trigger_get_tracer_token(const struct lttng_trigger *trigger); | |
86 | ||
242388e4 JR |
87 | LTTNG_HIDDEN |
88 | int lttng_trigger_generate_name(struct lttng_trigger *trigger, | |
89 | uint64_t unique_id); | |
90 | ||
85c06c44 JR |
91 | LTTNG_HIDDEN |
92 | bool lttng_trigger_is_equal( | |
93 | const struct lttng_trigger *a, const struct lttng_trigger *b); | |
94 | ||
f01d28b4 JR |
95 | LTTNG_HIDDEN |
96 | void lttng_trigger_get(struct lttng_trigger *trigger); | |
97 | ||
98 | LTTNG_HIDDEN | |
99 | void lttng_trigger_put(struct lttng_trigger *trigger); | |
100 | ||
3da864a9 JR |
101 | LTTNG_HIDDEN |
102 | const struct lttng_credentials *lttng_trigger_get_credentials( | |
103 | const struct lttng_trigger *trigger); | |
104 | ||
105 | LTTNG_HIDDEN | |
64eafdf6 | 106 | void lttng_trigger_set_credentials(struct lttng_trigger *trigger, |
3da864a9 JR |
107 | const struct lttng_credentials *creds); |
108 | ||
a58c490f | 109 | #endif /* LTTNG_TRIGGER_INTERNAL_H */ |