Typo: occured -> occurred
[lttng-tools.git] / include / lttng / notification / channel-internal.h
CommitLineData
a58c490f
JG
1/*
2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
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.
7 *
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
11 * for more details.
12 *
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
16 */
17
18#ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
19#define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
20
21#include <lttng/notification/channel.h>
22#include <common/macros.h>
23#include <common/dynamic-buffer.h>
24#include <stdint.h>
25#include <stdbool.h>
26#include <pthread.h>
27#include <urcu/list.h>
28
29#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
30#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 0
31
32enum 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,
40};
41
42struct lttng_notification_channel_message {
43 /* enum lttng_notification_channel_message_type */
44 int8_t type;
45 /* Size of the payload following this field. */
46 uint32_t size;
47 char payload[];
48} LTTNG_PACKED;
49
50struct lttng_notification_channel_command_handshake {
51 uint8_t major;
52 uint8_t minor;
53} LTTNG_PACKED;
54
55struct lttng_notification_channel_command_reply {
56 /* enum lttng_notification_channel_status */
57 int8_t status;
58} LTTNG_PACKED;
59
60struct pending_notification {
61 /* NULL means "notification dropped". */
62 struct lttng_notification *notification;
63 struct cds_list_head node;
64};
65
66/*
67 * The notification channel protocol is bidirectional and accomodates
68 * synchronous and asynchronous communication modes:
69 *
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
4149ace8 73 * client as one of the subscribed condition has occurred.
a58c490f
JG
74 *
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).
78 *
79 * Notifications that are received between a command and its reply and enqueued
80 * in the pending_notifications list.
81 */
82struct lttng_notification_channel {
83 pthread_mutex_t lock;
84 int socket;
85 struct {
86 /* Count of pending notifications. */
87 unsigned int count;
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. */
93 struct {
94 bool set;
95 int8_t major, minor;
96 } version;
97};
98
99#endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */
This page took 0.028232 seconds and 5 git commands to generate.