| 1 | /* |
| 2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_CONDITION_INTERNAL_H |
| 9 | #define LTTNG_CONDITION_INTERNAL_H |
| 10 | |
| 11 | #include <lttng/condition/condition.h> |
| 12 | #include <common/macros.h> |
| 13 | #include <common/payload-view.h> |
| 14 | #include <common/payload.h> |
| 15 | #include <stdbool.h> |
| 16 | #include <urcu/list.h> |
| 17 | #include <urcu/ref.h> |
| 18 | #include <stdint.h> |
| 19 | #include <sys/types.h> |
| 20 | |
| 21 | typedef void (*condition_destroy_cb)(struct lttng_condition *condition); |
| 22 | typedef bool (*condition_validate_cb)(const struct lttng_condition *condition); |
| 23 | typedef int (*condition_serialize_cb)( |
| 24 | const struct lttng_condition *condition, |
| 25 | struct lttng_payload *payload); |
| 26 | typedef bool (*condition_equal_cb)(const struct lttng_condition *a, |
| 27 | const struct lttng_condition *b); |
| 28 | typedef ssize_t (*condition_create_from_payload_cb)( |
| 29 | struct lttng_payload_view *view, |
| 30 | struct lttng_condition **condition); |
| 31 | |
| 32 | struct lttng_condition { |
| 33 | /* Reference counting is only exposed to internal users. */ |
| 34 | struct urcu_ref ref; |
| 35 | enum lttng_condition_type type; |
| 36 | condition_validate_cb validate; |
| 37 | condition_serialize_cb serialize; |
| 38 | condition_equal_cb equal; |
| 39 | condition_destroy_cb destroy; |
| 40 | }; |
| 41 | |
| 42 | struct lttng_condition_comm { |
| 43 | /* enum lttng_condition_type */ |
| 44 | int8_t condition_type; |
| 45 | char payload[]; |
| 46 | }; |
| 47 | |
| 48 | LTTNG_HIDDEN |
| 49 | void lttng_condition_get(struct lttng_condition *condition); |
| 50 | |
| 51 | LTTNG_HIDDEN |
| 52 | void lttng_condition_put(struct lttng_condition *condition); |
| 53 | |
| 54 | LTTNG_HIDDEN |
| 55 | void lttng_condition_init(struct lttng_condition *condition, |
| 56 | enum lttng_condition_type type); |
| 57 | |
| 58 | LTTNG_HIDDEN |
| 59 | bool lttng_condition_validate(const struct lttng_condition *condition); |
| 60 | |
| 61 | LTTNG_HIDDEN |
| 62 | ssize_t lttng_condition_create_from_payload( |
| 63 | struct lttng_payload_view *view, |
| 64 | struct lttng_condition **condition); |
| 65 | |
| 66 | LTTNG_HIDDEN |
| 67 | int lttng_condition_serialize(const struct lttng_condition *condition, |
| 68 | struct lttng_payload *payload); |
| 69 | |
| 70 | LTTNG_HIDDEN |
| 71 | bool lttng_condition_is_equal(const struct lttng_condition *a, |
| 72 | const struct lttng_condition *b); |
| 73 | |
| 74 | LTTNG_HIDDEN |
| 75 | const char *lttng_condition_type_str(enum lttng_condition_type type); |
| 76 | |
| 77 | #endif /* LTTNG_CONDITION_INTERNAL_H */ |