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>
29 #define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
30 #define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 0
32 enum lttng_notification_channel_message_type
{
33 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN
= -1,
34 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE
= 0,
35 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE
= 1,
36 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE
= 2,
37 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY
= 3,
38 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION
= 4,
39 LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED
= 5,
42 struct lttng_notification_channel_message
{
43 /* enum lttng_notification_channel_message_type */
45 /* Size of the payload following this field. */
50 struct lttng_notification_channel_command_handshake
{
55 struct lttng_notification_channel_command_reply
{
56 /* enum lttng_notification_channel_status */
60 struct pending_notification
{
61 /* NULL means "notification dropped". */
62 struct lttng_notification
*notification
;
63 struct cds_list_head node
;
67 * The notification channel protocol is bidirectional and accomodates
68 * synchronous and asynchronous communication modes:
70 * - Synchronous: commands emitted by the client to which a reply is expected
71 * (e.g. subscribing/unsubscribing to conditions),
72 * - Asynchronous: notifications which are sent by the lttng_endpoint to the
73 * client as one of the subscribed condition has occurred.
75 * The nature of this hybrid communication mode means that asynchronous messages
76 * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
77 * command and its reply).
79 * Notifications that are received between a command and its reply and enqueued
80 * in the pending_notifications list.
82 struct lttng_notification_channel
{
86 /* Count of pending notifications. */
88 /* List of struct pending_notification. */
89 struct cds_list_head list
;
90 } pending_notifications
;
91 struct lttng_dynamic_buffer reception_buffer
;
92 /* Sessiond notification protocol version. */
99 #endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */