b7299a5aa256ac7d22bc7bc90bf938a6edaec8bb
[lttng-tools.git] / src / bin / lttng-relayd / cmd-2-2.c
1 /*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #define _GNU_SOURCE
20 #include <assert.h>
21 #include <string.h>
22
23 #include <common/common.h>
24 #include <common/sessiond-comm/relayd.h>
25
26 #include "cmd-generic.h"
27 #include "cmd-2-1.h"
28 #include "utils.h"
29
30 int cmd_recv_stream_2_2(struct relay_connection *conn,
31 struct relay_stream *stream)
32 {
33 int ret;
34 struct lttcomm_relayd_add_stream_2_2 stream_info;
35
36 assert(conn);
37 assert(stream);
38
39 ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info));
40 if (ret < 0) {
41 ERR("Unable to recv stream version 2.2");
42 goto error;
43 }
44
45 stream->path_name = create_output_path(stream_info.pathname);
46 if (stream->path_name == NULL) {
47 PERROR("Path name allocation");
48 ret = -ENOMEM;
49 goto error;
50 }
51
52 stream->channel_name = strdup(stream_info.channel_name);
53 if (stream->channel_name == NULL) {
54 ret = -errno;
55 PERROR("Path name allocation");
56 goto error;
57 }
58
59 stream->tracefile_size = be64toh(stream_info.tracefile_size);
60 stream->tracefile_count = be64toh(stream_info.tracefile_count);
61 ret = 0;
62
63 error:
64 return ret;
65 }
This page took 0.029165 seconds and 3 git commands to generate.