2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
9 #define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
11 #include <common/macros.hpp>
12 #include <common/make-unique-wrapper.hpp>
13 #include <common/payload.hpp>
15 #include <lttng/notification/channel.h>
20 #include <urcu/list.h>
23 * Protocol version change log:
25 * - Initial implementation of the notification channel protocol,
26 * - Supported conditions are LOW/HIGH buffer usage conditions,
28 * - New condition type "LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE" added,
29 * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING" added,
30 * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED" added,
32 #define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
33 #define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 1
35 enum lttng_notification_channel_message_type {
36 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN = -1,
37 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE = 0,
38 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE = 1,
39 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE = 2,
40 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY = 3,
41 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION = 4,
42 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED = 5,
45 struct lttng_notification_channel_message {
46 /* enum lttng_notification_channel_message_type */
48 /* Size of the payload following this field. */
50 /* Number of FDs sent. */
55 struct lttng_notification_channel_command_handshake {
60 struct lttng_notification_channel_command_reply {
61 /* enum lttng_notification_channel_status */
65 struct pending_notification {
66 /* NULL means "notification dropped". */
67 struct lttng_notification *notification;
68 struct cds_list_head node;
72 * The notification channel protocol is bidirectional and accommodates
73 * synchronous and asynchronous communication modes:
75 * - Synchronous: commands emitted by the client to which a reply is expected
76 * (e.g. subscribing/unsubscribing to conditions),
77 * - Asynchronous: notifications which are sent by the lttng_endpoint to the
78 * client as one of the subscribed condition has occurred.
80 * The nature of this hybrid communication mode means that asynchronous messages
81 * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
82 * command and its reply).
84 * Notifications that are received between a command and its reply and enqueued
85 * in the pending_notifications list.
87 struct lttng_notification_channel {
88 using uptr = std::unique_ptr<
89 lttng_notification_channel,
90 lttng::memory::create_deleter_class<lttng_notification_channel,
91 lttng_notification_channel_destroy>::deleter>;
96 /* Count of pending notifications. */
98 /* List of struct pending_notification. */
99 struct cds_list_head list;
100 } pending_notifications;
101 struct lttng_payload reception_payload;
102 /* Sessiond notification protocol version. */
109 #endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */