Cleanup: rename session list count to "next_uuid"
[lttng-tools.git] / src / bin / lttng-sessiond / consumer.h
CommitLineData
f1e16794
DG
1/*
2 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program 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 General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18#ifndef _CONSUMER_H
19#define _CONSUMER_H
20
21#include <semaphore.h>
22
23#include <common/consumer.h>
00e2e675
DG
24#include <lttng/lttng.h>
25
26enum consumer_dst_type {
27 CONSUMER_DST_LOCAL,
28 CONSUMER_DST_NET,
29};
f1e16794
DG
30
31struct consumer_data {
32 enum lttng_consumer_type type;
33
34 pthread_t thread; /* Worker thread interacting with the consumer */
35 sem_t sem;
36
37 /* Mutex to control consumerd pid assignation */
38 pthread_mutex_t pid_mutex;
39 pid_t pid;
40
41 int err_sock;
42 int cmd_sock;
43
44 /* consumer error and command Unix socket path */
45 char err_unix_sock_path[PATH_MAX];
46 char cmd_unix_sock_path[PATH_MAX];
47};
48
00e2e675
DG
49/*
50 * Network URIs
51 */
52struct consumer_net {
53 /*
54 * Indicate if URI type is set. Those flags should only be set when the
55 * created URI is done AND valid.
56 */
57 int control_isset;
58 int data_isset;
59
60 /*
61 * The following two URIs MUST have the same destination address for
62 * network streaming to work. Network hop are not yet supported.
63 */
64
65 /* Control path for network streaming. */
66 struct lttng_uri control;
67
68 /* Data path for network streaming. */
69 struct lttng_uri data;
70};
71
72/*
73 * Consumer output object describing where and how to send data.
74 */
75struct consumer_output {
76 /* Consumer socket file descriptor */
77 int sock;
78 /* If the consumer is enabled meaning that should be used */
79 unsigned int enabled;
80 enum consumer_dst_type type;
81 /*
82 * The net_seq_index is the index of the network stream on the consumer
83 * side. It's basically the relayd socket file descriptor value so the
84 * consumer can identify which streams goes with which socket.
85 */
86 int net_seq_index;
87 /*
88 * Subdirectory path name used for both local and network consumer.
89 */
90 char subdir[PATH_MAX];
91 union {
92 char trace_path[PATH_MAX];
93 struct consumer_net net;
94 } dst;
95};
96
97struct consumer_output *consumer_create_output(enum consumer_dst_type type);
98struct consumer_output *consumer_copy_output(struct consumer_output *obj);
99void consumer_destroy_output(struct consumer_output *obj);
100int consumer_set_network_uri(struct consumer_output *obj,
101 struct lttng_uri *uri);
102int consumer_send_fds(int sock, int *fds, size_t nb_fd);
103int consumer_send_stream(int sock, struct consumer_output *dst,
104 struct lttcomm_consumer_msg *msg, int *fds, size_t nb_fd);
105int consumer_send_channel(int sock, struct lttcomm_consumer_msg *msg);
106void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg,
107 enum lttng_consumer_command cmd,
108 int channel_key,
109 int stream_key,
110 uint32_t state,
111 enum lttng_event_output output,
112 uint64_t mmap_len,
113 uid_t uid,
114 gid_t gid,
115 int net_index,
116 unsigned int metadata_flag,
117 const char *name,
118 const char *pathname);
119void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg,
120 enum lttng_consumer_command cmd,
121 int channel_key,
122 uint64_t max_sb_size,
123 uint64_t mmap_len,
124 const char *name);
125
f1e16794 126#endif /* _CONSUMER_H */
This page took 0.067823 seconds and 4 git commands to generate.