2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
19 #define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
21 #include <lttng/notification/channel.h>
22 #include <common/macros.h>
23 #include <common/dynamic-buffer.h>
27 #include <urcu/list.h>
30 * Protocol version change log:
32 * - Initial implementation of the notification channel protocol,
33 * - Supported conditions are LOW/HIGH buffer usage conditions,
35 * - New condition type "LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE" added,
36 * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING" added,
37 * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED" added,
39 #define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
40 #define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 1
42 enum lttng_notification_channel_message_type
{
43 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN
= -1,
44 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE
= 0,
45 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE
= 1,
46 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE
= 2,
47 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY
= 3,
48 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION
= 4,
49 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED
= 5,
52 struct lttng_notification_channel_message
{
53 /* enum lttng_notification_channel_message_type */
55 /* Size of the payload following this field. */
60 struct lttng_notification_channel_command_handshake
{
65 struct lttng_notification_channel_command_reply
{
66 /* enum lttng_notification_channel_status */
70 struct pending_notification
{
71 /* NULL means "notification dropped". */
72 struct lttng_notification
*notification
;
73 struct cds_list_head node
;
77 * The notification channel protocol is bidirectional and accomodates
78 * synchronous and asynchronous communication modes:
80 * - Synchronous: commands emitted by the client to which a reply is expected
81 * (e.g. subscribing/unsubscribing to conditions),
82 * - Asynchronous: notifications which are sent by the lttng_endpoint to the
83 * client as one of the subscribed condition has occurred.
85 * The nature of this hybrid communication mode means that asynchronous messages
86 * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
87 * command and its reply).
89 * Notifications that are received between a command and its reply and enqueued
90 * in the pending_notifications list.
92 struct lttng_notification_channel
{
96 /* Count of pending notifications. */
98 /* List of struct pending_notification. */
99 struct cds_list_head list
;
100 } pending_notifications
;
101 struct lttng_dynamic_buffer reception_buffer
;
102 /* Sessiond notification protocol version. */
109 #endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */