Commit | Line | Data |
---|---|---|
0f907de1 JD |
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 | ||
f263b7fd JD |
26 | #include <common/compat/endian.h> |
27 | ||
0f907de1 JD |
28 | #include "cmd-generic.h" |
29 | #include "cmd-2-1.h" | |
30 | #include "utils.h" | |
31 | ||
58eb9381 DG |
32 | int cmd_recv_stream_2_2(struct relay_connection *conn, |
33 | struct relay_stream *stream) | |
0f907de1 JD |
34 | { |
35 | int ret; | |
36 | struct lttcomm_relayd_add_stream_2_2 stream_info; | |
37 | ||
58eb9381 | 38 | assert(conn); |
0f907de1 JD |
39 | assert(stream); |
40 | ||
58eb9381 | 41 | ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info)); |
0f907de1 JD |
42 | if (ret < 0) { |
43 | ERR("Unable to recv stream version 2.2"); | |
44 | goto error; | |
45 | } | |
46 | ||
47 | stream->path_name = create_output_path(stream_info.pathname); | |
48 | if (stream->path_name == NULL) { | |
49 | PERROR("Path name allocation"); | |
50 | ret = -ENOMEM; | |
51 | goto error; | |
52 | } | |
53 | ||
54 | stream->channel_name = strdup(stream_info.channel_name); | |
55 | if (stream->channel_name == NULL) { | |
56 | ret = -errno; | |
57 | PERROR("Path name allocation"); | |
58 | goto error; | |
59 | } | |
60 | ||
61 | stream->tracefile_size = be64toh(stream_info.tracefile_size); | |
62 | stream->tracefile_count = be64toh(stream_info.tracefile_count); | |
63 | ret = 0; | |
64 | ||
65 | error: | |
66 | return ret; | |
67 | } |